@osdk/maker 0.16.0-beta.5 → 0.16.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +4 -1
- package/build/browser/api/defineAction.js +6 -0
- package/build/browser/api/defineAction.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/defineOntology.js +29 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/test/objects.test.js +11 -2
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +28 -0
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +145 -2
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +7 -5
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/index.js +5 -2
- package/build/browser/index.js.map +1 -1
- package/build/cjs/defineFunction-7ORD7HD4.cjs +72 -0
- package/build/cjs/defineFunction-7ORD7HD4.cjs.map +1 -0
- package/build/cjs/index.cjs +198 -7
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +186 -153
- package/build/esm/api/defineAction.js +6 -0
- package/build/esm/api/defineAction.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/defineOntology.js +29 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/test/objects.test.js +11 -2
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +28 -0
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +145 -2
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +7 -5
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/types/api/defineAction.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/defineOntology.d.ts +5 -0
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +4 -2
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/cli/main.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 +7 -5
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
18
|
+
import { defineCreateObjectAction } from "../defineCreateObjectAction.js";
|
|
18
19
|
import { defineInterface } from "../defineInterface.js";
|
|
20
|
+
import { defineObject } from "../defineObject.js";
|
|
19
21
|
import { defineOntology, dumpOntologyFullMetadata } from "../defineOntology.js";
|
|
20
22
|
import { defineSharedPropertyType } from "../defineSpt.js";
|
|
21
23
|
describe("SPTs", () => {
|
|
@@ -566,6 +568,32 @@ describe("SPTs", () => {
|
|
|
566
568
|
}
|
|
567
569
|
`);
|
|
568
570
|
});
|
|
571
|
+
it("Object decimal property with precision/scale works in actions", () => {
|
|
572
|
+
const obj = defineObject({
|
|
573
|
+
apiName: "decimal-test",
|
|
574
|
+
displayName: "Decimal Test",
|
|
575
|
+
pluralDisplayName: "Decimal Tests",
|
|
576
|
+
primaryKeyPropertyApiName: "id",
|
|
577
|
+
titlePropertyApiName: "id",
|
|
578
|
+
properties: {
|
|
579
|
+
id: {
|
|
580
|
+
type: "string"
|
|
581
|
+
},
|
|
582
|
+
price: {
|
|
583
|
+
type: {
|
|
584
|
+
type: "decimal",
|
|
585
|
+
precision: 10,
|
|
586
|
+
scale: 2
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
const action = defineCreateObjectAction({
|
|
592
|
+
objectType: obj
|
|
593
|
+
});
|
|
594
|
+
const priceParam = action.parameters?.find(p => p.id === "price");
|
|
595
|
+
expect(priceParam?.type).toBe("decimal");
|
|
596
|
+
});
|
|
569
597
|
it("Number formatting works", () => {
|
|
570
598
|
defineSharedPropertyType({
|
|
571
599
|
apiName: "foo",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spt.test.js","names":["beforeEach","describe","expect","it","defineInterface","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","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 { defineInterface } from \"../defineInterface.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(\"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,QAAQ;AACzD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,cAAc,EAAEC,wBAAwB,QAAQ,sBAAsB;AAC/E,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1DN,QAAQ,CAAC,MAAM,EAAE,MAAM;EACrBD,UAAU,CAAC,YAAY;IACrB,MAAMK,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFF,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpDI,wBAAwB,CAAC;MACvBC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFP,MAAM,CAAC,MAAM;MACXK,wBAAwB,CAAC;QACvBC,OAAO,EAAE,KAAK;QACdC,IAAI,EAAE;MACR,CAAC,CAAC;IACJ,CAAC,CAAC,CAACC,kCAAkC,CACnC,iFACF,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAChC,MAAMQ,MAAM,GAAGJ,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;IACR,CAAC,CAAC;IAEmBL,eAAe,CAAC;MACnCI,OAAO,EAAE,cAAc;MACvBI,WAAW,EAAE,eAAe;MAC5BC,UAAU,EAAE;QACVF;MACF,CAAC;MACDG,IAAI,EAAE;QAAEC,KAAK,EAAE,QAAQ;QAAEC,OAAO,EAAE;MAAW;IAC/C,CAAC,CAAC;IAEFd,MAAM,CAACI,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,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFf,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACzCI,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;IAEFrB,MAAM,CAACI,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;EAEFf,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAMqB,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;IAEFvB,eAAe,CAAC;MACdI,OAAO,EAAE,WAAW;MACpBK,UAAU,EAAE;QAAEe,GAAG,EAAEJ;MAAI;IACzB,CAAC,CAAC;IAEFtB,MAAM,CAACI,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;EAEFf,EAAE,CAAC,oCAAoC,EAAE,MAAM;IAChCI,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;IAEF5B,MAAM,CAACI,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;EACFf,EAAE,CAAC,yBAAyB,EAAE,MAAM;IACtBI,wBAAwB,CAAC;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE,QAAQ;MACdsB,aAAa,EAAE;QACbtB,IAAI,EAAE,QAAQ;QACduB,MAAM,EAAE;UACNvB,IAAI,EAAE,MAAM;UACZwB,IAAI,EAAE;YACJC,qBAAqB,EAAE;UACzB;QACF;MACF;IACF,CAAC,CAAC;IACFhC,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAAC,CAACY,qBAAqB,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;EACFf,EAAE,CAAC,sBAAsB,EAAE,MAAM;IACnBI,wBAAwB,CAAC;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;QAAEA,IAAI,EAAE;MAAS,CAAC;MACxB0B,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ;IAC9B,CAAC,CAAC;IACFjC,MAAM,CAACI,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
|
+
{"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,QAAQ;AACzD,SAASC,wBAAwB,QAAQ,gCAAgC;AACzE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,cAAc,EAAEC,wBAAwB,QAAQ,sBAAsB;AAC/E,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1DR,QAAQ,CAAC,MAAM,EAAE,MAAM;EACrBD,UAAU,CAAC,YAAY;IACrB,MAAMO,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFJ,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpDM,wBAAwB,CAAC;MACvBC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFT,MAAM,CAAC,MAAM;MACXO,wBAAwB,CAAC;QACvBC,OAAO,EAAE,KAAK;QACdC,IAAI,EAAE;MACR,CAAC,CAAC;IACJ,CAAC,CAAC,CAACC,kCAAkC,CACnC,iFACF,CAAC;EACH,CAAC,CAAC;EAEFT,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAChC,MAAMU,MAAM,GAAGJ,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;IACR,CAAC,CAAC;IAEmBN,eAAe,CAAC;MACnCK,OAAO,EAAE,cAAc;MACvBI,WAAW,EAAE,eAAe;MAC5BC,UAAU,EAAE;QACVF;MACF,CAAC;MACDG,IAAI,EAAE;QAAEC,KAAK,EAAE,QAAQ;QAAEC,OAAO,EAAE;MAAW;IAC/C,CAAC,CAAC;IAEFhB,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,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;AAC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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,KAAK,CAAC;EACJ,CAAC,CAAC;EACFjB,EAAE,CAAC,sBAAsB,EAAE,MAAM;IACnBM,wBAAwB,CAAC;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":[]}
|
|
@@ -14,17 +14,33 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
|
|
17
18
|
import { consola } from "consola";
|
|
19
|
+
import { execa } from "execa";
|
|
20
|
+
import { createJiti } from "jiti";
|
|
18
21
|
import * as fs from "node:fs/promises";
|
|
19
22
|
import * as path from "node:path";
|
|
20
23
|
import invariant from "tiny-invariant";
|
|
21
24
|
import yargs from "yargs";
|
|
22
25
|
import { hideBin } from "yargs/helpers";
|
|
23
26
|
import { defineOntology } from "../api/defineOntology.js";
|
|
27
|
+
|
|
28
|
+
// Dynamic imports for optional function discovery dependencies
|
|
29
|
+
let generateFunctionsIr;
|
|
30
|
+
async function loadFunctionDiscoveryDeps() {
|
|
31
|
+
try {
|
|
32
|
+
const defineFunctionModule = await import("../api/defineFunction.js");
|
|
33
|
+
generateFunctionsIr = defineFunctionModule.generateFunctionsIr;
|
|
34
|
+
return true;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
consola.warn("Failed to load function discovery dependencies:", e instanceof Error ? e.message : e);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
24
40
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
25
41
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
26
42
|
export default async function main(args = process.argv) {
|
|
27
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.16.0-beta.
|
|
43
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.16.0-beta.7" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
28
44
|
input: {
|
|
29
45
|
alias: "i",
|
|
30
46
|
describe: "Input file",
|
|
@@ -88,6 +104,41 @@ export default async function main(args = process.argv) {
|
|
|
88
104
|
describe: "Value used to assure uniqueness of entities",
|
|
89
105
|
type: "string",
|
|
90
106
|
coerce: path.resolve
|
|
107
|
+
},
|
|
108
|
+
generateFunctionsOsdk: {
|
|
109
|
+
describe: "Output folder for generated OSDK for functions",
|
|
110
|
+
type: "string",
|
|
111
|
+
coerce: path.resolve
|
|
112
|
+
},
|
|
113
|
+
functionsRootDir: {
|
|
114
|
+
describe: "Root folder containing function definitions",
|
|
115
|
+
type: "string",
|
|
116
|
+
coerce: path.resolve
|
|
117
|
+
},
|
|
118
|
+
functionsOutput: {
|
|
119
|
+
describe: "Output folder for function IR",
|
|
120
|
+
type: "string",
|
|
121
|
+
coerce: path.resolve
|
|
122
|
+
},
|
|
123
|
+
configPath: {
|
|
124
|
+
describe: "Path to the TypeScript config file",
|
|
125
|
+
type: "string",
|
|
126
|
+
coerce: path.resolve
|
|
127
|
+
},
|
|
128
|
+
pythonFunctionsDir: {
|
|
129
|
+
describe: "Path to Python functions source directory (enables Python function discovery)",
|
|
130
|
+
type: "string",
|
|
131
|
+
coerce: path.resolve
|
|
132
|
+
},
|
|
133
|
+
pythonBinary: {
|
|
134
|
+
describe: "Path to Python binary (required when using --pythonFunctionsDir)",
|
|
135
|
+
type: "string",
|
|
136
|
+
coerce: path.resolve
|
|
137
|
+
},
|
|
138
|
+
pythonRootProjectDir: {
|
|
139
|
+
describe: "Root project directory for Python functions (defaults to parent of pythonFunctionsDir)",
|
|
140
|
+
type: "string",
|
|
141
|
+
coerce: path.resolve
|
|
91
142
|
}
|
|
92
143
|
}).parseAsync();
|
|
93
144
|
let apiNamespace = "";
|
|
@@ -110,9 +161,101 @@ export default async function main(args = process.argv) {
|
|
|
110
161
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
111
162
|
await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
112
163
|
}
|
|
164
|
+
if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {
|
|
165
|
+
consola.error("--pythonBinary is required when using --pythonFunctionsDir");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Function discovery feature (requires optional dependencies)
|
|
170
|
+
if (commandLineOpts.functionsOutput !== undefined && commandLineOpts.functionsRootDir !== undefined) {
|
|
171
|
+
const hasFunctionDeps = await loadFunctionDiscoveryDeps();
|
|
172
|
+
if (!hasFunctionDeps || !generateFunctionsIr) {
|
|
173
|
+
consola.error("Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.");
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
consola.info(`Loading function IR`);
|
|
177
|
+
const functionsIr = await generateFunctionsIr(commandLineOpts.functionsRootDir, commandLineOpts.configPath, createEntityMappings(ontologyIr));
|
|
178
|
+
await fs.writeFile(commandLineOpts.functionsOutput, JSON.stringify(functionsIr, null, 2));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (commandLineOpts.generateFunctionsOsdk !== undefined) {
|
|
182
|
+
// Generate full ontology metadata for functions OSDK
|
|
183
|
+
const fullMetadata = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ontologyIr.ontology);
|
|
184
|
+
|
|
185
|
+
// Discover Python functions and merge into ontology metadata
|
|
186
|
+
if (commandLineOpts.pythonFunctionsDir) {
|
|
187
|
+
const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir ?? path.dirname(commandLineOpts.pythonFunctionsDir);
|
|
188
|
+
const queryTypes = await OntologyIrToFullMetadataConverter.getOsdkQueryTypes(commandLineOpts.pythonBinary, undefined, undefined, commandLineOpts.pythonFunctionsDir, effectivePythonRootDir);
|
|
189
|
+
const functionNames = Object.keys(queryTypes);
|
|
190
|
+
if (functionNames.length > 0) {
|
|
191
|
+
fullMetadata.queryTypes = queryTypes;
|
|
192
|
+
consola.info(`Discovered ${functionNames.length} Python function(s): ${functionNames.join(", ")}`);
|
|
193
|
+
} else {
|
|
194
|
+
consola.info("No Python functions discovered.");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
consola.info(`Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`);
|
|
198
|
+
await fs.writeFile(path.join(commandLineOpts.generateFunctionsOsdk, ".ontology.json"), JSON.stringify(fullMetadata, null, 2));
|
|
199
|
+
await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);
|
|
200
|
+
}
|
|
113
201
|
}
|
|
114
202
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
115
|
-
const q = await defineOntology(apiNamespace, async () =>
|
|
203
|
+
const q = await defineOntology(apiNamespace, async () => {
|
|
204
|
+
const jiti = createJiti(import.meta.filename, {
|
|
205
|
+
moduleCache: true,
|
|
206
|
+
debug: false,
|
|
207
|
+
importMeta: import.meta
|
|
208
|
+
});
|
|
209
|
+
await jiti.import(input);
|
|
210
|
+
}, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
116
211
|
return q;
|
|
117
212
|
}
|
|
213
|
+
async function fullMetadataToOsdk(workDir) {
|
|
214
|
+
// First create a clean temporary directory to generate the SDK into
|
|
215
|
+
const functionOsdkDir = path.join(workDir, "generated");
|
|
216
|
+
await fs.rm(functionOsdkDir, {
|
|
217
|
+
recursive: true,
|
|
218
|
+
force: true
|
|
219
|
+
});
|
|
220
|
+
await fs.mkdir(functionOsdkDir, {
|
|
221
|
+
recursive: true
|
|
222
|
+
});
|
|
223
|
+
try {
|
|
224
|
+
// Generate the source code for the osdk
|
|
225
|
+
await execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", functionOsdkDir, "--ontologyPath", path.join(workDir, ".ontology.json"), "--beta", "true", "--packageType", "module", "--version", "dev"]);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
await fs.rm(functionOsdkDir, {
|
|
228
|
+
recursive: true,
|
|
229
|
+
force: true
|
|
230
|
+
});
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function createEntityMappings(ontologyIr) {
|
|
235
|
+
const entityMappings = {
|
|
236
|
+
ontologies: {}
|
|
237
|
+
};
|
|
238
|
+
const ontologyRid = "ontology";
|
|
239
|
+
entityMappings.ontologies[ontologyRid] = {
|
|
240
|
+
objectTypes: {},
|
|
241
|
+
interfaceTypes: {}
|
|
242
|
+
};
|
|
243
|
+
for (const [apiName, blockData] of Object.entries(ontologyIr.ontology.objectTypes)) {
|
|
244
|
+
const propertyTypesMap = {};
|
|
245
|
+
Object.keys(blockData.objectType.propertyTypes).forEach(propertyName => {
|
|
246
|
+
propertyTypesMap[propertyName] = {
|
|
247
|
+
propertyId: propertyName
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {
|
|
251
|
+
objectTypeId: apiName,
|
|
252
|
+
primaryKey: {
|
|
253
|
+
propertyId: blockData.objectType.primaryKeys[0]
|
|
254
|
+
},
|
|
255
|
+
propertyTypes: propertyTypesMap,
|
|
256
|
+
linkTypes: {}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return entityMappings;
|
|
260
|
+
}
|
|
118
261
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineOntology","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","snippetPackageName","q"],"sources":["main.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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets\n && (commandLineOpts.codeSnippetPackageName !== \"\"\n || commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eAYL,GAAG,MAAMT,KAAK,CAACC,OAAO,CAACK,IAAI,CAAC,CAAC,CAC3BI,OAAO,CAAC,mBAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEb,KAAK,CAAC,CAAC,CAACc,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5CC,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,OAAO,CAAC;IACPC,KAAK,EAAE;MACLC,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,YAAY;MACtBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,uBAAuB;MAChCC,MAAM,EAAEzB,IAAI,CAAC0B;IACf,CAAC;IACDC,MAAM,EAAE;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B,SAAS,EACzBnB,eAAe,CAACqB,YAAY,EAC5BrB,eAAe,CAACsB,oBAAoB,EACpCtB,eAAe,CAACuB,sBAAsB,EACtCvB,eAAe,CAACwB,cAAc,EAC9BxB,eAAe,CAACyB,aAClB,CAAC;EAEDtC,OAAO,CAAC6C,IAAI,CAAC,sBAAsBhC,eAAe,CAACgB,MAAM,EAAE,CAAC;EAC5D,MAAM5B,EAAE,CAACgD,SAAS,CAChBpC,eAAe,CAACgB,MAAM,EACtBqB,IAAI,CAACC,SAAS,CACZJ,UAAU,EACV,IAAI,EACJ,CACF,CACF,CAAC;EACD;EACA,IACEA,UAAU,CAACK,UAAU,CAACA,UAAU,CAACZ,MAAM,GAAG,CAAC,IACxCO,UAAU,CAACM,kBAAkB,CAACD,UAAU,CAACZ,MAAM,GAAG,CAAC,EACtD;IACA,MAAMvC,EAAE,CAACgD,SAAS,CAChBpC,eAAe,CAACoB,gBAAgB,EAChCiB,IAAI,CAACC,SAAS,CACZJ,UAAU,CAACK,UAAU,EACrB,IAAI,EACJ,CACF,CACF,CAAC;EACH;AACF;AAEA,eAAeJ,YAAYA,CACzB1B,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7BsB,cAAkC,EAClCnB,oBAA6B,EAC7BoB,kBAA0B,EAC1BlB,cAAsB,EACtBC,aAAsB,EACtB;EACA,MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["OntologyIrToFullMetadataConverter","consola","execa","createJiti","fs","path","invariant","yargs","hideBin","defineOntology","generateFunctionsIr","loadFunctionDiscoveryDeps","defineFunctionModule","e","warn","Error","message","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","generateFunctionsOsdk","functionsRootDir","functionsOutput","configPath","pythonFunctionsDir","pythonBinary","pythonRootProjectDir","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","error","hasFunctionDeps","functionsIr","createEntityMappings","fullMetadata","getFullMetadataFromIr","ontology","effectivePythonRootDir","dirname","queryTypes","getOsdkQueryTypes","functionNames","Object","keys","join","fullMetadataToOsdk","dependencyFile","snippetPackageName","q","jiti","import","meta","filename","moduleCache","debug","importMeta","workDir","functionOsdkDir","rm","recursive","force","mkdir","entityMappings","ontologies","ontologyRid","objectTypes","interfaceTypes","apiName","blockData","entries","propertyTypesMap","objectType","propertyTypes","forEach","propertyName","propertyId","objectTypeId","primaryKey","primaryKeys","linkTypes"],"sources":["main.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 { OntologyIr } from \"@osdk/client.unstable\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport { execa } from \"execa\";\nimport { createJiti } from \"jiti\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { IEntityMetadataMapping } from \"../api/defineFunction.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\n// Dynamic imports for optional function discovery dependencies\nlet generateFunctionsIr:\n | ((\n rootDir: string,\n configPath: string | undefined,\n entityMappings: IEntityMetadataMapping,\n ) => Promise<unknown>)\n | undefined;\n\nasync function loadFunctionDiscoveryDeps(): Promise<boolean> {\n try {\n const defineFunctionModule = await import(\"../api/defineFunction.js\");\n generateFunctionsIr = defineFunctionModule.generateFunctionsIr;\n return true;\n } catch (e: unknown) {\n consola.warn(\n \"Failed to load function discovery dependencies:\",\n e instanceof Error ? e.message : e,\n );\n return false;\n }\n}\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n generateFunctionsOsdk?: string;\n functionsRootDir?: string;\n functionsOutput?: string;\n configPath?: string;\n pythonFunctionsDir?: string;\n pythonBinary?: string;\n pythonRootProjectDir?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateFunctionsOsdk: {\n describe: \"Output folder for generated OSDK for functions\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsRootDir: {\n describe: \"Root folder containing function definitions\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsOutput: {\n describe: \"Output folder for function IR\",\n type: \"string\",\n coerce: path.resolve,\n },\n configPath: {\n describe: \"Path to the TypeScript config file\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonFunctionsDir: {\n describe:\n \"Path to Python functions source directory (enables Python function discovery)\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonBinary: {\n describe:\n \"Path to Python binary (required when using --pythonFunctionsDir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonRootProjectDir: {\n describe:\n \"Root project directory for Python functions (defaults to parent of pythonFunctionsDir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets\n && (commandLineOpts.codeSnippetPackageName !== \"\"\n || commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n );\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n\n if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {\n consola.error(\n \"--pythonBinary is required when using --pythonFunctionsDir\",\n );\n return;\n }\n\n // Function discovery feature (requires optional dependencies)\n if (\n commandLineOpts.functionsOutput !== undefined\n && commandLineOpts.functionsRootDir !== undefined\n ) {\n const hasFunctionDeps = await loadFunctionDiscoveryDeps();\n if (!hasFunctionDeps || !generateFunctionsIr) {\n consola.error(\n \"Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.\",\n );\n return;\n }\n consola.info(`Loading function IR`);\n const functionsIr = await generateFunctionsIr(\n commandLineOpts.functionsRootDir,\n commandLineOpts.configPath,\n createEntityMappings(ontologyIr),\n );\n await fs.writeFile(\n commandLineOpts.functionsOutput,\n JSON.stringify(functionsIr, null, 2),\n );\n return;\n }\n\n if (commandLineOpts.generateFunctionsOsdk !== undefined) {\n // Generate full ontology metadata for functions OSDK\n const fullMetadata = OntologyIrToFullMetadataConverter\n .getFullMetadataFromIr(ontologyIr.ontology);\n\n // Discover Python functions and merge into ontology metadata\n if (commandLineOpts.pythonFunctionsDir) {\n const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir\n ?? path.dirname(commandLineOpts.pythonFunctionsDir);\n\n const queryTypes = await OntologyIrToFullMetadataConverter\n .getOsdkQueryTypes(\n commandLineOpts.pythonBinary,\n undefined,\n undefined,\n commandLineOpts.pythonFunctionsDir,\n effectivePythonRootDir,\n );\n\n const functionNames = Object.keys(queryTypes);\n if (functionNames.length > 0) {\n fullMetadata.queryTypes = queryTypes;\n consola.info(\n `Discovered ${functionNames.length} Python function(s): ${\n functionNames.join(\", \")\n }`,\n );\n } else {\n consola.info(\"No Python functions discovered.\");\n }\n }\n\n consola.info(\n `Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`,\n );\n\n await fs.writeFile(\n path.join(commandLineOpts.generateFunctionsOsdk, \".ontology.json\"),\n JSON.stringify(fullMetadata, null, 2),\n );\n\n await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => {\n const jiti = createJiti(import.meta.filename, {\n moduleCache: true,\n debug: false,\n importMeta: import.meta,\n });\n await jiti.import(input);\n },\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n\nasync function fullMetadataToOsdk(\n workDir: string,\n): Promise<void> {\n // First create a clean temporary directory to generate the SDK into\n const functionOsdkDir = path.join(\n workDir,\n \"generated\",\n );\n await fs.rm(functionOsdkDir, { recursive: true, force: true });\n await fs.mkdir(functionOsdkDir, { recursive: true });\n\n try {\n // Generate the source code for the osdk\n await execa(\"pnpm\", [\n \"exec\",\n \"osdk\",\n \"unstable\",\n \"typescript\",\n \"generate\",\n \"--outDir\",\n functionOsdkDir,\n \"--ontologyPath\",\n path.join(workDir, \".ontology.json\"),\n \"--beta\",\n \"true\",\n \"--packageType\",\n \"module\",\n \"--version\",\n \"dev\",\n ]);\n } catch (error) {\n await fs.rm(functionOsdkDir, { recursive: true, force: true });\n throw error;\n }\n}\n\nfunction createEntityMappings(ontologyIr: OntologyIr): IEntityMetadataMapping {\n const entityMappings: IEntityMetadataMapping = {\n ontologies: {},\n };\n\n const ontologyRid = \"ontology\";\n entityMappings.ontologies[ontologyRid] = {\n objectTypes: {},\n interfaceTypes: {},\n };\n\n for (\n const [apiName, blockData] of Object.entries(\n ontologyIr.ontology.objectTypes,\n )\n ) {\n const propertyTypesMap: Record<string, { propertyId: string }> = {};\n\n Object.keys(blockData.objectType.propertyTypes).forEach((propertyName) => {\n propertyTypesMap[propertyName] = { propertyId: propertyName };\n });\n\n entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {\n objectTypeId: apiName,\n primaryKey: {\n propertyId: blockData.objectType.primaryKeys[0],\n },\n propertyTypes: propertyTypesMap,\n linkTypes: {},\n };\n }\n\n return entityMappings;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,UAAU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cAAc,CAACC,UAAU,CAACC,WAAW,CAAC,GAAG;IACvCC,WAAW,EAAE,CAAC,CAAC;IACfC,cAAc,EAAE,CAAC;EACnB,CAAC;EAED,KACE,MAAM,CAACC,OAAO,EAAEC,SAAS,CAAC,IAAI1B,MAAM,CAAC2B,OAAO,CAC1C9C,UAAU,CAACa,QAAQ,CAAC6B,WACtB,CAAC,EACD;IACA,MAAMK,gBAAwD,GAAG,CAAC,CAAC;IAEnE5B,MAAM,CAACC,IAAI,CAACyB,SAAS,CAACG,UAAU,CAACC,aAAa,CAAC,CAACC,OAAO,CAAEC,YAAY,IAAK;MACxEJ,gBAAgB,CAACI,YAAY,CAAC,GAAG;QAAEC,UAAU,EAAED;MAAa,CAAC;IAC/D,CAAC,CAAC;IAEFZ,cAAc,CAACC,UAAU,CAACC,WAAW,CAAC,CAACC,WAAW,CAACE,OAAO,CAAC,GAAG;MAC5DS,YAAY,EAAET,OAAO;MACrBU,UAAU,EAAE;QACVF,UAAU,EAAEP,SAAS,CAACG,UAAU,CAACO,WAAW,CAAC,CAAC;MAChD,CAAC;MACDN,aAAa,EAAEF,gBAAgB;MAC/BS,SAAS,EAAE,CAAC;IACd,CAAC;EACH;EAEA,OAAOjB,cAAc;AACvB","ignoreList":[]}
|
|
@@ -104,6 +104,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
104
104
|
},
|
|
105
105
|
additionalMandatory: {
|
|
106
106
|
markings: {},
|
|
107
|
+
assumedMarkingsV2: {},
|
|
107
108
|
assumedMarkings: []
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -130,7 +131,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
130
131
|
rid: ds.objectSecurityPolicy?.name || "defaultObjectSecurityPolicy",
|
|
131
132
|
security: {
|
|
132
133
|
type: "granular",
|
|
133
|
-
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.
|
|
134
|
+
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.appliedMarkings, ds.objectSecurityPolicy?.assumedMarkings)
|
|
134
135
|
},
|
|
135
136
|
type: {
|
|
136
137
|
type: "primaryKey",
|
|
@@ -143,7 +144,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
143
144
|
rid: psg.name,
|
|
144
145
|
security: {
|
|
145
146
|
type: "granular",
|
|
146
|
-
granular: convertGranularPolicy(psg.granularPolicy, psg.
|
|
147
|
+
granular: convertGranularPolicy(psg.granularPolicy, psg.appliedMarkings, psg.assumedMarkings)
|
|
147
148
|
},
|
|
148
149
|
type: {
|
|
149
150
|
type: "property",
|
|
@@ -155,7 +156,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
155
156
|
})) ?? [])]
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
|
-
function convertGranularPolicy(granularPolicy,
|
|
159
|
+
function convertGranularPolicy(granularPolicy, appliedMarkings, assumedMarkings) {
|
|
159
160
|
return {
|
|
160
161
|
viewPolicy: {
|
|
161
162
|
granularPolicyCondition: granularPolicy ? convertSecurityCondition(granularPolicy) : {
|
|
@@ -165,8 +166,9 @@ function convertGranularPolicy(granularPolicy, additionalMandatoryMarkings) {
|
|
|
165
166
|
}
|
|
166
167
|
},
|
|
167
168
|
additionalMandatory: {
|
|
168
|
-
markings:
|
|
169
|
-
assumedMarkings: []
|
|
169
|
+
markings: appliedMarkings ?? {},
|
|
170
|
+
assumedMarkings: [],
|
|
171
|
+
assumedMarkingsV2: assumedMarkings ?? {}
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
};
|