@osdk/maker 0.9.0-beta.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +304 -0
- package/build/browser/api/defineImportSpt.js +24 -2
- package/build/browser/api/defineImportSpt.js.map +1 -1
- package/build/browser/api/defineInterface.js +34 -6
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +2 -1
- 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 +130 -14
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +2 -0
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +57 -10
- 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 +461 -68
- 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 +3 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/index.js +2 -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 +24 -2
- package/build/esm/api/defineImportSpt.js.map +1 -1
- package/build/esm/api/defineInterface.js +34 -6
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +2 -1
- 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 +130 -14
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +2 -0
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +57 -10
- 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 +461 -68
- 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 +3 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/index.js +2 -0
- package/build/esm/index.js.map +1 -1
- package/package.json +25 -12
- package/build/browser/api/defineImportSpt.d.ts +0 -10
- package/build/browser/api/defineImportSpt.d.ts.map +0 -1
- 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 -52
- 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 -7
- package/build/browser/index.d.ts.map +0 -1
- package/build/esm/api/defineImportSpt.d.ts +0 -10
- package/build/esm/api/defineImportSpt.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 -52
- 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 -7
- 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","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","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 || (typeof type === \"object\" && !(\"apiName\" in type))) {\n invariant(isPropertyTypeType(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 || 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 isPropertyTypeType(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\"\n || (typeof v === \"object\" && v.type === \"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,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAlEX,SAAS,QAA2D,aAAaM,OAAO,iBAAiB,IAAzGN,SAAS;EACT,MAAMY,UAAU,GAAGC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACV,IAAI,CAACO,UAAU,IAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAAC,CAAC,CAACV,OAAO,EAAEW,IAAI,CAAC,KAAK;IACjG,IAAI,OAAOA,IAAI,KAAK,QAAQ,IACpB,OAAOA,IAAI,KAAK,QAAQ,IAAI,EAAE,SAAS,IAAIA,IAAI,CAAE,EAAE;MACvD,CAAUC,kBAAkB,CAACD,IAAI,CAAC,GAAAR,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAlCX,SAAS,QAA2B,qBAAqBiB,IAAI,iBAAiBX,OAAO,qBAAqBA,OAAO,EAAE,IAAnHN,SAA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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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AAczD,OAAO,SAASC,eAAeA,CAC7BC,IAYC,EACc;EACf,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EACEJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1DX,SAAS,QAEP,aAAaM,OAAO,iBAAiB,IAFvCN,SAAS;EAKT,MAAMY,UAAU,GAAGC,MAAM,CAACC,WAAW,CACnCD,MAAM,CAACE,OAAO,CAACV,IAAI,CAACO,UAAU,IAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAGvC,CAAC,CAACV,OAAO,EAAEW,IAAI,CAAC,KAAK;IACnB,IACE,OAAOA,IAAI,KAAK,QAAQ,IACpB,OAAOA,IAAI,KAAK,QAAQ,IAAI,EA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,OAAOhC,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,GAAGiC,CAAC;AACvD;AAEA,SAASrB,kBAAkBA,CACzB6B,CAAmB,EACI;EACvB,OAAOA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IACjCA,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,IAC9B,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,CAAC9B,IAAI,KAAK,SAAU,IAC/C8B,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AACxB;AAEA,SAASZ,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,6 +13,7 @@
|
|
|
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) {
|
|
@@ -22,7 +23,7 @@ export function defineInterfaceLinkConstraint(linkDef) {
|
|
|
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","process","env","NODE_ENV","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,CA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* 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,
|
|
@@ -143,7 +257,7 @@ function convertType(type) {
|
|
|
143
257
|
const structFields = new Array();
|
|
144
258
|
for (const key in type.structDefinition) {
|
|
145
259
|
const fieldTypeDefinition = type.structDefinition[key];
|
|
146
|
-
|
|
260
|
+
let field;
|
|
147
261
|
if (typeof fieldTypeDefinition === "string") {
|
|
148
262
|
field = {
|
|
149
263
|
apiName: key,
|
|
@@ -206,6 +320,7 @@ function convertType(type) {
|
|
|
206
320
|
analyzerOverride: undefined,
|
|
207
321
|
enableAsciiFolding: undefined,
|
|
208
322
|
isLongText: false,
|
|
323
|
+
supportsEfficientLeadingWildcard: false,
|
|
209
324
|
supportsExactMatching: true
|
|
210
325
|
}
|
|
211
326
|
};
|
|
@@ -219,6 +334,7 @@ function convertType(type) {
|
|
|
219
334
|
return distributeTypeHelper(type);
|
|
220
335
|
}
|
|
221
336
|
}
|
|
337
|
+
|
|
222
338
|
/**
|
|
223
339
|
* Helper function to avoid duplication. Makes the types match properly with the correct
|
|
224
340
|
* behavior without needing to switch on type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineOntology.js","names":["ontologyDefinition","namespace","defineOntology","ns","body","actionTypes","objectTypes","queryTypes","interfaceTypes","sharedPropertyTypes","valueTypes","e","console","error","ontology","convertToWireOntologyIr","valueType","convertOntologyToValueTypeIr","Object","values","map","definitions","metadata","apiName","displayMetadata","status","versions","definition","version","baseType","constraints","exampleValues","fromEntries","entries","spt","sharedPropertyType","convertSpt","interfaceType","convertInterface","blockPermissionInformation","linkTypes","properties","allExtendsInterfaces","allLinks","allProperties","dumpOntologyFullMetadata","dumpValueTypeWireType","type","array","description","displayName","gothamMapping","typeClasses","dataConstraint","propertyTypeConstraints","nullability","undefined","nullabilityV2","noEmptyCollections","noNulls","visibility","subtype","convertType","aliases","baseFormatter","dataConstraints","indexedForSearch","provenance","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","fieldType","push","struct","geohash","precision","scale","analyzerOverride","enableAsciiFolding","isLongText","supportsExactMatching","mediaReference","distributeTypeHelper"],"sources":["defineOntology.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 */\n/** @internal */\nexport let ontologyDefinition;\n/** @internal */\nexport let namespace;\nexport async function defineOntology(ns, body) {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n };\n try {\n await body();\n }\n catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected error while processing the body of the ontology\", e);\n throw e;\n }\n return {\n ontology: convertToWireOntologyIr(ontologyDefinition),\n valueType: convertOntologyToValueTypeIr(ontologyDefinition),\n };\n}\nfunction convertOntologyToValueTypeIr(ontology) {\n return {\n valueTypes: Object.values(ontology.valueTypes).map(definitions => ({\n metadata: {\n apiName: definitions[0].apiName,\n displayMetadata: definitions[0].displayMetadata,\n status: definitions[0].status,\n },\n versions: definitions.map(definition => ({\n version: definition.version,\n baseType: definition.baseType,\n constraints: definition.constraints,\n exampleValues: definition.exampleValues,\n })),\n })),\n };\n}\nfunction convertToWireOntologyIr(ontology) {\n return {\n sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes)\n .map(([apiName, spt]) => [apiName, { sharedPropertyType: convertSpt(spt) }])),\n interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes)\n .map(([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType),\n }];\n })),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {},\n },\n };\n}\nfunction convertInterface(interfaceType) {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties)\n .map((spt) => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: [],\n };\n}\nexport function dumpOntologyFullMetadata() {\n return convertToWireOntologyIr(ontologyDefinition);\n}\nexport function dumpValueTypeWireType() {\n return convertOntologyToValueTypeIr(ontologyDefinition);\n}\nfunction convertSpt({ type, array, description, apiName, displayName, gothamMapping, typeClasses, valueType, }) {\n const dataConstraint = (typeof type === \"object\" && type.type === \"marking\")\n ? {\n propertyTypeConstraints: [],\n nullability: undefined,\n nullabilityV2: { noEmptyCollections: true, noNulls: true },\n }\n : undefined;\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description,\n },\n type: array\n ? {\n type: \"array\",\n array: {\n subtype: convertType(type),\n },\n }\n : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: dataConstraint,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: valueType,\n };\n}\nfunction convertType(type) {\n switch (true) {\n case (typeof type === \"object\" && \"markingType\" in type):\n return {\n \"type\": \"marking\",\n marking: { markingType: type.markingType },\n };\n case (typeof type === \"object\" && \"structDefinition\" in type):\n const structFields = new Array();\n for (const key in type.structDefinition) {\n const fieldTypeDefinition = type.structDefinition[key];\n var field;\n if (typeof fieldTypeDefinition === \"string\") {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n }\n else {\n // If it is a full form type definition then process it as such\n if (\"fieldType\" in fieldTypeDefinition) {\n field = {\n ...fieldTypeDefinition,\n apiName: key,\n fieldType: convertType(fieldTypeDefinition.fieldType),\n typeClasses: fieldTypeDefinition.typeClasses ?? [],\n aliases: fieldTypeDefinition.aliases ?? [],\n };\n }\n else {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n }\n }\n structFields.push(field);\n }\n return {\n type: \"struct\",\n struct: { structFields },\n };\n case (type === \"geopoint\"):\n return { type: \"geohash\", geohash: {} };\n case (type === \"decimal\"):\n return { type, [type]: { precision: undefined, scale: undefined } };\n case (type === \"string\"):\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true,\n },\n };\n case (type === \"mediaReference\"):\n return {\n type: type,\n mediaReference: {},\n };\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper(type) {\n return { type, [type]: {} }; // any cast to match conditional return type\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIA,kBAAkB;AAC7B;AACA,OAAO,IAAIC,SAA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AAS;MACpB,OAAO;QAAEA,IAAI;QAAE,CAACA,IAAI,GAAG;UAAEiC,SAAS,EAAExB,SAAS;UAAEyB,KAAK,EAAEzB;QAAU;MAAE,CAAC;IACvE,KAAMT,IAAI,KAAK,QAAQ;MACnB,OAAO;QACHA,IAAI;QACJ,CAACA,IAAI,GAAG;UACJmC,gBAAgB,EAAE1B,SAAS;UAC3B2B,kBAAkB,EAAE3B,SAAS;UAC7B4B,UAAU,EAAE,KAAK;UACjBC,qBAAqB,EAAE;QAC3B;MACJ,CAAC;IACL,KAAMtC,IAAI,KAAK,gBAAgB;MAC3B,OAAO;QACHA,IAAI,EAAEA,IAAI;QACVuC,cAAc,EAAE,CAAC;MACrB,CAAC;IACL;MACI;MACA,OAAOC,oBAAoB,CAACxC,IAAI,CAAC;EACzC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASwC,oBAAoBA,CAACxC,IAAI,EAAE;EAChC,OAAO;IAAEA,IAAI;IAAE,CAACA,IAAI,GAAG,CAAC;EAAE,CAAC,CAAC,CAAC;AACjC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineOntology.js","names":["ontologyDefinition","namespace","defineOntology","ns","body","actionTypes","objectTypes","queryTypes","interfaceTypes","sharedPropertyTypes","valueTypes","importedTypes","e","console","error","ontology","convertToWireOntologyIr","valueType","convertOntologyToValueTypeIr","Object","values","map","definitions","metadata","apiName","displayMetadata","status","versions","definition","version","baseType","constraints","exampleValues","blockData","fromEntries","entries","objectType","convertObject","spt","sharedPropertyType","convertSpt","interfaceType","convertInterface","blockPermissionInformation","linkTypes","propertyDatasource","properties","forEach","property","type","column","datasource","rid","concat","datasetV2","datasetRid","propertyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","implementations","implementsInterfaces","description","displayName","groupDisplayName","undefined","icon","blueprint","locator","color","pluralDisplayName","visibility","primaryKeys","propertyTypes","val","convertProperty","titlePropertyTypeRid","titlePropertyApiName","active","implementsInterfaces2","impl","interfaceTypeApiName","implements","mapping","interfaceProperty","propertyTypeRid","mapsTo","allImplementsInterfaces","datasources","entityMetadata","arePatchesEnabled","editsEnabled","output","sharedPropertyTypeApiName","indexedForSearch","ruleSetBinding","baseFormatter","convertType","typeClasses","inlineAction","dataConstraints","sharedPropertyTypeRid","allExtendsInterfaces","allLinks","allProperties","dumpOntologyFullMetadata","dumpValueTypeWireType","array","gothamMapping","dataConstraint","propertyTypeConstraints","nullability","nullabilityV2","noEmptyCollections","noNulls","subtype","aliases","provenance","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","fieldType","push","struct","geohash","precision","scale","analyzerOverride","enableAsciiFolding","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","mediaReference","distributeTypeHelper"],"sources":["defineOntology.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIr,\n OntologyIrInterfaceType,\n OntologyIrInterfaceTypeBlockDataV2,\n OntologyIrObjectTypeBlockDataV2,\n OntologyIrObjectTypeDatasource,\n OntologyIrPropertyType,\n OntologyIrSharedPropertyType,\n OntologyIrSharedPropertyTypeBlockDataV2,\n OntologyIrStructFieldType,\n OntologyIrType,\n OntologyIrValueTypeBlockData,\n OntologyIrValueTypeBlockDataEntry,\n PropertyTypeMappingInfo,\n} from \"@osdk/client.unstable\";\nimport type {\n InterfaceType,\n ObjectPropertyType,\n ObjectType,\n Ontology,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\n/** @internal */\nexport let ontologyDefinition: Ontology;\n\n/** @internal */\nexport let namespace: string;\n\ntype OntologyAndValueTypeIrs = {\n ontology: OntologyIr;\n valueType: OntologyIrValueTypeBlockData;\n};\n\nexport async function defineOntology(\n ns: string,\n body: () => void | Promise<void>,\n): Promise<OntologyAndValueTypeIrs> {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {},\n valueTypes: {},\n importedTypes: {\n sharedPropertyTypes: [],\n },\n };\n\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected error while processing the body of the ontology\",\n e,\n );\n throw e;\n }\n\n return {\n ontology: convertToWireOntologyIr(ontologyDefinition),\n valueType: convertOntologyToValueTypeIr(ontologyDefinition),\n };\n}\n\nfunction convertOntologyToValueTypeIr(\n ontology: Ontology,\n): OntologyIrValueTypeBlockData {\n return {\n valueTypes: Object.values(ontology.valueTypes).map<\n OntologyIrValueTypeBlockDataEntry\n >(definitions => ({\n metadata: {\n apiName: definitions[0].apiName,\n displayMetadata: definitions[0].displayMetadata,\n status: definitions[0].status,\n },\n versions: definitions.map(definition => ({\n version: definition.version,\n baseType: definition.baseType,\n constraints: definition.constraints,\n exampleValues: definition.exampleValues,\n })),\n })),\n };\n}\n\nfunction convertToWireOntologyIr(\n ontology: Ontology,\n): OntologyIr {\n return {\n blockData: {\n objectTypes: Object.fromEntries(\n Object.entries(ontology.objectTypes).map<\n [string, OntologyIrObjectTypeBlockDataV2]\n >(([apiName, objectType]) => {\n return [apiName, convertObject(objectType)];\n }),\n ),\n sharedPropertyTypes: Object.fromEntries(\n Object.entries(\n ontology.sharedPropertyTypes,\n )\n .map<[string, OntologyIrSharedPropertyTypeBlockDataV2]>((\n [apiName, spt],\n ) => [apiName, { sharedPropertyType: convertSpt(spt) }]),\n ),\n interfaceTypes: Object.fromEntries(\n Object.entries(\n ontology.interfaceTypes,\n )\n .map<[string, OntologyIrInterfaceTypeBlockDataV2]>(\n ([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType),\n }];\n },\n ),\n ),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {},\n },\n },\n importedTypes: ontology.importedTypes,\n };\n}\n\nfunction convertObject(\n objectType: ObjectType,\n): OntologyIrObjectTypeBlockDataV2 {\n const propertyDatasource: Record<string, PropertyTypeMappingInfo> = {};\n (objectType.properties ?? []).forEach((property) => {\n propertyDatasource[property.apiName] = {\n type: \"column\",\n column: property.apiName,\n };\n });\n\n const datasource: OntologyIrObjectTypeDatasource = {\n rid: \"ri.ontology.main.datasource.\".concat(objectType.apiName),\n datasource: {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: propertyDatasource,\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: false,\n };\n\n const implementations = objectType.implementsInterfaces ?? [];\n\n return {\n objectType: {\n displayMetadata: {\n description: objectType.description,\n displayName: objectType.displayName,\n groupDisplayName: undefined,\n icon: {\n type: \"blueprint\",\n blueprint: objectType.icon ?? { locator: \"cube\", color: \"#2D72D2\" },\n },\n pluralDisplayName: objectType.pluralDisplayName,\n visibility: objectType.visibility ?? \"NORMAL\",\n },\n primaryKeys: objectType.primaryKeys,\n propertyTypes: Object.fromEntries(\n objectType.properties?.map<[string, OntologyIrPropertyType]>(\n val => [val.apiName, convertProperty(val)],\n ) ?? [],\n ),\n titlePropertyTypeRid: objectType.titlePropertyApiName,\n apiName: objectType.apiName,\n status: objectType.status ?? {\n type: \"active\",\n active: {},\n },\n redacted: false,\n implementsInterfaces2: implementations.map(impl => ({\n interfaceTypeApiName: impl.implements.apiName,\n properties: Object.fromEntries(\n impl.propertyMapping.map(\n mapping => [namespace + mapping.interfaceProperty, {\n propertyTypeRid: mapping.mapsTo,\n }],\n ),\n ),\n })),\n allImplementsInterfaces: {},\n },\n datasources: [datasource],\n entityMetadata: { arePatchesEnabled: objectType.editsEnabled ?? false },\n };\n}\n\nfunction convertProperty(property: ObjectPropertyType): OntologyIrPropertyType {\n const output: OntologyIrPropertyType = {\n apiName: property.apiName,\n sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,\n displayMetadata: {\n displayName: property.displayName,\n description: property.description,\n visibility: property.visibility ?? \"NORMAL\",\n },\n indexedForSearch: property.indexedForSearch ?? true,\n ruleSetBinding: undefined,\n baseFormatter: property.baseFormatter,\n type: convertType(property.type),\n typeClasses: property.typeClasses ?? [],\n status: property.status ?? { type: \"active\", active: {} },\n inlineAction: undefined,\n dataConstraints: property.dataConstraints,\n sharedPropertyTypeRid: property.sharedPropertyType?.apiName,\n valueType: undefined,\n };\n return output;\n}\n\nfunction convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrInterfaceType {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties)\n .map<OntologyIrSharedPropertyType>((spt) => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: [],\n };\n}\n\nexport function dumpOntologyFullMetadata(): OntologyIr {\n return convertToWireOntologyIr(ontologyDefinition);\n}\n\nexport function dumpValueTypeWireType(): OntologyIrValueTypeBlockData {\n return convertOntologyToValueTypeIr(ontologyDefinition);\n}\n\nfunction convertSpt(\n {\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses,\n valueType,\n }: SharedPropertyType,\n): OntologyIrSharedPropertyType {\n const dataConstraint:\n | OntologyIrSharedPropertyType[\"dataConstraints\"]\n | undefined = (typeof type === \"object\" && type.type === \"marking\")\n ? {\n propertyTypeConstraints: [],\n nullability: undefined,\n nullabilityV2: { noEmptyCollections: true, noNulls: true },\n }\n : undefined;\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description,\n },\n type: array\n ? {\n type: \"array\" as const,\n array: {\n subtype: convertType(type),\n },\n }\n : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: dataConstraint,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: valueType,\n };\n}\n\nfunction convertType(\n type: PropertyTypeType,\n): OntologyIrType {\n switch (true) {\n case (typeof type === \"object\" && \"markingType\" in type):\n return {\n \"type\": \"marking\",\n marking: { markingType: type.markingType },\n };\n\n case (typeof type === \"object\" && \"structDefinition\" in type):\n const structFields: Array<OntologyIrStructFieldType> = new Array();\n for (const key in type.structDefinition) {\n const fieldTypeDefinition = type.structDefinition[key];\n let field: OntologyIrStructFieldType;\n if (typeof fieldTypeDefinition === \"string\") {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n } else {\n // If it is a full form type definition then process it as such\n if (\"fieldType\" in fieldTypeDefinition) {\n field = {\n ...fieldTypeDefinition,\n apiName: key,\n fieldType: convertType(fieldTypeDefinition.fieldType),\n typeClasses: fieldTypeDefinition.typeClasses ?? [],\n aliases: fieldTypeDefinition.aliases ?? [],\n };\n } else {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: convertType(fieldTypeDefinition),\n };\n }\n }\n\n structFields.push(field);\n }\n\n return {\n type: \"struct\",\n struct: { structFields },\n };\n\n case (type === \"geopoint\"):\n return { type: \"geohash\", geohash: {} };\n\n case (type === \"decimal\"):\n return { type, [type]: { precision: undefined, scale: undefined } };\n\n case (type === \"string\"):\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsEfficientLeadingWildcard: false,\n supportsExactMatching: true,\n },\n };\n\n case (type === \"mediaReference\"):\n return {\n type: type,\n mediaReference: {},\n };\n\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper<T extends string>(\n type: T,\n): T extends any ? { type: T } & { [K in T]: {} } : never {\n return { type, [type]: {} } as any; // any cast to match conditional return type\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;AACA,OAAO,IAAIA,kBAA4B;;AAEvC;AACA,OAAO,IAAIC,SAAiB;AAO5B,OAAO,eAAeC,cAAcA,CAClCC,EAAU,EACVC,IAAgC,EACE;EAClCH,SAAS,GAAGE,EAAE;EACdH,kBAAkB,GAAG;IACnBK,WAAW,EAAE,CAAC,CAAC;IACfC,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC,CAAC;IACdC,cAAc,EAAE,CAAC,CAAC;IAClBC,mBAAmB,EAAE,CAAC,CAAC;IACvBC,UAAU,EAAE,CAAC,CAAC;IACdC,aAAa,EAAE;MACbF,mBAAmB,EAAE;IACvB;EACF,CAAC;EAED,IAAI;IACF,MAAML,IAAI,CAAC,CAAC;EACd,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,KAAK,CACX,4DAA4D,EAC5DF,CACF,CAAC;IACD,MAAMA,CAAC;EACT;EAEA,OAAO;IACLG,QAAQ,EAAEC,uBAAuB,CAAChB,kBAAkB,CAAC;IACrDiB,SAAS,EAAEC,4BAA4B,CA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,EAAE7B,WAAW,CAAC2B,mBAAmB;YAC5C,CAAC;UACH;QACF;QAEAJ,YAAY,CAACO,IAAI,CAACF,KAAK,CAAC;MAC1B;MAEA,OAAO;QACL5E,IAAI,EAAE,QAAQ;QACd+E,MAAM,EAAE;UAAER;QAAa;MACzB,CAAC;IAEH,KAAMvE,IAAI,KAAK,UAAU;MACvB,OAAO;QAAEA,IAAI,EAAE,SAAS;QAAEgF,OAAO,EAAE,CAAC;MAAE,CAAC;IAEzC,KAAMhF,IAAI,KAAK,SAAS;MACtB,OAAO;QAAEA,IAAI;QAAE,CAACA,IAAI,GAAG;UAAEiF,SAAS,EAAEjE,SAAS;UAAEkE,KAAK,EAAElE;QAAU;MAAE,CAAC;IAErE,KAAMhB,IAAI,KAAK,QAAQ;MACrB,OAAO;QACLA,IAAI;QACJ,CAACA,IAAI,GAAG;UACNmF,gBAAgB,EAAEnE,SAAS;UAC3BoE,kBAAkB,EAAEpE,SAAS;UAC7BqE,UAAU,EAAE,KAAK;UACjBC,gCAAgC,EAAE,KAAK;UACvCC,qBAAqB,EAAE;QACzB;MACF,CAAC;IAEH,KAAMvF,IAAI,KAAK,gBAAgB;MAC7B,OAAO;QACLA,IAAI,EAAEA,IAAI;QACVwF,cAAc,EAAE,CAAC;MACnB,CAAC;IAEH;MACE;MACA,OAAOC,oBAAoB,CAACzF,IAAI,CAAC;EACrC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASyF,oBAAoBA,CAC3BzF,IAAO,EACiD;EACxD,OAAO;IAAEA,IAAI;IAAE,CAACA,IAAI,GAAG,CAAC;EAAE,CAAC,CAAQ,CAAC;AACtC","ignoreList":[]}
|
|
@@ -13,6 +13,7 @@
|
|
|
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, ontologyDefinition } from "./defineOntology.js";
|
|
18
19
|
const defaultTypeClasses = [{
|
|
@@ -28,6 +29,7 @@ export function defineSharedPropertyType(opts) {
|
|
|
28
29
|
return ontologyDefinition.sharedPropertyTypes[apiName] = {
|
|
29
30
|
...opts,
|
|
30
31
|
apiName,
|
|
32
|
+
nonNameSpacedApiName: opts.apiName,
|
|
31
33
|
displayName: opts.displayName ?? opts.apiName,
|
|
32
34
|
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
33
35
|
typeClasses: opts.typeClasses ?? defaultTypeClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineSpt.js","names":["invariant","namespace","ontologyDefinition","defaultTypeClasses","kind","name","defineSharedPropertyType","opts","apiName","sharedPropertyTypes","undefined","process","env","NODE_ENV","displayName","typeClasses"],"sources":["defineSpt.
|
|
1
|
+
{"version":3,"file":"defineSpt.js","names":["invariant","namespace","ontologyDefinition","defaultTypeClasses","kind","name","defineSharedPropertyType","opts","apiName","sharedPropertyTypes","undefined","process","env","NODE_ENV","nonNameSpacedApiName","displayName","typeClasses"],"sources":["defineSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ApiNameValueTypeReference,\n SharedPropertyTypeGothamMapping,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\nconst defaultTypeClasses: SharedPropertyType[\"typeClasses\"] = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\",\n}, { kind: \"render_hint\", name: \"SORTABLE\" }];\n\nexport function defineSharedPropertyType(\n opts: {\n apiName: string;\n type: PropertyTypeType;\n array?: boolean;\n description?: string;\n displayName?: string;\n valueType?: ApiNameValueTypeReference;\n typeClasses?: SharedPropertyType[\"typeClasses\"];\n gothamMapping?: SharedPropertyTypeGothamMapping;\n },\n): SharedPropertyType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.sharedPropertyTypes[apiName] === undefined,\n `Shared property type ${apiName} already exists`,\n );\n\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n nonNameSpacedApiName: opts.apiName,\n displayName: opts.displayName ?? opts.apiName, // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: opts.typeClasses ?? defaultTypeClasses,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AAGnE,MAAMC,kBAAqD,GAAG,CAAC;EAC7DC,IAAI,EAAE,aAAa;EACnBC,IAAI,EAAE;AACR,CAAC,EAAE;EAAED,IAAI,EAAE,aAAa;EAAEC,IAAI,EAAE;AAAW,CAAC,CAAC;AAE7C,OAAO,SAASC,wBAAwBA,CACtCC,IASC,EACmB;EACpB,MAAMC,OAAO,GAAGP,SAAS,GAAGM,IAAI,CAACC,OAAO;EACxC,EACEN,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD/Db,SAAS,QAEP,wBAAwBQ,OAAO,iBAAiB,IAFlDR,SAAS;EAKT,OAAOE,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,GAAG;IACvD,GAAGD,IAAI;IACPC,OAAO;IACPM,oBAAoB,EAAEP,IAAI,CAACC,OAAO;IAClCO,WAAW,EAAER,IAAI,CAACQ,WAAW,IAAIR,IAAI,CAACC,OAAO;IAAE;IAC/CQ,WAAW,EAAET,IAAI,CAACS,WAAW,IAAIb;EACnC,CAAC;AACH","ignoreList":[]}
|