@osdk/maker 0.9.0-beta.2 → 0.9.0-beta.20

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 (76) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/build/browser/api/defineImportSpt.d.ts +10 -0
  3. package/build/browser/api/defineImportSpt.d.ts.map +1 -0
  4. package/build/browser/api/defineImportSpt.js +44 -0
  5. package/build/browser/api/defineImportSpt.js.map +1 -0
  6. package/build/browser/api/defineInterface.d.ts +11 -0
  7. package/build/browser/api/defineInterface.d.ts.map +1 -1
  8. package/build/browser/api/defineInterface.js +38 -11
  9. package/build/browser/api/defineInterface.js.map +1 -1
  10. package/build/browser/api/defineInterfaceLinkConstraint.d.ts +2 -0
  11. package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
  12. package/build/browser/api/defineInterfaceLinkConstraint.js +2 -2
  13. package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
  14. package/build/browser/api/defineLink.js +2 -2
  15. package/build/browser/api/defineLink.js.map +1 -1
  16. package/build/browser/api/defineObject.d.ts.map +1 -1
  17. package/build/browser/api/defineObject.js +19 -2
  18. package/build/browser/api/defineObject.js.map +1 -1
  19. package/build/browser/api/defineOntology.d.ts +3 -3
  20. package/build/browser/api/defineOntology.d.ts.map +1 -1
  21. package/build/browser/api/defineOntology.js +85 -24
  22. package/build/browser/api/defineOntology.js.map +1 -1
  23. package/build/browser/api/defineSpt.js +1 -1
  24. package/build/browser/api/defineSpt.js.map +1 -1
  25. package/build/browser/api/defineValueType.d.ts +8 -17
  26. package/build/browser/api/defineValueType.d.ts.map +1 -1
  27. package/build/browser/api/defineValueType.js +57 -11
  28. package/build/browser/api/defineValueType.js.map +1 -1
  29. package/build/browser/api/overall.test.js +351 -60
  30. package/build/browser/api/overall.test.js.map +1 -1
  31. package/build/browser/api/types.d.ts +196 -3
  32. package/build/browser/api/types.d.ts.map +1 -1
  33. package/build/browser/cli/main.js +3 -3
  34. package/build/browser/cli/main.js.map +1 -1
  35. package/build/browser/index.d.ts +1 -0
  36. package/build/browser/index.d.ts.map +1 -1
  37. package/build/browser/index.js +1 -0
  38. package/build/browser/index.js.map +1 -1
  39. package/build/esm/api/defineImportSpt.d.ts +10 -0
  40. package/build/esm/api/defineImportSpt.d.ts.map +1 -0
  41. package/build/esm/api/defineImportSpt.js +44 -0
  42. package/build/esm/api/defineImportSpt.js.map +1 -0
  43. package/build/esm/api/defineInterface.d.ts +11 -0
  44. package/build/esm/api/defineInterface.d.ts.map +1 -1
  45. package/build/esm/api/defineInterface.js +38 -11
  46. package/build/esm/api/defineInterface.js.map +1 -1
  47. package/build/esm/api/defineInterfaceLinkConstraint.d.ts +2 -0
  48. package/build/esm/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
  49. package/build/esm/api/defineInterfaceLinkConstraint.js +2 -2
  50. package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
  51. package/build/esm/api/defineLink.js +2 -2
  52. package/build/esm/api/defineLink.js.map +1 -1
  53. package/build/esm/api/defineObject.d.ts.map +1 -1
  54. package/build/esm/api/defineObject.js +19 -2
  55. package/build/esm/api/defineObject.js.map +1 -1
  56. package/build/esm/api/defineOntology.d.ts +3 -3
  57. package/build/esm/api/defineOntology.d.ts.map +1 -1
  58. package/build/esm/api/defineOntology.js +85 -24
  59. package/build/esm/api/defineOntology.js.map +1 -1
  60. package/build/esm/api/defineSpt.js +1 -1
  61. package/build/esm/api/defineSpt.js.map +1 -1
  62. package/build/esm/api/defineValueType.d.ts +8 -17
  63. package/build/esm/api/defineValueType.d.ts.map +1 -1
  64. package/build/esm/api/defineValueType.js +57 -11
  65. package/build/esm/api/defineValueType.js.map +1 -1
  66. package/build/esm/api/overall.test.js +351 -60
  67. package/build/esm/api/overall.test.js.map +1 -1
  68. package/build/esm/api/types.d.ts +196 -3
  69. package/build/esm/api/types.d.ts.map +1 -1
  70. package/build/esm/cli/main.js +3 -3
  71. package/build/esm/cli/main.js.map +1 -1
  72. package/build/esm/index.d.ts +1 -0
  73. package/build/esm/index.d.ts.map +1 -1
  74. package/build/esm/index.js +1 -0
  75. package/build/esm/index.js.map +1 -1
  76. package/package.json +10 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,179 @@
