@osdk/maker 0.9.0-beta.3 → 0.9.0-beta.5

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/build/browser/api/defineInterface.d.ts.map +1 -1
  3. package/build/browser/api/defineInterface.js +7 -7
  4. package/build/browser/api/defineInterface.js.map +1 -1
  5. package/build/browser/api/defineInterfaceLinkConstraint.js +1 -1
  6. package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
  7. package/build/browser/api/defineLink.js +2 -2
  8. package/build/browser/api/defineLink.js.map +1 -1
  9. package/build/browser/api/defineObject.js +1 -1
  10. package/build/browser/api/defineObject.js.map +1 -1
  11. package/build/browser/api/defineOntology.d.ts.map +1 -1
  12. package/build/browser/api/defineOntology.js +56 -9
  13. package/build/browser/api/defineOntology.js.map +1 -1
  14. package/build/browser/api/defineSpt.js +1 -1
  15. package/build/browser/api/defineSpt.js.map +1 -1
  16. package/build/browser/api/defineValueType.js +1 -1
  17. package/build/browser/api/defineValueType.js.map +1 -1
  18. package/build/browser/api/overall.test.js +90 -0
  19. package/build/browser/api/overall.test.js.map +1 -1
  20. package/build/browser/api/types.d.ts +16 -2
  21. package/build/browser/api/types.d.ts.map +1 -1
  22. package/build/browser/cli/main.js +3 -3
  23. package/build/browser/cli/main.js.map +1 -1
  24. package/build/esm/api/defineInterface.d.ts.map +1 -1
  25. package/build/esm/api/defineInterface.js +7 -7
  26. package/build/esm/api/defineInterface.js.map +1 -1
  27. package/build/esm/api/defineInterfaceLinkConstraint.js +1 -1
  28. package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
  29. package/build/esm/api/defineLink.js +2 -2
  30. package/build/esm/api/defineLink.js.map +1 -1
  31. package/build/esm/api/defineObject.js +1 -1
  32. package/build/esm/api/defineObject.js.map +1 -1
  33. package/build/esm/api/defineOntology.d.ts.map +1 -1
  34. package/build/esm/api/defineOntology.js +56 -9
  35. package/build/esm/api/defineOntology.js.map +1 -1
  36. package/build/esm/api/defineSpt.js +1 -1
  37. package/build/esm/api/defineSpt.js.map +1 -1
  38. package/build/esm/api/defineValueType.js +1 -1
  39. package/build/esm/api/defineValueType.js.map +1 -1
  40. package/build/esm/api/overall.test.js +90 -0
  41. package/build/esm/api/overall.test.js.map +1 -1
  42. package/build/esm/api/types.d.ts +16 -2
  43. package/build/esm/api/types.d.ts.map +1 -1
  44. package/build/esm/cli/main.js +3 -3
  45. package/build/esm/cli/main.js.map +1 -1
  46. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @osdk/maker
2
2
 
3
+ ## 0.9.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - b0544d4: Add additional marking configuration
8
+ - 2b35ed4: Structs in maker package
9
+
10
+ ### Patch Changes
11
+
12
+ - @osdk/api@2.1.0-beta.5
13
+
14
+ ## 0.9.0-beta.4
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [0dc40b0]
19
+ - Updated dependencies [1dc0228]
20
+ - Updated dependencies [d3b3f35]
21
+ - @osdk/api@2.1.0-beta.4
22
+
3
23
  ## 0.9.0-beta.3
4
24
 
5
25
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterface.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterface.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,kBAAkB,GAAG,gBAAgB,CACtC,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/D,GACA,aAAa,CA2Ef"}
1
+ {"version":3,"file":"defineInterface.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterface.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,kBAAkB,GAAG,gBAAgB,CACtC,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/D,GACA,aAAa,CA8Ef"}
@@ -18,10 +18,10 @@ import { namespace, ontologyDefinition } from "./defineOntology.js";
18
18
  import { defineSharedPropertyType } from "./defineSpt.js";
19
19
  export function defineInterface(opts) {
20
20
  const apiName = namespace + opts.apiName;
21
- !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? invariant(false, `Interface ${apiName} already exists`) : void 0;
21
+ !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
22
22
  const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {
23
- if (typeof type === "string") {
24
- !isSimpleType(type) ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : void 0;
23
+ if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
24
+ !isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
25
25
  const spt = defineSharedPropertyType({
26
26
  apiName,
27
27
  displayName: apiName,
@@ -30,10 +30,10 @@ export function defineInterface(opts) {
30
30
  });
31
31
  return [apiName, spt];
32
32
  } else {
33
- !(namespace + apiName === type.apiName) ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
33
+ !(namespace + apiName === type.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
34
34
  key: apiName,
35
35
  apiName: type.apiName
36
- })}`) : void 0;
36
+ })}`) : invariant(false) : void 0;
37
37
  return [apiName, type];
38
38
  }
39
39
  }));
@@ -72,7 +72,7 @@ export function defineInterface(opts) {
72
72
  };
