Skip to content

Commit

Permalink
feat: distribute JSON schema for DatapackExportDefinition object
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeneos committed Aug 7, 2024
1 parent f3b8fa1 commit 55e1d50
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vlocity-deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"npm": ">=6.0.0"
},
"scripts": {
"build": "tsc",
"build": "pnpm build:schema && tsc",
"build:schema": "ts-json-schema-generator --path './src/**/*.ts' --tsconfig ./tsconfig.json --type DatapackExportDefinition --no-type-check -o ./src/export/exportDefinitions.schema.json --no-ref-encode",
"clean": "shx rm -rf ./lib ./coverage ./tsconfig.tsbuildinfo './*.tgz' './src/**/*.{d.ts,ts.map,js.map,js}'",
"watch": "tsc -w",
"pack": "pnpm run build && pnpm pack",
Expand Down Expand Up @@ -55,6 +56,7 @@
"jest": "^29.7.0",
"shx": "^0.3.4",
"ts-jest": "^29.1.1",
"ts-json-schema-generator": "^2.3.0",
"typescript": "5.1.6"
},
"dependencies": {
Expand Down
244 changes: 244 additions & 0 deletions packages/vlocity-deploy/src/export/exportDefinitions.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"$ref": "#/definitions/DatapackExportDefinition",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"DatapackExportDefinition": {
"additionalProperties": false,
"properties": {
"autoGeneratedMatchingKey": {
"description": "When true the matching key is auto-generated random number instead of a value based on the object data. autogenerated matching keys only work for none-lookup fields.",
"type": "boolean"
},
"embeddedLookupFields": {
"description": "List of lookup fields that are embedded as part of the object export in the parent datapack.",
"items": {
"type": "string"
},
"type": "array"
},
"fields": {
"additionalProperties": {
"$ref": "#/definitions/ExportFieldDefinition"
},
"description": "Optional object with specific export settings for fields in the object.",
"type": "object"
},
"fileName": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "The name of the file to export the object data to. The name can be a string which is evaluated as a template to include values from the dtapaack: ```yaml fileName: \"account_{Name}\" ``` All exported fields are written to this file in JSON format and '.json' is appended to the file name if no extension is provided."
},
"filter": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/alias-1030797743-2611-2701-1030797743-0-3796"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"type": "object"
}
],
"description": "Where condition to filter the object data to export by. Can be a string or an object. When an object, the key is the field name and the value is the value to filter by. Accesing fields from the parent datapack using bracket syntax `{}` is supported: ``` relatedObjectFilter: AccountId: $parent.Id IsActive: true ```\n\nWhen defined as a string, the string is used as the where condition and interpolated this allows for more complex where conditions: ```yaml filter: \"AccountId = '{parent.Id}' AND IsActive = 'true'\" ```"
},
"ignoreFields": {
"description": "List of fields to exclude from the export.",
"items": {
"type": "string"
},
"type": "array"
},
"matchingKeyFields": {
"description": "List of fields which uniquely identify the object and are used for matching the object when importing and for generating the external lookup reference.",
"items": {
"type": "string"
},
"type": "array"
},
"objectType": {
"description": "Type of SObject to export",
"type": "string"
},
"relatedObjects": {
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/ObjectFilter"
},
{
"$ref": "#/definitions/ObjectRelationship"
},
{
"type": "string"
}
]
},
"description": "List of objects that are related to this object and who's data should be included in the export. The key is the name under which related records are exported.",
"type": "object"
},
"sortFields": {
"description": "List of fields by which to sort the exported data when exporting\tas a related object.",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": ["objectType", "matchingKeyFields"],
"type": "object"
},
"ExportFieldDefinition": {
"additionalProperties": false,
"properties": {
"expandArray": {
"description": "When true expands an array value in the datapack to individual files.",
"type": "boolean"
},
"fileName": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "When set the data in the field is exported into a separate file with the specified name. The name can be a string which is evaluated as a template to include values from the datapack: ```yaml fileName: \"data_{Name}.json\" ``` If no extension is provided the extension is inferred from the field type:\n- json: .json\n- binary: .bin"
},
"processor": {
"description": "Processor function snippet to use for processing the field data before exporting.",
"type": "string"
}
},
"type": "object"
},
"ObjectFilter": {
"additionalProperties": false,
"properties": {
"filter": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/alias-1030797743-2611-2701-1030797743-0-3796"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"type": "object"
}
],
"description": "Where condition to filter the object data to export by. Can be a string or an object. When an object, the key is the field name and the value is the value to filter by. Accesing fields from the parent datapack using bracket syntax `{}` is supported: ``` relatedObjectFilter: AccountId: $parent.Id IsActive: true ```\n\nWhen defined as a string, the string is used as the where condition and interpolated this allows for more complex where conditions: ```yaml filter: \"AccountId = '{parent.Id}' AND IsActive = 'true'\" ```"
},
"objectType": {
"description": "Type of SObject to which this filter applies",
"type": "string"
}
},
"required": ["objectType", "filter"],
"type": "object"
},
"ObjectRelationship": {
"additionalProperties": false,
"properties": {
"filter": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/alias-1030797743-2611-2701-1030797743-0-3796"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"type": "object"
}
],
"description": "Optional filter to apply to the related object data to export."
},
"relationshipName": {
"description": "Name of the relationship field on the parent object",
"type": "string"
}
},
"required": ["relationshipName"],
"type": "object"
},
"alias-1030797743-2611-2701-1030797743-0-3796": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/alias-1030797743-2611-2701-1030797743-0-3796"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"type": "object"
}
]
}
}
}
Loading

0 comments on commit 55e1d50

Please sign in to comment.