@osdk/maker 0.8.0-beta.9 → 0.8.1
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 +95 -0
- package/build/browser/api/defineInterface.d.ts +14 -0
- package/build/browser/api/defineInterface.d.ts.map +1 -0
- package/build/browser/api/defineInterface.js +67 -0
- package/build/browser/api/defineInterface.js.map +1 -0
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts +21 -0
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +1 -0
- package/build/browser/api/defineInterfaceLinkConstraint.js +50 -0
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -0
- package/build/browser/api/defineLink.d.ts +18 -0
- package/build/browser/api/defineLink.d.ts.map +1 -0
- package/build/browser/api/defineLink.js +37 -0
- package/build/browser/api/defineLink.js.map +1 -0
- package/build/browser/api/defineObject.d.ts +15 -0
- package/build/browser/api/defineObject.d.ts.map +1 -0
- package/build/browser/api/defineObject.js +86 -0
- package/build/browser/api/defineObject.js.map +1 -0
- package/build/browser/api/defineOntology.d.ts +10 -0
- package/build/browser/api/defineOntology.d.ts.map +1 -0
- package/build/browser/api/defineOntology.js +174 -0
- package/build/browser/api/defineOntology.js.map +1 -0
- package/build/browser/api/defineSpt.d.ts +13 -0
- package/build/browser/api/defineSpt.d.ts.map +1 -0
- package/build/browser/api/defineSpt.js +36 -0
- package/build/browser/api/defineSpt.js.map +1 -0
- package/build/browser/api/defineValueType.d.ts +26 -0
- package/build/browser/api/defineValueType.d.ts.map +1 -0
- package/build/browser/api/defineValueType.js +61 -0
- package/build/browser/api/defineValueType.js.map +1 -0
- package/build/browser/api/iconNames.d.ts +3 -0
- package/build/browser/api/iconNames.d.ts.map +1 -0
- package/build/browser/api/iconNames.js +17 -0
- package/build/browser/api/iconNames.js.map +1 -0
- package/build/browser/api/overall.test.d.ts +2 -0
- package/build/browser/api/overall.test.d.ts.map +1 -0
- package/build/browser/api/overall.test.js +617 -0
- package/build/browser/api/overall.test.js.map +1 -0
- package/build/browser/api/types.d.ts +38 -0
- package/build/browser/api/types.d.ts.map +1 -0
- package/build/browser/api/types.js +17 -0
- package/build/browser/api/types.js.map +1 -0
- package/build/browser/cli/main.d.ts +2 -0
- package/build/browser/cli/main.d.ts.map +1 -0
- package/build/browser/cli/main.js +121 -0
- package/build/browser/cli/main.js.map +1 -0
- package/build/browser/index.d.ts +6 -0
- package/build/browser/index.d.ts.map +1 -0
- package/build/browser/index.js +20 -280
- package/build/browser/index.js.map +1 -1
- package/build/esm/api/defineInterface.d.ts +1 -0
- package/build/esm/api/defineInterface.d.ts.map +1 -1
- package/build/esm/api/defineInterface.js +67 -0
- package/build/esm/api/defineInterface.js.map +1 -0
- package/build/esm/api/defineInterfaceLinkConstraint.js +50 -0
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -0
- package/build/esm/api/defineLink.js +37 -0
- package/build/esm/api/defineLink.js.map +1 -0
- package/build/esm/api/defineObject.d.ts +2 -2
- package/build/esm/api/defineObject.d.ts.map +1 -1
- package/build/esm/api/defineObject.js +86 -0
- package/build/esm/api/defineObject.js.map +1 -0
- package/build/esm/api/defineOntology.d.ts +8 -2
- package/build/esm/api/defineOntology.d.ts.map +1 -1
- package/build/esm/api/defineOntology.js +174 -0
- package/build/esm/api/defineOntology.js.map +1 -0
- package/build/esm/api/defineSpt.d.ts +2 -1
- package/build/esm/api/defineSpt.d.ts.map +1 -1
- package/build/esm/api/defineSpt.js +36 -0
- package/build/esm/api/defineSpt.js.map +1 -0
- package/build/esm/api/defineValueType.d.ts +26 -0
- package/build/esm/api/defineValueType.d.ts.map +1 -0
- package/build/esm/api/defineValueType.js +61 -0
- package/build/esm/api/defineValueType.js.map +1 -0
- package/build/esm/api/iconNames.js +17 -0
- package/build/esm/api/iconNames.js.map +1 -0
- package/build/esm/api/overall.test.js +617 -0
- package/build/esm/api/overall.test.js.map +1 -0
- package/build/esm/api/types.d.ts +12 -1
- package/build/esm/api/types.d.ts.map +1 -1
- package/build/esm/api/types.js +17 -0
- package/build/esm/api/types.js.map +1 -0
- package/build/esm/cli/main.d.ts.map +1 -1
- package/build/esm/cli/main.js +121 -0
- package/build/esm/cli/main.js.map +1 -0
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +20 -280
- package/build/esm/index.js.map +1 -1
- package/package.json +7 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overall.test.js","names":["beforeEach","describe","expect","it","defineInterface","defineInterfaceLinkConstraint","defineOntology","dumpOntologyFullMetadata","dumpValueTypeWireType","defineSharedPropertyType","defineValueType","apiName","displayName","typeAndConstraints","baseType","boolean","constraints","constraint","allowedValues","version","toThrowErrorMatchingInlineSnapshot","toMatchInlineSnapshot","result","displayMetadata","toBe","description","properties","foo","type","a","b","not","toBeUndefined","from","toOne","toMany","fooSpt","icon","color","locator"],"sources":["overall.test.js"],"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 */\nimport { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineInterface } from \"./defineInterface.js\";\nimport { defineInterfaceLinkConstraint } from \"./defineInterfaceLinkConstraint.js\";\nimport { defineOntology, dumpOntologyFullMetadata, dumpValueTypeWireType, } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nimport { defineValueType } from \"./defineValueType.js\";\ndescribe(\"Ontology Defining\", () => {\n beforeEach(() => {\n defineOntology(\"com.palantir.\", () => { });\n });\n describe(\"ValueTypes\", () => {\n it(\"Fails to define value type with incorrect semver\", () => {\n expect(() => defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n typeAndConstraints: {\n baseType: { boolean: {} },\n constraints: [{\n constraint: { boolean: { allowedValues: [\"TRUE_VALUE\"] } },\n }],\n },\n version: \"not a version\",\n })).toThrowErrorMatchingInlineSnapshot(\"[Error: Invariant failed: Version is not a valid semver]\");\n });\n it(\"Correctly serializes a value type\", () => {\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n typeAndConstraints: {\n baseType: { boolean: {} },\n constraints: [{\n constraint: { boolean: { allowedValues: [\"TRUE_VALUE\"] } },\n }],\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 \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n \"versions\": [\n {\n \"baseType\": {\n \"boolean\": {},\n },\n \"constraints\": [\n {\n \"constraint\": {\n \"boolean\": \"boolean\",\n \"constraint\": {\n \"boolean\": {\n \"allowedValues\": [\n \"TRUE_VALUE\",\n ],\n },\n },\n },\n },\n ],\n \"exampleValues\": [],\n \"version\": \"0.1.0\",\n },\n ],\n },\n ],\n }\n `);\n });\n defineOntology(\"com.palantir.\", () => { });\n });\n describe(\"Interfaces\", () => {\n it(\"doesn't let you define the same interface twice\", () => {\n defineInterface({ apiName: \"Foo\" });\n expect(() => {\n defineInterface({ apiName: \"Foo\" });\n }).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Interface com.palantir.Foo already exists]`);\n });\n it(\"defaults displayName to apiName\", () => {\n const result = defineInterface({ apiName: \"Foo\" });\n expect(result.displayMetadata.displayName).toBe(\"Foo\");\n });\n it(\"defaults description to displayName\", () => {\n const result = defineInterface({ apiName: \"Foo\", displayName: \"d\" });\n expect(result.displayMetadata.description).toBe(\"d\");\n });\n it(\"defaults description to displayName to apiName\", () => {\n const result = defineInterface({ apiName: \"Foo\" });\n expect(result.displayMetadata.description).toBe(\"Foo\");\n });\n describe(\"auto spts\", () => {\n it(\"auto creates spts\", () => {\n defineInterface({\n apiName: \"Foo\",\n properties: {\n foo: \"string\",\n },\n });\n expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.Foo\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\n \"apiName\": \"com.palantir.Foo\",\n \"displayMetadata\": {\n \"description\": \"Foo\",\n \"displayName\": \"Foo\",\n \"icon\": undefined,\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [\n {\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 \"provenance\": undefined,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": 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 \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\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 \"provenance\": undefined,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": 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 it(\"does not let you conflict spts\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\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 \"provenance\": undefined,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": 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 expect(() => {\n defineInterface({\n apiName: \"Foo\",\n properties: {\n foo: \"string\",\n },\n });\n }).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);\n });\n });\n });\n describe(\"ILTs\", () => {\n let a;\n let b;\n beforeEach(() => {\n a = defineInterface({ apiName: \"A\" });\n b = defineInterface({ apiName: \"B\" });\n });\n it(\"single link works\", () => {\n expect(a).not.toBeUndefined();\n defineInterfaceLinkConstraint({\n from: a,\n toOne: b,\n apiName: \"singleLink\",\n });\n expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.A\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\n \"apiName\": \"com.palantir.A\",\n \"displayMetadata\": {\n \"description\": \"A\",\n \"displayName\": \"A\",\n \"icon\": undefined,\n },\n \"extendsInterfaces\": [],\n \"links\": [\n {\n \"cardinality\": \"SINGLE\",\n \"linkedEntityTypeId\": {\n \"interfaceType\": \"com.palantir.B\",\n \"type\": \"interfaceType\",\n },\n \"metadata\": {\n \"apiName\": \"com.palantir.singleLink\",\n \"description\": \"singleLink\",\n \"displayName\": \"singleLink\",\n },\n \"required\": true,\n },\n ],\n \"properties\": [],\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n \"com.palantir.B\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\n \"apiName\": \"com.palantir.B\",\n \"displayMetadata\": {\n \"description\": \"B\",\n \"displayName\": \"B\",\n \"icon\": undefined,\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"sharedPropertyTypes\": {},\n }\n `);\n });\n it(\"many link works\", () => {\n defineInterfaceLinkConstraint({\n from: a,\n toMany: b,\n apiName: \"manyLink\",\n });\n expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.A\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\n \"apiName\": \"com.palantir.A\",\n \"displayMetadata\": {\n \"description\": \"A\",\n \"displayName\": \"A\",\n \"icon\": undefined,\n },\n \"extendsInterfaces\": [],\n \"links\": [\n {\n \"cardinality\": \"MANY\",\n \"linkedEntityTypeId\": {\n \"interfaceType\": \"com.palantir.B\",\n \"type\": \"interfaceType\",\n },\n \"metadata\": {\n \"apiName\": \"com.palantir.manyLink\",\n \"description\": \"manyLink\",\n \"displayName\": \"manyLink\",\n },\n \"required\": true,\n },\n ],\n \"properties\": [],\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n \"com.palantir.B\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\n \"apiName\": \"com.palantir.B\",\n \"displayMetadata\": {\n \"description\": \"B\",\n \"displayName\": \"B\",\n \"icon\": undefined,\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"sharedPropertyTypes\": {},\n }\n `);\n });\n });\n describe(\"SPTs\", () => {\n it(\"doesn't let you create the same spt twice\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n expect(() => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n }).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);\n });\n });\n it(\"uses a predefined spt\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: \"string\",\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 expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`\n {\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.FooInterface\": {\n \"interfaceType\": {\n \"allExtendsInterfaces\": [],\n \"allLinks\": [],\n \"allProperties\": [],\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 {\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 \"provenance\": undefined,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": 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 \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\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 \"provenance\": undefined,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": 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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,6BAA6B,QAAQ,oCAAoC;AAClF,SAASC,cAAc,EAAEC,wBAAwB,EAAEC,qBAAqB,QAAS,qBAAqB;AACtG,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,SAASC,eAAe,QAAQ,sBAAsB;AACtDT,QAAQ,CAAC,mBAAmB,EAAE,MAAM;EAChCD,UAAU,CAAC,MAAM;IACbM,cAAc,CAAC,eAAe,EAAE,MAAM,CAAE,CAAC,CAAC;EAC9C,CAAC,CAAC;EACFL,QAAQ,CAAC,YAAY,EAAE,MAAM;IACzBE,EAAE,CAAC,kDAAkD,EAAE,MAAM;MACzDD,MAAM,CAAC,MAAMQ,eAAe,CAAC;QACzBC,OAAO,EAAE,SAAS;QAClBC,WAAW,EAAE,aAAa;QAC1BC,kBAAkB,EAAE;UAChBC,QAAQ,EAAE;YAAEC,OAAO,EAAE,CAAC;UAAE,CAAC;UACzBC,WAAW,EAAE,CAAC;YACNC,UAAU,EAAE;cAAEF,OAAO,EAAE;gBAAEG,aAAa,EAAE,CAAC,YAAY;cAAE;YAAE;UAC7D,CAAC;QACT,CAAC;QACDC,OAAO,EAAE;MACb,CAAC,CAAC,CAAC,CAACC,kCAAkC,CAAC,0DAA0D,CAAC;IACtG,CAAC,CAAC;IACFjB,EAAE,CAAC,mCAAmC,EAAE,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MAAM;MAC5C,MAAMmB,MAAM,GAAGlB,eAAe,CAAC;QAAEO,OAAO,EAAE,KAAK;QAAEC,WAAW,EAAE;MAAI,CAAC,CAAC;MACpEV,MAAM,CAACoB,MAAM,CAACC,eAAe,CAACE,WAAW,CAAC,CAACD,IAAI,CAAC,GAAG,CAAC;IACxD,CAAC,CAAC;IACFrB,EAAE,CAAC,gDAAgD,EAAE,MAAM;MACvD,MAAMmB,MAAM,GAAGlB,eAAe,CAAC;QAAEO,OAAO,EAAE;MAAM,CAAC,CAAC;MAClDT,MAAM,CAACoB,MAAM,CAACC,eAAe,CAACE,WAAW,CAAC,CAACD,IAAI,CAAC,KAAK,CAAC;IAC1D,CAAC,CAAC;IACFvB,QAAQ,CAAC,WAAW,EAAE,MAAM;MACxBE,EAAE,CAAC,mBAAmB,EAAE,MAAM;QAC1BC,eAAe,CAAC;UACZO,OAAO,EAAE,KAAK;UACde,UAAU,EAAE;YACRC,GAAG,EAAE;UACT;QACJ,CAAC,CAAC;QACFzB,MAAM,CAACK,wBAAwB,CAAC,CAAC,CAAC,CAACc,qBAAqB,CAAC;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFlB,EAAE,CAAC,g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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IACA,CAAC,CAAC;IACFlB,EAAE,CAAC,iBAAiB,EAAE,MAAM;MACxBE,6BAA6B,CAAC;QAC1B4B,IAAI,EAAEJ,CAAC;QACPM,MAAM,EAAEL,CAAC;QACTnB,OAAO,EAAE;MACb,CAAC,CAAC;MACFT,MAAM,CAACK,wBAAwB,CAAC,CAAC,CAAC,CAACc,qBAAqB,CAAC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IACA,CAAC,CAAC;EACN,CAAC,CAAC;EACFpB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACnBE,EAAE,CAAC,2CAA2C,EAAE,MAAM;MAClDM,wBAAwB,CAAC;QACrBE,OAAO,EAAE,KAAK;QACdiB,IAAI,EAAE;MACV,CAAC,CAAC;MACF1B,MAAM,CAAC,MAAM;QACTO,wBAAwB,CAAC;UACrBE,OAAO,EAAE,KAAK;UACdiB,IAAI,EAAE;QACV,CAAC,CAAC;MACN,CAAC,CAAC,CAACR,kCAAkC,CAAC,iFAAiF,CAAC;IAC5H,CAAC,CAAC;EACN,CAAC,CAAC;EACFjB,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAC9B,MAAMiC,MAAM,GAAG3B,wBAAwB,CAAC;MACpCE,OAAO,EAAE,QAAQ;MACjBiB,IAAI,EAAE;IACV,CAAC,CAAC;IACmBxB,eAAe,CAAC;MACjCO,OAAO,EAAE,cAAc;MACvBC,WAAW,EAAE,eAAe;MAC5Bc,UAAU,EAAE;QACRU;MACJ,CAAC;MACDC,IAAI,EAAE;QAAEC,KAAK,EAAE,QAAQ;QAAEC,OAAO,EAAE;MAAW;IACjD,CAAC,CAAC;IACFrC,MAAM,CAACK,wBAAwB,CAAC,CAAC,CAAC,CAACc,qBAAqB,CAAC;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ApiNameValueTypeReference, BaseType, ExampleValue, OntologyIrInterfaceType, SharedPropertyTypeGothamMapping, ValueTypeApiName, ValueTypeDataConstraint, ValueTypeDisplayMetadata, ValueTypeStatus, ValueTypeVersion } from "@osdk/client.unstable";
|
|
2
|
+
import type { OntologyFullMetadata } from "@osdk/internal.foundry.core";
|
|
3
|
+
export interface Ontology extends Omit<OntologyFullMetadata, "ontology" | "sharedPropertyTypes" | "interfaceTypes"> {
|
|
4
|
+
interfaceTypes: Record<string, InterfaceType>;
|
|
5
|
+
sharedPropertyTypes: Record<string, SharedPropertyType>;
|
|
6
|
+
valueTypes: Record<string, ValueTypeDefinitionVersion[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface InterfaceType extends Omit<OntologyIrInterfaceType, "properties" | "allProperties" | "allLinks" | "allExtendsInterfaces"> {
|
|
9
|
+
properties: Record<string, SharedPropertyType>;
|
|
10
|
+
}
|
|
11
|
+
export interface PropertyType {
|
|
12
|
+
type: PropertyTypeType;
|
|
13
|
+
array?: boolean;
|
|
14
|
+
description?: string;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
valueType?: ApiNameValueTypeReference;
|
|
17
|
+
typeClasses?: TypeClass[];
|
|
18
|
+
}
|
|
19
|
+
type TypeClass = {
|
|
20
|
+
kind: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
export interface SharedPropertyType extends PropertyType {
|
|
24
|
+
apiName: string;
|
|
25
|
+
gothamMapping?: SharedPropertyTypeGothamMapping;
|
|
26
|
+
}
|
|
27
|
+
export type PropertyTypeType = "boolean" | "byte" | "date" | "decimal" | "double" | "float" | "geopoint" | "geoshape" | "integer" | "long" | "marking" | "short" | "string" | "timestamp";
|
|
28
|
+
export type ValueTypeDefinitionVersion = {
|
|
29
|
+
apiName: ValueTypeApiName;
|
|
30
|
+
displayMetadata: ValueTypeDisplayMetadata;
|
|
31
|
+
status: ValueTypeStatus;
|
|
32
|
+
version: ValueTypeVersion;
|
|
33
|
+
baseType: BaseType;
|
|
34
|
+
constraints: ValueTypeDataConstraint[];
|
|
35
|
+
exampleValues: ExampleValue[];
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types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AAM,MAAM,gBAAgB,GACxB,SAAS,GACT,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,UAAU,GACV,SAAS,GACT,MAAM,GACN,SAAS,GACT,OAAO,GACP,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,eAAe,EAAE,wBAAwB,CAAC;IAC1C,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["types.js"],"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 */\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/cli/main.ts"],"names":[],"mappings":"AA8BA,wBAA8B,IAAI,CAChC,IAAI,GAAE,MAAM,EAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA4Ef"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import { consola } from "consola";
|
|
17
|
+
import * as fs from "node:fs/promises";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
import invariant from "tiny-invariant";
|
|
20
|
+
import yargs from "yargs";
|
|
21
|
+
import { hideBin } from "yargs/helpers";
|
|
22
|
+
import { defineInterface } from "../api/defineInterface.js";
|
|
23
|
+
import { defineLink } from "../api/defineLink.js";
|
|
24
|
+
import { defineObject } from "../api/defineObject.js";
|
|
25
|
+
import { defineOntology } from "../api/defineOntology.js";
|
|
26
|
+
import { defineSharedPropertyType } from "../api/defineSpt.js";
|
|
27
|
+
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
28
|
+
export default async function main(args = process.argv) {
|
|
29
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.8.1" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
30
|
+
input: {
|
|
31
|
+
alias: "i",
|
|
32
|
+
describe: "Input file",
|
|
33
|
+
type: "string",
|
|
34
|
+
default: ".ontology/ontology.ts",
|
|
35
|
+
coerce: path.resolve
|
|
36
|
+
},
|
|
37
|
+
output: {
|
|
38
|
+
alias: "o",
|
|
39
|
+
describe: "Output file",
|
|
40
|
+
type: "string",
|
|
41
|
+
default: "ontology.json",
|
|
42
|
+
coerce: path.resolve
|
|
43
|
+
},
|
|
44
|
+
apiNamespace: {
|
|
45
|
+
describe: "Api name prefix for namespaced ontology types",
|
|
46
|
+
type: "string",
|
|
47
|
+
default: ""
|
|
48
|
+
},
|
|
49
|
+
snapshotDir: {
|
|
50
|
+
alias: "s",
|
|
51
|
+
describe: "Snapshot directory",
|
|
52
|
+
type: "string",
|
|
53
|
+
default: "snapshots",
|
|
54
|
+
coerce: path.resolve
|
|
55
|
+
},
|
|
56
|
+
valueTypesOutput: {
|
|
57
|
+
describe: "Value Type Output File",
|
|
58
|
+
type: "string",
|
|
59
|
+
default: "value-types.json",
|
|
60
|
+
coerce: path.resolve
|
|
61
|
+
}
|
|
62
|
+
}).parseAsync();
|
|
63
|
+
let apiNamespace = "";
|
|
64
|
+
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
65
|
+
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
66
|
+
!(apiNamespace.length < 1024) ? invariant(false, "API namespace is too long.") : void 0;
|
|
67
|
+
!apiNamespaceRegex.test(apiNamespace) ? invariant(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\.[a-z0-9-]+)*\.$") : void 0;
|
|
68
|
+
}
|
|
69
|
+
consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
70
|
+
const ontology = await loadOntology(commandLineOpts.input, apiNamespace);
|
|
71
|
+
consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
72
|
+
await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology.ontology, null, 2));
|
|
73
|
+
// No point in generating block if there aren't any value types
|
|
74
|
+
if (ontology.valueType.valueTypes.length > 0) {
|
|
75
|
+
await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontology.valueType, null, 2));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function loadOntologyViaJiti(input) {
|
|
79
|
+
Object.assign(globalThis, {
|
|
80
|
+
defineInterface,
|
|
81
|
+
defineLink,
|
|
82
|
+
defineObject,
|
|
83
|
+
defineSharedPropertyType
|
|
84
|
+
});
|
|
85
|
+
const jiti_ = await import("jiti");
|
|
86
|
+
const jiti = jiti_.default(process.cwd(), {
|
|
87
|
+
debug: true
|
|
88
|
+
});
|
|
89
|
+
return defineOntology("", async () => await jiti(input));
|
|
90
|
+
}
|
|
91
|
+
async function loadOntologyViaTsNode(input) {
|
|
92
|
+
Object.assign(globalThis, {
|
|
93
|
+
defineInterface,
|
|
94
|
+
defineLink,
|
|
95
|
+
defineObject,
|
|
96
|
+
defineSharedPropertyType
|
|
97
|
+
});
|
|
98
|
+
const tsNode = await import("ts-node");
|
|
99
|
+
const tsNodeService = tsNode.register({
|
|
100
|
+
transpileOnly: true,
|
|
101
|
+
compilerOptions: {
|
|
102
|
+
module: "commonjs",
|
|
103
|
+
target: "esnext"
|
|
104
|
+
},
|
|
105
|
+
esm: true
|
|
106
|
+
});
|
|
107
|
+
tsNodeService.enabled(true);
|
|
108
|
+
const q = await import(input);
|
|
109
|
+
return q;
|
|
110
|
+
}
|
|
111
|
+
async function loadOntology(input, apiNamespace) {
|
|
112
|
+
// Object.assign(globalThis, {
|
|
113
|
+
// defineInterface,
|
|
114
|
+
// defineLink,
|
|
115
|
+
// defineObject,
|
|
116
|
+
// defineSharedPropertyType,
|
|
117
|
+
// });
|
|
118
|
+
const q = await defineOntology(apiNamespace, async () => await import(input));
|
|
119
|
+
return q;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineInterface","defineLink","defineObject","defineOntology","defineSharedPropertyType","apiNamespaceRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","valueTypesOutput","parseAsync","length","slice","test","info","ontology","loadOntology","writeFile","JSON","stringify","valueType","valueTypes","loadOntologyViaJiti","Object","assign","globalThis","jiti_","jiti","cwd","debug","loadOntologyViaTsNode","tsNode","tsNodeService","register","transpileOnly","compilerOptions","module","target","esm","enabled","q"],"sources":["main.js"],"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 */\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 { defineInterface } from \"../api/defineInterface.js\";\nimport { defineLink } from \"../api/defineLink.js\";\nimport { defineObject } from \"../api/defineObject.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { defineSharedPropertyType } from \"../api/defineSpt.js\";\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nexport default async function main(args = process.argv) {\n const commandLineOpts = 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 valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\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(apiNamespaceRegex.test(apiNamespace), \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\");\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n const ontology = await loadOntology(commandLineOpts.input, apiNamespace);\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology.ontology, null, 2));\n // No point in generating block if there aren't any value types\n if (ontology.valueType.valueTypes.length > 0) {\n await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontology.valueType, null, 2));\n }\n}\nasync function loadOntologyViaJiti(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType,\n });\n const jiti_ = await import(\"jiti\");\n const jiti = jiti_.default(process.cwd(), { debug: true });\n return defineOntology(\"\", async () => await jiti(input));\n}\nasync function loadOntologyViaTsNode(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType,\n });\n const tsNode = await import(\"ts-node\");\n const tsNodeService = tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n target: \"esnext\",\n },\n esm: true,\n });\n tsNodeService.enabled(true);\n const q = await import(input);\n return q;\n}\nasync function loadOntology(input, apiNamespace) {\n // Object.assign(globalThis, {\n // defineInterface,\n // defineLink,\n // defineObject,\n // defineSharedPropertyType,\n // });\n const q = await defineOntology(apiNamespace, async () => await import(input));\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,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,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,wBAAwB,QAAQ,qBAAqB;AAC9D,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,eAAe,eAAeC,IAAIA,CAACC,IAAI,GAAGC,OAAO,CAACC,IAAI,EAAE;EACpD,MAAMC,eAAe,GAAG,MAAMZ,KAAK,CAACC,OAAO,CAACQ,IAAI,CAAC,CAAC,CAC7CI,OAAO,CAAC,WAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,C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MAAM,CAACC,MAAM,CAACC,UAAU,EAAE;IACtB7C,eAAe;IACfC,UAAU;IACVC,YAAY;IACZE;EACJ,CAAC,CAAC;EACF,MAAM+C,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC;EACtC,MAAMC,aAAa,GAAGD,MAAM,CAACE,QAAQ,CAAC;IAClCC,aAAa,EAAE,IAAI;IACnBC,eAAe,EAAE;MACbC,MAAM,EAAE,UAAU;MAClBC,MAAM,EAAE;IACZ,CAAC;IACDC,GAAG,EAAE;EACT,CAAC,CAAC;EACFN,aAAa,CAACO,OAAO,CAAC,IAAI,CAAC;EAC3B,MAAMC,CAAC,GAAG,MAAM,MAAM,CAACzC,KAAK,CAAC;EAC7B,OAAOyC,CAAC;AACZ;AACA,eAAexB,YAAYA,CAACjB,KAAK,EAAEQ,YAAY,EAAE;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA,MAAMiC,CAAC,GAAG,MAAMzD,cAAc,CAACwB,YAAY,EAAE,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,CAAC;EAC7E,OAAOyC,CAAC;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as default } from "./cli/main.js";
|
|
2
|
+
export { defineInterface } from "./api/defineInterface.js";
|
|
3
|
+
export { defineInterfaceLinkConstraint } from "./api/defineInterfaceLinkConstraint.js";
|
|
4
|
+
export { defineSharedPropertyType } from "./api/defineSpt.js";
|
|
5
|
+
export { defineValueType } from "./api/defineValueType.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
package/build/browser/index.js
CHANGED
|
@@ -1,281 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
try {
|
|
23
|
-
await body();
|
|
24
|
-
} catch (e) {
|
|
25
|
-
console.error("Unexpected error while processing the body of the ontology", e);
|
|
26
|
-
throw e;
|
|
27
|
-
}
|
|
28
|
-
return convertToWireOntology(ontologyDefinition);
|
|
29
|
-
}
|
|
30
|
-
function convertToWireOntology(ontology) {
|
|
31
|
-
return {
|
|
32
|
-
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {
|
|
33
|
-
sharedPropertyType: convertSpt(spt)
|
|
34
|
-
}])),
|
|
35
|
-
interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {
|
|
36
|
-
return [apiName, {
|
|
37
|
-
interfaceType: convertInterface(interfaceType)
|
|
38
|
-
}];
|
|
39
|
-
})),
|
|
40
|
-
blockPermissionInformation: {
|
|
41
|
-
actionTypes: {},
|
|
42
|
-
linkTypes: {},
|
|
43
|
-
objectTypes: {}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function convertInterface(interfaceType) {
|
|
48
|
-
return {
|
|
49
|
-
...interfaceType,
|
|
50
|
-
properties: Object.values(interfaceType.properties).map((spt) => convertSpt(spt)),
|
|
51
|
-
// these are omitted from our internal types but we need to re-add them for the final json
|
|
52
|
-
allExtendsInterfaces: [],
|
|
53
|
-
allLinks: [],
|
|
54
|
-
allProperties: []
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function convertSpt({
|
|
58
|
-
type,
|
|
59
|
-
array,
|
|
60
|
-
description,
|
|
61
|
-
apiName,
|
|
62
|
-
displayName,
|
|
63
|
-
gothamMapping,
|
|
64
|
-
typeClasses
|
|
65
|
-
}) {
|
|
66
|
-
return {
|
|
67
|
-
apiName,
|
|
68
|
-
displayMetadata: {
|
|
69
|
-
displayName: displayName ?? apiName,
|
|
70
|
-
visibility: "NORMAL",
|
|
71
|
-
description
|
|
72
|
-
},
|
|
73
|
-
type: array ? {
|
|
74
|
-
type: "array",
|
|
75
|
-
array: {
|
|
76
|
-
subtype: convertType(type)
|
|
77
|
-
}
|
|
78
|
-
} : convertType(type),
|
|
79
|
-
aliases: [],
|
|
80
|
-
baseFormatter: void 0,
|
|
81
|
-
dataConstraints: void 0,
|
|
82
|
-
gothamMapping,
|
|
83
|
-
indexedForSearch: true,
|
|
84
|
-
provenance: void 0,
|
|
85
|
-
typeClasses: typeClasses ?? [],
|
|
86
|
-
valueType: void 0
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function convertType(type) {
|
|
90
|
-
switch (type) {
|
|
91
|
-
case "marking":
|
|
92
|
-
return {
|
|
93
|
-
type,
|
|
94
|
-
[type]: {
|
|
95
|
-
markingType: "MANDATORY"
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
case "geopoint":
|
|
99
|
-
return {
|
|
100
|
-
type: "geohash",
|
|
101
|
-
geohash: {}
|
|
102
|
-
};
|
|
103
|
-
case "decimal":
|
|
104
|
-
return {
|
|
105
|
-
type,
|
|
106
|
-
[type]: {
|
|
107
|
-
precision: void 0,
|
|
108
|
-
scale: void 0
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
case "string":
|
|
112
|
-
return {
|
|
113
|
-
type,
|
|
114
|
-
[type]: {
|
|
115
|
-
analyzerOverride: void 0,
|
|
116
|
-
enableAsciiFolding: void 0,
|
|
117
|
-
isLongText: false,
|
|
118
|
-
supportsExactMatching: true
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
default:
|
|
122
|
-
return distributeTypeHelper(type);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function distributeTypeHelper(type) {
|
|
126
|
-
return {
|
|
127
|
-
type,
|
|
128
|
-
[type]: {}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
var defaultTypeClasses = [{
|
|
132
|
-
kind: "render_hint",
|
|
133
|
-
name: "SELECTABLE"
|
|
134
|
-
}, {
|
|
135
|
-
kind: "render_hint",
|
|
136
|
-
name: "SORTABLE"
|
|
137
|
-
}];
|
|
138
|
-
function defineSharedPropertyType(opts) {
|
|
139
|
-
const apiName = namespace + opts.apiName;
|
|
140
|
-
!(ontologyDefinition.sharedPropertyTypes[apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant2(false, `Shared property type ${apiName} already exists`) : invariant2(false) : void 0;
|
|
141
|
-
return ontologyDefinition.sharedPropertyTypes[apiName] = {
|
|
142
|
-
...opts,
|
|
143
|
-
apiName,
|
|
144
|
-
displayName: opts.displayName ?? opts.apiName,
|
|
145
|
-
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
146
|
-
typeClasses: opts.typeClasses ?? defaultTypeClasses
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/api/defineInterface.ts
|
|
151
|
-
function defineInterface(opts) {
|
|
152
|
-
const apiName = namespace + opts.apiName;
|
|
153
|
-
!(ontologyDefinition.interfaceTypes[apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant2(false, `Interface ${apiName} already exists`) : invariant2(false) : void 0;
|
|
154
|
-
const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName2, type]) => {
|
|
155
|
-
if (typeof type === "string") {
|
|
156
|
-
!isSimpleType(type) ? process.env.NODE_ENV !== "production" ? invariant2(false, `Invalid data type ${type} for property ${apiName2} on InterfaceType ${apiName2}`) : invariant2(false) : void 0;
|
|
157
|
-
const spt = defineSharedPropertyType({
|
|
158
|
-
apiName: apiName2,
|
|
159
|
-
displayName: apiName2,
|
|
160
|
-
type,
|
|
161
|
-
array: false
|
|
162
|
-
});
|
|
163
|
-
return [apiName2, spt];
|
|
164
|
-
} else {
|
|
165
|
-
!(namespace + apiName2 === type.apiName) ? process.env.NODE_ENV !== "production" ? invariant2(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
166
|
-
key: apiName2,
|
|
167
|
-
apiName: type.apiName
|
|
168
|
-
})}`) : invariant2(false) : void 0;
|
|
169
|
-
return [apiName2, type];
|
|
170
|
-
}
|
|
171
|
-
}));
|
|
172
|
-
const a = {
|
|
173
|
-
apiName,
|
|
174
|
-
displayMetadata: {
|
|
175
|
-
displayName: opts.displayName ?? opts.apiName,
|
|
176
|
-
description: opts.description ?? opts.displayName ?? opts.apiName,
|
|
177
|
-
icon: opts.icon !== void 0 ? {
|
|
178
|
-
type: "blueprint",
|
|
179
|
-
blueprint: {
|
|
180
|
-
color: opts.icon.color,
|
|
181
|
-
locator: opts.icon.locator
|
|
182
|
-
}
|
|
183
|
-
} : void 0
|
|
184
|
-
},
|
|
185
|
-
extendsInterfaces: [],
|
|
186
|
-
links: [],
|
|
187
|
-
properties,
|
|
188
|
-
status: {
|
|
189
|
-
type: "active",
|
|
190
|
-
active: {}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
return ontologyDefinition.interfaceTypes[apiName] = a;
|
|
194
|
-
}
|
|
195
|
-
function isSimpleType(v) {
|
|
196
|
-
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// src/cli/main.ts
|
|
200
|
-
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
201
|
-
async function main(args = process.argv) {
|
|
202
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.8.0-beta.9").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
203
|
-
input: {
|
|
204
|
-
alias: "i",
|
|
205
|
-
describe: "Input file",
|
|
206
|
-
type: "string",
|
|
207
|
-
default: ".ontology/ontology.ts",
|
|
208
|
-
coerce: path.resolve
|
|
209
|
-
},
|
|
210
|
-
output: {
|
|
211
|
-
alias: "o",
|
|
212
|
-
describe: "Output file",
|
|
213
|
-
type: "string",
|
|
214
|
-
default: "ontology.json",
|
|
215
|
-
coerce: path.resolve
|
|
216
|
-
},
|
|
217
|
-
apiNamespace: {
|
|
218
|
-
describe: "Api name prefix for namespaced ontology types",
|
|
219
|
-
type: "string",
|
|
220
|
-
default: ""
|
|
221
|
-
},
|
|
222
|
-
snapshotDir: {
|
|
223
|
-
alias: "s",
|
|
224
|
-
describe: "Snapshot directory",
|
|
225
|
-
type: "string",
|
|
226
|
-
default: "snapshots",
|
|
227
|
-
coerce: path.resolve
|
|
228
|
-
}
|
|
229
|
-
}).parseAsync();
|
|
230
|
-
let apiNamespace = "";
|
|
231
|
-
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
232
|
-
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
233
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant2(false, "API namespace is too long.") : invariant2(false) : void 0;
|
|
234
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant2(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant2(false) : void 0;
|
|
235
|
-
}
|
|
236
|
-
consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
237
|
-
const ontology = await loadOntology(commandLineOpts.input, apiNamespace);
|
|
238
|
-
consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
239
|
-
await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));
|
|
240
|
-
}
|
|
241
|
-
async function loadOntology(input, apiNamespace) {
|
|
242
|
-
const q = await defineOntology(apiNamespace, async () => await import(input));
|
|
243
|
-
return q;
|
|
244
|
-
}
|
|
245
|
-
function defineInterfaceLinkConstraint(linkDef) {
|
|
246
|
-
const fromLinkMeta = getLinkMeta(linkDef);
|
|
247
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant2(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant2(false) : void 0;
|
|
248
|
-
linkDef.from.links.push({
|
|
249
|
-
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
250
|
-
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
251
|
-
metadata: fromLinkMeta,
|
|
252
|
-
required: true
|
|
253
|
-
// TODO: expose this?
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function getLinkedType(t) {
|
|
257
|
-
return {
|
|
258
|
-
type: "interfaceType",
|
|
259
|
-
interfaceType: typeof t === "string" ? t : t.apiName
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function getLinkMeta(meta) {
|
|
263
|
-
return typeof meta === "string" ? withDefaults({
|
|
264
|
-
apiName: namespace + meta
|
|
265
|
-
}) : withDefaults(meta);
|
|
266
|
-
}
|
|
267
|
-
function withDefaults({
|
|
268
|
-
apiName,
|
|
269
|
-
description,
|
|
270
|
-
displayName
|
|
271
|
-
}) {
|
|
272
|
-
return {
|
|
273
|
-
apiName: namespace + apiName,
|
|
274
|
-
displayName: displayName ?? apiName,
|
|
275
|
-
description: description ?? displayName ?? apiName
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export { main as default, defineInterface, defineInterfaceLinkConstraint, defineSharedPropertyType };
|
|
280
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
export { default } from "./cli/main.js";
|
|
17
|
+
export { defineInterface } from "./api/defineInterface.js";
|
|
18
|
+
export { defineInterfaceLinkConstraint } from "./api/defineInterfaceLinkConstraint.js";
|
|
19
|
+
export { defineSharedPropertyType } from "./api/defineSpt.js";
|
|
20
|
+
export { defineValueType } from "./api/defineValueType.js";
|
|
281
21
|
//# sourceMappingURL=index.js.map
|