Skip to content

Commit

Permalink
Add itemVersionProperty for tracking item state in ingestions (#3100)
Browse files Browse the repository at this point in the history
* add itemVersionProperty

* update

* update comment

* update comment

* update name

* update name

* update type
  • Loading branch information
ebo-codaio authored Nov 8, 2024
1 parent 2d29301 commit 426ded9
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 7 deletions.
9 changes: 9 additions & 0 deletions dist/bundle.d.ts

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

6 changes: 3 additions & 3 deletions dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/helpers/migration.js

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

11 changes: 10 additions & 1 deletion dist/schema.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/schema.js

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

5 changes: 5 additions & 0 deletions dist/testing/upload_validation.js

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

1 change: 1 addition & 0 deletions helpers/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ObjectSchemaHelper<T extends ObjectSchemaDefinition<string, string>> {
bodyTextProperty,
popularityRankProperty,
parentIdProperty,
versionProperty,
index,
...rest
} = schema;
Expand Down
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.8.1",
"version": "1.8.2-prerelease.1",
"license": "MIT",
"workspaces": [
"dev/eslint"
Expand Down
15 changes: 15 additions & 0 deletions schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ export type ObjectSchemaPathProperties = Pick<
| 'memberGroupIdProperty'
| 'bodyTextProperty'
| 'popularityRankProperty'
| 'versionProperty'
>;

/**
Expand Down Expand Up @@ -1374,6 +1375,16 @@ export interface ObjectSchemaDefinition<K extends string, L extends string>
*/
index?: IndexDefinition;

/**
* The name of the property within {@link ObjectSchemaDefinition.properties} that can be be interpreted as
* text representing the version of an item.
*
* Must be a {@link ValueType.String} property.
* TODO(ebo): Unhide this
* @hidden
*/
versionProperty? : PropertyIdentifier<K>;

// TODO(dweitzman): Only support options in the typing when the codaType is ValueHintType.SelectList.
}

Expand Down Expand Up @@ -2112,6 +2123,7 @@ export function normalizeObjectSchema(schema: GenericObjectSchema): GenericObjec
memberGroupIdProperty,
bodyTextProperty,
popularityRankProperty,
versionProperty,
index,
...rest
} = schema;
Expand Down Expand Up @@ -2189,6 +2201,9 @@ export function normalizeObjectSchema(schema: GenericObjectSchema): GenericObjec
popularityRankProperty: popularityRankProperty
? normalizeSchemaPropertyIdentifier(popularityRankProperty, normalizedProperties)
: undefined,
versionProperty: versionProperty
? normalizeSchemaPropertyIdentifier(versionProperty, normalizedProperties)
: undefined,
index: index ? normalizeIndexDefinition(index, normalizedProperties) : undefined,
type: ValueType.Object,
};
Expand Down
10 changes: 10 additions & 0 deletions testing/upload_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ ${endpointKey ? 'endpointKey is set' : `requiresEndpointUrl is ${requiresEndpoin
memberGroupIdProperty: propertySchema.optional(),
bodyTextProperty: propertySchema.optional(),
popularityRankProperty: propertySchema.optional(),
versionProperty: propertySchema.optional(),
options: zodOptionsFieldWithValues(z.object({}).passthrough(), false),
requireForUpdates: z.boolean().optional(),
index: indexSchema.optional(),
Expand Down Expand Up @@ -1611,6 +1612,14 @@ ${endpointKey ? 'endpointKey is set' : `requiresEndpointUrl is ${requiresEndpoin
);
};

const validateVersionProperty = () => {
return validateProperty(
'versionProperty',
versionPropertySchema => versionPropertySchema.type === ValueType.String,
`must refer to a "ValueType.String" property.`,
);
}

validateTitleProperty();
validateLinkProperty();
validateImageProperty();
Expand All @@ -1626,6 +1635,7 @@ ${endpointKey ? 'endpointKey is set' : `requiresEndpointUrl is ${requiresEndpoin
validateMemberGroupIdProperty();
validatebodyTextProperty();
validatePopularityRankProperty();
validateVersionProperty();
})
.superRefine((data, context) => {
const schemaHelper = objectSchemaHelper(data as GenericObjectSchema);
Expand Down

0 comments on commit 426ded9

Please sign in to comment.