@osdk/generator 1.12.0-main-20240530094422 → 1.12.1
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.
- package/CHANGELOG.md +63 -6
- package/build/browser/index.js +150 -44
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +152 -44
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.cts +1 -3
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.cts +2 -0
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
- package/build/cjs/shared/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/cjs/shared/propertyJsdoc.d.cts +6 -0
- package/build/cjs/shared/propertyJsdoc.d.ts.map +1 -0
- package/build/cjs/shared/sanitizeMetadata.d.cts +1 -9
- package/build/cjs/shared/sanitizeMetadata.d.ts.map +1 -1
- package/build/cjs/shared/wireObjectTypeV2ToSdkObjectConst.d.cts +0 -3
- package/build/cjs/shared/wireObjectTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.cts +1 -1
- package/build/cjs/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.cts +10 -2
- package/build/cjs/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/cjs/util/stringify.d.cts +3 -3
- package/build/cjs/util/stringify.d.ts.map +1 -1
- package/build/cjs/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/cjs/util/{verifyOutdir.d.cts → verifyOutDir.d.cts} +2 -2
- package/build/cjs/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
- package/build/cjs/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.cts +1 -1
- package/build/cjs/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/index.js +150 -44
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +1 -3
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts +2 -0
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts.map +1 -0
- package/build/esm/shared/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/esm/shared/propertyJsdoc.d.ts +6 -0
- package/build/esm/shared/propertyJsdoc.d.ts.map +1 -0
- package/build/esm/shared/sanitizeMetadata.d.ts +1 -9
- package/build/esm/shared/sanitizeMetadata.d.ts.map +1 -1
- package/build/esm/shared/wireObjectTypeV2ToSdkObjectConst.d.ts +0 -3
- package/build/esm/shared/wireObjectTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +1 -1
- package/build/esm/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map +1 -1
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts +10 -2
- package/build/esm/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts.map +1 -1
- package/build/esm/util/stringify.d.ts +3 -3
- package/build/esm/util/stringify.d.ts.map +1 -1
- package/build/esm/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/esm/util/{verifyOutdir.d.ts → verifyOutDir.d.ts} +2 -2
- package/build/esm/util/{verifyOutdir.d.ts.map → verifyOutDir.d.ts.map} +1 -1
- package/build/esm/v1.1/backcompat/generateOntologyRuntimeDistDir.d.ts.map +1 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts +1 -1
- package/build/esm/v1.1/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/package.json +18 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,66 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
-
## 1.12.
|
|
3
|
+
## 1.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8c76c1a: Adds VersionBound to actions
|
|
8
|
+
- e2ab8db: Fix long aggregations in legacy-client
|
|
9
|
+
|
|
10
|
+
## 1.12.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 388dba9: Change all internal dependencies to be tilde not caret
|
|
15
|
+
- 5378312: Added batch action support for 2.0 client
|
|
16
|
+
- 3ec7c38: Add support for queries in 2.0
|
|
17
|
+
- 0ecd42b: Generates 2.0's Ontology.ts in a typescript 5.5.0-beta safe way
|
|
18
|
+
- bc89b62: Spelling fixes and spell check in CI
|
|
19
|
+
- 116d848: Interface inherited properties are now generated
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [388dba9]
|
|
24
|
+
- Updated dependencies [d8edf10]
|
|
25
|
+
- Updated dependencies [3ec7c38]
|
|
26
|
+
- Updated dependencies [bc89b62]
|
|
27
|
+
- @osdk/generator-converters@0.7.0
|
|
28
|
+
- @osdk/api@1.9.0
|
|
29
|
+
- @osdk/gateway@2.4.0
|
|
30
|
+
|
|
31
|
+
## 1.12.0-beta.2
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- 3ec7c38: Add support for queries in 2.0
|
|
36
|
+
- bc89b62: Spelling fixes and spell check in CI
|
|
37
|
+
- 116d848: Interface inherited properties are now generated
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [3ec7c38]
|
|
42
|
+
- Updated dependencies [bc89b62]
|
|
43
|
+
- @osdk/api@1.9.0-beta.1
|
|
44
|
+
- @osdk/generator-converters@0.7.0-beta.1
|
|
45
|
+
- @osdk/gateway@2.4.0-beta.0
|
|
46
|
+
|
|
47
|
+
## 1.12.0-beta.1
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- 388dba9: Change all internal dependencies to be tilde not caret
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [388dba9]
|
|
56
|
+
- @osdk/generator-converters@0.7.0-beta.0
|
|
57
|
+
- @osdk/api@1.9.0-beta.0
|
|
58
|
+
|
|
59
|
+
## 1.12.0-beta.0
|
|
4
60
|
|
|
5
61
|
### Minor Changes
|
|
6
62
|
|
|
63
|
+
- 5378312: Added batch action support for 2.0 client
|
|
7
64
|
- 0ecd42b: Generates 2.0's Ontology.ts in a typescript 5.5.0-beta safe way
|
|
8
65
|
|
|
9
66
|
## 1.11.0
|
|
@@ -113,7 +170,7 @@
|
|
|
113
170
|
|
|
114
171
|
### Patch Changes
|
|
115
172
|
|
|
116
|
-
- b59cb10: Adding
|
|
173
|
+
- b59cb10: Adding backward compatibility for internal types
|
|
117
174
|
|
|
118
175
|
## 0.0.14
|
|
119
176
|
|
|
@@ -166,7 +223,7 @@
|
|
|
166
223
|
|
|
167
224
|
### Patch Changes
|
|
168
225
|
|
|
169
|
-
- f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9
|
|
226
|
+
- f3120fb: Move 2.0 client into @osdk/client to fix typescript 4.9 compatibility in @osdk/api"
|
|
170
227
|
- 848404c: Handle conflicts between object, action, and query names
|
|
171
228
|
- Updated dependencies [f3120fb]
|
|
172
229
|
- Updated dependencies [848404c]
|
|
@@ -192,14 +249,14 @@
|
|
|
192
249
|
|
|
193
250
|
### Patch Changes
|
|
194
251
|
|
|
195
|
-
- e22ce70: Adding proper support for
|
|
252
|
+
- e22ce70: Adding proper support for reserved keywords in properties
|
|
196
253
|
- 66cb4ce: Fixing generator for integration
|
|
197
254
|
|
|
198
255
|
## 0.0.5
|
|
199
256
|
|
|
200
257
|
### Patch Changes
|
|
201
258
|
|
|
202
|
-
- 70719db: Fixing nits, and adding support for legacy
|
|
259
|
+
- 70719db: Fixing nits, and adding support for legacy reserved word back-compat
|
|
203
260
|
|
|
204
261
|
## 0.0.4
|
|
205
262
|
|
|
@@ -214,7 +271,7 @@
|
|
|
214
271
|
|
|
215
272
|
### Patch Changes
|
|
216
273
|
|
|
217
|
-
- a2b7874:
|
|
274
|
+
- a2b7874: Add in TimeSeries support and fixing issues during code-gen time with Queries
|
|
218
275
|
- Updated dependencies [a2b7874]
|
|
219
276
|
- @osdk/api@0.0.7
|
|
220
277
|
|
package/build/browser/index.js
CHANGED
|
@@ -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
|
|
|
@@ -53,7 +55,7 @@ function isReservedKeyword(name) {
|
|
|
53
55
|
// src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts
|
|
54
56
|
function wireObjectTypeV2ToObjectInterfaceStringV1(objectTypeWithLinks, importExt = "") {
|
|
55
57
|
const uniqueLinkTargets = new Set(objectTypeWithLinks.linkTypes.map((a) => a.objectTypeApiName).filter((a) => a !== objectTypeWithLinks.objectType.apiName));
|
|
56
|
-
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink } from "@osdk/legacy-client";
|
|
58
|
+
return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink, StringLong } from "@osdk/legacy-client";
|
|
57
59
|
${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget} } from "./${linkTarget}${importExt}";`).join("\n")}
|
|
58
60
|
|
|
59
61
|
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
@@ -109,7 +111,7 @@ function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
|
109
111
|
case "geoshape":
|
|
110
112
|
return "GeoShape";
|
|
111
113
|
case "long":
|
|
112
|
-
return "
|
|
114
|
+
return "StringLong";
|
|
113
115
|
case "short":
|
|
114
116
|
return "number";
|
|
115
117
|
case "timestamp":
|
|
@@ -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) =>
|
|
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
|
})}
|
|
@@ -331,18 +367,18 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
331
367
|
|
|
332
368
|
|
|
333
369
|
// Represents the runtime arguments for the action
|
|
334
|
-
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}
|
|
370
|
+
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}>> | NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[];
|
|
335
371
|
|
|
336
372
|
|
|
337
373
|
// Represents a fqn of the action
|
|
338
374
|
export interface ${action.apiName} {
|
|
339
375
|
${getDescriptionIfPresent(action.description)}
|
|
340
|
-
<OP extends ApplyActionOptions>(args:
|
|
376
|
+
<P extends ${paramsIdentifier}, OP extends P extends NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[]? ApplyBatchActionOptions: ApplyActionOptions>(args: P, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
341
377
|
}
|
|
342
378
|
|
|
343
379
|
|
|
344
380
|
// Represents the definition of the action
|
|
345
|
-
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
|
|
381
|
+
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
346
382
|
${Object.entries(actionDefSansParameters).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
|
|
347
383
|
return `${key}: ${JSON.stringify(value)};`;
|
|
348
384
|
}).join("\n")}
|
|
@@ -374,9 +410,10 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
374
410
|
}
|
|
375
411
|
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
376
412
|
await fs2.writeFile(path16__default.join(outDir, `${action.apiName}.ts`), await formatTs(`
|
|
377
|
-
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
378
|
-
import type { ActionSignature, ApplyActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
413
|
+
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
|
|
414
|
+
import type { ActionSignature, ApplyActionOptions, ApplyBatchActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
379
415
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
416
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
380
417
|
${importObjects}
|
|
381
418
|
|
|
382
419
|
|
|
@@ -446,8 +483,8 @@ function camelize(name) {
|
|
|
446
483
|
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
447
484
|
}
|
|
448
485
|
|
|
449
|
-
// src/util/
|
|
450
|
-
async function
|
|
486
|
+
// src/util/verifyOutDir.ts
|
|
487
|
+
async function verifyOutDir(outDir, fs2) {
|
|
451
488
|
try {
|
|
452
489
|
const contents = await fs2.readdir(outDir);
|
|
453
490
|
if (contents.length !== 0) {
|
|
@@ -545,7 +582,7 @@ function reexportConsts(typesToExport) {
|
|
|
545
582
|
import { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
546
583
|
|
|
547
584
|
${typesToExport.map((q) => `
|
|
548
|
-
/** @deprecated submodule imports
|
|
585
|
+
/** @deprecated submodule imports aren't public api **/
|
|
549
586
|
export const ${q} = OG_${q};
|
|
550
587
|
`).join("\n\n")}
|
|
551
588
|
`;
|
|
@@ -595,7 +632,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
595
632
|
import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
596
633
|
|
|
597
634
|
${typesToExport.map((q) => `
|
|
598
|
-
/** @deprecated submodule imports
|
|
635
|
+
/** @deprecated submodule imports aren't public api **/
|
|
599
636
|
export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
|
|
600
637
|
`).join("\n\n")}
|
|
601
638
|
`;
|
|
@@ -603,8 +640,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
603
640
|
var captureInBracketsRegex = /<(.*?)>/;
|
|
604
641
|
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
605
642
|
function cleanup(s) {
|
|
606
|
-
if (s.length === 0)
|
|
607
|
-
return "";
|
|
643
|
+
if (s.length === 0) return "";
|
|
608
644
|
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
609
645
|
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
610
646
|
});
|
|
@@ -906,10 +942,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
906
942
|
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
907
943
|
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
908
944
|
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
909
|
-
await fs2.writeFile(
|
|
910
|
-
path16.join(runtimeDistDir, "index.ts"),
|
|
911
|
-
// TRASHFIXME
|
|
912
|
-
await formatTs(`
|
|
945
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`
|
|
913
946
|
export * from "./aggregations/index${importExt}";
|
|
914
947
|
export * from "./baseTypes/index${importExt}";
|
|
915
948
|
${""}
|
|
@@ -919,8 +952,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
919
952
|
|
|
920
953
|
export * from "./ontologyProvider/index${importExt}";
|
|
921
954
|
export * from "./paging/index${importExt}";
|
|
922
|
-
`)
|
|
923
|
-
);
|
|
955
|
+
`));
|
|
924
956
|
}
|
|
925
957
|
|
|
926
958
|
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
@@ -1283,10 +1315,10 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1283
1315
|
case "union":
|
|
1284
1316
|
const allowNulls = isNullableQueryDataType(input);
|
|
1285
1317
|
if (allowNulls && input.unionTypes.length === 2) {
|
|
1286
|
-
const
|
|
1287
|
-
if (
|
|
1318
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1319
|
+
if (nonNull) {
|
|
1288
1320
|
return {
|
|
1289
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(
|
|
1321
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1290
1322
|
nullable: true
|
|
1291
1323
|
};
|
|
1292
1324
|
}
|
|
@@ -1311,12 +1343,14 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1311
1343
|
case "twoDimensionalAggregation":
|
|
1312
1344
|
return {
|
|
1313
1345
|
type: "twoDimensionalAggregation",
|
|
1314
|
-
twoDimensionalAggregation: get2DQueryAggregationProps(input)
|
|
1346
|
+
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1347
|
+
nullable: false
|
|
1315
1348
|
};
|
|
1316
1349
|
case "threeDimensionalAggregation":
|
|
1317
1350
|
return {
|
|
1318
1351
|
type: "threeDimensionalAggregation",
|
|
1319
|
-
threeDimensionalAggregation: get3DQueryAggregationProps(input)
|
|
1352
|
+
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1353
|
+
nullable: false
|
|
1320
1354
|
};
|
|
1321
1355
|
case "null":
|
|
1322
1356
|
case "unsupported":
|
|
@@ -1375,6 +1409,15 @@ function wireQueryTypeV2ToSdkQueryDefinition(input) {
|
|
|
1375
1409
|
output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
|
|
1376
1410
|
};
|
|
1377
1411
|
}
|
|
1412
|
+
function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input) {
|
|
1413
|
+
return {
|
|
1414
|
+
type: "query",
|
|
1415
|
+
apiName: input.apiName,
|
|
1416
|
+
description: input.description,
|
|
1417
|
+
displayName: input.displayName,
|
|
1418
|
+
version: input.version
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1378
1421
|
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1379
1422
|
return {
|
|
1380
1423
|
description: parameter.description,
|
|
@@ -1383,19 +1426,36 @@ function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
|
1383
1426
|
}
|
|
1384
1427
|
|
|
1385
1428
|
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1386
|
-
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1429
|
+
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "", v2 = false) {
|
|
1387
1430
|
await fs2.mkdir(outDir, {
|
|
1388
1431
|
recursive: true
|
|
1389
1432
|
});
|
|
1390
1433
|
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1391
1434
|
const objectTypes = getObjectTypesFromQuery(query);
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1435
|
+
const importObjects = objectTypes.length > 0 ? `import {${[...objectTypes].join(",")}} from "../objects${importExt}";` : "";
|
|
1436
|
+
if (v2) {
|
|
1437
|
+
await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
|
|
1438
|
+
import { QueryDefinition } from "@osdk/api";
|
|
1439
|
+
${importObjects}
|
|
1440
|
+
export const ${query.apiName} = {
|
|
1441
|
+
${stringify(deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query)))},
|
|
1442
|
+
parameters: {${Object.entries(query.parameters).map(([name, parameter]) => {
|
|
1443
|
+
return `${name} : {${stringify(deleteUndefineds(wireQueryParameterV2ToQueryParameterDefinition(parameter)))},
|
|
1444
|
+
${parameter.dataType.type === "object" || parameter.dataType.type === "objectSet" ? getOsdkTargetTypeIfPresent(parameter.dataType.objectTypeApiName, v2) : ``}}`;
|
|
1445
|
+
})}},
|
|
1446
|
+
output: {${stringify(deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output)))},
|
|
1447
|
+
${query.output.type === "object" || query.output.type === "objectSet" ? getOsdkTargetTypeIfPresent(query.output.objectTypeApiName, v2) : ``}}
|
|
1448
|
+
} ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
|
|
1449
|
+
} else {
|
|
1450
|
+
await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
|
|
1451
|
+
import { QueryDefinition } from "@osdk/api";
|
|
1452
|
+
|
|
1453
|
+
export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} ${getQueryDefSatisfies(query.apiName, objectTypes)}`));
|
|
1454
|
+
}
|
|
1396
1455
|
}));
|
|
1397
1456
|
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1398
1457
|
${Object.values(ontology.queryTypes).map((query) => `export * from "./${query.apiName}${importExt}";`).join("\n")}
|
|
1458
|
+
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1399
1459
|
`));
|
|
1400
1460
|
}
|
|
1401
1461
|
function getObjectTypesFromQuery(query) {
|
|
@@ -1448,6 +1508,14 @@ function getObjectTypesFromDataType(dataType, types) {
|
|
|
1448
1508
|
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1449
1509
|
}
|
|
1450
1510
|
}
|
|
1511
|
+
function getQueryDefSatisfies(apiName, objectTypes) {
|
|
1512
|
+
return `satisfies QueryDefinition<"${apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiNameObj) => `"${apiNameObj}"`).join("|") : "never"}>;`;
|
|
1513
|
+
}
|
|
1514
|
+
function getOsdkTargetTypeIfPresent(objectTypeApiName, v2) {
|
|
1515
|
+
return `
|
|
1516
|
+
__OsdkTargetType: ${getObjectDefIdentifier(objectTypeApiName, v2)}
|
|
1517
|
+
`;
|
|
1518
|
+
}
|
|
1451
1519
|
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1452
1520
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
1453
1521
|
const signatures = [];
|
|
@@ -1597,7 +1665,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1597
1665
|
const objectsDir = path16.join(outDir, "ontology", "objects");
|
|
1598
1666
|
const actionsDir = path16.join(outDir, "ontology", "actions");
|
|
1599
1667
|
const queriesDir = path16.join(outDir, "ontology", "queries");
|
|
1600
|
-
await
|
|
1668
|
+
await verifyOutDir(outDir, fs2);
|
|
1601
1669
|
await fs2.mkdir(outDir, {
|
|
1602
1670
|
recursive: true
|
|
1603
1671
|
});
|
|
@@ -1617,9 +1685,37 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1617
1685
|
await generateIndexFile(fs2, outDir, importExt);
|
|
1618
1686
|
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1619
1687
|
}
|
|
1620
|
-
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
|
|
1688
|
+
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
1621
1689
|
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
|
|
1622
1690
|
const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
|
|
1691
|
+
const parents = definition.implements?.map((p) => {
|
|
1692
|
+
!(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;
|
|
1693
|
+
const it = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes[p], v2));
|
|
1694
|
+
return it;
|
|
1695
|
+
}) ?? [];
|
|
1696
|
+
const mergedProperties = {
|
|
1697
|
+
...definition.properties
|
|
1698
|
+
};
|
|
1699
|
+
for (const parent of parents) {
|
|
1700
|
+
for (const apiName of Object.keys(parent.properties)) {
|
|
1701
|
+
if (definition.properties[apiName] != null) {
|
|
1702
|
+
!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;
|
|
1703
|
+
} else if (mergedProperties[apiName] != null) {
|
|
1704
|
+
!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;
|
|
1705
|
+
}
|
|
1706
|
+
mergedProperties[apiName] = parent.properties[apiName];
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
const ogProperties = definition.properties;
|
|
1710
|
+
definition.properties = mergedProperties;
|
|
1711
|
+
function localPropertyJsdoc(apiName) {
|
|
1712
|
+
const property = definition.properties[apiName];
|
|
1713
|
+
const isInherited = ogProperties[apiName] == null;
|
|
1714
|
+
return propertyJsdoc(property, {
|
|
1715
|
+
isInherited,
|
|
1716
|
+
apiName
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1623
1719
|
function getV2Types() {
|
|
1624
1720
|
return `
|
|
1625
1721
|
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
@@ -1633,9 +1729,9 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1633
1729
|
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
1634
1730
|
})}
|
|
1635
1731
|
}`,
|
|
1636
|
-
properties: (
|
|
1637
|
-
${stringify(
|
|
1638
|
-
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
1732
|
+
properties: (properties) => `{
|
|
1733
|
+
${stringify(properties, {
|
|
1734
|
+
"*": (propertyDefinition, _, key) => [`${localPropertyJsdoc(key)}${key}`, `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`]
|
|
1639
1735
|
})}
|
|
1640
1736
|
}`
|
|
1641
1737
|
})}
|
|
@@ -1656,7 +1752,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1656
1752
|
|
|
1657
1753
|
};`;
|
|
1658
1754
|
}
|
|
1659
|
-
var ExpectedOsdkVersion = "0.
|
|
1755
|
+
var ExpectedOsdkVersion = "0.20.0";
|
|
1660
1756
|
async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
1661
1757
|
fs2.writeFile(path16__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1662
1758
|
import { OntologyMetadata as OM } from "@osdk/api";
|
|
@@ -1677,11 +1773,11 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
|
1677
1773
|
|
|
1678
1774
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1679
1775
|
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1680
|
-
await
|
|
1776
|
+
await verifyOutDir(outDir, fs2);
|
|
1681
1777
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1682
1778
|
const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
|
|
1683
1779
|
const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
|
|
1684
|
-
Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1780
|
+
const queryNames = Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1685
1781
|
const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
|
|
1686
1782
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1687
1783
|
await fs2.mkdir(outDir, {
|
|
@@ -1692,6 +1788,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1692
1788
|
export * from "./ontology/actions/index${importExt}";
|
|
1693
1789
|
export * from "./ontology/objects${importExt}";
|
|
1694
1790
|
export * from "./ontology/interfaces${importExt}";
|
|
1791
|
+
export * from "./ontology/queries/index${importExt}";
|
|
1695
1792
|
`));
|
|
1696
1793
|
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs2, outDir);
|
|
1697
1794
|
await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
@@ -1699,6 +1796,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1699
1796
|
import * as Actions from "./ontology/actions/index${importExt}";
|
|
1700
1797
|
import * as Objects from "./ontology/objects${importExt}";
|
|
1701
1798
|
import * as Interfaces from "./ontology/interfaces${importExt}";
|
|
1799
|
+
import * as Queries from "./ontology/queries/index${importExt}";
|
|
1702
1800
|
import { OntologyMetadata } from "./OntologyMetadata${importExt}";
|
|
1703
1801
|
|
|
1704
1802
|
export interface Ontology extends OntologyDefinition<${stringUnionFrom2(objectNames)}> {
|
|
@@ -1714,7 +1812,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1714
1812
|
}).join(",\n")}
|
|
1715
1813
|
},
|
|
1716
1814
|
queries: {
|
|
1717
|
-
|
|
1815
|
+
${queryNames.map((queryName) => {
|
|
1816
|
+
return `${queryName}: typeof Queries.${queryName}`;
|
|
1817
|
+
}).join(",\n")}
|
|
1718
1818
|
},
|
|
1719
1819
|
interfaces: {
|
|
1720
1820
|
${interfaceNames.map((objectName) => {
|
|
@@ -1737,7 +1837,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1737
1837
|
}).join(",\n")}
|
|
1738
1838
|
},
|
|
1739
1839
|
queries: {
|
|
1740
|
-
|
|
1840
|
+
${queryNames.map((queryName) => {
|
|
1841
|
+
return `${queryName}: Queries.${queryName}`;
|
|
1842
|
+
}).join(",\n")}
|
|
1741
1843
|
},
|
|
1742
1844
|
interfaces: {
|
|
1743
1845
|
${interfaceNames.map((objectName) => {
|
|
@@ -1772,6 +1874,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1772
1874
|
${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1773
1875
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
1774
1876
|
`));
|
|
1877
|
+
const queriesDir = path16__default.join(outDir, "ontology", "queries");
|
|
1878
|
+
await fs2.mkdir(queriesDir, {
|
|
1879
|
+
recursive: true
|
|
1880
|
+
});
|
|
1881
|
+
await generatePerQueryDataFiles(sanitizedOntology, fs2, queriesDir, importExt, true);
|
|
1775
1882
|
}
|
|
1776
1883
|
function stringUnionFrom2(values) {
|
|
1777
1884
|
if (values.length === 0) {
|
|
@@ -1793,7 +1900,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1793
1900
|
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1794
1901
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1795
1902
|
|
|
1796
|
-
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
|
|
1903
|
+
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
1797
1904
|
`));
|
|
1798
1905
|
}
|
|
1799
1906
|
await fs2.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
@@ -1804,8 +1911,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1804
1911
|
|
|
1805
1912
|
// src/generateClientSdkPackage.ts
|
|
1806
1913
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion) {
|
|
1807
|
-
if (!packageName)
|
|
1808
|
-
throw new Error("Package name is require");
|
|
1914
|
+
if (!packageName) throw new Error("Package name is require");
|
|
1809
1915
|
for (const packageType of ["module", "commonjs"]) {
|
|
1810
1916
|
const outDir = path16.join(baseOutDir, "dist", packageType);
|
|
1811
1917
|
await (sdkVersion === "1.1" ? generateClientSdkVersionOneDotOne : sdkVersion === "2.0" ? generateClientSdkVersionTwoPointZero : void 0)(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType);
|
|
@@ -1923,5 +2029,5 @@ async function writeJson(minimalFs, filePath, body) {
|
|
|
1923
2029
|
}
|
|
1924
2030
|
|
|
1925
2031
|
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero, getExpectedDependencies };
|
|
1926
|
-
//# sourceMappingURL=
|
|
2032
|
+
//# sourceMappingURL=index.js.map
|
|
1927
2033
|
//# sourceMappingURL=index.js.map
|