@osdk/maker 0.9.0-beta.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +304 -0
  2. package/build/browser/api/defineImportSpt.js +24 -2
  3. package/build/browser/api/defineImportSpt.js.map +1 -1
  4. package/build/browser/api/defineInterface.js +34 -6
  5. package/build/browser/api/defineInterface.js.map +1 -1
  6. package/build/browser/api/defineInterfaceLinkConstraint.js +2 -1
  7. package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
  8. package/build/browser/api/defineObject.js +57 -62
  9. package/build/browser/api/defineObject.js.map +1 -1
  10. package/build/browser/api/defineOntology.js +130 -14
  11. package/build/browser/api/defineOntology.js.map +1 -1
  12. package/build/browser/api/defineSpt.js +2 -0
  13. package/build/browser/api/defineSpt.js.map +1 -1
  14. package/build/browser/api/defineValueType.js +57 -10
  15. package/build/browser/api/defineValueType.js.map +1 -1
  16. package/build/browser/api/iconNames.js +0 -15
  17. package/build/browser/api/iconNames.js.map +1 -1
  18. package/build/browser/api/overall.test.js +461 -68
  19. package/build/browser/api/overall.test.js.map +1 -1
  20. package/build/browser/api/types.js +0 -15
  21. package/build/browser/api/types.js.map +1 -1
  22. package/build/browser/cli/main.js +3 -4
  23. package/build/browser/cli/main.js.map +1 -1
  24. package/build/browser/index.js +2 -0
  25. package/build/browser/index.js.map +1 -1
  26. package/build/cjs/index.cjs +716 -0
  27. package/build/cjs/index.cjs.map +1 -0
  28. package/build/cjs/index.d.cts +343 -0
  29. package/build/esm/api/defineImportSpt.js +24 -2
  30. package/build/esm/api/defineImportSpt.js.map +1 -1
  31. package/build/esm/api/defineInterface.js +34 -6
  32. package/build/esm/api/defineInterface.js.map +1 -1
  33. package/build/esm/api/defineInterfaceLinkConstraint.js +2 -1
  34. package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
  35. package/build/esm/api/defineObject.js +57 -62
  36. package/build/esm/api/defineObject.js.map +1 -1
  37. package/build/esm/api/defineOntology.js +130 -14
  38. package/build/esm/api/defineOntology.js.map +1 -1
  39. package/build/esm/api/defineSpt.js +2 -0
  40. package/build/esm/api/defineSpt.js.map +1 -1
  41. package/build/esm/api/defineValueType.js +57 -10
  42. package/build/esm/api/defineValueType.js.map +1 -1
  43. package/build/esm/api/iconNames.js +0 -15
  44. package/build/esm/api/iconNames.js.map +1 -1
  45. package/build/esm/api/overall.test.js +461 -68
  46. package/build/esm/api/overall.test.js.map +1 -1
  47. package/build/esm/api/types.js +0 -15
  48. package/build/esm/api/types.js.map +1 -1
  49. package/build/esm/cli/main.js +3 -4
  50. package/build/esm/cli/main.js.map +1 -1
  51. package/build/esm/index.js +2 -0
  52. package/build/esm/index.js.map +1 -1
  53. package/package.json +25 -12
  54. package/build/browser/api/defineImportSpt.d.ts +0 -10
  55. package/build/browser/api/defineImportSpt.d.ts.map +0 -1
  56. package/build/browser/api/defineInterface.d.ts +0 -14
  57. package/build/browser/api/defineInterface.d.ts.map +0 -1
  58. package/build/browser/api/defineInterfaceLinkConstraint.d.ts +0 -21
  59. package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +0 -1
  60. package/build/browser/api/defineLink.d.ts +0 -18
  61. package/build/browser/api/defineLink.d.ts.map +0 -1
  62. package/build/browser/api/defineLink.js +0 -37
  63. package/build/browser/api/defineLink.js.map +0 -1
  64. package/build/browser/api/defineObject.d.ts +0 -15
  65. package/build/browser/api/defineObject.d.ts.map +0 -1
  66. package/build/browser/api/defineOntology.d.ts +0 -10
  67. package/build/browser/api/defineOntology.d.ts.map +0 -1
  68. package/build/browser/api/defineSpt.d.ts +0 -13
  69. package/build/browser/api/defineSpt.d.ts.map +0 -1
  70. package/build/browser/api/defineValueType.d.ts +0 -26
  71. package/build/browser/api/defineValueType.d.ts.map +0 -1
  72. package/build/browser/api/iconNames.d.ts +0 -3
  73. package/build/browser/api/iconNames.d.ts.map +0 -1
  74. package/build/browser/api/overall.test.d.ts +0 -2
  75. package/build/browser/api/overall.test.d.ts.map +0 -1
  76. package/build/browser/api/types.d.ts +0 -52
  77. package/build/browser/api/types.d.ts.map +0 -1
  78. package/build/browser/cli/main.d.ts +0 -2
  79. package/build/browser/cli/main.d.ts.map +0 -1
  80. package/build/browser/index.d.ts +0 -7
  81. package/build/browser/index.d.ts.map +0 -1
  82. package/build/esm/api/defineImportSpt.d.ts +0 -10
  83. package/build/esm/api/defineImportSpt.d.ts.map +0 -1
  84. package/build/esm/api/defineInterface.d.ts +0 -14
  85. package/build/esm/api/defineInterface.d.ts.map +0 -1
  86. package/build/esm/api/defineInterfaceLinkConstraint.d.ts +0 -21
  87. package/build/esm/api/defineInterfaceLinkConstraint.d.ts.map +0 -1
  88. package/build/esm/api/defineLink.d.ts +0 -18
  89. package/build/esm/api/defineLink.d.ts.map +0 -1
  90. package/build/esm/api/defineLink.js +0 -37
  91. package/build/esm/api/defineLink.js.map +0 -1
  92. package/build/esm/api/defineObject.d.ts +0 -15
  93. package/build/esm/api/defineObject.d.ts.map +0 -1
  94. package/build/esm/api/defineOntology.d.ts +0 -10
  95. package/build/esm/api/defineOntology.d.ts.map +0 -1
  96. package/build/esm/api/defineSpt.d.ts +0 -13
  97. package/build/esm/api/defineSpt.d.ts.map +0 -1
  98. package/build/esm/api/defineValueType.d.ts +0 -26
  99. package/build/esm/api/defineValueType.d.ts.map +0 -1
  100. package/build/esm/api/iconNames.d.ts +0 -3
  101. package/build/esm/api/iconNames.d.ts.map +0 -1
  102. package/build/esm/api/overall.test.d.ts +0 -2
  103. package/build/esm/api/overall.test.d.ts.map +0 -1
  104. package/build/esm/api/types.d.ts +0 -52
  105. package/build/esm/api/types.d.ts.map +0 -1
  106. package/build/esm/cli/main.d.ts +0 -2
  107. package/build/esm/cli/main.d.ts.map +0 -1
  108. package/build/esm/index.d.ts +0 -7
  109. package/build/esm/index.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,309 @@
