@osdk/generator 1.12.0-beta.1 → 1.12.0-beta.2

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 (46) hide show
  1. package/CHANGELOG.md +21 -5
  2. package/build/browser/index.js +138 -31
  3. package/build/browser/index.js.map +1 -1
  4. package/build/cjs/index.cjs +140 -31
  5. package/build/cjs/index.cjs.map +1 -1
  6. package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.cts +2 -1
  7. package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
  8. package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.cts +2 -0
  9. package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
  10. package/build/cjs/shared/propertyJsdoc.d.cts +6 -0
  11. package/build/cjs/shared/propertyJsdoc.d.ts.map +1 -0
  12. package/build/cjs/shared/wireObjectTypeV2ToSdkObjectConst.d.ts.map +1 -1
  13. package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.cts +1 -1
  14. package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
  15. package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.cts +10 -2
  16. package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
  17. package/build/cjs/util/stringify.d.cts +3 -3
  18. package/build/cjs/util/stringify.d.ts.map +1 -1
  19. package/build/cjs/util/{verifyOutdir.d.cts → verifyOutDir.d.cts} +2 -2
  20. package/build/cjs/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
  21. package/build/cjs/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
  22. package/build/cjs/v1.1/generatePerQueryDataFiles.d.cts +1 -1
  23. package/build/cjs/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
  24. package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  25. package/build/esm/index.js +138 -31
  26. package/build/esm/index.js.map +1 -1
  27. package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +2 -1
  28. package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
  29. package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +2 -0
  30. package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
  31. package/build/esm/shared/propertyJsdoc.d.ts +6 -0
  32. package/build/esm/shared/propertyJsdoc.d.ts.map +1 -0
  33. package/build/esm/shared/wireObjectTypeV2ToSdkObjectConst.d.ts.map +1 -1
  34. package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +1 -1
  35. package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
  36. package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts +10 -2
  37. package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
  38. package/build/esm/util/stringify.d.ts +3 -3
  39. package/build/esm/util/stringify.d.ts.map +1 -1
  40. package/build/esm/util/{verifyOutdir.d.ts → verifyOutDir.d.ts} +2 -2
  41. package/build/esm/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
  42. package/build/esm/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
  43. package/build/esm/v1.1/generatePerQueryDataFiles.d.ts +1 -1
  44. package/build/esm/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
  45. package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
  46. package/package.json +13 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @osdk/generator
2
2
 
3
+ ## 1.12.0-beta.2
4
+
5
+ ### Minor Changes
6
+
7
+ - 3ec7c38: Add support for queries in 2.0
8
+ - bc89b62: Spelling fixes and spell check in CI
9
+ - 116d848: Interface inherited properties are now generated
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [3ec7c38]
14
+ - Updated dependencies [bc89b62]
15
+ - @osdk/api@1.9.0-beta.1
16
+ - @osdk/generator-converters@0.7.0-beta.1
17
+ - @osdk/gateway@2.4.0-beta.0
18
+
3
19
  ## 1.12.0-beta.1
4
20
 
5
21
  ### Minor Changes
@@ -126,7 +142,7 @@
126
142
 
127
143
  ### Patch Changes
128
144
 
129
- - b59cb10: Adding backcompatibility for internal types
145
+ - b59cb10: Adding backward compatibility for internal types
130
146
 
131
147
  ## 0.0.14
132
148
 
@@ -179,7 +195,7 @@
179
195
 
180
196
  ### Patch Changes
181
197
 
182
- - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatability in @osdk/api"
198
+ - f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatibility in @osdk/api"
183
199
  - 848404c: Handle conflicts between object, action, and query names
184
200
  - Updated dependencies [f3120fb]
185
201
  - Updated dependencies [848404c]
@@ -205,14 +221,14 @@
205
221
 
206
222
  ### Patch Changes
207
223
 
208
- - e22ce70: Adding proper support for reservered keywords in properties
224
+ - e22ce70: Adding proper support for reserved keywords in properties
209
225
  - 66cb4ce: Fixing generator for integration
210
226
 
