diff --git a/CHANGELOG.md b/CHANGELOG.md index aa637bfddf..e8c9c51689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This changelog keeps track of all changes to the Packs SDK. We follow convention ## [Unreleased] +### Changed + +- Added internal fields to sync formulas and identity + ## [1.7.10] - 2024-08-21 ### Added @@ -726,7 +730,5 @@ await myHelper(context); [0.9.0]: https://github.com/coda/packs-sdk/compare/v0.8.2...v0.9.0 [1.7.7]: https://github.com/coda/packs-sdk/compare/v1.7.1...v1.7.7 [1.7.8]: https://github.com/coda/packs-sdk/compare/v1.7.1...v1.7.8 - [1.7.9]: https://github.com/coda/packs-sdk/compare/v1.7.8...v1.7.9 - [1.7.10]: https://github.com/coda/packs-sdk/compare/v1.7.8...v1.7.10 diff --git a/dist/bundle.d.ts b/dist/bundle.d.ts index c19e468388..cac28fe3d5 100644 --- a/dist/bundle.d.ts +++ b/dist/bundle.d.ts @@ -1721,6 +1721,14 @@ export interface IdentityDefinition { dynamicUrl?: string; /** The ID of another pack, if you are trying to reference a value from different pack. */ packId?: number; + /** + * By default, result sets returned by dynamic sync tables will not be merged together for the purposes of presenting + * information. This value, if set, will allow results for identities for the same Pack and name to be merged together + * if they share the same `mergeKey`. + * + * @hidden In development. + */ + mergeKey?: string; /** @deprecated See {@link ObjectSchemaDefinition.attribution} */ attribution?: AttributionNode[]; } @@ -1797,10 +1805,10 @@ export interface DetailedIndexedProperty { } export type IndexedProperty = BasicIndexedProperty | DetailedIndexedProperty; /** - * Defines how to index objects for use with full-text indexing. - * TODO(alexd): Unhide this - * @hidden - */ + * Defines how to index objects for use with full-text indexing. + * TODO(alexd): Unhide this + * @hidden + */ export interface IndexDefinition { /** * A list of properties from within {@link ObjectSchemaDefinition.properties} that should be indexed. diff --git a/dist/cli/coda.js b/dist/cli/coda.js old mode 100755 new mode 100644 diff --git a/dist/schema.d.ts b/dist/schema.d.ts index 8612a5c47d..02bcf1a0de 100644 --- a/dist/schema.d.ts +++ b/dist/schema.d.ts @@ -857,6 +857,14 @@ export interface IdentityDefinition { dynamicUrl?: string; /** The ID of another pack, if you are trying to reference a value from different pack. */ packId?: number; + /** + * By default, result sets returned by dynamic sync tables will not be merged together for the purposes of presenting + * information. This value, if set, will allow results for identities for the same Pack and name to be merged together + * if they share the same `mergeKey`. + * + * @hidden In development. + */ + mergeKey?: string; /** @deprecated See {@link ObjectSchemaDefinition.attribution} */ attribution?: AttributionNode[]; } @@ -938,10 +946,10 @@ export interface DetailedIndexedProperty { } export type IndexedProperty = BasicIndexedProperty | DetailedIndexedProperty; /** - * Defines how to index objects for use with full-text indexing. - * TODO(alexd): Unhide this - * @hidden - */ + * Defines how to index objects for use with full-text indexing. + * TODO(alexd): Unhide this + * @hidden + */ export interface IndexDefinition { /** * A list of properties from within {@link ObjectSchemaDefinition.properties} that should be indexed. diff --git a/dist/testing/upload_validation.js b/dist/testing/upload_validation.js index 5d74de010b..37a260b262 100644 --- a/dist/testing/upload_validation.js +++ b/dist/testing/upload_validation.js @@ -953,8 +953,8 @@ function buildMetadataSchema({ sdkVersion }) { }); function makePropertyValidator(schema, context) { /** - * Validates a PropertyIdentifier key in the object schema. - */ + * Validates a PropertyIdentifier key in the object schema. + */ return function validateProperty(propertyValueRaw, fieldName, isValidSchema, invalidSchemaMessage, propertyObjectPath = [fieldName]) { function validatePropertyIdentifier(value, objectPath) { var _a; @@ -971,9 +971,7 @@ function buildMetadataSchema({ sdkVersion }) { })) === null || _a === void 0 ? void 0 : _a[0]; propertyValueIsPath = true; } - const propertyIdentifierDisplay = propertyValueIsPath - ? `"${fieldName}" path` - : `"${fieldName}" field name`; + const propertyIdentifierDisplay = propertyValueIsPath ? `"${fieldName}" path` : `"${fieldName}" field name`; if (!propertySchema) { context.addIssue({ code: z.ZodIssueCode.custom, @@ -1019,6 +1017,7 @@ function buildMetadataSchema({ sdkVersion }) { name: z.string().nonempty(), dynamicUrl: z.string().optional(), attribution: attributionSchema, + mergeKey: z.string().optional(), }).optional(), attribution: attributionSchema, properties: z.record(objectPropertyUnionSchema), @@ -1245,7 +1244,10 @@ function buildMetadataSchema({ sdkVersion }) { } } if (contextProperties) { - validatePropertyValue(contextProperties, 'contextProperties', () => true, `must be a valid property.`, ['index', 'contextProperties']); + validatePropertyValue(contextProperties, 'contextProperties', () => true, `must be a valid property.`, [ + 'index', + 'contextProperties', + ]); } })); const objectPropertyUnionSchema = z diff --git a/package.json b/package.json index eb375d79ff..333606a542 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codahq/packs-sdk", - "version": "1.7.10-prerelease.1", + "version": "1.7.10", "license": "MIT", "workspaces": [ "dev/eslint" diff --git a/testing/upload_validation.ts b/testing/upload_validation.ts index 14607d22b2..1dfa047b50 100644 --- a/testing/upload_validation.ts +++ b/testing/upload_validation.ts @@ -1169,23 +1169,20 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): { properties: z.array(indexedPropertySchema).min(1), contextProperties: contextPropertiesSchema.optional(), popularityRankProperty: propertySchema.optional(), - }); + }); function makePropertyValidator(schema: GenericObjectSchema, context: z.RefinementCtx) { /** - * Validates a PropertyIdentifier key in the object schema. - */ + * Validates a PropertyIdentifier key in the object schema. + */ return function validateProperty( propertyValueRaw: PropertyIdentifier | Array> | undefined, fieldName: string, isValidSchema: (schema: Schema & ObjectSchemaProperty) => boolean, invalidSchemaMessage: string, - propertyObjectPath: Array = [fieldName] + propertyObjectPath: Array = [fieldName], ) { - function validatePropertyIdentifier( - value: PropertyIdentifier, - objectPath: Array, - ) { + function validatePropertyIdentifier(value: PropertyIdentifier, objectPath: Array) { const propertyValue = typeof value === 'string' ? value : value?.property; let propertyValueIsPath = false; @@ -1202,9 +1199,7 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): { propertyValueIsPath = true; } - const propertyIdentifierDisplay = propertyValueIsPath - ? `"${fieldName}" path` - : `"${fieldName}" field name`; + const propertyIdentifierDisplay = propertyValueIsPath ? `"${fieldName}" path` : `"${fieldName}" field name`; if (!propertySchema) { context.addIssue({ @@ -1235,7 +1230,7 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): { validatePropertyIdentifier(propertyValueRaw, propertyObjectPath); } - } + }; } const genericObjectSchema: z.ZodTypeAny = z.lazy(() => @@ -1256,6 +1251,7 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): { name: z.string().nonempty(), dynamicUrl: z.string().optional(), attribution: attributionSchema, + mergeKey: z.string().optional(), }).optional(), attribution: attributionSchema, properties: z.record(objectPropertyUnionSchema), @@ -1599,15 +1595,12 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): { } if (contextProperties) { - validatePropertyValue( - contextProperties, + validatePropertyValue(contextProperties, 'contextProperties', () => true, `must be a valid property.`, [ + 'index', 'contextProperties', - () => true, - `must be a valid property.`, - ['index', 'contextProperties'], - ); + ]); } - }) + }), ); const objectPropertyUnionSchema = z