1
1
  # @osdk/maker
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 25fd9f0: Updating package.json to have better entry points to support react native bundlers.
8
+ - f0b519d: Upgrade to vitest 3 and vite 6
9
+ - 1812118: Add geotime support for OSDK.
10
+ - bc1761c: Update platform API dependencies.
11
+ - bb8b219: Use new external packages instead of the internal ones.
12
+ - 44e62f6: Updating fetch for auth and other packages.
13
+ - 91cfa3a: Fixing url parsing for client.
14
+ - c9e855d: Allowing interfaces to extend other interfaces for ontology as code.
15
+ - 94463b6: Support objects as code
16
+ - 9d35a1f: Remove unused imports
17
+ - 8d8bebb: Fix nullability
18
+ - 7a95618: Generate new OMS APIs
19
+ - c9da74c: Improves code quality by fixing linting errors
20
+ - abfe4b3: Add support for reading struct properties.
21
+ - caf1abc: Support generating linked products for marketplace
22
+ - cd8d657: Support importing foreign SPTs
23
+ - 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.
24
+ - b0544d4: Add additional marking configuration
25
+ - 9018dc2: Updating platform api dependencies.
26
+ - f569124: Add media reference to maker
27
+ - 0a4f131: Fix value types so they actually serialize correctly.
28
+ - 8e5e49a: Add optional link constraints
29
+ - 6b6c8a1: Updates gateway endpoints and changes fetchContents for attachments to return a response
30
+ - 2b35ed4: Structs in maker package
31
+ - 09eaf24: Update to latest platform sdks
32
+ - 06e66dc: Making interface type status configurable
33
+ - d665147: Update platform sdk deps
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [966d408]
38
+ - Updated dependencies [cddc196]
39
+ - Updated dependencies [d794c19]
40
+ - Updated dependencies [05febf4]
41
+ - Updated dependencies [55c05f2]
42
+ - Updated dependencies [0dc40b0]
43
+ - Updated dependencies [25fd9f0]
44
+ - Updated dependencies [11a05cc]
45
+ - Updated dependencies [7865cb6]
46
+ - Updated dependencies [9c4efe6]
47
+ - Updated dependencies [3ea2e79]
48
+ - Updated dependencies [1812118]
49
+ - Updated dependencies [bc1761c]
50
+ - Updated dependencies [656f975]
51
+ - Updated dependencies [f1145ff]
52
+ - Updated dependencies [f446d0c]
53
+ - Updated dependencies [c80ca45]
54
+ - Updated dependencies [bb8b219]
55
+ - Updated dependencies [03f95eb]
56
+ - Updated dependencies [1a89f23]
57
+ - Updated dependencies [9d35a1f]
58
+ - Updated dependencies [c691c8b]
59
+ - Updated dependencies [749cf69]
60
+ - Updated dependencies [f03e39f]
61
+ - Updated dependencies [11088aa]
62
+ - Updated dependencies [72c1905]
63
+ - Updated dependencies [9298f75]
64
+ - Updated dependencies [f34b3d4]
65
+ - Updated dependencies [acbfab9]
66
+ - Updated dependencies [62c1d63]
67
+ - Updated dependencies [3c9ac22]
68
+ - Updated dependencies [1591f04]
69
+ - Updated dependencies [03e1941]
70
+ - Updated dependencies [abfe4b3]
71
+ - Updated dependencies [b79becf]
72
+ - Updated dependencies [27866a8]
73
+ - Updated dependencies [e5fe7c0]
74
+ - Updated dependencies [1b2e8c9]
75
+ - Updated dependencies [9f3807c]
76
+ - Updated dependencies [0c56d21]
77
+ - Updated dependencies [e548b9b]
78
+ - Updated dependencies [ee6224b]
79
+ - Updated dependencies [1dc0228]
80
+ - Updated dependencies [6c60414]
81
+ - Updated dependencies [5fe2c8d]
82
+ - Updated dependencies [d3b3f35]
83
+ - Updated dependencies [785f663]
84
+ - Updated dependencies [6b6c8a1]
85
+ - Updated dependencies [c537e2d]
86
+ - Updated dependencies [73fa373]
87
+ - Updated dependencies [8e6a5f4]
88
+ - Updated dependencies [2d5e648]
89
+ - Updated dependencies [31e7d70]
90
+ - Updated dependencies [f19da8e]
91
+ - @osdk/api@2.1.0
92
+
93
+ ## 0.9.0-rc.32
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [55c05f2]
98
+ - @osdk/api@2.1.0-rc.32
99
+
100
+ ## 0.9.0-beta.31
101
+
102
+ ### Minor Changes
103
+
104
+ - bb8b219: Use new external packages instead of the internal ones.
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [bb8b219]
109
+ - Updated dependencies [ee6224b]
110
+ - Updated dependencies [5fe2c8d]
111
+ - @osdk/api@2.1.0-beta.31
112
+
113
+ ## 0.9.0-beta.30
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [966d408]
118
+ - Updated dependencies [f03e39f]
119
+ - Updated dependencies [1591f04]
120
+ - Updated dependencies [785f663]
121
+ - Updated dependencies [2d5e648]
122
+ - @osdk/api@2.1.0-beta.30
123
+
124
+ ## 0.9.0-beta.29
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [f1145ff]
129
+ - @osdk/api@2.1.0-beta.29
130
+
131
+ ## 0.9.0-beta.28
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [f446d0c]
136
+ - @osdk/api@2.1.0-beta.28
137
+
138
+ ## 0.9.0-beta.27
139
+
140
+ ### Patch Changes
141
+
142
+ - @osdk/api@2.1.0-beta.27
143
+
144
+ ## 0.9.0-beta.26
145
+
146
+ ### Minor Changes
147
+
148
+ - 44e62f6: Updating fetch for auth and other packages.
149
+ - 94463b6: Support objects as code
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [7865cb6]
154
+ - Updated dependencies [9c4efe6]
155
+ - Updated dependencies [f19da8e]
156
+ - @osdk/api@2.1.0-beta.26
157
+
158
+ ## 0.9.0-beta.25
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [c80ca45]
163
+ - @osdk/api@2.1.0-beta.25
164
+
165
+ ## 0.9.0-beta.24
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies [03f95eb]
170
+ - Updated dependencies [c691c8b]
171
+ - Updated dependencies [3c9ac22]
172
+ - @osdk/api@2.1.0-beta.24
173
+
174
+ ## 0.9.0-beta.23
175
+
176
+ ### Minor Changes
177
+
178
+ - f0b519d: Upgrade to vitest 3 and vite 6
179
+ - 7a95618: Generate new OMS APIs
180
+ - d665147: Update platform sdk deps
181
+
182
+ ### Patch Changes
183
+
184
+ - Updated dependencies [d794c19]
185
+ - Updated dependencies [62c1d63]
186
+ - @osdk/api@2.1.0-beta.23
187
+
188
+ ## 0.9.0-beta.22
189
+
190
+ ### Minor Changes
191
+
192
+ - 8d8bebb: Fix nullability
193
+ - c9da74c: Improves code quality by fixing linting errors
194
+
195
+ ### Patch Changes
196
+
197
+ - Updated dependencies [73fa373]
198
+ - @osdk/api@2.1.0-beta.22
199
+
200
+ ## 0.9.0-beta.21
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies [3ea2e79]
205
+ - Updated dependencies [656f975]
206
+ - Updated dependencies [f34b3d4]
207
+ - @osdk/api@2.1.0-beta.21
208
+
209
+ ## 0.9.0-beta.20
210
+
211
+ ### Minor Changes
212
+
213
+ - 9d35a1f: Remove unused imports
214
+ - abfe4b3: Add support for reading struct properties.
215
+ - 06e66dc: Making interface type status configurable
216
+
217
+ ### Patch Changes
218
+
219
+ - Updated dependencies [9d35a1f]
220
+ - Updated dependencies [abfe4b3]
221
+ - Updated dependencies [c537e2d]
222
+ - @osdk/api@2.1.0-beta.20
223
+
224
+ ## 0.9.0-beta.19
225
+
226
+ ### Patch Changes
227
+
228
+ - Updated dependencies [cddc196]
229
+ - @osdk/api@2.1.0-beta.19
230
+
231
+ ## 0.9.0-beta.18
232
+
233
+ ### Patch Changes
234
+
235
+ - @osdk/api@2.1.0-beta.18
236
+
237
+ ## 0.9.0-beta.17
238
+
239
+ ### Patch Changes
240
+
241
+ - @osdk/api@2.1.0-beta.17
242
+
243
+ ## 0.9.0-beta.16
244
+
245
+ ### Minor Changes
246
+
247
+ - 0a4f131: Fix value types so they actually serialize correctly.
248
+ - 8e5e49a: Add optional link constraints
249
+
250
+ ### Patch Changes
251
+
252
+ - Updated dependencies [e5fe7c0]
253
+ - @osdk/api@2.1.0-beta.16
254
+
255
+ ## 0.9.0-beta.15
256
+
257
+ ### Patch Changes
258
+
259
+ - @osdk/api@2.1.0-beta.15
260
+
261
+ ## 0.9.0-beta.14
262
+
263
+ ### Minor Changes
264
+
265
+ - 91cfa3a: Fixing url parsing for client.
266
+ - 6b6c8a1: Updates gateway endpoints and changes fetchContents for attachments to return a response
267
+
268
+ ### Patch Changes
269
+
270
+ - Updated dependencies [0c56d21]
271
+ - Updated dependencies [6b6c8a1]
272
+ - @osdk/api@2.1.0-beta.14
273
+
274
+ ## 0.9.0-beta.13
275
+
276
+ ### Patch Changes
277
+
278
+ - @osdk/api@2.1.0-beta.13
279
+
280
+ ## 0.9.0-beta.12
281
+
282
+ ### Patch Changes
283
+
284
+ - @osdk/api@2.1.0-beta.12
285
+
286
+ ## 0.9.0-beta.11
287
+
288
+ ### Minor Changes
289
+
290
+ - bc1761c: Update platform API dependencies.
291
+ - caf1abc: Support generating linked products for marketplace
292
+
293
+ ### Patch Changes
294
+
295
+ - Updated dependencies [bc1761c]
296
+ - Updated dependencies [9298f75]
297
+ - @osdk/api@2.1.0-beta.11
298
+
299
+ ## 0.9.0-beta.10
300
+
301
+ ### Patch Changes
302
+
303
+ - Updated dependencies [11a05cc]
304
+ - Updated dependencies [11088aa]
305
+ - @osdk/api@2.1.0-beta.10
306
+
3
307
  ## 0.9.0-beta.9
