@osdk/generator 2.1.0-beta.0 → 2.1.0-beta.10

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 (72) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/build/browser/GenerateContext/GenerateContext.d.ts +1 -0
  3. package/build/browser/GenerateContext/GenerateContext.d.ts.map +1 -1
  4. package/build/browser/generateClientSdkPackage.test.js +2 -2
  5. package/build/browser/generateClientSdkPackage.test.js.map +1 -1
  6. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +6 -6
  7. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  8. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +12 -19
  9. package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  10. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
  11. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  12. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +3 -2
  13. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  14. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +67 -86
  15. package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  16. package/build/browser/v2.0/generatePerActionDataFiles.d.ts +1 -1
  17. package/build/browser/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
  18. package/build/browser/v2.0/generatePerActionDataFiles.js +5 -4
  19. package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
  20. package/build/browser/v2.0/generatePerInterfaceDataFiles.js +4 -3
  21. package/build/browser/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
  22. package/build/browser/v2.0/generatePerObjectDataFiles.d.ts.map +1 -1
  23. package/build/browser/v2.0/generatePerObjectDataFiles.js +1 -1
  24. package/build/browser/v2.0/generatePerObjectDataFiles.js.map +1 -1
  25. package/build/browser/v2.0/generatePerQueryDataFiles.d.ts +1 -1
  26. package/build/browser/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
  27. package/build/browser/v2.0/generatePerQueryDataFiles.js +30 -16
  28. package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
  29. package/build/browser/v2.0/generatePerQueryDataFiles.test.js +259 -7
  30. package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
  31. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +0 -1
  32. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  33. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +14 -12
  34. package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  35. package/build/browser/validateWireOntologyAssumptions.js +2 -2
  36. package/build/browser/validateWireOntologyAssumptions.js.map +1 -1
  37. package/build/esm/GenerateContext/GenerateContext.d.ts +1 -0
  38. package/build/esm/GenerateContext/GenerateContext.d.ts.map +1 -1
  39. package/build/esm/generateClientSdkPackage.test.js +2 -2
  40. package/build/esm/generateClientSdkPackage.test.js.map +1 -1
  41. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +6 -6
  42. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
  43. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +12 -19
  44. package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
  45. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
  46. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  47. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +3 -2
  48. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
  49. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +67 -86
  50. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
  51. package/build/esm/v2.0/generatePerActionDataFiles.d.ts +1 -1
  52. package/build/esm/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
  53. package/build/esm/v2.0/generatePerActionDataFiles.js +5 -4
  54. package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
  55. package/build/esm/v2.0/generatePerInterfaceDataFiles.js +4 -3
  56. package/build/esm/v2.0/generatePerInterfaceDataFiles.js.map +1 -1
  57. package/build/esm/v2.0/generatePerObjectDataFiles.d.ts.map +1 -1
  58. package/build/esm/v2.0/generatePerObjectDataFiles.js +1 -1
  59. package/build/esm/v2.0/generatePerObjectDataFiles.js.map +1 -1
  60. package/build/esm/v2.0/generatePerQueryDataFiles.d.ts +1 -1
  61. package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
  62. package/build/esm/v2.0/generatePerQueryDataFiles.js +30 -16
  63. package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
  64. package/build/esm/v2.0/generatePerQueryDataFiles.test.js +259 -7
  65. package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
  66. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +0 -1
  67. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
  68. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +14 -12
  69. package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
  70. package/build/esm/validateWireOntologyAssumptions.js +2 -2
  71. package/build/esm/validateWireOntologyAssumptions.js.map +1 -1
  72. package/package.json +11 -9
@@ -32,21 +32,21 @@ describe("generatePerQueryDataFiles", () => {
32
32
  externalSpts: new Map()
33
33
  }),
34
34
  outDir: "/foo",
35
- importExt: ".js"
35
+ importExt: ".js",
36
+ forInternalUse: true
36
37
  }, true);
