Skip to content

Class: PackDefinitionBuilder

A class that assists in constructing a pack definition. Use newPack to create one.

Implements

Constructors

constructor

new PackDefinitionBuilder(definition?)

Constructs a PackDefinitionBuilder. However, coda.newPack() should be used instead rather than constructing a builder directly.

Parameters

Name Type
definition? Partial<PackVersionDefinition>

Defined in

builder.ts:85

Properties

defaultAuthentication

Optional defaultAuthentication: Authentication

See PackVersionDefinition.defaultAuthentication.

Implementation of

BasicPackDefinition.defaultAuthentication

Defined in

builder.ts:66


formats

formats: Format[]

See PackVersionDefinition.formats.

Implementation of

BasicPackDefinition.formats

Defined in

builder.ts:53


formulaNamespace

Optional formulaNamespace: string

deprecated

Implementation of

BasicPackDefinition.formulaNamespace

Defined in

builder.ts:77


formulas

formulas: (BooleanPackFormula<ParamDefs> | NumericPackFormula<ParamDefs> | StringPackFormula<ParamDefs> | ObjectPackFormula<ParamDefs, ArraySchema<Schema>> | ObjectPackFormula<ParamDefs, Schema>)[]

See PackVersionDefinition.formulas.

Implementation of

BasicPackDefinition.formulas

Defined in

builder.ts:49


networkDomains

networkDomains: string[]

See PackVersionDefinition.networkDomains.

Implementation of

BasicPackDefinition.networkDomains

Defined in

builder.ts:61


syncTables

syncTables: SyncTable[]

See PackVersionDefinition.syncTables.

Implementation of

BasicPackDefinition.syncTables

Defined in

builder.ts:57


systemConnectionAuthentication

Optional systemConnectionAuthentication: SystemAuthentication

See PackVersionDefinition.systemConnectionAuthentication.

Implementation of

BasicPackDefinition.systemConnectionAuthentication

Defined in

builder.ts:70


version

Optional version: string

See PackVersionDefinition.version.

Defined in

builder.ts:75

Methods

addColumnFormat

addColumnFormat(format): PackDefinitionBuilder

Adds a column format definition to this pack.

In the web editor, the /ColumnFormat shortcut will insert a snippet of a skeleton format.

example

pack.addColumnFormat({
  name: 'MyColumn',
  formulaName: 'MyFormula',
});

Parameters

Name Type
format Format

Returns

PackDefinitionBuilder

Defined in

builder.ts:231


addDynamicSyncTable

addDynamicSyncTable<K, L, ParamDefsT, SchemaT>(definition): PackDefinitionBuilder

Adds a dynamic sync table definition to this pack.

In the web editor, the /DynamicSyncTable shortcut will insert a snippet of a skeleton sync table.

example

pack.addDynamicSyncTable({
  name: "MySyncTable",
  getName: async funciton (context) => {
    const response = await context.fetcher.fetch({method: "GET", url: context.sync.dynamicUrl});
    return response.body.name;
  },
  getName: async function (context) => {
    const response = await context.fetcher.fetch({method: "GET", url: context.sync.dynamicUrl});
    return response.body.browserLink;
  },
  ...
});

Type parameters

Name Type
K extends string
L extends string
ParamDefsT extends ParamDefs
SchemaT extends ObjectSchemaDefinition<K, L, SchemaT>

Parameters

Name Type
definition DynamicSyncTableOptions<K, L, ParamDefsT, SchemaT>

Returns

PackDefinitionBuilder

Defined in

builder.ts:204


addFormula

addFormula<ParamDefsT, ResultT, SchemaT>(definition): PackDefinitionBuilder

Adds a formula definition to this pack.

In the web editor, the /Formula shortcut will insert a snippet of a skeleton formula.

example

pack.addFormula({
  resultType: ValueType.String,
   name: 'MyFormula',
   description: 'My description.',
   parameters: [
     makeParameter({
       type: ParameterType.String,
       name: 'myParam',
       description: 'My param description.',
     }),
   ],
   execute: async ([param]) => {
     return `Hello ${param}`;
   },
});

Type parameters

Name Type
ParamDefsT extends ParamDefs
ResultT extends ValueType
SchemaT extends Schema