4
308
 
5
309
  ### Patch Changes
@@ -13,13 +13,35 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
17
+ import invariant from "tiny-invariant";
18
+ import { ontologyDefinition } from "./defineOntology.js";
16
19
  /**
17
20
  * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation
18
21
  */
19
22
  export function importSharedPropertyType(opts) {
23
+ const {
24
+ apiName,
25
+ packageName,
26
+ typeHint
27
+ } = opts;
28
+ if (packageName !== undefined) {
29
+ ontologyDefinition.importedTypes.sharedPropertyTypes.push({
30
+ apiName,
31
+ packageName
32
+ });
33
+ !!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name format invalid ends with period") : invariant(false) : void 0;
34
+ !(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name includes upper case characters") : invariant(false) : void 0;
35
+ return {
36
+ apiName: packageName + "." + apiName,
37
+ type: typeHint,
38
+ nonNameSpacedApiName: apiName
39
+ };
40
+ }
20
41
  return {
21
- apiName: opts.apiName,
22
- type: opts.typeHint
42
+ apiName: apiName,
43
+ type: typeHint,
44
+ nonNameSpacedApiName: apiName
23
45
  };
24
46
  }
25
47
  //# sourceMappingURL=defineImportSpt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineImportSpt.js","names":["importSharedPropertyType","opts","apiName","type","typeHint"],"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 */\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 return { apiName: opts.apiName, type: opts.typeHint };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAwBA,CAACC,IAAI,EAAE;EAC3C,OAAO;IAAEC,OAAO,EAAED,IAAI,CAACC,OAAO;IAAEC,IAAI,EAAEF,IAAI,CAACG;EAAS,CAAC;AACzD","ignoreList":[]}
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","nonNameSpacedApiName"],"sources":["defineImportSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nimport type { PropertyTypeType, SharedPropertyType } from \"./types.js\";\n\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(\n opts: {\n apiName: string;\n packageName?: string;\n typeHint: PropertyTypeType;\n },\n): SharedPropertyType {\n const { apiName, packageName, typeHint } = opts;\n if (packageName !== undefined) {\n ontologyDefinition.importedTypes.sharedPropertyTypes.push({\n apiName,\n packageName,\n });\n invariant(\n !packageName.endsWith(\".\"),\n \"Package name format invalid ends with period\",\n );\n\n invariant(\n packageName.match(\"[A-Z]\") == null,\n \"Package name includes upper case characters\",\n );\n\n return {\n apiName: packageName + \".\" + apiName,\n type: typeHint,\n nonNameSpacedApiName: apiName,\n };\n }\n return { apiName: apiName, type: typeHint, nonNameSpacedApiName: apiName };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AAGxD;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAIC,EACmB;EACpB,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,IAAI;EAC/C,IAAIE,WAAW,KAAKE,SAAS,EAAE;IAC7BN,kBAAkB,CAACO,aAAa,CAACC,mBAAmB,CAACC,IAAI,CAAC;MACxDN,OAAO;MACPC;IACF,CAAC,CAAC;IACF,CACE,CAACA,WAAW,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD5Bd,SAAS,QAEP,8CAA8C,IAFhDA,SAAS;IAKT,EACEK,WAAW,CAACU,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADpCd,SAAS,QAEP,6CAA6C,IAF/CA,SAAS;IAKT,OAAO;MACLI,OAAO,EAAEC,WAAW,GAAG,GAAG,GAAGD,OAAO;MACpCY,IAAI,EAAEV,QAAQ;MACdW,oBAAoB,EAAEb;IACxB,CAAC;EACH;EACA,OAAO;IAAEA,OAAO,EAAEA,OAAO;IAAEY,IAAI,EAAEV,QAAQ;IAAEW,oBAAoB,EAAEb;EAAQ,CAAC;AAC5E","ignoreList":[]}
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
16
17
  import invariant from "tiny-invariant";