73
73
  return ontologyDefinition.interfaceTypes[apiName] = a;
74
74
  }
75
- function isSimpleType(v) {
76
- return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
75
+ function isPropertyTypeType(v) {
76
+ return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || typeof v === "object" && v.type === "marking" || v === "short" || v === "string" || v === "timestamp";
77
77
  }
78
78
  //# sourceMappingURL=defineInterface.js.map
@@ -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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AO;MACjEyB,IAAI,EAAE1B,IAAI,CAAC0B,IAAI,KAAKvB,SAAS,GACvB;QACEM,IAAI,EAAE,WAAW;QACjBkB,SAAS,EAAE;UAAEC,KAAK,EAAE5B,IAAI,CAAC0B,IAAI,CAACE,KAAK;UAAEC,OAAO,EAAE7B,IAAI,CAAC0B,IAAI,CAACG;QAAQ;MACpE,CAAC,GACC1B;IACV,CAAC;IACDc,iBAAiB,EAAEA,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","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, `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,SAAS;MACT,MAAMmB,GAAG,GAAGhB,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AAW,EAAEf,IAAI,CAACe,WAAW,IAAIf,IAAI,CAACC,OAAO;MAC7C2B,WAAW,EAAE5B,IAAI,CAAC4B,WAAW,IAAI5B,IAAI,CAACe,WAAW,IAAIf,IAAI,CAACC,OAAO;MACjE4B,IAAI,EAAE7B,IAAI,CAAC6B,IAAI,KAAK1B,SAAS,GACvB;QACES,IAAI,EAAE,WAAW;QACjBkB,SAAS,EAAE;UAAEC,KAAK,EAAE/B,IAAI,CAAC6B,IAAI,CAACE,KAAK;UAAEC,OAAO,EAAEhC,IAAI,CAAC6B,IAAI,CAACG;QAAQ;MACpE,CAAC,GACC7B;IACV,CAAC;IACDiB,iBAAiB,EAAEA,iBAAiB;IACpCa,KAAK,EAAE,EAAE;IACT1B,UAAU;IACV2B,MAAM,EAAE;MAAEtB,IAAI,EAAE,QAAQ;MAAEuB,MAAM,EAAE,CAAC;IAAE;EACzC,CAAC;EACD,OAAOtC,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,GAAGyB,CAAC;AACzD;AACA,SAASb,kBAAkBA,CAACuB,CAAC,EAAE;EAC3B,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,IAC9B,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,CAACxB,IAAI,KAAK,SAAU,IAC/CwB,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AAC5B","ignoreList":[]}
@@ -17,7 +17,7 @@ import invariant from "tiny-invariant";
17
17
  import { namespace } from "./defineOntology.js";
18
18
  export function defineInterfaceLinkConstraint(linkDef) {
19
19
  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;
20
+ !(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
21
  linkDef.from.links.push({
22
22
  cardinality: linkDef.toMany ? "MANY" : "SINGLE",
23
23
  linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
@@ -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.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 } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n invariant(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`);\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true, // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\nfunction withDefaults({ apiName, description, displayName }) {\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;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAO,SAASC,6BAA6BA,CAACC,OAAO,EAAE;EACnD,MAAMC,YAAY,GAAGC,WAAW,CAACF,OAAO,CAAC;EACzC,EAAUA,OAAO,CAACG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAACC,OAAO,KAAKP,YAAY,CAACO,OAAO,CAAC,IAC5E,IAAI,IADXX,SAAS,QACI,qBAAqBI,YAAY,CAACO,OAAO,sBAAsBR,OAAO,CAACQ,OAAO,EAAE;EAC7FR,OAAO,CAACG,IAAI,CAACC,KAAK,CAACK,IAAI,CAAC;IACpBC,WAAW,EAAEV,OAAO,CAACW,MAAM,GAAG,MAAM,GAAG,QAAQ;IAC/CC,kBAAkB,EAAEC,aAAa,CAACb,OAAO,CAACW,MAAM,IAAIX,OAAO,CAACc,KAAK,CAAC;IAClEP,QAAQ,EAAEN,YAAY;IACtBc,QAAQ,EAAE,IAAI,CAAE;EACpB,CAAC,CAAC;AACN;AACA,SAASF,aAAaA,CAACG,CAAC,EAAE;EACtB,OAAO;IACHC,IAAI,EAAE,eAAe;IACrBC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACR;EACjD,CAAC;AACL;AACA,SAASN,WAAWA,CAACiB,IAAI,EAAE;EACvB,OAAO,OAAOA,IAAI,KAAK,QAAQ,GACzBC,YAAY,CAAC;IAAEZ,OAAO,EAAEV,SAAS,GAAGqB;EAAK,CAAC,CAAC,GAC3CC,YAAY,CAACD,IAAI,CAAC;AAC5B;AACA,SAASC,YAAYA,CAAC;EAAEZ,OAAO;EAAEa,WAAW;EAAEC;AAAY,CAAC,EAAE;EACzD,OAAO;IACHd,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5Bc,WAAW,EAAEA,WAAW,IAAId,OAAO;IACnCa,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAId;EAC/C,CAAC;AACL","ignoreList":[]}
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.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 } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n invariant(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`);\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true, // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\nfunction withDefaults({ apiName, description, displayName }) {\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;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAO,SAASC,6BAA6BA,CAACC,OAAO,EAAE;EACnD,MAAMC,YAAY,GAAGC,WAAW,CAACF,OAAO,CAAC;EACzC,EAAUA,OAAO,CAACG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAACC,OAAO,KAAKP,YAAY,CAACO,OAAO,CAAC,IAC5E,IAAI,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADXd,SAAS,QACI,qBAAqBI,YAAY,CAACO,OAAO,sBAAsBR,OAAO,CAACQ,OAAO,EAAE,IAD7FX,SAAS;EAETG,OAAO,CAACG,IAAI,CAACC,KAAK,CAACQ,IAAI,CAAC;IACpBC,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,EAAE,IAAI,CAAE;EACpB,CAAC,CAAC;AACN;AACA,SAASF,aAAaA,CAACG,CAAC,EAAE;EACtB,OAAO;IACHC,IAAI,EAAE,eAAe;IACrBC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACX;EACjD,CAAC;AACL;AACA,SAASN,WAAWA,CAACoB,IAAI,EAAE;EACvB,OAAO,OAAOA,IAAI,KAAK,QAAQ,GACzBC,YAAY,CAAC;IAAEf,OAAO,EAAEV,SAAS,GAAGwB;EAAK,CAAC,CAAC,GAC3CC,YAAY,CAACD,IAAI,CAAC;AAC5B;AACA,SAASC,YAAYA,CAAC;EAAEf,OAAO;EAAEgB,WAAW;EAAEC;AAAY,CAAC,EAAE;EACzD,OAAO;IACHjB,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5BiB,WAAW,EAAEA,WAAW,IAAIjB,OAAO;IACnCgB,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAIjB;EAC/C,CAAC;AACL","ignoreList":[]}
@@ -18,8 +18,8 @@ export function defineLink(from, opts) {
18
18
  const apiName = opts.one ?? opts.many;
19
19
  const toApiName = opts.reverse.one ?? opts.reverse.many;
20
20
  const to = opts.to;
21
- !(from.linkTypes[apiName] == null) ? invariant(false, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`) : void 0;
22
- !(from.linkTypes[toApiName] == null) ? invariant(false, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`) : void 0;
21
+ !(from.linkTypes[apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`) : invariant(false) : void 0;
22
+ !(from.linkTypes[toApiName] == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`) : invariant(false) : void 0;
23
23
  from.linkTypes[apiName] = {
24
24
  cardinality: "ONE",
25
25
  displayName: apiName,
@@ -1 +1 @@
1
- {"version":3,"file":"defineLink.js","names":["invariant","defineLink","from","opts","apiName","one","many","toApiName","reverse","to","linkTypes","data","objectType","cardinality","displayName","objectTypeApiName","status"],"sources":["defineLink.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\";\nexport function defineLink(from, opts) {\n const apiName = opts.one ?? opts.many;\n const toApiName = opts.reverse.one ?? opts.reverse.many;\n const to = opts.to;\n invariant(from.linkTypes[apiName] == null, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`);\n invariant(from.linkTypes[toApiName] == null, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`);\n from.linkTypes[apiName] = {\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: to.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n to.linkTypes[toApiName] = {\n apiName: toApiName,\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: from.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,UAAUA,CAACC,IAAI,EAAEC,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAGD,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACG,IAAI;EACrC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,OAAO,CAACH,GAAG,IAAIF,IAAI,CAACK,OAAO,CAACF,IAAI;EACvD,MAAMG,EAAE,GAAGN,IAAI,CAACM,EAAE;EAClB,EAAUP,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,IAAI,IAAI,IAAzCJ,SAAS,QAAkC,qBAAqBI,OAAO,sBAAsBF,IAAI,CAACS,IAAI,CAACC,UAAU,CAACR,OAAO,EAAE;EAC3H,EAAUF,IAAI,CAACQ,SAAS,CAACH,SAAS,CAAC,IAAI,IAAI,IAA3CP,SAAS,QAAoC,qBAAqBO,SAAS,sBAAsBE,EAAE,CAACE,IAAI,CAACC,UAAU,CAACR,OAAO,EAAE;EAC7HF,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,GAAG;IACtBS,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEV,OAAO;IACpBW,iBAAiB,EAAEN,EAAE,CAACE,IAAI,CAACC,UAAU,CAACR,OAAO;IAC7CY,MAAM,EAAE;EACZ,CAAC;EACDP,EAAE,CAACC,SAAS,CAACH,SAAS,CAAC,GAAG;IACtBH,OAAO,EAAEG,SAAS;IAClBM,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEV,OAAO;IACpBW,iBAAiB,EAAEb,IAAI,CAACS,IAAI,CAACC,UAAU,CAACR,OAAO;IAC/CY,MAAM,EAAE;EACZ,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"defineLink.js","names":["invariant","defineLink","from","opts","apiName","one","many","toApiName","reverse","to","linkTypes","process","env","NODE_ENV","data","objectType","cardinality","displayName","objectTypeApiName","status"],"sources":["defineLink.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\";\nexport function defineLink(from, opts) {\n const apiName = opts.one ?? opts.many;\n const toApiName = opts.reverse.one ?? opts.reverse.many;\n const to = opts.to;\n invariant(from.linkTypes[apiName] == null, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`);\n invariant(from.linkTypes[toApiName] == null, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`);\n from.linkTypes[apiName] = {\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: to.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n to.linkTypes[toApiName] = {\n apiName: toApiName,\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: from.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,UAAUA,CAACC,IAAI,EAAEC,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAGD,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACG,IAAI;EACrC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,OAAO,CAACH,GAAG,IAAIF,IAAI,CAACK,OAAO,CAACF,IAAI;EACvD,MAAMG,EAAE,GAAGN,IAAI,CAACM,EAAE;EAClB,EAAUP,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,IAAI,IAAI,IAAAO,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAzCb,SAAS,QAAkC,qBAAqBI,OAAO,sBAAsBF,IAAI,CAACY,IAAI,CAACC,UAAU,CAACX,OAAO,EAAE,IAA3HJ,SAAS;EACT,EAAUE,IAAI,CAACQ,SAAS,CAACH,SAAS,CAAC,IAAI,IAAI,IAAAI,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAA3Cb,SAAS,QAAoC,qBAAqBO,SAAS,sBAAsBE,EAAE,CAACK,IAAI,CAACC,UAAU,CAACX,OAAO,EAAE,IAA7HJ,SAAS;EACTE,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,GAAG;IACtBY,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEb,OAAO;IACpBc,iBAAiB,EAAET,EAAE,CAACK,IAAI,CAACC,UAAU,CAACX,OAAO;IAC7Ce,MAAM,EAAE;EACZ,CAAC;EACDV,EAAE,CAACC,SAAS,CAACH,SAAS,CAAC,GAAG;IACtBH,OAAO,EAAEG,SAAS;IAClBS,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEb,OAAO;IACpBc,iBAAiB,EAAEhB,IAAI,CAACY,IAAI,CAACC,UAAU,CAACX,OAAO;IAC/Ce,MAAM,EAAE;EACZ,CAAC;AACL","ignoreList":[]}
@@ -81,6 +81,6 @@ function convertType(t) {
81
81
  type: t.type
82
82
  };
83
83
  }
84
- invariant(false);
84
+ process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false);
85
85
  }
86
86
  //# sourceMappingURL=defineObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType"],"sources":["defineObject.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 { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineObject(apiName, opts) {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\nfunction convertType(t) {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n default:\n return {\n type: t.type,\n };\n }\n invariant(false);\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,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAEC,IAAI,EAAE;EACxCH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACtCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACRN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACFC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACV,CAAC;MACDC,UAAU,EAAE;QACR,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACvBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU;QACzC;MACJ,CAAC;MACDU,GAAG,EAAE,aAAa;MAClBC,MAAM,EAAE,QAAQ;MAChBC,aAAa,EAAElB,IAAI,CAACM,UAAU,CAACP;IACnC,CAAC;IACDoB,yBAAyB,EAAE,CAAC;EAChC,CAAC;EACD;EACA,OAAO;IACHC,IAAI,EAAEvB,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC;IAC7CK,SAAS,EAAE,CAAC;EAChB,CAAC;AACL;AACA,SAASW,WAAWA,CAACM,CAAC,EAAE;EACpB,QAAQ,IAAI;IACR,KAAKA,CAAC,CAACC,YAAY,KAAK,IAAI;MACxB,OAAO;QACHV,IAAI,EAAE,OAAO;QACbW,OAAO,EAAER,WAAW,CAAC;UAAE,GAAGM,CAAC;UAAEC,YAAY,EAAE;QAAM,CAAC;MACtD,CAAC;IACL,KAAKD,CAAC,CAACT,IAAI,KAAK,kBAAkB;MAC9B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;MACD;IACJ,KAAKS,CAAC,CAACT,IAAI,KAAK,mBAAmB;MAC/B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;IACL,KAAKS,CAAC,CAACT,IAAI,KAAK,UAAU;MACtB,OAAO;QACHA,IAAI,EAAE;MACV,CAAC;IACL;MACI,OAAO;QACHA,IAAI,EAAES,CAAC,CAACT;MACZ,CAAC;EACT;EACAhB,SAAS;AACb","ignoreList":[]}
1
+ {"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType","process","env","NODE_ENV"],"sources":["defineObject.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 { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineObject(apiName, opts) {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\nfunction convertType(t) {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n default:\n return {\n type: t.type,\n };\n }\n invariant(false);\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,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAEC,IAAI,EAAE;EACxCH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACtCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACRN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACFC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACV,CAAC;MACDC,UAAU,EAAE;QACR,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACvBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU;QACzC;MACJ,CAAC;MACDU,GAAG,EAAE,aAAa;MAClBC,MAAM,EAAE,QAAQ;MAChBC,aAAa,EAAElB,IAAI,CAACM,UAAU,CAACP;IACnC,CAAC;IACDoB,yBAAyB,EAAE,CAAC;EAChC,CAAC;EACD;EACA,OAAO;IACHC,IAAI,EAAEvB,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC;IAC7CK,SAAS,EAAE,CAAC;EAChB,CAAC;AACL;AACA,SAASW,WAAWA,CAACM,CAAC,EAAE;EACpB,QAAQ,IAAI;IACR,KAAKA,CAAC,CAACC,YAAY,KAAK,IAAI;MACxB,OAAO;QACHV,IAAI,EAAE,OAAO;QACbW,OAAO,EAAER,WAAW,CAAC;UAAE,GAAGM,CAAC;UAAEC,YAAY,EAAE;QAAM,CAAC;MACtD,CAAC;IACL,KAAKD,CAAC,CAACT,IAAI,KAAK,kBAAkB;MAC9B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;MACD;IACJ,KAAKS,CAAC,CAACT,IAAI,KAAK,mBAAmB;MAC/B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;IACL,KAAKS,CAAC,CAACT,IAAI,KAAK,UAAU;MACtB,OAAO;QACHA,IAAI,EAAE;MACV,CAAC;IACL;MACI,OAAO;QACHA,IAAI,EAAES,CAAC,CAACT;MACZ,CAAC;EACT;EACAa,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAA/B,SAAS,UAATA,SAAS;AACb","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"defineOntology.d.ts","sourceRoot":"","sources":["../../../src/api/defineOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,6BAA6B,EAG7B,4BAA4B,EAG7B,MAAM,uBAAuB,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,6BAA6B,CAAC;IACxC,SAAS,EAAE,4BAA4B,CAAC;CACzC,CAAC;AAEF,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA0BlC;AAsED,wBAAgB,wBAAwB,IAAI,6BAA6B,CAExE;AAED,wBAAgB,qBAAqB,IAAI,4BAA4B,CAEpE"}
1
+ {"version":3,"file":"defineOntology.d.ts","sourceRoot":"","sources":["../../../src/api/defineOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,6BAA6B,EAK7B,4BAA4B,EAI7B,MAAM,uBAAuB,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,6BAA6B,CAAC;IACxC,SAAS,EAAE,4BAA4B,CAAC;CACzC,CAAC;AAEF,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA0BlC;AAsED,wBAAgB,wBAAwB,IAAI,6BAA6B,CAExE;AAED,wBAAgB,qBAAqB,IAAI,4BAA4B,CAEpE"}
@@ -123,20 +123,67 @@ function convertSpt({
123
123
  };
124
124
  }
125
125
  function convertType(type) {
126
- switch (type) {
127
- case "marking":
126
+ switch (true) {
127
+ case typeof type === "object" && "markingType" in type:
128
128
  return {
129
- type,
130
- [type]: {
131
- markingType: "MANDATORY"
129
+ "type": "marking",
130
+ marking: {
131
+ markingType: type.markingType
132
+ }
133
+ };
134
+ case typeof type === "object" && "structDefinition" in type:
135
+ const structFields = new Array();
136
+ for (const key in type.structDefinition) {
137
+ const fieldTypeDefinition = type.structDefinition[key];
138
+ var field;
139
+ if (typeof fieldTypeDefinition === "string") {
140
+ field = {
141
+ apiName: key,
142
+ displayMetadata: {
143
+ displayName: key,
144
+ description: undefined
145
+ },
146
+ typeClasses: [],
147
+ aliases: [],
148
+ fieldType: convertType(fieldTypeDefinition)
149
+ };
150
+ } else {
151
+ // If it is a full form type definition then process it as such
152
+ if ("fieldType" in fieldTypeDefinition) {
153
+ field = {
154
+ ...fieldTypeDefinition,
155
+ apiName: key,
156
+ fieldType: convertType(fieldTypeDefinition.fieldType),
157
+ typeClasses: fieldTypeDefinition.typeClasses ?? [],
158
+ aliases: fieldTypeDefinition.aliases ?? []
159
+ };
160
+ } else {
161
+ field = {
162
+ apiName: key,
163
+ displayMetadata: {
164
+ displayName: key,
165
+ description: undefined
166
+ },
167
+ typeClasses: [],
168
+ aliases: [],
169
+ fieldType: convertType(fieldTypeDefinition)
170
+ };
171
+ }
172
+ }
173
+ structFields.push(field);
174
+ }
175
+ return {
176
+ type: "struct",
177
+ struct: {
178
+ structFields
132
179
  }
133
180
  };
134
- case "geopoint":
181
+ case type === "geopoint":
135
182
  return {
136
183
  type: "geohash",
137
184
  geohash: {}
138
185
  };
139
- case "decimal":
186
+ case type === "decimal":
140
187
  return {
141
188
  type,
142
189
  [type]: {
@@ -144,7 +191,7 @@ function convertType(type) {
144
191
  scale: undefined
145
192
  }
146
193
  };
147
- case "string":
194
+ case type === "string":
148
195
  return {
149
196
  type,
150
197
  [type]: {
@@ -154,7 +201,7 @@ function convertType(type) {
154
201
  supportsExactMatching: true
155
202
  }
156
203
  };
157
- case "mediaReference":
204
+ case type === "mediaReference":
158
205
  return {
159
206
  type: type,
160
207
  mediaReference: {}
@@ -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","visibility","subtype","convertType","aliases","baseFormatter","undefined","dataConstraints","indexedForSearch","provenance","markingType","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 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: undefined,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: valueType,\n };\n}\nfunction convertType(type) {\n switch (type) {\n case \"marking\":\n return { type, [type]: { markingType: \"MANDATORY\" } };\n case \"geopoint\":\n return { type: \"geohash\", geohash: {} };\n case \"decimal\":\n return { type, [type]: { precision: undefined, scale: undefined } };\n case \"string\":\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true,\n },\n };\n case \"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,SAAS;AACpB,OAAO,eAAeC,cAAcA,CAACC,EAAE,EAAEC,IAAI,EAAE;EAC3CH,SAAS,GAAGE,EAAE;EACdH,kBAAkB,GAAG;IACjBK,WAAW,EAAE,CAAC,CAAC;IACfC,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC,CAAC;IACdC,cAAc,EAAE,CAAC,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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","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","visibility","subtype","convertType","aliases","baseFormatter","undefined","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 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: undefined,\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,SAAS;AACpB,OAAO,eAAeC,cAAcA,CAACC,EAAE,EAAE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BC,qBAAqB,EAAE;QAC3B;MACJ,CAAC;IACL,KAAMhC,IAAI,KAAK,gBAAgB;MAC3B,OAAO;QACHA,IAAI,EAAEA,IAAI;QACViC,cAAc,EAAE,CAAC;MACrB,CAAC;IACL;MACI;MACA,OAAOC,oBAAoB,CAAClC,IAAI,CAAC;EACzC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASkC,oBAAoBA,CAAClC,IAAI,EAAE;EAChC,OAAO;IAAEA,IAAI;IAAE,CAACA,IAAI,GAAG,CAAC;EAAE,CAAC,CAAC,CAAC;AACjC","ignoreList":[]}
@@ -24,7 +24,7 @@ const defaultTypeClasses = [{
24
24
  }];
25
25
  export function defineSharedPropertyType(opts) {
26
26
  const apiName = namespace + opts.apiName;
27
- !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? invariant(false, `Shared property type ${apiName} already exists`) : void 0;
27
+ !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;
28
28
  return ontologyDefinition.sharedPropertyTypes[apiName] = {
29
29
  ...opts,
30
30
  apiName,
@@ -1 +1 @@
1
- {"version":3,"file":"defineSpt.js","names":["invariant","namespace","ontologyDefinition","defaultTypeClasses","kind","name","defineSharedPropertyType","opts","apiName","sharedPropertyTypes","undefined","displayName","typeClasses"],"sources":["defineSpt.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\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\",\n }, { kind: \"render_hint\", name: \"SORTABLE\" }];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.sharedPropertyTypes[apiName] === undefined, `Shared property type ${apiName} already exists`);\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n 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;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,MAAMC,kBAAkB,GAAG,CAAC;EACpBC,IAAI,EAAE,aAAa;EACnBC,IAAI,EAAE;AACV,CAAC,EAAE;EAAED,IAAI,EAAE,aAAa;EAAEC,IAAI,EAAE;AAAW,CAAC,CAAC;AACjD,OAAO,SAASC,wBAAwBA,CAACC,IAAI,EAAE;EAC3C,MAAMC,OAAO,GAAGP,SAAS,GAAGM,IAAI,CAACC,OAAO;EACxC,EAAUN,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAvEV,SAAS,QAAgE,wBAAwBQ,OAAO,iBAAiB;EACzH,OAAON,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,GAAG;IACrD,GAAGD,IAAI;IACPC,OAAO;IACPG,WAAW,EAAEJ,IAAI,CAACI,WAAW,IAAIJ,IAAI,CAACC,OAAO;IAAE;IAC/CI,WAAW,EAAEL,IAAI,CAACK,WAAW,IAAIT;EACrC,CAAC;AACL","ignoreList":[]}
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.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\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\",\n }, { kind: \"render_hint\", name: \"SORTABLE\" }];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.sharedPropertyTypes[apiName] === undefined, `Shared property type ${apiName} already exists`);\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n 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;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,MAAMC,kBAAkB,GAAG,CAAC;EACpBC,IAAI,EAAE,aAAa;EACnBC,IAAI,EAAE;AACV,CAAC,EAAE;EAAED,IAAI,EAAE,aAAa;EAAEC,IAAI,EAAE;AAAW,CAAC,CAAC;AACjD,OAAO,SAASC,wBAAwBA,CAACC,IAAI,EAAE;EAC3C,MAAMC,OAAO,GAAGP,SAAS,GAAGM,IAAI,CAACC,OAAO;EACxC,EAAUN,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAvEb,SAAS,QAAgE,wBAAwBQ,OAAO,iBAAiB,IAAzHR,SAAS;EACT,OAAOE,kBAAkB,CAACO,mBAAmB,CAACD,OAAO,CAAC,GAAG;IACrD,GAAGD,IAAI;IACPC,OAAO;IACPM,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIP,IAAI,CAACC,OAAO;IAAE;IAC/CO,WAAW,EAAER,IAAI,CAACQ,WAAW,IAAIZ;EACrC,CAAC;AACL","ignoreList":[]}
@@ -23,7 +23,7 @@ export function defineValueType(opts) {
23
23
  typeAndConstraints,
24
24
  version
25
25
  } = opts;
26
- !/^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/.test(version) ? invariant(false, "Version is not a valid semver") : void 0;
26
+ !/^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/.test(version) ? process.env.NODE_ENV !== "production" ? invariant(false, "Version is not a valid semver") : invariant(false) : void 0;
27
27
  // These suck but TS doesn't understand the relationship from the key of the base type to the type string
28
28
  const constraints = typeAndConstraints.constraints ? typeAndConstraints.constraints.map(constraint => {
29
29
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"defineValueType.js","names":["invariant","ontologyDefinition","defineValueType","opts","apiName","displayName","description","typeAndConstraints","version","test","constraints","map","constraint","Object","keys","baseType","vt","displayMetadata","status","type","active","exampleValues","valueTypes","undefined","push"],"sources":["defineValueType.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 { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineValueType(opts) {\n const { apiName, displayName, description, typeAndConstraints, version } = opts;\n const semverValidation = /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = typeAndConstraints.constraints\n ? typeAndConstraints.constraints.map(constraint => {\n return {\n constraint: {\n [Object.keys(constraint[\"constraint\"])[0]]: Object.keys(constraint[\"constraint\"])[0],\n ...constraint,\n },\n };\n })\n : [];\n const baseType = {\n [Object.keys(typeAndConstraints.baseType)[0]]: Object.keys(typeAndConstraints.baseType)[0],\n ...typeAndConstraints.baseType,\n };\n const vt = {\n apiName,\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: { type: \"active\", active: {} },\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n };\n if (ontologyDefinition.valueTypes[apiName] === undefined) {\n ontologyDefinition.valueTypes[apiName] = [];\n }\n ontologyDefinition.valueTypes[apiName].push(vt);\n return vt;\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,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAM;IAAE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AAkB,CAACqB,UAAU,CAAClB,OAAO,CAAC,CAACoB,IAAI,CAACR,EAAE,CAAC;EAC/C,OAAOA,EAAE;AACb","ignoreList":[]}
1
+ {"version":3,"file":"defineValueType.js","names":["invariant","ontologyDefinition","defineValueType","opts","apiName","displayName","description","typeAndConstraints","version","test","process","env","NODE_ENV","constraints","map","constraint","Object","keys","baseType","vt","displayMetadata","status","type","active","exampleValues","valueTypes","undefined","push"],"sources":["defineValueType.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 { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineValueType(opts) {\n const { apiName, displayName, description, typeAndConstraints, version } = opts;\n const semverValidation = /^((([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$/;\n invariant(semverValidation.test(version), \"Version is not a valid semver\");\n // These suck but TS doesn't understand the relationship from the key of the base type to the type string\n const constraints = typeAndConstraints.constraints\n ? typeAndConstraints.constraints.map(constraint => {\n return {\n constraint: {\n [Object.keys(constraint[\"constraint\"])[0]]: Object.keys(constraint[\"constraint\"])[0],\n ...constraint,\n },\n };\n })\n : [];\n const baseType = {\n [Object.keys(typeAndConstraints.baseType)[0]]: Object.keys(typeAndConstraints.baseType)[0],\n ...typeAndConstraints.baseType,\n };\n const vt = {\n apiName,\n displayMetadata: {\n displayName: displayName,\n description: description ?? \"\",\n },\n status: { type: \"active\", active: {} },\n version: version,\n baseType: baseType,\n constraints: constraints,\n exampleValues: [],\n };\n if (ontologyDefinition.valueTypes[apiName] === undefined) {\n ontologyDefinition.valueTypes[apiName] = [];\n }\n ontologyDefinition.valueTypes[apiName].push(vt);\n return vt;\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,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC,WAAW;IAAEC,kBAAkB;IAAEC;EAAQ,CAAC,GAAGL,IAAI;EAE/E,CADyB,uHAAuH,CACrHM,IAAI,CAACD,OAAO,CAAC,GAAAE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAxCZ,SAAS,QAAiC,+BAA+B,IAAzEA,SAAS;EACT;EACA,MAAMa,WAAW,GAAGN,kBAAkB,CAACM,WAAW,GAC5CN,kBAAkB,CAACM,WAAW,CAACC,GAAG,CAACC,UAAU,IAAI;IAC/C,OAAO;MACHA,UAAU,EAAE;QACR,CAACC,MAAM,CAACC,IAAI,CAACF,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAGC,MAAM,CAACC,IAAI,CAACF,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACpF,GAAGA;MACP;IACJ,CAAC;EACL,CAAC,CAAC,GACA,EAAE;EACR,MAAMG,QAAQ,GAAG;IACb,CAACF,MAAM,CAACC,IAAI,CAACV,kBAAkB,CAACW,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAGF,MAAM,CAACC,IAAI,CAACV,kBAAkB,CAACW,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1F,GAAGX,kBAAkB,CAACW;EAC1B,CAAC;EACD,MAAMC,EAAE,GAAG;IACPf,OAAO;IACPgB,eAAe,EAAE;MACbf,WAAW,EAAEA,WAAW;MACxBC,WAAW,EAAEA,WAAW,IAAI;IAChC,CAAC;IACDe,MAAM,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;IACtCf,OAAO,EAAEA,OAAO;IAChBU,QAAQ,EAAEA,QAAQ;IAClBL,WAAW,EAAEA,WAAW;IACxBW,aAAa,EAAE;EACnB,CAAC;EACD,IAAIvB,kBAAkB,CAACwB,UAAU,CAACrB,OAAO,CAAC,KAAKsB,SAAS,EAAE;IACtDzB,kBAAkB,CAACwB,UAAU,CAACrB,OAAO,CAAC,GAAG,EAAE;EAC/C;EACAH,kBAAkB,CAACwB,UAAU,CAACrB,OAAO,CAAC,CAACuB,IAAI,CAACR,EAAE,CAAC;EAC/C,OAAOA,EAAE;AACb","ignoreList":[]}
@@ -1037,5 +1037,95 @@ describe("Ontology Defining", () => {
1037
1037
  }
1038
1038
  `);