Parameters

Name Type
definition { resultType: ResultT } & FormulaDefinition<ParamDefsT, ResultT, SchemaT>

Returns

PackDefinitionBuilder

Defined in

builder.ts:130


addNetworkDomain

addNetworkDomain(...domain): PackDefinitionBuilder

Adds the domain that this pack makes HTTP requests to. For example, if your pack makes HTTP requests to "api.example.com", use "example.com" as your network domain.

If your pack make HTTP requests, it must declare a network domain, for security purposes. Coda enforces that your pack cannot make requests to any undeclared domains.

You are allowed one network domain per pack by default. If your pack needs to connect to multiple domains, contact Coda Support for approval.

example

pack.addNetworkDomain('example.com');

Parameters

Name Type
...domain string[]

Returns

PackDefinitionBuilder

Defined in

builder.ts:339


addSyncTable

addSyncTable<K, L, ParamDefsT, SchemaT>(__namedParameters): PackDefinitionBuilder

Adds a sync table definition to this pack.

In the web editor, the /SyncTable shortcut will insert a snippet of a skeleton sync table.

example

pack.addSyncTable({
  name: 'MySyncTable',
  identityName: 'EntityName',
  schema: coda.makeObjectSchema({
    ...
  }),
  formula: {
    ...
  },
});

Type parameters

Name Type
K extends string
L extends string
ParamDefsT extends ParamDefs
SchemaT extends ObjectSchema<K, L, SchemaT>

Parameters

Name Type
__namedParameters SyncTableOptions<K, L, ParamDefsT, SchemaT>

Returns

PackDefinitionBuilder

Defined in

builder.ts:160


setSystemAuthentication

setSystemAuthentication(systemAuthentication): PackDefinitionBuilder

Sets this pack to use authentication provided by you as the maker of this pack.

You will need to register credentials to use with this pack. When users use the pack, their requests will be authenticated with those system credentials, they need not register their own account.

In the web editor, the /SystemAuthentication shortcut will insert a snippet of a skeleton authentication definition.

example

pack.setSystemAuthentication({
  type: AuthenticationType.HeaderBearerToken,
});

Parameters

Name Type
systemAuthentication SystemAuthenticationDef

Returns

PackDefinitionBuilder

Defined in

builder.ts:300


setUserAuthentication

setUserAuthentication(authDef): PackDefinitionBuilder

Sets this pack to use authentication for individual users, using the authentication method is the given definition.

Each user will need to register an account in order to use this pack.

In the web editor, the /UserAuthentication shortcut will insert a snippet of a skeleton authentication definition.

By default, this will set a default connection (account) requirement, making a user account required to invoke all formulas in this pack unless you specify differently on a particular formula. To change the default, you can pass a defaultConnectionRequirement option into this method.

example

pack.setUserAuthentication({
  type: AuthenticationType.HeaderBearerToken,
});

Parameters

Name Type
authDef NoAuthentication & { defaultConnectionRequirement?: ConnectionRequirement } & VariousAuthentication & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<HeaderBearerTokenAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<CodaApiBearerTokenAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<CustomHeaderTokenAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<QueryParamTokenAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<MultiQueryParamTokenAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<OAuth2Authentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<WebBasicAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<AWSAccessKeyAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<AWSAssumeRoleAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement } & Omit<CustomAuthentication, "getConnectionName" | "getConnectionUserId" | "postSetup"> & { getConnectionName?: MetadataFormulaDef ; getConnectionUserId?: MetadataFormulaDef ; postSetup?: SetEndpointDef[] } & { defaultConnectionRequirement?: ConnectionRequirement }

Returns

PackDefinitionBuilder

Defined in

builder.ts:257


setVersion

setVersion(version): PackDefinitionBuilder

Sets the semantic version of this pack version, e.g. '1.2.3'.

This is optional, and you only need to provide a version if you are manually doing semantic versioning, or using the CLI. If using the web editor, you can omit this and the web editor will automatically provide an appropriate semantic version each time you build a version.

example

pack.setVersion('1.2.3');

Parameters

Name Type
version string

Returns

PackDefinitionBuilder

Defined in

builder.ts:357