211
227
  ## 0.0.5
212
228
 
213
229
  ### Patch Changes
214
230
 
215
- - 70719db: Fixing nits, and adding support for legacy reservered word backcompat
231
+ - 70719db: Fixing nits, and adding support for legacy reserved word back-compat
216
232
 
217
233
  ## 0.0.4
218
234
 
@@ -227,7 +243,7 @@
227
243
 
228
244
  ### Patch Changes
229
245
 
230
- - a2b7874: Addin TimeSeries support and fixing issues during code-gen time with Queries
246
+ - a2b7874: Add in TimeSeries support and fixing issues during code-gen time with Queries
231
247
  - Updated dependencies [a2b7874]
232
248
  - @osdk/api@0.0.7
233
249
 
@@ -4,6 +4,8 @@ import path16__default, { join } from 'path';
4
4
  import { format } from 'prettier';
5
5
  import organizeImports from 'prettier-plugin-organize-imports';
6
6
  import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
7
+ import fastDeepEqual from 'fast-deep-equal';
8
+ import invariant from 'tiny-invariant';
7
9
 
8
10
  // src/generateClientSdkPackage.ts
9
11
 
@@ -218,6 +220,38 @@ function createModifiedEntities(addedObjects, modifiedObjects) {
218
220
  }
219
221
  return entities;
220
222
  }
223
+
224
+ // src/shared/propertyJsdoc.ts
225
+ function propertyJsdoc(property, {
226
+ isInherited,
227
+ apiName
228
+ }) {
229
+ let ret = `/**
230
+ `;
231
+ const renderDisplayName = property.displayName && property.displayName !== apiName;
232
+ if (isInherited || renderDisplayName || property.description) {
233
+ if (isInherited) {
234
+ ret += ` * (inherited from parent)
235
+ `;
236
+ }
237
+ if (renderDisplayName) {
238
+ ret += ` * display name: '${property.displayName}'${property.description ? "," : ""}
239
+ `;
240
+ }
241
+ if (property.description) {
242
+ ret += ` * description: ${property.description}
243
+ `;
244
+ }
245
+ } else {
246
+ ret += ` * (no ontology metadata)
247
+ `;
248
+ }
249
+ ret += ` */
250
+ `;
251
+ return ret;
252
+ }
253
+
254
+ // src/shared/wireObjectTypeV2ToSdkObjectConst.ts
221
255
  function getObjectDefIdentifier(name, v2) {
222
256
  return v2 ? name : `${name}Def`;
223
257
  }
