Skip to content

Interface: SyncFormulaDef<K, L, ParamDefsT, SchemaT, ContextT, PermissionsContextT>

Defined in: api.ts:1376

Inputs for creating the formula that implements a sync table.

Extends

Type Parameters

Type Parameter
K extends string
L extends string
ParamDefsT extends ParamDefs
SchemaT extends ObjectSchemaDefinition<K, L>
ContextT extends SyncExecutionContext<any, any>
PermissionsContextT extends SyncPassthroughData

Properties

cacheTtlSecs?

readonly optional cacheTtlSecs: number

Defined in: api_types.ts:547

How long formulas running with the same values should cache their results for.

Inherited from

CommonPackFormulaDef.cacheTtlSecs


connectionRequirement?

readonly optional connectionRequirement: ConnectionRequirement

Defined in: api_types.ts:539

Does this formula require a connection (aka an account)?

Inherited from

CommonPackFormulaDef.connectionRequirement


description

readonly description: string

Defined in: api_types.ts:508

A brief description of what the formula does.

Inherited from

CommonPackFormulaDef.description


examples?

readonly optional examples: object[]

Defined in: api_types.ts:528

Sample inputs and outputs demonstrating usage of this formula.

params

params: (PackFormulaValue | undefined)[]

result

result: PackFormulaResult

Inherited from

CommonPackFormulaDef.examples


extraOAuthScopes?

readonly optional extraOAuthScopes: string[]

Defined in: api_types.ts:569

OAuth scopes that the formula needs that weren't requested in the pack's overall authentication config. For example, a Slack pack can have one formula that needs admin privileges, but non-admins can use the bulk of the pack without those privileges. Coda will give users help in understanding that they need additional authentication to use a formula with extra OAuth scopes. Note that these scopes will always be requested in addition to the default scopes for the pack, so an end user must have both sets of permissions.

Inherited from

CommonPackFormulaDef.extraOAuthScopes


instructions?

readonly optional instructions: string

Defined in: api_types.ts:513

Instructions for LLMs to use the formula, overrides the description for LLMs if set.

Inherited from

CommonPackFormulaDef.instructions


isAction?

readonly optional isAction: boolean

Defined in: api_types.ts:534

Does this formula take an action (vs retrieve data or make a calculation)? Actions are presented as buttons in the Coda UI.

Inherited from

CommonPackFormulaDef.isAction


isExperimental?

readonly optional isExperimental: boolean

Defined in: api_types.ts:553

If specified, the formula will not be suggested to users in Coda's formula autocomplete. The formula can still be invoked by manually typing its full name.

Inherited from

CommonPackFormulaDef.isExperimental


isSystem?

readonly optional isSystem: boolean

Defined in: api_types.ts:559

Whether this is a formula that will be used by Coda internally and not exposed directly to users. Not for use by packs that are not authored by Coda.

Inherited from

CommonPackFormulaDef.isSystem


maxUpdateBatchSize?

optional maxUpdateBatchSize: number

Defined in: api.ts:1401

If the table supports object updates, the maximum number of objects that will be sent to the pack in a single batch. Defaults to 1 if not specified.


name

readonly name: string

Defined in: api_types.ts:503

The name of the formula, used to invoke it.

Inherited from

CommonPackFormulaDef.name


network?

readonly optional network: Network

Defined in: api_types.ts:542

Deprecated

use isAction and connectionRequirement instead

Inherited from

CommonPackFormulaDef.network


parameters

readonly parameters: ParamDefsT

Defined in: api_types.ts:518

The parameter inputs to the formula, if any.

Inherited from

CommonPackFormulaDef.parameters


validateParameters?

optional validateParameters: MetadataFormula<SyncExecutionContext<Continuation, Continuation, Continuation>, ParameterValidationResult>

Defined in: api.ts:1450

The JavaScript function that implements parameter validation. For sync tables, the execution context will include a sync field.

Overrides

CommonPackFormulaDef.validateParameters


varargParameters?

readonly optional varargParameters: ParamDefs

Defined in: api_types.ts:523

Variable argument parameters, used if this formula should accept arbitrary numbers of inputs.

Inherited from

CommonPackFormulaDef.varargParameters

Methods

execute()

execute<ContextReturnT>(params, context): Promise<SyncFormulaResult<K, L, SchemaT, ContextReturnT, PermissionsContextT>>

Defined in: api.ts:1392

The JavaScript function that implements this sync.

This function takes in parameters and a sync context which may have a continuation from a previous invocation, and fetches and returns one page of results, as well as another continuation if there are more result to fetch.

Type Parameters

Type Parameter
ContextReturnT extends SyncExecutionContext<any, any, any>

Parameters

Parameter Type
params ParamValues<ParamDefsT>
context ContextT

Returns

Promise<SyncFormulaResult<K, L, SchemaT, ContextReturnT, PermissionsContextT>>


executeUpdate()?

optional executeUpdate(params, updates, context): Promise<SyncUpdateResult<K, L, SchemaT>>

Defined in: api.ts:1409

The JavaScript function that implements this sync update if the table supports updates.

This function takes in parameters, updated sync table objects, and a sync context, and is responsible for pushing those updated objects to the external system then returning the new state of each object.

Parameters

Parameter Type
params ParamValues<ParamDefsT>
updates SyncUpdate<K, L, SchemaT>[]
context UpdateSyncExecutionContext

Returns

Promise<SyncUpdateResult<K, L, SchemaT>>


onError()?

optional onError(error): any

Defined in: api.ts:1697

If specified, will catch errors in the execute function and call this function with the error, instead of letting them throw and the formula failing.

This is helpful for writing common error handling into a singular helper function that can then be applied to many different formulas in a pack.

Parameters

Parameter Type
error Error

Returns

any

Inherited from

OnErrorFormulaOptions.onError