Interface: PackFormulaDef<ParamsT, ResultT, ContextT>¶
Defined in: api.ts:971
Base type for the inputs for creating a pack formula.
Extends¶
CommonPackFormulaDef<ParamsT>
Extended by¶
Type Parameters¶
| Type Parameter | Default type |
|---|---|
ParamsT extends ParamDefs |
- |
ResultT extends PackFormulaResult |
- |
ContextT extends ExecutionContext |
ExecutionContext |
Properties¶
cacheTtlSecs?¶
readonlyoptionalcacheTtlSecs: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?¶
readonlyoptionalconnectionRequirement:ConnectionRequirement
Defined in: api_types.ts:539
Does this formula require a connection (aka an account)?
Inherited from¶
CommonPackFormulaDef.connectionRequirement
description¶
readonlydescription:string
Defined in: api_types.ts:508
A brief description of what the formula does.
Inherited from¶
CommonPackFormulaDef.description
examples?¶
readonlyoptionalexamples: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¶
extraOAuthScopes?¶
readonlyoptionalextraOAuthScopes: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?¶
readonlyoptionalinstructions: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?¶
readonlyoptionalisAction: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¶
isExperimental?¶
readonlyoptionalisExperimental: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?¶
readonlyoptionalisSystem: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¶
name¶
readonlyname:string
Defined in: api_types.ts:503
The name of the formula, used to invoke it.
Inherited from¶
network?¶
readonlyoptionalnetwork:Network
Defined in: api_types.ts:542
Deprecated¶
use isAction and connectionRequirement instead
Inherited from¶
parameters¶
readonlyparameters:ParamsT
Defined in: api_types.ts:518
The parameter inputs to the formula, if any.
Inherited from¶
CommonPackFormulaDef.parameters
validateParameters?¶
optionalvalidateParameters:MetadataFormula<ExecutionContext,ParameterValidationResult>
Defined in: api_types.ts:613
The JavaScript function that implements parameter validation. This is only allowed on sync formulas.
This function takes in parameters and a context containing a PermissionSyncMode and validates the parameters. A formula may want to validate parameters differently for permissionSyncMode 'PermissionAware' vs 'Personal' vs undefined (which represents a formula).
Example¶
validateParameters: async function (context, _, params) {
let {quantity, sku} = ensureExists(params);
let errors = [];
if (quantity < 0) {
errors.push({message: "Must be a positive number.", propertyName: "quantity"});
}
if (!isValidSku(context, sku)) {
errors.push({message: `Product SKU not found.`, propertyName: "sku"});
}
if (errors.length > 0) {
return {
isValid: false,
message: "Invalid parameter values.",
errors,
};
}
return {
isValid: true,
};
},
Returns¶
Inherited from¶
CommonPackFormulaDef.validateParameters
varargParameters?¶
readonlyoptionalvarargParameters: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(
params,context):ResultT|Promise<ResultT>
Defined in: api.ts:977
The JavaScript function that implements this formula
Parameters¶
| Parameter | Type |
|---|---|
params |
ParamValues<ParamsT> |
context |
ContextT |
Returns¶
ResultT | Promise<ResultT>