@osdk/maker 0.14.0-beta.3 → 0.14.0-beta.4

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 (120) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/browser/api/defineAction.js +121 -413
  3. package/build/browser/api/defineAction.js.map +1 -1
  4. package/build/browser/api/defineCreateInterfaceObjectAction.js +69 -0
  5. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
  6. package/build/browser/api/defineCreateObjectAction.js +76 -0
  7. package/build/browser/api/defineCreateObjectAction.js.map +1 -0
  8. package/build/browser/api/defineCreateOrModifyObjectAction.js +92 -0
  9. package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
  10. package/build/browser/api/defineDeleteObjectAction.js +56 -0
  11. package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
  12. package/build/browser/api/defineModifyInterfaceObjectAction.js +68 -0
  13. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
  14. package/build/browser/api/defineModifyObjectAction.js +91 -0
  15. package/build/browser/api/defineModifyObjectAction.js.map +1 -0
  16. package/build/browser/api/test/actions.test.js +12014 -0
  17. package/build/browser/api/test/actions.test.js.map +1 -0
  18. package/build/browser/api/test/interfaces.test.js +924 -0
  19. package/build/browser/api/test/interfaces.test.js.map +1 -0
  20. package/build/browser/api/test/links.test.js +1974 -0
  21. package/build/browser/api/test/links.test.js.map +1 -0
  22. package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  23. package/build/browser/api/test/markingconstraint.test.js.map +1 -0
  24. package/build/browser/api/test/misc.test.js +1058 -0
  25. package/build/browser/api/test/misc.test.js.map +1 -0
  26. package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  27. package/build/browser/api/test/objectStatus.test.js.map +1 -0
  28. package/build/browser/api/test/objects.test.js +1494 -0
  29. package/build/browser/api/test/objects.test.js.map +1 -0
  30. package/build/browser/api/test/spt.test.js +387 -0
  31. package/build/browser/api/test/spt.test.js.map +1 -0
  32. package/build/browser/api/test/valueTypes.test.js +156 -0
  33. package/build/browser/api/test/valueTypes.test.js.map +1 -0
  34. package/build/browser/cli/main.js +1 -1
  35. package/build/browser/index.js +7 -1
  36. package/build/browser/index.js.map +1 -1
  37. package/build/cjs/index.cjs +561 -503
  38. package/build/cjs/index.cjs.map +1 -1
  39. package/build/cjs/index.d.cts +27 -13
  40. package/build/esm/api/defineAction.js +121 -413
  41. package/build/esm/api/defineAction.js.map +1 -1
  42. package/build/esm/api/defineCreateInterfaceObjectAction.js +69 -0
  43. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
  44. package/build/esm/api/defineCreateObjectAction.js +76 -0
  45. package/build/esm/api/defineCreateObjectAction.js.map +1 -0
  46. package/build/esm/api/defineCreateOrModifyObjectAction.js +92 -0
  47. package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
  48. package/build/esm/api/defineDeleteObjectAction.js +56 -0
  49. package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
  50. package/build/esm/api/defineModifyInterfaceObjectAction.js +68 -0
  51. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
  52. package/build/esm/api/defineModifyObjectAction.js +91 -0
  53. package/build/esm/api/defineModifyObjectAction.js.map +1 -0
  54. package/build/esm/api/test/actions.test.js +12014 -0
  55. package/build/esm/api/test/actions.test.js.map +1 -0
  56. package/build/esm/api/test/interfaces.test.js +924 -0
  57. package/build/esm/api/test/interfaces.test.js.map +1 -0
  58. package/build/esm/api/test/links.test.js +1974 -0
  59. package/build/esm/api/test/links.test.js.map +1 -0
  60. package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  61. package/build/esm/api/test/markingconstraint.test.js.map +1 -0
  62. package/build/esm/api/test/misc.test.js +1058 -0
  63. package/build/esm/api/test/misc.test.js.map +1 -0
  64. package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  65. package/build/esm/api/test/objectStatus.test.js.map +1 -0
  66. package/build/esm/api/test/objects.test.js +1494 -0
  67. package/build/esm/api/test/objects.test.js.map +1 -0
  68. package/build/esm/api/test/spt.test.js +387 -0
  69. package/build/esm/api/test/spt.test.js.map +1 -0
  70. package/build/esm/api/test/valueTypes.test.js +156 -0
  71. package/build/esm/api/test/valueTypes.test.js.map +1 -0
  72. package/build/esm/cli/main.js +1 -1
  73. package/build/esm/index.js +7 -1
  74. package/build/esm/index.js.map +1 -1
  75. package/build/types/api/defineAction.d.ts +22 -6
  76. package/build/types/api/defineAction.d.ts.map +1 -1
  77. package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
  78. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
  79. package/build/types/api/defineCreateObjectAction.d.ts +3 -0
  80. package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
  81. package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
  82. package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
  83. package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
  84. package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
  85. package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
  86. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
  87. package/build/types/api/defineModifyObjectAction.d.ts +3 -0
  88. package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
  89. package/build/types/api/test/actions.test.d.ts.map +1 -0
  90. package/build/types/api/test/interfaces.test.d.ts.map +1 -0
  91. package/build/types/api/test/links.test.d.ts.map +1 -0
  92. package/build/types/api/test/markingconstraint.test.d.ts +1 -0
  93. package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
  94. package/build/types/api/test/misc.test.d.ts +1 -0
  95. package/build/types/api/test/misc.test.d.ts.map +1 -0
  96. package/build/types/api/test/objectStatus.test.d.ts +1 -0
  97. package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
  98. package/build/types/api/test/objects.test.d.ts +1 -0
  99. package/build/types/api/test/objects.test.d.ts.map +1 -0
  100. package/build/types/api/test/spt.test.d.ts +1 -0
  101. package/build/types/api/test/spt.test.d.ts.map +1 -0
  102. package/build/types/api/test/valueTypes.test.d.ts +1 -0
  103. package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
  104. package/build/types/index.d.ts +7 -1
  105. package/build/types/index.d.ts.map +1 -1
  106. package/package.json +3 -3
  107. package/build/browser/api/markingconstraint.test.js.map +0 -1
  108. package/build/browser/api/objectStatus.test.js.map +0 -1
  109. package/build/browser/api/overall.test.js +0 -14002
  110. package/build/browser/api/overall.test.js.map +0 -1
  111. package/build/esm/api/markingconstraint.test.js.map +0 -1
  112. package/build/esm/api/objectStatus.test.js.map +0 -1
  113. package/build/esm/api/overall.test.js +0 -14002
  114. package/build/esm/api/overall.test.js.map +0 -1
  115. package/build/types/api/markingconstraint.test.d.ts.map +0 -1
  116. package/build/types/api/objectStatus.test.d.ts.map +0 -1
  117. package/build/types/api/overall.test.d.ts.map +0 -1
  118. /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
  119. /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
  120. /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
