@osdk/maker 0.15.0-beta.5 → 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 +17 -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 +53 -14
- 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 +1872 -1412
- 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 +417 -114
- 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 +53 -14
- 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 +1872 -1412
- 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":"defineCreateInterfaceObjectAction.js","names":["convertMappingValue","addNamespaceToActionDefinition","convertValidationRule","CREATE_INTERFACE_OBJECT_PARAMETER","createDefaultParameterOrdering","createParameters","defineAction","getInterfaceParameterName","getNonNamespacedParameterName","isPropertyParameter","kebab","validateActionParameters","validateParameterOrdering","getFlattenedInterfaceProperties","defineCreateInterfaceObjectAction","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","addInterfaceRule","interfaceApiName","objectTypeParameter","sharedPropertyValues","parameterId","useNonNamespacedParameters","Array","from","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineCreateInterfaceObjectAction.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 CREATE_INTERFACE_OBJECT_PARAMETER,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n getInterfaceParameterName,\n getNonNamespacedParameterName,\n isPropertyParameter,\n kebab,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\n\nexport function defineCreateInterfaceObjectAction(\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(getInterfaceParameterName(def, param))\n );\n parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);\n const actionApiName = def.apiName ?? `create-${\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(CREATE_INTERFACE_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(CREATE_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 ?? `Create ${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: \"addInterfaceRule\",\n addInterfaceRule: {\n interfaceApiName: def.interfaceType.apiName,\n objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,\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 CREATE_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,iCAAiC,EACjCC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,yBAAyB,EACzBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,KAAK,EACLC,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,CACt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BC,gBAAgB,EAAE;QAChBC,KAAK,EAAE1D,GAAG,CAACwD;MACb;IACF,CAAC,CAAC;IACF,IAAIxD,GAAG,CAAC2D,QAAQ,IACX;MACDA,QAAQ,EAAExD,MAAM,CAACW,WAAW,CAC1Bd,GAAG,CAAC2D,QAAQ,CAAC/C,GAAG,CAACgD,OAAO,IAAI,CAACA,OAAO,CAAC5C,EAAE,EAAE4C,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAI5D,GAAG,CAAC6D,kBAAkB,IACrB;MAAEA,kBAAkB,EAAE7D,GAAG,CAAC6D;IAAmB,CAAC,CAAC;IACpD,IAAI7D,GAAG,CAAC8D,IAAI,IAAI;MAAEA,IAAI,EAAE9D,GAAG,CAAC8D;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineCreateInterfaceObjectAction.js","names":["convertInterfacePropertyMappingValue","convertMappingValue","convertValidationRule","CREATE_INTERFACE_OBJECT_PARAMETER","createDefaultParameterOrdering","createParameters","defineAction","getInterfaceParameterName","getNonNamespacedParameterName","isPropertyParameter","kebab","validateActionParameters","validateParameterOrdering","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","defineCreateInterfaceObjectAction","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","addInterfaceRule","interfaceApiName","objectTypeParameter","sharedPropertyValues","parameterId","useNonNamespacedParameters","interfacePropertyValues","logicRuleValue","Array","from","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineCreateInterfaceObjectAction.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 CREATE_INTERFACE_OBJECT_PARAMETER,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n getInterfaceParameterName,\n getNonNamespacedParameterName,\n isPropertyParameter,\n kebab,\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 defineCreateInterfaceObjectAction(\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 ) =>\n isPropertyParameter(\n def,\n apiName,\n getInterfacePropertyTypeType(type),\n )\n );\n const sptNames = actionInterfaceProperties\n .filter(([_apiName, type]) => isInterfaceSharedPropertyType(type))\n .map(([apiName]) => apiName);\n\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(getInterfaceParameterName(def, param))\n );\n parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);\n const actionApiName = def.apiName ?? `create-${\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(CREATE_INTERFACE_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(CREATE_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 ?? `Create ${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: \"addInterfaceRule\",\n addInterfaceRule: {\n interfaceApiName: def.interfaceType.apiName,\n objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,\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 CREATE_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,iCAAiC,EACjCC,8BAA8B,EAC9BC,gBAAgB,EAChBC,YAAY,EACZC,yBAAyB,EACzBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,KAAK,EACLC,wBAAwB,EACxBC,yBAAyB,QACpB,mBAAmB;AAC1B,SAASC,+BAA+B,QAAQ,gDAAgD;AAChG,SACEC,4BAA4B,EAC5BC,6BAA6B,QACxB,sCAAsC;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AAE,EAAE+C,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAIjE,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,29 +17,44 @@
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
19
19
|
import { namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
20
|
-
import {
|
|
20
|
+
import { isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
21
21
|
import { mapSimplifiedStatusToInterfaceTypeStatus } from "./interface/mapSimplifiedStatusToInterfaceTypeStatus.js";
|
|
22
22
|
import { combineApiNamespaceIfMissing } from "./namespace/combineApiNamespaceIfMissing.js";
|
|
23
|
-
import { isPropertyTypeType } from "./properties/PropertyTypeType.js";
|
|
23
|
+
import { isExotic, isPropertyTypeType } from "./properties/PropertyTypeType.js";
|
|
24
24
|
export function defineInterface(interfaceDef) {
|
|
25
25
|
const apiName = namespace + interfaceDef.apiName;
|
|
26
26
|
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
|
|
28
|
+
// legacy support for propertiesV2 (only SPTs)
|
|
29
|
+
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
30
|
+
return isInterfaceSharedPropertyType(prop) || "apiName" in prop;
|
|
31
|
+
}).map(([s, spt]) => {
|
|
32
|
+
const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;
|
|
33
|
+
return [s, {
|
|
34
|
+
sharedPropertyType: isInterfaceSharedPropertyType(spt) ? spt.sharedPropertyType : spt,
|
|
35
|
+
required: required
|
|
36
|
+
}];
|
|
37
|
+
}));
|
|
38
|
+
const propertiesV2 = Object.fromEntries(Object.entries(spts).map(([propName, type]) => {
|
|
39
|
+
const sptApiName = combineApiNamespaceIfMissing(namespace, type.sharedPropertyType.apiName);
|
|
40
|
+
return [sptApiName, {
|
|
41
|
+
required: type.required,
|
|
42
|
+
sharedPropertyType: verifyBasePropertyDefinition(namespace, propName, type.sharedPropertyType)
|
|
43
|
+
}];
|
|
44
|
+
}));
|
|
45
|
+
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName, prop]) => {
|
|
46
|
+
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
47
|
+
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
48
|
+
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
49
|
+
// SPT
|
|
31
50
|
return [apiName, {
|
|
32
|
-
required:
|
|
33
|
-
sharedPropertyType:
|
|
51
|
+
required: required,
|
|
52
|
+
sharedPropertyType: propertyBase
|
|
34
53
|
}];
|
|
54
|
+
} else {
|
|
55
|
+
// IDP
|
|
56
|
+
return [apiName, propertyBase];
|
|
35
57
|
}
|
|
36
|
-
|
|
37
|
-
// If the property is an imported SPT, use the SPT's apiName
|
|
38
|
-
const apiName = combineApiNamespaceIfMissing(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
39
|
-
return [apiName, {
|
|
40
|
-
required: true,
|
|
41
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
42
|
-
}];
|
|
43
58
|
}));
|
|
44
59
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
45
60
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
@@ -62,30 +77,21 @@ export function defineInterface(interfaceDef) {
|
|
|
62
77
|
extendsInterfaces,
|
|
63
78
|
links: [],
|
|
64
79
|
status,
|
|
65
|
-
propertiesV2:
|
|
80
|
+
propertiesV2: propertiesV2,
|
|
81
|
+
propertiesV3: propertiesV3,
|
|
66
82
|
searchable: interfaceDef.searchable ?? true,
|
|
67
83
|
__type: OntologyEntityTypeEnum.INTERFACE_TYPE
|
|
68
84
|
};
|
|
69
85
|
updateOntology(fullInterface);
|
|
70
86
|
return fullInterface;
|
|
71
87
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
return spt;
|
|
82
|
-
} else {
|
|
83
|
-
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
84
|
-
!(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
85
|
-
key: apiName,
|
|
86
|
-
apiName: type.apiName
|
|
87
|
-
})}`) : invariant(false) : void 0;
|
|
88
|
-
return type;
|
|
89
|
-
}
|
|
88
|
+
function verifyBasePropertyDefinition(namespace, apiName, type) {
|
|
89
|
+
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
90
|
+
!(isPropertyTypeType(type.type) || isExotic(type.type)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
|
|
91
|
+
!(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
92
|
+
key: apiName,
|
|
93
|
+
apiName: type.apiName
|
|
94
|
+
})}`) : invariant(false) : void 0;
|
|
95
|
+
return type;
|
|
90
96
|
}
|
|
91
97
|
//# sourceMappingURL=defineInterface.js.map
|
|
@@ -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"],"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I,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,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAGEC,6BAA6B,QACxB,sCAAsC;AAE7C,SAASC,wCAAwC,QAAQ,yDAAyD;AAClH,SAASC,4BAA4B,QAAQ,6CAA6C;AAC1F,SAASC,QAAQ,EAAEC,kBAAkB,QAAQ,kCAAkC;AA8B/E,OAAO,SAASC,eAAeA,CAC7BC,YAAqC,EACtB;EACf,MAAMC,OAAO,GAAGX,SAAS,GAAGU,YAAY,CAACC,OAAO;EAChD,EACEV,kBAAkB,CAACF,sBAAsB,CAACa,cAAc,CAAC,CAACD,OAAO,CAAC,KAC5DE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFjBlB,SAAS,QAGP,aAAaa,OAAO,iBAAiB,IAHvCb,SAAS;;EAMT;EACA,MAAMmB,IAAqC,GAAGC,MAAM,CAACC,WAAW,CAC9DD,MAAM,CAACE,OAAO,CAACV,YAAY,CAACW,UAAU,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAAC,CAAC,CAACC,KAAK,EAAEC,IAAI,CAAC,KAAK;IACtE,OAAOpB,6BAA6B,CAACoB,IAAI,CAAC,IAAI,SAAS,IAAIA,IAAI;EACjE,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,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BgB,KAAK,EAAE,EAAE;IACTZ,MAAM;IACNX,YAAY,EAAEA,YAAY;IAC1BK,YAAY,EAAEA,YAAY;IAC1BmB,UAAU,EAAE5C,YAAY,CAAC4C,UAAU,IAAI,IAAI;IAC3CC,MAAM,EAAExD,sBAAsB,CAACa;EACjC,CAAC;EAEDV,cAAc,CAAC2C,aAAa,CAAC;EAC7B,OAAOA,aAAa;AACtB;AAEA,SAASX,4BAA4BA,CACnClC,SAAiB,EACjBW,OAAe,EACfqB,IAAwB,EACJ;EACpB,MAAMwB,uBAAuB,GAAGrD,gBAAgB,CAAC6B,IAAI,CAACrB,OAAO,CAAC;EAC9D,EACEH,kBAAkB,CAACwB,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,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AqB,CAC/Ba,GAAG,CAACmD,qBAAqB,EACzBrB,UACF;IACF,CAAC,GACC,CAAC,CAAC,CAAC;IACP,IAAI9B,GAAG,CAACqD,aAAa,IAAI;MAAEA,aAAa,EAAErD,GAAG,CAACqD;IAAc,CAAC,CAAC;IAC9D,IAAIrD,GAAG,CAACsD,kBAAkB,IACrB;MAAEA,kBAAkB,EAAEtD,GAAG,CAACsD;IAAmB,CAAC,CAAC;IACpD,IAAItD,GAAG,CAACuD,kBAAkB,IAAI;MAC5BC,gBAAgB,EAAE;QAChBC,KAAK,EAAEzD,GAAG,CAACuD;MACb;IACF,CAAC,CAAC;IACF,IAAIvD,GAAG,CAAC0D,QAAQ,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;A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CAAC4D,kBAAkB,IACrB;MAAEA,kBAAkB,EAAE5D,GAAG,CAAC4D;IAAmB,CAAC,CAAC;IACpD,IAAI5D,GAAG,CAAC6D,kBAAkB,IAAI;MAC5BC,gBAAgB,EAAE;QAChBC,KAAK,EAAE/D,GAAG,CAAC6D;MACb;IACF,CAAC,CAAC;IACF,IAAI7D,GAAG,CAACgE,QAAQ,IACX;MACDA,QAAQ,EAAE7D,MAAM,CAACc,WAAW,CAC1BjB,GAAG,CAACgE,QAAQ,CAACpD,GAAG,CAACqD,OAAO,IAAI,CAACA,OAAO,CAAC/C,EAAE,EAAE+C,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAIjE,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 {
|
|
@@ -158,12 +162,43 @@ function validateDerivedDatasource(objectDef, datasource) {
|
|
|
158
162
|
validateAggregations(datasource, objectDef);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
|
-
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Gets properties for validation, handling self-referential links where
|
|
168
|
+
* the target object is the same as the object being defined (not yet in registry).
|
|
169
|
+
*/
|
|
170
|
+
function getPropertiesForValidation(linkObject, objectDef) {
|
|
171
|
+
const targetApiName = typeof linkObject === "string" ? linkObject : linkObject.apiName;
|
|
172
|
+
const selfApiName = namespace + objectDef.apiName;
|
|
173
|
+
|
|
174
|
+
// Self-referential: use objectDef directly (not yet in registry)
|
|
175
|
+
if (targetApiName === selfApiName) {
|
|
176
|
+
return {
|
|
177
|
+
apiName: selfApiName,
|
|
178
|
+
hasProperty: propName => objectDef.properties?.[propName] !== undefined
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Non-self-referential: look up from registry
|
|
183
|
+
const {
|
|
184
|
+
apiName,
|
|
185
|
+
object
|
|
186
|
+
} = getObject(linkObject);
|
|
187
|
+
return {
|
|
188
|
+
apiName,
|
|
189
|
+
hasProperty: propName => object.properties?.find(p => p.apiName === propName) !== undefined
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function validateLinkedProperties(datasource, objectDef) {
|
|
162
193
|
const foreignProperties = Object.values(datasource.propertyMapping);
|
|
163
194
|
// the foreign property must exist in the final object in the link chain
|
|
164
|
-
const
|
|
195
|
+
const targetObject = datasource.linkDefinition.at(-1).linkType.toMany.object;
|
|
196
|
+
const {
|
|
197
|
+
apiName,
|
|
198
|
+
hasProperty
|
|
199
|
+
} = getPropertiesForValidation(targetObject, objectDef);
|
|
165
200
|
foreignProperties.forEach(prop => {
|
|
166
|
-
!(
|
|
201
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant(false) : void 0;
|
|
167
202
|
});
|
|
168
203
|
}
|
|
169
204
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -199,8 +234,12 @@ function validateAggregations(datasource, objectDef) {
|
|
|
199
234
|
// if a foreign property is referenced, it must exist in the final object
|
|
200
235
|
if (agg.type !== "count") {
|
|
201
236
|
const foreignProperty = agg.property;
|
|
202
|
-
const
|
|
203
|
-
|
|
237
|
+
const targetObject = datasource.linkDefinition.at(-1).linkType.toMany.object;
|
|
238
|
+
const {
|
|
239
|
+
apiName,
|
|
240
|
+
hasProperty
|
|
241
|
+
} = getPropertiesForValidation(targetObject, objectDef);
|
|
242
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant(false) : void 0;
|
|
204
243
|
}
|
|
205
244
|
});
|
|
206
245
|
}
|