@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.
- package/CHANGELOG.md +21 -5
- package/build/browser/index.js +138 -31
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +140 -31
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.cts +2 -1
- 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/propertyJsdoc.d.cts +6 -0
- package/build/cjs/shared/propertyJsdoc.d.ts.map +1 -0
- 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/{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 +138 -31
- package/build/esm/index.js.map +1 -1
- package/build/esm/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts +2 -1
- 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/propertyJsdoc.d.ts +6 -0
- package/build/esm/shared/propertyJsdoc.d.ts.map +1 -0
- 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/{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 +13 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InterfaceType } from "@osdk/gateway/types";
|
|
2
|
+
import type { WireOntologyDefinition } from "../WireOntologyDefinition.cjs";
|
|
2
3
|
/** @internal */
|
|
3
|
-
export declare function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef: InterfaceType, v2?: boolean): string;
|
|
4
|
+
export declare function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef: InterfaceType, ontology: WireOntologyDefinition, v2?: boolean): string;
|
|
4
5
|
//# sourceMappingURL=UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts","sourceRoot":"","sources":["../../../src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts","sourceRoot":"","sources":["../../../src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAI3E,gBAAgB;AAChB,wBAAgB,8CAA8C,CAC5D,YAAY,EAAE,aAAa,EAC3B,QAAQ,EAAE,sBAAsB,EAChC,EAAE,GAAE,OAAe,UA4HpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.d.ts","sourceRoot":"","sources":["../../../src/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ObjectTypePropertyDefinition } from "@osdk/api";
|
|
2
|
+
export declare function propertyJsdoc(property: ObjectTypePropertyDefinition, { isInherited, apiName }: {
|
|
3
|
+
isInherited?: boolean;
|
|
4
|
+
apiName: string;
|
|
5
|
+
}): string;
|
|
6
|
+
//# sourceMappingURL=propertyJsdoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertyJsdoc.d.ts","sourceRoot":"","sources":["../../../src/shared/propertyJsdoc.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,4BAA4B,EACtC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,UAyBrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConst.d.ts","sourceRoot":"","sources":["../../../src/shared/wireObjectTypeV2ToSdkObjectConst.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConst.d.ts","sourceRoot":"","sources":["../../../src/shared/wireObjectTypeV2ToSdkObjectConst.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAMlE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,UAE/D;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,sBAAsB,EAC9B,SAAS,EAAE,MAAM,EACjB,EAAE,GAAE,OAAe,UAsGpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { QueryDataTypeDefinition } from "@osdk/api";
|
|
2
2
|
import type { QueryDataType } from "@osdk/gateway/types";
|
|
3
|
-
export declare function wireQueryDataTypeToQueryDataTypeDefinition<K extends string>(input: QueryDataType): QueryDataTypeDefinition<K>;
|
|
3
|
+
export declare function wireQueryDataTypeToQueryDataTypeDefinition<K extends string>(input: QueryDataType): QueryDataTypeDefinition<K, any>;
|
|
4
4
|
//# sourceMappingURL=wireQueryDataTypeToQueryDataTypeDefinition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireQueryDataTypeToQueryDataTypeDefinition.d.ts","sourceRoot":"","sources":["../../../src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAIV,aAAa,EAGd,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"wireQueryDataTypeToQueryDataTypeDefinition.d.ts","sourceRoot":"","sources":["../../../src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAIV,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAI7B,wBAAgB,0CAA0C,CACxD,CAAC,SAAS,MAAM,EAEhB,KAAK,EAAE,aAAa,GACnB,uBAAuB,CAAC,CAAC,EAAE,GAAG,CAAC,CAuGjC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type { QueryDefinition } from "@osdk/api";
|
|
2
|
-
import type { QueryTypeV2 } from "@osdk/gateway/types";
|
|
1
|
+
import type { QueryDefinition, QueryParameterDefinition } from "@osdk/api";
|
|
2
|
+
import type { QueryParameterV2, QueryTypeV2 } from "@osdk/gateway/types";
|
|
3
3
|
export declare function wireQueryTypeV2ToSdkQueryDefinition(input: QueryTypeV2): QueryDefinition<any, any>;
|
|
4
|
+
export declare function wireQueryTypeV2ToSdkQueryDefinitionNoParams(input: QueryTypeV2): {
|
|
5
|
+
type: string;
|
|
6
|
+
apiName: string;
|
|
7
|
+
description: string | undefined;
|
|
8
|
+
displayName: string | undefined;
|
|
9
|
+
version: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function wireQueryParameterV2ToQueryParameterDefinition(parameter: QueryParameterV2): QueryParameterDefinition<any>;
|
|
4
12
|
//# sourceMappingURL=wireQueryTypeV2ToSdkQueryDefinition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireQueryTypeV2ToSdkQueryDefinition.d.ts","sourceRoot":"","sources":["../../../src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"wireQueryTypeV2ToSdkQueryDefinition.d.ts","sourceRoot":"","sources":["../../../src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKzE,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,WAAW,GACjB,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAc3B;AAED,wBAAgB,2CAA2C,CACzD,KAAK,EAAE,WAAW;;;;;;EASnB;AAED,wBAAgB,8CAA8C,CAC5D,SAAS,EAAE,gBAAgB,GAC1B,wBAAwB,CAAC,GAAG,CAAC,CAK/B"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* A function for changing the stringified key/value pairs of an object.
|
|
3
3
|
*
|
|
4
4
|
* @param value The value of the key/value pair.
|
|
5
|
-
* @param defaultValueFormatter The function that would be called if this customizer
|
|
5
|
+
* @param defaultValueFormatter The function that would be called if this customizer wasn't used
|
|
6
6
|
* @param key The key of the key/value pair.
|
|
7
|
-
* @param defaultKeyFormatter The function that would be called if this customizer
|
|
7
|
+
* @param defaultKeyFormatter The function that would be called if this customizer wasn't used
|
|
8
8
|
*
|
|
9
9
|
* @returns A string, a tuple of strings, or undefined.
|
|
10
10
|
* If a string is returned, it will be used as the value of the key/value pair.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* and the second string will be used as the value of the key/value pair.
|
|
13
13
|
* If undefined is returned, the pair will be removed
|
|
14
14
|
*/
|
|
15
|
-
type Customizer<K, V extends {}> = (value: V, defaultValueFormatter: (value: any) => string, key: K, defaultKeyFormatter: (key: string) => string) => [string, string] | string | undefined;
|
|
15
|
+
type Customizer<K extends string | symbol | number, V extends {}> = (value: V, defaultValueFormatter: (value: any) => string, key: K extends "*" ? string : K, defaultKeyFormatter: (key: string) => string) => [string, string] | string | undefined;
|
|
16
16
|
export declare function stringify<T extends Record<string, any>>(obj: T, customizer?: {
|
|
17
17
|
[K in keyof T | "*"]?: Customizer<K, T[K]>;
|
|
18
18
|
}, separator?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../../src/util/stringify.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../../src/util/stringify.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,CAClE,KAAK,EAAE,CAAC,EACR,qBAAqB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,EAC7C,GAAG,EAAE,CAAC,SAAS,GAAG,GAAG,MAAM,GAAG,CAAC,EAC/B,mBAAmB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KACzC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;AAU3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,GAAG,EAAE,CAAC,EACN,UAAU,GAAE;KACT,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC,EACN,SAAS,SAAQ,UA0BlB"}
|
|
@@ -5,5 +5,5 @@ import type { MinimalFs } from "../MinimalFs.cjs";
|
|
|
5
5
|
* Re-generating an ontology on top of itself is not supported and may leave old
|
|
6
6
|
* files around or refuse to update files with new contents in some cases.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export declare function verifyOutDir(outDir: string, fs: MinimalFs): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=verifyOutDir.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"verifyOutDir.d.ts","sourceRoot":"","sources":["../../../src/util/verifyOutDir.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,iBAgB/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateOntologyRuntimeDistDir.d.ts","sourceRoot":"","sources":["../../../../src/v1.1/backcompat/generateOntologyRuntimeDistDir.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AASpD,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,SAAS,EACb,SAAS,SAAK,
|
|
1
|
+
{"version":3,"file":"generateOntologyRuntimeDistDir.d.ts","sourceRoot":"","sources":["../../../../src/v1.1/backcompat/generateOntologyRuntimeDistDir.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AASpD,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,SAAS,EACb,SAAS,SAAK,iBA6Cf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MinimalFs } from "../MinimalFs.cjs";
|
|
2
2
|
import type { WireOntologyDefinition } from "../WireOntologyDefinition.cjs";
|
|
3
|
-
export declare function generatePerQueryDataFiles(ontology: WireOntologyDefinition, fs: MinimalFs, outDir: string, importExt?: string): Promise<void>;
|
|
3
|
+
export declare function generatePerQueryDataFiles(ontology: WireOntologyDefinition, fs: MinimalFs, outDir: string, importExt?: string, v2?: boolean): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=generatePerQueryDataFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePerQueryDataFiles.d.ts","sourceRoot":"","sources":["../../../src/v1.1/generatePerQueryDataFiles.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"generatePerQueryDataFiles.d.ts","sourceRoot":"","sources":["../../../src/v1.1/generatePerQueryDataFiles.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAWjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,sBAAsB,EAChC,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAW,EACtB,EAAE,GAAE,OAAe,iBAqFpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClientSdkVersionTwoPointZero.d.ts","sourceRoot":"","sources":["../../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"generateClientSdkVersionTwoPointZero.d.ts","sourceRoot":"","sources":["../../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAUjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG3E,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,QAAQ,GAAG,UAAuB,iBAgLhD"}
|
package/build/esm/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
|
|
|
@@ -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
|
})}
|
|
@@ -446,8 +482,8 @@ function camelize(name) {
|
|
|
446
482
|
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
447
483
|
}
|
|
448
484
|
|
|
449
|
-
// src/util/
|
|
450
|
-
async function
|
|
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
|
|
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
|
|
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
|
|
1286
|
-
if (
|
|
1317
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1318
|
+
if (nonNull) {
|
|
1287
1319
|
return {
|
|
1288
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(
|
|
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
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
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
|
|
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: (
|
|
1636
|
-
${stringify(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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(`
|