@osdk/maker 0.9.0-beta.3 → 0.9.0-beta.30
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 +258 -0
- package/build/browser/api/defineImportSpt.js +47 -0
- package/build/browser/api/defineImportSpt.js.map +1 -0
- package/build/browser/api/defineInterface.js +39 -11
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +3 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineObject.js +57 -62
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +194 -23
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +3 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +58 -11
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/iconNames.js +0 -15
- package/build/browser/api/iconNames.js.map +1 -1
- package/build/browser/api/overall.test.js +704 -63
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/types.js +0 -15
- package/build/browser/api/types.js.map +1 -1
- package/build/browser/cli/main.js +5 -6
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/index.js +3 -0
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +716 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +343 -0
- package/build/esm/api/defineImportSpt.js +47 -0
- package/build/esm/api/defineImportSpt.js.map +1 -0
- package/build/esm/api/defineInterface.js +39 -11
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +3 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineObject.js +57 -62
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +194 -23
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +3 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +58 -11
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/iconNames.js +0 -15
- package/build/esm/api/iconNames.js.map +1 -1
- package/build/esm/api/overall.test.js +704 -63
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/types.js +0 -15
- package/build/esm/api/types.js.map +1 -1
- package/build/esm/cli/main.js +5 -6
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/index.js +3 -0
- package/build/esm/index.js.map +1 -1
- package/package.json +28 -13
- package/build/browser/api/defineInterface.d.ts +0 -14
- package/build/browser/api/defineInterface.d.ts.map +0 -1
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts +0 -21
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +0 -1
- package/build/browser/api/defineLink.d.ts +0 -18
- package/build/browser/api/defineLink.d.ts.map +0 -1
- package/build/browser/api/defineLink.js +0 -37
- package/build/browser/api/defineLink.js.map +0 -1
- package/build/browser/api/defineObject.d.ts +0 -15
- package/build/browser/api/defineObject.d.ts.map +0 -1
- package/build/browser/api/defineOntology.d.ts +0 -10
- package/build/browser/api/defineOntology.d.ts.map +0 -1
- package/build/browser/api/defineSpt.d.ts +0 -13
- package/build/browser/api/defineSpt.d.ts.map +0 -1
- package/build/browser/api/defineValueType.d.ts +0 -26
- package/build/browser/api/defineValueType.d.ts.map +0 -1
- package/build/browser/api/iconNames.d.ts +0 -3
- package/build/browser/api/iconNames.d.ts.map +0 -1
- package/build/browser/api/overall.test.d.ts +0 -2
- package/build/browser/api/overall.test.d.ts.map +0 -1
- package/build/browser/api/types.d.ts +0 -38
- package/build/browser/api/types.d.ts.map +0 -1
- package/build/browser/cli/main.d.ts +0 -2
- package/build/browser/cli/main.d.ts.map +0 -1
- package/build/browser/index.d.ts +0 -6
- package/build/browser/index.d.ts.map +0 -1
- package/build/esm/api/defineInterface.d.ts +0 -14
- package/build/esm/api/defineInterface.d.ts.map +0 -1
- package/build/esm/api/defineInterfaceLinkConstraint.d.ts +0 -21
- package/build/esm/api/defineInterfaceLinkConstraint.d.ts.map +0 -1
- package/build/esm/api/defineLink.d.ts +0 -18
- package/build/esm/api/defineLink.d.ts.map +0 -1
- package/build/esm/api/defineLink.js +0 -37
- package/build/esm/api/defineLink.js.map +0 -1
- package/build/esm/api/defineObject.d.ts +0 -15
- package/build/esm/api/defineObject.d.ts.map +0 -1
- package/build/esm/api/defineOntology.d.ts +0 -10
- package/build/esm/api/defineOntology.d.ts.map +0 -1
- package/build/esm/api/defineSpt.d.ts +0 -13
- package/build/esm/api/defineSpt.d.ts.map +0 -1
- package/build/esm/api/defineValueType.d.ts +0 -26
- package/build/esm/api/defineValueType.d.ts.map +0 -1
- package/build/esm/api/iconNames.d.ts +0 -3
- package/build/esm/api/iconNames.d.ts.map +0 -1
- package/build/esm/api/overall.test.d.ts +0 -2
- package/build/esm/api/overall.test.d.ts.map +0 -1
- package/build/esm/api/types.d.ts +0 -38
- package/build/esm/api/types.d.ts.map +0 -1
- package/build/esm/cli/main.d.ts +0 -2
- package/build/esm/cli/main.d.ts.map +0 -1
- package/build/esm/index.d.ts +0 -6
- package/build/esm/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","properties","Object","fromEntries","entries","map","type","isSimpleType","spt","displayName","array","JSON","stringify","key","extendsInterfaces","extends","Array","isArray","every","item","a","displayMetadata","description","icon","blueprint","color","locator","links","status","active","v"],"sources":["defineInterface.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 invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.interfaceTypes[apiName] === undefined, `Interface ${apiName} already exists`);\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n invariant(isSimpleType(type), `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`);\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n }\n else {\n invariant(namespace + apiName === type.apiName, `property key and it's apiName must be identical. ${JSON.stringify({ key: apiName, apiName: type.apiName })}`);\n return [apiName, type];\n }\n }));\n let extendsInterfaces = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n }\n else if (Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")) {\n extendsInterfaces = opts.extends;\n }\n else if (opts.extends.apiName !== undefined) {\n extendsInterfaces = [opts.extends.apiName];\n }\n else {\n extendsInterfaces = opts.extends.map(item => item.apiName);\n }\n }\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status: { type: \"active\", active: {} },\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\" || v === \"marking\"\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EAAUJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAlER,SAAS,QAA2D,aAAaM,OAAO,iBAAiB;EACzG,MAAMG,UAAU,GAAGC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACP,IAAI,CAACI,UAAU,IAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAAC,CAAC,CAACP,OAAO,EAAEQ,IAAI,CAAC,KAAK;IACjG,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1B,CAAUC,YAAY,CAACD,IAAI,CAAC,GAA5Bd,SAAS,QAAqB,qBAAqBc,IAAI,iBAAiBR,OAAO,qBAAqBA,OAAO,EAAE;MAC7G,MAAMU,GAAG,GAAGb,wBAAwB,CAAC;QACjCG,OAAO;QACPW,WAAW,EAAEX,OAAO;QACpBQ,IAAI;QACJI,KAAK,EAAE;MACX,CAAC,CAAC;MACF,OAAO,CAACZ,OAAO,EAAEU,GAAG,CAAC;IACzB,CAAC,MACI;MACD,EAAUf,SAAS,GAAGK,OAAO,KAAKQ,IAAI,CAACR,OAAO,IAA9CN,SAAS,QAAuC,oDAAoDmB,IAAI,CAACC,SAAS,CAAC;QAAEC,GAAG,EAAEf,OAAO;QAAEA,OAAO,EAAEQ,IAAI,CAACR;MAAQ,CAAC,CAAC,EAAE;MAC7J,OAAO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iBAAiB;IACpCa,KAAK,EAAE,EAAE;IACT1B,UAAU;IACV2B,MAAM,EAAE;MAAEtB,IAAI,EAAE,QAAQ;MAAEuB,MAAM,EAAE,CAAC;IAAE;EACzC,CAAC;EACD,OAAOnC,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,GAAGsB,CAAC;AACzD;AACA,SAASb,YAAYA,CAACuB,CAAC,EAAE;EACrB,OAAOA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAC/BA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,QAAQ,IACjDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,UAAU,IAAIA,CAAC,KAAK,UAAU,IACrDA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAClDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AAC5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","JSON","stringify","spt","displayName","array","unNamespacedTypeApiName","slice","lastIndexOf","key","extendsInterfaces","extends","Array","isArray","every","item","status","mapSimplifiedStatusToInterfaceTypeStatus","deprecated","message","deadline","a","displayMetadata","description","icon","blueprint","color","locator","links","v","replacedBy","active","experimental","Error"],"sources":["defineInterface.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nimport type { BlueprintIcon } from \"./iconNames.js\";\nimport type {\n InterfaceType,\n InterfaceTypeStatus,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\ntype SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\nexport function defineInterface(\n opts: {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n SharedPropertyType | PropertyTypeType\n >;\n\n extends?: InterfaceType | InterfaceType[] | string | string[];\n },\n): InterfaceType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.interfaceTypes[apiName] === undefined,\n `Interface ${apiName} already exists`,\n );\n\n const properties = Object.fromEntries(\n Object.entries(opts.properties ?? {}).map<\n [string, SharedPropertyType]\n >(\n ([apiName, type]) => {\n if (\n typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))\n ) {\n invariant(\n isPropertyTypeType(type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n } else {\n const unNamespacedTypeApiName = type.apiName.slice(\n type.apiName.lastIndexOf(\".\") + 1,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return [apiName, type];\n }\n },\n ),\n );\n\n let extendsInterfaces: string[] = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n } else if (\n Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")\n ) {\n extendsInterfaces = opts.extends;\n } else if ((opts.extends as InterfaceType).apiName !== undefined) {\n extendsInterfaces = [(opts.extends as InterfaceType).apiName];\n } else {\n extendsInterfaces = (opts.extends as InterfaceType[]).map(item =>\n item.apiName\n );\n }\n }\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n opts.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const a: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status,\n };\n\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\n\nfunction isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n\nfunction mapSimplifiedStatusToInterfaceTypeStatus(\n status: SimplifiedInterfaceTypeStatus,\n): InterfaceTypeStatus {\n switch (status.type) {\n case \"deprecated\":\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: undefined,\n },\n };\n case \"active\":\n return {\n type: \"active\",\n active: {},\n };\n case \"experimental\":\n return {\n type: \"experimental\",\n experimental: {},\n };\n default:\n throw new Error(`Invalid status type: ${(status as any).type}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;A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,wCAAwCA,CAC/CD,MAAqC,EAChB;EACrB,QAAQA,MAAM,CAACjB,IAAI;IACjB,KAAK,YAAY;MACf,OAAO;QACLA,IAAI,EAAE,YAAY;QAClBmB,UAAU,EAAE;UACVC,OAAO,EAAEH,MAAM,CAACG,OAAO;UACvBC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;UACzBU,UAAU,EAAExC;QACd;MACF,CAAC;IACH,KAAK,QAAQ;MACX,OAAO;QACLS,IAAI,EAAE,QAAQ;QACdgC,MAAM,EAAE,CAAC;MACX,CAAC;IACH,KAAK,cAAc;MACjB,OAAO;QACLhC,IAAI,EAAE,cAAc;QACpBiC,YAAY,EAAE,CAAC;MACjB,CAAC;IACH;MACE,MAAM,IAAIC,KAAK,CAAC,wBAAyBjB,MAAM,CAASjB,IAAI,EAAE,CAAC;EACnE;AACF","ignoreList":[]}
|
|
@@ -13,16 +13,17 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
|
|
16
17
|
import invariant from "tiny-invariant";
|
|
17
18
|
import { namespace } from "./defineOntology.js";
|
|
18
19
|
export function defineInterfaceLinkConstraint(linkDef) {
|
|
19
20
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
20
|
-
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : void 0;
|
|
21
|
+
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;
|
|
21
22
|
linkDef.from.links.push({
|
|
22
23
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
23
24
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
24
25
|
metadata: fromLinkMeta,
|
|
25
|
-
required:
|
|
26
|
+
required: linkDef.required ?? true
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
function getLinkedType(t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","process","env","NODE_ENV","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nimport type { InterfaceType } from \"./types.js\";\n\ntype Meta = { apiName: string; displayName?: string; description?: string };\ntype ApiNameOrInterfaceType = string | InterfaceType;\n\ntype Many = {\n apiName: string;\n from: InterfaceType;\n toMany: ApiNameOrInterfaceType;\n toOne?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\ntype One = {\n apiName: string;\n from: InterfaceType;\n toOne: ApiNameOrInterfaceType;\n toMany?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\n\nexport function defineInterfaceLinkConstraint(\n linkDef: One | Many,\n): void {\n const fromLinkMeta = getLinkMeta(linkDef);\n\n invariant(\n linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null,\n `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`,\n );\n\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: linkDef.required ?? true,\n });\n}\n\nfunction getLinkedType(t: string | InterfaceType) {\n return {\n type: \"interfaceType\" as const,\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\n\nfunction getLinkMeta(meta: One | Many) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\n\nfunction withDefaults(\n { apiName, description, displayName }: Meta,\n): Required<Meta> {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAyB/C,OAAO,SAASC,6BAA6BA,CAC3CC,OAAmB,EACb;EACN,MAAMC,YAAY,GAAGC,WAAW,CAACF,OAAO,CAAC;EAEzC,EACEA,OAAO,CAACG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAACC,OAAO,KAAKP,YAAY,CAACO,OAAO,CAAC,IACpE,IAAI,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFXd,SAAS,QAGP,qBAAqBI,YAAY,CAACO,OAAO,sBAAsBR,OAAO,CAACQ,OAAO,EAAE,IAHlFX,SAAS;EAMTG,OAAO,CAACG,IAAI,CAACC,KAAK,CAACQ,IAAI,CAAC;IACtBC,WAAW,EAAEb,OAAO,CAACc,MAAM,GAAG,MAAM,GAAG,QAAQ;IAC/CC,kBAAkB,EAAEC,aAAa,CAAChB,OAAO,CAACc,MAAM,IAAId,OAAO,CAACiB,KAAK,CAAC;IAClEV,QAAQ,EAAEN,YAAY;IACtBiB,QAAQ,EAAElB,OAAO,CAACkB,QAAQ,IAAI;EAChC,CAAC,CAAC;AACJ;AAEA,SAASF,aAAaA,CAACG,CAAyB,EAAE;EAChD,OAAO;IACLC,IAAI,EAAE,eAAwB;IAC9BC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACX;EAC/C,CAAC;AACH;AAEA,SAASN,WAAWA,CAACoB,IAAgB,EAAE;EACrC,OAAO,OAAOA,IAAI,KAAK,QAAQ,GAC3BC,YAAY,CAAC;IAAEf,OAAO,EAAEV,SAAS,GAAGwB;EAAK,CAAC,CAAC,GAC3CC,YAAY,CAACD,IAAI,CAAC;AACxB;AAEA,SAASC,YAAYA,CACnB;EAAEf,OAAO;EAAEgB,WAAW;EAAEC;AAAkB,CAAC,EAC3B;EAChB,OAAO;IACLjB,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5BiB,WAAW,EAAEA,WAAW,IAAIjB,OAAO;IACnCgB,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAIjB;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -13,74 +13,69 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
|
|
16
17
|
import invariant from "tiny-invariant";
|
|
17
|
-
import { ontologyDefinition } from "./defineOntology.js";
|
|
18
|
-
export function defineObject(
|
|
18
|
+
import { namespace, ontologyDefinition } from "./defineOntology.js";
|
|
19
|
+
export function defineObject(objectDef) {
|
|
20
|
+
const apiName = namespace + objectDef.apiName;
|
|
21
|
+
const propertyApiNames = (objectDef.properties ?? []).map(val => val.apiName);
|
|
22
|
+
if (ontologyDefinition.objectTypes[apiName] !== undefined) {
|
|
23
|
+
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
24
|
+
}
|
|
25
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant(false) : void 0;
|
|
26
|
+
!(objectDef.primaryKeys.length !== 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `${objectDef.apiName} does not have any primary keys, objects must have at least one primary key`) : invariant(false) : void 0;
|
|
27
|
+
const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey => !objectDef.properties?.map(val => val.apiName).includes(primaryKey));
|
|
28
|
+
!(nonExistentPrimaryKeys.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key properties ${nonExistentPrimaryKeys} do not exist on object ${objectDef.apiName}`) : invariant(false) : void 0;
|
|
29
|
+
objectDef.implementsInterfaces?.forEach(interfaceImpl => {
|
|
30
|
+
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => interfaceImpl.implements.properties[interfaceProperty] === undefined).map(interfaceProp => ({
|
|
31
|
+
type: "invalid",
|
|
32
|
+
reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
|
|
33
|
+
}));
|
|
34
|
+
const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [mapping.interfaceProperty, mapping.mapsTo]));
|
|
35
|
+
const validateProperty = interfaceProp => {
|
|
36
|
+
if (interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties) {
|
|
37
|
+
return validateInterfaceImplProperty(interfaceProp[1], interfaceToObjectProperties[interfaceProp[0]], objectDef);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
type: "invalid",
|
|
41
|
+
reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp[1].nonNameSpacedApiName} not implemented by ${objectDef.apiName} object definition`
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const baseValidations = Object.entries(interfaceImpl.implements.properties).map(validateProperty);
|
|
45
|
+
const extendsValidations = interfaceImpl.implements.extendsInterfaces.flatMap(interfaceApiName => Object.entries(ontologyDefinition.interfaceTypes[interfaceApiName].properties).map(validateProperty));
|
|
46
|
+
const allFailedValidations = baseValidations.concat(extendsValidations, nonExistentInterfaceProperties).filter(val => val.type === "invalid");
|
|
47
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant(false) : void 0;
|
|
48
|
+
});
|
|
19
49
|
ontologyDefinition.objectTypes[apiName] = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
linkTypes: [],
|
|
23
|
-
objectType: {
|
|
24
|
-
apiName,
|
|
25
|
-
primaryKey: opts.primaryKey.apiName,
|
|
26
|
-
displayName: opts.displayName ?? apiName,
|
|
27
|
-
pluralDisplayName: opts.pluralDisplayName ?? apiName,
|
|
28
|
-
icon: {
|
|
29
|
-
color: "blue",
|
|
30
|
-
name: "cube",
|
|
31
|
-
type: "blueprint"
|
|
32
|
-
},
|
|
33
|
-
properties: {
|
|
34
|
-
[opts.primaryKey.apiName]: {
|
|
35
|
-
dataType: convertType(opts.primaryKey)
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
rid: "PLACEHOLDER",
|
|
39
|
-
status: "ACTIVE",
|
|
40
|
-
titleProperty: opts.primaryKey.apiName
|
|
41
|
-
},
|
|
42
|
-
sharedPropertyTypeMapping: {}
|
|
50
|
+
...objectDef,
|
|
51
|
+
apiName: apiName
|
|
43
52
|
};
|
|
44
|
-
// FIXME: don't return the raw value
|
|
45
53
|
return {
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
...objectDef,
|
|
55
|
+
apiName: apiName
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
case t.type === "numericTimeseries":
|
|
69
|
-
return {
|
|
70
|
-
itemType: {
|
|
71
|
-
type: "double"
|
|
72
|
-
},
|
|
73
|
-
type: "timeseries"
|
|
74
|
-
};
|
|
75
|
-
case t.type === "datetime":
|
|
76
|
-
return {
|
|
77
|
-
type: "timestamp"
|
|
78
|
-
};
|
|
79
|
-
default:
|
|
80
|
-
return {
|
|
81
|
-
type: t.type
|
|
82
|
-
};
|
|
58
|
+
function formatValidationErrors(error) {
|
|
59
|
+
return `Ontology Definition Error: ${error.reason}\n`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Validate that the object and the interface property match up
|
|
63
|
+
function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
|
|
64
|
+
const objProp = object.properties?.find(prop => prop.apiName === mappedObjectProp);
|
|
65
|
+
if (objProp === undefined) {
|
|
66
|
+
return {
|
|
67
|
+
type: "invalid",
|
|
68
|
+
reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (spt.type !== objProp?.type) {
|
|
72
|
+
return {
|
|
73
|
+
type: "invalid",
|
|
74
|
+
reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`
|
|
75
|
+
};
|
|
83
76
|
}
|
|
84
|
-
|
|
77
|
+
return {
|
|
78
|
+
type: "valid"
|
|
79
|
+
};
|
|
85
80
|
}
|
|
86
81
|
//# sourceMappingURL=defineObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","
|
|
1
|
+
{"version":3,"file":"defineObject.js","names":["invariant","namespace","ontologyDefinition","defineObject","objectDef","apiName","propertyApiNames","properties","map","val","objectTypes","undefined","Error","includes","titlePropertyApiName","process","env","NODE_ENV","primaryKeys","length","nonExistentPrimaryKeys","filter","primaryKey","implementsInterfaces","forEach","interfaceImpl","nonExistentInterfaceProperties","propertyMapping","interfaceProperty","implements","interfaceProp","type","reason","interfaceToObjectProperties","Object","fromEntries","mapping","mapsTo","validateProperty","nonNameSpacedApiName","validateInterfaceImplProperty","baseValidations","entries","extendsValidations","extendsInterfaces","flatMap","interfaceApiName","interfaceTypes","allFailedValidations","concat","formatValidationErrors","join","error","spt","mappedObjectProp","object","objProp","find","prop"],"sources":["defineObject.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport type { ObjectType, SharedPropertyType } from \"./types.js\";\n\nexport function defineObject(objectDef: ObjectType): ObjectType {\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = (objectDef.properties ?? []).map(val => val.apiName);\n if (ontologyDefinition.objectTypes[apiName] !== undefined) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n objectDef.primaryKeys.length !== 0,\n `${objectDef.apiName} does not have any primary keys, objects must have at least one primary key`,\n );\n const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey =>\n !objectDef.properties?.map(val => val.apiName).includes(primaryKey)\n );\n invariant(\n nonExistentPrimaryKeys.length === 0,\n `Primary key properties ${nonExistentPrimaryKeys} do not exist on object ${objectDef.apiName}`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n interfaceImpl.implements.properties[interfaceProperty] === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [mapping.interfaceProperty, mapping.mapsTo],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, SharedPropertyType],\n ): ValidationResult => {\n if (\n interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties\n ) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason: `Interface property ${interfaceImpl.implements.apiName}.${\n interfaceProp[1].nonNameSpacedApiName\n } not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const baseValidations = Object.entries(interfaceImpl.implements.properties)\n .map<ValidationResult>(validateProperty);\n const extendsValidations = interfaceImpl.implements.extendsInterfaces\n .flatMap(interfaceApiName =>\n Object.entries(\n ontologyDefinition.interfaceTypes[interfaceApiName].properties,\n ).map(validateProperty)\n );\n\n const allFailedValidations = baseValidations.concat(\n extendsValidations,\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n ontologyDefinition.objectTypes[apiName] = { ...objectDef, apiName: apiName };\n return { ...objectDef, apiName: apiName };\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n spt: SharedPropertyType,\n mappedObjectProp: string,\n object: ObjectType,\n): ValidationResult {\n const objProp = object.properties?.find(prop =>\n prop.apiName === mappedObjectProp\n );\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n if (spt.type !== objProp?.type) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGnE,OAAO,SAASC,YAAYA,CAACC,SAAqB,EAAc;EAC9D,MAAMC,OAAO,GAAGJ,SAAS,GAAGG,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAG,CAACF,SAAS,CAACG,UAAU,IAAI,EAAE,EAAEC,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACJ,OAAO,CAAC;EAC7E,IAAIH,kBAAkB,CAACQ,WAAW,CAACL,OAAO,CAAC,KAAKM,SAAS,EAAE;IACzD,MAAM,IAAIC,KAAK,CACb,4BAA4BR,SAAS,CAACC,OAAO,qBAC/C,CAAC;EACH;EACA,CACEC,gBAAgB,CAACO,QAAQ,CAACT,SAAS,CAACU,oBAAoB,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD3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BAAkB,CAACQ,WAAW,CAACL,OAAO,CAAC,GAAG;IAAE,GAAGD,SAAS;IAAEC,OAAO,EAAEA;EAAQ,CAAC;EAC5E,OAAO;IAAE,GAAGD,SAAS;IAAEC,OAAO,EAAEA;EAAQ,CAAC;AAC3C;AAIA,SAAS6C,sBAAsBA,CAC7BE,KAA0C,EAClC;EACR,OAAO,8BAA8BA,KAAK,CAACpB,MAAM,IAAI;AACvD;;AAEA;AACA,SAASQ,6BAA6BA,CACpCa,GAAuB,EACvBC,gBAAwB,EACxBC,MAAkB,EACA;EAClB,MAAMC,OAAO,GAAGD,MAAM,CAAChD,UAAU,EAAEkD,IAAI,CAACC,IAAI,IAC1CA,IAAI,CAACrD,OAAO,KAAKiD,gBACnB,CAAC;EACD,IAAIE,OAAO,KAAK7C,SAAS,EAAE;IACzB,OAAO;MACLoB,IAAI,EAAE,SAAS;MACfC,MAAM,EACJ,+EAA+EsB,gBAAgB;IACnG,CAAC;EACH;EACA,IAAID,GAAG,CAACtB,IAAI,KAAKyB,OAAO,EAAEzB,IAAI,EAAE;IAC9B,OAAO;MACLA,IAAI,EAAE,SAAS;MACfC,MAAM,EACJ,mGAAmGqB,GAAG,CAAChD,OAAO,qBAAqBiD,gBAAgB;IACvJ,CAAC;EACH;EAEA,OAAO;IAAEvB,IAAI,EAAE;EAAQ,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
1
17
|
/*
|
|
2
18
|
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
19
|
*
|
|
@@ -13,8 +29,10 @@
|
|
|
13
29
|
* See the License for the specific language governing permissions and
|
|
14
30
|
* limitations under the License.
|
|
15
31
|
*/
|
|
32
|
+
|
|
16
33
|
/** @internal */
|
|
17
34
|
export let ontologyDefinition;
|
|
35
|
+
|
|
18
36
|
/** @internal */
|
|
19
37
|
export let namespace;
|
|
20
38
|
export async function defineOntology(ns, body) {
|
|
@@ -25,7 +43,10 @@ export async function defineOntology(ns, body) {
|
|
|
25
43
|
queryTypes: {},
|
|
26
44
|
interfaceTypes: {},
|
|
27
45
|
sharedPropertyTypes: {},
|
|
28
|
-
valueTypes: {}
|
|
46
|
+
valueTypes: {},
|
|
47
|
+
importedTypes: {
|
|
48
|
+
sharedPropertyTypes: []
|
|
49
|
+
}
|
|
29
50
|
};
|
|
30
51
|
try {
|
|
31
52
|
await body();
|
|
@@ -58,21 +79,114 @@ function convertOntologyToValueTypeIr(ontology) {
|
|
|
58
79
|
}
|
|
59
80
|
function convertToWireOntologyIr(ontology) {
|
|
60
81
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}]
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
blockData: {
|
|
83
|
+
objectTypes: Object.fromEntries(Object.entries(ontology.objectTypes).map(([apiName, objectType]) => {
|
|
84
|
+
return [apiName, convertObject(objectType)];
|
|
85
|
+
})),
|
|
86
|
+
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {
|
|
87
|
+
sharedPropertyType: convertSpt(spt)
|
|
88
|
+
}])),
|
|
89
|
+
interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {
|
|
90
|
+
return [apiName, {
|
|
91
|
+
interfaceType: convertInterface(interfaceType)
|
|
92
|
+
}];
|
|
93
|
+
})),
|
|
94
|
+
blockPermissionInformation: {
|
|
95
|
+
actionTypes: {},
|
|
96
|
+
linkTypes: {},
|
|
97
|
+
objectTypes: {}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
importedTypes: ontology.importedTypes
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function convertObject(objectType) {
|
|
104
|
+
const propertyDatasource = {};
|
|
105
|
+
(objectType.properties ?? []).forEach(property => {
|
|
106
|
+
propertyDatasource[property.apiName] = {
|
|
107
|
+
type: "column",
|
|
108
|
+
column: property.apiName
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const datasource = {
|
|
112
|
+
rid: "ri.ontology.main.datasource.".concat(objectType.apiName),
|
|
113
|
+
datasource: {
|
|
114
|
+
type: "datasetV2",
|
|
115
|
+
datasetV2: {
|
|
116
|
+
datasetRid: objectType.apiName,
|
|
117
|
+
propertyMapping: propertyDatasource
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
editsConfiguration: {
|
|
121
|
+
onlyAllowPrivilegedEdits: false
|
|
122
|
+
},
|
|
123
|
+
redacted: false
|
|
124
|
+
};
|
|
125
|
+
const implementations = objectType.implementsInterfaces ?? [];
|
|
126
|
+
return {
|
|
127
|
+
objectType: {
|
|
128
|
+
displayMetadata: {
|
|
129
|
+
description: objectType.description,
|
|
130
|
+
displayName: objectType.displayName,
|
|
131
|
+
groupDisplayName: undefined,
|
|
132
|
+
icon: {
|
|
133
|
+
type: "blueprint",
|
|
134
|
+
blueprint: objectType.icon ?? {
|
|
135
|
+
locator: "cube",
|
|
136
|
+
color: "#2D72D2"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
pluralDisplayName: objectType.pluralDisplayName,
|
|
140
|
+
visibility: objectType.visibility ?? "NORMAL"
|
|
141
|
+
},
|
|
142
|
+
primaryKeys: objectType.primaryKeys,
|
|
143
|
+
propertyTypes: Object.fromEntries(objectType.properties?.map(val => [val.apiName, convertProperty(val)]) ?? []),
|
|
144
|
+
titlePropertyTypeRid: objectType.titlePropertyApiName,
|
|
145
|
+
apiName: objectType.apiName,
|
|
146
|
+
status: objectType.status ?? {
|
|
147
|
+
type: "active",
|
|
148
|
+
active: {}
|
|
149
|
+
},
|
|
150
|
+
redacted: false,
|
|
151
|
+
implementsInterfaces2: implementations.map(impl => ({
|
|
152
|
+
interfaceTypeApiName: impl.implements.apiName,
|
|
153
|
+
properties: Object.fromEntries(impl.propertyMapping.map(mapping => [namespace + mapping.interfaceProperty, {
|
|
154
|
+
propertyTypeRid: mapping.mapsTo
|
|
155
|
+
}]))
|
|
156
|
+
})),
|
|
157
|
+
allImplementsInterfaces: {}
|
|
158
|
+
},
|
|
159
|
+
datasources: [datasource],
|
|
160
|
+
entityMetadata: {
|
|
161
|
+
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
73
162
|
}
|
|
74
163
|
};
|
|
75
164
|
}
|
|
165
|
+
function convertProperty(property) {
|
|
166
|
+
const output = {
|
|
167
|
+
apiName: property.apiName,
|
|
168
|
+
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
169
|
+
displayMetadata: {
|
|
170
|
+
displayName: property.displayName,
|
|
171
|
+
description: property.description,
|
|
172
|
+
visibility: property.visibility ?? "NORMAL"
|
|
173
|
+
},
|
|
174
|
+
indexedForSearch: property.indexedForSearch ?? true,
|
|
175
|
+
ruleSetBinding: undefined,
|
|
176
|
+
baseFormatter: property.baseFormatter,
|
|
177
|
+
type: convertType(property.type),
|
|
178
|
+
typeClasses: property.typeClasses ?? [],
|
|
179
|
+
status: property.status ?? {
|
|
180
|
+
type: "active",
|
|
181
|
+
active: {}
|
|
182
|
+
},
|
|
183
|
+
inlineAction: undefined,
|
|
184
|
+
dataConstraints: property.dataConstraints,
|
|
185
|
+
sharedPropertyTypeRid: property.sharedPropertyType?.apiName,
|
|
186
|
+
valueType: undefined
|
|
187
|
+
};
|
|
188
|
+
return output;
|
|
189
|
+
}
|
|
76
190
|
function convertInterface(interfaceType) {
|
|
77
191
|
return {
|
|
78
192
|
...interfaceType,
|
|
@@ -99,6 +213,14 @@ function convertSpt({
|
|
|
99
213
|
typeClasses,
|
|
100
214
|
valueType
|
|
101
215
|
}) {
|
|
216
|
+
const dataConstraint = typeof type === "object" && type.type === "marking" ? {
|
|
217
|
+
propertyTypeConstraints: [],
|
|
218
|
+
nullability: undefined,
|
|
219
|
+
nullabilityV2: {
|
|
220
|
+
noEmptyCollections: true,
|
|
221
|
+
noNulls: true
|
|
222
|
+
}
|
|
223
|
+
} : undefined;
|
|
102
224
|
return {
|
|
103
225
|
apiName,
|
|
104
226
|
displayMetadata: {
|
|
@@ -114,7 +236,7 @@ function convertSpt({
|
|
|
114
236
|
} : convertType(type),
|
|
115
237
|
aliases: [],
|
|
116
238
|
baseFormatter: undefined,
|
|
117
|
-
dataConstraints:
|
|
239
|
+
dataConstraints: dataConstraint,
|
|
118
240
|
gothamMapping: gothamMapping,
|
|
119
241
|
indexedForSearch: true,
|
|
120
242
|
provenance: undefined,
|
|
@@ -123,20 +245,67 @@ function convertSpt({
|
|
|
123
245
|
};
|
|
124
246
|
}
|
|
125
247
|
function convertType(type) {
|
|
126
|
-
switch (
|
|
127
|
-
case "
|
|
248
|
+
switch (true) {
|
|
249
|
+
case typeof type === "object" && "markingType" in type:
|
|
128
250
|
return {
|
|
129
|
-
type,
|
|
130
|
-
|
|
131
|
-
markingType:
|
|
251
|
+
"type": "marking",
|
|
252
|
+
marking: {
|
|
253
|
+
markingType: type.markingType
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
case typeof type === "object" && "structDefinition" in type:
|
|
257
|
+
const structFields = new Array();
|
|
258
|
+
for (const key in type.structDefinition) {
|
|
259
|
+
const fieldTypeDefinition = type.structDefinition[key];
|
|
260
|
+
let field;
|
|
261
|
+
if (typeof fieldTypeDefinition === "string") {
|
|
262
|
+
field = {
|
|
263
|
+
apiName: key,
|
|
264
|
+
displayMetadata: {
|
|
265
|
+
displayName: key,
|
|
266
|
+
description: undefined
|
|
267
|
+
},
|
|
268
|
+
typeClasses: [],
|
|
269
|
+
aliases: [],
|
|
270
|
+
fieldType: convertType(fieldTypeDefinition)
|
|
271
|
+
};
|
|
272
|
+
} else {
|
|
273
|
+
// If it is a full form type definition then process it as such
|
|
274
|
+
if ("fieldType" in fieldTypeDefinition) {
|
|
275
|
+
field = {
|
|
276
|
+
...fieldTypeDefinition,
|
|
277
|
+
apiName: key,
|
|
278
|
+
fieldType: convertType(fieldTypeDefinition.fieldType),
|
|
279
|
+
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
280
|
+
aliases: fieldTypeDefinition.aliases ?? []
|
|
281
|
+
};
|
|
282
|
+
} else {
|
|
283
|
+
field = {
|
|
284
|
+
apiName: key,
|
|
285
|
+
displayMetadata: {
|
|
286
|
+
displayName: key,
|
|
287
|
+
description: undefined
|
|
288
|
+
},
|
|
289
|
+
typeClasses: [],
|
|
290
|
+
aliases: [],
|
|
291
|
+
fieldType: convertType(fieldTypeDefinition)
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
structFields.push(field);
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
type: "struct",
|
|
299
|
+
struct: {
|
|
300
|
+
structFields
|
|
132
301
|
}
|
|
133
302
|
};
|
|
134
|
-
case "geopoint":
|
|
303
|
+
case type === "geopoint":
|
|
135
304
|
return {
|
|
136
305
|
type: "geohash",
|
|
137
306
|
geohash: {}
|
|
138
307
|
};
|
|
139
|
-
case "decimal":
|
|
308
|
+
case type === "decimal":
|
|
140
309
|
return {
|
|
141
310
|
type,
|
|
142
311
|
[type]: {
|
|
@@ -144,17 +313,18 @@ function convertType(type) {
|
|
|
144
313
|
scale: undefined
|
|
145
314
|
}
|
|
146
315
|
};
|
|
147
|
-
case "string":
|
|
316
|
+
case type === "string":
|
|
148
317
|
return {
|
|
149
318
|
type,
|
|
150
319
|
[type]: {
|
|
151
320
|
analyzerOverride: undefined,
|
|
152
321
|
enableAsciiFolding: undefined,
|
|
153
322
|
isLongText: false,
|
|
323
|
+
supportsEfficientLeadingWildcard: false,
|
|
154
324
|
supportsExactMatching: true
|
|
155
325
|
}
|
|
156
326
|
};
|
|
157
|
-
case "mediaReference":
|
|
327
|
+
case type === "mediaReference":
|
|
158
328
|
return {
|
|
159
329
|
type: type,
|
|
160
330
|
mediaReference: {}
|
|
@@ -164,6 +334,7 @@ function convertType(type) {
|
|
|
164
334
|
return distributeTypeHelper(type);
|
|
165
335
|
}
|
|
166
336
|
}
|
|
337
|
+
|
|
167
338
|
/**
|
|
168
339
|
* Helper function to avoid duplication. Makes the types match properly with the correct
|
|
169
340
|
* behavior without needing to switch on type.
|