@osdk/maker 0.16.0-beta.8 → 0.16.0
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 +142 -0
- package/build/browser/api/defineFunction.js +6 -5
- package/build/browser/api/defineFunction.js.map +1 -1
- package/build/browser/api/defineInterface.js +3 -0
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -0
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.js +9 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/cli/main.js +4 -147
- package/build/browser/cli/main.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/convertLink.js +9 -4
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/util/ApiNameValidator.js +26 -0
- package/build/browser/util/ApiNameValidator.js.map +1 -0
- package/build/cjs/index.cjs +107 -218
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +5 -1
- package/build/esm/api/defineFunction.js +6 -5
- package/build/esm/api/defineFunction.js.map +1 -1
- package/build/esm/api/defineInterface.js +3 -0
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -0
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.js +9 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/cli/main.js +4 -147
- package/build/esm/cli/main.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/convertLink.js +9 -4
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/util/ApiNameValidator.js +26 -0
- package/build/esm/util/ApiNameValidator.js.map +1 -0
- package/build/types/api/defineFunction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineObject.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/links/LinkType.d.ts +2 -0
- package/build/types/api/links/LinkType.d.ts.map +1 -1
- package/build/types/api/object/ObjectType.d.ts +1 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/build/types/util/ApiNameValidator.d.ts +4 -0
- package/build/types/util/ApiNameValidator.d.ts.map +1 -0
- package/package.json +6 -7
- package/build/browser/api/test/actions.test.js +0 -14402
- 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 -252
- package/build/browser/api/test/objectStatus.test.js.map +0 -1
- package/build/browser/api/test/objects.test.js +0 -4441
- package/build/browser/api/test/objects.test.js.map +0 -1
- package/build/browser/api/test/spt.test.js +0 -751
- 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/cjs/defineFunction-7ORD7HD4.cjs +0 -72
- package/build/cjs/defineFunction-7ORD7HD4.cjs.map +0 -1
- package/build/esm/api/test/actions.test.js +0 -14402
- 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 -252
- package/build/esm/api/test/objectStatus.test.js.map +0 -1
- package/build/esm/api/test/objects.test.js +0 -4441
- package/build/esm/api/test/objects.test.js.map +0 -1
- package/build/esm/api/test/spt.test.js +0 -751
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spt.test.js","names":["beforeEach","describe","expect","it","defineCreateObjectAction","defineInterface","defineObject","defineOntology","dumpOntologyFullMetadata","defineSharedPropertyType","apiName","type","toThrowErrorMatchingInlineSnapshot","fooSpt","displayName","properties","icon","color","locator","ontology","toMatchInlineSnapshot","structDefinition","fieldType","displayMetadata","description","undefined","spt","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","foo","precision","scale","obj","pluralDisplayName","primaryKeyPropertyApiName","titlePropertyApiName","id","price","action","objectType","priceParam","parameters","find","p","toBe","baseFormatter","number","base","maximumFractionDigits","aliases"],"sources":["spt.test.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 { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineCreateObjectAction } from \"../defineCreateObjectAction.js\";\nimport { defineInterface } from \"../defineInterface.js\";\nimport { defineObject } from \"../defineObject.js\";\nimport { defineOntology, dumpOntologyFullMetadata } from \"../defineOntology.js\";\nimport { defineSharedPropertyType } from \"../defineSpt.js\";\ndescribe(\"SPTs\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"doesn't let you create the same spt twice\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n\n expect(() => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n }).toThrowErrorMatchingInlineSnapshot(\n `[Error: Invariant failed: Shared property type com.palantir.foo already exists]`,\n );\n });\n\n it(\"uses a predefined spt\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: \"string\",\n });\n\n const FooInterface = defineInterface({\n apiName: \"FooInterface\",\n displayName: \"Foo Interface\",\n properties: {\n fooSpt,\n },\n icon: { color: \"#00000\", locator: \"airplane\" },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.FooInterface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.FooInterface\",\n \"displayMetadata\": {\n \"description\": \"Foo Interface\",\n \"displayName\": \"Foo Interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#00000\",\n \"locator\": \"airplane\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.fooSpt\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyBasedPropertyType\": {\n \"requireImplementation\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n \"type\": \"sharedPropertyBasedPropertyType\",\n },\n },\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"properly serializes both types of struct SPTs\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: {\n type: \"struct\",\n structDefinition: {\n \"simpleProperty\": \"boolean\",\n \"complexProperty\": {\n fieldType: \"date\",\n displayMetadata: {\n displayName: \"complex property\",\n description: undefined,\n },\n },\n },\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"struct\": {\n \"mainValue\": undefined,\n \"structFields\": [\n {\n \"aliases\": [],\n \"apiName\": \"simpleProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"simpleProperty\",\n },\n \"fieldType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"typeClasses\": [],\n },\n {\n \"aliases\": [],\n \"apiName\": \"complexProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"complex property\",\n },\n \"fieldType\": {\n \"date\": {},\n \"type\": \"date\",\n },\n \"typeClasses\": [],\n },\n ],\n },\n \"type\": \"struct\",\n },\n \"typeClasses\": [],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom string fields properly set\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: {\n type: \"string\",\n isLongText: true,\n supportsEfficientLeadingWildcard: true,\n supportsExactMatching: false,\n },\n });\n\n defineInterface({\n apiName: \"interface\",\n properties: { foo: spt },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.interface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.interface\",\n \"displayMetadata\": {\n \"description\": \"interface\",\n \"displayName\": \"interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#4C90F0\",\n \"locator\": \"layout-hierarchy\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.foo\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {\n \"com.palantir.foo\": {\n \"sharedPropertyBasedPropertyType\": {\n \"requireImplementation\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n \"type\": \"sharedPropertyBasedPropertyType\",\n },\n },\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom decimal fields properly set\", () => {\n const spt1 = defineSharedPropertyType({\n apiName: \"precision\",\n type: {\n type: \"decimal\",\n precision: 10,\n },\n });\n const spt2 = defineSharedPropertyType({\n apiName: \"scale\",\n type: {\n type: \"decimal\",\n scale: 5,\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.precision\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.precision\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"precision\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"decimal\": {\n \"precision\": 10,\n \"scale\": undefined,\n },\n \"type\": \"decimal\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n \"com.palantir.scale\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.scale\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"scale\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"decimal\": {\n \"precision\": undefined,\n \"scale\": 5,\n },\n \"type\": \"decimal\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n it(\"Object decimal property with precision/scale works in actions\", () => {\n const obj = defineObject({\n apiName: \"decimal-test\",\n displayName: \"Decimal Test\",\n pluralDisplayName: \"Decimal Tests\",\n primaryKeyPropertyApiName: \"id\",\n titlePropertyApiName: \"id\",\n properties: {\n id: { type: \"string\" },\n price: {\n type: { type: \"decimal\", precision: 10, scale: 2 },\n },\n },\n });\n const action = defineCreateObjectAction({ objectType: obj });\n const priceParam = action.parameters?.find(p => p.id === \"price\");\n expect(priceParam?.type).toBe(\"decimal\");\n });\n it(\"Number formatting works\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: \"double\",\n baseFormatter: {\n type: \"number\",\n number: {\n type: \"base\",\n base: {\n maximumFractionDigits: 1,\n },\n },\n },\n });\n expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"importedOntology\": {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {},\n },\n \"importedValueTypes\": {\n \"valueTypes\": [],\n },\n \"ontology\": {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": {\n \"number\": {\n \"base\": {\n \"maximumFractionDigits\": 1,\n },\n \"type\": \"base\",\n },\n \"type\": \"number\",\n },\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"double\": {},\n \"type\": \"double\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n },\n \"randomnessKey\": undefined,\n \"valueTypes\": {\n \"valueTypes\": [],\n },\n }\n `);\n });\n it(\"Aliases properly set\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: { type: \"string\" },\n aliases: [\"alias1\", \"alias2\"],\n });\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [\n \"alias1\",\n \"alias2\",\n ],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFjB,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACzCM,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdU,gBAAgB,EAAE;UAChB,gBAAgB,EAAE,SAAS;UAC3B,iBAAiB,EAAE;YACjBC,SAAS,EAAE,MAAM;YACjBC,eAAe,EAAE;cACfT,WAAW,EAAE,kBAAkB;cAC/BU,WAAW,EAAEC;YACf;UACF;QACF;MACF;IACF,CAAC,CAAC;IAEFvB,MAAM,CAACM,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFjB,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAMuB,GAAG,GAAGjB,wBAAwB,CAAC;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdgB,UAAU,EAAE,IAAI;QAChBC,gCAAgC,EAAE,IAAI;QACtCC,qBAAqB,EAAE;MACzB;IACF,CAAC,CAAC;IAEFxB,eAAe,CAAC;MACdK,OAAO,EAAE,WAAW;MACpBK,UAAU,EAAE;QAAEe,GAAG,EAAEJ;MAAI;IACzB,CAAC,CAAC;IAEFxB,MAAM,CAACM,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFjB,EAAE,CAAC,oCAAoC,EAAE,MAAM;IAChCM,wBAAwB,CAAC;MACpCC,OAAO,EAAE,WAAW;MACpBC,IAAI,EAAE;QACJA,IAAI,EAAE,SAAS;QACfoB,SAAS,EAAE;MACb;IACF,CAAC,CAAC;IACWtB,wBAAwB,CAAC;MACpCC,OAAO,EAAE,OAAO;MAChBC,IAAI,EAAE;QACJA,IAAI,EAAE,SAAS;QACfqB,KAAK,EAAE;MACT;IACF,CAAC,CAAC;IAEF9B,MAAM,CAACM,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EACFjB,EAAE,CAAC,+DAA+D,EAAE,MAAM;IACxE,MAAM8B,GAAG,GAAG3B,YAAY,CAAC;MACvBI,OAAO,EAAE,cAAc;MACvBI,WAAW,EAAE,cAAc;MAC3BoB,iBAAiB,EAAE,eAAe;MAClCC,yBAAyB,EAAE,IAAI;MAC/BC,oBAAoB,EAAE,IAAI;MAC1BrB,UAAU,EAAE;QACVsB,EAAE,EAAE;UAAE1B,IAAI,EAAE;QA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C;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;QAAEA,IAAI,EAAE;MAAS,CAAC;MACxBuC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ;IAC9B,CAAC,CAAC;IACFhD,MAAM,CAACM,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,307 +0,0 @@
|
|
|
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 { beforeEach, describe, expect, it } from "vitest";
|
|
18
|
-
import { defineObject } from "../defineObject.js";
|
|
19
|
-
import { defineOntology, dumpOntologyFullMetadata, dumpValueTypeWireType } from "../defineOntology.js";
|
|
20
|
-
import { defineValueType } from "../defineValueType.js";
|
|
21
|
-
describe("Value Types", () => {
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
await defineOntology("com.palantir.", () => {}, "/tmp/");
|
|
24
|
-
});
|
|
25
|
-
it("Fails to define value type with incorrect semver", () => {
|
|
26
|
-
expect(() => defineValueType({
|
|
27
|
-
apiName: "apiName",
|
|
28
|
-
displayName: "displayName",
|
|
29
|
-
type: {
|
|
30
|
-
"type": "boolean",
|
|
31
|
-
constraints: [{
|
|
32
|
-
constraint: {
|
|
33
|
-
"allowedValues": ["TRUE_VALUE"]
|
|
34
|
-
}
|
|
35
|
-
}]
|
|
36
|
-
},
|
|
37
|
-
version: "not a version"
|
|
38
|
-
})).toThrowErrorMatchingInlineSnapshot("[Error: Invariant failed: Version is not a valid semver]");
|
|
39
|
-
});
|
|
40
|
-
it("Tests convertProperty function with valueType constraints for string", () => {
|
|
41
|
-
const testStringValueType = defineValueType({
|
|
42
|
-
apiName: "stringWithConstraints",
|
|
43
|
-
displayName: "String With Constraints",
|
|
44
|
-
description: "A string type with additional constraints",
|
|
45
|
-
type: {
|
|
46
|
-
"type": "string",
|
|
47
|
-
constraints: [{
|
|
48
|
-
constraint: {
|
|
49
|
-
type: "length",
|
|
50
|
-
length: {
|
|
51
|
-
minSize: 5,
|
|
52
|
-
maxSize: 20
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
failureMessage: {
|
|
56
|
-
message: "String must be between 5 and 20 characters"
|
|
57
|
-
}
|
|
58
|
-
}]
|
|
59
|
-
},
|
|
60
|
-
version: "1.0.0"
|
|
61
|
-
});
|
|
62
|
-
defineObject({
|
|
63
|
-
titlePropertyApiName: "constrainedString",
|
|
64
|
-
displayName: "Test Object",
|
|
65
|
-
pluralDisplayName: "Test Objects",
|
|
66
|
-
apiName: "testObject",
|
|
67
|
-
primaryKeyPropertyApiName: "constrainedString",
|
|
68
|
-
properties: {
|
|
69
|
-
"constrainedString": {
|
|
70
|
-
type: "string",
|
|
71
|
-
displayName: "Constrained String",
|
|
72
|
-
valueType: testStringValueType
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const ontology = dumpOntologyFullMetadata();
|
|
77
|
-
const objectPropertyType = ontology.ontology.objectTypes["com.palantir.testObject"].objectType.propertyTypes["constrainedString"];
|
|
78
|
-
expect(objectPropertyType.valueType).toEqual({
|
|
79
|
-
apiName: "stringWithConstraints",
|
|
80
|
-
version: "1.0.0",
|
|
81
|
-
packageNamespace: "com.palantir",
|
|
82
|
-
displayMetadata: {
|
|
83
|
-
displayName: "String With Constraints",
|
|
84
|
-
description: "A string type with additional constraints"
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
expect(objectPropertyType.dataConstraints).toBeDefined();
|
|
88
|
-
expect(objectPropertyType.dataConstraints?.propertyTypeConstraints).toHaveLength(1);
|
|
89
|
-
const constraintWrapper = objectPropertyType.dataConstraints?.propertyTypeConstraints[0];
|
|
90
|
-
expect(constraintWrapper?.constraints?.type).toBe("string");
|
|
91
|
-
expect((constraintWrapper?.constraints).string.length.minSize).toBe(5);
|
|
92
|
-
expect((constraintWrapper?.constraints).string.length.maxSize).toBe(20);
|
|
93
|
-
expect(constraintWrapper?.failureMessage?.message).toBe("String must be between 5 and 20 characters");
|
|
94
|
-
});
|
|
95
|
-
it("Correctly serializes a value type", () => {
|
|
96
|
-
defineValueType({
|
|
97
|
-
apiName: "apiName",
|
|
98
|
-
displayName: "displayName",
|
|
99
|
-
type: {
|
|
100
|
-
"type": "boolean",
|
|
101
|
-
constraints: [{
|
|
102
|
-
constraint: {
|
|
103
|
-
"allowedValues": ["TRUE_VALUE"]
|
|
104
|
-
}
|
|
105
|
-
}]
|
|
106
|
-
},
|
|
107
|
-
version: "0.1.0"
|
|
108
|
-
});
|
|
109
|
-
expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`
|
|
110
|
-
{
|
|
111
|
-
"valueTypes": [
|
|
112
|
-
{
|
|
113
|
-
"metadata": {
|
|
114
|
-
"apiName": "apiName",
|
|
115
|
-
"displayMetadata": {
|
|
116
|
-
"description": "",
|
|
117
|
-
"displayName": "displayName",
|
|
118
|
-
},
|
|
119
|
-
"packageNamespace": "com.palantir",
|
|
120
|
-
"status": {
|
|
121
|
-
"active": {},
|
|
122
|
-
"type": "active",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
"versions": [
|
|
126
|
-
{
|
|
127
|
-
"baseType": {
|
|
128
|
-
"boolean": {},
|
|
129
|
-
"type": "boolean",
|
|
130
|
-
},
|
|
131
|
-
"constraints": [
|
|
132
|
-
{
|
|
133
|
-
"constraint": {
|
|
134
|
-
"constraint": {
|
|
135
|
-
"boolean": {
|
|
136
|
-
"allowedValues": [
|
|
137
|
-
"TRUE_VALUE",
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
"type": "boolean",
|
|
141
|
-
},
|
|
142
|
-
"failureMessage": undefined,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
"exampleValues": [],
|
|
147
|
-
"version": "0.1.0",
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
}
|
|
153
|
-
`);
|
|
154
|
-
});
|
|
155
|
-
it("Correctly sets a status", () => {
|
|
156
|
-
defineValueType({
|
|
157
|
-
apiName: "apiName",
|
|
158
|
-
displayName: "displayName",
|
|
159
|
-
type: {
|
|
160
|
-
"type": "boolean",
|
|
161
|
-
constraints: [{
|
|
162
|
-
constraint: {
|
|
163
|
-
"allowedValues": ["TRUE_VALUE"]
|
|
164
|
-
}
|
|
165
|
-
}]
|
|
166
|
-
},
|
|
167
|
-
status: {
|
|
168
|
-
type: "deprecated",
|
|
169
|
-
deadline: "2026-01-01",
|
|
170
|
-
message: "This value type is deprecated"
|
|
171
|
-
},
|
|
172
|
-
version: "0.1.0"
|
|
173
|
-
});
|
|
174
|
-
expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`
|
|
175
|
-
{
|
|
176
|
-
"valueTypes": [
|
|
177
|
-
{
|
|
178
|
-
"metadata": {
|
|
179
|
-
"apiName": "apiName",
|
|
180
|
-
"displayMetadata": {
|
|
181
|
-
"description": "",
|
|
182
|
-
"displayName": "displayName",
|
|
183
|
-
},
|
|
184
|
-
"packageNamespace": "com.palantir",
|
|
185
|
-
"status": {
|
|
186
|
-
"deprecated": {
|
|
187
|
-
"deadline": "2026-01-01",
|
|
188
|
-
"message": "This value type is deprecated",
|
|
189
|
-
"replacedBy": undefined,
|
|
190
|
-
},
|
|
191
|
-
"type": "deprecated",
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
"versions": [
|
|
195
|
-
{
|
|
196
|
-
"baseType": {
|
|
197
|
-
"boolean": {},
|
|
198
|
-
"type": "boolean",
|
|
199
|
-
},
|
|
200
|
-
"constraints": [
|
|
201
|
-
{
|
|
202
|
-
"constraint": {
|
|
203
|
-
"constraint": {
|
|
204
|
-
"boolean": {
|
|
205
|
-
"allowedValues": [
|
|
206
|
-
"TRUE_VALUE",
|
|
207
|
-
],
|
|
208
|
-
},
|
|
209
|
-
"type": "boolean",
|
|
210
|
-
},
|
|
211
|
-
"failureMessage": undefined,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
"exampleValues": [],
|
|
216
|
-
"version": "0.1.0",
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
],
|
|
221
|
-
}
|
|
222
|
-
`);
|
|
223
|
-
});
|
|
224
|
-
it("Prefixes apiName with namespace when namespacePrefix is true", () => {
|
|
225
|
-
defineValueType({
|
|
226
|
-
apiName: "myValueType",
|
|
227
|
-
displayName: "My Value Type",
|
|
228
|
-
type: {
|
|
229
|
-
type: "string"
|
|
230
|
-
},
|
|
231
|
-
version: "1.0.0",
|
|
232
|
-
namespacePrefix: true
|
|
233
|
-
});
|
|
234
|
-
expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`
|
|
235
|
-
{
|
|
236
|
-
"valueTypes": [
|
|
237
|
-
{
|
|
238
|
-
"metadata": {
|
|
239
|
-
"apiName": "com.palantir.myValueType",
|
|
240
|
-
"displayMetadata": {
|
|
241
|
-
"description": "",
|
|
242
|
-
"displayName": "My Value Type",
|
|
243
|
-
},
|
|
244
|
-
"packageNamespace": "com.palantir",
|
|
245
|
-
"status": {
|
|
246
|
-
"active": {},
|
|
247
|
-
"type": "active",
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
"versions": [
|
|
251
|
-
{
|
|
252
|
-
"baseType": {
|
|
253
|
-
"string": {},
|
|
254
|
-
"type": "string",
|
|
255
|
-
},
|
|
256
|
-
"constraints": [],
|
|
257
|
-
"exampleValues": [],
|
|
258
|
-
"version": "1.0.0",
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
}
|
|
264
|
-
`);
|
|
265
|
-
});
|
|
266
|
-
it("Fails to define duplicate value type with same apiName and version", () => {
|
|
267
|
-
defineValueType({
|
|
268
|
-
apiName: "duplicateTest",
|
|
269
|
-
displayName: "First Value Type",
|
|
270
|
-
type: {
|
|
271
|
-
type: "string"
|
|
272
|
-
},
|
|
273
|
-
version: "1.0.0"
|
|
274
|
-
});
|
|
275
|
-
expect(() => defineValueType({
|
|
276
|
-
apiName: "duplicateTest",
|
|
277
|
-
displayName: "Second Value Type",
|
|
278
|
-
type: {
|
|
279
|
-
type: "boolean"
|
|
280
|
-
},
|
|
281
|
-
version: "1.0.0"
|
|
282
|
-
})).toThrowErrorMatchingInlineSnapshot("[Error: Invariant failed: Value type with apiName duplicateTest and version 1.0.0 is already defined]");
|
|
283
|
-
});
|
|
284
|
-
it("Allows multiple versions of the same value type", () => {
|
|
285
|
-
defineValueType({
|
|
286
|
-
apiName: "multiVersion",
|
|
287
|
-
displayName: "Multi Version Type",
|
|
288
|
-
type: {
|
|
289
|
-
type: "string"
|
|
290
|
-
},
|
|
291
|
-
version: "1.0.0"
|
|
292
|
-
});
|
|
293
|
-
defineValueType({
|
|
294
|
-
apiName: "multiVersion",
|
|
295
|
-
displayName: "Multi Version Type",
|
|
296
|
-
type: {
|
|
297
|
-
type: "string"
|
|
298
|
-
},
|
|
299
|
-
version: "2.0.0"
|
|
300
|
-
});
|
|
301
|
-
const wireType = dumpValueTypeWireType();
|
|
302
|
-
expect(wireType.valueTypes).toHaveLength(1);
|
|
303
|
-
expect(wireType.valueTypes[0].versions).toHaveLength(2);
|
|
304
|
-
expect(wireType.valueTypes[0].versions.map(v => v.version)).toEqual(["1.0.0", "2.0.0"]);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
//# sourceMappingURL=valueTypes.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"valueTypes.test.js","names":["beforeEach","describe","expect","it","defineObject","defineOntology","dumpOntologyFullMetadata","dumpValueTypeWireType","defineValueType","apiName","displayName","type","constraints","constraint","version","toThrowErrorMatchingInlineSnapshot","testStringValueType","description","length","minSize","maxSize","failureMessage","message","titlePropertyApiName","pluralDisplayName","primaryKeyPropertyApiName","properties","valueType","ontology","objectPropertyType","objectTypes","objectType","propertyTypes","toEqual","packageNamespace","displayMetadata","dataConstraints","toBeDefined","propertyTypeConstraints","toHaveLength","constraintWrapper","toBe","string","toMatchInlineSnapshot","status","deadline","namespacePrefix","wireType","valueTypes","versions","map","v"],"sources":["valueTypes.test.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 { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineObject } from \"../defineObject.js\";\nimport {\n defineOntology,\n dumpOntologyFullMetadata,\n dumpValueTypeWireType,\n} from \"../defineOntology.js\";\nimport { defineValueType } from \"../defineValueType.js\";\n\ndescribe(\"Value Types\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"Fails to define value type with incorrect semver\", () => {\n expect(() =>\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n type: {\n \"type\": \"boolean\",\n constraints: [{ constraint: { \"allowedValues\": [\"TRUE_VALUE\"] } }],\n },\n version: \"not a version\",\n })\n ).toThrowErrorMatchingInlineSnapshot(\n \"[Error: Invariant failed: Version is not a valid semver]\",\n );\n });\n\n it(\"Tests convertProperty function with valueType constraints for string\", () => {\n const testStringValueType = defineValueType({\n apiName: \"stringWithConstraints\",\n displayName: \"String With Constraints\",\n description: \"A string type with additional constraints\",\n type: {\n \"type\": \"string\",\n constraints: [\n {\n constraint: {\n type: \"length\",\n length: {\n minSize: 5,\n maxSize: 20,\n },\n },\n failureMessage: {\n message: \"String must be between 5 and 20 characters\",\n },\n },\n ],\n },\n version: \"1.0.0\",\n });\n\n const object = defineObject({\n titlePropertyApiName: \"constrainedString\",\n displayName: \"Test Object\",\n pluralDisplayName: \"Test Objects\",\n apiName: \"testObject\",\n primaryKeyPropertyApiName: \"constrainedString\",\n properties: {\n \"constrainedString\": {\n type: \"string\",\n displayName: \"Constrained String\",\n valueType: testStringValueType,\n },\n },\n });\n\n const ontology = dumpOntologyFullMetadata();\n const objectPropertyType =\n ontology.ontology.objectTypes[\"com.palantir.testObject\"]\n .objectType.propertyTypes[\"constrainedString\"];\n\n expect(objectPropertyType.valueType).toEqual({\n apiName: \"stringWithConstraints\",\n version: \"1.0.0\",\n packageNamespace: \"com.palantir\",\n displayMetadata: {\n displayName: \"String With Constraints\",\n description: \"A string type with additional constraints\",\n },\n });\n\n expect(objectPropertyType.dataConstraints).toBeDefined();\n expect(objectPropertyType.dataConstraints?.propertyTypeConstraints)\n .toHaveLength(1);\n\n const constraintWrapper = objectPropertyType.dataConstraints\n ?.propertyTypeConstraints[0];\n expect(constraintWrapper?.constraints?.type).toBe(\"string\");\n expect(\n (constraintWrapper?.constraints as {\n type: \"string\";\n string: { length: { minSize: number; maxSize: number } };\n }).string.length.minSize,\n ).toBe(5);\n expect(\n (constraintWrapper?.constraints as {\n type: \"string\";\n string: { length: { minSize: number; maxSize: number } };\n }).string.length.maxSize,\n ).toBe(20);\n expect(constraintWrapper?.failureMessage?.message).toBe(\n \"String must be between 5 and 20 characters\",\n );\n });\n\n it(\"Correctly serializes a value type\", () => {\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n type: {\n \"type\": \"boolean\",\n constraints: [{ constraint: { \"allowedValues\": [\"TRUE_VALUE\"] } }],\n },\n version: \"0.1.0\",\n });\n expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`\n {\n \"valueTypes\": [\n {\n \"metadata\": {\n \"apiName\": \"apiName\",\n \"displayMetadata\": {\n \"description\": \"\",\n \"displayName\": \"displayName\",\n },\n \"packageNamespace\": \"com.palantir\",\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n \"versions\": [\n {\n \"baseType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"constraints\": [\n {\n \"constraint\": {\n \"constraint\": {\n \"boolean\": {\n \"allowedValues\": [\n \"TRUE_VALUE\",\n ],\n },\n \"type\": \"boolean\",\n },\n \"failureMessage\": undefined,\n },\n },\n ],\n \"exampleValues\": [],\n \"version\": \"0.1.0\",\n },\n ],\n },\n ],\n }\n `);\n });\n it(\"Correctly sets a status\", () => {\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n type: {\n \"type\": \"boolean\",\n constraints: [{ constraint: { \"allowedValues\": [\"TRUE_VALUE\"] } }],\n },\n status: {\n type: \"deprecated\",\n deadline: \"2026-01-01\",\n message: \"This value type is deprecated\",\n },\n version: \"0.1.0\",\n });\n expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`\n {\n \"valueTypes\": [\n {\n \"metadata\": {\n \"apiName\": \"apiName\",\n \"displayMetadata\": {\n \"description\": \"\",\n \"displayName\": \"displayName\",\n },\n \"packageNamespace\": \"com.palantir\",\n \"status\": {\n \"deprecated\": {\n \"deadline\": \"2026-01-01\",\n \"message\": \"This value type is deprecated\",\n \"replacedBy\": undefined,\n },\n \"type\": \"deprecated\",\n },\n },\n \"versions\": [\n {\n \"baseType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"constraints\": [\n {\n \"constraint\": {\n \"constraint\": {\n \"boolean\": {\n \"allowedValues\": [\n \"TRUE_VALUE\",\n ],\n },\n \"type\": \"boolean\",\n },\n \"failureMessage\": undefined,\n },\n },\n ],\n \"exampleValues\": [],\n \"version\": \"0.1.0\",\n },\n ],\n },\n ],\n }\n `);\n });\n\n it(\"Prefixes apiName with namespace when namespacePrefix is true\", () => {\n defineValueType({\n apiName: \"myValueType\",\n displayName: \"My Value Type\",\n type: {\n type: \"string\",\n },\n version: \"1.0.0\",\n namespacePrefix: true,\n });\n expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`\n {\n \"valueTypes\": [\n {\n \"metadata\": {\n \"apiName\": \"com.palantir.myValueType\",\n \"displayMetadata\": {\n \"description\": \"\",\n \"displayName\": \"My Value Type\",\n },\n \"packageNamespace\": \"com.palantir\",\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n \"versions\": [\n {\n \"baseType\": {\n \"string\": {},\n \"type\": \"string\",\n },\n \"constraints\": [],\n \"exampleValues\": [],\n \"version\": \"1.0.0\",\n },\n ],\n },\n ],\n }\n `);\n });\n\n it(\"Fails to define duplicate value type with same apiName and version\", () => {\n defineValueType({\n apiName: \"duplicateTest\",\n displayName: \"First Value Type\",\n type: {\n type: \"string\",\n },\n version: \"1.0.0\",\n });\n\n expect(() =>\n defineValueType({\n apiName: \"duplicateTest\",\n displayName: \"Second Value Type\",\n type: {\n type: \"boolean\",\n },\n version: \"1.0.0\",\n })\n ).toThrowErrorMatchingInlineSnapshot(\n \"[Error: Invariant failed: Value type with apiName duplicateTest and version 1.0.0 is already defined]\",\n );\n });\n\n it(\"Allows multiple versions of the same value type\", () => {\n defineValueType({\n apiName: \"multiVersion\",\n displayName: \"Multi Version Type\",\n type: {\n type: \"string\",\n },\n version: \"1.0.0\",\n });\n\n defineValueType({\n apiName: \"multiVersion\",\n displayName: \"Multi Version Type\",\n type: {\n type: \"string\",\n },\n version: \"2.0.0\",\n });\n\n const wireType = dumpValueTypeWireType();\n expect(wireType.valueTypes).toHaveLength(1);\n expect(wireType.valueTypes[0].versions).toHaveLength(2);\n expect(wireType.valueTypes[0].versions.map(v => v.version)).toEqual([\n \"1.0.0\",\n \"2.0.0\",\n ]);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SACEC,cAAc,EACdC,wBAAwB,EACxBC,qBAAqB,QAChB,sBAAsB;AAC7B,SAASC,eAAe,QAAQ,uBAAuB;AAEvDP,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC5BD,UAAU,CAAC,YAAY;IACrB,MAAMK,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFF,EAAE,CAAC,kDAAkD,EAAE,MAAM;IAC3DD,MAAM,CAAC,MACLM,eAAe,CAAC;MACdC,OAAO,EAAE,SAAS;MAClBC,WAAW,EAAE,aAAa;MAC1BC,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS;QACjBC,WAAW,EAAE,CAAC;UAAEC,UAAU,EAAE;YAAE,eAAe,EAAE,CAAC,YAAY;UAAE;QAAE,CAAC;MACnE,CAAC;MACDC,OAAO,EAAE;IAC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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;EACFxC,EAAE,CAAC,yBAAyB,EAAE,MAAM;IAClCK,eAAe,CAAC;MACdC,OAAO,EAAE,SAAS;MAClBC,WAAW,EAAE,aAAa;MAC1BC,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS;QACjBC,WAAW,EAAE,CAAC;UAAEC,UAAU,EAAE;YAAE,eAAe,EAAE,CAAC,YAAY;UAAE;QAAE,CAAC;MACnE,CAAC;MACD+B,MAAM,EAAE;QACNjC,IAAI,EAAE,YAAY;QAClBkC,QAAQ,EAAE,YAAY;QACtBvB,OAAO,EAAE;MACX,CAAC;MACDR,OAAO,EAAE;IACX,CAAC,CAAC;IACFZ,MAAM,CAACK,qBAAqB,CAAC,CAAC,CAAC,CAACoC,qBAAqB,CAAC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFxC,EAAE,CAAC,8DAA8D,EAAE,MAAM;IACvEK,eAAe,CAAC;MACdC,OAAO,EAAE,aAAa;MACtBC,WAAW,EAAE,eAAe;MAC5BC,IAAI,EAAE;QACJA,IAAI,EAAE;MACR,CAAC;MACDG,OAAO,EAAE,OAAO;MAChBgC,eAAe,EAAE;IACnB,CAAC,CAAC;IACF5C,MAAM,CAACK,qBAAqB,CAAC,CAAC,CAAC,CAACoC,qBAAqB,CAAC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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CAClE,OAAO,EACP,OAAO,CACR,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var generatorConverters_ontologyir = require('@osdk/generator-converters.ontologyir');
|
|
4
|
-
var consola = require('consola');
|
|
5
|
-
var path = require('path');
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
26
|
-
|
|
27
|
-
// src/api/defineFunction.ts
|
|
28
|
-
var cachedFunctionDiscoverer = null;
|
|
29
|
-
async function loadFunctionDiscoverer() {
|
|
30
|
-
if (cachedFunctionDiscoverer != null) {
|
|
31
|
-
return cachedFunctionDiscoverer;
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const modulePath = "@foundry/functions-typescript-osdk-discovery";
|
|
35
|
-
const module = await import(
|
|
36
|
-
/* @vite-ignore */
|
|
37
|
-
modulePath
|
|
38
|
-
);
|
|
39
|
-
cachedFunctionDiscoverer = module.FunctionDiscoverer;
|
|
40
|
-
return cachedFunctionDiscoverer;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
consola.consola.warn("Failed to load @foundry/functions-typescript-osdk-discovery:", e instanceof Error ? e.message : e);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function extractFunctionEntries(discoveredFunctions) {
|
|
47
|
-
return discoveredFunctions.map((fn) => {
|
|
48
|
-
if (fn.locator.type !== "typescriptOsdk") {
|
|
49
|
-
throw new Error(`OAC functions must be TypeScript, got type: ${fn.locator.type}`);
|
|
50
|
-
}
|
|
51
|
-
const locator = fn.locator;
|
|
52
|
-
return [locator.typescriptOsdk.functionName, fn];
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async function generateFunctionsIr(rootDir, configPath, entityMappings) {
|
|
56
|
-
const functionsDiscoverer = await loadFunctionDiscoverer();
|
|
57
|
-
if (!functionsDiscoverer) {
|
|
58
|
-
throw new Error("Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed");
|
|
59
|
-
}
|
|
60
|
-
const tsConfigPath = configPath ?? path__namespace.join(rootDir, "tsconfig.json");
|
|
61
|
-
const program = generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, rootDir);
|
|
62
|
-
const functionsDir = path__namespace.join(rootDir, "functions");
|
|
63
|
-
const fd = new functionsDiscoverer(program, rootDir, functionsDir, entityMappings);
|
|
64
|
-
const functions = fd.discover();
|
|
65
|
-
return {
|
|
66
|
-
functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.generateFunctionsIr = generateFunctionsIr;
|
|
71
|
-
//# sourceMappingURL=defineFunction-7ORD7HD4.cjs.map
|
|
72
|
-
//# sourceMappingURL=defineFunction-7ORD7HD4.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/defineFunction.ts"],"names":["consola","path","OntologyIrToFullMetadataConverter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAI,wBAA2B,GAAA,IAAA;AAC/B,eAAe,sBAAyB,GAAA;AACtC,EAAA,IAAI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CAAA,IAAA,CAAA,OAAA,EAAS,WAAW,CAAA;AACnD,EAAA,MAAM,KAAK,IAAI,mBAAA,CAAoB,OAAS,EAAA,OAAA,EAAS,cAAc,cAAc,CAAA;AACjF,EAAM,MAAA,SAAA,GAAY,GAAG,QAAS,EAAA;AAC9B,EAAO,OAAA;AAAA,IACL,sBAAsB,MAAO,CAAA,WAAA,CAAY,sBAAuB,CAAA,SAAA,CAAU,mBAAmB,CAAC;AAAA,GAChG;AACF","file":"defineFunction-7ORD7HD4.cjs","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\";\n\n// Type definitions for optional function discovery dependencies\n\n// Lazy-loaded function discovery module\nlet cachedFunctionDiscoverer = null;\nasync function loadFunctionDiscoverer() {\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) {\n consola.warn(\"Failed to load @foundry/functions-typescript-osdk-discovery:\", e instanceof Error ? e.message : e);\n return null;\n }\n}\nfunction extractFunctionEntries(discoveredFunctions) {\n return discoveredFunctions.map(fn => {\n if (fn.locator.type !== \"typescriptOsdk\") {\n throw new Error(`OAC functions must be TypeScript, got type: ${fn.locator.type}`);\n }\n const locator = fn.locator;\n return [locator.typescriptOsdk.functionName, fn];\n });\n}\nexport async function generateFunctionsIr(rootDir, configPath, entityMappings) {\n const functionsDiscoverer = await loadFunctionDiscoverer();\n if (!functionsDiscoverer) {\n throw new Error(\"Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed\");\n }\n const tsConfigPath = configPath ?? path.join(rootDir, \"tsconfig.json\");\n const program = OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, rootDir);\n const functionsDir = path.join(rootDir, \"functions\");\n const fd = new functionsDiscoverer(program, rootDir, functionsDir, entityMappings);\n const functions = fd.discover();\n return {\n functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))\n };\n}"]}
|