@osdk/maker 0.15.0-beta.6 → 0.15.0-beta.7
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/action/ActionParameter.js.map +1 -1
- package/build/browser/api/action/ActionParameterConfiguration.js.map +1 -1
- package/build/browser/api/defineAction.js +65 -22
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +28 -8
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineInterface.js +40 -34
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +31 -8
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +13 -9
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/interface/InterfacePropertyType.js +22 -1
- package/build/browser/api/interface/InterfacePropertyType.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js +9 -3
- package/build/browser/api/interface/getFlattenedInterfaceProperties.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/api/test/actions.test.js +6105 -5850
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/interfaces.test.js +723 -470
- package/build/browser/api/test/interfaces.test.js.map +1 -1
- package/build/browser/api/test/links.test.js +1334 -1325
- package/build/browser/api/test/links.test.js.map +1 -1
- package/build/browser/api/test/misc.test.js +262 -11
- package/build/browser/api/test/misc.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +1019 -960
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +250 -103
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -2
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterfacePropertyType.js +66 -0
- package/build/browser/conversion/toMarketplace/convertInterfacePropertyType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js +35 -0
- package/build/browser/conversion/toMarketplace/convertMappingValue.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObject.js +4 -2
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +2 -1
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertSpt.js +4 -2
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js +143 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js.map +1 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -0
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +386 -109
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +28 -13
- package/build/esm/api/action/ActionParameter.js.map +1 -1
- package/build/esm/api/action/ActionParameterConfiguration.js.map +1 -1
- package/build/esm/api/defineAction.js +65 -22
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +28 -8
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineInterface.js +40 -34
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +31 -8
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +13 -9
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/interface/InterfacePropertyType.js +22 -1
- package/build/esm/api/interface/InterfacePropertyType.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js +9 -3
- package/build/esm/api/interface/getFlattenedInterfaceProperties.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/api/test/actions.test.js +6105 -5850
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/interfaces.test.js +723 -470
- package/build/esm/api/test/interfaces.test.js.map +1 -1
- package/build/esm/api/test/links.test.js +1334 -1325
- package/build/esm/api/test/links.test.js.map +1 -1
- package/build/esm/api/test/misc.test.js +262 -11
- package/build/esm/api/test/misc.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +1019 -960
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +250 -103
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -2
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterfacePropertyType.js +66 -0
- package/build/esm/conversion/toMarketplace/convertInterfacePropertyType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js +35 -0
- package/build/esm/conversion/toMarketplace/convertMappingValue.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObject.js +4 -2
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +2 -1
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertSpt.js +4 -2
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js +143 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.js.map +1 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -0
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/api/action/ActionParameter.d.ts +2 -1
- package/build/types/api/action/ActionParameter.d.ts.map +1 -1
- package/build/types/api/action/ActionParameterConfiguration.d.ts +2 -1
- package/build/types/api/action/ActionParameterConfiguration.d.ts.map +1 -1
- package/build/types/api/defineAction.d.ts +4 -3
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts +5 -5
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +3 -0
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/interface/InterfacePropertyType.d.ts +12 -2
- package/build/types/api/interface/InterfacePropertyType.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +3 -2
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts +1 -1
- package/build/types/api/interface/getFlattenedInterfaceProperties.d.ts.map +1 -1
- package/build/types/api/object/ObjectType.d.ts +1 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +1 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/SharedPropertyType.d.ts +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertInterface.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertInterfacePropertyType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/convertInterfacePropertyType.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertMappingValue.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts +1 -1
- package/build/types/conversion/toMarketplace/convertSpt.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.d.ts +3 -0
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrInterfaceType.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterface.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","withoutNamespace","defineSharedPropertyType","mapSimplifiedStatusToInterfaceTypeStatus","combineApiNamespaceIfMissing","isPropertyTypeType","defineInterface","interfaceDef","apiName","INTERFACE_TYPE","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","unNamespacedPropApiName","type","propertyDefinition","required","sharedPropertyType","unifyBasePropertyDefinition","extendsInterfaces","extends","Array","isArray","status","deprecated","message","deadline","fullInterface","displayMetadata","displayName","description","icon","blueprint","color","locator","links","propertiesV2","searchable","__type","JSON","stringify","spt","array","unNamespacedTypeApiName","key"],"sources":["defineInterface.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { InterfaceTypeStatus } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { BlueprintIcon } from \"./common/BlueprintIcons.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nimport { type InterfaceType } from \"./interface/InterfaceType.js\";\nimport { mapSimplifiedStatusToInterfaceTypeStatus } from \"./interface/mapSimplifiedStatusToInterfaceTypeStatus.js\";\nimport { combineApiNamespaceIfMissing } from \"./namespace/combineApiNamespaceIfMissing.js\";\nimport {\n isPropertyTypeType,\n type PropertyTypeType,\n} from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\n\nexport type SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\ntype PropertyBase = SharedPropertyType | PropertyTypeType;\ntype PropertyWithOptional = {\n required: boolean;\n propertyDefinition: PropertyBase;\n};\n\nexport type InterfaceTypeDefinition = {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n PropertyBase | PropertyWithOptional\n >;\n extends?: InterfaceType | InterfaceType[];\n searchable?: boolean;\n};\n\nexport function defineInterface(\n interfaceDef: InterfaceTypeDefinition,\n): InterfaceType {\n const apiName = namespace + interfaceDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName]\n === undefined,\n `Interface ${apiName} already exists`,\n );\n\n const properties = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).map<\n [string, { required: boolean; sharedPropertyType: SharedPropertyType }]\n >(\n ([unNamespacedPropApiName, type]) => {\n if (typeof type === \"object\" && \"propertyDefinition\" in type) {\n // If the property is an imported SPT, use the SPT's apiName\n const apiName = combineApiNamespaceIfMissing(\n namespace,\n typeof type.propertyDefinition === \"object\"\n && \"apiName\" in type.propertyDefinition\n ? type.propertyDefinition.apiName\n : unNamespacedPropApiName,\n );\n\n return [apiName, {\n required: type.required,\n sharedPropertyType: unifyBasePropertyDefinition(\n namespace,\n unNamespacedPropApiName,\n type.propertyDefinition,\n ),\n }];\n }\n\n // If the property is an imported SPT, use the SPT's apiName\n const apiName = combineApiNamespaceIfMissing(\n namespace,\n typeof type === \"object\" && \"apiName\" in type\n ? type.apiName\n : unNamespacedPropApiName,\n );\n return [apiName, {\n required: true,\n sharedPropertyType: unifyBasePropertyDefinition(\n namespace,\n unNamespacedPropApiName,\n type,\n ),\n }];\n },\n ),\n );\n\n const extendsInterfaces = interfaceDef.extends\n ? (Array.isArray(interfaceDef.extends)\n ? interfaceDef.extends\n : [interfaceDef.extends])\n : [];\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n interfaceDef.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const fullInterface: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: interfaceDef.displayName ?? interfaceDef.apiName,\n description: interfaceDef.description ?? interfaceDef.displayName\n ?? interfaceDef.apiName,\n icon: interfaceDef.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: {\n color: interfaceDef.icon.color,\n locator: interfaceDef.icon.locator,\n },\n }\n : undefined,\n },\n extendsInterfaces,\n links: [],\n status,\n propertiesV2: properties,\n searchable: interfaceDef.searchable ?? true,\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE,\n };\n\n updateOntology(fullInterface);\n return fullInterface;\n}\n\nfunction unifyBasePropertyDefinition(\n namespace: string,\n apiName: string,\n type: PropertyBase,\n): SharedPropertyType {\n if (\n typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))\n ) {\n invariant(\n isPropertyTypeType(type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return spt;\n } else {\n const unNamespacedTypeApiName = withoutNamespace(type.apiName);\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return type;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,wBAAwB,QAAQ,gBAAgB;AAEzD,SAASC,wCAAwC,QAAQ,yDAAyD;AAClH,SAASC,4BAA4B,QAAQ,6CAA6C;AAC1F,SACEC,kBAAkB,QAEb,kCAAkC;AA4BzC,OAAO,SAASC,eAAeA,CAC7BC,YAAqC,EACtB;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e,EACfY,IAAkB,EACE;EACpB,IACE,OAAOA,IAAI,KAAK,QAAQ,IACpB,OAAOA,IAAI,KAAK,QAAQ,IAAI,EAAE,SAAS,IAAIA,IAAI,CAAE,EACrD;IACA,CACEf,kBAAkB,CAACe,IAAI,CAAC,GAAAT,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1BjB,SAAS,QAEP,qBACEiD,IAAI,CAACC,SAAS,CAAC1B,IAAI,CAAC,iBACLZ,OAAO,qBAAqBA,OAAO,EAAE,IAJxDZ,SAAS;IAOT,MAAMmD,GAAG,GAAG7C,wBAAwB,CAAC;MACnCM,OAAO;MACP2B,WAAW,EAAE3B,OAAO;MACpBY,IAAI;MACJ4B,KAAK,EAAE;IACT,CAAC,CAAC;IACF,OAAOD,GAAG;EACZ,CAAC,MAAM;IACL,MAAME,uBAAuB,GAAGhD,gBAAgB,CAACmB,IAAI,CAACZ,OAAO,CAAC;IAC9D,EACEV,SAAS,GAAGU,OAAO,KAAKY,IAAI,CAACZ,OAAO,IAC/BA,OAAO,KAAKyC,uBAAuB,IAAAtC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1CjB,SAAS,QAGP,oDACEiD,IAAI,CAACC,SAAS,CAAC;MAAEI,GAAG,EAAE1C,OAAO;MAAEA,OAAO,EAAEY,IAAI,CAACZ;IAAQ,CAAC,CAAC,EACvD,IALJZ,SAAS;IAOT,OAAOwB,IAAI;EACb;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","withoutNamespace","isInterfaceSharedPropertyType","mapSimplifiedStatusToInterfaceTypeStatus","combineApiNamespaceIfMissing","isExotic","isPropertyTypeType","defineInterface","interfaceDef","apiName","INTERFACE_TYPE","undefined","process","env","NODE_ENV","spts","Object","fromEntries","entries","properties","filter","_name","prop","map","s","spt","required","sharedPropertyType","propertiesV2","propName","type","sptApiName","verifyBasePropertyDefinition","propertiesV3","propertyBase","extendsInterfaces","extends","Array","isArray","status","deprecated","message","deadline","fullInterface","displayMetadata","displayName","description","icon","blueprint","color","locator","links","searchable","__type","unNamespacedTypeApiName","JSON","stringify","key"],"sources":["defineInterface.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { InterfaceTypeStatus } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { BlueprintIcon } from \"./common/BlueprintIcons.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport {\n type InterfaceDefinedProperty,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport { type InterfaceType } from \"./interface/InterfaceType.js\";\nimport { mapSimplifiedStatusToInterfaceTypeStatus } from \"./interface/mapSimplifiedStatusToInterfaceTypeStatus.js\";\nimport { combineApiNamespaceIfMissing } from \"./namespace/combineApiNamespaceIfMissing.js\";\nimport { isExotic, isPropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\n\nexport type SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\ntype PropertyBase =\n | SharedPropertyType\n | InterfaceDefinedProperty;\ntype SptWithOptional = {\n required: boolean;\n sharedPropertyType: SharedPropertyType;\n};\n\nexport type InterfaceTypeDefinition = {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n PropertyBase | SptWithOptional\n >;\n extends?: InterfaceType | InterfaceType[];\n searchable?: boolean;\n};\n\nexport function defineInterface(\n interfaceDef: InterfaceTypeDefinition,\n): InterfaceType {\n const apiName = namespace + interfaceDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName]\n === undefined,\n `Interface ${apiName} already exists`,\n );\n\n // legacy support for propertiesV2 (only SPTs)\n const spts: Record<string, SptWithOptional> = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {\n return isInterfaceSharedPropertyType(prop) || \"apiName\" in prop;\n }).map(([s, spt]) => {\n const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;\n return [s, {\n sharedPropertyType: (isInterfaceSharedPropertyType(spt)\n ? spt.sharedPropertyType\n : spt) as SharedPropertyType,\n required: required,\n }];\n }),\n );\n const propertiesV2 = Object.fromEntries(\n Object.entries(spts).map<\n [string, { required: boolean; sharedPropertyType: SharedPropertyType }]\n >(\n ([propName, type]) => {\n const sptApiName = combineApiNamespaceIfMissing(\n namespace,\n type.sharedPropertyType.apiName,\n );\n return [sptApiName, {\n required: type.required,\n sharedPropertyType: verifyBasePropertyDefinition(\n namespace,\n propName,\n type.sharedPropertyType,\n ),\n }];\n },\n ),\n );\n\n const propertiesV3 = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).map<\n [string, InterfacePropertyType]\n >(([apiName, prop]) => {\n const required =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.required\n : true;\n const propertyBase: PropertyBase =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.sharedPropertyType\n : prop;\n if (\n typeof propertyBase === \"object\"\n && \"nonNameSpacedApiName\" in propertyBase\n ) {\n // SPT\n return [apiName, {\n required: required,\n sharedPropertyType: propertyBase,\n }];\n } else {\n // IDP\n return [apiName, propertyBase];\n }\n }),\n );\n\n const extendsInterfaces = interfaceDef.extends\n ? (Array.isArray(interfaceDef.extends)\n ? interfaceDef.extends\n : [interfaceDef.extends])\n : [];\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n interfaceDef.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const fullInterface: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: interfaceDef.displayName ?? interfaceDef.apiName,\n description: interfaceDef.description ?? interfaceDef.displayName\n ?? interfaceDef.apiName,\n icon: interfaceDef.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: {\n color: interfaceDef.icon.color,\n locator: interfaceDef.icon.locator,\n },\n }\n : undefined,\n },\n extendsInterfaces,\n links: [],\n status,\n propertiesV2: propertiesV2,\n propertiesV3: propertiesV3,\n searchable: interfaceDef.searchable ?? true,\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE,\n };\n\n updateOntology(fullInterface);\n return fullInterface;\n}\n\nfunction verifyBasePropertyDefinition(\n namespace: string,\n apiName: string,\n type: SharedPropertyType,\n): SharedPropertyType {\n const unNamespacedTypeApiName = withoutNamespace(type.apiName);\n invariant(\n isPropertyTypeType(type.type) || isExotic(type.type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return type;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SA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wB,IAAI,CAACA,IAAI,CAAC,IAAIzB,QAAQ,CAACyB,IAAI,CAACA,IAAI,CAAC,IAAAlB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADtDlB,SAAS,QAEP,qBACE2D,IAAI,CAACC,SAAS,CAAC1B,IAAI,CAAC,iBACLrB,OAAO,qBAAqBA,OAAO,EAAE,IAJxDb,SAAS;EAMT,EACEE,SAAS,GAAGW,OAAO,KAAKqB,IAAI,CAACrB,OAAO,IAC/BA,OAAO,KAAK6C,uBAAuB,IAAA1C,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1ClB,SAAS,QAGP,oDACE2D,IAAI,CAACC,SAAS,CAAC;IAAEC,GAAG,EAAEhD,OAAO;IAAEA,OAAO,EAAEqB,IAAI,CAACrB;EAAQ,CAAC,CAAC,EACvD,IALJb,SAAS;EAOT,OAAOkC,IAAI;AACb","ignoreList":[]}
|
|
@@ -14,16 +14,19 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { convertMappingValue } from "../conversion/toMarketplace/convertMappingValue.js";
|
|
18
|
-
import {
|
|
17
|
+
import { convertInterfacePropertyMappingValue, convertMappingValue } from "../conversion/toMarketplace/convertMappingValue.js";
|
|
18
|
+
import { convertValidationRule, createDefaultParameterOrdering, createParameters, defineAction, getInterfaceParameterName, getNonNamespacedParameterName, isPropertyParameter, kebab, MODIFY_INTERFACE_OBJECT_PARAMETER, validateActionParameters, validateParameterOrdering } from "./defineAction.js";
|
|
19
19
|
import { getFlattenedInterfaceProperties } from "./interface/getFlattenedInterfaceProperties.js";
|
|
20
|
+
import { getInterfacePropertyTypeType, isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
20
21
|
export function defineModifyInterfaceObjectAction(def) {
|
|
21
|
-
addNamespaceToActionDefinition(def);
|
|
22
22
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
23
23
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => {
|
|
25
|
+
return isPropertyParameter(def, apiName, getInterfacePropertyTypeType(type));
|
|
26
|
+
});
|
|
27
|
+
const sptNames = actionInterfaceProperties.filter(([_apiName, type]) => isInterfaceSharedPropertyType(type)).map(([apiName]) => apiName);
|
|
28
|
+
const parameterNames = new Set(actionInterfaceProperties.map(([apiName, _type]) => getInterfaceParameterName(def, apiName)));
|
|
29
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop]));
|
|
27
30
|
Object.keys(def.parameterConfiguration ?? {}).forEach(param => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
28
31
|
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
29
32
|
const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === undefined ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
@@ -33,8 +36,17 @@ export function defineModifyInterfaceObjectAction(def) {
|
|
|
33
36
|
}
|
|
34
37
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
35
38
|
}
|
|
36
|
-
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
37
|
-
|
|
39
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required ?? true])));
|
|
40
|
+
let sptMappings = {};
|
|
41
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => {
|
|
42
|
+
if (sptNames.includes(id)) {
|
|
43
|
+
sptMappings = {
|
|
44
|
+
...sptMappings,
|
|
45
|
+
[id]: convertMappingValue(value)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return [id, convertInterfacePropertyMappingValue(value)];
|
|
49
|
+
}));
|
|
38
50
|
return defineAction({
|
|
39
51
|
apiName: actionApiName,
|
|
40
52
|
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -49,12 +61,23 @@ export function defineModifyInterfaceObjectAction(def) {
|
|
|
49
61
|
rules: [{
|
|
50
62
|
type: "modifyInterfaceRule",
|
|
51
63
|
modifyInterfaceRule: {
|
|
64
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
52
65
|
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
53
66
|
sharedPropertyValues: {
|
|
54
67
|
...Object.fromEntries(sptNames.map(id => [id, {
|
|
55
68
|
type: "parameterId",
|
|
56
69
|
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
57
70
|
}])),
|
|
71
|
+
...sptMappings
|
|
72
|
+
},
|
|
73
|
+
interfacePropertyValues: {
|
|
74
|
+
...Object.fromEntries(actionInterfaceProperties.map(([id, _type]) => [id, {
|
|
75
|
+
type: "logicRuleValue",
|
|
76
|
+
logicRuleValue: {
|
|
77
|
+
type: "parameterId",
|
|
78
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
79
|
+
}
|
|
80
|
+
}])),
|
|
58
81
|
...mappings
|
|
59
82
|
}
|
|
60
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineModifyInterfaceObjectAction.js","names":["convertMappingValue","addNamespaceToActionDefinition","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","getInterfaceParameterName","getNonNamespacedParameterName","isPropertyParameter","kebab","MODIFY_INTERFACE_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","getFlattenedInterfaceProperties","defineModifyInterfaceObjectAction","def","allProperties","interfaceType","Object","keys","apiName","sptNames","filter","sharedPropertyType","type","parameterNames","Set","map","propertyMap","fromEntries","entries","id","prop","parameterConfiguration","forEach","param","add","actionApiName","split","pop","objectType","undefined","parameterOrdering","includes","unshift","parameters","required","mappings","nonParameterMappings","value","displayName","displayMetadata","status","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","rules","modifyInterfaceRule","interfaceObjectToModifyParameter","sharedPropertyValues","parameterId","useNonNamespacedParameters","Array","from","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyInterfaceObjectAction.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 { convertMappingValue } from \"../conversion/toMarketplace/convertMappingValue.js\";\nimport { type ActionType } from \"./action/ActionType.js\";\nimport type { InterfaceActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n addNamespaceToActionDefinition,\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n getInterfaceParameterName,\n getNonNamespacedParameterName,\n isPropertyParameter,\n kebab,\n MODIFY_INTERFACE_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\n\nexport function defineModifyInterfaceObjectAction(\n def: InterfaceActionTypeUserDefinition,\n): ActionType {\n addNamespaceToActionDefinition(def);\n const allProperties = getFlattenedInterfaceProperties(def.interfaceType);\n validateActionParameters(\n def,\n Object.keys(allProperties),\n def.interfaceType.apiName,\n );\n const sptNames = Object.keys(allProperties).filter(apiName =>\n isPropertyParameter(\n def,\n apiName,\n allProperties[apiName].sharedPropertyType.type,\n )\n );\n const parameterNames = new Set(\n sptNames.map(apiName => getInterfaceParameterName(def, apiName)),\n );\n const propertyMap = Object.fromEntries(\n Object.entries(allProperties).map((\n [id, prop],\n ) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]),\n );\n\n Object.keys(def.parameterConfiguration ?? {}).forEach(param =>\n parameterNames.add(\n getInterfaceParameterName(def, param),\n )\n );\n parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);\n const actionApiName = def.apiName ?? `modify-${\n kebab(\n def.interfaceType.apiName.split(\".\").pop() ?? def.interfaceType.apiName,\n )\n }${\n def.objectType === undefined\n ? \"\"\n : `-${\n kebab(\n def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName,\n )\n }`\n }`;\n if (def.parameterOrdering) {\n if (!def.parameterOrdering.includes(MODIFY_INTERFACE_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(MODIFY_INTERFACE_OBJECT_PARAMETER);\n }\n validateParameterOrdering(\n def.parameterOrdering,\n parameterNames,\n actionApiName,\n );\n }\n const parameters = createParameters(\n def,\n propertyMap,\n parameterNames,\n Object.fromEntries(\n Object.entries(allProperties).map(([id, prop]) => [id, prop.required]),\n ),\n );\n const mappings = Object.fromEntries(\n Object.entries(def.nonParameterMappings ?? {}).map((\n [id, value],\n ) => [id, convertMappingValue(value)]),\n );\n\n return defineAction({\n apiName: actionApiName,\n displayName: def.displayName\n ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,\n parameters: parameters,\n status: def.status ?? (def.interfaceType.status.type !== \"deprecated\"\n ? def.interfaceType.status.type\n : def.interfaceType.status),\n entities: {\n affectedInterfaceTypes: [def.interfaceType.apiName],\n affectedObjectTypes: [],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n rules: [\n {\n type: \"modifyInterfaceRule\",\n modifyInterfaceRule: {\n interfaceObjectToModifyParameter: \"interfaceObjectToModifyParameter\",\n sharedPropertyValues: {\n ...Object.fromEntries(\n sptNames.map(\n id => [id, {\n type: \"parameterId\",\n parameterId: def.useNonNamespacedParameters\n ? getNonNamespacedParameterName(def, id)\n : id,\n }],\n ),\n ),\n ...mappings,\n },\n },\n },\n ],\n parameterOrdering: def.parameterOrdering\n ?? createDefaultParameterOrdering(\n def,\n Array.from(parameterNames),\n parameters,\n MODIFY_INTERFACE_OBJECT_PARAMETER,\n ),\n ...(def.actionLevelValidation\n ? {\n validation: convertValidationRule(\n def.actionLevelValidation,\n parameters,\n ),\n }\n : {}),\n ...(def.defaultFormat && { defaultFormat: def.defaultFormat }),\n ...(def.enableLayoutSwitch\n && { enableLayoutSwitch: def.enableLayoutSwitch }),\n ...(def.tableConfiguration && {\n displayAndFormat: {\n table: def.tableConfiguration,\n },\n }),\n ...(def.sections\n && {\n sections: Object.fromEntries(\n def.sections.map(section => [section.id, section]),\n ),\n }),\n ...(def.submissionMetadata\n && { submissionMetadata: def.submissionMetadata }),\n ...(def.icon && { icon: def.icon }),\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,mBAAmB,QAAQ,oDAAoD;AAGxF,SACEC,8BAA8B,EAC9BC,qBAAqB,EACrBC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,yBAAyB,EACzBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,KAAK,EACLC,iCAAiC,EACjCC,wBAAwB,EACxBC,yBAAyB,QACpB,mBAAmB;AAC1B,SAASC,+BAA+B,QAAQ,gDAAgD;AAEhG,OAAO,SAASC,iCAAiCA,CAC/CC,GAAsC,EAC1B;EACZd,8BAA8B,CAACc,GAAG,CAAC;EACnC,MAAMC,aAAa,GAAGH,+BAA+B,CAACE,GAAG,CAACE,aAAa,CAAC;EACxEN,wBAAwB,CACtBI,GAAG,EACHG,MAAM,CAACC,IAAI,CAACH,aA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AAQ,IACX;MACDA,QAAQ,EAAEvD,MAAM,CAACW,WAAW,CAC1Bd,GAAG,CAAC0D,QAAQ,CAAC9C,GAAG,CAAC+C,OAAO,IAAI,CAACA,OAAO,CAAC3C,EAAE,EAAE2C,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAI3D,GAAG,CAAC4D,kBAAkB,IACrB;MAAEA,kBAAkB,EAAE5D,GAAG,CAAC4D;IAAmB,CAAC,CAAC;IACpD,IAAI5D,GAAG,CAAC6D,IAAI,IAAI;MAAEA,IAAI,EAAE7D,GAAG,CAAC6D;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineModifyInterfaceObjectAction.js","names":["convertInterfacePropertyMappingValue","convertMappingValue","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","getInterfaceParameterName","getNonNamespacedParameterName","isPropertyParameter","kebab","MODIFY_INTERFACE_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","defineModifyInterfaceObjectAction","def","allProperties","interfaceType","Object","keys","apiName","actionInterfaceProperties","entries","filter","type","sptNames","_apiName","map","parameterNames","Set","_type","propertyMap","fromEntries","id","prop","parameterConfiguration","forEach","param","add","actionApiName","split","pop","objectType","undefined","parameterOrdering","includes","unshift","parameters","required","sptMappings","mappings","nonParameterMappings","value","displayName","displayMetadata","status","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","rules","modifyInterfaceRule","interfaceApiName","interfaceObjectToModifyParameter","sharedPropertyValues","parameterId","useNonNamespacedParameters","interfacePropertyValues","logicRuleValue","Array","from","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyInterfaceObjectAction.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 {\n convertInterfacePropertyMappingValue,\n convertMappingValue,\n} from \"../conversion/toMarketplace/convertMappingValue.js\";\nimport { type ActionType } from \"./action/ActionType.js\";\nimport type { InterfaceActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n getInterfaceParameterName,\n getNonNamespacedParameterName,\n isPropertyParameter,\n kebab,\n MODIFY_INTERFACE_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\n\nexport function defineModifyInterfaceObjectAction(\n def: InterfaceActionTypeUserDefinition,\n): ActionType {\n const allProperties = getFlattenedInterfaceProperties(def.interfaceType);\n validateActionParameters(\n def,\n Object.keys(allProperties),\n def.interfaceType.apiName,\n );\n const actionInterfaceProperties = Object.entries(allProperties).filter(\n ([apiName, type]) => {\n return isPropertyParameter(\n def,\n apiName,\n getInterfacePropertyTypeType(type),\n );\n },\n );\n const sptNames = actionInterfaceProperties\n .filter(([_apiName, type]) => isInterfaceSharedPropertyType(type))\n .map(([apiName]) => apiName);\n const parameterNames = new Set(\n actionInterfaceProperties.map(([apiName, _type]) =>\n getInterfaceParameterName(def, apiName)\n ),\n );\n const propertyMap = Object.fromEntries(\n Object.entries(allProperties).map((\n [id, prop],\n ) => [getInterfaceParameterName(def, id), prop]),\n );\n\n Object.keys(def.parameterConfiguration ?? {}).forEach(param =>\n parameterNames.add(\n getInterfaceParameterName(def, param),\n )\n );\n parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);\n const actionApiName = def.apiName ?? `modify-${\n kebab(\n def.interfaceType.apiName.split(\".\").pop() ?? def.interfaceType.apiName,\n )\n }${\n def.objectType === undefined\n ? \"\"\n : `-${\n kebab(\n def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName,\n )\n }`\n }`;\n if (def.parameterOrdering) {\n if (!def.parameterOrdering.includes(MODIFY_INTERFACE_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(MODIFY_INTERFACE_OBJECT_PARAMETER);\n }\n validateParameterOrdering(\n def.parameterOrdering,\n parameterNames,\n actionApiName,\n );\n }\n const parameters = createParameters(\n def,\n propertyMap,\n parameterNames,\n Object.fromEntries(\n Object.entries(allProperties).map((\n [id, prop],\n ) => [id, prop.required ?? true]),\n ),\n );\n let sptMappings = {};\n const mappings = Object.fromEntries(\n Object.entries(def.nonParameterMappings ?? {}).map((\n [id, value],\n ) => {\n if (sptNames.includes(id)) {\n sptMappings = {\n ...sptMappings,\n [id]: convertMappingValue(value),\n };\n }\n return [id, convertInterfacePropertyMappingValue(value)];\n }),\n );\n\n return defineAction({\n apiName: actionApiName,\n displayName: def.displayName\n ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,\n parameters: parameters,\n status: def.status ?? (def.interfaceType.status.type !== \"deprecated\"\n ? def.interfaceType.status.type\n : def.interfaceType.status),\n entities: {\n affectedInterfaceTypes: [def.interfaceType.apiName],\n affectedObjectTypes: [],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n rules: [\n {\n type: \"modifyInterfaceRule\",\n modifyInterfaceRule: {\n interfaceApiName: def.interfaceType.apiName,\n interfaceObjectToModifyParameter: \"interfaceObjectToModifyParameter\",\n sharedPropertyValues: {\n ...Object.fromEntries(\n sptNames.map(\n id => [id, {\n type: \"parameterId\",\n parameterId: def.useNonNamespacedParameters\n ? getNonNamespacedParameterName(def, id)\n : id,\n }],\n ),\n ),\n ...sptMappings,\n },\n interfacePropertyValues: {\n ...Object.fromEntries(\n actionInterfaceProperties\n .map(([id, _type]) => [\n id,\n {\n type: \"logicRuleValue\",\n logicRuleValue: {\n type: \"parameterId\",\n parameterId: def.useNonNamespacedParameters\n ? getNonNamespacedParameterName(def, id)\n : id,\n },\n },\n ]),\n ),\n ...mappings,\n },\n },\n },\n ],\n parameterOrdering: def.parameterOrdering\n ?? createDefaultParameterOrdering(\n def,\n Array.from(parameterNames),\n parameters,\n MODIFY_INTERFACE_OBJECT_PARAMETER,\n ),\n ...(def.actionLevelValidation\n ? {\n validation: convertValidationRule(\n def.actionLevelValidation,\n parameters,\n ),\n }\n : {}),\n ...(def.defaultFormat && { defaultFormat: def.defaultFormat }),\n ...(def.enableLayoutSwitch\n && { enableLayoutSwitch: def.enableLayoutSwitch }),\n ...(def.tableConfiguration && {\n displayAndFormat: {\n table: def.tableConfiguration,\n },\n }),\n ...(def.sections\n && {\n sections: Object.fromEntries(\n def.sections.map(section => [section.id, section]),\n ),\n }),\n ...(def.submissionMetadata\n && { submissionMetadata: def.submissionMetadata }),\n ...(def.icon && { icon: def.icon }),\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,oCAAoC,EACpCC,mBAAmB,QACd,oDAAoD;AAG3D,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,yBAAyB,EACzBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,KAAK,EACLC,iCAAiC,EACjCC,wBAAwB,EACxBC,yBAAyB,QACpB,mBAAmB;AAC1B,SAASC,+BAA+B,QAAQ,gDAAgD;AAChG,SACEC,4BAA4B,EAC5BC,6BAA6B,QACxB,sCAAsC;AAE7C,OAAO,SAASC,iCAAiCA,CAC/CC,GAAsC,EAC1B;EACZ,MAAMC,aAAa,G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AAIjE,GAAG,CAACkE,kBAAkB,IACrB;MAAEA,kBAAkB,EAAElE,GAAG,CAACkE;IAAmB,CAAC,CAAC;IACpD,IAAIlE,GAAG,CAACmE,IAAI,IAAI;MAAEA,IAAI,EAAEnE,GAAG,CAACmE;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { getObject } from "../conversion/toMarketplace/convertLink.js";
|
|
19
19
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
20
|
-
import { addNamespaceIfNone, importedTypes, namespace, ontologyDefinition, updateOntology } from "./defineOntology.js";
|
|
20
|
+
import { addNamespaceIfNone, importedTypes, namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
21
21
|
import { getFlattenedInterfaceProperties } from "./interface/getFlattenedInterfaceProperties.js";
|
|
22
|
+
import { getInterfacePropertyTypeType, isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
22
23
|
import { isExotic } from "./properties/PropertyTypeType.js";
|
|
24
|
+
|
|
23
25
|
// From https://stackoverflow.com/a/79288714
|
|
24
26
|
const ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+D)|(?:\d+(?:\.|,)\d+D$))?(T((?:\d+H)|(?:\d+(?:\.|,)\d+H$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+S)|(?:\d+(?:\.|,)\d+S$))?)?)|(?:\d+(?:(?:\.|,)\d+)?W))$/;
|
|
25
27
|
|
|
@@ -67,18 +69,19 @@ export function defineObject(objectDef) {
|
|
|
67
69
|
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant(false) : void 0;
|
|
68
70
|
objectDef.implementsInterfaces?.forEach(interfaceImpl => {
|
|
69
71
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
70
|
-
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === undefined).map(interfaceProp => ({
|
|
72
|
+
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === undefined && allInterfaceProperties[withoutNamespace(interfaceProperty)] === undefined).map(interfaceProp => ({
|
|
71
73
|
type: "invalid",
|
|
72
74
|
reason: `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
73
75
|
}));
|
|
74
|
-
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [
|
|
76
|
+
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [mapping.interfaceProperty, mapping.mapsTo]));
|
|
75
77
|
const validateProperty = interfaceProp => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const apiName = isInterfaceSharedPropertyType(interfaceProp[1]) ? interfaceProp[1].sharedPropertyType.apiName : interfaceProp[0];
|
|
79
|
+
if (apiName in interfaceToObjectProperties) {
|
|
80
|
+
return validateInterfaceImplProperty(interfaceProp[1], apiName, interfaceToObjectProperties[interfaceProp[0]], objectDef);
|
|
78
81
|
}
|
|
79
82
|
return {
|
|
80
83
|
type: "invalid",
|
|
81
|
-
reason: `Interface
|
|
84
|
+
reason: `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`
|
|
82
85
|
};
|
|
83
86
|
};
|
|
84
87
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
@@ -101,7 +104,7 @@ function formatValidationErrors(error) {
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
// Validate that the object and the interface property match up
|
|
104
|
-
function validateInterfaceImplProperty(
|
|
107
|
+
function validateInterfaceImplProperty(type, apiName, mappedObjectProp, object) {
|
|
105
108
|
const objProp = object.properties?.[mappedObjectProp];
|
|
106
109
|
if (objProp === undefined) {
|
|
107
110
|
return {
|
|
@@ -109,10 +112,11 @@ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
|
109
112
|
reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
const propertyType = getInterfacePropertyTypeType(type);
|
|
116
|
+
if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {
|
|
113
117
|
return {
|
|
114
118
|
type: "invalid",
|
|
115
|
-
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${
|
|
119
|
+
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`
|
|
116
120
|
};
|
|
117
121
|
}
|
|
118
122
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineObject.js","names":["invariant","getObject","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","getFlattenedInterfaceProperties","isExotic","ISO_8601_DURATION","ISO_8601_DATETIME","API_NAME_PATTERN","defineObject","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","test","process","env","NODE_ENV","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","retentionPeriods","datasources","filter","ds","type","map","retentionPeriod","forEach","baseDatasources","length","join","derivedDatasources","validateDerivedDatasource","status","activeProperties","entries","property","push","deadline","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","spt","mappedObjectProp","object","objProp","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"sources":["defineObject.ts"],"sourcesContent":["/*\n * Copyright 2024 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 invariant from \"tiny-invariant\";\nimport { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport type { InterfacePropertyType } from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic } from \"./properties/PropertyTypeType.js\";\nimport type { SharedPropertyType } from \"./properties/SharedPropertyType.js\";\n\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nconst API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\\\-]*)$/;\n\nexport function defineObject(\n objectDef: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n API_NAME_PATTERN.test(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate that if object status is experimental, no property can have a status of active\n if (objectDef.status === \"experimental\") {\n const activeProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status === \"active\") {\n activeProperties.push(apiName);\n }\n },\n );\n invariant(\n activeProperties.length === 0,\n `When object \"${objectDef.apiName}\" has experimental status, no properties can have \"active\" status, but found active properties: ${\n activeProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n invariant(\n !isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n addNamespaceIfNone(mapping.interfaceProperty),\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n if (\n interfaceProp[1].sharedPropertyType.apiName\n in interfaceToObjectProperties\n ) {\n return validateInterfaceImplProperty(\n interfaceProp[1].sharedPropertyType,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason: `Interface property ${\n interfaceProp[1].sharedPropertyType.apiName\n } not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n spt: SharedPropertyType,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n if (JSON.stringify(spt.type) !== JSON.stringify(objProp?.type)) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,4CAA4C;AACtE,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,kBAAkB,EAClBC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AAC5B,SAASC,+BAA+B,QAAQ,gDAAgD;AAYhG,SAASC,QAAQ,QAAQ,kCAAkC;AAG3D;AACA,MAAMC,iBAAiB,GACrB,+OAA+O;;AAEjP;AACA,MAAMC,iBAAiB,GACrB,sEAAsE;AAExE,MAAMC,gBAAgB,GAAG,6BAA6B;AAEtD,OAAO,SAASC,YAAYA,CAC1BC,SAA+B,EACT;EACtB,MAAMC,OAAO,GAAGV,SAAS,GAAGS,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,UAAU,GACzCC,MAAM,CAACC,IAAI,CAACL,SAAS,CAACG,UAAU,CAAC,GACjC,EAAE;EACN,IACEX,kBAAkB,CAACJ,sBAAsB,CAACkB,WAAW,CAAC,CAACL,OAAO,CAAC,KACzDM,S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,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACA,IAAI;EAC5D,OAAO,CACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,WAAW,CACZ,CAACR,QAAQ,CAAC8F,QAAQ,CAAC;AACtB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineObject.js","names":["invariant","getObject","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","withoutNamespace","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","isExotic","ISO_8601_DURATION","ISO_8601_DATETIME","API_NAME_PATTERN","defineObject","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","test","process","env","NODE_ENV","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","retentionPeriods","datasources","filter","ds","type","map","retentionPeriod","forEach","baseDatasources","length","join","derivedDatasources","validateDerivedDatasource","status","activeProperties","entries","property","push","deadline","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","mappedObjectProp","object","objProp","propertyType","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"sources":["defineObject.ts"],"sourcesContent":["/*\n * Copyright 2024 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 invariant from \"tiny-invariant\";\nimport { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic } from \"./properties/PropertyTypeType.js\";\n\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nconst API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\\\-]*)$/;\n\nexport function defineObject(\n objectDef: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n API_NAME_PATTERN.test(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate that if object status is experimental, no property can have a status of active\n if (objectDef.status === \"experimental\") {\n const activeProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status === \"active\") {\n activeProperties.push(apiName);\n }\n },\n );\n invariant(\n activeProperties.length === 0,\n `When object \"${objectDef.apiName}\" has experimental status, no properties can have \"active\" status, but found active properties: ${\n activeProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n invariant(\n !isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined\n && allInterfaceProperties[withoutNamespace(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n mapping.interfaceProperty,\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n const apiName = isInterfaceSharedPropertyType(interfaceProp[1])\n ? interfaceProp[1].sharedPropertyType.apiName\n : interfaceProp[0];\n if (apiName in interfaceToObjectProperties) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n apiName,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason:\n `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n type: InterfacePropertyType,\n apiName: string,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n const propertyType = getInterfacePropertyTypeType(type);\n if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,4CAA4C;AACtE,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,kBAAkB,EAClBC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,+BAA+B,QAAQ,gDAAgD;AAChG,SACEC,4BAA4B,EAE5BC,6BAA6B,QACxB,sCAAsC;AAW7C,SAASC,QAAQ,QAAQ,kCAAkC;;AAE3D;AACA,MAAMC,iBAAiB,GACrB,+OAA+O;;AAEjP;AACA,MAAMC,iBAAiB,GACrB,sEAAsE;AAExE,MAAMC,gBAAgB,GAAG,6BAA6B;AAEtD,OAAO,SAASC,YAAYA,CAC1BC,SAA+B,EACT;EACtB,MAAMC,OAAO,GAAGb,SAAS,GAAGY,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,UAAU,GACzCC,MAAM,CAACC,IAAI,CAACL,SAAS,CAACG,UAAU,CAAC,GACjC,EAAE;EACN,IACEd,kBAAkB,CAACJ,sBAAsB,CAACqB,WAAW,CAAC,CAACL,OAAO,CAAC,KACzDM,SAAS,EACf;IACA,MAAM,IAAIC,KAAK,CACb,4BAA4BR,SAAS,CAACC,OAAO,qBAC/C,CAAC;EACH;EACA,CACEH,gBAAgB,CAACW,IAAI,CAACT,SAAS,CAACC,OAAO,CAAC,GAAAS,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1C7B,SAAS,QAEP,oBAAoBiB,SAAS,CAACC,OA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,IAAI,GAAGA,IAAI,CAACA,IAAI;EAC5D,OAAO,CACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,WAAW,CACZ,CAACR,QAAQ,CAAC8F,QAAQ,CAAC;AACtB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineSpt.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldNotHaveRenderHints","defineSharedPropertyType","sptDef","apiName","SHARED_PROPERTY_TYPE","undefined","process","env","NODE_ENV","type","typeClasses","fullSpt","nonNameSpacedApiName","displayName","__type"],"sources":["defineSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport { type PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldNotHaveRenderHints,\n} from \"./propertyConversionUtils.js\";\n\nexport interface SharedPropertyTypeDefinition {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n}\n\nexport function defineSharedPropertyType(\n sptDef: SharedPropertyTypeDefinition,\n): SharedPropertyType {\n const apiName = namespace + sptDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName]\n === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n invariant(\n !shouldNotHaveRenderHints(sptDef.type)\n || !hasRenderHints(sptDef.typeClasses),\n `Shared property type ${apiName} of type '${\n getPropertyTypeName(sptDef.type)\n }' should not have render hints`,\n );\n\n const fullSpt: SharedPropertyType = {\n ...sptDef,\n apiName,\n nonNameSpacedApiName: sptDef.apiName,\n displayName: sptDef.displayName ?? sptDef.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: sptDef.typeClasses\n ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n updateOntology(fullSpt);\n return fullSpt;\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,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;
|
|
1
|
+
{"version":3,"file":"defineSpt.js","names":["invariant","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldNotHaveRenderHints","defineSharedPropertyType","sptDef","apiName","SHARED_PROPERTY_TYPE","undefined","process","env","NODE_ENV","type","typeClasses","fullSpt","nonNameSpacedApiName","displayName","__type"],"sources":["defineSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 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 OntologyIrBaseFormatter,\n OntologyIrValueTypeReferenceWithMetadata,\n SharedPropertyTypeGothamMapping,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n} from \"./defineOntology.js\";\nimport type { Nullability } from \"./properties/Nullability.js\";\nimport { type PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\nimport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldNotHaveRenderHints,\n} from \"./propertyConversionUtils.js\";\n\nexport interface SharedPropertyTypeDefinition {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: OntologyIrValueTypeReferenceWithMetadata;\n visibility?: Visibility;\n nullability?: Nullability;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n aliases?: Array<string>;\n gothamMapping?: SharedPropertyTypeGothamMapping;\n baseFormatter?: OntologyIrBaseFormatter;\n}\n\nexport function defineSharedPropertyType(\n sptDef: SharedPropertyTypeDefinition,\n): SharedPropertyType {\n const apiName = namespace + sptDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName]\n === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n invariant(\n !shouldNotHaveRenderHints(sptDef.type)\n || !hasRenderHints(sptDef.typeClasses),\n `Shared property type ${apiName} of type '${\n getPropertyTypeName(sptDef.type)\n }' should not have render hints`,\n );\n\n const fullSpt: SharedPropertyType = {\n ...sptDef,\n apiName,\n nonNameSpacedApiName: sptDef.apiName,\n displayName: sptDef.displayName ?? sptDef.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: sptDef.typeClasses\n ?? (shouldNotHaveRenderHints(sptDef.type) ? [] : defaultTypeClasses),\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n updateOntology(fullSpt);\n return fullSpt;\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,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,qBAAqB;AAI5B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,QACnB,8BAA8B;AAiBrC,OAAO,SAASC,wBAAwBA,CACtCC,MAAoC,EAChB;EACpB,MAAMC,OAAO,GAAGT,SAAS,GAAGQ,MAAM,CAACC,OAAO;EAC1C,EACER,kBAAkB,CAACF,sBAAsB,CAACW,oBAAoB,CAAC,CAACD,OAAO,CAAC,KAClEE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFjBhB,SAAS,QAGP,wBAAwBW,OAAO,iBAAiB,IAHlDX,SAAS;EAMT,EACE,CAACQ,wBAAwB,CAACE,MAAM,CAACO,IAAI,CAAC,IACjC,CAACV,cAAc,CAACG,MAAM,CAACQ,WAAW,CAAC,IAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1ChB,SAAS,QAGP,wBAAwBW,OAAO,aAC7BL,mBAAmB,CAACI,MAAM,CAACO,IAAI,CAAC,gCACF,IALlCjB,SAAS;EAQT,MAAMmB,OAA2B,GAAG;IAClC,GAAGT,MAAM;IACTC,OAAO;IACPS,oBAAoB,EAAEV,MAAM,CAACC,OAAO;IACpCU,WAAW,EAAEX,MAAM,CAACW,WAAW,IAAIX,MAAM,CAACC,OAAO;IAAE;IACnDO,WAAW,EAAER,MAAM,CAACQ,WAAW,KACzBV,wBAAwB,CAACE,MAAM,CAACO,IAAI,CAAC,GAAG,EAAE,GAAGZ,kBAAkB,CAAC;IACtEiB,MAAM,EAAErB,sBAAsB,CAACW;EACjC,CAAC;EACDR,cAAc,CAACe,OAAO,CAAC;EACvB,OAAOA,OAAO;AAChB","ignoreList":[]}
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export function isInterfaceSharedPropertyType(interfacePropertyType) {
|
|
18
|
+
return "sharedPropertyType" in interfacePropertyType;
|
|
19
|
+
}
|
|
20
|
+
export function getInterfacePropertyTypeType(interfacePropertyType) {
|
|
21
|
+
return isInterfaceSharedPropertyType(interfacePropertyType) ? interfacePropertyType.sharedPropertyType.type : interfacePropertyType.type;
|
|
22
|
+
}
|
|
2
23
|
//# sourceMappingURL=InterfacePropertyType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfacePropertyType.js","names":[],"sources":["InterfacePropertyType.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 {
|
|
1
|
+
{"version":3,"file":"InterfacePropertyType.js","names":["isInterfaceSharedPropertyType","interfacePropertyType","getInterfacePropertyTypeType","sharedPropertyType","type"],"sources":["InterfacePropertyType.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 { OntologyIrBaseFormatter } from \"@osdk/client.unstable\";\nimport type { PropertyTypeType } from \"../properties/PropertyTypeType.js\";\nimport type {\n PropertyType,\n SharedPropertyType,\n} from \"../properties/SharedPropertyType.js\";\n\nexport type InterfacePropertyType =\n | InterfaceSharedPropertyType\n | InterfaceDefinedProperty;\n\nexport interface InterfaceDefinedProperty extends PropertyType {\n required?: boolean;\n primaryKeyConstraint?: \"MUST_BE_PK\" | \"CANNOT_BE_PK\" | \"NO_RESTRICTION\";\n baseFormatter?: OntologyIrBaseFormatter;\n}\n\nexport interface InterfaceSharedPropertyType {\n sharedPropertyType: SharedPropertyType;\n required: boolean;\n}\n\nexport function isInterfaceSharedPropertyType(\n interfacePropertyType: InterfacePropertyType,\n): interfacePropertyType is InterfaceSharedPropertyType {\n return \"sharedPropertyType\" in interfacePropertyType;\n}\n\nexport function getInterfacePropertyTypeType(\n interfacePropertyType: InterfacePropertyType,\n): PropertyTypeType {\n return isInterfaceSharedPropertyType(interfacePropertyType)\n ? interfacePropertyType.sharedPropertyType.type\n : interfacePropertyType.type;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA,OAAO,SAASA,6BAA6BA,CAC3CC,qBAA4C,EACU;EACtD,OAAO,oBAAoB,IAAIA,qBAAqB;AACtD;AAEA,OAAO,SAASC,4BAA4BA,CAC1CD,qBAA4C,EAC1B;EAClB,OAAOD,6BAA6B,CAACC,qBAAqB,CAAC,GACvDA,qBAAqB,CAACE,kBAAkB,CAACC,IAAI,GAC7CH,qBAAqB,CAACG,IAAI;AAChC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.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 InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.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 InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {\n InterfacePropertyType,\n InterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\n\nexport interface InterfaceType extends\n OntologyEntityBase,\n Omit<\n OntologyIrMarketplaceInterfaceType,\n // we want our simplified representation\n | \"properties\"\n // these things don't need to exist as the system works fine without them (I'm told)\n | \"propertiesV2\"\n | \"propertiesV3\"\n | \"extendsInterfaces\"\n >\n{\n propertiesV2: Record<string, InterfaceSharedPropertyType>;\n propertiesV3: Record<string, InterfacePropertyType>;\n extendsInterfaces: Array<InterfaceType>;\n status: InterfaceTypeStatus;\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { isInterfaceSharedPropertyType } from "./InterfacePropertyType.js";
|
|
17
18
|
export function getFlattenedInterfaceProperties(interfaceType) {
|
|
18
|
-
let properties = interfaceType.
|
|
19
|
+
let properties = Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([key, value]) => [isInterfaceSharedPropertyType(value) ? value.sharedPropertyType.apiName : key, value]));
|
|
20
|
+
Object.entries(interfaceType.propertiesV2).forEach(([apiName, spt]) => {
|
|
21
|
+
if (!(apiName in properties)) {
|
|
22
|
+
properties[apiName] = spt;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
interfaceType.extendsInterfaces.forEach(ext => {
|
|
20
26
|
properties = {
|
|
21
|
-
...
|
|
22
|
-
...
|
|
27
|
+
...getFlattenedInterfaceProperties(ext),
|
|
28
|
+
...properties
|
|
23
29
|
};
|
|
24
30
|
});
|
|
25
31
|
return properties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFlattenedInterfaceProperties.js","names":["getFlattenedInterfaceProperties","interfaceType","properties","
|
|
1
|
+
{"version":3,"file":"getFlattenedInterfaceProperties.js","names":["isInterfaceSharedPropertyType","getFlattenedInterfaceProperties","interfaceType","properties","Object","fromEntries","entries","propertiesV3","map","key","value","sharedPropertyType","apiName","propertiesV2","forEach","spt","extendsInterfaces","ext"],"sources":["getFlattenedInterfaceProperties.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 {\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\nimport type { InterfaceType } from \"./InterfaceType.js\";\n\nexport function getFlattenedInterfaceProperties(\n interfaceType: InterfaceType,\n): Record<string, InterfacePropertyType> {\n let properties: Record<string, InterfacePropertyType> = Object.fromEntries(\n Object.entries(interfaceType.propertiesV3).map(([key, value]) => [\n isInterfaceSharedPropertyType(value)\n ? value.sharedPropertyType.apiName\n : key,\n value,\n ]),\n );\n Object.entries(interfaceType.propertiesV2).forEach(([apiName, spt]) => {\n if (!(apiName in properties)) {\n properties[apiName] = spt;\n }\n });\n interfaceType.extendsInterfaces.forEach(ext => {\n properties = {\n ...getFlattenedInterfaceProperties(ext),\n ...properties,\n };\n });\n return properties;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,6BAA6B,QACxB,4BAA4B;AAGnC,OAAO,SAASC,+BAA+BA,CAC7CC,aAA4B,EACW;EACvC,IAAIC,UAAiD,GAAGC,MAAM,CAACC,WAAW,CACxED,MAAM,CAACE,OAAO,CAACJ,aAAa,CAACK,YAAY,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAC/DV,6BAA6B,CAACU,KAAK,CAAC,GAChCA,KAAK,CAACC,kBAAkB,CAACC,OAAO,GAChCH,GAAG,EACPC,KAAK,CACN,CACH,CAAC;EACDN,MAAM,CAACE,OAAO,CAACJ,aAAa,CAACW,YAAY,CAAC,CAACC,OAAO,CAAC,CAAC,CAACF,OAAO,EAAEG,GAAG,CAAC,KAAK;IACrE,IAAI,EAAEH,OAAO,IAAIT,UAAU,CAAC,EAAE;MAC5BA,UAAU,CAACS,OAAO,CAAC,GAAGG,GAAG;IAC3B;EACF,CAAC,CAAC;EACFb,aAAa,CAACc,iBAAiB,CAACF,OAAO,CAACG,GAAG,IAAI;IAC7Cd,UAAU,GAAG;MACX,GAAGF,+BAA+B,CAACgB,GAAG,CAAC;MACvC,GAAGd;IACL,CAAC;EACH,CAAC,CAAC;EACF,OAAOA,UAAU;AACnB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectType.js","names":[],"sources":["ObjectType.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 { OntologyIrObjectType, Visibility } from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyType } from \"./ObjectPropertyType.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectType =\n & OntologyEntityBase\n & RequiredFields<\n Partial<ObjectTypeInner>,\n | \"apiName\"\n | \"primaryKeyPropertyApiName\"\n | \"displayName\"\n | \"pluralDisplayName\"\n | \"titlePropertyApiName\"\n >\n & {\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n __type: OntologyEntityTypeEnum.OBJECT_TYPE;\n };\n\nexport interface ObjectTypeInner extends\n Omit<\n OntologyIrObjectType,\n | \"titlePropertyTypeRid\"\n | \"propertyTypes\"\n | \"allImplementsInterfaces\"\n | \"implementsInterfaces2\"\n | \"displayMetadata\"\n | \"primaryKeys\"\n | \"status\"\n >\n{\n primaryKeyPropertyApiName: string;\n properties: Array<ObjectPropertyType>;\n titlePropertyApiName: string;\n implementsInterfaces: Array<InterfaceImplementation>;\n description: string | undefined;\n icon: { locator: BlueprintIcon; color: string } | undefined;\n displayName: string;\n pluralDisplayName: string;\n visibility: Visibility;\n editsEnabled: boolean;\n status?: ObjectTypeStatus;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectType.js","names":[],"sources":["ObjectType.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 { OntologyIrObjectType, Visibility } from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyType } from \"./ObjectPropertyType.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectType =\n & OntologyEntityBase\n & RequiredFields<\n Partial<ObjectTypeInner>,\n | \"apiName\"\n | \"primaryKeyPropertyApiName\"\n | \"displayName\"\n | \"pluralDisplayName\"\n | \"titlePropertyApiName\"\n >\n & {\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n __type: OntologyEntityTypeEnum.OBJECT_TYPE;\n };\n\nexport interface ObjectTypeInner extends\n Omit<\n OntologyIrObjectType,\n | \"titlePropertyTypeRid\"\n | \"propertyTypes\"\n | \"allImplementsInterfaces\"\n | \"implementsInterfaces2\"\n | \"displayMetadata\"\n | \"primaryKeys\"\n | \"status\"\n >\n{\n primaryKeyPropertyApiName: string;\n properties: Array<ObjectPropertyType>;\n titlePropertyApiName: string;\n implementsInterfaces: Array<InterfaceImplementation>;\n description: string | undefined;\n icon: { locator: BlueprintIcon; color: string } | undefined;\n displayName: string;\n pluralDisplayName: string;\n visibility: Visibility;\n editsEnabled: boolean;\n status?: ObjectTypeStatus;\n aliases?: Array<string>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTypeDefinition.js","names":[],"sources":["ObjectTypeDefinition.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 { Visibility } from \"@osdk/client.unstable\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectTypeDefinition = {\n apiName: string;\n primaryKeyPropertyApiName: string;\n displayName: string;\n pluralDisplayName: string;\n titlePropertyApiName: string;\n properties?: { [key: string]: ObjectPropertyTypeUserDefinition };\n implementsInterfaces?: Array<InterfaceImplementation>;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n visibility?: Visibility;\n editsEnabled?: boolean;\n status?: ObjectTypeStatus;\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectTypeDefinition.js","names":[],"sources":["ObjectTypeDefinition.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 { Visibility } from \"@osdk/client.unstable\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectTypeDefinition = {\n apiName: string;\n primaryKeyPropertyApiName: string;\n displayName: string;\n pluralDisplayName: string;\n titlePropertyApiName: string;\n properties?: { [key: string]: ObjectPropertyTypeUserDefinition };\n implementsInterfaces?: Array<InterfaceImplementation>;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n visibility?: Visibility;\n editsEnabled?: boolean;\n status?: ObjectTypeStatus;\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n aliases?: Array<string>;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -24,7 +24,7 @@ export function isExotic(type) {
|
|
|
24
24
|
if (typeof type === "string") {
|
|
25
25
|
return ["geopoint", "geoshape", "mediaReference", "geotimeSeries"].includes(type);
|
|
26
26
|
} else if (typeof type === "object" && type != null) {
|
|
27
|
-
return type.type === "marking" || type.type === "struct";
|
|
27
|
+
return type.type === "marking" || type.type === "struct" || type.type === "string" || type.type === "decimal";
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
}
|