17
18
  import { namespace, ontologyDefinition } from "./defineOntology.js";
18
19
  import { defineSharedPropertyType } from "./defineSpt.js";
@@ -21,7 +22,7 @@ export function defineInterface(opts) {
21
22
  !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
22
23
  const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {
23
24
  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
+ !isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
25
26
  const spt = defineSharedPropertyType({
26
27
  apiName,
27
28
  displayName: apiName,
@@ -30,7 +31,8 @@ export function defineInterface(opts) {
30
31
  });
31
32
  return [apiName, spt];
32
33
  } else {
33
- !(namespace + apiName === type.apiName || apiName === type.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
34
+ const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(".") + 1);
35
+ !(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
36
  key: apiName,
35
37
  apiName: type.apiName
36
38
  })}`) : invariant(false) : void 0;
@@ -49,6 +51,10 @@ export function defineInterface(opts) {
49
51
  extendsInterfaces = opts.extends.map(item => item.apiName);
50
52
  }
51
53
  }
54
+ const status = mapSimplifiedStatusToInterfaceTypeStatus(opts.status ?? {
55
+ type: "active"
56
+ });
57
+ !(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
58
  const a = {
53
59
  apiName,
54
60
  displayMetadata: {
@@ -65,14 +71,36 @@ export function defineInterface(opts) {
65
71
  extendsInterfaces: extendsInterfaces,
66
72
  links: [],
67
73
  properties,
68
- status: {
69
- type: "active",
70
- active: {}
71
- }
74
+ status
72
75
  };
73
76
  return ontologyDefinition.interfaceTypes[apiName] = a;
74
77
  }
75
78
  function isPropertyTypeType(v) {
76
79
  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
80
  }
81
+ function mapSimplifiedStatusToInterfaceTypeStatus(status) {
82
+ switch (status.type) {
83
+ case "deprecated":
84
+ return {
85
+ type: "deprecated",
86
+ deprecated: {
87
+ message: status.message,
88
+ deadline: status.deadline,
89
+ replacedBy: undefined
90
+ }
91
+ };
92
+ case "active":
93
+ return {
94
+ type: "active",
95
+ active: {}
96
+ };
97
+ case "experimental":
98
+ return {
99
+ type: "experimental",
100
+ experimental: {}
101
+ };
102
+ default:
103
+ throw new Error(`Invalid status type: ${status.type}`);
104
+ }
105
+ }
78
106
  //# sourceMappingURL=defineInterface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","spt","displayName","array","JSON","stringify","key","extendsInterfaces","extends","Array","isArray","every","item","a","displayMetadata","description","icon","blueprint","color","locator","links","status","active","v"],"sources":["defineInterface.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.interfaceTypes[apiName] === undefined, `Interface ${apiName} already exists`);\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))) {\n invariant(isPropertyTypeType(type), `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`);\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n }\n else {\n invariant(namespace + apiName === type.apiName || apiName === type.apiName, `property key and it's apiName must be identical. ${JSON.stringify({ key: apiName, apiName: type.apiName })}`);\n return [apiName, type];\n }\n }));\n let extendsInterfaces = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n }\n else if (Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")) {\n extendsInterfaces = opts.extends;\n }\n else if (opts.extends.apiName !== undefined) {\n extendsInterfaces = [opts.extends.apiName];\n }\n else {\n extendsInterfaces = opts.extends.map(item => item.apiName);\n }\n }\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status: { type: \"active\", active: {} },\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isPropertyTypeType(v) {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EAAUJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAAC,OAAA,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,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":[]}
1
+ {"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","JSON","stringify","spt","displayName","array","unNamespacedTypeApiName","slice","lastIndexOf","key","extendsInterfaces","extends","Array","isArray","every","item","status","mapSimplifiedStatusToInterfaceTypeStatus","deprecated","message","deadline","a","displayMetadata","description","icon","blueprint","color","locator","links","v","replacedBy","active","experimental","Error"],"sources":["defineInterface.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nimport type { BlueprintIcon } from \"./iconNames.js\";\nimport type {\n InterfaceType,\n InterfaceTypeStatus,\n PropertyTypeType,\n SharedPropertyType,\n} from \"./types.js\";\n\ntype SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" };\n\nexport function defineInterface(\n opts: {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n SharedPropertyType | PropertyTypeType\n >;\n\n extends?: InterfaceType | InterfaceType[] | string | string[];\n },\n): InterfaceType {\n const apiName = namespace + opts.apiName;\n invariant(\n ontologyDefinition.interfaceTypes[apiName] === undefined,\n `Interface ${apiName} already exists`,\n );\n\n const properties = Object.fromEntries(\n Object.entries(opts.properties ?? {}).map<\n [string, SharedPropertyType]\n >(\n ([apiName, type]) => {\n if (\n typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))\n ) {\n invariant(\n isPropertyTypeType(type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n } else {\n const unNamespacedTypeApiName = type.apiName.slice(\n type.apiName.lastIndexOf(\".\") + 1,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return [apiName, type];\n }\n },\n ),\n );\n\n let extendsInterfaces: string[] = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n } else if (\n Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")\n ) {\n extendsInterfaces = opts.extends;\n } else if ((opts.extends as InterfaceType).apiName !== undefined) {\n extendsInterfaces = [(opts.extends as InterfaceType).apiName];\n } else {\n extendsInterfaces = (opts.extends as InterfaceType[]).map(item =>\n item.apiName\n );\n }\n }\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n opts.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const a: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status,\n };\n\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\n\nfunction isPropertyTypeType(\n v: PropertyTypeType,\n): v is PropertyTypeType {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n\nfunction mapSimplifiedStatusToInterfaceTypeStatus(\n status: SimplifiedInterfaceTypeStatus,\n): InterfaceTypeStatus {\n switch (status.type) {\n case \"deprecated\":\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: undefined,\n },\n };\n case \"active\":\n return {\n type: \"active\",\n active: {},\n };\n case \"experimental\":\n return {\n type: \"experimental\",\n experimental: {},\n };\n default:\n throw new Error(`Invalid status type: ${(status as any).type}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,SAASC,wBAAwB,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EAAEH,MAAM,CAACG,OAAO;UACvBC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;UACzBU,UAAU,EAAExC;QACd;MACF,CAAC;IACH,KAAK,QAAQ;MACX,OAAO;QACLS,IAAI,EAAE,QAAQ;QACdgC,MAAM,EAAE,CAAC;MACX,CAAC;IACH,KAAK,cAAc;MACjB,OAAO;QACLhC,IAAI,EAAE,cAAc;QACpBiC,YAAY,EAAE,CAAC;MACjB,CAAC;IACH;MACE,MAAM,IAAIC,KAAK,CAAC,wBAAyBjB,MAAM,CAASjB,IAAI,EAAE,CAAC;EACnE;AACF","ignoreList":[]}
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
16
17
  import invariant from "tiny-invariant";
17
18
  import { namespace } from "./defineOntology.js";
18
19
  export function defineInterfaceLinkConstraint(linkDef) {
@@ -22,7 +23,7 @@ export function defineInterfaceLinkConstraint(linkDef) {
22
23
  cardinality: linkDef.toMany ? "MANY" : "SINGLE",
23
24
  linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
24
25
  metadata: fromLinkMeta,
25
- required: true // TODO: expose this?
26
+ required: linkDef.required ?? true
26
27
  });
27
28
  }
28
29
  function getLinkedType(t) {
@@ -1 +1 @@
1
- {"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","process","env","NODE_ENV","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.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":[]}
1
+ {"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","process","env","NODE_ENV","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nimport type { InterfaceType } from \"./types.js\";\n\ntype Meta = { apiName: string; displayName?: string; description?: string };\ntype ApiNameOrInterfaceType = string | InterfaceType;\n\ntype Many = {\n apiName: string;\n from: InterfaceType;\n toMany: ApiNameOrInterfaceType;\n toOne?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\ntype One = {\n apiName: string;\n from: InterfaceType;\n toOne: ApiNameOrInterfaceType;\n toMany?: never;\n displayName?: string;\n description?: string;\n required?: boolean;\n};\n\nexport function defineInterfaceLinkConstraint(\n linkDef: One | Many,\n): void {\n const fromLinkMeta = getLinkMeta(linkDef);\n\n invariant(\n linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null,\n `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`,\n );\n\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: linkDef.required ?? true,\n });\n}\n\nfunction getLinkedType(t: string | InterfaceType) {\n return {\n type: \"interfaceType\" as const,\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\n\nfunction getLinkMeta(meta: One | Many) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\n\nfunction withDefaults(\n { apiName, description, displayName }: Meta,\n): Required<Meta> {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName,\n };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A,CACnB;EAAEf,OAAO;EAAEgB,WAAW;EAAEC;AAAkB,CAAC,EAC3B;EAChB,OAAO;IACLjB,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5BiB,WAAW,EAAEA,WAAW,IAAIjB,OAAO;IACnCgB,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAIjB;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -13,74 +13,69 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+
16
17
  import invariant from "tiny-invariant";
17
- import { ontologyDefinition } from "./defineOntology.js";
18
- export function defineObject(apiName, opts) {
18
+ import { namespace, ontologyDefinition } from "./defineOntology.js";
19
+ export function defineObject(objectDef) {
20
+ const apiName = namespace + objectDef.apiName;
21
+ const propertyApiNames = (objectDef.properties ?? []).map(val => val.apiName);
22
+ if (ontologyDefinition.objectTypes[apiName] !== undefined) {
23
+ throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
24
+ }
25
+ !propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant(false) : void 0;
26
+ !(objectDef.primaryKeys.length !== 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `${objectDef.apiName} does not have any primary keys, objects must have at least one primary key`) : invariant(false) : void 0;
27
+ const nonExistentPrimaryKeys = objectDef.primaryKeys.filter(primaryKey => !objectDef.properties?.map(val => val.apiName).includes(primaryKey));
28
+ !(nonExistentPrimaryKeys.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key properties ${nonExistentPrimaryKeys} do not exist on object ${objectDef.apiName}`) : invariant(false) : void 0;
29
+ objectDef.implementsInterfaces?.forEach(interfaceImpl => {
30
+ const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map(val => val.interfaceProperty).filter(interfaceProperty => interfaceImpl.implements.properties[interfaceProperty] === undefined).map(interfaceProp => ({
31
+ type: "invalid",
32
+ reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp} referenced in ${objectDef.apiName} object does not exist`
33
+ }));
34
+ const interfaceToObjectProperties = Object.fromEntries(interfaceImpl.propertyMapping.map(mapping => [mapping.interfaceProperty, mapping.mapsTo]));
35
+ const validateProperty = interfaceProp => {
36
+ if (interfaceProp[1].nonNameSpacedApiName in interfaceToObjectProperties) {
37
+ return validateInterfaceImplProperty(interfaceProp[1], interfaceToObjectProperties[interfaceProp[0]], objectDef);
38
+ }
39
+ return {
40
+ type: "invalid",
41
+ reason: `Interface property ${interfaceImpl.implements.apiName}.${interfaceProp[1].nonNameSpacedApiName} not implemented by ${objectDef.apiName} object definition`
42
+ };
43
+ };
44
+ const baseValidations = Object.entries(interfaceImpl.implements.properties).map(validateProperty);
45
+ const extendsValidations = interfaceImpl.implements.extendsInterfaces.flatMap(interfaceApiName => Object.entries(ontologyDefinition.interfaceTypes[interfaceApiName].properties).map(validateProperty));
46
+ const allFailedValidations = baseValidations.concat(extendsValidations, nonExistentInterfaceProperties).filter(val => val.type === "invalid");
47
+ !(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant(false) : void 0;
48
+ });
19
49
  ontologyDefinition.objectTypes[apiName] = {
20
- implementsInterfaces: [],
21
- implementsInterfaces2: {},
22
- linkTypes: [],
23
- objectType: {
24
- apiName,
25
- primaryKey: opts.primaryKey.apiName,
26
- displayName: opts.displayName ?? apiName,
27
- pluralDisplayName: opts.pluralDisplayName ?? apiName,
28
- icon: {
29
- color: "blue",
30
- name: "cube",
31
- type: "blueprint"
32
- },
33
- properties: {
34
- [opts.primaryKey.apiName]: {
35
- dataType: convertType(opts.primaryKey)
36
- }
37
- },
38
- rid: "PLACEHOLDER",
39
- status: "ACTIVE",
40
- titleProperty: opts.primaryKey.apiName
41
- },
42
- sharedPropertyTypeMapping: {}
50
+ ...objectDef,
51
+ apiName: apiName
43
52
  };
44
- // FIXME: don't return the raw value
45
53
  return {
46
- data: ontologyDefinition.objectTypes[apiName],
47
- linkTypes: {}
54
+ ...objectDef,
55
+ apiName: apiName
48
56
  };
49
57
  }
50
- function convertType(t) {
51
- switch (true) {
52
- case t.multiplicity === true:
53
- return {
54
- type: "array",
55
- subType: convertType({
56
- ...t,
57
- multiplicity: false
58
- })
59
- };
60
- case t.type === "stringTimeseries":
61
- return {
62
- itemType: {
63
- type: "string"
64
- },
65
- type: "timeseries"
66
- };
67
- break;
68
- case t.type === "numericTimeseries":
69
- return {
70
- itemType: {
71
- type: "double"
72
- },
73
- type: "timeseries"
74
- };
75
- case t.type === "datetime":
76
- return {
77
- type: "timestamp"
78
- };
79
- default:
80
- return {
81
- type: t.type
82
- };
58
+ function formatValidationErrors(error) {
59
+ return `Ontology Definition Error: ${error.reason}\n`;
60
+ }
61
+
62
+ // Validate that the object and the interface property match up
63
+ function validateInterfaceImplProperty(spt, mappedObjectProp, object) {
64
+ const objProp = object.properties?.find(prop => prop.apiName === mappedObjectProp);
65
+ if (objProp === undefined) {
66
+ return {
67
+ type: "invalid",
68
+ reason: `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`
69
+ };
70
+ }
71
+ if (spt.type !== objProp?.type) {
72
+ return {
73
+ type: "invalid",
74
+ reason: `Object property type does not match the interface property it is mapped to. Interface Property: ${spt.apiName}, objectProperty: ${mappedObjectProp}`
75
+ };
83
76
  }
84
- process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false);
77
+ return {
78
+ type: "valid"
79
+ };
85
80
  }
86
81
  //# sourceMappingURL=defineObject.js.map