@osdk/maker 0.14.0-beta.8 → 0.14.0-rc.16

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 +128 -0
  2. package/README.md +0 -1
  3. package/build/browser/api/code-snippets/createCodeSnippets.js +94 -0
  4. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
  5. package/build/browser/api/code-snippets/snippetTypes.js +61 -0
  6. package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
  7. package/build/browser/api/defineAction.js +6 -0
  8. package/build/browser/api/defineAction.js.map +1 -1
  9. package/build/browser/api/defineCreateInterfaceObjectAction.js +8 -7
  10. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
  11. package/build/browser/api/defineDeleteInterfaceObjectAction.js +2 -2
  12. package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  13. package/build/browser/api/defineModifyInterfaceObjectAction.js +8 -7
  14. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
  15. package/build/browser/api/defineObject.js +1 -2
  16. package/build/browser/api/defineObject.js.map +1 -1
  17. package/build/browser/api/defineOntology.js +5 -1
  18. package/build/browser/api/defineOntology.js.map +1 -1
  19. package/build/browser/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
  20. package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
  21. package/build/browser/api/test/actions.test.js +1252 -10
  22. package/build/browser/api/test/actions.test.js.map +1 -1
  23. package/build/browser/api/test/misc.test.js +2 -2
  24. package/build/browser/api/test/misc.test.js.map +1 -1
  25. package/build/browser/api/test/spt.test.js +204 -105
  26. package/build/browser/api/test/spt.test.js.map +1 -1
  27. package/build/browser/cli/main.js +23 -4
  28. package/build/browser/cli/main.js.map +1 -1
  29. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
  30. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  31. package/build/cjs/index.cjs +206 -61
  32. package/build/cjs/index.cjs.map +1 -1
  33. package/build/cjs/index.d.cts +15 -6
  34. package/build/esm/api/code-snippets/createCodeSnippets.js +94 -0
  35. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
  36. package/build/esm/api/code-snippets/snippetTypes.js +61 -0
  37. package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
  38. package/build/esm/api/defineAction.js +6 -0
  39. package/build/esm/api/defineAction.js.map +1 -1
  40. package/build/esm/api/defineCreateInterfaceObjectAction.js +8 -7
  41. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
  42. package/build/esm/api/defineDeleteInterfaceObjectAction.js +2 -2
  43. package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  44. package/build/esm/api/defineModifyInterfaceObjectAction.js +8 -7
  45. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
  46. package/build/esm/api/defineObject.js +1 -2
  47. package/build/esm/api/defineObject.js.map +1 -1
  48. package/build/esm/api/defineOntology.js +5 -1
  49. package/build/esm/api/defineOntology.js.map +1 -1
  50. package/build/esm/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
  51. package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
  52. package/build/esm/api/test/actions.test.js +1252 -10
  53. package/build/esm/api/test/actions.test.js.map +1 -1
  54. package/build/esm/api/test/misc.test.js +2 -2
  55. package/build/esm/api/test/misc.test.js.map +1 -1
  56. package/build/esm/api/test/spt.test.js +204 -105
  57. package/build/esm/api/test/spt.test.js.map +1 -1
  58. package/build/esm/cli/main.js +23 -4
  59. package/build/esm/cli/main.js.map +1 -1
  60. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
  61. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  62. package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
  63. package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
  64. package/build/types/api/code-snippets/snippetTypes.d.ts +24 -0
  65. package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
  66. package/build/types/api/defineAction.d.ts +3 -0
  67. package/build/types/api/defineAction.d.ts.map +1 -1
  68. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
  69. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
  70. package/build/types/api/defineOntology.d.ts +1 -1
  71. package/build/types/api/defineOntology.d.ts.map +1 -1
  72. package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts +1 -1
  73. package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts.map +1 -1
  74. package/build/types/api/properties/PropertyTypeType.d.ts +11 -4
  75. package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
  76. package/package.json +8 -5
@@ -267,121 +267,220 @@ describe("SPTs", () => {
267
267
  }
268
268
  });
269
269
  expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