37
38
  expect(helper.getFiles()).toMatchInlineSnapshot(`
38
39
  {
39
40
  "/foo/ontology/queries.ts": "export { getCount } from './queries/getCount.js';
40
41
  export { returnsTodo } from './queries/returnsTodo.js';
41
42
  ",
42
- "/foo/ontology/queries/getCount.ts": "import type { QueryDefinition, VersionBound } from '@osdk/api';
43
- import type { QueryParam, QueryResult } from '@osdk/api';
43
+ "/foo/ontology/queries/getCount.ts": "import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';
44
44
  import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
45
45
  import { $osdkMetadata } from '../../OntologyMetadata.js';
46
46
 
47
47
  export namespace getCount {
48
48
  export interface Signature {
49
- (query: getCount.Parameters): Promise<QueryResult.PrimitiveType<'integer'>>;
49
+ (query: getCount.Parameters): Promise<getCount.ReturnType>;
50
50
  }
51
51
 
52
52
  export interface Parameters {
@@ -55,6 +55,8 @@ describe("generatePerQueryDataFiles", () => {
55
55
  */
56
56
  readonly completed: QueryParam.PrimitiveType<'boolean'>;
57
57
  }
58
+
59
+ export type ReturnType = QueryResult.PrimitiveType<'integer'>;
58
60
  }
59
61
 
60
62
  export interface getCount extends QueryDefinition<getCount.Signature>, VersionBound<$ExpectedClientVersion> {
@@ -91,15 +93,14 @@ describe("generatePerQueryDataFiles", () => {
91
93
  osdkMetadata: $osdkMetadata,
92
94
  };
93
95
  ",
94
- "/foo/ontology/queries/returnsTodo.ts": "import type { QueryDefinition, VersionBound } from '@osdk/api';
95
- import type { QueryParam, QueryResult } from '@osdk/api';
96
+ "/foo/ontology/queries/returnsTodo.ts": "import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';
96
97
  import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
97
98
  import { $osdkMetadata } from '../../OntologyMetadata.js';
98
99
  import type { Todo } from '../objects/Todo.js';
99
100
 
100
101
  export namespace returnsTodo {
101
102
  export interface Signature {
102
- (query: returnsTodo.Parameters): Promise<QueryResult.ObjectType<Todo>>;
103
+ (query: returnsTodo.Parameters): Promise<returnsTodo.ReturnType>;
103
104
  }
104
105
 
105
106
  export interface Parameters {
@@ -108,6 +109,8 @@ describe("generatePerQueryDataFiles", () => {
108
109
  */
109
110
  readonly someTodo: QueryParam.ObjectType<Todo>;
110
111
  }
112
+
113
+ export type ReturnType = QueryResult.ObjectType<Todo>;
111
114
  }
112
115
 
113
116
  export interface returnsTodo extends QueryDefinition<returnsTodo.Signature>, VersionBound<$ExpectedClientVersion> {
@@ -197,5 +200,254 @@ describe("generatePerQueryDataFiles", () => {
197
200
  console.log(q);
198
201
  ts.createDocumentRegistry();
199
202
  });
203
+ it("generates structs for queries", async () => {
204
+ const helper = createMockMinimalFiles();
205
+ await generatePerQueryDataFilesV2({
206
+ fs: helper.minimalFiles,
207
+ ontology: enhanceOntology({
208
+ sanitized: {
209
+ actionTypes: {},
210
+ interfaceTypes: {},
211
+ objectTypes: {},
212
+ ontology: {
213
+ apiName: "foo",
214
+ description: "foo",
215
+ displayName: "foo",
216
+ rid: "ri.foo"
217
+ },
218
+ queryTypes: {
219
+ doThing: {
220
+ rid: "rid.query.1",
221
+ version: "0",
222
+ apiName: "doThing",
223
+ parameters: {
224
+ foo: {
225
+ dataType: {
226
+ type: "string"
227
+ }
228
+ },
229
+ paramStruct: {
230
+ dataType: {
231
+ type: "struct",
232
+ fields: [{
233
+ name: "aDate",
234
+ fieldType: {
235
+ type: "date"
236
+ }
237
+ }, {
238
+ name: "nestedStruct",
239
+ fieldType: {
240
+ type: "struct",
241
+ fields: [{
242
+ name: "nestedString",
243
+ fieldType: {
244
+ type: "string"
245
+ }
246
+ }, {
247
+ name: "nestedInteger",
248
+ fieldType: {
249
+ type: "integer"
250
+ }
251
+ }]
252
+ }
253
+ }]
254
+ }
255
+ }
256
+ },
257
+ output: {
258
+ type: "struct",
259
+ fields: [{
260
+ name: "aString",
261
+ fieldType: {
262
+ type: "string"
263
+ }
264
+ }, {
265
+ name: "anInteger",
266
+ fieldType: {
267
+ type: "integer"
268
+ }
269
+ }, {
270
+ name: "aLong",
271
+ fieldType: {
272
+ type: "long"
273
+ }
274
+ }, {
275
+ name: "aDate",
276
+ fieldType: {
277
+ type: "date"
278
+ }
279
+ }, {
280
+ name: "nestedStruct",
281
+ fieldType: {
282
+ type: "struct",
283
+ fields: [{
284
+ name: "nestedString",
285
+ fieldType: {
286
+ type: "string"
287
+ }
288
+ }, {
289
+ name: "nestedInteger",
290
+ fieldType: {
291
+ type: "integer"
292
+ }
293
+ }]
294
+ }
295
+ }]
296
+ }
297
+ }
298
+ },
299
+ sharedPropertyTypes: {}
300
+ },
301
+ importExt: ".js",
302
+ externalObjects: new Map(),
303
+ externalInterfaces: new Map(),
304
+ externalSpts: new Map()
305
+ }),
306
+ outDir: "/foo",
307
+ importExt: ".js",
308
+ forInternalUse: true
309
+ }, true);
310
+ expect(helper.getFiles()["/foo/ontology/queries/doThing.ts"]).toMatchInlineSnapshot(`
311
+ "import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';
312
+ import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
313
+ import { $osdkMetadata } from '../../OntologyMetadata.js';
314
+
315
+ export namespace doThing {
316
+ export interface Signature {
317
+ (query: doThing.Parameters): Promise<doThing.ReturnType>;
318
+ }
319
+
320
+ export interface Parameters {
321
+ /**
322
+ * (no ontology metadata)
323
+ */
324
+ readonly foo: QueryParam.PrimitiveType<'string'>;
325
+
326
+ /**
327
+ * (no ontology metadata)
328
+ */
329
+ readonly paramStruct: {
330
+ readonly aDate: QueryParam.PrimitiveType<'datetime'>;
331
+
332
+ readonly nestedStruct: {
333
+ readonly nestedInteger: QueryParam.PrimitiveType<'integer'>;
334
+
335
+ readonly nestedString: QueryParam.PrimitiveType<'string'>;
336
+ };
337
+ };
338
+ }
339
+
340
+ export interface ReturnType {
341
+ aDate: QueryResult.PrimitiveType<'datetime'>;
342
+
343
+ aLong: QueryResult.PrimitiveType<'long'>;
344
+
345
+ anInteger: QueryResult.PrimitiveType<'integer'>;
346
+
347
+ aString: QueryResult.PrimitiveType<'string'>;
348
+
349
+ nestedStruct: {
350
+ nestedInteger: QueryResult.PrimitiveType<'integer'>;
351
+
352
+ nestedString: QueryResult.PrimitiveType<'string'>;
353
+ };
354
+ }
355
+ }
356
+
357
+ export interface doThing extends QueryDefinition<doThing.Signature>, VersionBound<$ExpectedClientVersion> {
358
+ __DefinitionMetadata?: {
359
+ apiName: 'doThing';
360
+ rid: 'rid.query.1';
361
+ type: 'query';
362
+ version: '0';
363
+ parameters: {
364
+ /**
365
+ * (no ontology metadata)
366
+ */
367
+ foo: {
368
+ nullable: false;
369
+ type: 'string';
370
+ };
371
+ /**
372
+ * (no ontology metadata)
373
+ */
374
+ paramStruct: {
375
+ nullable: false;
376
+ struct: {
377
+ aDate: {
378
+ type: 'date';
379
+ nullable: false;
380
+ };
381
+ nestedStruct: {
382
+ type: 'struct';
383
+ struct: {
384
+ nestedString: {
385
+ type: 'string';
386
+ nullable: false;
387
+ };
388
+ nestedInteger: {
389
+ type: 'integer';
390
+ nullable: false;
391
+ };
392
+ };
393
+ nullable: false;
394
+ };
395
+ };
396
+ type: 'struct';
397
+ };
398
+ };
399
+ output: {
400
+ nullable: false;
401
+ struct: {
402
+ aString: {
403
+ type: 'string';
404
+ nullable: false;
405
+ };
406
+ anInteger: {
407
+ type: 'integer';
408
+ nullable: false;
409
+ };
410
+ aLong: {
411
+ type: 'long';
412
+ nullable: false;
413
+ };
414
+ aDate: {
415
+ type: 'date';
416
+ nullable: false;
417
+ };
418
+ nestedStruct: {
419
+ type: 'struct';
420
+ struct: {
421
+ nestedString: {
422
+ type: 'string';
423
+ nullable: false;
424
+ };
425
+ nestedInteger: {
426
+ type: 'integer';
427
+ nullable: false;
428
+ };
429
+ };
430
+ nullable: false;
431
+ };
432
+ };
433
+ type: 'struct';
434
+ };
435
+ signature: doThing.Signature;
436
+ };
437
+ apiName: 'doThing';
438
+ type: 'query';
439
+ version: '0';
440
+ osdkMetadata: typeof $osdkMetadata;
441
+ }
442
+
443
+ export const doThing: doThing = {
444
+ apiName: 'doThing',
445
+ type: 'query',
446
+ version: '0',
447
+ osdkMetadata: $osdkMetadata,
448
+ };
449
+ "
450
+ `);
451
+ });
200
452
  });
201
453
  //# sourceMappingURL=generatePerQueryDataFiles.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generatePerQueryDataFiles.test.js","names":["ts","describe","expect","it","enhanceOntology","createMockMinimalFiles","TodoWireOntology","generatePerQueryDataFilesV2","helper","fs","minimalFiles","ontology","sanitized","importExt","externalObjects","Map","externalInterfaces","externalSpts","outDir","getFiles","toMatchInlineSnapshot","writeFile","rootFileNames","Object","keys","console","log","files","forEach","fileName","version","servicesHost","getScriptFileNames","getScriptVersion","toString","getScriptSnapshot","undefined","ScriptSnapshot","fromString","getCurrentDirectory","getCompilationSettings","getDefaultLibFileName","options","getDefaultLibFilePath","fileExists","path","readFile","readDirectory","extensions","exclude","include","depth","sys","directoryExists","getDirectories","langServices","createLanguageService","q","getDocCommentTemplateAtPosition","createDocumentRegistry"],"sources":["generatePerQueryDataFiles.test.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as ts from \"typescript\";\nimport { describe, expect, it } from \"vitest\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { createMockMinimalFiles } from \"../util/test/createMockMinimalFiles.js\";\nimport { TodoWireOntology } from \"../util/test/TodoWireOntology.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\ndescribe(\"generatePerQueryDataFiles\", () => {\n it(\"is stable v2\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n await generatePerQueryDataFilesV2({\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: TodoWireOntology,\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n }, true);\n expect(helper.getFiles()).toMatchInlineSnapshot(`\n {\n \"/foo/ontology/queries.ts\": \"export { getCount } from './queries/getCount.js';\n export { returnsTodo } from './queries/returnsTodo.js';\n \",\n \"/foo/ontology/queries/getCount.ts\": \"import type { QueryDefinition, VersionBound } from '@osdk/api';\n import type { QueryParam, QueryResult } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace getCount {\n export interface Signature {\n (query: getCount.Parameters): Promise<QueryResult.PrimitiveType<'integer'>>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly completed: QueryParam.PrimitiveType<'boolean'>;\n }\n }\n\n export interface getCount extends QueryDefinition<getCount.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'getCount';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * (no ontology metadata)\n */\n completed: {\n nullable: false;\n type: 'boolean';\n };\n };\n output: {\n nullable: false;\n type: 'integer';\n };\n signature: getCount.Signature;\n };\n apiName: 'getCount';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const getCount: getCount = {\n apiName: 'getCount',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n \"/foo/ontology/queries/returnsTodo.ts\": \"import type { QueryDefinition, VersionBound } from '@osdk/api';\n import type { QueryParam, QueryResult } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n import type { Todo } from '../objects/Todo.js';\n\n export namespace returnsTodo {\n export interface Signature {\n (query: returnsTodo.Parameters): Promise<QueryResult.ObjectType<Todo>>;\n }\n\n export interface Parameters {\n /**\n * description: Random desc so we test jsdoc\n */\n readonly someTodo: QueryParam.ObjectType<Todo>;\n }\n }\n\n export interface returnsTodo extends QueryDefinition<returnsTodo.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'returnsTodo';\n rid: 'rid.query.2';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * description: Random desc so we test jsdoc\n */\n someTodo: {\n description: 'Random desc so we test jsdoc';\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n };\n output: {\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n signature: returnsTodo.Signature;\n };\n apiName: 'returnsTodo';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const returnsTodo: returnsTodo = {\n apiName: 'returnsTodo',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n }\n `);\n await helper.minimalFiles.writeFile(\"/bar/test.ts\", `\n import {returnsTodo} from \"/foo/ontology/queries/returnsTodo.ts\";\n\n returnsTodo({someTodo:/*marker*/})\n `);\n const rootFileNames = Object.keys(helper.getFiles());\n console.log(rootFileNames);\n const files = {};\n // initialize the list of files\n rootFileNames.forEach(fileName => {\n files[fileName] = { version: 0 };\n });\n const servicesHost = {\n getScriptFileNames: () => Object.keys(helper.getFiles()),\n getScriptVersion: fileName => files[fileName] && files[fileName].version.toString(),\n getScriptSnapshot: fileName => {\n if (!helper.getFiles()[fileName]) {\n return undefined;\n }\n return ts.ScriptSnapshot.fromString(helper.getFiles()[fileName]);\n },\n getCurrentDirectory: () => \"/bar\",\n getCompilationSettings: () => ({}),\n getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),\n fileExists: (path) => {\n console.log(path);\n return helper.getFiles()[path] !== undefined;\n },\n readFile: (path) => {\n console.log(\"readFile: \", path);\n return helper.getFiles()[path];\n },\n readDirectory: (path, extensions, exclude, include, depth) => {\n console.log(\"readDirectory\", path);\n return ts.sys.readDirectory(path, extensions, exclude, include, depth);\n },\n directoryExists: ts.sys.directoryExists,\n getDirectories: ts.sys.getDirectories,\n };\n const langServices = ts.createLanguageService(servicesHost);\n const q = langServices.getDocCommentTemplateAtPosition(\"/bar/test.ts\", 1);\n console.log(q);\n ts.createDocumentRegistry();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,EAAE,MAAM,YAAY;AAChC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,sBAAsB,QAAQ,wCAAwC;AAC/E,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5EN,QAAQ,CAAC,2BAA2B,EAAE,MAAM;EACxCE,EAAE,CAAC,cAAc,EAAE,YAAY;IAC3B,MAAMK,MAAM,GAAGH,sBAAsB,CAAC,CAAC;IAEvC,MAAME,2BAA2B,CAAC;MAC9BE,EAAE,EAAED,MAAM,CAACE,YAAY;MACvBC,QAAQ,EAAEP,eAAe,CAAC;QACtBQ,SAAS,EAAEN,gBAAgB;QAC3BO,SAAS,EAAE,KAAK;QAChBC,eAAe,EAAE,IAAIC,GAAG,CAAC,CAAC;QAC1BC,kBAAkB,EAAE,IAAID,GAAG,CAAC,CAAC;QAC7BE,YAAY,EAAE,IAAIF,GAAG,CAAC;MAC1B,CAAC,CAAC;MACFG,MAAM,EAVQ,MAUG;MACjBL,SAAS,EAAE;IACf,CAAC,EAAE,IAAI,CAAC;IACRX,MAAM,CAACM,MAAM,CAACW,QAAQ,CAAC,CAAC,CAAC,CAACC,qBAAqB,CAAC;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;IACE,MAAMZ,MAAM,CAACE,YAAY,CAACW,SAAS,CAAC,cAAc,EAAE;AAC5D;AACA;AACA;AACA,KAAK,CAAC;IACE,MAAMC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAAChB,MAAM,CAACW,QAAQ,CAAC,CAAC,CAAC;IACpDM,OAAO,CAACC,GAAG,CAACJ,aAAa,CAAC;IAC1B,MAAMK,KAAK,GAAG,CAAC,CAAC;IAChB;IACAL,aAAa,CAACM,OAAO,CAACC,QAAQ,IAAI;MAC9BF,KAAK,CAACE,QAAQ,CAAC,GAAG;QAAEC,OAAO,EAAE;MAAE,CAAC;IACpC,CAAC,CAAC;IACF,MAAMC,YAAY,GAAG;MACjBC,kBAAkB,EAAEA,CAAA,KAAMT,MAAM,CAACC,IAAI,CAAChB,MAAM,CAACW,QAAQ,CAAC,CAAC,CAAC;MACxDc,gBAAgB,EAAEJ,QAAQ,IAAIF,KAAK,CAACE,QAA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C3B,CAAC;IACD,MAAMC,YAAY,GAAGvD,EAAE,CAACwD,qBAAqB,CAACzB,YAAY,CAAC;IAC3D,MAAM0B,CAAC,GAAGF,YAAY,CAACG,+BAA+B,CAAC,cAAc,EAAE,CAAC,CAAC;IACzEjC,OAAO,CAACC,GAAG,CAAC+B,CAAC,CAAC;IACdzD,EAAE,CAAC2D,sBAAsB,CAAC,CAAC;EAC/B,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"generatePerQueryDataFiles.test.js","names":["ts","describe","expect","it","enhanceOntology","createMockMinimalFiles","TodoWireOntology","generatePerQueryDataFilesV2","helper","fs","minimalFiles","ontology","sanitized","importExt","externalObjects","Map","externalInterfaces","externalSpts","outDir","forInternalUse","getFiles","toMatchInlineSnapshot","writeFile","rootFileNames","Object","keys","console","log","files","forEach","fileName","version","servicesHost","getScriptFileNames","getScriptVersion","toString","getScriptSnapshot","undefined","ScriptSnapshot","fromString","getCurrentDirectory","getCompilationSettings","getDefaultLibFileName","options","getDefaultLibFilePath","fileExists","path","readFile","readDirectory","extensions","exclude","include","depth","sys","directoryExists","getDirectories","langServices","createLanguageService","q","getDocCommentTemplateAtPosition","createDocumentRegistry","actionTypes","interfaceTypes","objectTypes","apiName","description","displayName","rid","queryTypes","doThing","parameters","foo","dataType","type","paramStruct","fields","name","fieldType","output","sharedPropertyTypes"],"sources":["generatePerQueryDataFiles.test.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as ts from \"typescript\";\nimport { describe, expect, it } from \"vitest\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { createMockMinimalFiles } from \"../util/test/createMockMinimalFiles.js\";\nimport { TodoWireOntology } from \"../util/test/TodoWireOntology.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\ndescribe(\"generatePerQueryDataFiles\", () => {\n it(\"is stable v2\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n await generatePerQueryDataFilesV2({\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: TodoWireOntology,\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n }, true);\n expect(helper.getFiles()).toMatchInlineSnapshot(`\n {\n \"/foo/ontology/queries.ts\": \"export { getCount } from './queries/getCount.js';\n export { returnsTodo } from './queries/returnsTodo.js';\n \",\n \"/foo/ontology/queries/getCount.ts\": \"import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace getCount {\n export interface Signature {\n (query: getCount.Parameters): Promise<getCount.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly completed: QueryParam.PrimitiveType<'boolean'>;\n }\n\n export type ReturnType = QueryResult.PrimitiveType<'integer'>;\n }\n\n export interface getCount extends QueryDefinition<getCount.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'getCount';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * (no ontology metadata)\n */\n completed: {\n nullable: false;\n type: 'boolean';\n };\n };\n output: {\n nullable: false;\n type: 'integer';\n };\n signature: getCount.Signature;\n };\n apiName: 'getCount';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const getCount: getCount = {\n apiName: 'getCount',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n \"/foo/ontology/queries/returnsTodo.ts\": \"import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n import type { Todo } from '../objects/Todo.js';\n\n export namespace returnsTodo {\n export interface Signature {\n (query: returnsTodo.Parameters): Promise<returnsTodo.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * description: Random desc so we test jsdoc\n */\n readonly someTodo: QueryParam.ObjectType<Todo>;\n }\n\n export type ReturnType = QueryResult.ObjectType<Todo>;\n }\n\n export interface returnsTodo extends QueryDefinition<returnsTodo.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'returnsTodo';\n rid: 'rid.query.2';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * description: Random desc so we test jsdoc\n */\n someTodo: {\n description: 'Random desc so we test jsdoc';\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n };\n output: {\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n signature: returnsTodo.Signature;\n };\n apiName: 'returnsTodo';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const returnsTodo: returnsTodo = {\n apiName: 'returnsTodo',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n }\n `);\n await helper.minimalFiles.writeFile(\"/bar/test.ts\", `\n import {returnsTodo} from \"/foo/ontology/queries/returnsTodo.ts\";\n\n returnsTodo({someTodo:/*marker*/})\n `);\n const rootFileNames = Object.keys(helper.getFiles());\n console.log(rootFileNames);\n const files = {};\n // initialize the list of files\n rootFileNames.forEach(fileName => {\n files[fileName] = { version: 0 };\n });\n const servicesHost = {\n getScriptFileNames: () => Object.keys(helper.getFiles()),\n getScriptVersion: fileName => files[fileName] && files[fileName].version.toString(),\n getScriptSnapshot: fileName => {\n if (!helper.getFiles()[fileName]) {\n return undefined;\n }\n return ts.ScriptSnapshot.fromString(helper.getFiles()[fileName]);\n },\n getCurrentDirectory: () => \"/bar\",\n getCompilationSettings: () => ({}),\n getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),\n fileExists: (path) => {\n console.log(path);\n return helper.getFiles()[path] !== undefined;\n },\n readFile: (path) => {\n console.log(\"readFile: \", path);\n return helper.getFiles()[path];\n },\n readDirectory: (path, extensions, exclude, include, depth) => {\n console.log(\"readDirectory\", path);\n return ts.sys.readDirectory(path, extensions, exclude, include, depth);\n },\n directoryExists: ts.sys.directoryExists,\n getDirectories: ts.sys.getDirectories,\n };\n const langServices = ts.createLanguageService(servicesHost);\n const q = langServices.getDocCommentTemplateAtPosition(\"/bar/test.ts\", 1);\n console.log(q);\n ts.createDocumentRegistry();\n });\n it(\"generates structs for queries\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n await generatePerQueryDataFilesV2({\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: {\n actionTypes: {},\n interfaceTypes: {},\n objectTypes: {},\n ontology: {\n apiName: \"foo\",\n description: \"foo\",\n displayName: \"foo\",\n rid: \"ri.foo\",\n },\n queryTypes: {\n doThing: {\n rid: \"rid.query.1\",\n version: \"0\",\n apiName: \"doThing\",\n parameters: {\n foo: {\n dataType: { type: \"string\" },\n },\n paramStruct: {\n dataType: {\n type: \"struct\",\n fields: [\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n output: {\n type: \"struct\",\n fields: [\n {\n name: \"aString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"anInteger\",\n fieldType: { type: \"integer\" },\n },\n {\n name: \"aLong\",\n fieldType: { type: \"long\" },\n },\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n sharedPropertyTypes: {},\n },\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n }, true);\n expect(helper.getFiles()[\"/foo/ontology/queries/doThing.ts\"])\n .toMatchInlineSnapshot(`\n \"import type { QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace doThing {\n export interface Signature {\n (query: doThing.Parameters): Promise<doThing.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly foo: QueryParam.PrimitiveType<'string'>;\n\n /**\n * (no ontology metadata)\n */\n readonly paramStruct: {\n readonly aDate: QueryParam.PrimitiveType<'datetime'>;\n\n readonly nestedStruct: {\n readonly nestedInteger: QueryParam.PrimitiveType<'integer'>;\n\n readonly nestedString: QueryParam.PrimitiveType<'string'>;\n };\n };\n }\n\n export interface ReturnType {\n aDate: QueryResult.PrimitiveType<'datetime'>;\n\n aLong: QueryResult.PrimitiveType<'long'>;\n\n anInteger: QueryResult.PrimitiveType<'integer'>;\n\n aString: QueryResult.PrimitiveType<'string'>;\n\n nestedStruct: {\n nestedInteger: QueryResult.PrimitiveType<'integer'>;\n\n nestedString: QueryResult.PrimitiveType<'string'>;\n };\n }\n }\n\n export interface doThing extends QueryDefinition<doThing.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'doThing';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * (no ontology metadata)\n */\n foo: {\n nullable: false;\n type: 'string';\n };\n /**\n * (no ontology metadata)\n */\n paramStruct: {\n nullable: false;\n struct: {\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n };\n output: {\n nullable: false;\n struct: {\n aString: {\n type: 'string';\n nullable: false;\n };\n anInteger: {\n type: 'integer';\n nullable: false;\n };\n aLong: {\n type: 'long';\n nullable: false;\n };\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n signature: doThing.Signature;\n };\n apiName: 'doThing';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const doThing: doThing = {\n apiName: 'doThing',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,EAAE,MAAM,YAAY;AAChC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,sBAAsB,QAAQ,wCAAwC;AAC/E,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5EN,QAAQ,CAAC,2BAA2B,EAAE,MAAM;EACxCE,EAAE,CAAC,cAAc,EAAE,YAAY;IAC3B,MAAMK,MAAM,GAAGH,sBAAsB,CAAC,CAAC;IAEvC,MAAME,2BAA2B,CAAC;MAC9BE,EAAE,EAAED,MAAM,CAACE,YAAY;MACvBC,QAAQ,EAAEP,eAAe,CAAC;QACtBQ,SAAS,EAAEN,gBAAgB;QAC3BO,SAAS,EAAE,KAAK;QAChBC,eAAe,EAAE,IAAIC,GAAG,CAAC,CAAC;QAC1BC,kBAAkB,EAAE,IAAID,GAAG,CAAC,CAAC;QAC7BE,YAAY,EAAE,IAAIF,GAAG,CAAC;MAC1B,CAAC,CAAC;MACFG,MAAM,EAVQ,MAUG;MACjBL,SAAS,EAAE,KAAK;MAChBM,cAAc,EAAE;IACpB,CAAC,EAAE,IAAI,CAAC;IACRjB,MAAM,CAACM,MAAM,CAACY,QAAQ,CAAC,CAAC,CAAC,CAACC,qBAAqB,CAAC;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;IACE,MAAMb,MAAM,CAACE,YAAY,CAACY,SAAS,CAAC,cAAc,EAAE;AAC5D;AACA;AACA;AACA,KAAK,CAAC;IACE,MAAMC,aAAa,GAAGC,MAAM,CAACC,IAAI,CAACjB,MAAM,CAACY,QAA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sBACIG,IAAI,EAAE,eAAe;sBACrBC,SAAS,EAAE;wBAAEJ,IAAI,EAAE;sBAAU;oBACjC,CAAC;kBAET;gBACJ,CAAC;cAET;YACJ;UACJ,CAAC;UACDM,mBAAmB,EAAE,CAAC;QAC1B,CAAC;QACDlE,SAAS,EAAE,KAAK;QAChBC,eAAe,EAAE,IAAIC,GAAG,CAAC,CAAC;QAC1BC,kBAAkB,EAAE,IAAID,GAAG,CAAC,CAAC;QAC7BE,YAAY,EAAE,IAAIF,GAAG,CAAC;MAC1B,CAAC,CAAC;MACFG,MAAM,EAjGQ,MAiGG;MACjBL,SAAS,EAAE,KAAK;MAChBM,cAAc,EAAE;IACpB,CAAC,EAAE,IAAI,CAAC;IACRjB,MAAM,CAACM,MAAM,CAACY,QAAQ,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CACxDC,qBAAqB,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACJ,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import type { EnhancedInterfaceType } from "../GenerateContext/EnhancedInterfaceType.js";
2
2
  import { EnhancedObjectType } from "../GenerateContext/EnhancedObjectType.js";
3
3
  import type { EnhancedOntologyDefinition } from "../GenerateContext/EnhancedOntologyDefinition.js";
4
- export declare function getObjectDefIdentifier(name: string, v2: boolean): string;
5
4
  export interface Identifiers extends Record<"osdkObjectIdentifier" | "propertyKeysIdentifier" | "osdkObjectPropsIdentifier" | "objectDefIdentifier" | "osdkObjectLinksIdentifier" | "osdkObjectStrictPropsIdentifier" | "objectSetIdentifier", string> {
6
5
  }
7
6
  export declare function createOsdkObject(object: EnhancedObjectType | EnhancedInterfaceType, identifier: string, { osdkObjectPropsIdentifier, objectDefIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }: Identifiers): string;
@@ -1 +1 @@
1
- {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.d.ts","sourceRoot":"","sources":["../../../src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAQnG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,UAE/D;AAwGD,MAAM,WAAW,WAAY,SAC3B,MAAM,CACF,sBAAsB,GACtB,wBAAwB,GACxB,2BAA2B,GAC3B,qBAAqB,GACrB,2BAA2B,GAC3B,iCAAiC,GACjC,qBAAqB,EACvB,MAAM,CACP;CACD;AAEF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,UAAU,EAAE,MAAM,EAClB,EACE,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,yBAAyB,GAC1B,EAAE,WAAW,UAsBf;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,EACE,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,EAAE,WAAW,UAYf;AAeD,wBAAgB,WAAW,CACzB,IAAI,EAAE,qBAAqB,GAAG,kBAAkB,EAChD,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,UAoBhB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,QAAQ,EAAE,0BAA0B,EACpC,UAAU,EAAE,MAAM,EAClB,EACE,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,+BAA+B,EAC/B,yBAAyB,GAC1B,EAAE,WAAW,UAmDf;AAED,wBAAgB,WAAW,CACzB,QAAQ,EAAE,0BAA0B,EACpC,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,UAAU,EAAE,MAAM,UAiCnB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,kBAAkB,GAAG,qBAAqB,UAOjD"}
1
+ {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.d.ts","sourceRoot":"","sources":["../../../src/v2.0/wireObjectTypeV2ToSdkObjectConstV2.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAiHnG,MAAM,WAAW,WAAY,SAC3B,MAAM,CACF,sBAAsB,GACtB,wBAAwB,GACxB,2BAA2B,GAC3B,qBAAqB,GACrB,2BAA2B,GAC3B,iCAAiC,GACjC,qBAAqB,EACvB,MAAM,CACP;CACD;AAEF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,UAAU,EAAE,MAAM,EAClB,EACE,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,yBAAyB,GAC1B,EAAE,WAAW,UAsBf;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,EACE,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,EAAE,WAAW,UAYf;AAeD,wBAAgB,WAAW,CACzB,IAAI,EAAE,qBAAqB,GAAG,kBAAkB,EAChD,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,UA8BhB;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,QAAQ,EAAE,0BAA0B,EACpC,UAAU,EAAE,MAAM,EAClB,EACE,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,+BAA+B,EAC/B,yBAAyB,GAC1B,EAAE,WAAW,UAmDf;AAED,wBAAgB,WAAW,CACzB,QAAQ,EAAE,0BAA0B,EACpC,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,EAClD,UAAU,EAAE,MAAM,UAiCnB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,kBAAkB,GAAG,qBAAqB,UAUjD"}
@@ -20,12 +20,10 @@ import { getObjectImports } from "../shared/getObjectImports.js";
20
20
  import { propertyJsdoc } from "../shared/propertyJsdoc.js";
21
21
  import { deleteUndefineds } from "../util/deleteUndefineds.js";
22
22
  import { stringify } from "../util/stringify.js";
23
- export function getObjectDefIdentifier(name, v2) {
24
- return v2 ? name : `${name}Def`;
25
- }
26
23
  /** @internal */
27
24
  export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
28
- ontology
25
+ ontology,
26
+ forInternalUse
29
27
  }, currentFilePath) {
30
28
  const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
31
29
  if (object instanceof ForeignType) {
@@ -51,19 +49,19 @@ export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
51
49
  propertyKeysIdentifier
52
50
  };
53
51
  const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
54
- return `${imports}${function (object) {
52
+ return `${imports}${function (object, forInternalUse = false) {
55
53
  return `import type {
56
54
  PropertyKeys as $PropertyKeys,
57
55
  ObjectTypeDefinition as $ObjectTypeDefinition,
58
56
  ObjectMetadata as $ObjectMetadata,
59
- } from "@osdk/api";
57
+ } from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
60
58
  import type {
61
59
  ObjectSet as $ObjectSet,
62
60
  Osdk as $Osdk,
63
61
  OsdkObject as $OsdkObject,
64
62
  PropertyValueWireToClient as $PropType,
65
63
  SingleLinkAccessor as $SingleLinkAccessor,
66
- } from "@osdk/api";
64
+ } from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
67
65
 
68
66
 
69
67
  export namespace ${object.shortApiName} {
@@ -85,7 +83,7 @@ export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
85
83
 
86
84
  ${createDefinition(object, ontology, object.shortApiName, identifiers)}
87
85
  `;
88
- }(object)}
86
+ }(object, forInternalUse)}
89
87
 
90
88
  export const ${object.shortApiName}: ${objectDefIdentifier}
91
89
  = {
@@ -103,7 +101,7 @@ export function createOsdkObject(object, identifier, {
103
101
  object.getCleanedUpDefinition(true);
104
102
  return `
105
103
  export type ${identifier}<
106
- OPTIONS extends never | "$notStrict" | "$rid" = never,
104
+ OPTIONS extends never | "$rid" = never,
107
105
  K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
108
106
  >
109
107
  = $Osdk.Instance<
@@ -115,7 +113,7 @@ export function createOsdkObject(object, identifier, {
115
113
 
116
114
  /** @deprecated use ${identifier} */
117
115
  export type OsdkObject<
118
- OPTIONS extends never | "$notStrict" | "$rid" = never,
116
+ OPTIONS extends never | "$rid" = never,
119
117
  K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
120
118
  > = ${identifier}<OPTIONS, K>;
121
119
  ;
@@ -146,6 +144,9 @@ function maybeStripNamespace(type, q) {
146
144
  }
147
145
  }
148
146
  export function createProps(type, identifier, strict) {
147
+ if (identifier === "StrictProps") {
148
+ return `export type StrictProps = Props`;
149
+ }
149
150
  const definition = type.getCleanedUpDefinition(true);
150
151
  return `export interface ${identifier} {
151
152
  ${stringify(definition.properties, {
@@ -153,7 +154,7 @@ ${stringify(definition.properties, {
153
154
  return [`readonly "${maybeStripNamespace(type, apiName)}"${
154
155
  // after we convert everything over we can do this:
155
156
  // !strict || propertyDefinition.nullable ? "?" : ""
156
- ""}`, `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? "[]" : ""}${propertyDefinition.nullable || !strict ? `| undefined` : ""}`];
157
+ ""}`, `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? "[]" : ""}${propertyDefinition.nullable || !strict && !(definition.type === "object" && definition.primaryKeyApiName === apiName) ? `| undefined` : ""}`];
157
158
  }
158
159
  })}
159
160
  }`;
@@ -210,6 +211,7 @@ ${stringify(definition.links, {
210
211
  `}`;
211
212
  }
212
213
  export function createPropertyKeys(type) {
213
- return `export type PropertyKeys = ${Object.keys(type.getCleanedUpDefinition(true).properties).map(a => maybeStripNamespace(type, a)).map(a => `"${a}"`).join("|")};`;
214
+ const properties = Object.keys(type.getCleanedUpDefinition(true).properties);
215
+ return `export type PropertyKeys = ${properties.length === 0 ? "never" : properties.map(a => maybeStripNamespace(type, a)).map(a => `"${a}"`).join("|")};`;
214
216
  }
215
217
  //# sourceMappingURL=wireObjectTypeV2ToSdkObjectConstV2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","deleteUndefineds","stringify","getObjectDefIdentifier","name","v2","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","currentFilePath","object","requireObjectType","objectType","apiName","Error","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","properties","*","propertyDefinition","_","JSON","multiplicity","nullable","links","targetType","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nexport function getObjectDefIdentifier(name, v2) {\n return v2 ? name : `${name}Def`;\n}\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(wireObject, { ontology }, currentFilePath) {\n const object = ontology.requireObjectType(wireObject.objectType.apiName, true);\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map(a => ontology.requireObjectType(a.objectTypeApiName, false)));\n const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n const identifiers = {\n objectDefIdentifier: `${object.shortApiName}`,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n function getV2Types(object) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"@osdk/api\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"@osdk/api\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkInstance\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);\n return `${imports}${getV2Types(object)}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\nexport function createOsdkObject(object, identifier, { osdkObjectPropsIdentifier, objectDefIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > \n = $Osdk.Instance<\n ${objectDefIdentifier}, \n OPTIONS,\n K\n >;\n \n\n /** @deprecated use ${identifier} */\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\nexport function createObjectSet(object, { objectDefIdentifier, objectSetIdentifier, propertyKeysIdentifier, osdkObjectIdentifier, }) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\nfunction maybeStripNamespace(type, q) {\n if (type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)) {\n return q.slice(type.apiNamespace.length + 1);\n }\n else {\n return q;\n }\n}\nexport function createProps(type, identifier, strict) {\n const definition = type.getCleanedUpDefinition(true);\n return `export interface ${identifier} {\n${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `readonly \"${maybeStripNamespace(type, apiName)}\"${\n // after we convert everything over we can do this:\n // !strict || propertyDefinition.nullable ? \"?\" : \"\"\n \"\"}`,\n `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? \"[]\" : \"\"}${propertyDefinition.nullable || !strict ? `| undefined` : \"\"}`,\n ];\n },\n })}\n }`;\n}\nexport function createDefinition(object, ontology, identifier, { objectDefIdentifier, objectSetIdentifier, osdkObjectPropsIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export interface ${identifier} extends ${object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`} {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${stringify(definition, {\n links: (_value) => `{\n ${stringify(definition.links, {\n \"*\": (definition) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true)}, ${definition.multiplicity}>`,\n })}\n }`,\n properties: (_value) => (`{\n ${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => [\n `${propertyJsdoc(propertyDefinition, { apiName })}\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<\"${propertyDefinition.type}\", \"${propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"}\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ],\n })}\n }`),\n })}\n } \n}\n `;\n}\nexport function createLinks(ontology, object, identifier) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n ${Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true);\n return [\n `readonly ${key}`,\n `${definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`}\n `,\n ];\n },\n })}\n }\n `}`;\n}\nexport function createPropertyKeys(type) {\n return `export type PropertyKeys = ${Object.keys(type.getCleanedUpDefinition(true).properties).map((a) => maybeStripNamespace(type, a)).map(a => `\"${a}\"`).join(\"|\")};`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,OAAO,SAASC,sBAAsBA,CAACC,IAAI,EAAEC,EAAE,EAAE;EAC7C,OAAOA,EAAE,GAAGD,IAAI,GAAG,GAAGA,IAAI,KAAK;AACnC;AACA;AACA,OAAO,SAASE,kCAAkCA,CAACC,UAAU,EAAE;EAAEC;AAAS,CAAC,EAAEC,eAAe,EAAE;EAC1F,MAAMC,MAAM,GAAGF,QAAQ,CAACG,iBAAiB,CAACJ,UAAU,CAACK,UAAU,CAACC,OAAO,EAAE,IAAI,CAAC;EAC9E,IAAIH,MAAM,YAAYZ,WAAW,EAAE;IAC/B,MAAM,IAAIgB,KAAK,CAAC,qDAAqD,CAAC;EAC1E;EACA,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAACT,UAAU,CAACU,SAAS,CAACC,GAAG,CAACC,CAAC,IAAIX,QAAQ,CAACG,iBAAiB,CAACQ,CAAC,CAACC,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;EAC5H,MAAMC,UAAU,GAAGpB,gBAAgB,CAACL,6CAA6C,CAACc,MAAM,CAACY,GAAG,EAAE,IAAI,CAAC,CAAC;EACpG,MAAMC,mBAAmB,GAAGb,MAAM,CAACc,uBAAuB,CAAC,IAAI,CAAC;EAChE,MAAMC,mBA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,UAAU,CAACsC,UAAU,CAAC,CAC/DC,+BAA+B,CAAC,IAAI,CAAC;MAC1C,OAAO,CACH,YAAYG,GAAG,EAAE,EACjB,GAAG1C,UAAU,CAACmC,YAAY,GACpB,GAAGQ,UAAU,YAAY,GACzB,uBAAuBA,UAAU,GAAG;AAC9D,WAAW,CACM;IACL;EACJ,CAAC,CAAC;AACV;AACA,KAAK,EAAE;AACP;AACA,OAAO,SAAS9B,kBAAkBA,CAACU,IAAI,EAAE;EACrC,OAAO,8BAA8BiB,MAAM,CAACC,IAAI,CAAClB,IAAI,CAACF,sBAAsB,CAAC,IAAI,CAAC,CAACS,UAAU,CAAC,CAACjC,GAAG,CAAEC,CAAC,IAAKwB,mBAAmB,CAACC,IAAI,EAAEzB,CAAC,CAAC,CAAC,CAACD,GAAG,CAACC,CAAC,IAAI,IAAIA,CAAC,GAAG,CAAC,CAAC8C,IAAI,CAAC,GAAG,CAAC,GAAG;AAC3K","ignoreList":[]}
1
+ {"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","deleteUndefineds","stringify","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","forInternalUse","currentFilePath","object","requireObjectType","objectType","apiName","Error","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","properties","*","propertyDefinition","_","JSON","multiplicity","nullable","primaryKeyApiName","links","targetType","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(wireObject, { ontology, forInternalUse }, currentFilePath) {\n const object = ontology.requireObjectType(wireObject.objectType.apiName, true);\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map(a => ontology.requireObjectType(a.objectTypeApiName, false)));\n const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n const identifiers = {\n objectDefIdentifier: `${object.shortApiName}`,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n function getV2Types(object, forInternalUse = false) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkInstance\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);\n return `${imports}${getV2Types(object, forInternalUse)}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\nexport function createOsdkObject(object, identifier, { osdkObjectPropsIdentifier, objectDefIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > \n = $Osdk.Instance<\n ${objectDefIdentifier}, \n OPTIONS,\n K\n >;\n \n\n /** @deprecated use ${identifier} */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\nexport function createObjectSet(object, { objectDefIdentifier, objectSetIdentifier, propertyKeysIdentifier, osdkObjectIdentifier, }) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\nfunction maybeStripNamespace(type, q) {\n if (type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)) {\n return q.slice(type.apiNamespace.length + 1);\n }\n else {\n return q;\n }\n}\nexport function createProps(type, identifier, strict) {\n if (identifier === \"StrictProps\") {\n return `export type StrictProps = Props`;\n }\n const definition = type.getCleanedUpDefinition(true);\n return `export interface ${identifier} {\n${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `readonly \"${maybeStripNamespace(type, apiName)}\"${\n // after we convert everything over we can do this:\n // !strict || propertyDefinition.nullable ? \"?\" : \"\"\n \"\"}`,\n `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? \"[]\" : \"\"}${propertyDefinition.nullable\n || (!strict\n && !(definition.type === \"object\"\n && definition.primaryKeyApiName === apiName))\n ? `| undefined`\n : \"\"}`,\n ];\n },\n })}\n }`;\n}\nexport function createDefinition(object, ontology, identifier, { objectDefIdentifier, objectSetIdentifier, osdkObjectPropsIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export interface ${identifier} extends ${object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`} {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${stringify(definition, {\n links: (_value) => `{\n ${stringify(definition.links, {\n \"*\": (definition) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true)}, ${definition.multiplicity}>`,\n })}\n }`,\n properties: (_value) => (`{\n ${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => [\n `${propertyJsdoc(propertyDefinition, { apiName })}\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<\"${propertyDefinition.type}\", \"${propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"}\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ],\n })}\n }`),\n })}\n } \n}\n `;\n}\nexport function createLinks(ontology, object, identifier) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n ${Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true);\n return [\n `readonly ${key}`,\n `${definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`}\n `,\n ];\n },\n })}\n }\n `}`;\n}\nexport function createPropertyKeys(type) {\n const properties = Object.keys(type.getCleanedUpDefinition(true).properties);\n return `export type PropertyKeys = ${properties.length === 0\n ? \"never\"\n : properties.map((a) => maybeStripNamespace(type, a)).map(a => `\"${a}\"`).join(\"|\")};`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,gBAAgB,QAA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UAAU,GAAG;AAC9D,WAAW,CACM;IACL;EACJ,CAAC,CAAC;AACV;AACA,KAAK,EAAE;AACP;AACA,OAAO,SAAS/B,kBAAkBA,CAACU,IAAI,EAAE;EACrC,MAAMO,UAAU,GAAGW,MAAM,CAACC,IAAI,CAACnB,IAAI,CAACF,sBAAsB,CAAC,IAAI,CAAC,CAACS,UAAU,CAAC;EAC5E,OAAO,8BAA8BA,UAAU,CAACF,MAAM,KAAK,CAAC,GACtD,OAAO,GACPE,UAAU,CAACjC,GAAG,CAAEC,CAAC,IAAKwB,mBAAmB,CAACC,IAAI,EAAEzB,CAAC,CAAC,CAAC,CAACD,GAAG,CAACC,CAAC,IAAI,IAAIA,CAAC,GAAG,CAAC,CAAC+C,IAAI,CAAC,GAAG,CAAC,GAAG;AAC7F","ignoreList":[]}
@@ -25,9 +25,9 @@ export function validateWireOntologyAssumptions(ontology) {
25
25
  }
26
26
  }
27
27
  function invariantMapKeyMatchesApiName(key, value) {
28
- !(key === value.apiName) ? invariant(false, "Key in the map should be the same as the apiName.") : void 0;
28
+ !(key === value.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, "Key in the map should be the same as the apiName.") : invariant(false) : void 0;
29
29
  }
30
30
  function invariantNotStartWithDollarSign(value) {
31
- !!value.startsWith("$") ? invariant(false, "apiName should not start with $") : void 0;
31
+ !!value.startsWith("$") ? process.env.NODE_ENV !== "production" ? invariant(false, "apiName should not start with $") : invariant(false) : void 0;
32
32
  }
33
33
  //# sourceMappingURL=validateWireOntologyAssumptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateWireOntologyAssumptions.js","names":["invariant","validateWireOntologyAssumptions","ontology","invariantNotStartWithDollarSign","apiName","objectKey","objectType","Object","entries","objectTypes","invariantMapKeyMatchesApiName","propertyKey","propertyType","properties","key","value","startsWith"],"sources":["validateWireOntologyAssumptions.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nexport function validateWireOntologyAssumptions(ontology) {\n invariantNotStartWithDollarSign(ontology.ontology.apiName);\n for (const [objectKey, objectType] of Object.entries(ontology.objectTypes)) {\n invariantMapKeyMatchesApiName(objectKey, objectType.objectType);\n invariantNotStartWithDollarSign(objectType.objectType.apiName);\n for (const [propertyKey, propertyType] of Object.entries(objectType.objectType.properties)) {\n invariantNotStartWithDollarSign(propertyKey);\n }\n }\n}\nfunction invariantMapKeyMatchesApiName(key, value) {\n invariant(key === value.apiName, \"Key in the map should be the same as the apiName.\");\n}\nfunction invariantNotStartWithDollarSign(value) {\n invariant(!value.startsWith(\"$\"), \"apiName should not start with $\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,+BAA+BA,CAACC,QAAQ,EAAE;EACtDC,+BAA+B,CAACD,QAAQ,CAACA,QAAQ,CAACE,OAAO,CAAC;EAC1D,KAAK,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,QAAQ,CAACO,WAAW,CAAC,EAAE;IACxEC,6BAA6B,CAACL,SAAS,EAAEC,UAAU,CAACA,UAAU,CAAC;IAC/DH,+BAA+B,CAACG,UAAU,CAACA,UAAU,CAACF,OAAO,CAAC;IAC9D,KAAK,MAAM,CAACO,WAAW,EAAEC,YAAY,CAAC,IAAIL,MAAM,CAACC,OAAO,CAACF,UAAU,CAACA,UAAU,CAACO,UAAU,CAAC,EAAE;MACxFV,+BAA+B,CAACQ,WAAW,CAAC;IAChD;EACJ;AACJ;AACA,SAASD,6BAA6BA,CAACI,GAAG,EAAEC,KAAK,EAAE;EAC/C,EAAUD,GAAG,KAAKC,KAAK,CAACX,OAAO,IAA/BJ,SAAS,QAAwB,mDAAmD;AACxF;AACA,SAASG,+BAA+BA,CAACY,KAAK,EAAE;EAC5C,CAAU,CAACA,KAAK,CAACC,UAAU,CAAC,GAAG,CAAC,GAAhChB,SAAS,QAAyB,iCAAiC;AACvE","ignoreList":[]}
1
+ {"version":3,"file":"validateWireOntologyAssumptions.js","names":["invariant","validateWireOntologyAssumptions","ontology","invariantNotStartWithDollarSign","apiName","objectKey","objectType","Object","entries","objectTypes","invariantMapKeyMatchesApiName","propertyKey","propertyType","properties","key","value","process","env","NODE_ENV","startsWith"],"sources":["validateWireOntologyAssumptions.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nexport function validateWireOntologyAssumptions(ontology) {\n invariantNotStartWithDollarSign(ontology.ontology.apiName);\n for (const [objectKey, objectType] of Object.entries(ontology.objectTypes)) {\n invariantMapKeyMatchesApiName(objectKey, objectType.objectType);\n invariantNotStartWithDollarSign(objectType.objectType.apiName);\n for (const [propertyKey, propertyType] of Object.entries(objectType.objectType.properties)) {\n invariantNotStartWithDollarSign(propertyKey);\n }\n }\n}\nfunction invariantMapKeyMatchesApiName(key, value) {\n invariant(key === value.apiName, \"Key in the map should be the same as the apiName.\");\n}\nfunction invariantNotStartWithDollarSign(value) {\n invariant(!value.startsWith(\"$\"), \"apiName should not start with $\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,+BAA+BA,CAACC,QAAQ,EAAE;EACtDC,+BAA+B,CAACD,QAAQ,CAACA,QAAQ,CAACE,OAAO,CAAC;EAC1D,KAAK,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,QAAQ,CAACO,WAAW,CAAC,EAAE;IACxEC,6BAA6B,CAACL,SAAS,EAAEC,UAAU,CAACA,UAAU,CAAC;IAC/DH,+BAA+B,CAACG,UAAU,CAACA,UAAU,CAACF,OAAO,CAAC;IAC9D,KAAK,MAAM,CAACO,WAAW,EAAEC,YAAY,CAAC,IAAIL,MAAM,CAACC,OAAO,CAACF,UAAU,CAACA,UAAU,CAACO,UAAU,CAAC,EAAE;MACxFV,+BAA+B,CAACQ,WAAW,CAAC;IAChD;EACJ;AACJ;AACA,SAASD,6BAA6BA,CAACI,GAAG,EAAEC,KAAK,EAAE;EAC/C,EAAUD,GAAG,KAAKC,KAAK,CAACX,OAAO,IAAAY,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAA/BlB,SAAS,QAAwB,mDAAmD,IAApFA,SAAS;AACb;AACA,SAASG,+BAA+BA,CAACY,KAAK,EAAE;EAC5C,CAAU,CAACA,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAhClB,SAAS,QAAyB,iCAAiC,IAAnEA,SAAS;AACb","ignoreList":[]}