Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-codaio committed Aug 23, 2024
1 parent 64212f9 commit 6e2587f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 36 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
16 changes: 12 additions & 4 deletions dist/bundle.d.ts

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

Empty file modified dist/cli/coda.js
100755 → 100644
Empty file.
16 changes: 12 additions & 4 deletions dist/schema.d.ts

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

14 changes: 8 additions & 6 deletions 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.10-prerelease.1",
"version": "1.7.10",
"license": "MIT",
"workspaces": [
"dev/eslint"
Expand Down
31 changes: 12 additions & 19 deletions testing/upload_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> | Array<PropertyIdentifier<string>> | undefined,
fieldName: string,
isValidSchema: (schema: Schema & ObjectSchemaProperty) => boolean,
invalidSchemaMessage: string,
propertyObjectPath: Array<string | number> = [fieldName]
propertyObjectPath: Array<string | number> = [fieldName],
) {
function validatePropertyIdentifier(
value: PropertyIdentifier,
objectPath: Array<string | number>,
) {
function validatePropertyIdentifier(value: PropertyIdentifier, objectPath: Array<string | number>) {
const propertyValue = typeof value === 'string' ? value : value?.property;

let propertyValueIsPath = false;
Expand All @@ -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({
Expand Down Expand Up @@ -1235,7 +1230,7 @@ function buildMetadataSchema({sdkVersion}: BuildMetadataSchemaArgs): {

validatePropertyIdentifier(propertyValueRaw, propertyObjectPath);
}
}
};
}

const genericObjectSchema: z.ZodTypeAny = z.lazy(() =>
Expand All @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e2587f

Please sign in to comment.