@osdk/maker 0.16.0 → 0.17.0-main-20260407074313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/build/browser/api/defineAction.js +7 -6
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateObjectAction.js +7 -5
- package/build/browser/api/defineCreateObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js +8 -6
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineModifyObjectAction.js +8 -6
- package/build/browser/api/defineModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +2 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/objectPropertyHelpers.js +53 -0
- package/build/browser/api/object/objectPropertyHelpers.js.map +1 -0
- package/build/browser/cli/main.js +1 -1
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +2 -2
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/cjs/index.cjs +47 -18
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +36 -36
- package/build/esm/api/defineAction.js +7 -6
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateObjectAction.js +7 -5
- package/build/esm/api/defineCreateObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js +8 -6
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineModifyObjectAction.js +8 -6
- package/build/esm/api/defineModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +2 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/objectPropertyHelpers.js +53 -0
- package/build/esm/api/object/objectPropertyHelpers.js.map +1 -0
- package/build/esm/cli/main.js +1 -1
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +2 -2
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/types/api/defineAction.d.ts +5 -3
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/links/LinkType.d.ts +9 -8
- package/build/types/api/links/LinkType.d.ts.map +1 -1
- package/build/types/api/object/objectPropertyHelpers.d.ts +17 -0
- package/build/types/api/object/objectPropertyHelpers.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertLink.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertLink.js","names":["invariant","OntologyEntityTypeEnum","cleanAndValidateLinkTypeId","importedTypes","ontologyDefinition","convertCardinality","convertLink","linkType","validateLink","definition","datasource","undefined","apiName","oneObjectApiName","object","oneObject","getObject","one","toManyObjectApiName","toManyObject","toMany","type","oneToMany","cardinalityHint","cardinality","manyToOneLinkMetadata","metadata","objectTypeRidManySide","objectTypeRidOneSide","oneToManyLinkMetadata","oneSidePrimaryKeyToManySidePropertyMapping","from","primaryKeyPropertyApiName","to","manyForeignKeyProperty","manyObjectApiName","manyObject","many","intermediary","objectTypeAToBLinkMetadata","objectTypeBToALinkMetadata","objectTypeRidA","objectTypeRidB","intermediaryObjectTypeRid","intermediaryObjectType","aToIntermediaryLinkTypeRid","linkToIntermediary","intermediaryToBLinkTypeRid","columnA","columnB","hasCollision","resolvedColumnA","resolvedColumnB","manyToMany","peeringMetadata","objectTypeAPrimaryKeyPropertyMapping","objectTypeBPrimaryKeyPropertyMapping","datasourceName","dataset","datasetRid","concat","writebackDatasetRid","objectTypeAPrimaryKeyMapping","property","column","objectTypeBPrimaryKeyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","id","status","convertLinkStatus","datasources","entityMetadata","arePatchesEnabled","editsEnabled","linkDefinition","foreignKey","properties","find","p","process","env","NODE_ENV","test","typesMatch","intermediaryObjectTypeApiName","manyIntermediaryOneObjectApiName","manyIntermediaryOneObject","manyIntermediaryToManyObjectApiName","manyIntermediaryToManyObject","toManyIntermediaryOneObjectApiName","toManyIntermediaryOneObject","toManyIntermediaryToManyObjectApiName","toManyIntermediaryToManyObject","objectApiName","fullObject","OBJECT_TYPE","deprecated","message","deadline","experimental","example","active"],"sources":["convertLink.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIrLinkDefinition,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrLinkTypeStatus,\n OntologyIrManyToManyLinkTypeDatasource,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {\n cleanAndValidateLinkTypeId,\n importedTypes,\n ontologyDefinition,\n} from \"../../api/defineOntology.js\";\nimport type { LinkType, UserLinkTypeStatus } from \"../../api/links/LinkType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type { ObjectTypeDefinition } from \"../../api/object/ObjectTypeDefinition.js\";\nimport { convertCardinality } from \"./convertCardinality.js\";\n\nexport function convertLink(\n linkType: LinkType,\n): OntologyIrLinkTypeBlockDataV2 {\n validateLink(linkType);\n let definition: OntologyIrLinkDefinition;\n let datasource: OntologyIrManyToManyLinkTypeDatasource | undefined =\n undefined;\n if (\"one\" in linkType) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkType.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"oneToMany\",\n oneToMany: {\n cardinalityHint: convertCardinality(linkType.cardinality),\n manyToOneLinkMetadata: linkType.toMany.metadata,\n objectTypeRidManySide: toManyObjectApiName,\n objectTypeRidOneSide: oneObjectApiName,\n oneToManyLinkMetadata: linkType.one.metadata,\n oneSidePrimaryKeyToManySidePropertyMapping: [{\n from: {\n apiName: oneObject.primaryKeyPropertyApiName,\n object: oneObjectApiName,\n },\n to: {\n apiName: linkType.manyForeignKeyProperty,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n } else if (\"intermediaryObjectType\" in linkType) {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"intermediary\",\n intermediary: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,\n aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.many.linkToIntermediary.apiName,\n ),\n intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.toMany.linkToIntermediary.apiName,\n ),\n },\n };\n } else {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n\n const columnA = manyObject.primaryKeyPropertyApiName;\n const columnB = toManyObject.primaryKeyPropertyApiName;\n const hasCollision = columnA === columnB;\n const resolvedColumnA = hasCollision ? `${columnA}_from` : columnA;\n const resolvedColumnB = hasCollision ? `${columnB}_to` : columnB;\n\n definition = {\n type: \"manyToMany\",\n manyToMany: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n peeringMetadata: undefined,\n objectTypeAPrimaryKeyPropertyMapping: [{\n from: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n to: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n }],\n objectTypeBPrimaryKeyPropertyMapping: [{\n from: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n to: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n\n datasource = {\n datasourceName: linkType.apiName,\n datasource: {\n type: \"dataset\",\n dataset: {\n datasetRid: \"link-\".concat(linkType.apiName),\n writebackDatasetRid: undefined,\n objectTypeAPrimaryKeyMapping: [{\n property: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n column: resolvedColumnA,\n }],\n objectTypeBPrimaryKeyMapping: [{\n property: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n column: resolvedColumnB,\n }],\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: linkType.redacted,\n };\n }\n\n return {\n linkType: {\n definition: definition,\n id: cleanAndValidateLinkTypeId(linkType.apiName),\n status: convertLinkStatus(linkType.status),\n redacted: linkType.redacted ?? false,\n },\n datasources: datasource !== undefined ? [datasource] : [],\n entityMetadata: {\n arePatchesEnabled: linkType.editsEnabled ?? false,\n },\n };\n}\nfunction validateLink(linkDefinition: LinkType) {\n if (\"one\" in linkDefinition) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkDefinition.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n const foreignKey = toManyObject.properties?.find(p =>\n p.apiName === linkDefinition.manyForeignKeyProperty\n );\n invariant(\n foreignKey !== undefined,\n `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`,\n );\n\n invariant(\n /([a-z][a-z0-9\\\\-]*)/.test(linkDefinition.apiName),\n `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\\\-]*) ${linkDefinition.apiName} does not match`,\n );\n\n const typesMatch = foreignKey.type\n === oneObject.properties?.find(p =>\n p.apiName === oneObject.primaryKeyPropertyApiName\n )?.type;\n invariant(\n typesMatch,\n `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`,\n );\n }\n if (\"intermediaryObjectType\" in linkDefinition) {\n const {\n apiName: intermediaryObjectTypeApiName,\n object: intermediaryObjectType,\n } = getObject(linkDefinition.intermediaryObjectType);\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkDefinition.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n\n const {\n apiName: manyIntermediaryOneObjectApiName,\n object: manyIntermediaryOneObject,\n } = getObject((linkDefinition.many.linkToIntermediary as any).one.object);\n const {\n apiName: manyIntermediaryToManyObjectApiName,\n object: manyIntermediaryToManyObject,\n } = getObject(linkDefinition.many.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.many.linkToIntermediary\n && manyIntermediaryOneObjectApiName\n === manyObject.apiName\n && manyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`,\n );\n\n const {\n apiName: toManyIntermediaryOneObjectApiName,\n object: toManyIntermediaryOneObject,\n } = getObject((linkDefinition.toMany.linkToIntermediary as any).one.object);\n const {\n apiName: toManyIntermediaryToManyObjectApiName,\n object: toManyIntermediaryToManyObject,\n } = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.toMany.linkToIntermediary\n && toManyIntermediaryOneObjectApiName\n === toManyObjectApiName\n && toManyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`,\n );\n }\n}\n\nexport function getObject(\n object: string | ObjectTypeDefinition,\n): { apiName: string; object: ObjectType } {\n const objectApiName = typeof object === \"string\" ? object : object.apiName;\n const fullObject =\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName]\n ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];\n invariant(\n fullObject !== undefined,\n `Object ${objectApiName} is not defined`,\n );\n return { apiName: objectApiName, object: fullObject };\n}\n\nexport function convertLinkStatus(\n status: UserLinkTypeStatus | undefined,\n): OntologyIrLinkTypeStatus {\n if (\n typeof status === \"object\" && \"type\" in status\n && status.type === \"deprecated\"\n ) {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n },\n };\n }\n switch (status) {\n case \"experimental\":\n return { type: \"experimental\", experimental: {} };\n case \"example\":\n return { type: \"example\", example: {} };\n case \"active\":\n default:\n return { type: \"active\", active: {} };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,sBAAsB,QAAQ,4CAA4C;AACnF,SACEC,0BAA0B,EAC1BC,aAAa,EACbC,kBAAkB,QACb,6BAA6B;AAIpC,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,OAAO,SAASC,WAAWA,CACzBC,QAAkB,EACa;EAC/BC,YAAY,CAACD,QAAQ,CAAC;EACtB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,aAAa,iBAAiB,IAF1C/F,SAAS;EAIT,OAAO;IAAEY,OAAO,EAAEmF,aAAa;IAAEjF,MAAM,EAAEkF;EAAW,CAAC;AACvD;AAEA,OAAO,SAASzB,iBAAiBA,CAC/BD,MAAsC,EACZ;EAC1B,IACE,OAAOA,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAIA,MAAM,IAC3CA,MAAM,CAACjD,IAAI,KAAK,YAAY,EAC/B;IACA,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB6E,UAAU,EAAE;QACVC,OAAO,EAAE7B,MAAM,CAAC6B,OAAO;QACvBC,QAAQ,EAAE9B,MAAM,CAAC8B;MACnB;IACF,CAAC;EACH;EACA,QAAQ9B,MAAM;IACZ,KAAK,cAAc;MACjB,OAAO;QAAEjD,IAAI,EAAE,cAAc;QAAEgF,YAAY,EAAE,CAAC;MAAE,CAAC;IACnD,KAAK,SAAS;MACZ,OAAO;QAAEhF,IAAI,EAAE,SAAS;QAAEiF,OAAO,EAAE,CAAC;MAAE,CAAC;IACzC,KAAK,QAAQ;IACb;MACE,OAAO;QAAEjF,IAAI,EAAE,QAAQ;QAAEkF,MAAM,EAAE,CAAC;MAAE,CAAC;EACzC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertLink.js","names":["invariant","OntologyEntityTypeEnum","cleanAndValidateLinkTypeId","importedTypes","ontologyDefinition","convertCardinality","convertLink","linkType","validateLink","definition","datasource","apiName","oneObjectApiName","object","oneObject","getObject","one","toManyObjectApiName","toManyObject","toMany","type","oneToMany","cardinalityHint","cardinality","manyToOneLinkMetadata","metadata","objectTypeRidManySide","objectTypeRidOneSide","oneToManyLinkMetadata","oneSidePrimaryKeyToManySidePropertyMapping","from","primaryKeyPropertyApiName","to","manyForeignKeyProperty","manyObjectApiName","manyObject","many","intermediary","objectTypeAToBLinkMetadata","objectTypeBToALinkMetadata","objectTypeRidA","objectTypeRidB","intermediaryObjectTypeRid","intermediaryObjectType","aToIntermediaryLinkTypeRid","linkToIntermediary","intermediaryToBLinkTypeRid","columnA","columnB","hasCollision","resolvedColumnA","resolvedColumnB","manyToMany","peeringMetadata","undefined","objectTypeAPrimaryKeyPropertyMapping","objectTypeBPrimaryKeyPropertyMapping","datasourceName","dataset","datasetRid","concat","writebackDatasetRid","objectTypeAPrimaryKeyMapping","property","column","objectTypeBPrimaryKeyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","id","status","convertLinkStatus","datasources","entityMetadata","arePatchesEnabled","editsEnabled","linkDefinition","foreignKey","properties","find","p","process","env","NODE_ENV","test","typesMatch","intermediaryObjectTypeApiName","manyIntermediaryOneObjectApiName","manyIntermediaryOneObject","manyIntermediaryToManyObjectApiName","manyIntermediaryToManyObject","toManyIntermediaryOneObjectApiName","toManyIntermediaryOneObject","toManyIntermediaryToManyObjectApiName","toManyIntermediaryToManyObject","objectApiName","fullObject","OBJECT_TYPE","deprecated","message","deadline","experimental","example","active"],"sources":["convertLink.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIrLinkDefinition,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrLinkTypeStatus,\n OntologyIrManyToManyLinkTypeDatasource,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {\n cleanAndValidateLinkTypeId,\n importedTypes,\n ontologyDefinition,\n} from \"../../api/defineOntology.js\";\nimport type { LinkType, UserLinkTypeStatus } from \"../../api/links/LinkType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type { ObjectTypeDefinition } from \"../../api/object/ObjectTypeDefinition.js\";\nimport { convertCardinality } from \"./convertCardinality.js\";\n\nexport function convertLink(\n linkType: LinkType,\n): OntologyIrLinkTypeBlockDataV2 {\n validateLink(linkType);\n let definition: OntologyIrLinkDefinition;\n let datasource: OntologyIrManyToManyLinkTypeDatasource | undefined;\n if (\"one\" in linkType) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkType.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"oneToMany\",\n oneToMany: {\n cardinalityHint: convertCardinality(linkType.cardinality),\n manyToOneLinkMetadata: linkType.toMany.metadata,\n objectTypeRidManySide: toManyObjectApiName,\n objectTypeRidOneSide: oneObjectApiName,\n oneToManyLinkMetadata: linkType.one.metadata,\n oneSidePrimaryKeyToManySidePropertyMapping: [{\n from: {\n apiName: oneObject.primaryKeyPropertyApiName,\n object: oneObjectApiName,\n },\n to: {\n apiName: linkType.manyForeignKeyProperty,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n } else if (\"intermediaryObjectType\" in linkType) {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"intermediary\",\n intermediary: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,\n aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.many.linkToIntermediary.apiName,\n ),\n intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.toMany.linkToIntermediary.apiName,\n ),\n },\n };\n } else {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n\n const columnA = manyObject.primaryKeyPropertyApiName;\n const columnB = toManyObject.primaryKeyPropertyApiName;\n const hasCollision = columnA === columnB;\n const resolvedColumnA = hasCollision ? `${columnA}_from` : columnA;\n const resolvedColumnB = hasCollision ? `${columnB}_to` : columnB;\n\n definition = {\n type: \"manyToMany\",\n manyToMany: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n peeringMetadata: undefined,\n objectTypeAPrimaryKeyPropertyMapping: [{\n from: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n to: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n }],\n objectTypeBPrimaryKeyPropertyMapping: [{\n from: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n to: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n\n datasource = {\n datasourceName: linkType.apiName,\n datasource: {\n type: \"dataset\",\n dataset: {\n datasetRid: \"link-\".concat(linkType.apiName),\n writebackDatasetRid: undefined,\n objectTypeAPrimaryKeyMapping: [{\n property: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n column: resolvedColumnA,\n }],\n objectTypeBPrimaryKeyMapping: [{\n property: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n column: resolvedColumnB,\n }],\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: linkType.redacted,\n };\n }\n\n return {\n linkType: {\n definition,\n id: cleanAndValidateLinkTypeId(linkType.apiName),\n status: convertLinkStatus(linkType.status),\n redacted: linkType.redacted ?? false,\n },\n datasources: datasource !== undefined ? [datasource] : [],\n entityMetadata: {\n arePatchesEnabled: linkType.editsEnabled ?? false,\n },\n };\n}\nfunction validateLink(linkDefinition: LinkType) {\n if (\"one\" in linkDefinition) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkDefinition.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n const foreignKey = toManyObject.properties?.find(p =>\n p.apiName === linkDefinition.manyForeignKeyProperty\n );\n invariant(\n foreignKey !== undefined,\n `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`,\n );\n\n invariant(\n /([a-z][a-z0-9\\\\-]*)/.test(linkDefinition.apiName),\n `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\\\-]*) ${linkDefinition.apiName} does not match`,\n );\n\n const typesMatch = foreignKey.type\n === oneObject.properties?.find(p =>\n p.apiName === oneObject.primaryKeyPropertyApiName\n )?.type;\n invariant(\n typesMatch,\n `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`,\n );\n }\n if (\"intermediaryObjectType\" in linkDefinition) {\n const {\n apiName: intermediaryObjectTypeApiName,\n object: intermediaryObjectType,\n } = getObject(linkDefinition.intermediaryObjectType);\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkDefinition.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n\n const {\n apiName: manyIntermediaryOneObjectApiName,\n object: manyIntermediaryOneObject,\n } = getObject((linkDefinition.many.linkToIntermediary as any).one.object);\n const {\n apiName: manyIntermediaryToManyObjectApiName,\n object: manyIntermediaryToManyObject,\n } = getObject(linkDefinition.many.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.many.linkToIntermediary\n && manyIntermediaryOneObjectApiName\n === manyObject.apiName\n && manyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`,\n );\n\n const {\n apiName: toManyIntermediaryOneObjectApiName,\n object: toManyIntermediaryOneObject,\n } = getObject((linkDefinition.toMany.linkToIntermediary as any).one.object);\n const {\n apiName: toManyIntermediaryToManyObjectApiName,\n object: toManyIntermediaryToManyObject,\n } = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.toMany.linkToIntermediary\n && toManyIntermediaryOneObjectApiName\n === toManyObjectApiName\n && toManyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`,\n );\n }\n}\n\nexport function getObject(\n object: string | ObjectTypeDefinition | ObjectType,\n): { apiName: string; object: ObjectType } {\n const objectApiName = typeof object === \"string\" ? object : object.apiName;\n const fullObject =\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName]\n ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];\n invariant(\n fullObject !== undefined,\n `Object ${objectApiName} is not defined`,\n );\n return { apiName: objectApiName, object: fullObject };\n}\n\nexport function convertLinkStatus(\n status: UserLinkTypeStatus | undefined,\n): OntologyIrLinkTypeStatus {\n if (\n typeof status === \"object\" && \"type\" in status\n && status.type === \"deprecated\"\n ) {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n },\n };\n }\n switch (status) {\n case \"experimental\":\n return { type: \"experimental\", experimental: {} };\n case \"example\":\n return { type: \"example\", example: {} };\n case \"active\":\n default:\n return { type: \"active\", active: {} };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,sBAAs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CAAC,IAChE5F,aAAa,CAACF,sBAAsB,CAACgG,WAAW,CAAC,CAACF,aAAa,CAAC;EACvE,EACEC,UAAU,KAAK1C,SAAS,IAAA2B,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1BnF,SAAS,QAEP,UAAU+F,aAAa,iBAAiB,IAF1C/F,SAAS;EAIT,OAAO;IAAEW,OAAO,EAAEoF,aAAa;IAAElF,MAAM,EAAEmF;EAAW,CAAC;AACvD;AAEA,OAAO,SAASzB,iBAAiBA,CAC/BD,MAAsC,EACZ;EAC1B,IACE,OAAOA,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAIA,MAAM,IAC3CA,MAAM,CAAClD,IAAI,KAAK,YAAY,EAC/B;IACA,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB8E,UAAU,EAAE;QACVC,OAAO,EAAE7B,MAAM,CAAC6B,OAAO;QACvBC,QAAQ,EAAE9B,MAAM,CAAC8B;MACnB;IACF,CAAC;EACH;EACA,QAAQ9B,MAAM;IACZ,KAAK,cAAc;MACjB,OAAO;QAAElD,IAAI,EAAE,cAAc;QAAEiF,YAAY,EAAE,CAAC;MAAE,CAAC;IACnD,KAAK,SAAS;MACZ,OAAO;QAAEjF,IAAI,EAAE,SAAS;QAAEkF,OAAO,EAAE,CAAC;MAAE,CAAC;IACzC,KAAK,QAAQ;IACb;MACE,OAAO;QAAElF,IAAI,EAAE,QAAQ;QAAEmF,MAAM,EAAE,CAAC;MAAE,CAAC;EACzC;AACF","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -82,7 +82,7 @@ function convertCardinality(cardinality) {
|
|
|
82
82
|
function convertLink(linkType) {
|
|
83
83
|
validateLink(linkType);
|
|
84
84
|
let definition;
|
|
85
|
-
let datasource
|
|
85
|
+
let datasource;
|
|
86
86
|
if ("one" in linkType) {
|
|
87
87
|
const {
|
|
88
88
|
apiName: oneObjectApiName,
|
|
@@ -2680,7 +2680,7 @@ function getNamespace() {
|
|
|
2680
2680
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2681
2681
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2682
2682
|
async function main(args = process.argv) {
|
|
2683
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
2683
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.17.0-main-20260407074313").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2684
2684
|
input: {
|
|
2685
2685
|
alias: "i",
|
|
2686
2686
|
describe: "Input file",
|
|
@@ -2795,6 +2795,32 @@ function isActionParameterTypePrimitive(type) {
|
|
|
2795
2795
|
return ["boolean", "booleanList", "integer", "integerList", "long", "longList", "double", "doubleList", "string", "stringList", "decimal", "decimalList", "timestamp", "timestampList", "geohash", "geohashList", "geoshape", "geoshapeList", "timeSeriesReference", "date", "dateList", "objectTypeReference", "objectReference", "attachment", "attachmentList", "marking", "markingList", "mediaReference", "mediaReferenceList", "geotimeSeriesReference", "geotimeSeriesReferenceList"].includes(type);
|
|
2796
2796
|
}
|
|
2797
2797
|
|
|
2798
|
+
// src/api/object/objectPropertyHelpers.ts
|
|
2799
|
+
function getProperty(obj, propertyId) {
|
|
2800
|
+
const props = obj.properties;
|
|
2801
|
+
if (props == null) return void 0;
|
|
2802
|
+
if (Array.isArray(props)) {
|
|
2803
|
+
return props.find((prop) => prop.apiName === propertyId);
|
|
2804
|
+
}
|
|
2805
|
+
return propertyId in props ? props[propertyId] : void 0;
|
|
2806
|
+
}
|
|
2807
|
+
function getPropertyKeys(obj) {
|
|
2808
|
+
const props = obj.properties;
|
|
2809
|
+
if (props == null) return [];
|
|
2810
|
+
if (Array.isArray(props)) {
|
|
2811
|
+
return props.map((prop) => prop.apiName);
|
|
2812
|
+
}
|
|
2813
|
+
return Object.keys(props);
|
|
2814
|
+
}
|
|
2815
|
+
function toPropertyMap(obj) {
|
|
2816
|
+
const props = obj.properties;
|
|
2817
|
+
if (props == null) return {};
|
|
2818
|
+
if (Array.isArray(props)) {
|
|
2819
|
+
return Object.fromEntries(props.map((prop) => [prop.apiName, prop]));
|
|
2820
|
+
}
|
|
2821
|
+
return props;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2798
2824
|
// src/api/defineAction.ts
|
|
2799
2825
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
2800
2826
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
@@ -2861,12 +2887,12 @@ function isPropertyParameter(def, name, type) {
|
|
|
2861
2887
|
if ("interfaceType" in def) {
|
|
2862
2888
|
return Object.keys(getFlattenedInterfaceProperties(def.interfaceType)).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2863
2889
|
}
|
|
2864
|
-
return
|
|
2890
|
+
return getPropertyKeys(def.objectType).includes(name) && !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2865
2891
|
}
|
|
2866
2892
|
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
2867
2893
|
const targetParams = getTargetParameters(def, parameterSet);
|
|
2868
2894
|
return [...targetParams, ...Array.from(parameterSet).map((id) => {
|
|
2869
|
-
let propertyMetadata
|
|
2895
|
+
let propertyMetadata;
|
|
2870
2896
|
if (id in propertyMap) {
|
|
2871
2897
|
propertyMetadata = "sharedPropertyType" in propertyMap[id] ? propertyMap[id].sharedPropertyType : propertyMap[id];
|
|
2872
2898
|
}
|
|
@@ -3631,16 +3657,17 @@ function defineCreateInterfaceObjectAction(defInput) {
|
|
|
3631
3657
|
// src/api/defineCreateObjectAction.ts
|
|
3632
3658
|
function defineCreateObjectAction(defInput) {
|
|
3633
3659
|
const def = cloneDefinition(defInput);
|
|
3634
|
-
|
|
3660
|
+
const propertyKeys = getPropertyKeys(def.objectType);
|
|
3661
|
+
validateActionParameters(def, propertyKeys, def.objectType.apiName);
|
|
3635
3662
|
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3636
|
-
const propertyParameters =
|
|
3663
|
+
const propertyParameters = propertyKeys.filter((id) => isPropertyParameter(def, id, getProperty(def.objectType, id)?.type) && !isStruct(getProperty(def.objectType, id)?.type) && !propertiesWithDerivedDatasources.includes(id));
|
|
3637
3664
|
const parameterNames = new Set(propertyParameters);
|
|
3638
3665
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3639
3666
|
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
3640
3667
|
if (def.parameterOrdering) {
|
|
3641
3668
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3642
3669
|
}
|
|
3643
|
-
const parameters = createParameters(def, def.objectType
|
|
3670
|
+
const parameters = createParameters(def, toPropertyMap(def.objectType), parameterNames);
|
|
3644
3671
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3645
3672
|
return defineAction({
|
|
3646
3673
|
apiName: actionApiName,
|
|
@@ -3667,7 +3694,7 @@ function defineCreateObjectAction(defInput) {
|
|
|
3667
3694
|
structFieldValues: {}
|
|
3668
3695
|
}
|
|
3669
3696
|
}],
|
|
3670
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
3697
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, propertyKeys, parameters),
|
|
3671
3698
|
...def.actionLevelValidation ? {
|
|
3672
3699
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3673
3700
|
} : {},
|
|
@@ -3697,9 +3724,10 @@ function defineCreateObjectAction(defInput) {
|
|
|
3697
3724
|
// src/api/defineCreateOrModifyObjectAction.ts
|
|
3698
3725
|
function defineCreateOrModifyObjectAction(defInput) {
|
|
3699
3726
|
const def = cloneDefinition(defInput);
|
|
3700
|
-
|
|
3727
|
+
const propertyKeys = getPropertyKeys(def.objectType);
|
|
3728
|
+
validateActionParameters(def, propertyKeys, def.objectType.apiName);
|
|
3701
3729
|
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3702
|
-
const propertyParameters =
|
|
3730
|
+
const propertyParameters = propertyKeys.filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(getProperty(def.objectType, id)?.type) && id !== def.objectType.primaryKeyPropertyApiName && !propertiesWithDerivedDatasources.includes(id));
|
|
3703
3731
|
const parameterNames = new Set(propertyParameters);
|
|
3704
3732
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3705
3733
|
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
@@ -3710,9 +3738,9 @@ function defineCreateOrModifyObjectAction(defInput) {
|
|
|
3710
3738
|
}
|
|
3711
3739
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3712
3740
|
}
|
|
3713
|
-
const parameters = createParameters(def, def.objectType
|
|
3741
|
+
const parameters = createParameters(def, toPropertyMap(def.objectType), parameterNames);
|
|
3714
3742
|
parameters.forEach((p) => {
|
|
3715
|
-
if (def.objectType
|
|
3743
|
+
if (getProperty(def.objectType, p.id) && p.defaultValue === void 0) {
|
|
3716
3744
|
p.defaultValue = {
|
|
3717
3745
|
type: "objectParameterPropertyValue",
|
|
3718
3746
|
objectParameterPropertyValue: {
|
|
@@ -3748,7 +3776,7 @@ function defineCreateOrModifyObjectAction(defInput) {
|
|
|
3748
3776
|
affectedLinkTypes: [],
|
|
3749
3777
|
typeGroups: []
|
|
3750
3778
|
},
|
|
3751
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
3779
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, propertyKeys, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
3752
3780
|
...def.actionLevelValidation ? {
|
|
3753
3781
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3754
3782
|
} : {},
|
|
@@ -4146,8 +4174,9 @@ function defineModifyInterfaceObjectAction(defInput) {
|
|
|
4146
4174
|
// src/api/defineModifyObjectAction.ts
|
|
4147
4175
|
function defineModifyObjectAction(defInput) {
|
|
4148
4176
|
const def = cloneDefinition(defInput);
|
|
4149
|
-
|
|
4150
|
-
|
|
4177
|
+
const propertyKeys = getPropertyKeys(def.objectType);
|
|
4178
|
+
validateActionParameters(def, propertyKeys, def.objectType.apiName);
|
|
4179
|
+
const propertyParameters = propertyKeys.filter((id) => isPropertyParameter(def, id, getProperty(def.objectType, id)?.type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
4151
4180
|
const parameterNames = new Set(propertyParameters);
|
|
4152
4181
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
4153
4182
|
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
@@ -4158,9 +4187,9 @@ function defineModifyObjectAction(defInput) {
|
|
|
4158
4187
|
}
|
|
4159
4188
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
4160
4189
|
}
|
|
4161
|
-
const parameters = createParameters(def, def.objectType
|
|
4190
|
+
const parameters = createParameters(def, toPropertyMap(def.objectType), parameterNames);
|
|
4162
4191
|
parameters.forEach((p) => {
|
|
4163
|
-
if (def.objectType
|
|
4192
|
+
if (getProperty(def.objectType, p.id) && p.defaultValue === void 0) {
|
|
4164
4193
|
p.defaultValue = {
|
|
4165
4194
|
type: "objectParameterPropertyValue",
|
|
4166
4195
|
objectParameterPropertyValue: {
|
|
@@ -4196,7 +4225,7 @@ function defineModifyObjectAction(defInput) {
|
|
|
4196
4225
|
affectedLinkTypes: [],
|
|
4197
4226
|
typeGroups: []
|
|
4198
4227
|
},
|
|
4199
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
4228
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, propertyKeys, parameters, MODIFY_OBJECT_PARAMETER),
|
|
4200
4229
|
...def.actionLevelValidation ? {
|
|
4201
4230
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
4202
4231
|
} : {},
|