@@ -256,7 +290,9 @@ function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
256
290
  }`,
257
291
  properties: (_value) => `{
258
292
  ${stringify(definition.properties, {
259
- "*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
293
+ "*": (propertyDefinition, _, apiName) => [`${propertyJsdoc(propertyDefinition, {
294
+ apiName
295
+ })}${apiName}`, `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
260
296
  })}
261
297
  }`
262
298
  })}
@@ -446,8 +482,8 @@ function camelize(name) {
446
482
  return name.replace(/-./g, (segment) => segment[1].toUpperCase());
447
483
  }
448
484
 
449
- // src/util/verifyOutdir.ts
450
- async function verifyOutdir(outDir, fs2) {
485
+ // src/util/verifyOutDir.ts
486
+ async function verifyOutDir(outDir, fs2) {
451
487
  try {
452
488
  const contents = await fs2.readdir(outDir);
453
489
  if (contents.length !== 0) {
@@ -545,7 +581,7 @@ function reexportConsts(typesToExport) {
545
581
  import { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
546
582
 
547
583
  ${typesToExport.map((q) => `
548
- /** @deprecated submodule imports arent public api **/
584
+ /** @deprecated submodule imports aren't public api **/
549
585
  export const ${q} = OG_${q};
550
586
  `).join("\n\n")}
551
587
  `;
@@ -595,7 +631,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
595
631
  import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
596
632
 
597
633
  ${typesToExport.map((q) => `
598
- /** @deprecated submodule imports arent public api **/
634
+ /** @deprecated submodule imports aren't public api **/
599
635
  export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
600
636
  `).join("\n\n")}
601
637
  `;
@@ -905,10 +941,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
905
941
  await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
906
942
  await generateClientDir(runtimeDistDir, fs2, importExt);
907
943
  await generateFiltersDir(runtimeDistDir, fs2, importExt);
908
- await fs2.writeFile(
909
- path16.join(runtimeDistDir, "index.ts"),
910
- // TRASHFIXME
911
- await formatTs(`
944
+ await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`
912
945
  export * from "./aggregations/index${importExt}";
913
946
  export * from "./baseTypes/index${importExt}";
914
947
  ${""}
@@ -918,8 +951,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
918
951
 
919
952
  export * from "./ontologyProvider/index${importExt}";
920
953
  export * from "./paging/index${importExt}";
921
- `)
922
- );
954
+ `));
923
955
  }
924
956
 
925
957
  // src/v1.1/generateBackCompatDeprecatedExports.ts
@@ -1282,10 +1314,10 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
1282
1314
  case "union":
1283
1315
  const allowNulls = isNullableQueryDataType(input);
1284
1316
  if (allowNulls && input.unionTypes.length === 2) {
1285
- const nonnull = input.unionTypes.find((t) => t.type != null);
1286
- if (nonnull) {
1317
+ const nonNull = input.unionTypes.find((t) => t.type != null);
1318
+ if (nonNull) {
1287
1319
  return {
1288
- ...wireQueryDataTypeToQueryDataTypeDefinition(nonnull),
1320
+ ...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
1289
1321
  nullable: true
1290
1322
  };
1291
1323
  }
@@ -1310,12 +1342,14 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
1310
1342
  case "twoDimensionalAggregation":
1311
1343
  return {
1312
1344
  type: "twoDimensionalAggregation",
1313
- twoDimensionalAggregation: get2DQueryAggregationProps(input)
1345
+ twoDimensionalAggregation: get2DQueryAggregationProps(input),
1346
+ nullable: false
1314
1347
  };
1315
1348
  case "threeDimensionalAggregation":
1316
1349
  return {
1317
1350
  type: "threeDimensionalAggregation",
1318
- threeDimensionalAggregation: get3DQueryAggregationProps(input)
1351
+ threeDimensionalAggregation: get3DQueryAggregationProps(input),
1352
+ nullable: false
1319
1353
  };
1320
1354
  case "null":
1321
1355
  case "unsupported":
@@ -1374,6 +1408,15 @@ function wireQueryTypeV2ToSdkQueryDefinition(input) {
1374
1408
  output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
1375
1409
  };
1376
1410
  }
1411
+ function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
1412
+ return {
1413
+ type: "query",
1414
+ apiName: input.apiName,
1415
+ description: input.description,
1416
+ displayName: input.displayName,
1417
+ version: input.version
1418
+ };
1419
+ }
1377
1420
  function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
1378
1421
  return {
1379
1422
  description: parameter.description,
@@ -1382,19 +1425,36 @@ function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
1382
1425
  }
1383
1426
 
1384
1427
  // src/v1.1/generatePerQueryDataFiles.ts
1385
- async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "") {
1428
+ async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "", v2 = false) {
1386
1429
  await fs2.mkdir(outDir, {
1387
1430
  recursive: true
1388
1431
  });
1389
1432
  await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
1390
1433
  const objectTypes = getObjectTypesFromQuery(query);
1391
- await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
1392
- import { QueryDefinition } from "@osdk/api";
1393
-
1394
- export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} satisfies QueryDefinition<"${query.apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiName) => `"${apiName}"`).join("|") : "never"}>;`));
1434
+ const importObjects = objectTypes.length > 0 ? `import {${[...objectTypes].join(",")}} from "../objects${importExt}";` : "";
1435
+ if (v2) {
1436
+ await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
1437
+ import { QueryDefinition } from "@osdk/api";
1438
+ ${importObjects}
1439
+ export const ${query.apiName} = {
1440
+ ${stringify(deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query)))},
1441
+ parameters: {${Object.entries(query.parameters).map(([name, parameter]) => {
1442
+ return `${name} : {${stringify(deleteUndefineds(wireQueryParameterV2ToQueryParameterDefinition(parameter)))},
1443
+ ${parameter.dataType.type === "object" || parameter.dataType.type === "objectSet" ? getOsdkTargetTypeIfPresent(parameter.dataType.objectTypeApiName, v2) : ``}}`;
1444
+ })}},
1445
+ output: {${stringify(deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output)))},
1446
+ ${query.output.type === "object" || query.output.type === "objectSet" ? getOsdkTargetTypeIfPresent(query.output.objectTypeApiName, v2) : ``}}
1447
+ } ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
1448
+ } else {
1449
+ await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
1450
+ import { QueryDefinition } from "@osdk/api";
1451
+
1452
+ export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
1453
+ }
1395
1454
  }));