@@ -0,0 +1,1058 @@
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
+
17
+ import * as fs from "fs";
18
+ import path from "path";
19
+ import { fileURLToPath } from "url";
20
+ import { beforeEach, describe, expect, it } from "vitest";
21
+ import { addDependency } from "../addDependency.js";
22
+ import { OntologyEntityTypeEnum } from "../common/OntologyEntityTypeEnum.js";
23
+ import { defineInterface } from "../defineInterface.js";
24
+ import { defineObject } from "../defineObject.js";
25
+ import { defineOntology, dumpOntologyFullMetadata } from "../defineOntology.js";
26
+ import { defineSharedPropertyType } from "../defineSpt.js";
27
+ import { importOntologyEntity } from "../importOntologyEntity.js";
28
+ import { importSharedPropertyType } from "../importSharedPropertyType.js";
29
+ describe("Miscellaneous Tests", () => {
30
+ beforeEach(async () => {
31
+ await defineOntology("com.palantir.", () => {}, "/tmp/");
32
+ });
33
+ describe("Imports", () => {
34
+ it("Legacy importing works", () => {
35
+ const id = importSharedPropertyType({
36
+ apiName: "id",
37
+ packageName: "com.palantir.core.ontology.types",
38
+ typeHint: "string"
39
+ });
40
+ defineInterface({
41
+ apiName: "myInterface",
42
+ properties: {
43
+ id
44
+ }
45
+ });
46
+ expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
47
+ {
48
+ "importedOntology": {
49
+ "actionTypes": {},
50
+ "blockPermissionInformation": {
51
+ "actionTypes": {},
52
+ "linkTypes": {},
53
+ "objectTypes": {},
54
+ },
55
+ "interfaceTypes": {},
56
+ "linkTypes": {},
57
+ "objectTypes": {},
58
+ "sharedPropertyTypes": {
59
+ "com.palantir.core.ontology.types.id": {
60
+ "sharedPropertyType": {
61
+ "aliases": [],
62
+ "apiName": "com.palantir.core.ontology.types.id",
63
+ "baseFormatter": undefined,
64
+ "dataConstraints": undefined,
65
+ "displayMetadata": {
66
+ "description": undefined,
67
+ "displayName": "com.palantir.core.ontology.types.id",
68
+ "visibility": "NORMAL",
69
+ },
70
+ "gothamMapping": undefined,
71
+ "indexedForSearch": true,
72
+ "type": {
73
+ "string": {
74
+ "analyzerOverride": undefined,
75
+ "enableAsciiFolding": undefined,
76
+ "isLongText": false,
77
+ "supportsEfficientLeadingWildcard": false,
78
+ "supportsExactMatching": true,
79
+ },
80
+ "type": "string",
81
+ },
82
+ "typeClasses": [],
83
+ "valueType": undefined,
84
+ },
85
+ },
86
+ },
87
+ },
88
+ "importedValueTypes": {
89
+ "valueTypes": [],
90
+ },
91
+ "ontology": {
92
+ "actionTypes": {},
93
+ "blockPermissionInformation": {
94
+ "actionTypes": {},
95
+ "linkTypes": {},
96
+ "objectTypes": {},
97
+ },
98
+ "interfaceTypes": {
99
+ "com.palantir.myInterface": {
100
+ "interfaceType": {
101
+ "apiName": "com.palantir.myInterface",
102
+ "displayMetadata": {
103
+ "description": "myInterface",
104
+ "displayName": "myInterface",
105
+ "icon": {
106
+ "blueprint": {
107
+ "color": "#4C90F0",
108
+ "locator": "layout-hierarchy",
109
+ },
110
+ "type": "blueprint",
111
+ },
112
+ },
113
+ "extendsInterfaces": [],
114
+ "links": [],
115
+ "properties": [],
116
+ "propertiesV2": {
117
+ "com.palantir.core.ontology.types.id": {
118
+ "required": true,
119
+ "sharedPropertyType": {
120
+ "aliases": [],
121
+ "apiName": "com.palantir.core.ontology.types.id",
122
+ "baseFormatter": undefined,
123
+ "dataConstraints": undefined,
124
+ "displayMetadata": {
125
+ "description": undefined,
126
+ "displayName": "com.palantir.core.ontology.types.id",
127
+ "visibility": "NORMAL",
128
+ },
129
+ "gothamMapping": undefined,
130
+ "indexedForSearch": true,
131
+ "type": {
132
+ "string": {
133
+ "analyzerOverride": undefined,
134
+ "enableAsciiFolding": undefined,
135
+ "isLongText": false,
136
+ "supportsEfficientLeadingWildcard": false,
137
+ "supportsExactMatching": true,
138
+ },
139
+ "type": "string",
140
+ },
141
+ "typeClasses": [],
142
+ "valueType": undefined,
143
+ },
144
+ },
145
+ },
146
+ "propertiesV3": {},
147
+ "searchable": true,
148
+ "status": {
149
+ "active": {},
150
+ "type": "active",
151
+ },
152
+ },
153
+ },
154
+ },
155
+ "linkTypes": {},
156
+ "objectTypes": {},
157
+ "sharedPropertyTypes": {},
158
+ },
159
+ "randomnessKey": undefined,
160
+ "valueTypes": {
161
+ "valueTypes": [],
162
+ },
163
+ }
164
+ `);
165
+ });
166
+ it("Simple importing works", () => {
167
+ // does the same as "import { spt } from '@other/package'"
168
+ const spt = {
169
+ apiName: "com.other.package.spt",
170
+ nonNameSpacedApiName: "spt",
171
+ type: "string",
172
+ __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
173
+ };
174
+ importOntologyEntity(spt);
175
+ defineInterface({
176
+ apiName: "myInterface",
177
+ properties: {
178
+ spt
179
+ }
180
+ });
181
+ expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
182
+ {
183
+ "importedOntology": {
184
+ "actionTypes": {},
185
+ "blockPermissionInformation": {
186
+ "actionTypes": {},
187
+ "linkTypes": {},
188
+ "objectTypes": {},
189
+ },
190
+ "interfaceTypes": {},
191
+ "linkTypes": {},
192
+ "objectTypes": {},
193
+ "sharedPropertyTypes": {
194
+ "com.other.package.spt": {
195
+ "sharedPropertyType": {
196
+ "aliases": [],
197
+ "apiName": "com.other.package.spt",
198
+ "baseFormatter": undefined,
199
+ "dataConstraints": undefined,
200
+ "displayMetadata": {
201
+ "description": undefined,
202
+ "displayName": "com.other.package.spt",
203
+ "visibility": "NORMAL",
204
+ },
205
+ "gothamMapping": undefined,
206
+ "indexedForSearch": true,
207
+ "type": {
208
+ "string": {
209
+ "analyzerOverride": undefined,
210
+ "enableAsciiFolding": undefined,
211
+ "isLongText": false,
212
+ "supportsEfficientLeadingWildcard": false,
213
+ "supportsExactMatching": true,
214
+ },
215
+ "type": "string",
216
+ },
217
+ "typeClasses": [],
218
+ "valueType": undefined,
219
+ },
220
+ },
221
+ },
222
+ },
223
+ "importedValueTypes": {
224
+ "valueTypes": [],
225
+ },
226
+ "ontology": {
227
+ "actionTypes": {},
228
+ "blockPermissionInformation": {
229
+ "actionTypes": {},
230
+ "linkTypes": {},
231
+ "objectTypes": {},
232
+ },
233
+ "interfaceTypes": {
234
+ "com.palantir.myInterface": {
235
+ "interfaceType": {
236
+ "apiName": "com.palantir.myInterface",
237
+ "displayMetadata": {
238
+ "description": "myInterface",
239
+ "displayName": "myInterface",
240
+ "icon": {
241
+ "blueprint": {
242
+ "color": "#4C90F0",
243
+ "locator": "layout-hierarchy",
244
+ },
245
+ "type": "blueprint",
246
+ },
247
+ },
248
+ "extendsInterfaces": [],
249
+ "links": [],
250
+ "properties": [],
251
+ "propertiesV2": {
252
+ "com.other.package.spt": {
253
+ "required": true,
254
+ "sharedPropertyType": {
255
+ "aliases": [],
256
+ "apiName": "com.other.package.spt",
257
+ "baseFormatter": undefined,
258
+ "dataConstraints": undefined,
259
+ "displayMetadata": {
260
+ "description": undefined,
261
+ "displayName": "com.other.package.spt",
262
+ "visibility": "NORMAL",
263
+ },
264
+ "gothamMapping": undefined,
265
+ "indexedForSearch": true,
266
+ "type": {
267
+ "string": {
268
+ "analyzerOverride": undefined,
269
+ "enableAsciiFolding": undefined,
270
+ "isLongText": false,
271
+ "supportsEfficientLeadingWildcard": false,
272
+ "supportsExactMatching": true,
273
+ },
274
+ "type": "string",
275
+ },
276
+ "typeClasses": [],
277
+ "valueType": undefined,
278
+ },
279
+ },
280
+ },
281
+ "propertiesV3": {},
282
+ "searchable": true,
283
+ "status": {
284
+ "active": {},
285
+ "type": "active",
286
+ },
287
+ },
288
+ },
289
+ },
290
+ "linkTypes": {},
291
+ "objectTypes": {},
292
+ "sharedPropertyTypes": {},
293
+ },
294
+ "randomnessKey": undefined,
295
+ "valueTypes": {
296
+ "valueTypes": [],
297
+ },
298
+ }
299
+ `);
300
+ });
301
+ it("Export files are generated correctly", async () => {
302
+ const generatedDir = path.resolve(path.join(__dirname, "..", "generatedNoCheck", "export_files_are_generated_correctly"));
303
+ await defineOntology("com.my.package.", () => {
304
+ const mySpt = defineSharedPropertyType({
305
+ apiName: "mySpt",
306
+ type: "string"
307
+ });
308
+ const myInterface = defineInterface({
309
+ apiName: "myInterface",
310
+ properties: {
311
+ mySpt
312
+ }
313
+ });
314
+ defineObject({
315
+ titlePropertyApiName: "bar",
316
+ displayName: "My Object",
317
+ pluralDisplayName: "myObjects",
318
+ apiName: "myObject",
319
+ primaryKeyPropertyApiName: "bar",
320
+ properties: {
321
+ "bar": {
322
+ type: "string"
323
+ }
324
+ },
325
+ implementsInterfaces: [{
326
+ implements: myInterface,
327
+ propertyMapping: [{
328
+ interfaceProperty: "com.my.package.mySpt",
329
+ mapsTo: "bar"
330
+ }]
331
+ }]
332
+ });
333
+ }, generatedDir);
334
+ expect(fs.readFileSync(path.join(generatedDir, "codegen/interface-types/myInterface.ts"), "utf8")).toMatchInlineSnapshot(`
335
+ "
336
+ import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
337
+ import type { InterfaceType } from '@osdk/maker';
338
+
339
+ /** @type {import('@osdk/maker').InterfaceType} */
340
+ const myInterface_base: InterfaceType = {
341
+ "apiName": "com.my.package.myInterface",
342
+ "displayMetadata": {
343
+ "displayName": "myInterface",
344
+ "description": "myInterface"
345
+ },
346
+ "extendsInterfaces": [],
347
+ "links": [],
348
+ "status": {
349
+ "type": "active",
350
+ "active": {}
351
+ },
352
+ "propertiesV2": {
353
+ "com.my.package.mySpt": {
354
+ "required": true,
355
+ "sharedPropertyType": {
356
+ "apiName": "com.my.package.mySpt",
357
+ "type": "string",
358
+ "nonNameSpacedApiName": "mySpt",
359
+ "displayName": "mySpt",
360
+ "typeClasses": [
361
+ {
362
+ "kind": "render_hint",
363
+ "name": "SELECTABLE"
364
+ },
365
+ {
366
+ "kind": "render_hint",
367
+ "name": "SORTABLE"
368
+ }
369
+ ],
370
+ "__type": OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
371
+ }
372
+ }
373
+ },
374
+ "searchable": true,
375
+ "__type": OntologyEntityTypeEnum.INTERFACE_TYPE
376
+ } as unknown as InterfaceType;
377
+
378
+ export const myInterface: InterfaceType = wrapWithProxy(myInterface_base);
379
+ "
380
+ `);
381
+ expect(fs.readFileSync(path.join(generatedDir, "codegen/object-types/myObject.ts"), "utf8")).toMatchInlineSnapshot(`
382
+ "
383
+ import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
384
+ import type { ObjectType } from '@osdk/maker';
385
+
386
+ /** @type {import('@osdk/maker').ObjectType} */
387
+ const myObject_base: ObjectType = {
388
+ "titlePropertyApiName": "bar",
389
+ "displayName": "My Object",
390
+ "pluralDisplayName": "myObjects",
391
+ "apiName": "com.my.package.myObject",
392
+ "primaryKeyPropertyApiName": "bar",
393
+ "properties": [
394
+ {
395
+ "type": "string",
396
+ "apiName": "bar",
397
+ "displayName": "Bar"
398
+ }
399
+ ],
400
+ "implementsInterfaces": [
401
+ {
402
+ "implements": {
403
+ "apiName": "com.my.package.myInterface",
404
+ "displayMetadata": {
405
+ "displayName": "myInterface",
406
+ "description": "myInterface"
407
+ },
408
+ "extendsInterfaces": [],
409
+ "links": [],
410
+ "status": {
411
+ "type": "active",
412
+ "active": {}
413
+ },
414
+ "propertiesV2": {
415
+ "com.my.package.mySpt": {
416
+ "required": true,
417
+ "sharedPropertyType": {
418
+ "apiName": "com.my.package.mySpt",
419
+ "type": "string",
420
+ "nonNameSpacedApiName": "mySpt",
421
+ "displayName": "mySpt",
422
+ "typeClasses": [
423
+ {
424
+ "kind": "render_hint",
425
+ "name": "SELECTABLE"
426
+ },
427
+ {
428
+ "kind": "render_hint",
429
+ "name": "SORTABLE"
430
+ }
431
+ ],
432
+ "__type": OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
433
+ }
434
+ }
435
+ },
436
+ "searchable": true,
437
+ "__type": OntologyEntityTypeEnum.INTERFACE_TYPE
438
+ },
439
+ "propertyMapping": [
440
+ {
441
+ "interfaceProperty": "com.my.package.mySpt",
442
+ "mapsTo": "bar"
443
+ }
444
+ ]
445
+ }
446
+ ],
447
+ "__type": OntologyEntityTypeEnum.OBJECT_TYPE
448
+ } as unknown as ObjectType;
449
+
450
+ export const myObject: ObjectType = wrapWithProxy(myObject_base);
451
+ "
452
+ `);
453
+ expect(fs.readFileSync(path.join(generatedDir, "codegen/shared-property-types/mySpt.ts"), "utf8")).toMatchInlineSnapshot(`
454
+ "
455
+ import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
456
+ import type { SharedPropertyType } from '@osdk/maker';
457
+
458
+ /** @type {import('@osdk/maker').SharedPropertyType} */
459
+ const mySpt_base: SharedPropertyType = {
460
+ "apiName": "com.my.package.mySpt",
461
+ "type": "string",
462
+ "nonNameSpacedApiName": "mySpt",
463
+ "displayName": "mySpt",
464
+ "typeClasses": [
465
+ {
466
+ "kind": "render_hint",
467
+ "name": "SELECTABLE"
468
+ },
469
+ {
470
+ "kind": "render_hint",
471
+ "name": "SORTABLE"
472
+ }
473
+ ],
474
+ "__type": OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
475
+ } as unknown as SharedPropertyType;
476
+
477
+ export const mySpt: SharedPropertyType = wrapWithProxy(mySpt_base);
478
+ "
479
+ `);
480
+ fs.rmSync(path.resolve(path.join(generatedDir, "..")), {
481
+ recursive: true,
482
+ force: true
483
+ });
484
+ });
485
+ it("Extended interfaces are propagated to the static objects", async () => {
486
+ const generatedDir = path.resolve(path.join(__dirname, "..", "generatedNoCheck", "extended_interfaces_are_propagated_to_the_static_objects"));
487
+ await defineOntology("com.palantir.", () => {
488
+ const parentInterface = defineInterface({
489
+ apiName: "parentInterface",
490
+ properties: {
491
+ property1: "string"
492
+ }
493
+ });
494
+ defineInterface({
495
+ apiName: "childInterface",
496
+ properties: {
497
+ property2: "string"
498
+ },
499
+ extends: [parentInterface]
500
+ });
501
+ }, generatedDir);
502
+ expect(fs.readFileSync(path.join(generatedDir, "codegen/interface-types/childInterface.ts"), "utf8")).toMatchInlineSnapshot(`
503
+ "
504
+ import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
505
+ import type { InterfaceType } from '@osdk/maker';
506
+
507
+ /** @type {import('@osdk/maker').InterfaceType} */
508
+ const childInterface_base: InterfaceType = {
509
+ "apiName": "com.palantir.childInterface",
510
+ "displayMetadata": {
511
+ "displayName": "childInterface",
512
+ "description": "childInterface"
513
+ },
514
+ "extendsInterfaces": [
515
+ {
516
+ "apiName": "com.palantir.parentInterface",
517
+ "displayMetadata": {
518
+ "displayName": "parentInterface",
519
+ "description": "parentInterface"
520
+ },
521
+ "extendsInterfaces": [],
522
+ "links": [],
523
+ "status": {
524
+ "type": "active",
525
+ "active": {}
526
+ },
527
+ "propertiesV2": {
528
+ "com.palantir.property1": {
529
+ "required": true,
530
+ "sharedPropertyType": {
531
+ "apiName": "com.palantir.property1",
532
+ "displayName": "property1",
533
+ "type": "string",
534
+ "array": false,
535
+ "nonNameSpacedApiName": "property1",
536
+ "typeClasses": [
537
+ {
538
+ "kind": "render_hint",
539
+ "name": "SELECTABLE"
540
+ },
541
+ {
542
+ "kind": "render_hint",
543
+ "name": "SORTABLE"
544
+ }
545
+ ],
546
+ "__type": OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
547
+ }
548
+ }
549
+ },
550
+ "searchable": true,
551
+ "__type": OntologyEntityTypeEnum.INTERFACE_TYPE
552
+ }
553
+ ],
554
+ "links": [],
555
+ "status": {
556
+ "type": "active",
557
+ "active": {}
558
+ },
559
+ "propertiesV2": {
560
+ "com.palantir.property2": {
561
+ "required": true,
562
+ "sharedPropertyType": {
563
+ "apiName": "com.palantir.property2",
564
+ "displayName": "property2",
565
+ "type": "string",
566
+ "array": false,
567
+ "nonNameSpacedApiName": "property2",
568
+ "typeClasses": [
569
+ {
570
+ "kind": "render_hint",
571
+ "name": "SELECTABLE"
572
+ },
573
+ {
574
+ "kind": "render_hint",
575
+ "name": "SORTABLE"
576
+ }
577
+ ],
578
+ "__type": OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
579
+ }
580
+ }
581
+ },
582
+ "searchable": true,
583
+ "__type": OntologyEntityTypeEnum.INTERFACE_TYPE
584
+ } as unknown as InterfaceType;
585
+
586
+ export const childInterface: InterfaceType = wrapWithProxy(childInterface_base);
587
+ "
588
+ `);
589
+ fs.rmSync(path.join(generatedDir, ".."), {
590
+ recursive: true,
591
+ force: true
592
+ });
593
+ });
594
+ it("Extended interface properties are checked in object type property mapping", () => {
595
+ const parentInterface = defineInterface({
596
+ apiName: "parentInterface",
597
+ properties: {
598
+ iProperty1: "string"
599
+ }
600
+ });
601
+ const childInterface = defineInterface({
602
+ apiName: "childInterface",
603
+ properties: {
604
+ iProperty2: "string"
605
+ },
606
+ extends: [parentInterface]
607
+ });
608
+ defineObject({
609
+ apiName: "objectDef",
610
+ primaryKeyPropertyApiName: "property1",
611
+ titlePropertyApiName: "property1",
612
+ displayName: "objectDef",
613
+ pluralDisplayName: "objectDefs",
614
+ properties: {
615
+ "property1": {
616
+ type: "string",
617
+ displayName: "property1"
618
+ },
619
+ "property2": {
620
+ type: "string",
621
+ displayName: "property2"
622
+ }
623
+ },
624
+ implementsInterfaces: [{
625
+ implements: childInterface,
626
+ propertyMapping: [{
627
+ interfaceProperty: "com.palantir.iProperty1",
628
+ mapsTo: "property1"
629
+ }, {
630
+ interfaceProperty: "com.palantir.iProperty2",
631
+ mapsTo: "property2"
632
+ }]
633
+ }]
634
+ });
635
+ expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
636
+ {
637
+ "importedOntology": {
638
+ "actionTypes": {},
639
+ "blockPermissionInformation": {
640
+ "actionTypes": {},
641
+ "linkTypes": {},
642
+ "objectTypes": {},
643
+ },
644
+ "interfaceTypes": {},
645
+ "linkTypes": {},
646
+ "objectTypes": {},
647
+ "sharedPropertyTypes": {},
648
+ },
649
+ "importedValueTypes": {
650
+ "valueTypes": [],
651
+ },
652
+ "ontology": {
653
+ "actionTypes": {},
654
+ "blockPermissionInformation": {
655
+ "actionTypes": {},
656
+ "linkTypes": {},
657
+ "objectTypes": {},
658
+ },
659
+ "interfaceTypes": {
660
+ "com.palantir.childInterface": {
661
+ "interfaceType": {
662
+ "apiName": "com.palantir.childInterface",
663
+ "displayMetadata": {
664
+ "description": "childInterface",
665
+ "displayName": "childInterface",
666
+ "icon": {
667
+ "blueprint": {
668
+ "color": "#4C90F0",
669
+ "locator": "layout-hierarchy",
670
+ },
671
+ "type": "blueprint",
672
+ },
673
+ },
674
+ "extendsInterfaces": [
675
+ "com.palantir.parentInterface",
676
+ ],
677
+ "links": [],
678
+ "properties": [],
679
+ "propertiesV2": {
680
+ "com.palantir.iProperty2": {
681
+ "required": true,
682
+ "sharedPropertyType": {
683
+ "aliases": [],
684
+ "apiName": "com.palantir.iProperty2",
685
+ "baseFormatter": undefined,
686
+ "dataConstraints": undefined,
687
+ "displayMetadata": {
688
+ "description": undefined,
689
+ "displayName": "iProperty2",
690
+ "visibility": "NORMAL",
691
+ },
692
+ "gothamMapping": undefined,
693
+ "indexedForSearch": true,
694
+ "type": {
695
+ "string": {
696
+ "analyzerOverride": undefined,
697
+ "enableAsciiFolding": undefined,
698
+ "isLongText": false,
699
+ "supportsEfficientLeadingWildcard": false,
700
+ "supportsExactMatching": true,
701
+ },
702
+ "type": "string",
703
+ },
704
+ "typeClasses": [
705
+ {
706
+ "kind": "render_hint",
707
+ "name": "SELECTABLE",
708
+ },
709
+ {
710
+ "kind": "render_hint",
711
+ "name": "SORTABLE",
712
+ },
713
+ ],
714
+ "valueType": undefined,
715
+ },
716
+ },
717
+ },
718
+ "propertiesV3": {},
719
+ "searchable": true,
720
+ "status": {
721
+ "active": {},
722
+ "type": "active",
723
+ },
724
+ },
725
+ },
726
+ "com.palantir.parentInterface": {
727
+ "interfaceType": {
728
+ "apiName": "com.palantir.parentInterface",
729
+ "displayMetadata": {
730
+ "description": "parentInterface",
731
+ "displayName": "parentInterface",
732
+ "icon": {
733
+ "blueprint": {
734
+ "color": "#4C90F0",
735
+ "locator": "layout-hierarchy",
736
+ },
737
+ "type": "blueprint",
738
+ },
739
+ },
740
+ "extendsInterfaces": [],
741
+ "links": [],
742
+ "properties": [],
743
+ "propertiesV2": {
744
+ "com.palantir.iProperty1": {
745
+ "required": true,
746
+ "sharedPropertyType": {
747
+ "aliases": [],
748
+ "apiName": "com.palantir.iProperty1",
749
+ "baseFormatter": undefined,
750
+ "dataConstraints": undefined,
751
+ "displayMetadata": {
752
+ "description": undefined,
753
+ "displayName": "iProperty1",
754
+ "visibility": "NORMAL",
755
+ },
756
+ "gothamMapping": undefined,
757
+ "indexedForSearch": true,
758
+ "type": {
759
+ "string": {
760
+ "analyzerOverride": undefined,
761
+ "enableAsciiFolding": undefined,
762
+ "isLongText": false,
763
+ "supportsEfficientLeadingWildcard": false,
764
+ "supportsExactMatching": true,
765
+ },
766
+ "type": "string",
767
+ },
768
+ "typeClasses": [
769
+ {
770
+ "kind": "render_hint",
771
+ "name": "SELECTABLE",
772
+ },
773
+ {
774
+ "kind": "render_hint",
775
+ "name": "SORTABLE",
776
+ },
777
+ ],
778
+ "valueType": undefined,
779
+ },
780
+ },
781
+ },
782
+ "propertiesV3": {},
783
+ "searchable": true,
784
+ "status": {
785
+ "active": {},
786
+ "type": "active",
787
+ },
788
+ },
789
+ },
790
+ },
791
+ "linkTypes": {},
792
+ "objectTypes": {
793
+ "com.palantir.objectDef": {
794
+ "datasources": [
795
+ {
796
+ "datasource": {
797
+ "datasetV2": {
798
+ "datasetRid": "com.palantir.objectDef",
799
+ "propertyMapping": {
800
+ "property1": {
801
+ "column": "property1",
802
+ "type": "column",
803
+ },
804
+ "property2": {
805
+ "column": "property2",
806
+ "type": "column",
807
+ },
808
+ },
809
+ },
810
+ "type": "datasetV2",
811
+ },
812
+ "datasourceName": "com.palantir.objectDef",
813
+ "editsConfiguration": {
814
+ "onlyAllowPrivilegedEdits": false,
815
+ },
816
+ "redacted": false,
817
+ },
818
+ ],
819
+ "entityMetadata": {
820
+ "arePatchesEnabled": false,
821
+ },
822
+ "objectType": {
823
+ "allImplementsInterfaces": {},
824
+ "apiName": "com.palantir.objectDef",
825
+ "displayMetadata": {
826
+ "description": undefined,
827
+ "displayName": "objectDef",
828
+ "groupDisplayName": undefined,
829
+ "icon": {
830
+ "blueprint": {
831
+ "color": "#2D72D2",
832
+ "locator": "cube",
833
+ },
834
+ "type": "blueprint",
835
+ },
836
+ "pluralDisplayName": "objectDefs",
837
+ "visibility": "NORMAL",
838
+ },
839
+ "implementsInterfaces2": [
840
+ {
841
+ "interfaceTypeApiName": "com.palantir.childInterface",
842
+ "linksV2": {},
843
+ "properties": {
844
+ "com.palantir.iProperty1": {
845
+ "propertyTypeRid": "property1",
846
+ },
847
+ "com.palantir.iProperty2": {
848
+ "propertyTypeRid": "property2",
849
+ },
850
+ },
851
+ "propertiesV2": {},
852
+ },
853
+ ],
854
+ "primaryKeys": [
855
+ "property1",
856
+ ],
857
+ "propertyTypes": {
858
+ "property1": {
859
+ "apiName": "property1",
860
+ "baseFormatter": undefined,
861
+ "dataConstraints": undefined,
862
+ "displayMetadata": {
863
+ "description": undefined,
864
+ "displayName": "property1",
865
+ "visibility": "NORMAL",
866
+ },
867
+ "indexedForSearch": true,
868
+ "inlineAction": undefined,
869
+ "ruleSetBinding": undefined,
870
+ "sharedPropertyTypeApiName": undefined,
871
+ "sharedPropertyTypeRid": undefined,
872
+ "status": {
873
+ "active": {},
874
+ "type": "active",
875
+ },
876
+ "type": {
877
+ "string": {
878
+ "analyzerOverride": undefined,
879
+ "enableAsciiFolding": undefined,
880
+ "isLongText": false,
881
+ "supportsEfficientLeadingWildcard": false,
882
+ "supportsExactMatching": true,
883
+ },
884
+ "type": "string",
885
+ },
886
+ "typeClasses": [
887
+ {
888
+ "kind": "render_hint",
889
+ "name": "SELECTABLE",
890
+ },
891
+ {
892
+ "kind": "render_hint",
893
+ "name": "SORTABLE",
894
+ },
895
+ ],
896
+ "valueType": undefined,
897
+ },
898
+ "property2": {
899
+ "apiName": "property2",
900
+ "baseFormatter": undefined,
901
+ "dataConstraints": undefined,
902
+ "displayMetadata": {
903
+ "description": undefined,
904
+ "displayName": "property2",
905
+ "visibility": "NORMAL",
906
+ },
907
+ "indexedForSearch": true,
908
+ "inlineAction": undefined,
909
+ "ruleSetBinding": undefined,
910
+ "sharedPropertyTypeApiName": undefined,
911
+ "sharedPropertyTypeRid": undefined,
912
+ "status": {
913
+ "active": {},
914
+ "type": "active",
915
+ },
916
+ "type": {
917
+ "string": {
918
+ "analyzerOverride": undefined,
919
+ "enableAsciiFolding": undefined,
920
+ "isLongText": false,
921
+ "supportsEfficientLeadingWildcard": false,
922
+ "supportsExactMatching": true,
923
+ },
924
+ "type": "string",
925
+ },
926
+ "typeClasses": [
927
+ {
928
+ "kind": "render_hint",
929
+ "name": "SELECTABLE",
930
+ },
931
+ {
932
+ "kind": "render_hint",
933
+ "name": "SORTABLE",
934
+ },
935
+ ],
936
+ "valueType": undefined,
937
+ },
938
+ },
939
+ "redacted": false,
940
+ "status": {
941
+ "active": {},
942
+ "type": "active",
943
+ },
944
+ "titlePropertyTypeRid": "property1",
945
+ },
946
+ },
947
+ },
948
+ "sharedPropertyTypes": {
949
+ "com.palantir.iProperty1": {
950
+ "sharedPropertyType": {
951
+ "aliases": [],
952
+ "apiName": "com.palantir.iProperty1",
953
+ "baseFormatter": undefined,
954
+ "dataConstraints": undefined,
955
+ "displayMetadata": {
956
+ "description": undefined,
957
+ "displayName": "iProperty1",
958
+ "visibility": "NORMAL",
959
+ },
960
+ "gothamMapping": undefined,
961
+ "indexedForSearch": true,
962
+ "type": {
963
+ "string": {
964
+ "analyzerOverride": undefined,
965
+ "enableAsciiFolding": undefined,
966
+ "isLongText": false,
967
+ "supportsEfficientLeadingWildcard": false,
968
+ "supportsExactMatching": true,
969
+ },
970
+ "type": "string",
971
+ },
972
+ "typeClasses": [
973
+ {
974
+ "kind": "render_hint",
975
+ "name": "SELECTABLE",
976
+ },
977
+ {
978
+ "kind": "render_hint",
979
+ "name": "SORTABLE",
980
+ },
981
+ ],
982
+ "valueType": undefined,
983
+ },
984
+ },
985
+ "com.palantir.iProperty2": {
986
+ "sharedPropertyType": {
987
+ "aliases": [],
988
+ "apiName": "com.palantir.iProperty2",
989
+ "baseFormatter": undefined,
990
+ "dataConstraints": undefined,
991
+ "displayMetadata": {
992
+ "description": undefined,
993
+ "displayName": "iProperty2",
994
+ "visibility": "NORMAL",
995
+ },
996
+ "gothamMapping": undefined,
997
+ "indexedForSearch": true,
998
+ "type": {
999
+ "string": {
1000
+ "analyzerOverride": undefined,
1001
+ "enableAsciiFolding": undefined,
1002
+ "isLongText": false,
1003
+ "supportsEfficientLeadingWildcard": false,
1004
+ "supportsExactMatching": true,
1005
+ },
1006
+ "type": "string",
1007
+ },
1008
+ "typeClasses": [
1009
+ {
1010
+ "kind": "render_hint",
1011
+ "name": "SELECTABLE",
1012
+ },
1013
+ {
1014
+ "kind": "render_hint",
1015
+ "name": "SORTABLE",
1016
+ },
1017
+ ],
1018
+ "valueType": undefined,
1019
+ },
1020
+ },
1021
+ },
1022
+ },
1023
+ "randomnessKey": undefined,
1024
+ "valueTypes": {
1025
+ "valueTypes": [],
1026
+ },
1027
+ }
1028
+ `);
1029
+ });
1030
+ });
1031
+ describe("Dependencies", () => {
1032
+ it("Correctly adds dependencies", async () => {
1033
+ const generatedDir = path.resolve(path.join(__dirname, "..", "generatedNoCheck", "correctly_adds_dependencies"));
1034
+ await defineOntology("com.palantir.", () => {
1035
+ addDependency("com.palantir", fileURLToPath(import.meta.url));
1036
+ defineInterface({
1037
+ apiName: "myInterface",
1038
+ properties: {
1039
+ property1: "string"
1040
+ }
1041
+ });
1042
+ }, generatedDir, path.join(generatedDir, "dependencies.json"));
1043
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "..", "package.json"), "utf8"));
1044
+ expect(packageJson.version).toBeDefined();
1045
+ expect(fs.readFileSync(path.join(generatedDir, "dependencies.json"), "utf8")).toMatchInlineSnapshot(`
1046
+ "{
1047
+ "com.palantir": "${packageJson.version}"
1048
+ }"
1049
+ `);
1050
+ expect(fs.readFileSync(path.join(generatedDir, "index.ts"), "utf8")).toContain(`addDependency("com.palantir", new URL(import.meta.url).pathname);`);
1051
+ fs.rmSync(path.join(generatedDir, ".."), {
1052
+ recursive: true,
1053
+ force: true
1054
+ });
1055
+ });
1056
+ });
1057
+ });
1058
+ //# sourceMappingURL=misc.test.js.map