1
1
  # @osdk/maker
2
2
 
3
+ ## 0.9.0-beta.20
4
+
5
+ ### Minor Changes
6
+
7
+ - 9d35a1f: Remove unused imports
8
+ - abfe4b3: Add support for reading struct properties.
9
+ - 06e66dc: Making interface type status configurable
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [9d35a1f]
14
+ - Updated dependencies [abfe4b3]
15
+ - Updated dependencies [c537e2d]
16
+ - @osdk/api@2.1.0-beta.20
17
+
18
+ ## 0.9.0-beta.19
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [cddc196]
23
+ - @osdk/api@2.1.0-beta.19
24
+
25
+ ## 0.9.0-beta.18
26
+
27
+ ### Patch Changes
28
+
29
+ - @osdk/api@2.1.0-beta.18
30
+
31
+ ## 0.9.0-beta.17
32
+
33
+ ### Patch Changes
34
+
35
+ - @osdk/api@2.1.0-beta.17
36
+
37
+ ## 0.9.0-beta.16
38
+
39
+ ### Minor Changes
40
+
41
+ - 0a4f131: Fix value types so they actually serialize correctly.
42
+ - 8e5e49a: Add optional link constraints
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [e5fe7c0]
47
+ - @osdk/api@2.1.0-beta.16
48
+
49
+ ## 0.9.0-beta.15
50
+
51
+ ### Patch Changes
52
+
53
+ - @osdk/api@2.1.0-beta.15
54
+
55
+ ## 0.9.0-beta.14
56
+
57
+ ### Minor Changes
58
+
59
+ - 91cfa3a: Fixing url parsing for client.
60
+ - 6b6c8a1: Updates gateway endpoints and changes fetchContents for attachments to return a response
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [0c56d21]
65
+ - Updated dependencies [6b6c8a1]
66
+ - @osdk/api@2.1.0-beta.14
67
+
68
+ ## 0.9.0-beta.13
69
+
70
+ ### Patch Changes
71
+
72
+ - @osdk/api@2.1.0-beta.13
73
+
74
+ ## 0.9.0-beta.12
75
+
76
+ ### Patch Changes
77
+
78
+ - @osdk/api@2.1.0-beta.12
79
+
80
+ ## 0.9.0-beta.11
81
+
82
+ ### Minor Changes
83
+
84
+ - bc1761c: Update platform API dependencies.
85
+ - caf1abc: Support generating linked products for marketplace
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [bc1761c]
90
+ - Updated dependencies [9298f75]
91
+ - @osdk/api@2.1.0-beta.11
92
+
93
+ ## 0.9.0-beta.10
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [11a05cc]
98
+ - Updated dependencies [11088aa]
99
+ - @osdk/api@2.1.0-beta.10
100
+
101
+ ## 0.9.0-beta.9
102
+
103
+ ### Patch Changes
104
+
105
+ - Updated dependencies [acbfab9]
106
+ - @osdk/api@2.1.0-beta.9
107
+
108
+ ## 0.9.0-beta.8
109
+
110
+ ### Minor Changes
111
+
112
+ - b8a1a58: Add nullability to markings because of course they need to be nullable. This sucks in the data model, I should talk to the ontology team about this.
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies [9f3807c]
117
+ - @osdk/api@2.1.0-beta.8
118
+
119
+ ## 0.9.0-beta.7
120
+
121
+ ### Minor Changes
122
+
123
+ - cd8d657: Support importing foreign SPTs
124
+ - 9018dc2: Updating platform api dependencies.
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [27866a8]
129
+ - Updated dependencies [31e7d70]
130
+ - @osdk/api@2.1.0-beta.7
131
+
132
+ ## 0.9.0-beta.6
133
+
134
+ ### Minor Changes
135
+
136
+ - 25fd9f0: Updating package.json to have better entry points to support react native bundlers.
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [25fd9f0]
141
+ - Updated dependencies [1a89f23]
142
+ - Updated dependencies [1b2e8c9]
143
+ - @osdk/api@2.1.0-beta.6
144
+
145
+ ## 0.9.0-beta.5
146
+
147
+ ### Minor Changes
148
+
149
+ - b0544d4: Add additional marking configuration
150
+ - 2b35ed4: Structs in maker package
151
+
152
+ ### Patch Changes
153
+
154
+ - @osdk/api@2.1.0-beta.5
155
+
156
+ ## 0.9.0-beta.4
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [0dc40b0]
161
+ - Updated dependencies [1dc0228]
162
+ - Updated dependencies [d3b3f35]
163
+ - @osdk/api@2.1.0-beta.4
164
+
165
+ ## 0.9.0-beta.3
166
+
167
+ ### Minor Changes
168
+
169
+ - 09eaf24: Update to latest platform sdks
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [05febf4]
174
+ - Updated dependencies [b79becf]
175
+ - @osdk/api@2.1.0-beta.3
176
+
3
177
  ## 0.9.0-beta.2