1396
1455
  await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
1397
1456
  ${Object.values(ontology.queryTypes).map((query) => `export * from "./${query.apiName}${importExt}";`).join("\n")}
1457
+ ${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
1398
1458
  `));
1399
1459
  }
1400
1460
  function getObjectTypesFromQuery(query) {
@@ -1447,6 +1507,14 @@ function getObjectTypesFromDataType(dataType, types) {
1447
1507
  throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
1448
1508
  }
1449
1509
  }
1510
+ function getQueryDefSatisfies(apiName, objectTypes) {
1511
+ return `satisfies QueryDefinition<"${apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never"}>;`;
1512
+ }
1513
+ function getOsdkTargetTypeIfPresent(objectTypeApiName, v2) {
1514
+ return `
1515
+ __OsdkTargetType: ${getObjectDefIdentifier(objectTypeApiName, v2)}
1516
+ `;
1517
+ }
1450
1518
  async function generateQueries(ontology, fs2, outDir, importExt = "") {
1451
1519
  const importedObjects = /* @__PURE__ */ new Set();
1452
1520
  const signatures = [];
@@ -1596,7 +1664,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
1596
1664
  const objectsDir = path16.join(outDir, "ontology", "objects");
1597
1665
  const actionsDir = path16.join(outDir, "ontology", "actions");
1598
1666
  const queriesDir = path16.join(outDir, "ontology", "queries");
1599
- await verifyOutdir(outDir, fs2);
1667
+ await verifyOutDir(outDir, fs2);
1600
1668
  await fs2.mkdir(outDir, {
1601
1669
  recursive: true
1602
1670
  });
@@ -1616,9 +1684,37 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
1616
1684
  await generateIndexFile(fs2, outDir, importExt);
1617
1685
  await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
1618
1686
  }
1619
- function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
1687
+ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
1620
1688
  const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
1621
1689
  const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
1690
+ const parents = definition.implements?.map((p) => {
1691
+ !(ontology.interfaceTypes[p] != null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected to find a parent interface named ${p} in the ontology and did not.`) : invariant(false) : void 0;
1692
+ const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes[p], v2));
1693
+ return it;
1694
+ }) ?? [];
1695
+ const mergedProperties = {
1696
+ ...definition.properties
1697
+ };
1698
+ for (const parent of parents) {
1699
+ for (const apiName of Object.keys(parent.properties)) {
1700
+ if (definition.properties[apiName] != null) {
1701
+ !fastDeepEqual(definition.properties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`) : invariant(false) : void 0;
1702
+ } else if (mergedProperties[apiName] != null) {
1703
+ !fastDeepEqual(mergedProperties[apiName], parent.properties[apiName]) ? process.env.NODE_ENV !== "production" ? invariant(false, `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`) : invariant(false) : void 0;
1704
+ }
1705
+ mergedProperties[apiName] = parent.properties[apiName];
1706
+ }
1707
+ }
1708
+ const ogProperties = definition.properties;
1709
+ definition.properties = mergedProperties;
1710
+ function localPropertyJsdoc(apiName) {
1711
+ const property = definition.properties[apiName];
1712
+ const isInherited = ogProperties[apiName] == null;
1713
+ return propertyJsdoc(property, {
1714
+ isInherited,
1715
+ apiName
1716
+ });
1717
+ }
1622
1718
  function getV2Types() {
1623
1719
  return `
1624
1720
  export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
@@ -1632,9 +1728,9 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
1632
1728
  "*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
1633
1729
  })}
1634
1730
  }`,
1635
- properties: (_value) => `{
1636
- ${stringify(definition.properties, {
1637
- "*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
1731
+ properties: (properties) => `{
1732
+ ${stringify(properties, {
1733
+ "*": (propertyDefinition, _, key) => [`${localPropertyJsdoc(key)}${key}`, `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
1638
1734
  })}
1639
1735
  }`
1640
1736
  })}
@@ -1676,11 +1772,11 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
1676
1772
 
1677
1773
  // src/v2.0/generateClientSdkVersionTwoPointZero.ts
1678
1774
  async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
1679
- await verifyOutdir(outDir, fs2);
1775
+ await verifyOutDir(outDir, fs2);
1680
1776
  const sanitizedOntology = sanitizeMetadata(ontology);
1681
1777
  const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
1682
1778
  const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
1683
- Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
1779
+ const queryNames = Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
1684
1780
  const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
1685
1781
  const importExt = packageType === "module" ? ".js" : "";
1686
1782
  await fs2.mkdir(outDir, {
@@ -1691,6 +1787,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
1691
1787
  export * from "./ontology/actions/index${importExt}";
1692
1788
  export * from "./ontology/objects${importExt}";
1693
1789
  export * from "./ontology/interfaces${importExt}";
1790
+ export * from "./ontology/queries/index${importExt}";
1694
1791
  `));
