@osdk/generator 1.12.0-main-20240530094422 → 1.12.0
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 +56 -6
- package/build/browser/index.js +144 -39
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +146 -39
- 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/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 +144 -39
- 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/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
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockMinimalFiles.d.ts","sourceRoot":"","sources":["../../../../src/util/test/createMockMinimalFiles.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,sBAAsB
|
|
1
|
+
{"version":3,"file":"createMockMinimalFiles.d.ts","sourceRoot":"","sources":["../../../../src/util/test/createMockMinimalFiles.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,sBAAsB;;mBAaR,WAAW;;iBAEf,SAAS;;;;;;EAWlC"}
|
|
@@ -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
|
})}
|
|
@@ -331,13 +367,13 @@ 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
|
|
|
@@ -375,7 +411,7 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
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
413
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
378
|
-
import type { ActionSignature, ApplyActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
414
|
+
import type { ActionSignature, ApplyActionOptions, ApplyBatchActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
379
415
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
380
416
|
${importObjects}
|
|
381
417
|
|
|
@@ -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
|
`;
|
|
@@ -603,8 +639,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
603
639
|
var captureInBracketsRegex = /<(.*?)>/;
|
|
604
640
|
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
605
641
|
function cleanup(s) {
|
|
606
|
-
if (s.length === 0)
|
|
607
|
-
return "";
|
|
642
|
+
if (s.length === 0) return "";
|
|
608
643
|
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
609
644
|
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
610
645
|
});
|
|
@@ -906,10 +941,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
906
941
|
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
907
942
|
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
908
943
|
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
909
|
-
await fs2.writeFile(
|
|
910
|
-
path16.join(runtimeDistDir, "index.ts"),
|
|
911
|
-
// TRASHFIXME
|
|
912
|
-
await formatTs(`
|
|
944
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`
|
|
913
945
|
export * from "./aggregations/index${importExt}";
|
|
914
946
|
export * from "./baseTypes/index${importExt}";
|
|
915
947
|
${""}
|
|
@@ -919,8 +951,7 @@ async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
|
919
951
|
|
|
920
952
|
export * from "./ontologyProvider/index${importExt}";
|
|
921
953
|
export * from "./paging/index${importExt}";
|
|
922
|
-
`)
|
|
923
|
-
);
|
|
954
|
+
`));
|
|
924
955
|
}
|
|
925
956
|
|
|
926
957
|
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
@@ -1283,10 +1314,10 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1283
1314
|
case "union":
|
|
1284
1315
|
const allowNulls = isNullableQueryDataType(input);
|
|
1285
1316
|
if (allowNulls && input.unionTypes.length === 2) {
|
|
1286
|
-
const
|
|
1287
|
-
if (
|
|
1317
|
+
const nonNull = input.unionTypes.find((t) => t.type != null);
|
|
1318
|
+
if (nonNull) {
|
|
1288
1319
|
return {
|
|
1289
|
-
...wireQueryDataTypeToQueryDataTypeDefinition(
|
|
1320
|
+
...wireQueryDataTypeToQueryDataTypeDefinition(nonNull),
|
|
1290
1321
|
nullable: true
|
|
1291
1322
|
};
|
|
1292
1323
|
}
|
|
@@ -1311,12 +1342,14 @@ function wireQueryDataTypeToQueryDataTypeDefinition(input) {
|
|
|
1311
1342
|
case "twoDimensionalAggregation":
|
|
1312
1343
|
return {
|
|
1313
1344
|
type: "twoDimensionalAggregation",
|
|
1314
|
-
twoDimensionalAggregation: get2DQueryAggregationProps(input)
|
|
1345
|
+
twoDimensionalAggregation: get2DQueryAggregationProps(input),
|
|
1346
|
+
nullable: false
|
|
1315
1347
|
};
|
|
1316
1348
|
case "threeDimensionalAggregation":
|
|
1317
1349
|
return {
|
|
1318
1350
|
type: "threeDimensionalAggregation",
|
|
1319
|
-
threeDimensionalAggregation: get3DQueryAggregationProps(input)
|
|
1351
|
+
threeDimensionalAggregation: get3DQueryAggregationProps(input),
|
|
1352
|
+
nullable: false
|
|
1320
1353
|
};
|
|
1321
1354
|
case "null":
|
|
1322
1355
|
case "unsupported":
|
|
@@ -1375,6 +1408,15 @@ function wireQueryTypeV2ToSdkQueryDefinition(input) {
|
|
|
1375
1408
|
output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)
|
|
1376
1409
|
};
|
|
1377
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
|
+
}
|
|
1378
1420
|
function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
1379
1421
|
return {
|
|
1380
1422
|
description: parameter.description,
|
|
@@ -1383,19 +1425,36 @@ function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
|
1383
1425
|
}
|
|
1384
1426
|
|
|
1385
1427
|
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1386
|
-
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1428
|
+
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "", v2 = false) {
|
|
1387
1429
|
await fs2.mkdir(outDir, {
|
|
1388
1430
|
recursive: true
|
|
1389
1431
|
});
|
|
1390
1432
|
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1391
1433
|
const objectTypes = getObjectTypesFromQuery(query);
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
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
|
+
}
|
|
1396
1454
|
}));
|
|
1397
1455
|
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1398
1456
|
${Object.values(ontology.queryTypes).map((query) => `export * from "./${query.apiName}${importExt}";`).join("\n")}
|
|
1457
|
+
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1399
1458
|
`));
|
|
1400
1459
|
}
|
|
1401
1460
|
function getObjectTypesFromQuery(query) {
|
|
@@ -1448,6 +1507,14 @@ function getObjectTypesFromDataType(dataType, types) {
|
|
|
1448
1507
|
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1449
1508
|
}
|
|
1450
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
|
+
}
|
|
1451
1518
|
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1452
1519
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
1453
1520
|
const signatures = [];
|
|
@@ -1597,7 +1664,7 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1597
1664
|
const objectsDir = path16.join(outDir, "ontology", "objects");
|
|
1598
1665
|
const actionsDir = path16.join(outDir, "ontology", "actions");
|
|
1599
1666
|
const queriesDir = path16.join(outDir, "ontology", "queries");
|
|
1600
|
-
await
|
|
1667
|
+
await verifyOutDir(outDir, fs2);
|
|
1601
1668
|
await fs2.mkdir(outDir, {
|
|
1602
1669
|
recursive: true
|
|
1603
1670
|
});
|
|
@@ -1617,9 +1684,37 @@ async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDi
|
|
|
1617
1684
|
await generateIndexFile(fs2, outDir, importExt);
|
|
1618
1685
|
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1619
1686
|
}
|
|
1620
|
-
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
|
|
1687
|
+
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false) {
|
|
1621
1688
|
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
|
|
1622
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
|
+
}
|
|
1623
1718
|
function getV2Types() {
|
|
1624
1719
|
return `
|
|
1625
1720
|
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
@@ -1633,9 +1728,9 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1633
1728
|
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
1634
1729
|
})}
|
|
1635
1730
|
}`,
|
|
1636
|
-
properties: (
|
|
1637
|
-
${stringify(
|
|
1638
|
-
"*": (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"}">`]
|
|
1639
1734
|
})}
|
|
1640
1735
|
}`
|
|
1641
1736
|
})}
|
|
@@ -1656,7 +1751,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1656
1751
|
|
|
1657
1752
|
};`;
|
|
1658
1753
|
}
|
|
1659
|
-
var ExpectedOsdkVersion = "0.
|
|
1754
|
+
var ExpectedOsdkVersion = "0.20.0";
|
|
1660
1755
|
async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
1661
1756
|
fs2.writeFile(path16__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1662
1757
|
import { OntologyMetadata as OM } from "@osdk/api";
|
|
@@ -1677,11 +1772,11 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
|
1677
1772
|
|
|
1678
1773
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1679
1774
|
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1680
|
-
await
|
|
1775
|
+
await verifyOutDir(outDir, fs2);
|
|
1681
1776
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1682
1777
|
const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
|
|
1683
1778
|
const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
|
|
1684
|
-
Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1779
|
+
const queryNames = Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1685
1780
|
const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
|
|
1686
1781
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1687
1782
|
await fs2.mkdir(outDir, {
|
|
@@ -1692,6 +1787,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1692
1787
|
export * from "./ontology/actions/index${importExt}";
|
|
1693
1788
|
export * from "./ontology/objects${importExt}";
|
|
1694
1789
|
export * from "./ontology/interfaces${importExt}";
|
|
1790
|
+
export * from "./ontology/queries/index${importExt}";
|
|
1695
1791
|
`));
|
|
1696
1792
|
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs2, outDir);
|
|
1697
1793
|
await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
@@ -1699,6 +1795,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1699
1795
|
import * as Actions from "./ontology/actions/index${importExt}";
|
|
1700
1796
|
import * as Objects from "./ontology/objects${importExt}";
|
|
1701
1797
|
import * as Interfaces from "./ontology/interfaces${importExt}";
|
|
1798
|
+
import * as Queries from "./ontology/queries/index${importExt}";
|
|
1702
1799
|
import { OntologyMetadata } from "./OntologyMetadata${importExt}";
|
|
1703
1800
|
|
|
1704
1801
|
export interface Ontology extends OntologyDefinition<${stringUnionFrom2(objectNames)}> {
|
|
@@ -1714,7 +1811,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1714
1811
|
}).join(",\n")}
|
|
1715
1812
|
},
|
|
1716
1813
|
queries: {
|
|
1717
|
-
|
|
1814
|
+
${queryNames.map((queryName) => {
|
|
1815
|
+
return `${queryName}: typeof Queries.${queryName}`;
|
|
1816
|
+
}).join(",\n")}
|
|
1718
1817
|
},
|
|
1719
1818
|
interfaces: {
|
|
1720
1819
|
${interfaceNames.map((objectName) => {
|
|
@@ -1737,7 +1836,9 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1737
1836
|
}).join(",\n")}
|
|
1738
1837
|
},
|
|
1739
1838
|
queries: {
|
|
1740
|
-
|
|
1839
|
+
${queryNames.map((queryName) => {
|
|
1840
|
+
return `${queryName}: Queries.${queryName}`;
|
|
1841
|
+
}).join(",\n")}
|
|
1741
1842
|
},
|
|
1742
1843
|
interfaces: {
|
|
1743
1844
|
${interfaceNames.map((objectName) => {
|
|
@@ -1772,6 +1873,11 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1772
1873
|
${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1773
1874
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
1774
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);
|
|
1775
1881
|
}
|
|
1776
1882
|
function stringUnionFrom2(values) {
|
|
1777
1883
|
if (values.length === 0) {
|
|
@@ -1793,7 +1899,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1793
1899
|
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1794
1900
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1795
1901
|
|
|
1796
|
-
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
|
|
1902
|
+
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, ontology, true)}
|
|
1797
1903
|
`));
|
|
1798
1904
|
}
|
|
1799
1905
|
await fs2.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
@@ -1804,8 +1910,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1804
1910
|
|
|
1805
1911
|
// src/generateClientSdkPackage.ts
|
|
1806
1912
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion) {
|
|
1807
|
-
if (!packageName)
|
|
1808
|
-
throw new Error("Package name is require");
|
|
1913
|
+
if (!packageName) throw new Error("Package name is require");
|
|
1809
1914
|
for (const packageType of ["module", "commonjs"]) {
|
|
1810
1915
|
const outDir = path16.join(baseOutDir, "dist", packageType);
|
|
1811
1916
|
await (sdkVersion === "1.1" ? generateClientSdkVersionOneDotOne : sdkVersion === "2.0" ? generateClientSdkVersionTwoPointZero : void 0)(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType);
|