4
178
 
5
179
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ import type { PropertyTypeType, SharedPropertyType } from "./types.js";
2
+ /**
3
+ * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation
4
+ */
5
+ export declare function importSharedPropertyType(opts: {
6
+ apiName: string;
7
+ packageName?: string;
8
+ typeHint: PropertyTypeType;
9
+ }): SharedPropertyType;
10
+ //# sourceMappingURL=defineImportSpt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineImportSpt.d.ts","sourceRoot":"","sources":["../../../src/api/defineImportSpt.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GACA,kBAAkB,CAoBpB"}
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import invariant from "tiny-invariant";
17
+ import { ontologyDefinition } from "./defineOntology.js";
18
+ /**
19
+ * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation
20
+ */
21
+ export function importSharedPropertyType(opts) {
22
+ const {
23
+ apiName,
24
+ packageName,
25
+ typeHint
26
+ } = opts;
27
+ if (packageName !== undefined) {
28
+ ontologyDefinition.importedTypes.sharedPropertyTypes.push({
29
+ apiName,
30
+ packageName
31
+ });
32
+ !!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name format invalid ends with period") : invariant(false) : void 0;
33
+ !(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name includes upper case characters") : invariant(false) : void 0;
34
+ return {
35
+ apiName: packageName + "." + apiName,
36
+ type: typeHint
37
+ };
38
+ }
39
+ return {
40
+ apiName: apiName,
41
+ type: typeHint
42
+ };
43
+ }
44
+ //# sourceMappingURL=defineImportSpt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineImportSpt.js","names":["invariant","ontologyDefinition","importSharedPropertyType","opts","apiName","packageName","typeHint","undefined","importedTypes","sharedPropertyTypes","push","endsWith","process","env","NODE_ENV","match","type"],"sources":["defineImportSpt.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\";\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(opts) {\n const { apiName, packageName, typeHint } = opts;\n if (packageName !== undefined) {\n ontologyDefinition.importedTypes.sharedPropertyTypes.push({\n apiName,\n packageName,\n });\n invariant(!packageName.endsWith(\".\"), \"Package name format invalid ends with period\");\n invariant(packageName.match(\"[A-Z]\") == null, \"Package name includes upper case characters\");\n return { apiName: packageName + \".\" + apiName, type: typeHint };\n }\n return { apiName: apiName, type: typeHint };\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;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAACC,IAAI,EAAE;EAC3C,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,IAAI;EAC/C,IAAIE,WAAW,KAAKE,SAAS,EAAE;IAC3BN,kBAAkB,CAACO,aAAa,CAACC,mBAAmB,CAACC,IAAI,CAAC;MACtDN,OAAO;MACPC;IACJ,CAAC,CAAC;IACF,CAAU,CAACA,WAAW,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAApCd,SAAS,QAA6B,8CAA8C,IAApFA,SAAS;IACT,EAAUK,WAAW,CAACU,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAA5Cd,SAAS,QAAqC,6CAA6C,IAA3FA,SAAS;IACT,OAAO;MAAEI,OAAO,EAAEC,WAAW,GAAG,GAAG,GAAGD,OAAO;MAAEY,IAAI,EAAEV;IAAS,CAAC;EACnE;EACA,OAAO;IAAEF,OAAO,EAAEA,OAAO;IAAEY,IAAI,EAAEV;EAAS,CAAC;AAC/C","ignoreList":[]}
@@ -1,5 +1,14 @@
1
1
  import type { BlueprintIcon } from "./iconNames.js";
2
2
  import type { InterfaceType, PropertyTypeType, SharedPropertyType } from "./types.js";
3
+ type SimplifiedInterfaceTypeStatus = {
4
+ type: "deprecated";
5
+ message: string;
6
+ deadline: string;
7
+ } | {
8
+ type: "active";
9
+ } | {
10
+ type: "experimental";
11
+ };
3
12
  export declare function defineInterface(opts: {
4
13
  apiName: string;
5
14
  displayName?: string;
@@ -8,7 +17,9 @@ export declare function defineInterface(opts: {
8
17
  locator: BlueprintIcon;
9
18
  color: string;
10
19
  };
20
+ status?: SimplifiedInterfaceTypeStatus;
11
21
  properties?: Record<string, SharedPropertyType | PropertyTypeType>;
12
22
  extends?: InterfaceType | InterfaceType[] | string | string[];
13
23
  }): InterfaceType;
24
+ export {};
14
25
  //# sourceMappingURL=defineInterface.d.ts.map
@@ -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,EAEb,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,KAAK,6BAA6B,GAC9B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7B,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,MAAM,CAAC,EAAE,6BAA6B,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,kBAAkB,GAAG,gBAAgB,CACtC,CAAC;IAEF,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/D,GACA,aAAa,CA4Ff"}
@@ -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,11 @@ 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
+ const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(".") + 1);
34
+ !(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
34
35
  key: apiName,
35
36
  apiName: type.apiName
36
- })}`) : void 0;
37
+ })}`) : invariant(false) : void 0;
37
38
  return [apiName, type];
