Skip to content

Commit

Permalink
add supportsIncrementalSync in ParamDef to support incremental sync (#…
Browse files Browse the repository at this point in the history
…2975)

* add supportsIncrementalSync

* update version to prerelease
  • Loading branch information
ebo-codaio authored Jul 1, 2024
1 parent cbcff0f commit 38bbde8
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 3 deletions.
8 changes: 8 additions & 0 deletions api_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ export interface ParamDef<T extends UnionType> {
// TODO(patrick): Unhide this
/** @hidden */
crawlStrategy?: CrawlStrategy;

/**
* Whether this parameter is compatible with incremental sync.
* If not, it will be hidden from the Coda Brain setup UI.
*/
// TODO(ebo): Unhide this
/** @hidden */
supportsIncrementalSync?: boolean;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions dist/api_types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/bundle.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion dist/testing/upload_validation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codahq/packs-sdk",
"version": "1.7.8",
"version": "1.7.8-prerelease.1",
"license": "MIT",
"workspaces": [
"dev/eslint"
Expand Down
31 changes: 31 additions & 0 deletions test/upload_validation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4471,6 +4471,37 @@ describe('Pack metadata Validation', async () => {
},
]);
});

it('rejects required param does not support incremental sync', async () => {
const formula = makeFormula({
resultType: ValueType.String,
name: 'Hi',
description: 'A',
examples: [],
parameters: [
makeParameter({
type: ParameterType.String,
name: 'myParam',
description: '',
optional: false,
supportsIncrementalSync: false,
}),
],
execute: () => '',
});

const metadata = createFakePackVersionMetadata({
formulas: [formula],
formulaNamespace: 'MyNamespace',
});
const err = await validateJsonAndAssertFails(metadata);
assert.deepEqual(err.validationErrors, [
{
message: `Required params should support incremental sync.`,
path: 'formulas[0].parameters[0]',
},
]);
});
});

describe('deprecation warnings', () => {
Expand Down
8 changes: 7 additions & 1 deletion testing/upload_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,13 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): {
defaultValue: z.unknown().optional(),
suggestedValue: z.unknown().optional(),
crawlStrategy: z.unknown().optional(),
});
supportsIncrementalSync: z.boolean().optional().default(true),
}).refine(
param => {
return param.optional || param.supportsIncrementalSync;
},
{message: 'Required params should support incremental sync.'},
);

const commonPackFormulaSchema = {
// It would be preferable to use validateFormulaName here, but we have to exempt legacy packs with sync tables
Expand Down

0 comments on commit 38bbde8

Please sign in to comment.