1695
1792
  await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs2, outDir);
1696
1793
  await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
@@ -1698,6 +1795,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
1698
1795
  import * as Actions from "./ontology/actions/index${importExt}";
1699
1796
  import * as Objects from "./ontology/objects${importExt}";
1700
1797
  import * as Interfaces from "./ontology/interfaces${importExt}";
1798
+ import * as Queries from "./ontology/queries/index${importExt}";
1701
1799
  import { OntologyMetadata } from "./OntologyMetadata${importExt}";
1702
1800
 
1703
1801
  export interface Ontology extends OntologyDefinition<${stringUnionFrom2(objectNames)}> {
@@ -1713,7 +1811,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
1713
1811
  }).join(",\n")}
1714
1812
  },
1715
1813
  queries: {
1716
- // TODO
1814
+ ${queryNames.map((queryName) => {
1815
+ return `${queryName}: typeof Queries.${queryName}`;
1816
+ }).join(",\n")}
1717
1817
  },
1718
1818
  interfaces: {
1719
1819
  ${interfaceNames.map((objectName) => {
@@ -1736,7 +1836,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
1736
1836
  }).join(",\n")}
1737
1837
  },
1738
1838
  queries: {
1739
- // TODO
1839
+ ${queryNames.map((queryName) => {
1840
+ return `${queryName}: Queries.${queryName}`;
1841
+ }).join(",\n")}
1740
1842
  },
1741
1843
  interfaces: {
1742
1844
  ${interfaceNames.map((objectName) => {
@@ -1771,6 +1873,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
1771
1873
  ${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
1772
1874
  ${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
1773
1875
  `));
1876
+ const queriesDir = path16__default.join(outDir, "ontology", "queries");
1877
+ await fs2.mkdir(queriesDir, {
1878
+ recursive: true
1879
+ });
1880
+ await generatePerQueryDataFiles(sanitizedOntology, fs2, queriesDir, importExt, true);
1774
1881
  }
1775
1882
  function stringUnionFrom2(values) {
1776
1883
  if (values.length === 0) {
@@ -1792,7 +1899,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
1792
1899
  import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
1793
1900
  import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
1794
1901
 
1795
- ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
1902
+ ${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
1796
1903
  `));
1797
1904
  }
1798
1905
  await fs2.writeFile(interfacesDir + ".ts", await formatTs(`