@osdk/maker 0.15.0 → 0.16.0-beta.10
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 +89 -126
- package/README.md +18 -1
- package/build/browser/api/cloneDefinition.js +36 -0
- package/build/browser/api/cloneDefinition.js.map +1 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/browser/api/defineAction.js +9 -1
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateObjectAction.js +3 -1
- package/build/browser/api/defineCreateObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteObjectAction.js +3 -1
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -1
- package/build/browser/api/defineFunction.js +61 -0
- package/build/browser/api/defineFunction.js.map +1 -0
- package/build/browser/api/defineInterface.js +3 -1
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -1
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineModifyObjectAction.js +3 -1
- package/build/browser/api/defineModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +29 -10
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +29 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +3 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +3 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/object/ObjectPropertyType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/properties/ReducerType.js +2 -0
- package/build/browser/api/properties/ReducerType.js.map +1 -0
- package/build/browser/api/properties/SharedPropertyType.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +17 -6
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/browser/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/browser/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/browser/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/browser/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/browser/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/browser/index.js +5 -2
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +267 -105
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +214 -164
- package/build/esm/api/cloneDefinition.js +36 -0
- package/build/esm/api/cloneDefinition.js.map +1 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +1 -1
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/esm/api/defineAction.js +9 -1
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateObjectAction.js +3 -1
- package/build/esm/api/defineCreateObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js +3 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteObjectAction.js +3 -1
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -1
- package/build/esm/api/defineFunction.js +61 -0
- package/build/esm/api/defineFunction.js.map +1 -0
- package/build/esm/api/defineInterface.js +3 -1
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +6 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -1
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +3 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineModifyObjectAction.js +3 -1
- package/build/esm/api/defineModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +29 -10
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +29 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +3 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +3 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/object/ObjectPropertyType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/properties/ReducerType.js +2 -0
- package/build/esm/api/properties/ReducerType.js.map +1 -0
- package/build/esm/api/properties/SharedPropertyType.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +17 -6
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertMainValue.js +36 -0
- package/build/esm/conversion/toMarketplace/convertMainValue.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js +4 -3
- package/build/esm/conversion/toMarketplace/convertObjectPropertyType.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertReducers.js +53 -0
- package/build/esm/conversion/toMarketplace/convertReducers.js.map +1 -0
- package/build/esm/conversion/toMarketplace/convertSpt.js +5 -3
- package/build/esm/conversion/toMarketplace/convertSpt.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +4 -2
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/types/api/cloneDefinition.d.ts +9 -0
- package/build/types/api/cloneDefinition.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts +1 -1
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -1
- package/build/types/api/defineFunction.d.ts +19 -0
- package/build/types/api/defineFunction.d.ts.map +1 -0
- package/build/types/api/defineInterface.d.ts +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts +1 -1
- package/build/types/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts +1 -1
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +5 -0
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +3 -1
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/defineValueType.d.ts +1 -1
- package/build/types/api/defineValueType.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +1 -1
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/object/ObjectPropertyType.d.ts +2 -0
- package/build/types/api/object/ObjectPropertyType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +10 -3
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +4 -0
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/build/types/api/properties/ReducerType.d.ts +4 -0
- package/build/types/api/properties/ReducerType.d.ts.map +1 -0
- package/build/types/api/properties/SharedPropertyType.d.ts +2 -0
- package/build/types/api/properties/SharedPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertDatasourceDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts +4 -0
- package/build/types/conversion/toMarketplace/convertMainValue.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertObjectPropertyType.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertReducers.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertReducers.d.ts.map +1 -0
- 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/propertyTypeTypeToOntologyIrType.d.ts +2 -1
- package/build/types/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.d.ts.map +1 -1
- package/build/types/index.d.ts +14 -6
- package/build/types/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/build/browser/api/test/actions.test.js +0 -14397
- package/build/browser/api/test/actions.test.js.map +0 -1
- package/build/browser/api/test/interfaces.test.js +0 -1189
- package/build/browser/api/test/interfaces.test.js.map +0 -1
- package/build/browser/api/test/links.test.js +0 -2019
- package/build/browser/api/test/links.test.js.map +0 -1
- package/build/browser/api/test/markingconstraint.test.js +0 -134
- package/build/browser/api/test/markingconstraint.test.js.map +0 -1
- package/build/browser/api/test/misc.test.js +0 -1315
- package/build/browser/api/test/misc.test.js.map +0 -1
- package/build/browser/api/test/objectStatus.test.js +0 -160
- package/build/browser/api/test/objectStatus.test.js.map +0 -1
- package/build/browser/api/test/objects.test.js +0 -3856
- package/build/browser/api/test/objects.test.js.map +0 -1
- package/build/browser/api/test/spt.test.js +0 -722
- package/build/browser/api/test/spt.test.js.map +0 -1
- package/build/browser/api/test/valueTypes.test.js +0 -307
- package/build/browser/api/test/valueTypes.test.js.map +0 -1
- package/build/esm/api/test/actions.test.js +0 -14397
- package/build/esm/api/test/actions.test.js.map +0 -1
- package/build/esm/api/test/interfaces.test.js +0 -1189
- package/build/esm/api/test/interfaces.test.js.map +0 -1
- package/build/esm/api/test/links.test.js +0 -2019
- package/build/esm/api/test/links.test.js.map +0 -1
- package/build/esm/api/test/markingconstraint.test.js +0 -134
- package/build/esm/api/test/markingconstraint.test.js.map +0 -1
- package/build/esm/api/test/misc.test.js +0 -1315
- package/build/esm/api/test/misc.test.js.map +0 -1
- package/build/esm/api/test/objectStatus.test.js +0 -160
- package/build/esm/api/test/objectStatus.test.js.map +0 -1
- package/build/esm/api/test/objects.test.js +0 -3856
- package/build/esm/api/test/objects.test.js.map +0 -1
- package/build/esm/api/test/spt.test.js +0 -722
- package/build/esm/api/test/spt.test.js.map +0 -1
- package/build/esm/api/test/valueTypes.test.js +0 -307
- package/build/esm/api/test/valueTypes.test.js.map +0 -1
- package/build/types/api/test/actions.test.d.ts +0 -1
- package/build/types/api/test/actions.test.d.ts.map +0 -1
- package/build/types/api/test/interfaces.test.d.ts +0 -1
- package/build/types/api/test/interfaces.test.d.ts.map +0 -1
- package/build/types/api/test/links.test.d.ts +0 -1
- package/build/types/api/test/links.test.d.ts.map +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/test/misc.test.d.ts +0 -1
- package/build/types/api/test/misc.test.d.ts.map +0 -1
- package/build/types/api/test/objectStatus.test.d.ts +0 -1
- package/build/types/api/test/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/test/objects.test.d.ts +0 -1
- package/build/types/api/test/objects.test.d.ts.map +0 -1
- package/build/types/api/test/spt.test.d.ts +0 -1
- package/build/types/api/test/spt.test.d.ts.map +0 -1
- package/build/types/api/test/valueTypes.test.d.ts +0 -1
- package/build/types/api/test/valueTypes.test.d.ts.map +0 -1
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
17
18
|
import { defineAction, kebab } from "./defineAction.js";
|
|
18
|
-
export function defineDeleteInterfaceObjectAction(
|
|
19
|
+
export function defineDeleteInterfaceObjectAction(defInput) {
|
|
20
|
+
const def = cloneDefinition(defInput);
|
|
19
21
|
return defineAction({
|
|
20
22
|
apiName: def.apiName ?? `delete-interface-object-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}`,
|
|
21
23
|
displayName: def.displayName ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineDeleteInterfaceObjectAction.js","names":["defineAction","kebab","defineDeleteInterfaceObjectAction","def","apiName","interfaceType","split","pop","displayName","displayMetadata","parameters","id","type","interfaceReference","interfaceTypeRid","validation","required","allowedValues","status","rules","deleteObjectRule","objectToDelete","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","icon"],"sources":["defineDeleteInterfaceObjectAction.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 { ActionType } from \"./action/ActionType.js\";\nimport type { InterfaceActionTypeUserDefinition } from \"./defineAction.js\";\nimport { defineAction, kebab } from \"./defineAction.js\";\n\nexport function defineDeleteInterfaceObjectAction(\n
|
|
1
|
+
{"version":3,"file":"defineDeleteInterfaceObjectAction.js","names":["cloneDefinition","defineAction","kebab","defineDeleteInterfaceObjectAction","defInput","def","apiName","interfaceType","split","pop","displayName","displayMetadata","parameters","id","type","interfaceReference","interfaceTypeRid","validation","required","allowedValues","status","rules","deleteObjectRule","objectToDelete","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","icon"],"sources":["defineDeleteInterfaceObjectAction.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 { ActionType } from \"./action/ActionType.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { InterfaceActionTypeUserDefinition } from \"./defineAction.js\";\nimport { defineAction, kebab } from \"./defineAction.js\";\n\nexport function defineDeleteInterfaceObjectAction(\n defInput: InterfaceActionTypeUserDefinition,\n): ActionType {\n const def = cloneDefinition(defInput);\n return defineAction({\n apiName: def.apiName\n ?? `delete-interface-object-${\n kebab(\n def.interfaceType.apiName.split(\".\").pop()\n ?? def.interfaceType.apiName,\n )\n }`,\n displayName: def.displayName\n ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,\n parameters: [\n {\n id: \"objectToDeleteParameter\",\n displayName: \"Delete object\",\n type: {\n type: \"interfaceReference\",\n interfaceReference: { interfaceTypeRid: def.interfaceType.apiName },\n },\n validation: {\n required: true,\n allowedValues: { type: \"interfaceObjectQuery\" },\n },\n },\n ],\n status: def.status ?? \"active\",\n rules: [{\n type: \"deleteObjectRule\",\n deleteObjectRule: {\n objectToDelete: \"objectToDeleteParameter\",\n },\n }],\n entities: {\n affectedInterfaceTypes: [def.interfaceType.apiName],\n affectedObjectTypes: [],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n ...(def.icon &&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AAE,EAAE;MACrBC,UAAU,EAAE;IACd,CAAC;IACD,IAAIvB,GAAG,CAACwB,IAAI,IAAI;MAAEA,IAAI,EAAExB,GAAG,CAACwB;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
17
18
|
import { convertValidationRule, createParameters, defineAction, DELETE_OBJECT_PARAMETER, kebab } from "./defineAction.js";
|
|
18
|
-
export function defineDeleteObjectAction(
|
|
19
|
+
export function defineDeleteObjectAction(defInput) {
|
|
20
|
+
const def = cloneDefinition(defInput);
|
|
19
21
|
return defineAction({
|
|
20
22
|
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
21
23
|
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineDeleteObjectAction.js","names":["convertValidationRule","createParameters","defineAction","DELETE_OBJECT_PARAMETER","kebab","defineDeleteObjectAction","def","apiName","objectType","split","pop","displayName","parameters","Set","status","rules","type","deleteObjectRule","objectToDelete","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","icon"],"sources":["defineDeleteObjectAction.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 ActionType } from \"./action/ActionType.js\";\nimport type { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createParameters,\n defineAction,\n DELETE_OBJECT_PARAMETER,\n kebab,\n} from \"./defineAction.js\";\n\nexport function defineDeleteObjectAction(\n
|
|
1
|
+
{"version":3,"file":"defineDeleteObjectAction.js","names":["cloneDefinition","convertValidationRule","createParameters","defineAction","DELETE_OBJECT_PARAMETER","kebab","defineDeleteObjectAction","defInput","def","apiName","objectType","split","pop","displayName","parameters","Set","status","rules","type","deleteObjectRule","objectToDelete","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","icon"],"sources":["defineDeleteObjectAction.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 ActionType } from \"./action/ActionType.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createParameters,\n defineAction,\n DELETE_OBJECT_PARAMETER,\n kebab,\n} from \"./defineAction.js\";\n\nexport function defineDeleteObjectAction(\n defInput: ActionTypeUserDefinition,\n): ActionType {\n const def = cloneDefinition(defInput);\n return defineAction({\n apiName: def.apiName\n ?? `delete-object-${\n kebab(def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName)\n }`,\n displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,\n parameters: createParameters(def, {}, new Set([DELETE_OBJECT_PARAMETER])),\n status: def.status ?? \"active\",\n rules: [{\n type: \"deleteObjectRule\",\n deleteObjectRule: {\n objectToDelete: DELETE_OBJECT_PARAMETER,\n },\n }],\n entities: {\n affectedInterfaceTypes: [],\n affectedObjectTypes: [def.objectType.apiName],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n ...(def.actionLevelValidation\n ? {\n validation: convertValidationRule(\n def.actionLevelValidation,\n ),\n }\n : {}),\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;;AAGA,SAASA,eAAe,QAAQ,sBAAsB;AAEtD,SACEC,qBAAqB,EACrBC,gBAAgB,EAChBC,YAAY,EACZC,uBAAuB,EACvBC,KAAK,QACA,mBAAmB;AAE1B,OAAO,SAASC,wBAAwBA,CACtCC,QAAkC,EACtB;EACZ,MAAMC,GAAG,GAAGR,eAAe,CAACO,QAAQ,CAAC;EACrC,OAAOJ,YAAY,CAAC;IAClBM,OAAO,EAAED,GAAG,CAACC,OAAO,IACf,iBACDJ,KAAK,CAACG,GAAG,CAACE,UAAU,CAACD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,IAAIJ,GAAG,CAACE,UAAU,CAACD,OAAO,CAAC,EACxE;IACJI,WAAW,EAAEL,GAAG,CAACK,WAAW,IAAI,UAAUL,GAAG,CAACE,UAAU,CAACG,WAAW,EAAE;IACtEC,UAAU,EAAEZ,gBAAgB,CAACM,GAAG,EAAE,CAAC,CAAC,EAAE,IAAIO,GAAG,CAAC,CAACX,uBAAuB,CAAC,CAAC,CAAC;IACzEY,MAAM,EAAER,GAAG,CAACQ,MAAM,IAAI,QAAQ;IAC9BC,KAAK,EAAE,CAAC;MACNC,IAAI,EAAE,kBAAkB;MACxBC,gBAAgB,EAAE;QAChBC,cAAc,EAAEhB;MAClB;IACF,CAAC,CAAC;IACFiB,QAAQ,EAAE;MACRC,sBAAsB,EAAE,EAAE;MAC1BC,mBAAmB,EAAE,CAACf,GAAG,CAACE,UAAU,CAACD,OAAO,CAAC;MAC7Ce,iBAAiB,EAAE,EAAE;MACrBC,UAAU,EAAE;IACd,CAAC;IACD,IAAIjB,GAAG,CAACkB,qBAAqB,GACzB;MACAC,UAAU,EAAE1B,qBAAqB,CAC/BO,GAAG,CAACkB,qBACN;IACF,CAAC,GACC,CAAC,CAAC,CAAC;IACP,IAAIlB,GAAG,CAACoB,IAAI,IAAI;MAAEA,IAAI,EAAEpB,GAAG,CAACoB;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
|
|
18
|
+
import { consola } from "consola";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
|
|
21
|
+
// Type definitions for optional function discovery dependencies
|
|
22
|
+
|
|
23
|
+
// Lazy-loaded function discovery module
|
|
24
|
+
let cachedFunctionDiscoverer = null;
|
|
25
|
+
async function loadFunctionDiscoverer() {
|
|
26
|
+
if (cachedFunctionDiscoverer != null) {
|
|
27
|
+
return cachedFunctionDiscoverer;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const module = await import(/* @vite-ignore */"@foundry/functions-typescript-osdk-discovery");
|
|
31
|
+
cachedFunctionDiscoverer = module.FunctionDiscoverer;
|
|
32
|
+
return cachedFunctionDiscoverer;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
consola.warn("Failed to load @foundry/functions-typescript-osdk-discovery:", e instanceof Error ? e.message : e);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function extractFunctionEntries(discoveredFunctions) {
|
|
39
|
+
return discoveredFunctions.map(fn => {
|
|
40
|
+
if (fn.locator.type !== "typescriptOsdk") {
|
|
41
|
+
throw new Error(`OAC functions must be TypeScript, got type: ${fn.locator.type}`);
|
|
42
|
+
}
|
|
43
|
+
const locator = fn.locator;
|
|
44
|
+
return [locator.typescriptOsdk.functionName, fn];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export async function generateFunctionsIr(rootDir, configPath, entityMappings) {
|
|
48
|
+
const functionsDiscoverer = await loadFunctionDiscoverer();
|
|
49
|
+
if (!functionsDiscoverer) {
|
|
50
|
+
throw new Error("Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed");
|
|
51
|
+
}
|
|
52
|
+
const tsConfigPath = configPath ?? path.join(rootDir, "tsconfig.json");
|
|
53
|
+
const program = OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, rootDir);
|
|
54
|
+
const functionsDir = path.join(rootDir, "functions");
|
|
55
|
+
const fd = new functionsDiscoverer(program, rootDir, functionsDir, entityMappings);
|
|
56
|
+
const functions = fd.discover();
|
|
57
|
+
return {
|
|
58
|
+
functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=defineFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineFunction.js","names":["OntologyIrToFullMetadataConverter","consola","path","cachedFunctionDiscoverer","loadFunctionDiscoverer","module","FunctionDiscoverer","e","warn","Error","message","extractFunctionEntries","discoveredFunctions","map","fn","locator","type","typescriptOsdk","functionName","generateFunctionsIr","rootDir","configPath","entityMappings","functionsDiscoverer","tsConfigPath","join","program","createProgram","functionsDir","fd","functions","discover","functionsBlockDataV1","Object","fromEntries"],"sources":["defineFunction.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 { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport * as path from \"node:path\";\nimport type * as ts from \"typescript\";\n\nexport interface FunctionIrBlockData {\n functionsBlockDataV1: Record<string, unknown>;\n}\n\n// Type definitions for optional function discovery dependencies\ntype IFunctionDiscoverer = new(\n program: ts.Program,\n entryPointPath: string,\n fullFilePath: string,\n entityMappings?: IEntityMetadataMapping,\n) => {\n discover(): {\n discoveredFunctions: IDiscoveredFunction[];\n diagnostics?: unknown;\n };\n};\n\ninterface IDiscoveredFunction {\n locator:\n | { type: \"typescriptOsdk\"; typescriptOsdk: { functionName: string } }\n | { type: string };\n [key: string]: unknown;\n}\n\nexport interface IEntityMetadataMapping {\n ontologies: Record<\n string,\n {\n objectTypes: Record<\n string,\n {\n objectTypeId: string;\n primaryKey: { propertyId: string };\n propertyTypes: Record<string, { propertyId: string }>;\n linkTypes: Record<string, unknown>;\n }\n >;\n interfaceTypes: Record<string, unknown>;\n }\n >;\n}\n\n// Lazy-loaded function discovery module\nlet cachedFunctionDiscoverer: IFunctionDiscoverer | null = null;\n\nasync function loadFunctionDiscoverer(): Promise<IFunctionDiscoverer | null> {\n if (cachedFunctionDiscoverer != null) {\n return cachedFunctionDiscoverer;\n }\n try {\n const modulePath = \"@foundry/functions-typescript-osdk-discovery\";\n const module = await import(/* @vite-ignore */ modulePath);\n cachedFunctionDiscoverer = module.FunctionDiscoverer;\n return cachedFunctionDiscoverer;\n } catch (e: unknown) {\n consola.warn(\n \"Failed to load @foundry/functions-typescript-osdk-discovery:\",\n e instanceof Error ? e.message : e,\n );\n return null;\n }\n}\n\nfunction extractFunctionEntries(\n discoveredFunctions: IDiscoveredFunction[],\n): Array<[string, IDiscoveredFunction]> {\n return discoveredFunctions.map((fn: IDiscoveredFunction) => {\n if (fn.locator.type !== \"typescriptOsdk\") {\n throw new Error(\n `OAC functions must be TypeScript, got type: ${fn.locator.type}`,\n );\n }\n const locator = fn.locator as {\n typescriptOsdk: { functionName: string };\n };\n return [locator.typescriptOsdk.functionName, fn];\n });\n}\n\nexport async function generateFunctionsIr(\n rootDir: string,\n configPath?: string,\n entityMappings?: IEntityMetadataMapping,\n): Promise<FunctionIrBlockData> {\n const functionsDiscoverer = await loadFunctionDiscoverer();\n if (!functionsDiscoverer) {\n throw new Error(\n \"Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed\",\n );\n }\n\n const tsConfigPath = configPath ?? path.join(rootDir, \"tsconfig.json\");\n const program = OntologyIrToFullMetadataConverter.createProgram(\n tsConfigPath,\n rootDir,\n );\n const functionsDir = path.join(rootDir, \"functions\");\n const fd = new functionsDiscoverer(\n program,\n rootDir,\n functionsDir,\n entityMappings,\n );\n const functions = fd.discover();\n\n return {\n functionsBlockDataV1: Object.fromEntries(\n extractFunctionEntries(functions.discoveredFunctions),\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,IAAI,MAAM,WAAW;;AAOjC;;AAsCA;AACA,IAAIC,wBAAo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AI,CAACuB,IAAI,CAACL,OAAO,EAAE,WAAW,CAAC;EACpD,MAAMS,EAAE,GAAG,IAAIN,mBAAmB,CAChCG,OAAO,EACPN,OAAO,EACPQ,YAAY,EACZN,cACF,CAAC;EACD,MAAMQ,SAAS,GAAGD,EAAE,CAACE,QAAQ,CAAC,CAAC;EAE/B,OAAO;IACLC,oBAAoB,EAAEC,MAAM,CAACC,WAAW,CACtCvB,sBAAsB,CAACmB,SAAS,CAAClB,mBAAmB,CACtD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
18
19
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
19
20
|
import { namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
20
21
|
import { isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
21
22
|
import { mapSimplifiedStatusToInterfaceTypeStatus } from "./interface/mapSimplifiedStatusToInterfaceTypeStatus.js";
|
|
22
23
|
import { combineApiNamespaceIfMissing } from "./namespace/combineApiNamespaceIfMissing.js";
|
|
23
24
|
import { isExotic, isPropertyTypeType } from "./properties/PropertyTypeType.js";
|
|
24
|
-
export function defineInterface(
|
|
25
|
+
export function defineInterface(interfaceDefInput) {
|
|
26
|
+
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
25
27
|
const apiName = namespace + interfaceDef.apiName;
|
|
26
28
|
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
|
|
27
29
|
|
|
@@ -1 +1 @@
|
|
|
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 | { type: \"example\" };\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;AA+B/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,CAACC,CAAC,EAAEC,GAAG,CAAC,KAAK;IACnB,MAAMC,QAAQ,GAAGxB,6BAA6B,CAACuB,GAAG,CAAC,GAAGA,GAAG,CAACC,QAAQ,GAAG,IAAI;IACzE,OAAO,CAACF,CAAC,EAAE;MACTG,kB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AsB,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":[]}
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","withoutNamespace","isInterfaceSharedPropertyType","mapSimplifiedStatusToInterfaceTypeStatus","combineApiNamespaceIfMissing","isExotic","isPropertyTypeType","defineInterface","interfaceDefInput","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 { cloneDefinition } from \"./cloneDefinition.js\";\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 | { type: \"example\" };\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 interfaceDefInput: InterfaceTypeDefinition,\n): InterfaceType {\n const interfaceDef = cloneDefinition(interfaceDefInput);\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;AACtC,SAASC,eAAe,QAAQ,sBAAsB;AAEtD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EACJ;EACpB,MAAMwB,uBAAuB,GAAGtD,gBAAgB,CAAC8B,IAAI,CAACrB,OAAO,CAAC;EAC9D,EACEJ,kBAAkB,CAACyB,IAAI,CAACA,IAAI,CAAC,IAAI1B,QAAQ,CAAC0B,IAAI,CAACA,IAAI,CAAC,IAAAlB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADtDpB,SAAS,QAEP,qBACE6D,IAAI,CAACC,SAAS,CAAC1B,IAAI,CAAC,iBACLrB,OAAO,qBAAqBA,OAAO,EAAE,IAJxDf,SAAS;EAMT,EACEG,SAAS,GAAGY,OAAO,KAAKqB,IAAI,CAACrB,OAAO,IAC/BA,OAAO,KAAK6C,uBAAuB,IAAA1C,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1CpB,SAAS,QAGP,oDACE6D,IAAI,CAACC,SAAS,CAAC;IAAEC,GAAG,EAAEhD,OAAO;IAAEA,OAAO,EAAEqB,IAAI,CAACrB;EAAQ,CAAC,CAAC,EACvD,IALJf,SAAS;EAOT,OAAOoC,IAAI;AACb","ignoreList":[]}
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
-
import {
|
|
18
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
19
|
+
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
20
|
+
import { importedTypes, namespace, withoutNamespace } from "./defineOntology.js";
|
|
19
21
|
import { combineApiNamespaceIfMissing } from "./namespace/combineApiNamespaceIfMissing.js";
|
|
20
|
-
export function defineInterfaceLinkConstraint(
|
|
22
|
+
export function defineInterfaceLinkConstraint(linkDefInput) {
|
|
23
|
+
const linkDef = cloneDefinition(linkDefInput);
|
|
24
|
+
!(importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Cannot define a link constraint from imported interface ${linkDef.from.apiName}. The "from" side must be a locally defined interface.`) : invariant(false) : void 0;
|
|
21
25
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
22
26
|
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;
|
|
23
27
|
linkDef.from.links.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","withoutNamespace","combineApiNamespaceIfMissing","defineInterfaceLinkConstraint","
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","importedTypes","namespace","withoutNamespace","combineApiNamespaceIfMissing","defineInterfaceLinkConstraint","linkDefInput","linkDef","INTERFACE_TYPE","from","apiName","process","env","NODE_ENV","fromLinkMeta","getLinkMeta","links","find","a","metadata","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","displayName","description","apiNameWithNamespace","apiNameWithoutNamespace"],"sources":["defineInterfaceLinkConstraint.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 { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n importedTypes,\n namespace,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport type { InterfaceType } from \"./interface/InterfaceType.js\";\nimport { combineApiNamespaceIfMissing } from \"./namespace/combineApiNamespaceIfMissing.js\";\n\ntype Meta = { apiName: string; displayName?: string; description?: string };\ntype ApiNameOrInterfaceType = string | InterfaceType;\n\ntype Many = {\n apiName: string;\n from: InterfaceType;\n toMany: ApiNameOrInterfaceType;\n toOne?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\ntype One = {\n apiName: string;\n from: InterfaceType;\n toOne: ApiNameOrInterfaceType;\n toMany?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\n\nexport function defineInterfaceLinkConstraint(\n linkDefInput: One | Many,\n): void {\n const linkDef = cloneDefinition(linkDefInput);\n\n invariant(\n importedTypes[OntologyEntityTypeEnum.INTERFACE_TYPE][linkDef.from.apiName]\n == null,\n `Cannot define a link constraint from imported interface ${linkDef.from.apiName}. The \"from\" side must be a locally defined interface.`,\n );\n\n const fromLinkMeta = getLinkMeta(linkDef);\n\n invariant(\n linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null,\n `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`,\n );\n\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: linkDef.required ?? true,\n });\n}\n\nfunction getLinkedType(t: string | InterfaceType) {\n return {\n type: \"interfaceType\" as const,\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\n\nfunction getLinkMeta(meta: One | Many): Required<Meta> {\n const { apiName, displayName, description } = meta;\n const apiNameWithNamespace = combineApiNamespaceIfMissing(namespace, apiName);\n const apiNameWithoutNamespace = withoutNamespace(apiNameWithNamespace);\n return {\n apiName: apiNameWithNamespace,\n displayName: displayName ?? apiNameWithoutNamespace,\n description: description ?? displayName ?? apiNameWithoutNamespace,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AACG,CAAyB,EAAE;EAChD,OAAO;IACLC,IAAI,EAAE,eAAwB;IAC9BC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACjB;EAC/C,CAAC;AACH;AAEA,SAASK,WAAWA,CAACe,IAAgB,EAAkB;EACrD,MAAM;IAAEpB,OAAO;IAAEqB,WAAW;IAAEC;EAAY,CAAC,GAAGF,IAAI;EAClD,MAAMG,oBAAoB,GAAG7B,4BAA4B,CAACF,SAAS,EAAEQ,OAAO,CAAC;EAC7E,MAAMwB,uBAAuB,GAAG/B,gBAAgB,CAAC8B,oBAAoB,CAAC;EACtE,OAAO;IACLvB,OAAO,EAAEuB,oBAAoB;IAC7BF,WAAW,EAAEA,WAAW,IAAIG,uBAAuB;IACnDF,WAAW,EAAEA,WAAW,IAAID,WAAW,IAAIG;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
17
18
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
18
19
|
import { convertToPluralDisplayName, uppercaseFirstLetter } from "./defineObject.js";
|
|
19
20
|
import { updateOntology } from "./defineOntology.js";
|
|
20
|
-
export function defineLink(
|
|
21
|
+
export function defineLink(linkDefinitionInput) {
|
|
22
|
+
const linkDefinition = cloneDefinition(linkDefinitionInput);
|
|
21
23
|
// NOTE: we would normally do validation here, but because of circular dependencies
|
|
22
24
|
// we have to wait to validate until everything has been defined. The code for validation
|
|
23
25
|
// was moved to convertLink.ts.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineLink.js","names":["OntologyEntityTypeEnum","convertToPluralDisplayName","uppercaseFirstLetter","updateOntology","defineLink","linkDefinition","fullLinkDefinition","one","convertUserOneToManyLinkDefinition","toMany","many","convertUserIntermediaryLinkDefinition","convertUserManyToManyLinkDefinition","linkType","cardinality","undefined","apiName","__type","LINK_TYPE","oneToMany","metadata","convertLinkTypeMetadata","manyToMany","intermediary","displayMetadata","displayName","pluralDisplayName","visibility","groupDisplayName","typeClasses"],"sources":["defineLink.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 { LinkTypeMetadata } from \"@osdk/client.unstable\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n convertToPluralDisplayName,\n uppercaseFirstLetter,\n} from \"./defineObject.js\";\nimport { updateOntology } from \"./defineOntology.js\";\nimport type {\n IntermediaryObjectLinkReference,\n IntermediaryObjectLinkReferenceUserDefinition,\n LinkType,\n LinkTypeDefinition,\n LinkTypeMetadataUserDefinition,\n ManyToManyObjectLinkReference,\n ManyToManyObjectLinkReferenceUserDefinition,\n OneToManyObjectLinkReference,\n OneToManyObjectLinkReferenceUserDefinition,\n} from \"./links/LinkType.js\";\n\nexport function defineLink(\n
|
|
1
|
+
{"version":3,"file":"defineLink.js","names":["cloneDefinition","OntologyEntityTypeEnum","convertToPluralDisplayName","uppercaseFirstLetter","updateOntology","defineLink","linkDefinitionInput","linkDefinition","fullLinkDefinition","one","convertUserOneToManyLinkDefinition","toMany","many","convertUserIntermediaryLinkDefinition","convertUserManyToManyLinkDefinition","linkType","cardinality","undefined","apiName","__type","LINK_TYPE","oneToMany","metadata","convertLinkTypeMetadata","manyToMany","intermediary","displayMetadata","displayName","pluralDisplayName","visibility","groupDisplayName","typeClasses"],"sources":["defineLink.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 { LinkTypeMetadata } from \"@osdk/client.unstable\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n convertToPluralDisplayName,\n uppercaseFirstLetter,\n} from \"./defineObject.js\";\nimport { updateOntology } from \"./defineOntology.js\";\nimport type {\n IntermediaryObjectLinkReference,\n IntermediaryObjectLinkReferenceUserDefinition,\n LinkType,\n LinkTypeDefinition,\n LinkTypeMetadataUserDefinition,\n ManyToManyObjectLinkReference,\n ManyToManyObjectLinkReferenceUserDefinition,\n OneToManyObjectLinkReference,\n OneToManyObjectLinkReferenceUserDefinition,\n} from \"./links/LinkType.js\";\n\nexport function defineLink(\n linkDefinitionInput: LinkTypeDefinition,\n): LinkType {\n const linkDefinition = cloneDefinition(linkDefinitionInput);\n // NOTE: we would normally do validation here, but because of circular dependencies\n // we have to wait to validate until everything has been defined. The code for validation\n // was moved to convertLink.ts.\n\n let fullLinkDefinition;\n if (\"one\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n one: convertUserOneToManyLinkDefinition(linkDefinition.one),\n toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany),\n };\n } else if (\"intermediaryObjectType\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserIntermediaryLinkDefinition(\n linkDefinition.many,\n ),\n toMany: convertUserIntermediaryLinkDefinition(\n linkDefinition.toMany,\n ),\n };\n } else {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserManyToManyLinkDefinition(linkDefinition.many),\n toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany),\n };\n }\n const linkType: LinkType = {\n cardinality: \"one\" in linkDefinition\n ? linkDefinition.cardinality\n : undefined,\n ...fullLinkDefinition,\n apiName: linkDefinition.apiName,\n __type: OntologyEntityTypeEnum.LINK_TYPE,\n };\n updateOntology(linkType);\n return linkType;\n}\n\nfunction convertUserOneToManyLinkDefinition(\n oneToMany: OneToManyObjectLinkReferenceUserDefinition,\n): OneToManyObjectLinkReference {\n return {\n ...oneToMany,\n metadata: convertLinkTypeMetadata(oneToMany.metadata),\n };\n}\n\nfunction convertUserManyToManyLinkDefinition(\n manyToMany: ManyToManyObjectLinkReferenceUserDefinition,\n): ManyToManyObjectLinkReference {\n return {\n ...manyToMany,\n metadata: convertLinkTypeMetadata(manyToMany.metadata),\n };\n}\n\nfunction convertUserIntermediaryLinkDefinition(\n intermediary: IntermediaryObjectLinkReferenceUserDefinition,\n): IntermediaryObjectLinkReference {\n return {\n ...intermediary,\n metadata: convertLinkTypeMetadata(intermediary.metadata),\n };\n}\n\nfunction convertLinkTypeMetadata(\n metadata: LinkTypeMetadataUserDefinition,\n): LinkTypeMetadata {\n return {\n apiName: metadata.apiName,\n displayMetadata: {\n displayName: metadata.displayName\n ?? uppercaseFirstLetter(metadata.apiName),\n pluralDisplayName: metadata.pluralDisplayName\n ?? convertToPluralDisplayName(metadata.apiName),\n visibility: metadata.visibility ?? \"NORMAL\",\n groupDisplayName: metadata.groupDisplayName ?? \"\",\n },\n typeClasses: [],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,0BAA0B,EAC1BC,oBAAoB,QACf,mBAAmB;AAC1B,SAASC,cAAc,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;IACL,GAAGA,UAAU;IACbF,QAAQ,EAAEC,uBAAuB,CAACC,UAAU,CAACF,QAAQ;EACvD,CAAC;AACH;AAEA,SAAST,qCAAqCA,CAC5CY,YAA2D,EAC1B;EACjC,OAAO;IACL,GAAGA,YAAY;IACfH,QAAQ,EAAEC,uBAAuB,CAACE,YAAY,CAACH,QAAQ;EACzD,CAAC;AACH;AAEA,SAASC,uBAAuBA,CAC9BD,QAAwC,EACtB;EAClB,OAAO;IACLJ,OAAO,EAAEI,QAAQ,CAACJ,OAAO;IACzBQ,eAAe,EAAE;MACfC,WAAW,EAAEL,QAAQ,CAACK,WAAW,IAC5BxB,oBAAoB,CAACmB,QAAQ,CAACJ,OAAO,CAAC;MAC3CU,iBAAiB,EAAEN,QAAQ,CAACM,iBAAiB,IACxC1B,0BAA0B,CAACoB,QAAQ,CAACJ,OAAO,CAAC;MACjDW,UAAU,EAAEP,QAAQ,CAACO,UAAU,IAAI,QAAQ;MAC3CC,gBAAgB,EAAER,QAAQ,CAACQ,gBAAgB,IAAI;IACjD,CAAC;IACDC,WAAW,EAAE;EACf,CAAC;AACH","ignoreList":[]}
|
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { convertInterfacePropertyMappingValue, convertMappingValue } from "../conversion/toMarketplace/convertMappingValue.js";
|
|
18
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
18
19
|
import { convertValidationRule, createDefaultParameterOrdering, createParameters, defineAction, getInterfaceParameterName, getNonNamespacedParameterName, isPropertyParameter, kebab, MODIFY_INTERFACE_OBJECT_PARAMETER, validateActionParameters, validateParameterOrdering } from "./defineAction.js";
|
|
19
20
|
import { getFlattenedInterfaceProperties } from "./interface/getFlattenedInterfaceProperties.js";
|
|
20
21
|
import { getInterfacePropertyTypeType, isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
21
|
-
export function defineModifyInterfaceObjectAction(
|
|
22
|
+
export function defineModifyInterfaceObjectAction(defInput) {
|
|
23
|
+
const def = cloneDefinition(defInput);
|
|
22
24
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
23
25
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
24
26
|
const actionInterfaceProperties = Object.entries(allProperties).filter(([apiName, type]) => {
|
|
@@ -1 +1 @@
|
|
|
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,GAAGL,+BAA+B,CAACI,GAAG,CAACE,aAAa,CAAC;EACxER,wBAAwB,CACtBM,GAAG,EACHG,MAAM,CAACC,IAAI,CAACH,aAAa,CAAC,EAC1BD,GAAG,CAACE,aAAa,CAACG,OACpB,CAAC;EACD,MAAMC,yBAAyB,GAAGH,MAAM,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C;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineModifyInterfaceObjectAction.js","names":["convertInterfacePropertyMappingValue","convertMappingValue","cloneDefinition","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","getInterfaceParameterName","getNonNamespacedParameterName","isPropertyParameter","kebab","MODIFY_INTERFACE_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","defineModifyInterfaceObjectAction","defInput","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 { cloneDefinition } from \"./cloneDefinition.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 defInput: InterfaceActionTypeUserDefinition,\n): ActionType {\n const def = cloneDefinition(defInput);\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;AAE3D,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,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,QAA2C,EAC/B;EACZ,MAAMC,GAAG,GAAGjB,eAAe,CAACgB,QAAQ,CAAC;EACrC,MAAME,aAAa,GAAGN,+BAA+B,CAACK,GAAG,CAACE,aAAa,CAAC;EACxET,wBAAwB,CACtBO,GAAG,EACHG,MAAM,CAACC,IAAI,CAACH,aAAa,CAAC,EAC1BD,GAAG,CAACE,aAAa,CAACG,OACpB,CAAC;EACD,MAAMC,yBAAyB,GAAGH,MAAM,CAACI,OAAO,CAACN,aAAa,CAAC,CAACO,MAAM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@@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { convertMappingValue } from "../conversion/toMarketplace/convertMappingValue.js";
|
|
18
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
18
19
|
import { convertValidationRule, createDefaultParameterOrdering, createParameters, defineAction, isPropertyParameter, kebab, MODIFY_OBJECT_PARAMETER, validateActionParameters, validateParameterOrdering } from "./defineAction.js";
|
|
19
|
-
export function defineModifyObjectAction(
|
|
20
|
+
export function defineModifyObjectAction(defInput) {
|
|
21
|
+
const def = cloneDefinition(defInput);
|
|
20
22
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
21
23
|
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter(id => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
22
24
|
const parameterNames = new Set(propertyParameters);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineModifyObjectAction.js","names":["convertMappingValue","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","isPropertyParameter","kebab","MODIFY_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","defineModifyObjectAction","def","Object","keys","objectType","properties","apiName","propertyParameters","filter","id","type","primaryKeyPropertyApiName","parameterNames","Set","parameterConfiguration","forEach","param","add","actionApiName","split","pop","parameterOrdering","includes","unshift","parameters","p","defaultValue","undefined","objectParameterPropertyValue","parameterId","propertyTypeId","mappings","fromEntries","entries","nonParameterMappings","map","value","displayName","status","rules","modifyObjectRule","objectToModify","propertyValues","structFieldValues","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyObjectAction.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 { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n isPropertyParameter,\n kebab,\n MODIFY_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\n\nexport function defineModifyObjectAction(\n
|
|
1
|
+
{"version":3,"file":"defineModifyObjectAction.js","names":["convertMappingValue","cloneDefinition","convertValidationRule","createDefaultParameterOrdering","createParameters","defineAction","isPropertyParameter","kebab","MODIFY_OBJECT_PARAMETER","validateActionParameters","validateParameterOrdering","defineModifyObjectAction","defInput","def","Object","keys","objectType","properties","apiName","propertyParameters","filter","id","type","primaryKeyPropertyApiName","parameterNames","Set","parameterConfiguration","forEach","param","add","actionApiName","split","pop","parameterOrdering","includes","unshift","parameters","p","defaultValue","undefined","objectParameterPropertyValue","parameterId","propertyTypeId","mappings","fromEntries","entries","nonParameterMappings","map","value","displayName","status","rules","modifyObjectRule","objectToModify","propertyValues","structFieldValues","entities","affectedInterfaceTypes","affectedObjectTypes","affectedLinkTypes","typeGroups","actionLevelValidation","validation","defaultFormat","enableLayoutSwitch","tableConfiguration","displayAndFormat","table","sections","section","submissionMetadata","icon"],"sources":["defineModifyObjectAction.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 { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { ActionTypeUserDefinition } from \"./defineAction.js\";\nimport {\n convertValidationRule,\n createDefaultParameterOrdering,\n createParameters,\n defineAction,\n isPropertyParameter,\n kebab,\n MODIFY_OBJECT_PARAMETER,\n validateActionParameters,\n validateParameterOrdering,\n} from \"./defineAction.js\";\n\nexport function defineModifyObjectAction(\n defInput: ActionTypeUserDefinition,\n): ActionType {\n const def = cloneDefinition(defInput);\n validateActionParameters(\n def,\n Object.keys(def.objectType.properties ?? {}),\n def.objectType.apiName,\n );\n const propertyParameters = Object.keys(def.objectType.properties ?? {})\n .filter(\n id =>\n isPropertyParameter(def, id, def.objectType.properties?.[id].type!)\n && id !== def.objectType.primaryKeyPropertyApiName,\n );\n const parameterNames = new Set(propertyParameters);\n Object.keys(def.parameterConfiguration ?? {}).forEach(param =>\n parameterNames.add(param)\n );\n parameterNames.add(MODIFY_OBJECT_PARAMETER);\n const actionApiName = def.apiName\n ?? `modify-object-${\n kebab(def.objectType.apiName.split(\".\").pop() ?? def.objectType.apiName)\n }`;\n if (def.parameterOrdering) {\n if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {\n def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);\n }\n validateParameterOrdering(\n def.parameterOrdering,\n parameterNames,\n actionApiName,\n );\n }\n const parameters = createParameters(\n def,\n def.objectType.properties ?? {},\n parameterNames,\n );\n parameters.forEach(\n p => {\n // create prefilled parameters for object type properties unless overridden\n if (def.objectType.properties?.[p.id] && p.defaultValue === undefined) {\n p.defaultValue = {\n type: \"objectParameterPropertyValue\",\n objectParameterPropertyValue: {\n parameterId: MODIFY_OBJECT_PARAMETER,\n propertyTypeId: p.id,\n },\n };\n }\n },\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 ?? `Modify ${def.objectType.displayName}`,\n parameters: parameters,\n status: def.status ?? \"active\",\n rules: [{\n type: \"modifyObjectRule\",\n modifyObjectRule: {\n objectToModify: MODIFY_OBJECT_PARAMETER,\n propertyValues: {\n ...Object.fromEntries(\n propertyParameters.map(\n p => [p, { type: \"parameterId\", parameterId: p }],\n ),\n ),\n ...mappings,\n },\n structFieldValues: {},\n },\n }],\n entities: {\n affectedInterfaceTypes: [],\n affectedObjectTypes: [def.objectType.apiName],\n affectedLinkTypes: [],\n typeGroups: [],\n },\n parameterOrdering: def.parameterOrdering\n ?? createDefaultParameterOrdering(\n def,\n Object.keys(def.objectType.properties ?? {}),\n parameters,\n MODIFY_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;AAExF,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SACEC,qBAAqB,EACrBC,8BAA8B,EAC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CAACrB,GAAG,CAACsB,OAAO,IAAI,CAACA,OAAO,CAAChD,EAAE,EAAEgD,OAAO,CAAC,CACnD;IACF,CAAC,CAAC;IACJ,IAAIxD,GAAG,CAACyD,kBAAkB,IACrB;MAAEA,kBAAkB,EAAEzD,GAAG,CAACyD;IAAmB,CAAC,CAAC;IACpD,IAAIzD,GAAG,CAAC0D,IAAI,IAAI;MAAEA,IAAI,EAAE1D,GAAG,CAAC0D;IAAK,CAAC;EACpC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -16,19 +16,20 @@
|
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { getObject } from "../conversion/toMarketplace/convertLink.js";
|
|
19
|
+
import { cloneDefinition } from "./cloneDefinition.js";
|
|
19
20
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
20
21
|
import { addNamespaceIfNone, importedTypes, namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
21
22
|
import { getFlattenedInterfaceProperties } from "./interface/getFlattenedInterfaceProperties.js";
|
|
22
23
|
import { getInterfacePropertyTypeType, isInterfaceSharedPropertyType } from "./interface/InterfacePropertyType.js";
|
|
23
|
-
import { isExotic } from "./properties/PropertyTypeType.js";
|
|
24
|
-
|
|
24
|
+
import { isExotic, isStruct } from "./properties/PropertyTypeType.js";
|
|
25
25
|
// From https://stackoverflow.com/a/79288714
|
|
26
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))$/;
|
|
27
27
|
|
|
28
28
|
// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)
|
|
29
29
|
const ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
30
30
|
const API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
31
|
-
export function defineObject(
|
|
31
|
+
export function defineObject(objectDefInput) {
|
|
32
|
+
const objectDef = cloneDefinition(objectDefInput);
|
|
32
33
|
const apiName = namespace + objectDef.apiName;
|
|
33
34
|
const propertyApiNames = objectDef.properties ? Object.keys(objectDef.properties) : [];
|
|
34
35
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== undefined) {
|
|
@@ -49,15 +50,23 @@ export function defineObject(objectDef) {
|
|
|
49
50
|
derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
// Validate
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// Validate property statuses match the object status.
|
|
54
|
+
// An experimental object can only have experimental properties.
|
|
55
|
+
// A deprecated object can only have deprecated properties.
|
|
56
|
+
// An example object can only have example properties.
|
|
57
|
+
// There is no restriction on property statuses of an active object.
|
|
58
|
+
const objectStatusType = getStatusType(objectDef.status);
|
|
59
|
+
if (objectStatusType === "experimental" || objectStatusType === "deprecated" || objectStatusType === "example") {
|
|
60
|
+
const mismatchedProperties = [];
|
|
55
61
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName, property]) => {
|
|
56
|
-
if (property.status
|
|
57
|
-
|
|
62
|
+
if (property.status !== undefined) {
|
|
63
|
+
const propertyStatusType = getStatusType(property.status);
|
|
64
|
+
if (propertyStatusType !== objectStatusType) {
|
|
65
|
+
mismatchedProperties.push(apiName);
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
});
|
|
60
|
-
!(
|
|
69
|
+
!(mismatchedProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object "${objectDef.apiName}" has "${objectStatusType}" status, but the following properties have a different status: ${mismatchedProperties.join(", ")}`) : invariant(false) : void 0;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
// Validate deprecated status deadline is in ISO 8601 format
|
|
@@ -65,7 +74,8 @@ export function defineObject(objectDef) {
|
|
|
65
74
|
const deadline = objectDef.status.deadline;
|
|
66
75
|
!(deadline !== undefined && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant(false) : void 0;
|
|
67
76
|
}
|
|
68
|
-
|
|
77
|
+
const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]?.type;
|
|
78
|
+
!(!isExotic(titleProp) || isStruct(titleProp) && titleProp.mainValue && !isExotic(titleProp.mainValue.type)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant(false) : void 0;
|
|
69
79
|
!!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;
|
|
70
80
|
objectDef.implementsInterfaces?.forEach(interfaceImpl => {
|
|
71
81
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
@@ -258,4 +268,13 @@ function isPrimitive(type) {
|
|
|
258
268
|
const typeType = typeof type === "string" ? type : type.type;
|
|
259
269
|
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
260
270
|
}
|
|
271
|
+
function getStatusType(status) {
|
|
272
|
+
if (status === undefined) {
|
|
273
|
+
return "active";
|
|
274
|
+
}
|
|
275
|
+
if (typeof status === "string") {
|
|
276
|
+
return status;
|
|
277
|
+
}
|
|
278
|
+
return status.type;
|
|
279
|
+
}
|
|
261
280
|
//# sourceMappingURL=defineObject.js.map
|