Skip to content

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

Defined in: api.ts:2382

Options provided when defining a dynamic sync table.

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

connectionRequirement?

optional connectionRequirement: ConnectionRequirement

Defined in: api.ts:2454

A ConnectionRequirement that will be used for all formulas contained within this sync table (including autocomplete formulas).


defaultAddDynamicColumns?

optional defaultAddDynamicColumns: boolean

Defined in: api.ts:2470

Default is true.

If false, when subsequent syncs discover new schema properties, these properties will not automatically be added as new columns on the table. The user can still manually add columns for these new properties. This only applies to tables that use dynamic schemas.

When tables with dynamic schemas are synced, the getSchema formula is run each time, which may return a schema that is different than that from the last sync. The default behavior is that any schema properties that are new in this sync are automatically added as new columns, so they are apparent to the user. However, in rare cases when schemas change frequently, this can cause the number of columns to grow quickly and become overwhelming. Setting this value to false leaves the columns unchanged and puts the choice of what columns to display into the hands of the user.


description?

optional description: string

Defined in: api.ts:2403

The description of the dynamic sync table. This is shown to users in the Coda UI when listing what build blocks are contained within this pack. This should describe what the dynamic sync table does in a more detailed language.


entityName?

optional entityName: string

Defined in: api.ts:2449

A label for the kind of entities that you are syncing. This label is used in a doc to identify the column in this table that contains the synced data. If you don't provide an entityName, the value of identity.name from your schema will be used instead, so in most cases you don't need to provide this.


formula

formula: FormulaOptions<ParamDefsT, SyncFormulaDef<K, L, ParamDefsT, SchemaT, ContextT, PermissionsContextT>>

Defined in: api.ts:2443

The definition of the formula that implements this sync. This is a Coda packs formula that returns an array of objects fitting the given schema and optionally a Continuation. (The SyncFormulaDef.name is redundant and should be the same as the name parameter here. These will eventually be consolidated.)


getDisplayUrl

getDisplayUrl: MetadataFormulaDef<ContextT>

Defined in: api.ts:2426

A formula that that returns a browser-friendly url representing the resource being synced. The Coda UI links to this url as the source of the table data. This is typically a browser-friendly form of the dynamicUrl, which is typically an API url.


getName

getName: MetadataFormulaDef<ContextT>

Defined in: api.ts:2407

A formula that returns the name of this table.


getSchema

getSchema: MetadataFormulaDef<ContextT>

Defined in: api.ts:2419

A formula that returns the schema for this table.


identityName

identityName: string

Defined in: api.ts:2415

See SyncTableOptions.identityName for an introduction.

Every dynamic schema generated from this dynamic sync table definition should all use the same name for their identity. Code that refers to objects in these tables will use the dynamicUrl to differentiate which exact table to use.


listDynamicUrls?

optional listDynamicUrls: MetadataFormulaDef<ExecutionContext, LegacyDefaultMetadataReturnType>

Defined in: api.ts:2431

A formula that returns a list of available dynamic urls that can be used to create an instance of this dynamic sync table.


name

name: string

Defined in: api.ts:2397

The name of the dynamic sync table. This is shown to users in the Coda UI when listing what build blocks are contained within this pack. This should describe the category of entities being synced. The actual table name once added to the doc will be dynamic, it will be whatever value is returned by the getName formula.


placeholderSchema?

optional placeholderSchema: SchemaT

Defined in: api.ts:2477

Optional placeholder schema before the dynamic schema is retrieved.

If defaultAddDynamicColumns is false, only featured columns in placeholderSchema will be rendered by default after the sync.


propertyOptions?

optional propertyOptions: PropertyOptionsMetadataFunction<any>

Defined in: api.ts:2511

An options function to use for any dynamic schema properties. The name of the property that's being modified by the doc editor is available in the option function's context parameter.

Example

coda.makeDynamicSyncTable({
  name: "MySyncTable",
  getSchema: async function (context) => {
    return coda.makeObjectSchema({
      properties: {
        dynamicPropertyName: {
          type: coda.ValueType.String,
          codaType: coda.ValueHintType.SelectList,
          mutable: true,
          options: coda.OptionsType.Dynamic,
        },
      },
    });
  },
  propertyOptions: async function (context) => {
    if (context.propertyName === "dynamicPropertyName") {
      return ["Dynamic Value 1", "Dynamic value 2"];
    }
    throw new coda.UserVisibleError(
      `Cannot generate options for property ${context.propertyName}`
    );
  },
  ...

searchDynamicUrls?

optional searchDynamicUrls: MetadataFormulaDef<ExecutionContext, LegacyDefaultMetadataReturnType>

Defined in: api.ts:2436

A formula that returns a list of available dynamic urls that match a given search query that can be used to create an instance of this dynamic sync table.