270
- {
271
- "actionTypes": {},
272
- "blockPermissionInformation": {
273
- "actionTypes": {},
274
- "linkTypes": {},
275
- "objectTypes": {},
276
- },
277
- "interfaceTypes": {
278
- "com.palantir.interface": {
279
- "interfaceType": {
280
- "apiName": "com.palantir.interface",
281
- "displayMetadata": {
282
- "description": "interface",
283
- "displayName": "interface",
284
- "icon": {
285
- "blueprint": {
286
- "color": "#4C90F0",
287
- "locator": "layout-hierarchy",
288
- },
289
- "type": "blueprint",
290
- },
270
+ {
271
+ "actionTypes": {},
272
+ "blockPermissionInformation": {
273
+ "actionTypes": {},
274
+ "linkTypes": {},
275
+ "objectTypes": {},
276
+ },
277
+ "interfaceTypes": {
278
+ "com.palantir.interface": {
279
+ "interfaceType": {
280
+ "apiName": "com.palantir.interface",
281
+ "displayMetadata": {
282
+ "description": "interface",
283
+ "displayName": "interface",
284
+ "icon": {
285
+ "blueprint": {
286
+ "color": "#4C90F0",
287
+ "locator": "layout-hierarchy",
291
288
  },
292
- "extendsInterfaces": [],
293
- "links": [],
294
- "properties": [],
295
- "propertiesV2": {
296
- "com.palantir.foo": {
297
- "required": true,
298
- "sharedPropertyType": {
299
- "aliases": [],
300
- "apiName": "com.palantir.foo",
301
- "baseFormatter": undefined,
302
- "dataConstraints": undefined,
303
- "displayMetadata": {
304
- "description": undefined,
305
- "displayName": "foo",
306
- "visibility": "NORMAL",
307
- },
308
- "gothamMapping": undefined,
309
- "indexedForSearch": true,
310
- "type": {
311
- "string": {
312
- "analyzerOverride": undefined,
313
- "enableAsciiFolding": undefined,
314
- "isLongText": true,
315
- "supportsEfficientLeadingWildcard": true,
316
- "supportsExactMatching": false,
317
- },
318
- "type": "string",
319
- },
320
- "typeClasses": [
321
- {
322
- "kind": "render_hint",
323
- "name": "SELECTABLE",
324
- },
325
- {
326
- "kind": "render_hint",
327
- "name": "SORTABLE",
328
- },
329
- ],
330
- "valueType": undefined,
289
+ "type": "blueprint",
290
+ },
291
+ },
292
+ "extendsInterfaces": [],
293
+ "links": [],
294
+ "properties": [],
295
+ "propertiesV2": {
296
+ "com.palantir.foo": {
297
+ "required": true,
298
+ "sharedPropertyType": {
299
+ "aliases": [],
300
+ "apiName": "com.palantir.foo",
301
+ "baseFormatter": undefined,
302
+ "dataConstraints": undefined,
303
+ "displayMetadata": {
304
+ "description": undefined,
305
+ "displayName": "foo",
306
+ "visibility": "NORMAL",
307
+ },
308
+ "gothamMapping": undefined,
309
+ "indexedForSearch": true,
310
+ "type": {
311
+ "string": {
312
+ "analyzerOverride": undefined,
313
+ "enableAsciiFolding": undefined,
314
+ "isLongText": true,
315
+ "supportsEfficientLeadingWildcard": true,
316
+ "supportsExactMatching": false,
317
+ "supportsFullTextRegex": undefined,
331
318
  },
319
+ "type": "string",
332
320
  },
321
+ "typeClasses": [
322
+ {
323
+ "kind": "render_hint",
324
+ "name": "SELECTABLE",
325
+ },
326
+ {
327
+ "kind": "render_hint",
328
+ "name": "SORTABLE",
329
+ },
330
+ ],
331
+ "valueType": undefined,
333
332
  },
334
- "propertiesV3": {},
335
- "searchable": true,
336
- "status": {
337
- "active": {},
338
- "type": "active",
339
- },
340
333
  },
341
334
  },
335
+ "propertiesV3": {},
336
+ "searchable": true,
337
+ "status": {
338
+ "active": {},
339
+ "type": "active",
340
+ },
341
+ },
342
+ },
343
+ },
344
+ "linkTypes": {},
345
+ "objectTypes": {},
346
+ "sharedPropertyTypes": {
347
+ "com.palantir.foo": {
348
+ "sharedPropertyType": {
349
+ "aliases": [],
350
+ "apiName": "com.palantir.foo",
351
+ "baseFormatter": undefined,
352
+ "dataConstraints": undefined,
353
+ "displayMetadata": {
354
+ "description": undefined,
355
+ "displayName": "foo",
356
+ "visibility": "NORMAL",
357
+ },
358
+ "gothamMapping": undefined,
359
+ "indexedForSearch": true,
360
+ "type": {
361
+ "string": {
362
+ "analyzerOverride": undefined,
363
+ "enableAsciiFolding": undefined,
364
+ "isLongText": true,
365
+ "supportsEfficientLeadingWildcard": true,
366
+ "supportsExactMatching": false,
367
+ "supportsFullTextRegex": undefined,
368
+ },
369
+ "type": "string",
370
+ },
371
+ "typeClasses": [
372
+ {
373
+ "kind": "render_hint",
374
+ "name": "SELECTABLE",
375
+ },
376
+ {
377
+ "kind": "render_hint",
378
+ "name": "SORTABLE",
379
+ },
380
+ ],
381
+ "valueType": undefined,
342
382
  },
343
- "linkTypes": {},
344
- "objectTypes": {},
345
- "sharedPropertyTypes": {
346
- "com.palantir.foo": {
347
- "sharedPropertyType": {
348
- "aliases": [],
349
- "apiName": "com.palantir.foo",
350
- "baseFormatter": undefined,
351
- "dataConstraints": undefined,
352
- "displayMetadata": {
353
- "description": undefined,
354
- "displayName": "foo",
355
- "visibility": "NORMAL",
356
- },
357
- "gothamMapping": undefined,
358
- "indexedForSearch": true,
359
- "type": {
360
- "string": {
361
- "analyzerOverride": undefined,
362
- "enableAsciiFolding": undefined,
363
- "isLongText": true,
364
- "supportsEfficientLeadingWildcard": true,
365
- "supportsExactMatching": false,
366
- },
367
- "type": "string",
368
- },
369
- "typeClasses": [
370
- {
371
- "kind": "render_hint",
372
- "name": "SELECTABLE",
373
- },
374
- {
375
- "kind": "render_hint",
376
- "name": "SORTABLE",
377
- },
378
- ],
379
- "valueType": undefined,
383
+ },
384
+ },
385
+ }
386
+ `);
387
+ });
388
+ it("Custom decimal fields properly set", () => {
389
+ defineSharedPropertyType({
390
+ apiName: "precision",
391
+ type: {
392
+ type: "decimal",
393
+ precision: 10
394
+ }
395
+ });
396
+ defineSharedPropertyType({
397
+ apiName: "scale",
398
+ type: {
399
+ type: "decimal",
400
+ scale: 5
401
+ }
402
+ });
403
+ expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
404
+ {
405
+ "actionTypes": {},
406
+ "blockPermissionInformation": {
407
+ "actionTypes": {},
408
+ "linkTypes": {},
409
+ "objectTypes": {},
410
+ },
411
+ "interfaceTypes": {},
412
+ "linkTypes": {},
413
+ "objectTypes": {},
414
+ "sharedPropertyTypes": {
415
+ "com.palantir.precision": {
416
+ "sharedPropertyType": {
417
+ "aliases": [],
418
+ "apiName": "com.palantir.precision",
419
+ "baseFormatter": undefined,
420
+ "dataConstraints": undefined,
421
+ "displayMetadata": {
422
+ "description": undefined,
423
+ "displayName": "precision",
424
+ "visibility": "NORMAL",
425
+ },
426
+ "gothamMapping": undefined,
427
+ "indexedForSearch": true,
428
+ "type": {
429
+ "decimal": {
430
+ "precision": 10,
431
+ "scale": undefined,
380
432
  },
433
+ "type": "decimal",
381
434
  },
435
+ "typeClasses": [
436
+ {
437
+ "kind": "render_hint",
438
+ "name": "SELECTABLE",
439
+ },
440
+ {
441
+ "kind": "render_hint",
442
+ "name": "SORTABLE",
443
+ },
444
+ ],
445
+ "valueType": undefined,
382
446
  },
383
- }
384
- `);
447
+ },
448
+ "com.palantir.scale": {
449
+ "sharedPropertyType": {
450
+ "aliases": [],
451
+ "apiName": "com.palantir.scale",
452
+ "baseFormatter": undefined,
453
+ "dataConstraints": undefined,
454
+ "displayMetadata": {
455
+ "description": undefined,
456
+ "displayName": "scale",
457
+ "visibility": "NORMAL",
458
+ },
459
+ "gothamMapping": undefined,
460
+ "indexedForSearch": true,
461
+ "type": {
462
+ "decimal": {
463
+ "precision": undefined,
464
+ "scale": 5,
465
+ },
466
+ "type": "decimal",
467
+ },
468
+ "typeClasses": [
469
+ {
470
+ "kind": "render_hint",
471
+ "name": "SELECTABLE",
472
+ },
473
+ {
474
+ "kind": "render_hint",
475
+ "name": "SORTABLE",
476
+ },
477
+ ],
478
+ "valueType": undefined,
479
+ },
480
+ },
481
+ },
482
+ }
483
+ `);
385
484
  });
386
485
  });
387
486
  //# sourceMappingURL=spt.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spt.test.js","names":["beforeEach","describe","expect","it","defineInterface","defineOntology","dumpOntologyFullMetadata","defineSharedPropertyType","apiName","type","toThrowErrorMatchingInlineSnapshot","fooSpt","displayName","properties","icon","color","locator","ontology","toMatchInlineSnapshot","structDefinition","fieldType","displayMetadata","description","undefined","spt","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","foo"],"sources":["spt.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineInterface } from \"../defineInterface.js\";\nimport { defineOntology, dumpOntologyFullMetadata } from \"../defineOntology.js\";\nimport { defineSharedPropertyType } from \"../defineSpt.js\";\ndescribe(\"SPTs\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"doesn't let you create the same spt twice\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n\n expect(() => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n }).toThrowErrorMatchingInlineSnapshot(\n `[Error: Invariant failed: Shared property type com.palantir.foo already exists]`,\n );\n });\n\n it(\"uses a predefined spt\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: \"string\",\n });\n\n const FooInterface = defineInterface({\n apiName: \"FooInterface\",\n displayName: \"Foo Interface\",\n properties: {\n fooSpt,\n },\n icon: { color: \"#00000\", locator: \"airplane\" },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.FooInterface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.FooInterface\",\n \"displayMetadata\": {\n \"description\": \"Foo Interface\",\n \"displayName\": \"Foo Interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#00000\",\n \"locator\": \"airplane\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.fooSpt\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"properly serializes both types of struct SPTs\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: {\n type: \"struct\",\n structDefinition: {\n \"simpleProperty\": \"boolean\",\n \"complexProperty\": {\n fieldType: \"date\",\n displayMetadata: {\n displayName: \"complex property\",\n description: undefined,\n },\n },\n },\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"struct\": {\n \"structFields\": [\n {\n \"aliases\": [],\n \"apiName\": \"simpleProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"simpleProperty\",\n },\n \"fieldType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"typeClasses\": [],\n },\n {\n \"aliases\": [],\n \"apiName\": \"complexProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"complex property\",\n },\n \"fieldType\": {\n \"date\": {},\n \"type\": \"date\",\n },\n \"typeClasses\": [],\n },\n ],\n },\n \"type\": \"struct\",\n },\n \"typeClasses\": [],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom string fields properly set\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: {\n type: \"string\",\n isLongText: true,\n supportsEfficientLeadingWildcard: true,\n supportsExactMatching: false,\n },\n });\n\n defineInterface({\n apiName: \"interface\",\n properties: { foo: spt },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.interface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.interface\",\n \"displayMetadata\": {\n \"description\": \"interface\",\n \"displayName\": \"interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#4C90F0\",\n \"locator\": \"layout-hierarchy\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.foo\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;EACR,CAAC,CAAC;EAEFf,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACzCI,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdU,gBAAgB,EAAE;UAChB,gBAAgB,EAAE,SAAS;UAC3B,iBAAiB,EAAE;YACjBC,SAAS,EAAE,MAAM;YACjBC,eAAe,EAAE;cACfT,WAAW,EAAE,kBAAkB;cAC/BU,WAAW,EAAEC;YACf;UACF;QACF;MACF;IACF,CAAC,CAAC;IAEFrB,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;EACV,CAAC,CAAC;EAEFf,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAMqB,GAAG,GAAGjB,wBAAwB,CAAC;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdgB,UAAU,EAAE,IAAI;QAChBC,gCAAgC,EAAE,IAAI;QACtCC,qBAAqB,EAAE;MACzB;IACF,CAAC,CAAC;IAEFvB,eAAe,CAAC;MACdI,OAAO,EAAE,WAAW;MACpBK,UAAU,EAAE;QAAEe,GAAG,EAAEJ;MAAI;IACzB,CAAC,CAAC;IAEFtB,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;EACR,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"spt.test.js","names":["beforeEach","describe","expect","it","defineInterface","defineOntology","dumpOntologyFullMetadata","defineSharedPropertyType","apiName","type","toThrowErrorMatchingInlineSnapshot","fooSpt","displayName","properties","icon","color","locator","ontology","toMatchInlineSnapshot","structDefinition","fieldType","displayMetadata","description","undefined","spt","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","foo","precision","scale"],"sources":["spt.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineInterface } from \"../defineInterface.js\";\nimport { defineOntology, dumpOntologyFullMetadata } from \"../defineOntology.js\";\nimport { defineSharedPropertyType } from \"../defineSpt.js\";\ndescribe(\"SPTs\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"doesn't let you create the same spt twice\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n\n expect(() => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n }).toThrowErrorMatchingInlineSnapshot(\n `[Error: Invariant failed: Shared property type com.palantir.foo already exists]`,\n );\n });\n\n it(\"uses a predefined spt\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: \"string\",\n });\n\n const FooInterface = defineInterface({\n apiName: \"FooInterface\",\n displayName: \"Foo Interface\",\n properties: {\n fooSpt,\n },\n icon: { color: \"#00000\", locator: \"airplane\" },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.FooInterface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.FooInterface\",\n \"displayMetadata\": {\n \"description\": \"Foo Interface\",\n \"displayName\": \"Foo Interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#00000\",\n \"locator\": \"airplane\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.fooSpt\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"properly serializes both types of struct SPTs\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: {\n type: \"struct\",\n structDefinition: {\n \"simpleProperty\": \"boolean\",\n \"complexProperty\": {\n fieldType: \"date\",\n displayMetadata: {\n displayName: \"complex property\",\n description: undefined,\n },\n },\n },\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"struct\": {\n \"structFields\": [\n {\n \"aliases\": [],\n \"apiName\": \"simpleProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"simpleProperty\",\n },\n \"fieldType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"typeClasses\": [],\n },\n {\n \"aliases\": [],\n \"apiName\": \"complexProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"complex property\",\n },\n \"fieldType\": {\n \"date\": {},\n \"type\": \"date\",\n },\n \"typeClasses\": [],\n },\n ],\n },\n \"type\": \"struct\",\n },\n \"typeClasses\": [],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom string fields properly set\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: {\n type: \"string\",\n isLongText: true,\n supportsEfficientLeadingWildcard: true,\n supportsExactMatching: false,\n },\n });\n\n defineInterface({\n apiName: \"interface\",\n properties: { foo: spt },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.interface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.interface\",\n \"displayMetadata\": {\n \"description\": \"interface\",\n \"displayName\": \"interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#4C90F0\",\n \"locator\": \"layout-hierarchy\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.foo\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n \"supportsFullTextRegex\": undefined,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom decimal fields properly set\", () => {\n const spt1 = defineSharedPropertyType({\n apiName: \"precision\",\n type: {\n type: \"decimal\",\n precision: 10,\n },\n });\n const spt2 = defineSharedPropertyType({\n apiName: \"scale\",\n type: {\n type: \"decimal\",\n scale: 5,\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.precision\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.precision\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"precision\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"decimal\": {\n \"precision\": 10,\n \"scale\": undefined,\n },\n \"type\": \"decimal\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n \"com.palantir.scale\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.scale\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"scale\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"decimal\": {\n \"precision\": undefined,\n \"scale\": 5,\n },\n \"type\": \"decimal\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,cAAc,EAAEC,wBAAwB,QAAQ,sBAAsB;AAC/E,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1DN,QAAQ,CAAC,MAAM,EAAE,MAAM;EACrBD,UAAU,CAAC,YAAY;IACrB,MAAMK,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFF,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpDI,wBAAwB,CAAC;MACvBC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFP,MAAM,CAAC,MAAM;MACXK,wBAAwB,CAAC;QACvBC,OAAO,EAAE,KAAK;QACdC,IAAI,EAAE;MACR,CAAC,CAAC;IACJ,CAAC,CAAC,CAACC,kCAAkC,CACnC,iFACF,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAChC,MAAMQ,MAAM,GAAGJ,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;IACR,CAAC,CAAC;IAEmBL,eAAe,CAAC;MACnCI,OAAO,EAAE,cAAc;MACvBI,WAAW,EAAE,eAAe;MAC5BC,UAAU,EAAE;QACVF;MACF,CAAC;MACDG,IAAI,EAAE;QAAEC,KAAK,EAAE,QAAQ;QAAEC,OAAO,EAAE;MAAW;IAC/C,CAAC,CAAC;IAEFd,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;EACR,CAAC,CAAC;EAEFf,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACzCI,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdU,gBAAgB,EAAE;UAChB,gBAAgB,EAAE,SAAS;UAC3B,iBAAiB,EAAE;YACjBC,SAAS,EAAE,MAAM;YACjBC,eAAe,EAAE;cACfT,WAAW,EAAE,kBAAkB;cAC/BU,WAAW,EAAEC;YACf;UACF;QACF;MACF;IACF,CAAC,CAAC;IAEFrB,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;EACV,CAAC,CAAC;EAEFf,EAAE,CAAC,mCAAmC,EAAE,MAAM;IAC5C,MAAMqB,GAAG,GAAGjB,wBAAwB,CAAC;MACnCC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;QACJA,IAAI,EAAE,QAAQ;QACdgB,UAAU,EAAE,IAAI;QAChBC,gCAAgC,EAAE,IAAI;QACtCC,qBAAqB,EAAE;MACzB;IACF,CAAC,CAAC;IAEFvB,eAAe,CAAC;MACdI,OAAO,EAAE,WAAW;MACpBK,UAAU,EAAE;QAAEe,GAAG,EAAEJ;MAAI;IACzB,CAAC,CAAC;IAEFtB,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFf,EAAE,CAAC,oCAAoC,EAAE,MAAM;IAChCI,wBAAwB,CAAC;MACpCC,OAAO,EAAE,WAAW;MACpBC,IAAI,EAAE;QACJA,IAAI,EAAE,SAAS;QACfoB,SAAS,EAAE;MACb;IACF,CAAC,CAAC;IACWtB,wBAAwB,CAAC;MACpCC,OAAO,EAAE,OAAO;MAChBC,IAAI,EAAE;QACJA,IAAI,EAAE,SAAS;QACfqB,KAAK,EAAE;MACT;IACF,CAAC,CAAC;IAEF5B,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -24,7 +24,7 @@ import { defineOntology } from "../api/defineOntology.js";
24
24
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
25
25
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
26
26
  export default async function main(args = process.argv) {
27
- const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.8" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
27
+ const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-rc.16" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
28
28
  input: {
29
29
  alias: "i",
30
30
  describe: "Input file",
@@ -68,6 +68,22 @@ export default async function main(args = process.argv) {
68
68
  type: "string",
69
69
  coerce: path.resolve
70
70
  },
71
+ generateCodeSnippets: {
72
+ describe: "Enable code snippet files creation",
73
+ type: "boolean",
74
+ default: false
75
+ },
76
+ codeSnippetPackageName: {
77
+ describe: "The package name that will be displayed in the code snippets",
78
+ default: "",
79
+ type: "string"
80
+ },
81
+ codeSnippetDir: {
82
+ describe: "Directory for generated code snippet files",
83
+ type: "string",
84
+ default: "./",
85
+ coerce: path.resolve
86
+ },
71
87
  randomnessKey: {
72
88
  describe: "Value used to assure uniqueness of entities",
73
89
  type: "string",
@@ -81,10 +97,13 @@ export default async function main(args = process.argv) {
81
97
  !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\.[a-z0-9-]+)*\.$") : invariant(false) : void 0;
82
98
  }
83
99
  consola.info(`Loading ontology from ${commandLineOpts.input}`);
100
+ if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path.resolve("./"))) {
101
+ consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
102
+ }
84
103
  if (commandLineOpts.randomnessKey !== undefined) {
85
104
  !uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant(false) : void 0;
86
105
  }
87
- const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
106
+ const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
88
107
  consola.info(`Saving ontology to ${commandLineOpts.output}`);
89
108
  await fs.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
90
109
  // No point in generating block if there aren't any value types
@@ -92,8 +111,8 @@ export default async function main(args = process.argv) {
92
111
  await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
93
112
  }
94
113
  }
95
- async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
96
- const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
114
+ async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
115
+ const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
97
116
  return q;
98
117
  }
99
118
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineOntology","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","q"],"sources":["main.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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.randomnessKey,\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\n randomnessKey,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eASL,GAAG,MAAMT,KAAK,CAACC,OAAO,CAACK,IAAI,CAAC,CAAC,CAC3BI,OAAO,CAAC,mBAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEb,KAAK,CAAC,CAAC,CAACc,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5CC,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,OAAO,CAAC;IACPC,KAAK,EAAE;MACLC,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,YAAY;MACtBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,uBAAuB;MAChCC,MAAM,EAAEzB,IAAI,CAAC0B;IACf,CAAC;IACDC,MAAM,EAAE;MACNN,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,aAAa;MACvBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,eAAe;MACxBC,MAAM,EAAEzB,IAAI,CAAC0B;IACf,CAAC;IACDE,YAAY,EAAE;MACZN,QAAQ,EAAE,+CAA+C;MACzDC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ACR,KAAK,CAAC,EAC/BU,SAAS,EACTmB,cAAc,EACdhB,aACF,CAAC;EACD,OAAOiB,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"main.js","names":["consola","fs","path","invariant","yargs","hideBin","defineOntology","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","snippetPackageName","q"],"sources":["main.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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets\n && (commandLineOpts.codeSnippetPackageName !== \"\"\n || commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0\n || ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,M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AAG,CAAC,IACxCO,UAAU,CAACM,kBAAkB,CAACD,UAAU,CAACZ,MAAM,GAAG,CAAC,EACtD;IACA,MAAMvC,EAAE,CAACgD,SAAS,CAChBpC,eAAe,CAACoB,gBAAgB,EAChCiB,IAAI,CAACC,SAAS,CACZJ,UAAU,CAACK,UAAU,EACrB,IAAI,EACJ,CACF,CACF,CAAC;EACH;AACF;AAEA,eAAeJ,YAAYA,CACzB1B,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7BsB,cAAkC,EAClCnB,oBAA6B,EAC7BoB,kBAA0B,EAC1BlB,cAAsB,EACtBC,aAAsB,EACtB;EACA,MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
@@ -17,14 +17,14 @@
17
17
  import { distributeTypeHelper } from "../toConjure/distributeTypeHelper.js";
18
18
  export function propertyTypeTypeToOntologyIrType(type) {
19
19
  switch (true) {
20
- case typeof type === "object" && "markingType" in type:
20
+ case typeof type === "object" && type.type === "marking":
21
21
  return {
22
22
  "type": "marking",
23
23
  marking: {
24
24
  markingType: type.markingType
25
25
  }
26
26
  };
27
- case typeof type === "object" && "structDefinition" in type:
27
+ case typeof type === "object" && type.type === "struct":
28
28
  const structFields = new Array();
29
29
  for (const key in type.structDefinition) {
30
30
  const fieldTypeDefinition = type.structDefinition[key];
@@ -71,15 +71,24 @@ export function propertyTypeTypeToOntologyIrType(type) {
71
71
  structFields
72
72
  }
73
73
  };
74
- case typeof type === "object" && "isLongText" in type:
74
+ case typeof type === "object" && type.type === "string":
75
75
  return {
76
76
  "type": "string",
77
77
  "string": {
78
78
  analyzerOverride: undefined,
79
- enableAsciiFolding: undefined,
80
- isLongText: type.isLongText,
81
- supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard,
82
- supportsExactMatching: type.supportsExactMatching
79
+ enableAsciiFolding: type.enableAsciiFolding,
80
+ isLongText: type.isLongText ?? false,
81
+ supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard ?? false,
82
+ supportsExactMatching: type.supportsExactMatching ?? true,
83
+ supportsFullTextRegex: type.supportsFullTextRegex
84
+ }
85
+ };
86
+ case typeof type === "object" && type.type === "decimal":
87
+ return {
88
+ "type": "decimal",
89
+ "decimal": {
90
+ precision: type.precision,
91
+ scale: type.scale
83
92
  }
84
93
  };
85
94
  case type === "geopoint":
@@ -118,6 +127,9 @@ export function propertyTypeTypeToOntologyIrType(type) {
118
127
  };
119
128
  default:
120
129
  // use helper function to distribute `type` properly
130
+ if (typeof type === "object") {
131
+ throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
132
+ }
121
133
  return distributeTypeHelper(type);
122
134
  }
123
135
  }