38
39
  }
39
40
  }));
@@ -49,6 +50,10 @@ export function defineInterface(opts) {
49
50
  extendsInterfaces = opts.extends.map(item => item.apiName);
50
51
  }
51
52
  }
53
+ const status = mapSimplifiedStatusToInterfaceTypeStatus(opts.status ?? {
54
+ type: "active"
55
+ });
56
+ !(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant(false, `Deprecated status must include message and deadline properties.`) : invariant(false) : void 0;
52
57
  const a = {
53
58
  apiName,
54
59
  displayMetadata: {
@@ -65,14 +70,36 @@ export function defineInterface(opts) {
65
70
  extendsInterfaces: extendsInterfaces,
66
71
  links: [],
67
72
  properties,
68
- status: {
69
- type: "active",
70
- active: {}
71
- }
73
+ status
72
74
  };
73
75
  return ontologyDefinition.interfaceTypes[apiName] = a;
74
76
  }
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";
77
+ function isPropertyTypeType(v) {
78
+ 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";
79
+ }
80
+ function mapSimplifiedStatusToInterfaceTypeStatus(status) {
81
+ switch (status.type) {
82
+ case "deprecated":
83
+ return {
84
+ type: "deprecated",
85
+ deprecated: {
86
+ message: status.message,
87
+ deadline: status.deadline,
88
+ replacedBy: undefined
89
+ }
90
+ };
91
+ case "active":
92
+ return {
93
+ type: "active",
94
+ active: {}
95
+ };
96
+ case "experimental":
97
+ return {
98
+ type: "experimental",
99
+ experimental: {}
100
+ };
101
+ default:
102
+ throw new Error(`Invalid status type: ${status.type}`);
103
+ }
77
104
  }
78
105
  //# 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;MACF,OAAO,CAACZ,OAAO,EAAEU,GAAG,CAAC;IACzB,CAAC,MACI;MACD,EAAUf,SAAS,GAAGK,OAAO,KAAKQ,IAAI,CAACR,OAAO,IAA9CN,SAAS,QAAuC,oDAAoDmB,IAAI,CAACC,SAAS,CAAC;QAAEC,GAAG,EAAEf,OAAO;QAAEA,OAAO,EAAEQ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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","unNamespacedTypeApiName","slice","lastIndexOf","JSON","stringify","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.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 const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(\".\") + 1);\n invariant(namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName, `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 status = mapSimplifiedStatusToInterfaceTypeStatus(opts.status ?? { type: \"active\" });\n invariant(status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline), `Deprecated status must include message and deadline properties.`);\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,\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}\nfunction mapSimplifiedStatusToInterfaceTypeStatus(status) {\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.type}`);\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,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,KA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EAAE,EAAE;IACTlC,UAAU;IACVsB;EACJ,CAAC;EACD,OAAOhC,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,GAAGiC,CAAC;AACzD;AACA,SAASrB,kBAAkBA,CAAC6B,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,CAAC9B,IAAI,KAAK,SAAU,IAC/C8B,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AAC5B;AACA,SAASZ,wCAAwCA,CAACD,MAAM,EAAE;EACtD,QAAQA,MAAM,CAACjB,IAAI;IACf,KAAK,YAAY;MACb,OAAO;QACHA,IAAI,EAAE,YAAY;QAClBmB,UAAU,EAAE;UACRC,OAAO,EAAEH,MAAM,CAACG,OAAO;UACvBC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;UACzBU,UAAU,EAAExC;QAChB;MACJ,CAAC;IACL,KAAK,QAAQ;MACT,OAAO;QACHS,IAAI,EAAE,QAAQ;QACdgC,MAAM,EAAE,CAAC;MACb,CAAC;IACL,KAAK,cAAc;MACf,OAAO;QACHhC,IAAI,EAAE,cAAc;QACpBiC,YAAY,EAAE,CAAC;MACnB,CAAC;IACL;MACI,MAAM,IAAIC,KAAK,CAAC,wBAAwBjB,MAAM,CAACjB,IAAI,EAAE,CAAC;EAC9D;AACJ","ignoreList":[]}
@@ -7,6 +7,7 @@ type Many = {
7
7
  toOne?: never;
8
8
  displayName?: string;
9
9
  description?: string;
10
+ required?: boolean;
10
11
  };
11
12
  type One = {
12
13
  apiName: string;
@@ -15,6 +16,7 @@ type One = {
15
16
  toMany?: never;
16
17
  displayName?: string;
17
18
  description?: string;
19
+ required?: boolean;
18
20
  };
19
21
  export declare function defineInterfaceLinkConstraint(linkDef: One | Many): void;
20
22
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterfaceLinkConstraint.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterfaceLinkConstraint.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,sBAAsB,GAAG,MAAM,GAAG,aAAa,CAAC;AAErD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,GAAG,GAAG,IAAI,QAgBpB"}
1
+ {"version":3,"file":"defineInterfaceLinkConstraint.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterfaceLinkConstraint.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,sBAAsB,GAAG,MAAM,GAAG,aAAa,CAAC;AAErD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,GAAG,GAAG,IAAI,QAgBpB"}
@@ -17,12 +17,12 @@ 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),
24
24
  metadata: fromLinkMeta,
25
- required: true // TODO: expose this?
25
+ required: linkDef.required ?? true
26
26
  });