1039
1039
  });
1040
+ it("properly serializes both types of struct SPTs", () => {
1041
+ defineSharedPropertyType({
1042
+ apiName: "fooSpt",
1043
+ type: {
1044
+ type: "struct",
1045
+ structDefinition: {
1046
+ "simpleProperty": "boolean",
1047
+ "complexProperty": {
1048
+ fieldType: "date",
1049
+ displayMetadata: {
1050
+ displayName: "complex property",
1051
+ description: undefined
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1056
+ });
1057
+ expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
1058
+ {
1059
+ "blockPermissionInformation": {
1060
+ "actionTypes": {},
1061
+ "linkTypes": {},
1062
+ "objectTypes": {},
1063
+ },
1064
+ "interfaceTypes": {},
1065
+ "sharedPropertyTypes": {
1066
+ "com.palantir.fooSpt": {
1067
+ "sharedPropertyType": {
1068
+ "aliases": [],
1069
+ "apiName": "com.palantir.fooSpt",
1070
+ "baseFormatter": undefined,
1071
+ "dataConstraints": undefined,
1072
+ "displayMetadata": {
1073
+ "description": undefined,
1074
+ "displayName": "fooSpt",
1075
+ "visibility": "NORMAL",
1076
+ },
1077
+ "gothamMapping": undefined,
1078
+ "indexedForSearch": true,
1079
+ "provenance": undefined,
1080
+ "type": {
1081
+ "struct": {
1082
+ "structFields": [
1083
+ {
1084
+ "aliases": [],
1085
+ "apiName": "simpleProperty",
1086
+ "displayMetadata": {
1087
+ "description": undefined,
1088
+ "displayName": "simpleProperty",
1089
+ },
1090
+ "fieldType": {
1091
+ "boolean": {},
1092
+ "type": "boolean",
1093
+ },
1094
+ "typeClasses": [],
1095
+ },
1096
+ {
1097
+ "aliases": [],
1098
+ "apiName": "complexProperty",
1099
+ "displayMetadata": {
1100
+ "description": undefined,
1101
+ "displayName": "complex property",
1102
+ },
1103
+ "fieldType": {
1104
+ "date": {},
1105
+ "type": "date",
1106
+ },
1107
+ "typeClasses": [],
1108
+ },
1109
+ ],
1110
+ },
1111
+ "type": "struct",
1112
+ },
1113
+ "typeClasses": [
1114
+ {
1115
+ "kind": "render_hint",
1116
+ "name": "SELECTABLE",
1117
+ },
1118
+ {
1119
+ "kind": "render_hint",
1120
+ "name": "SORTABLE",
1121
+ },
1122
+ ],
1123
+ "valueType": undefined,
1124
+ },
1125
+ },
1126
+ },
1127
+ }
1128
+ `);
1129
+ });
1040
1130
  });
1041
1131
  //# sourceMappingURL=overall.test.js.map