27
27
  }
28
28
  function getLinkedType(t) {
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.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,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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: linkDef.required ?? true,\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,MA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,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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sources":["../../../src/api/defineObject.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AASrC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAIzB,CAAC,CAAC;CACJ;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACJ,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,cAAc,CAAC,QAAQ,CAC9B,CAAC;CACH,GACA,UAAU,CAiCZ"}
1
+ {"version":3,"file":"defineObject.d.ts","sourceRoot":"","sources":["../../../src/api/defineObject.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AASrC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAIzB,CAAC,CAAC;CACJ;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACJ,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,cAAc,CAAC,QAAQ,CAC9B,CAAC;CACH,GACA,UAAU,CAkCZ"}
@@ -32,7 +32,8 @@ export function defineObject(apiName, opts) {
32
32
  },
33
33
  properties: {
34
34
  [opts.primaryKey.apiName]: {
35
- dataType: convertType(opts.primaryKey)
35
+ dataType: convertType(opts.primaryKey),
36
+ rid: "rid"
36
37
  }
37
38
  },
38
39
  rid: "PLACEHOLDER",
@@ -72,15 +73,31 @@ function convertType(t) {
72
73
  },
73
74
  type: "timeseries"
74
75
  };
76
+ case t.type === "sensorTimeseries":
77
+ return {
78
+ type: "timeseries"
79
+ };
75
80
  case t.type === "datetime":
76
81
  return {
77
82
  type: "timestamp"
78
83
  };
84
+ case typeof t.type === "object":
85
+ {
86
+ return {
87
+ type: "struct",
88
+ structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({
89
+ apiName,
90
+ dataType: {
91
+ type: dataType
92
+ }
93
+ }))
94
+ };
95
+ }
79
96
  default:
80
97
  return {
81
98
  type: t.type
82
99
  };
83
100
  }
84
- invariant(false);
101
+ process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false);
85
102
  }
86
103
  //# 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,CAA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C,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","structFieldTypes","Object","entries","map","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 rid: \"rid\",\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 === \"sensorTimeseries\":\n return {\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n case typeof t.type === \"object\": {\n return {\n type: \"struct\",\n structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({\n apiName,\n dataType: { type: dataType },\n })),\n };\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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AQ,EAAE;cAAEF,IAAI,EAAEE;YAAS;UAC/B,CAAC,CAAC;QACN,CAAC;MACL;IACA;MACI,OAAO;QACHF,IAAI,EAAES,CAAC,CAACT;MACZ,CAAC;EACT;EACAiB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAnC,SAAS,UAATA,SAAS;AACb","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import type { OntologyIrOntologyBlockDataV2, OntologyIrValueTypeBlockData } from "@osdk/client.unstable";
1
+ import type { OntologyIr, OntologyIrValueTypeBlockData } from "@osdk/client.unstable";
2
2
  type OntologyAndValueTypeIrs = {
3
- ontology: OntologyIrOntologyBlockDataV2;
3
+ ontology: OntologyIr;
4
4
  valueType: OntologyIrValueTypeBlockData;
5
5
  };
6
6
  export declare function defineOntology(ns: string, body: () => void | Promise<void>): Promise<OntologyAndValueTypeIrs>;
7
- export declare function dumpOntologyFullMetadata(): OntologyIrOntologyBlockDataV2;
7
+ export declare function dumpOntologyFullMetadata(): OntologyIr;
8
8
  export declare function dumpValueTypeWireType(): OntologyIrValueTypeBlockData;
9
9
  export {};
10
10
  //# sourceMappingURL=defineOntology.d.ts.map
@@ -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,EACV,UAAU,EAOV,4BAA4B,EAE7B,MAAM,uBAAuB,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,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,CA6BlC;AAyED,wBAAgB,wBAAwB,IAAI,UAAU,CAErD;AAED,wBAAgB,qBAAqB,IAAI,4BAA4B,CAEpE"}