@osdk/generator 1.9.0 → 1.9.1-main-20240411211601
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_OLD.md → CHANGELOG.md} +10 -0
- package/build/js/index.cjs +1200 -1072
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +1182 -1056
- package/build/js/index.mjs.map +1 -1
- package/build/types/generateClientSdkPackage.d.ts +53 -0
- package/build/types/generateClientSdkPackage.d.ts.map +1 -0
- package/build/types/generateClientSdkPackage.test.d.ts +2 -0
- package/build/types/generateClientSdkPackage.test.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/shared/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/types/shared/generatePerActionDataFiles.d.ts.map +1 -0
- package/build/types/shared/generatePerActionDataFiles.test.d.ts.map +1 -0
- package/build/types/shared/wireObjectTypeV2ToSdkObjectConst.d.ts.map +1 -1
- package/build/types/v1.1/generateClientSdkVersionOneDotOne.d.ts.map +1 -1
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/types/v2.0/generateMetadata.d.ts.map +1 -1
- package/package.json +5 -6
- package/build/types/v1.1/generatePerActionDataFiles.d.ts.map +0 -1
- package/build/types/v1.1/generatePerActionDataFiles.test.d.ts.map +0 -1
- package/changelog/1.2.0/pr-10.v2.yml +0 -5
- package/changelog/1.3.0/pr-20.v2.yml +0 -5
- package/changelog/1.4.0/pr-34.v2.yml +0 -5
- package/changelog/1.4.0/pr-48.v2.yml +0 -5
- package/changelog/1.4.0/pr-53.v2.yml +0 -5
- package/changelog/1.4.0/pr-65.v2.yml +0 -5
- package/changelog/1.6.0/pr-67.v2.yml +0 -5
- package/changelog/1.6.0/pr-83.v2.yml +0 -5
- package/changelog/1.6.0/pr-88.v2.yml +0 -5
- package/changelog/1.6.0/pr-89.v2.yml +0 -5
- package/changelog/1.7.0/pr-101.v2.yml +0 -5
- package/changelog/1.7.0/pr-102.v2.yml +0 -5
- package/changelog/1.7.0/pr-113.v2.yml +0 -5
- package/changelog/1.7.0/pr-120.v2.yml +0 -5
- package/changelog/1.7.0/pr-121.v2.yml +0 -5
- package/changelog/1.7.0/pr-124.v2.yml +0 -5
- package/changelog/1.8.0/pr-138.v2.yml +0 -5
- package/changelog/1.8.0/pr-140.v2.yml +0 -5
- package/changelog/1.8.0/pr-141.v2.yml +0 -5
- package/changelog/1.8.0/pr-142.v2.yml +0 -5
- package/changelog/1.9.0/pr-151.v2.yml +0 -5
- package/changelog/@unreleased/.gitkeep +0 -0
- /package/build/types/{v1.1 → shared}/generatePerActionDataFiles.d.ts +0 -0
- /package/build/types/{v1.1 → shared}/generatePerActionDataFiles.test.d.ts +0 -0
package/build/js/index.mjs
CHANGED
|
@@ -1,39 +1,132 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path16 from 'path';
|
|
3
|
+
import path16__default, { join } from 'path';
|
|
3
4
|
import { format } from 'prettier';
|
|
4
5
|
import organizeImports from 'prettier-plugin-organize-imports';
|
|
5
6
|
import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
|
|
6
7
|
|
|
7
|
-
// src/
|
|
8
|
+
// src/generateClientSdkPackage.ts
|
|
8
9
|
|
|
9
|
-
// src/
|
|
10
|
-
function
|
|
11
|
-
return
|
|
12
|
-
...ontology,
|
|
13
|
-
actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map((actionType) => {
|
|
14
|
-
return [camelize(actionType.apiName), {
|
|
15
|
-
...actionType,
|
|
16
|
-
apiName: camelize(actionType.apiName)
|
|
17
|
-
}];
|
|
18
|
-
}))
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function camelize(name) {
|
|
22
|
-
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
10
|
+
// src/util/deleteUndefineds.ts
|
|
11
|
+
function deleteUndefineds(obj) {
|
|
12
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
|
|
23
13
|
}
|
|
24
14
|
|
|
25
|
-
// src/util/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
// src/util/stringify.ts
|
|
16
|
+
var defaultCustomizer = (value, defaultValueFormatter, key, defaultKeyFormatter) => {
|
|
17
|
+
return [defaultKeyFormatter(key), defaultValueFormatter(value)];
|
|
18
|
+
};
|
|
19
|
+
function stringify(obj, customizer = {}, separator = ",\n") {
|
|
20
|
+
const defaultKeyFormatter = (key) => `${JSON.stringify(key)}`;
|
|
21
|
+
const entries = [];
|
|
22
|
+
const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
|
|
23
|
+
for (const key of sortedKeys) {
|
|
24
|
+
const value = obj[key];
|
|
25
|
+
const res = (customizer[key] ?? customizer["*"] ?? defaultCustomizer)(value, (value2) => JSON.stringify(value2, null, 2), key, defaultKeyFormatter);
|
|
26
|
+
if (res) {
|
|
27
|
+
if (typeof res === "string") {
|
|
28
|
+
entries.push(`${defaultKeyFormatter(key)}: ${res}`);
|
|
29
|
+
} else {
|
|
30
|
+
entries.push(`${res[0]}: ${res[1]}`);
|
|
31
|
+
}
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
return entries.join(separator);
|
|
35
|
+
}
|
|
36
|
+
function formatTs(contents) {
|
|
37
|
+
return format(contents, {
|
|
38
|
+
parser: "typescript",
|
|
39
|
+
singleQuote: true,
|
|
40
|
+
trailingComma: "all",
|
|
41
|
+
plugins: [organizeImports],
|
|
42
|
+
tabWidth: 2,
|
|
43
|
+
printWidth: 120
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/util/reservedKeywords.ts
|
|
48
|
+
var reservedKeywords = /* @__PURE__ */ new Set(["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "null", "return", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"]);
|
|
49
|
+
function isReservedKeyword(name) {
|
|
50
|
+
return reservedKeywords.has(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts
|
|
54
|
+
function wireObjectTypeV2ToObjectInterfaceStringV1(objectTypeWithLinks, importExt = "") {
|
|
55
|
+
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";
|
|
57
|
+
${Array.from(uniqueLinkTargets).map((linkTarget) => `import type { ${linkTarget} } from "./${linkTarget}${importExt}";`).join("\n")}
|
|
58
|
+
|
|
59
|
+
${getDescriptionIfPresent(objectTypeWithLinks.objectType.description)}
|
|
60
|
+
export interface ${objectTypeWithLinks.objectType.apiName} extends OntologyObject {
|
|
61
|
+
/** @deprecated please migrate to $apiName instead */
|
|
62
|
+
readonly __apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
63
|
+
/** @deprecated please migrate to $primaryKey instead */
|
|
64
|
+
readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
65
|
+
readonly $apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
66
|
+
readonly $primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
67
|
+
${Object.entries(objectTypeWithLinks.objectType.properties).sort((a, b) => a[0].localeCompare(b[0])).flatMap(([propertyName, propertyDefinition]) => {
|
|
68
|
+
const propertyType = wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType);
|
|
69
|
+
const entries = [`${getDescriptionIfPresent(propertyDefinition.description, true)}readonly ${propertyName}: ${propertyType} | undefined`];
|
|
70
|
+
if (isReservedKeyword(propertyName)) {
|
|
71
|
+
entries.push(`/** @deprecated please migrate to '${propertyName}' instead */
|
|
72
|
+
readonly ${propertyName}_: ${propertyType} | undefined`);
|
|
35
73
|
}
|
|
74
|
+
return entries;
|
|
75
|
+
}).join(";\n")}
|
|
76
|
+
${objectTypeWithLinks.linkTypes.flatMap((linkType) => {
|
|
77
|
+
const entries = [`readonly ${linkType.apiName}: ${linkType.cardinality === "MANY" ? "MultiLink" : "SingleLink"}<${linkType.objectTypeApiName}>`];
|
|
78
|
+
return entries;
|
|
79
|
+
}).join(";\n")}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
function wirePropertyTypeV2ToTypeScriptType(property) {
|
|
84
|
+
switch (property.type) {
|
|
85
|
+
case "string":
|
|
86
|
+
return "string";
|
|
87
|
+
case "boolean":
|
|
88
|
+
return "boolean";
|
|
89
|
+
case "array":
|
|
90
|
+
return wirePropertyTypeV2ToTypeScriptType(property.subType) + "[]";
|
|
91
|
+
case "integer":
|
|
92
|
+
return "number";
|
|
93
|
+
case "attachment":
|
|
94
|
+
return "Attachment";
|
|
95
|
+
case "byte":
|
|
96
|
+
return "number";
|
|
97
|
+
case "date":
|
|
98
|
+
return "LocalDate";
|
|
99
|
+
case "decimal":
|
|
100
|
+
return "string";
|
|
101
|
+
case "double":
|
|
102
|
+
return "number";
|
|
103
|
+
case "float":
|
|
104
|
+
return "number";
|
|
105
|
+
case "geopoint":
|
|
106
|
+
return "GeoPoint";
|
|
107
|
+
case "geoshape":
|
|
108
|
+
return "GeoShape";
|
|
109
|
+
case "long":
|
|
110
|
+
return "string";
|
|
111
|
+
case "short":
|
|
112
|
+
return "number";
|
|
113
|
+
case "timestamp":
|
|
114
|
+
return "Timestamp";
|
|
115
|
+
case "timeseries":
|
|
116
|
+
return property.itemType.type === "string" ? `TimeSeries<string>` : `TimeSeries<number>`;
|
|
117
|
+
case "marking":
|
|
118
|
+
return "string";
|
|
119
|
+
default:
|
|
120
|
+
throw new Error(`Unknown property type ${property}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function getDescriptionIfPresent(description, includeNewline) {
|
|
124
|
+
if (description) {
|
|
125
|
+
return `/**
|
|
126
|
+
* ${description}
|
|
127
|
+
*/${includeNewline ? "\n" : ""}`;
|
|
36
128
|
}
|
|
129
|
+
return "";
|
|
37
130
|
}
|
|
38
131
|
|
|
39
132
|
// src/shared/getEditedEntities.ts
|
|
@@ -55,488 +148,316 @@ function getModifiedEntityTypes(action) {
|
|
|
55
148
|
modifiedObjects
|
|
56
149
|
};
|
|
57
150
|
}
|
|
58
|
-
function formatTs(contents) {
|
|
59
|
-
return format(contents, {
|
|
60
|
-
parser: "typescript",
|
|
61
|
-
singleQuote: true,
|
|
62
|
-
trailingComma: "all",
|
|
63
|
-
plugins: [organizeImports],
|
|
64
|
-
tabWidth: 2,
|
|
65
|
-
printWidth: 120
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
151
|
|
|
69
|
-
// src/
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let jsDocBlock = ["/**"];
|
|
81
|
-
if (action.description) {
|
|
82
|
-
jsDocBlock.push(`* ${action.description}`);
|
|
83
|
-
}
|
|
84
|
-
let parameterBlock = "";
|
|
85
|
-
if (entries.length > 0) {
|
|
86
|
-
parameterBlock = `params: {
|
|
87
|
-
`;
|
|
88
|
-
for (const [parameterName, parameterData] of entries) {
|
|
89
|
-
parameterBlock += `"${parameterName}"`;
|
|
90
|
-
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
91
|
-
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
92
|
-
parameterBlock += `${typeScriptType};
|
|
93
|
-
`;
|
|
94
|
-
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
95
|
-
}
|
|
96
|
-
parameterBlock += "}, ";
|
|
97
|
-
}
|
|
98
|
-
jsDocBlock.push(`*/`);
|
|
99
|
-
actionSignatures.push(`
|
|
100
|
-
${jsDocBlock.join("\n")}
|
|
101
|
-
${action.apiName}<O extends ActionExecutionOptions>(${parameterBlock}options?: O):
|
|
102
|
-
Promise<Result<ActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;`);
|
|
103
|
-
}
|
|
104
|
-
await fs.mkdir(outDir, {
|
|
105
|
-
recursive: true
|
|
106
|
-
});
|
|
107
|
-
await fs.writeFile(path15__default.join(outDir, "Actions.ts"), await formatTs(`
|
|
108
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from "@osdk/legacy-client";
|
|
109
|
-
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
110
|
-
export interface Actions {
|
|
111
|
-
${actionSignatures.join("\n")}
|
|
112
|
-
}
|
|
113
|
-
`));
|
|
152
|
+
// src/shared/wireActionTypeV2ToSdkActionDefinition.ts
|
|
153
|
+
function wireActionTypeV2ToSdkActionDefinition(input) {
|
|
154
|
+
const modifiedEntityTypes = getModifiedEntityTypes(input);
|
|
155
|
+
return {
|
|
156
|
+
type: "action",
|
|
157
|
+
apiName: input.apiName,
|
|
158
|
+
parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),
|
|
159
|
+
displayName: input.displayName,
|
|
160
|
+
description: input.description,
|
|
161
|
+
modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects)
|
|
162
|
+
};
|
|
114
163
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return `${objectType} | ${objectType}["__primaryKey"]`;
|
|
126
|
-
}
|
|
127
|
-
case "array":
|
|
128
|
-
return `Array<${getTypeScriptTypeFromDataType(actionParameter.subType, importedObjects)}>`;
|
|
164
|
+
function wireActionParameterV2ToSdkParameterDefinition(value) {
|
|
165
|
+
return {
|
|
166
|
+
multiplicity: value.dataType.type === "array",
|
|
167
|
+
type: actionPropertyToSdkPropertyDefinition(value.dataType.type === "array" ? value.dataType.subType : value.dataType),
|
|
168
|
+
nullable: !value.required,
|
|
169
|
+
description: value.description
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function actionPropertyToSdkPropertyDefinition(parameterType) {
|
|
173
|
+
switch (parameterType.type) {
|
|
129
174
|
case "string":
|
|
130
|
-
return `string`;
|
|
131
175
|
case "boolean":
|
|
132
|
-
return `boolean`;
|
|
133
176
|
case "attachment":
|
|
134
|
-
return `Attachment`;
|
|
135
|
-
case "date":
|
|
136
|
-
return `LocalDate`;
|
|
137
177
|
case "double":
|
|
138
178
|
case "integer":
|
|
139
179
|
case "long":
|
|
140
|
-
return `number`;
|
|
141
180
|
case "timestamp":
|
|
142
|
-
return `Timestamp`;
|
|
143
181
|
case "marking":
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
182
|
+
return parameterType.type;
|
|
183
|
+
case "date":
|
|
184
|
+
return "datetime";
|
|
185
|
+
case "objectSet":
|
|
186
|
+
return {
|
|
187
|
+
type: "objectSet",
|
|
188
|
+
objectSet: parameterType.objectTypeApiName
|
|
189
|
+
};
|
|
190
|
+
case "object":
|
|
191
|
+
return {
|
|
192
|
+
type: "object",
|
|
193
|
+
object: parameterType.objectTypeApiName
|
|
194
|
+
};
|
|
195
|
+
case "array":
|
|
196
|
+
return actionPropertyToSdkPropertyDefinition(parameterType.subType);
|
|
147
197
|
}
|
|
148
198
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
await fs.writeFile(path15__default.join(confidentialClientDistDir, "index.ts"), await formatTs(`
|
|
169
|
-
export * from "./ConfidentialClientAuth${importExt}";
|
|
170
|
-
`));
|
|
171
|
-
await fs.writeFile(path15__default.join(confidentialClientDistDir, "ConfidentialClientAuth.ts"), await formatTs(`
|
|
172
|
-
${reexportConsts(["ConfidentialClientAuth"])}
|
|
173
|
-
`));
|
|
174
|
-
}
|
|
175
|
-
async function generatePublicClientDir(fs, oauthDistDir, importExt = "") {
|
|
176
|
-
const publicClientDistDir = path15__default.join(oauthDistDir, "PublicClient");
|
|
177
|
-
await fs.mkdir(publicClientDistDir, {
|
|
178
|
-
recursive: true
|
|
179
|
-
});
|
|
180
|
-
await fs.writeFile(path15__default.join(publicClientDistDir, "index.ts"), await formatTs(`
|
|
181
|
-
export * from "./PublicClientAuth${importExt}";
|
|
182
|
-
`));
|
|
183
|
-
await fs.writeFile(path15__default.join(publicClientDistDir, "PublicClientAuth.ts"), await formatTs(`
|
|
184
|
-
${reexportConsts(["PublicClientAuth"])}
|
|
185
|
-
`));
|
|
199
|
+
function createModifiedEntities(addedObjects, modifiedObjects) {
|
|
200
|
+
let entities = {};
|
|
201
|
+
for (const key of addedObjects) {
|
|
202
|
+
entities[key] = {
|
|
203
|
+
created: true,
|
|
204
|
+
modified: false
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
for (const key of modifiedObjects) {
|
|
208
|
+
if (entities[key]) {
|
|
209
|
+
entities[key].modified = true;
|
|
210
|
+
} else {
|
|
211
|
+
entities[key] = {
|
|
212
|
+
created: false,
|
|
213
|
+
modified: true
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return entities;
|
|
186
218
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
await fs.mkdir(userTokenDistDir, {
|
|
190
|
-
recursive: true
|
|
191
|
-
});
|
|
192
|
-
await fs.writeFile(path15__default.join(userTokenDistDir, "index.ts"), await formatTs(`
|
|
193
|
-
export * from "./UserTokenAuth${importExt}";
|
|
194
|
-
`));
|
|
195
|
-
await fs.writeFile(path15__default.join(userTokenDistDir, "UserTokenAuth.ts"), await formatTs(`
|
|
196
|
-
${reexportConsts(["UserTokenAuth"])}
|
|
197
|
-
`));
|
|
219
|
+
function getObjectDefIdentifier(name, v2) {
|
|
220
|
+
return v2 ? name : `${name}Def`;
|
|
198
221
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
222
|
+
function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
223
|
+
const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
|
|
224
|
+
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object, v2));
|
|
225
|
+
const objectDefIdentifier = getObjectDefIdentifier(object.objectType.apiName, v2);
|
|
226
|
+
function getV1Types() {
|
|
227
|
+
return `
|
|
228
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
229
|
+
${stringify(definition, {
|
|
230
|
+
osdkMetadata: () => void 0,
|
|
231
|
+
// not used in v1
|
|
232
|
+
links: (_value) => `{
|
|
233
|
+
${stringify(definition.links, {
|
|
234
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
235
|
+
})}
|
|
236
|
+
}`
|
|
237
|
+
})}
|
|
238
|
+
}
|
|
209
239
|
`;
|
|
210
|
-
}
|
|
211
|
-
var captureInBracketsRegex = /<(.*?)>/;
|
|
212
|
-
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
213
|
-
function cleanup(s) {
|
|
214
|
-
if (s.length === 0)
|
|
215
|
-
return "";
|
|
216
|
-
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
217
|
-
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
218
|
-
});
|
|
219
|
-
return `<${genericParameterNames?.join(",")}>`;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/v1.1/backcompat/generateOAuthDistDir.ts
|
|
223
|
-
async function generateOAuthClientDistDir(outDir, fs, importExt = "") {
|
|
224
|
-
const oauthDistDir = path15.join(outDir, "internal", "@foundry", "oauth-client", "dist");
|
|
225
|
-
await fs.mkdir(oauthDistDir, {
|
|
226
|
-
recursive: true
|
|
227
|
-
});
|
|
228
|
-
await fs.writeFile(path15.join(oauthDistDir, "index.ts"), await formatTs(`
|
|
229
|
-
export * from "./Auth${importExt}";
|
|
230
|
-
export * from "./ConfidentialClient/index${importExt}";
|
|
231
|
-
export * from "./OAuthClient${importExt}";
|
|
232
|
-
export * from "./PublicClient/index${importExt}";
|
|
233
|
-
export * from "./Token${importExt}";
|
|
234
|
-
export * from "./UserToken/index${importExt}";
|
|
235
|
-
`));
|
|
236
|
-
await fs.writeFile(path15.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
237
|
-
await fs.writeFile(path15.join(oauthDistDir, "Token.ts"), await formatTs(reexportTypes(["Token", "TokenValue"])));
|
|
238
|
-
await fs.writeFile(path15.join(oauthDistDir, "OAuthClient.ts"), await formatTs(reexportTypes(["AuthSubscription", "UnsubscribeFunction", "SignInResponse", "RefreshResponse", "SignOutResponse"])));
|
|
239
|
-
await fs.writeFile(path15.join(oauthDistDir, "OAuthToken.ts"), await formatTs(reexportConsts(["OAuthToken"])));
|
|
240
|
-
await fs.writeFile(path15.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
241
|
-
await generateConfidentialClientDir(fs, oauthDistDir, importExt);
|
|
242
|
-
await generatePublicClientDir(fs, oauthDistDir, importExt);
|
|
243
|
-
await generateUserTokenDir(fs, oauthDistDir, importExt);
|
|
244
|
-
}
|
|
245
|
-
async function generateAggregationsAggregations(fs, aggregationsDir) {
|
|
246
|
-
await fs.writeFile(path15.join(aggregationsDir, "Aggregations.ts"), await formatTs(`
|
|
247
|
-
import { LocalDate, Timestamp } from "@osdk/legacy-client";
|
|
248
|
-
` + reexportTypes(["Double", "Rangeable", "MetricValue", "Date", "BucketKey", "BucketValue", "TimeUnit", "BucketGroup", "Metrics", "AggregatableProperties", "AggregationClause"]) + reexportTypes(["Range"], "<T extends Rangeable>", "<T>") + reexportTypes(["BaseGroupBy"], "<_T extends BucketValue = BucketValue>") + reexportTypes(["Duration"], "<_T extends Timestamp | LocalDate = Timestamp | LocalDate>") + reexportTypes(["AggregatableProperty", "MultipleAggregationsOperations"], "<_T extends MetricValue = MetricValue>") + reexportTypes(["AggregationGroup"], "<TMetrics extends Metrics | MetricValue, TBucketGroup extends BucketGroup>") + reexportTypes(["Bucketing"], "<_T extends string , _X extends BucketValue>") + reexportTypes(["AggregationResult"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + reexportTypes(["BaseBucketing"], "<TBucketKey extends BucketKey, TBucketValue extends BucketValue, Kind extends string>") + reexportTypes(["ExactValueBucketing", "InternalBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends BucketValue>`) + reexportTypes(["RangeBucketing", "FixedWidthBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Range<Rangeable>>`) + reexportTypes(["DurationBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Date>`) + reexportTypes(["InternalBucketingVisitor"], "<TBucketKey extends BucketKey, T extends BucketValue, R>") + reexportTypes(["AggregationBuilderResult"], "<T, TMultipleAggregationProperties>") + reexportTypes(["AggregatablePropertiesForResult", "AggregatablePropertyNamesForResult"], "<TAggregatableProperties, TResult extends MetricValue>") + reexportConsts(["assertBucketingInternal", "visitInternalBucketing"]) + reexportTypes(["AggregatableObjectSetStep"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketableProperties, TBucketGroup extends BucketGroup = {}>") + reexportTypes(["GroupedTerminalAggregationOperations"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketGroup extends BucketGroup = {}>")));
|
|
249
|
-
}
|
|
250
|
-
async function generateGroupBy(fs, aggregationsDir, importExt = "") {
|
|
251
|
-
await fs.mkdir(path15.join(aggregationsDir, "groupBy"), {
|
|
252
|
-
recursive: true
|
|
253
|
-
});
|
|
254
|
-
const groupBys = ["BooleanGroupBy", "LocalDateGroupBy", "NumericGroupBy", "StringGroupBy", "TimestampGroupBy"];
|
|
255
|
-
const reexportFiles = [...groupBys, "GroupKeyType"];
|
|
256
|
-
for (const key of reexportFiles) {
|
|
257
|
-
await fs.writeFile(path15.join(aggregationsDir, "groupBy", `${key}.ts`), await formatTs(`export {${key}} from "./index${importExt}";`));
|
|
258
240
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
241
|
+
function getV2Types() {
|
|
242
|
+
return `
|
|
243
|
+
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
244
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
245
|
+
${stringify(definition, {
|
|
246
|
+
osdkMetadata: () => void 0,
|
|
247
|
+
// we are going to reference another object instead
|
|
248
|
+
type: () => void 0,
|
|
249
|
+
apiName: () => void 0,
|
|
250
|
+
links: (_value) => `{
|
|
251
|
+
${stringify(definition.links, {
|
|
252
|
+
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
253
|
+
})}
|
|
254
|
+
}`,
|
|
255
|
+
properties: (_value) => `{
|
|
256
|
+
${stringify(definition.properties, {
|
|
257
|
+
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
258
|
+
})}
|
|
259
|
+
}`
|
|
260
|
+
})}
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
`;
|
|
277
265
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
export * from "./DefaultAggregatableProperty${importExt}";
|
|
281
|
-
export * from "./LocalDatePropertyMetric${importExt}";
|
|
282
|
-
export * from "./metrics${importExt}";
|
|
283
|
-
export * from "./MultipleAggregatableProperty${importExt}";
|
|
284
|
-
export * from "./NumericPropertyMetric${importExt}";
|
|
285
|
-
export * from "./TimestampPropertyMetric${importExt}";
|
|
286
|
-
`));
|
|
287
|
-
}
|
|
266
|
+
const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${getObjectDefIdentifier(type, v2)} } from "./${type}${importExt}";`);
|
|
267
|
+
return `${imports.join("\n")}
|
|
288
268
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
await generateAggregationsAggregations(fs, aggregationsDir);
|
|
297
|
-
await generateMetrics(fs, aggregationsDir, importExt);
|
|
298
|
-
await fs.writeFile(path15.join(aggregationsDir, "index.ts"), await formatTs(`
|
|
299
|
-
${""}
|
|
300
|
-
${""}
|
|
301
|
-
|
|
302
|
-
export * from "./Aggregations${importExt}";
|
|
303
|
-
export * from "./ComputeStep${importExt}";
|
|
304
|
-
export * from "./CountOperation${importExt}";
|
|
305
|
-
export * from "./groupBy/index${importExt}";
|
|
306
|
-
export * from "./internalAggregationRequest${importExt}";
|
|
307
|
-
export * from "./metrics/index${importExt}";
|
|
308
|
-
`));
|
|
309
|
-
await fs.writeFile(path15.join(aggregationsDir, "ComputeStep.ts"), await formatTs(`
|
|
310
|
-
import { ObjectSetDefinition } from "../baseTypes/index${importExt}";
|
|
311
|
-
import { FoundryClientOptions } from "../client/${importExt}";
|
|
312
|
-
import { AggregateObjectsError, OntologyMetadata, Result } from "../ontologyProvider/index${importExt}";
|
|
313
|
-
import { AggregationClause, AggregationResult, BucketGroup, BucketValue, InternalBucketing, Metrics, MetricValue } from "./Aggregations${importExt}";
|
|
314
|
-
` + reexportConsts(["ComputeStep"]) + reexportTypes(["ComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue> ") + reexportTypes(["AggregationComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + `
|
|
269
|
+
${v2 ? getV2Types() : getV1Types()}
|
|
270
|
+
|
|
271
|
+
export const ${object.objectType.apiName}: ${objectDefIdentifier} = {
|
|
272
|
+
${v2 ? `osdkMetadata: $osdkMetadata,` : ""}
|
|
273
|
+
${stringify(definition, {
|
|
274
|
+
osdkMetadata: (value) => void 0
|
|
275
|
+
})}
|
|
315
276
|
|
|
316
|
-
|
|
317
|
-
await fs.writeFile(path15.join(aggregationsDir, "CountOperation.ts"), await formatTs(`` + reexportConsts(["CountOperation", "isCountOperation"]) + reexportTypes(["CountOperation"])));
|
|
318
|
-
await fs.writeFile(path15.join(aggregationsDir, "internalAggregationRequest.ts"), await formatTs(reexportTypes(["InternalAggregationRequest"])));
|
|
319
|
-
}
|
|
320
|
-
async function generateAttachmentsDir(attachmentsDir, fs, importExt = "") {
|
|
321
|
-
await fs.mkdir(attachmentsDir, {
|
|
322
|
-
recursive: true
|
|
323
|
-
});
|
|
324
|
-
await fs.writeFile(path15__default.join(attachmentsDir, "index.ts"), await formatTs(`export * from "./Attachment${importExt}";
|
|
325
|
-
export * from "./Attachments${importExt}";
|
|
326
|
-
`));
|
|
327
|
-
await fs.writeFile(path15__default.join(attachmentsDir, "Attachment.ts"), await formatTs(reexportTypes(["Attachment", "AttachmentMetadata"])));
|
|
328
|
-
await fs.writeFile(path15__default.join(attachmentsDir, "Attachments.ts"), await formatTs(reexportTypes(["Attachments"])));
|
|
329
|
-
}
|
|
330
|
-
async function generateGeoshapesDir(runtimeDistDir, fs, importExt = "") {
|
|
331
|
-
await fs.mkdir(runtimeDistDir, {
|
|
332
|
-
recursive: true
|
|
333
|
-
});
|
|
334
|
-
await fs.writeFile(path15.join(runtimeDistDir, "index.ts"), await formatTs(`export * from "./Distance${importExt}";
|
|
335
|
-
export * from "./GeoJson${importExt}";
|
|
336
|
-
export * from "./GeometryCollection${importExt}";
|
|
337
|
-
export * from "./GeoPoint${importExt}";
|
|
338
|
-
export * from "./GeoShape${importExt}";
|
|
339
|
-
export * from "./LineString${importExt}";
|
|
340
|
-
export * from "./MultiGeoPoint${importExt}";
|
|
341
|
-
export * from "./MultiLineString${importExt}";
|
|
342
|
-
export * from "./MultiPolygon${importExt}";
|
|
343
|
-
export * from "./Polygon${importExt}";`));
|
|
344
|
-
await fs.writeFile(path15.join(runtimeDistDir, "Distance.ts"), await formatTs(`` + reexportConsts(["Distance", "DistanceUnit"]) + reexportTypes(["Distance", "DistanceUnit"])));
|
|
345
|
-
await fs.writeFile(path15.join(runtimeDistDir, "GeoJson.ts"), await formatTs(reexportTypes(["GeoJsonPoint", "GeoJsonPolygon", "GeoJsonLineString", "GeoJsonMultiPoint", "GeoJsonMultiPolygon", "GeoJsonMultiLineString", "GeoJsonGeometryCollection", "GeoJsonGeometry", "GeoJson"])));
|
|
346
|
-
await fs.writeFile(path15.join(runtimeDistDir, "GeometryCollection.ts"), await formatTs(reexportConsts(["GeometryCollection"])));
|
|
347
|
-
await fs.writeFile(path15.join(runtimeDistDir, "GeoPoint.ts"), await formatTs(`` + reexportConsts(["isGeoPoint", "GeoPoint", "mapCoordinatesToGeoPoint"]) + reexportTypes(["GeoHash", "Coordinates", "GeoPoint"])));
|
|
348
|
-
await fs.writeFile(path15.join(runtimeDistDir, "GeoShape.ts"), await formatTs(reexportConsts(["GeoShape"]) + reexportTypes(["GeoShape"])));
|
|
349
|
-
await fs.writeFile(path15.join(runtimeDistDir, "LineString.ts"), await formatTs(reexportConsts(["LineString"]) + reexportTypes(["LineString"])));
|
|
350
|
-
await fs.writeFile(path15.join(runtimeDistDir, "MultiGeoPoint.ts"), await formatTs(reexportConsts(["MultiGeoPoint"]) + reexportTypes(["MultiGeoPoint"])));
|
|
351
|
-
await fs.writeFile(path15.join(runtimeDistDir, "MultiLineString.ts"), await formatTs(reexportConsts(["MultiLineString"]) + reexportTypes(["MultiLineString"])));
|
|
352
|
-
await fs.writeFile(path15.join(runtimeDistDir, "MultiPolygon.ts"), await formatTs(reexportConsts(["MultiPolygon"]) + reexportTypes(["MultiPolygon"])));
|
|
353
|
-
await fs.writeFile(path15.join(runtimeDistDir, "Polygon.ts"), await formatTs(reexportConsts(["Polygon"]) + reexportTypes(["LinearRing", "Polygon"])));
|
|
354
|
-
}
|
|
355
|
-
async function generateObjectSetDir(objectSetDir, fs, importExt = "") {
|
|
356
|
-
await fs.mkdir(objectSetDir, {
|
|
357
|
-
recursive: true
|
|
358
|
-
});
|
|
359
|
-
await fs.writeFile(path15__default.join(objectSetDir, "index.ts"), await formatTs(`
|
|
360
|
-
export * from "./ObjectSetDefinition${importExt}";
|
|
361
|
-
export * from "./OntologyObjectSet${importExt}";
|
|
362
|
-
`));
|
|
363
|
-
await fs.writeFile(path15__default.join(objectSetDir, "ObjectSetDefinition.ts"), await formatTs(reexportTypes(["BaseObjectSetDefinition", "ReferenceObjectSetDefinition", "StaticObjectSetDefinition", "IntersectObjectSetDefinition", "SubtractObjectSetDefinition", "SearchAroundObjectSetDefinition", "FilterObjectSetDefinition", "ObjectSetDefinition"])));
|
|
364
|
-
await fs.writeFile(path15__default.join(objectSetDir, "OntologyObjectSet.ts"), await formatTs(reexportTypes(["OntologyObjectSet"])));
|
|
365
|
-
}
|
|
366
|
-
async function generateSharedObjectCodeDir(sharedObjectCodeDir, fs, importExt = "") {
|
|
367
|
-
await fs.mkdir(sharedObjectCodeDir, {
|
|
368
|
-
recursive: true
|
|
369
|
-
});
|
|
370
|
-
await fs.writeFile(path15__default.join(sharedObjectCodeDir, "index.ts"), await formatTs(`
|
|
371
|
-
export * from "./FilteredPropertiesTerminalOperations${importExt}";
|
|
372
|
-
`));
|
|
373
|
-
await fs.writeFile(path15__default.join(sharedObjectCodeDir, "FilteredPropertiesTerminalOperations.ts"), await formatTs(`import { OntologyObject } from "../OntologyObject${importExt}` + reexportTypes(["FilteredPropertiesTerminalOperations", "FilteredPropertiesTerminalOperationsWithGet"], "<T extends OntologyObject, V extends Array<keyof T>>")));
|
|
374
|
-
}
|
|
375
|
-
async function generateTimeSeriesDir(timeseriesDir, fs, importExt = "") {
|
|
376
|
-
await fs.mkdir(timeseriesDir, {
|
|
377
|
-
recursive: true
|
|
378
|
-
});
|
|
379
|
-
await fs.writeFile(path15.join(timeseriesDir, "index.ts"), await formatTs(`
|
|
380
|
-
export * from "./TimeSeries${importExt}";
|
|
381
|
-
export * from "./TimeSeriesDuration${importExt}";
|
|
382
|
-
export * from "./TimeSeriesPoint${importExt}";
|
|
383
|
-
${""}
|
|
384
|
-
export * from "./TimeSeriesQuery${importExt}";
|
|
385
|
-
export * from "./TimeSeriesTerminalOperations${importExt}";
|
|
386
|
-
`));
|
|
387
|
-
await fs.writeFile(path15.join(timeseriesDir, "TimeSeries.ts"), await formatTs(reexportTypes(["TimeSeries"], `<T extends number | string>`)));
|
|
388
|
-
await fs.writeFile(path15.join(timeseriesDir, "TimeSeriesDuration.ts"), await formatTs(reexportTypes([`WhenUnit`, `DurationUnit`, `TimeSeriesDuration`])));
|
|
389
|
-
await fs.writeFile(path15.join(timeseriesDir, "TimeSeriesPoint.ts"), await formatTs(reexportTypes(["TimeSeriesPoint"], `<T extends number | string>`)));
|
|
390
|
-
await fs.writeFile(path15.join(timeseriesDir, "TimeSeriesQuery.ts"), await formatTs(reexportTypes(["TimeSeriesQuery"], `<T extends number | string>`)));
|
|
391
|
-
await fs.writeFile(path15.join(timeseriesDir, "TimeSeriesTerminalOperations.ts"), await formatTs(reexportTypes(["TimeSeriesTerminalOperations", "TimeSeriesIterator"], `<T extends number | string>`)));
|
|
277
|
+
};`;
|
|
392
278
|
}
|
|
393
279
|
|
|
394
|
-
// src/
|
|
395
|
-
async function
|
|
396
|
-
|
|
397
|
-
await fs.mkdir(baseTypesDir, {
|
|
280
|
+
// src/shared/generatePerActionDataFiles.ts
|
|
281
|
+
async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2) {
|
|
282
|
+
await fs2.mkdir(outDir, {
|
|
398
283
|
recursive: true
|
|
399
284
|
});
|
|
400
|
-
await
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
export * from "./AttachmentFilter${importExt}";
|
|
446
|
-
export * from "./BooleanFilter${importExt}";
|
|
447
|
-
export * from "./DateTimeFilters${importExt}";
|
|
448
|
-
export * from "./Filters${importExt}";
|
|
449
|
-
export * from "./GeoPointFilter${importExt}";
|
|
450
|
-
export * from "./GeoShapeFilter${importExt}";
|
|
451
|
-
export * from "./NumericFilter${importExt}";
|
|
452
|
-
export * from "./Op${importExt}";
|
|
453
|
-
export * from "./OrderByOption${importExt}";
|
|
454
|
-
export * from "./StringFilter${importExt}";`));
|
|
455
|
-
await fs.writeFile(path15__default.join(pagingDir, "ArrayFilter.ts"), await formatTs(`import { Attachment, GeoPoint, GeoShape, LocalDate, Timestamp } from "../baseTypes/index${importExt}";` + reexportConsts(["ArrayFilter"]) + reexportTypes(["ArrayFilter"], "<T extends string | number | Timestamp | LocalDate | boolean | GeoShape | GeoPoint | Attachment>")));
|
|
456
|
-
await fs.writeFile(path15__default.join(pagingDir, "AttachmentFilter.ts"), await formatTs(reexportConsts(["AttachmentFilter"]) + reexportTypes(["AttachmentFilter"])));
|
|
457
|
-
await fs.writeFile(path15__default.join(pagingDir, "BooleanFilter.ts"), await formatTs(reexportConsts(["BooleanFilter"]) + reexportTypes(["BooleanFilter"])));
|
|
458
|
-
await fs.writeFile(path15__default.join(pagingDir, "GeoPointFilter.ts"), await formatTs(reexportConsts(["GeoPointFilter"]) + reexportTypes(["GeoPointFilter", "BoundingBox"])));
|
|
459
|
-
await fs.writeFile(path15__default.join(pagingDir, "DateTimeFilters.ts"), await formatTs(reexportConsts(["TimestampFilter", "LocalDateFilter"]) + reexportTypes(["TimestampFilter", "LocalDateFilter"])));
|
|
460
|
-
await fs.writeFile(path15__default.join(pagingDir, "GeoShapeFilter.ts"), await formatTs(reexportConsts(["GeoShapeFilter"]) + reexportTypes(["GeoShapeFilter"])));
|
|
461
|
-
await fs.writeFile(path15__default.join(pagingDir, "NumericFilter.ts"), await formatTs(reexportConsts(["NumericFilter"]) + reexportTypes(["NumericFilter"])));
|
|
462
|
-
await fs.writeFile(path15__default.join(pagingDir, "Op.ts"), await formatTs(reexportConsts(["Op"])));
|
|
463
|
-
await fs.writeFile(path15__default.join(pagingDir, "OrderByOption.ts"), await formatTs(reexportConsts(["OrderByOption"]) + reexportTypes(["OrderByOption"])));
|
|
464
|
-
await fs.writeFile(path15__default.join(pagingDir, "StringFilter.ts"), await formatTs(reexportConsts(["StringFilter"]) + reexportTypes(["StringFilter"])));
|
|
465
|
-
await fs.writeFile(path15__default.join(pagingDir, "Filters.ts"), await formatTs(`import { OntologyObject } from "@osdk/legacy-client";` + reexportTypes(["ObjectTypeFilterFunction", "ObjectTypeOrderByFunction"], "<T extends OntologyObject>") + reexportTypes(["BoundingBoxFilter", "DistanceOf", "SearchClause", "LtWhereClause", "GtWhereClause", "LteWhereClause", "GteWhereClause", "EqWhereClause", "IsNullWhereClause", "ContainsWhereClause", "StartsWithWhereClause", "ContainsAllTermsInOrderWhereClause", "ContainsAnyTermWhereClause", "ContainsAllTermsWhereClause", "WithinDistanceOfWhereClause", "WithinBoundingBoxWhereClause", "IntersectsBoundingBoxWhereClause", "DoesNotIntersectBoundingBoxWhereClause", "WithinPolygonWhereClause", "IntersectsPolygonWhereClause", "DoesNotIntersectPolygonWhereClause", "AndWhereClause", "OrWhereClause", "NotWhereClause", "WhereClause", "OrderByClause"]) + reexportTypes(["FilterType"], "<T extends string | number>")));
|
|
466
|
-
}
|
|
467
|
-
async function generateErrors(fs, ontologyProviderDir) {
|
|
468
|
-
await fs.writeFile(path15.join(ontologyProviderDir, "Errors.ts"), await formatTs(reexportTypes(["PermissionDenied", "Unauthorized", "InvalidAggregationRangeValue", "MalformedPropertyFilters", "PropertiesNotFilterable", "ParametersNotFound", "ApplyActionFailed", "PropertyTypesSearchNotSupported", "InvalidParameterValue", "QueryTimeExceededLimit", "CompositePrimaryKeyNotSupported", "PropertyBaseTypeNotSupported", "PropertiesNotSearchable", "AttachmentNotFound", "ObjectTypeNotFound", "InvalidGroupId", "OntologySyncing", "ActionNotFound", "ParameterObjectSetRidNotFound", "LinkTypeNotFound", "InvalidRangeQuery", "ActionParameterObjectNotFound", "InvalidPropertyValue", "PropertiesNotSortable", "FunctionExecutionTimedOut", "InvalidFields", "ActionTypeNotFound", "ObjectTypeNotSynced", "OntologyEditsExceededLimit", "AggregationGroupCountExceededLimit", "InvalidContentType", "PropertiesNotFound", "FunctionInvalidInput", "InvalidSortOrder", "QueryDepthExceededLimit", "InvalidPropertyFiltersCombination", "ObjectsExceededLimit", "DuplicateOrderBy", "FunctionEncounteredUserFacingError", "InvalidUserId", "QueryNotFound", "InvalidAggregationRange", "ParameterObjectNotFound", "QueryMemoryExceededLimit", "InvalidContentLength", "OntologyNotFound", "ActionParameterObjectTypeNotFound", "UnknownParameter", "InvalidSortType", "PropertyFiltersNotSupported", "ActionValidationFailed", "MultipleGroupByOnFieldNotSupported", "LinkedObjectNotFound", "ActionEditedPropertiesNotFound", "InvalidPropertyFilterValue", "QueryEncounteredUserFacingError", "AttachmentSizeExceededLimit", "ObjectNotFound", "PropertyApiNameNotFound", "ParameterTypeNotSupported", "InvalidAggregationRangePropertyType", "MissingParameter"])));
|
|
469
|
-
}
|
|
470
|
-
async function generateOntologyMetadata(fs, ontologyProviderDir) {
|
|
471
|
-
await fs.writeFile(path15.join(ontologyProviderDir, "OntologyMetadata.ts"), await formatTs(reexportTypes(["OntologyMetadata"])));
|
|
472
|
-
}
|
|
473
|
-
async function generateResult(fs, ontologyProviderDir) {
|
|
474
|
-
await fs.writeFile(path15.join(ontologyProviderDir, "Result.ts"), await formatTs(`import {FoundryApiError} from "@osdk/legacy-client";
|
|
475
|
-
` + reexportTypes(["Ok", "Err"], "<T>") + reexportTypes(["Result"], "<V, E = FoundryApiError>", "<V,E>") + reexportConsts(["isOk", "isErr", "visitError"]) + reexportTypes(["ErrorVisitor"], "<E extends FoundryApiError, R>", "<E,R>") + reexportTypes(["ExtractKeysWithType"], "<T, K extends keyof T>", "<T,K>")));
|
|
476
|
-
}
|
|
285
|
+
await Promise.all(Object.values(ontology.actionTypes).map(async (action) => {
|
|
286
|
+
const uniqueApiNames = new Set(extractReferencedObjectsFromAction(action));
|
|
287
|
+
const uniqueApiNamesString = uniqueApiNames.size > 0 ? [...uniqueApiNames].map((apiName) => `"${apiName}"`).join("|") : "never";
|
|
288
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionDefinition(action));
|
|
289
|
+
const {
|
|
290
|
+
parameters,
|
|
291
|
+
...actionDefSansParameters
|
|
292
|
+
} = fullActionDef;
|
|
293
|
+
const actionDefIdentifier = `ActionDef$${action.apiName}`;
|
|
294
|
+
const paramsDefIdentifier = `${actionDefIdentifier}$Params`;
|
|
295
|
+
const paramsIdentifier = `${action.apiName}$Params`;
|
|
296
|
+
function createParamsDef() {
|
|
297
|
+
const entries = Object.entries(parameters);
|
|
298
|
+
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
299
|
+
if (entries.length === 0) {
|
|
300
|
+
return `// Represents the definition of the parameters for the action
|
|
301
|
+
export type ${paramsDefIdentifier} = Record<string, never>;`;
|
|
302
|
+
}
|
|
303
|
+
return `// Represents the definition of the parameters for the action
|
|
304
|
+
export type ${paramsDefIdentifier} = {
|
|
305
|
+
${entries.map(([key, value]) => {
|
|
306
|
+
return `"${key}": {
|
|
307
|
+
${stringify(value, {
|
|
308
|
+
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
309
|
+
// trick to remove undefineds
|
|
310
|
+
type: (type) => {
|
|
311
|
+
if (typeof type === "string") {
|
|
312
|
+
return JSON.stringify(type);
|
|
313
|
+
} else if (type.type === "object") {
|
|
314
|
+
return `ObjectActionDataType<"${type.object}", ${getObjectDefIdentifier(type.object, v2)}>`;
|
|
315
|
+
} else if (type.type === "objectSet") {
|
|
316
|
+
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, v2)}>`;
|
|
317
|
+
}
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
})}
|
|
321
|
+
}`;
|
|
322
|
+
}).join(";\n")}
|
|
323
|
+
}`;
|
|
324
|
+
}
|
|
325
|
+
function createV2Types() {
|
|
326
|
+
return `
|
|
327
|
+
|
|
328
|
+
${createParamsDef()}
|
|
329
|
+
|
|
477
330
|
|
|
478
|
-
//
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
331
|
+
// Represents the runtime arguments for the action
|
|
332
|
+
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}>>;
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
// Represents a fqn of the action
|
|
336
|
+
export interface ${action.apiName} {
|
|
337
|
+
${getDescriptionIfPresent(action.description)}
|
|
338
|
+
<OP extends ApplyActionOptions>(args: ${paramsIdentifier}, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
// Represents the definition of the action
|
|
343
|
+
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
|
|
344
|
+
${Object.entries(actionDefSansParameters).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
|
|
345
|
+
return `${key}: ${JSON.stringify(value)};`;
|
|
346
|
+
}).join("\n")}
|
|
347
|
+
parameters: ${paramsDefIdentifier};
|
|
348
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
349
|
+
}`;
|
|
350
|
+
}
|
|
351
|
+
function createV2Object() {
|
|
352
|
+
return ` export const ${action.apiName}: ${actionDefIdentifier} =
|
|
353
|
+
{
|
|
354
|
+
${stringify(fullActionDef)},
|
|
355
|
+
osdkMetadata: $osdkMetadata
|
|
356
|
+
}
|
|
357
|
+
`;
|
|
358
|
+
}
|
|
359
|
+
function createV1Object() {
|
|
360
|
+
return ` export const ${action.apiName} = ${JSON.stringify(fullActionDef, null, 2)} satisfies ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}>;`;
|
|
361
|
+
}
|
|
362
|
+
const referencedObjectDefs = /* @__PURE__ */ new Set();
|
|
363
|
+
for (const p of Object.values(action.parameters)) {
|
|
364
|
+
if (p.dataType.type === "object" || p.dataType.type === "objectSet") {
|
|
365
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectApiName, v2));
|
|
366
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.objectTypeApiName, v2));
|
|
367
|
+
}
|
|
368
|
+
if (p.dataType.type === "array" && (p.dataType.subType.type === "object" || p.dataType.subType.type === "objectSet")) {
|
|
369
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.subType.objectApiName, v2));
|
|
370
|
+
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.subType.objectTypeApiName, v2));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
374
|
+
await fs2.writeFile(path16__default.join(outDir, `${action.apiName}.ts`), await formatTs(`
|
|
375
|
+
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
376
|
+
import type { ActionSignature, ApplyActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client';
|
|
377
|
+
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
378
|
+
${importObjects}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
${v2 ? createV2Types() : ""}
|
|
382
|
+
|
|
383
|
+
${v2 ? createV2Object() : createV1Object()}
|
|
384
|
+
`));
|
|
385
|
+
}));
|
|
386
|
+
await fs2.writeFile(path16__default.join(outDir, `index.ts`), await formatTs(`
|
|
387
|
+
${Object.values(ontology.actionTypes).map((action) => `export {${action.apiName}} from "./${action.apiName}${importExt}";`).join("\n")}
|
|
388
|
+
${Object.keys(ontology.actionTypes).length === 0 ? "export {};" : ""}
|
|
389
|
+
`));
|
|
495
390
|
}
|
|
496
|
-
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
391
|
+
function extractReferencedObjectsFromAction(actionType) {
|
|
392
|
+
const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({
|
|
393
|
+
dataType
|
|
394
|
+
}) => {
|
|
395
|
+
const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);
|
|
396
|
+
return objectTypeReference ? [objectTypeReference] : [];
|
|
397
|
+
});
|
|
398
|
+
const referenceObjectsInEdits = actionType.operations.flatMap((value) => {
|
|
399
|
+
switch (value.type) {
|
|
400
|
+
case "createObject":
|
|
401
|
+
return [value.objectTypeApiName];
|
|
402
|
+
case "modifyObject":
|
|
403
|
+
return [value.objectTypeApiName];
|
|
404
|
+
case "deleteObject":
|
|
405
|
+
case "createLink":
|
|
406
|
+
case "deleteLink":
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
500
409
|
});
|
|
501
|
-
|
|
502
|
-
|
|
410
|
+
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
411
|
+
}
|
|
412
|
+
function extractReferencedObjectsFromActionParameter(actionParameter) {
|
|
413
|
+
switch (actionParameter.type) {
|
|
414
|
+
case "objectSet":
|
|
415
|
+
case "object":
|
|
416
|
+
return actionParameter.objectTypeApiName;
|
|
417
|
+
case "array":
|
|
418
|
+
return extractReferencedObjectsFromActionParameter(actionParameter.subType);
|
|
419
|
+
case "string":
|
|
420
|
+
case "boolean":
|
|
421
|
+
case "attachment":
|
|
422
|
+
case "date":
|
|
423
|
+
case "double":
|
|
424
|
+
case "integer":
|
|
425
|
+
case "long":
|
|
426
|
+
case "timestamp":
|
|
427
|
+
return void 0;
|
|
428
|
+
}
|
|
503
429
|
}
|
|
504
430
|
|
|
505
|
-
// src/
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
// TRASHFIXME
|
|
520
|
-
await formatTs(`
|
|
521
|
-
export * from "./aggregations/index${importExt}";
|
|
522
|
-
export * from "./baseTypes/index${importExt}";
|
|
523
|
-
${""}
|
|
524
|
-
// export * from "./filters/index${importExt}";
|
|
525
|
-
${""}
|
|
526
|
-
${""}
|
|
527
|
-
|
|
528
|
-
export * from "./ontologyProvider/index${importExt}";
|
|
529
|
-
export * from "./paging/index${importExt}";
|
|
530
|
-
`)
|
|
531
|
-
);
|
|
431
|
+
// src/shared/sanitizeMetadata.ts
|
|
432
|
+
function sanitizeMetadata(ontology) {
|
|
433
|
+
return {
|
|
434
|
+
...ontology,
|
|
435
|
+
actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map((actionType) => {
|
|
436
|
+
return [camelize(actionType.apiName), {
|
|
437
|
+
...actionType,
|
|
438
|
+
apiName: camelize(actionType.apiName)
|
|
439
|
+
}];
|
|
440
|
+
}))
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
function camelize(name) {
|
|
444
|
+
return name.replace(/-./g, (segment) => segment[1].toUpperCase());
|
|
532
445
|
}
|
|
533
446
|
|
|
534
|
-
// src/
|
|
535
|
-
async function
|
|
536
|
-
|
|
537
|
-
|
|
447
|
+
// src/util/verifyOutdir.ts
|
|
448
|
+
async function verifyOutdir(outDir, fs2) {
|
|
449
|
+
try {
|
|
450
|
+
const contents = await fs2.readdir(outDir);
|
|
451
|
+
if (contents.length !== 0) {
|
|
452
|
+
throw new Error(`outDir ${outDir} is not empty, please delete its contents and try again`);
|
|
453
|
+
}
|
|
454
|
+
} catch (e) {
|
|
455
|
+
if (e.code === "ENOENT") ; else {
|
|
456
|
+
throw e;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
538
459
|
}
|
|
539
|
-
async function
|
|
460
|
+
async function generateActions(ontology, fs2, outDir, importExt = "") {
|
|
540
461
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
541
462
|
let actionSignatures = [];
|
|
542
463
|
for (const action of Object.values(ontology.actionTypes)) {
|
|
@@ -562,601 +483,694 @@ async function generateBulkActions(ontology, fs, outDir, importExt = "") {
|
|
|
562
483
|
`;
|
|
563
484
|
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
564
485
|
}
|
|
565
|
-
parameterBlock += "}
|
|
566
|
-
} else {
|
|
567
|
-
parameterBlock = `params: Record<string,never>[], `;
|
|
486
|
+
parameterBlock += "}, ";
|
|
568
487
|
}
|
|
569
488
|
jsDocBlock.push(`*/`);
|
|
570
489
|
actionSignatures.push(`
|
|
571
490
|
${jsDocBlock.join("\n")}
|
|
572
|
-
${action.apiName}<O extends
|
|
573
|
-
Promise<Result<
|
|
574
|
-
`);
|
|
491
|
+
${action.apiName}<O extends ActionExecutionOptions>(${parameterBlock}options?: O):
|
|
492
|
+
Promise<Result<ActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;`);
|
|
575
493
|
}
|
|
576
|
-
await
|
|
494
|
+
await fs2.mkdir(outDir, {
|
|
577
495
|
recursive: true
|
|
578
496
|
});
|
|
579
|
-
await
|
|
580
|
-
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions,
|
|
497
|
+
await fs2.writeFile(path16__default.join(outDir, "Actions.ts"), await formatTs(`
|
|
498
|
+
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from "@osdk/legacy-client";
|
|
581
499
|
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
582
|
-
export interface
|
|
500
|
+
export interface Actions {
|
|
583
501
|
${actionSignatures.join("\n")}
|
|
584
502
|
}
|
|
585
503
|
`));
|
|
586
504
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {
|
|
594
|
-
constructor(options: FoundryClientOptions<TAuth>) {
|
|
595
|
-
super(options, Ontology);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
get ontology(): Ontology {
|
|
599
|
-
return super.ontology;
|
|
600
|
-
}
|
|
601
|
-
}`));
|
|
602
|
-
}
|
|
603
|
-
async function generateIndexFile(fs, outDir, importExt) {
|
|
604
|
-
await fs.mkdir(outDir, {
|
|
605
|
-
recursive: true
|
|
606
|
-
});
|
|
607
|
-
await fs.writeFile(path15.join(outDir, "index.ts"), await formatTs(`
|
|
608
|
-
export * from "@osdk/legacy-client";
|
|
609
|
-
export type { Ontology } from "./Ontology${importExt}";
|
|
610
|
-
export { FoundryClient } from "./FoundryClient${importExt}";
|
|
611
|
-
`));
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// src/util/commaSeparatedIdentifiers.ts
|
|
615
|
-
function commaSeparatedIdentifiers(identifiers, alternateNames) {
|
|
616
|
-
return identifiers.map((i) => {
|
|
617
|
-
const alt = alternateNames?.get(i);
|
|
618
|
-
if (alt) {
|
|
619
|
-
return `${i}: ${alt}`;
|
|
620
|
-
}
|
|
621
|
-
return i;
|
|
622
|
-
}).join(",");
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
// src/util/commaSeparatedTypeIdentifiers.ts
|
|
626
|
-
function commaSeparatedTypeIdentifiers(identifiers, altNames) {
|
|
627
|
-
return identifiers.map((i) => `${i}: typeof ${altNames?.get(i) ?? i}`).join(",");
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// src/v1.1/generateMetadataFile.ts
|
|
631
|
-
async function generateMetadataFile(ontology, userAgent, fs, outDir, importExt = "") {
|
|
632
|
-
const objectNames = Object.keys(ontology.objectTypes);
|
|
633
|
-
const actionNames = Object.keys(ontology.actionTypes);
|
|
634
|
-
const queryNames = Object.keys(ontology.queryTypes);
|
|
635
|
-
const actionAltNames = /* @__PURE__ */ new Map();
|
|
636
|
-
const queryAltNames = /* @__PURE__ */ new Map();
|
|
637
|
-
const seenIdentifiers = new Set(objectNames);
|
|
638
|
-
for (const actionName of actionNames) {
|
|
639
|
-
if (seenIdentifiers.has(actionName)) {
|
|
640
|
-
actionAltNames.set(actionName, `${actionName}Action`);
|
|
641
|
-
} else {
|
|
642
|
-
seenIdentifiers.add(actionName);
|
|
505
|
+
function getTypeScriptTypeFromDataType(actionParameter, importedObjects) {
|
|
506
|
+
switch (actionParameter.type) {
|
|
507
|
+
case "objectSet": {
|
|
508
|
+
const objectType = actionParameter.objectTypeApiName;
|
|
509
|
+
importedObjects.add(objectType);
|
|
510
|
+
return `ObjectSet<${objectType}>`;
|
|
643
511
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
512
|
+
case "object": {
|
|
513
|
+
const objectType = actionParameter.objectTypeApiName;
|
|
514
|
+
importedObjects.add(objectType);
|
|
515
|
+
return `${objectType} | ${objectType}["__primaryKey"]`;
|
|
648
516
|
}
|
|
517
|
+
case "array":
|
|
518
|
+
return `Array<${getTypeScriptTypeFromDataType(actionParameter.subType, importedObjects)}>`;
|
|
519
|
+
case "string":
|
|
520
|
+
return `string`;
|
|
521
|
+
case "boolean":
|
|
522
|
+
return `boolean`;
|
|
523
|
+
case "attachment":
|
|
524
|
+
return `Attachment`;
|
|
525
|
+
case "date":
|
|
526
|
+
return `LocalDate`;
|
|
527
|
+
case "double":
|
|
528
|
+
case "integer":
|
|
529
|
+
case "long":
|
|
530
|
+
return `number`;
|
|
531
|
+
case "timestamp":
|
|
532
|
+
return `Timestamp`;
|
|
533
|
+
case "marking":
|
|
534
|
+
return "string";
|
|
535
|
+
default:
|
|
536
|
+
throw new Error(`Unsupported action parameter type: ${actionParameter}`);
|
|
649
537
|
}
|
|
650
|
-
const getImportClause = (name, altNames) => {
|
|
651
|
-
const alt = altNames.get(name);
|
|
652
|
-
if (alt) {
|
|
653
|
-
return `${name} as ${alt}`;
|
|
654
|
-
} else {
|
|
655
|
-
return name;
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
await fs.writeFile(path15__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
659
|
-
import type { OntologyDefinition } from "@osdk/api";
|
|
660
|
-
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
661
|
-
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
662
|
-
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
663
|
-
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
664
|
-
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
665
|
-
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
666
|
-
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
667
|
-
${queryNames.map((name) => `import {${getImportClause(name, queryAltNames)}} from "./ontology/queries/${name}${importExt}";`).join("\n")}
|
|
668
|
-
|
|
669
|
-
export const Ontology : {
|
|
670
|
-
metadata: {
|
|
671
|
-
ontologyRid: "${ontology.ontology.rid}",
|
|
672
|
-
ontologyApiName: "${ontology.ontology.apiName}",
|
|
673
|
-
userAgent: "${userAgent}",
|
|
674
|
-
},
|
|
675
|
-
objects: {
|
|
676
|
-
${commaSeparatedTypeIdentifiers(objectNames)}
|
|
677
|
-
},
|
|
678
|
-
actions: {
|
|
679
|
-
${commaSeparatedTypeIdentifiers(actionNames, actionAltNames)}
|
|
680
|
-
},
|
|
681
|
-
queries: {
|
|
682
|
-
${commaSeparatedTypeIdentifiers(queryNames, queryAltNames)}
|
|
683
|
-
},
|
|
684
|
-
} = {
|
|
685
|
-
metadata: {
|
|
686
|
-
ontologyRid: "${ontology.ontology.rid}" as const,
|
|
687
|
-
ontologyApiName: "${ontology.ontology.apiName}" as const,
|
|
688
|
-
userAgent: "${userAgent}" as const,
|
|
689
|
-
},
|
|
690
|
-
objects: {
|
|
691
|
-
${commaSeparatedIdentifiers(objectNames)}
|
|
692
|
-
},
|
|
693
|
-
actions: {
|
|
694
|
-
${commaSeparatedIdentifiers(actionNames, actionAltNames)}
|
|
695
|
-
},
|
|
696
|
-
queries: {
|
|
697
|
-
${commaSeparatedIdentifiers(queryNames, queryAltNames)}
|
|
698
|
-
}
|
|
699
|
-
} satisfies OntologyDefinition<
|
|
700
|
-
${stringUnionFrom(objectNames)},
|
|
701
|
-
${stringUnionFrom(Object.values(ontology.actionTypes).map((actionType) => actionType.apiName))},
|
|
702
|
-
${stringUnionFrom(Object.values(ontology.queryTypes).map((queryType) => queryType.apiName))}>;
|
|
703
|
-
|
|
704
|
-
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
705
|
-
objects: Objects;
|
|
706
|
-
actions: Actions;
|
|
707
|
-
bulkActions: BulkActions;
|
|
708
|
-
queries: Queries;
|
|
709
|
-
}`));
|
|
710
538
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
539
|
+
|
|
540
|
+
// src/v1.1/backcompat/util/reexportConsts.ts
|
|
541
|
+
function reexportConsts(typesToExport) {
|
|
542
|
+
return `
|
|
543
|
+
import { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
544
|
+
|
|
545
|
+
${typesToExport.map((q) => `
|
|
546
|
+
/** @deprecated submodule imports arent public api **/
|
|
547
|
+
export const ${q} = OG_${q};
|
|
548
|
+
`).join("\n\n")}
|
|
549
|
+
`;
|
|
716
550
|
}
|
|
717
|
-
|
|
718
|
-
|
|
551
|
+
|
|
552
|
+
// src/v1.1/backcompat/internal-foundry-oauth-dist/generateConfidentialClientDir.ts
|
|
553
|
+
async function generateConfidentialClientDir(fs2, oauthDistDir, importExt = "") {
|
|
554
|
+
const confidentialClientDistDir = path16__default.join(oauthDistDir, "ConfidentialClient");
|
|
555
|
+
await fs2.mkdir(confidentialClientDistDir, {
|
|
719
556
|
recursive: true
|
|
720
557
|
});
|
|
721
|
-
await
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
;`));
|
|
558
|
+
await fs2.writeFile(path16__default.join(confidentialClientDistDir, "index.ts"), await formatTs(`
|
|
559
|
+
export * from "./ConfidentialClientAuth${importExt}";
|
|
560
|
+
`));
|
|
561
|
+
await fs2.writeFile(path16__default.join(confidentialClientDistDir, "ConfidentialClientAuth.ts"), await formatTs(`
|
|
562
|
+
${reexportConsts(["ConfidentialClientAuth"])}
|
|
563
|
+
`));
|
|
729
564
|
}
|
|
730
|
-
async function
|
|
731
|
-
|
|
565
|
+
async function generatePublicClientDir(fs2, oauthDistDir, importExt = "") {
|
|
566
|
+
const publicClientDistDir = path16__default.join(oauthDistDir, "PublicClient");
|
|
567
|
+
await fs2.mkdir(publicClientDistDir, {
|
|
732
568
|
recursive: true
|
|
733
569
|
});
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const localApiName = `OG_${apiName}`;
|
|
741
|
-
const contents = [];
|
|
742
|
-
contents.push(`import { ObjectSetAggregateArg, ObjectSetFilterArg, ObjectSetGroupByArg, ObjectSetMultipleAggregateArg, ObjectSetOrderByArg } from "@osdk/legacy-client";`);
|
|
743
|
-
contents.push(`import { ${apiName} as ${localApiName} } from "../${apiName}${importExt}";`);
|
|
744
|
-
contents.push("");
|
|
745
|
-
contents.push(`/** @deprecated Use ${apiName} from ontology/objects instead */`, `export type ${apiName} = ${localApiName};`);
|
|
746
|
-
contents.push(`/** @deprecated Use ObjectSetFilterArg<${apiName}> instead */`, `export type ${apiName}Filter = ObjectSetFilterArg<${localApiName}>;`);
|
|
747
|
-
contents.push(`/** @deprecated Use ObjectSetOrderByArg<${apiName}> instead */`, `export type ${apiName}OrderBy = ObjectSetOrderByArg<${localApiName}>;`);
|
|
748
|
-
contents.push(`/** @deprecated Use ObjectSetGroupByArg<${apiName}> instead */`, `export type ${apiName}GroupByProperties = ObjectSetGroupByArg<${localApiName}>;`);
|
|
749
|
-
contents.push(`
|
|
750
|
-
/**
|
|
751
|
-
* Aggregation properties for ${apiName}
|
|
752
|
-
* @deprecated Use ObjectSetAggregateArg<${apiName}> instead
|
|
753
|
-
*/`, `export type ${apiName}AggregationProperties = ObjectSetAggregateArg<${localApiName}>;`);
|
|
754
|
-
contents.push(`
|
|
755
|
-
/**
|
|
756
|
-
* Multiple aggregation properties for ${apiName}.
|
|
757
|
-
* @deprecated Use ObjectSetMultipleAggregateArg<${apiName}> instead
|
|
758
|
-
*/`, `export type ${apiName}MultipleAggregationProperties = ObjectSetMultipleAggregateArg<${localApiName}>;`);
|
|
759
|
-
await fs.writeFile(fileName, contents.join("\n"));
|
|
760
|
-
}
|
|
570
|
+
await fs2.writeFile(path16__default.join(publicClientDistDir, "index.ts"), await formatTs(`
|
|
571
|
+
export * from "./PublicClientAuth${importExt}";
|
|
572
|
+
`));
|
|
573
|
+
await fs2.writeFile(path16__default.join(publicClientDistDir, "PublicClientAuth.ts"), await formatTs(`
|
|
574
|
+
${reexportConsts(["PublicClientAuth"])}
|
|
575
|
+
`));
|
|
761
576
|
}
|
|
762
|
-
async function
|
|
763
|
-
|
|
577
|
+
async function generateUserTokenDir(fs2, oauthDistDir, importExt = "") {
|
|
578
|
+
const userTokenDistDir = path16__default.join(oauthDistDir, "UserToken");
|
|
579
|
+
await fs2.mkdir(userTokenDistDir, {
|
|
764
580
|
recursive: true
|
|
765
581
|
});
|
|
766
|
-
await
|
|
767
|
-
|
|
582
|
+
await fs2.writeFile(path16__default.join(userTokenDistDir, "index.ts"), await formatTs(`
|
|
583
|
+
export * from "./UserTokenAuth${importExt}";
|
|
584
|
+
`));
|
|
585
|
+
await fs2.writeFile(path16__default.join(userTokenDistDir, "UserTokenAuth.ts"), await formatTs(`
|
|
586
|
+
${reexportConsts(["UserTokenAuth"])}
|
|
768
587
|
`));
|
|
769
588
|
}
|
|
770
589
|
|
|
771
|
-
// src/
|
|
772
|
-
function
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
};
|
|
590
|
+
// src/v1.1/backcompat/util/reexportTypes.ts
|
|
591
|
+
function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = cleanup(genericArgsLeft)) {
|
|
592
|
+
return `
|
|
593
|
+
import type { ${typesToExport.map((q) => `${q} as OG_${q}`).join(", ")}} from "@osdk/legacy-client";
|
|
594
|
+
|
|
595
|
+
${typesToExport.map((q) => `
|
|
596
|
+
/** @deprecated submodule imports arent public api **/
|
|
597
|
+
export type ${q}${genericArgsLeft} = OG_${q}${genericArgsRight};
|
|
598
|
+
`).join("\n\n")}
|
|
599
|
+
`;
|
|
782
600
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
601
|
+
var captureInBracketsRegex = /<(.*?)>/;
|
|
602
|
+
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
603
|
+
function cleanup(s) {
|
|
604
|
+
if (s.length === 0)
|
|
605
|
+
return "";
|
|
606
|
+
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
607
|
+
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
608
|
+
});
|
|
609
|
+
return `<${genericParameterNames?.join(",")}>`;
|
|
790
610
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
611
|
+
|
|
612
|
+
// src/v1.1/backcompat/generateOAuthDistDir.ts
|
|
613
|
+
async function generateOAuthClientDistDir(outDir, fs2, importExt = "") {
|
|
614
|
+
const oauthDistDir = path16.join(outDir, "internal", "@foundry", "oauth-client", "dist");
|
|
615
|
+
await fs2.mkdir(oauthDistDir, {
|
|
616
|
+
recursive: true
|
|
617
|
+
});
|
|
618
|
+
await fs2.writeFile(path16.join(oauthDistDir, "index.ts"), await formatTs(`
|
|
619
|
+
export * from "./Auth${importExt}";
|
|
620
|
+
export * from "./ConfidentialClient/index${importExt}";
|
|
621
|
+
export * from "./OAuthClient${importExt}";
|
|
622
|
+
export * from "./PublicClient/index${importExt}";
|
|
623
|
+
export * from "./Token${importExt}";
|
|
624
|
+
export * from "./UserToken/index${importExt}";
|
|
625
|
+
`));
|
|
626
|
+
await fs2.writeFile(path16.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
627
|
+
await fs2.writeFile(path16.join(oauthDistDir, "Token.ts"), await formatTs(reexportTypes(["Token", "TokenValue"])));
|
|
628
|
+
await fs2.writeFile(path16.join(oauthDistDir, "OAuthClient.ts"), await formatTs(reexportTypes(["AuthSubscription", "UnsubscribeFunction", "SignInResponse", "RefreshResponse", "SignOutResponse"])));
|
|
629
|
+
await fs2.writeFile(path16.join(oauthDistDir, "OAuthToken.ts"), await formatTs(reexportConsts(["OAuthToken"])));
|
|
630
|
+
await fs2.writeFile(path16.join(oauthDistDir, "Auth.ts"), await formatTs(reexportTypes(["Auth"])));
|
|
631
|
+
await generateConfidentialClientDir(fs2, oauthDistDir, importExt);
|
|
632
|
+
await generatePublicClientDir(fs2, oauthDistDir, importExt);
|
|
633
|
+
await generateUserTokenDir(fs2, oauthDistDir, importExt);
|
|
634
|
+
}
|
|
635
|
+
async function generateAggregationsAggregations(fs2, aggregationsDir) {
|
|
636
|
+
await fs2.writeFile(path16.join(aggregationsDir, "Aggregations.ts"), await formatTs(`
|
|
637
|
+
import { LocalDate, Timestamp } from "@osdk/legacy-client";
|
|
638
|
+
` + reexportTypes(["Double", "Rangeable", "MetricValue", "Date", "BucketKey", "BucketValue", "TimeUnit", "BucketGroup", "Metrics", "AggregatableProperties", "AggregationClause"]) + reexportTypes(["Range"], "<T extends Rangeable>", "<T>") + reexportTypes(["BaseGroupBy"], "<_T extends BucketValue = BucketValue>") + reexportTypes(["Duration"], "<_T extends Timestamp | LocalDate = Timestamp | LocalDate>") + reexportTypes(["AggregatableProperty", "MultipleAggregationsOperations"], "<_T extends MetricValue = MetricValue>") + reexportTypes(["AggregationGroup"], "<TMetrics extends Metrics | MetricValue, TBucketGroup extends BucketGroup>") + reexportTypes(["Bucketing"], "<_T extends string , _X extends BucketValue>") + reexportTypes(["AggregationResult"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + reexportTypes(["BaseBucketing"], "<TBucketKey extends BucketKey, TBucketValue extends BucketValue, Kind extends string>") + reexportTypes(["ExactValueBucketing", "InternalBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends BucketValue>`) + reexportTypes(["RangeBucketing", "FixedWidthBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Range<Rangeable>>`) + reexportTypes(["DurationBucketing"], `<TBucketKey extends BucketKey, TBucketValue extends Date>`) + reexportTypes(["InternalBucketingVisitor"], "<TBucketKey extends BucketKey, T extends BucketValue, R>") + reexportTypes(["AggregationBuilderResult"], "<T, TMultipleAggregationProperties>") + reexportTypes(["AggregatablePropertiesForResult", "AggregatablePropertyNamesForResult"], "<TAggregatableProperties, TResult extends MetricValue>") + reexportConsts(["assertBucketingInternal", "visitInternalBucketing"]) + reexportTypes(["AggregatableObjectSetStep"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketableProperties, TBucketGroup extends BucketGroup = {}>") + reexportTypes(["GroupedTerminalAggregationOperations"], "<TAggregatableProperties, TMultipleAggregationProperties, TBucketGroup extends BucketGroup = {}>")));
|
|
817
639
|
}
|
|
818
|
-
function
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
640
|
+
async function generateGroupBy(fs2, aggregationsDir, importExt = "") {
|
|
641
|
+
await fs2.mkdir(path16.join(aggregationsDir, "groupBy"), {
|
|
642
|
+
recursive: true
|
|
643
|
+
});
|
|
644
|
+
const groupBys = ["BooleanGroupBy", "LocalDateGroupBy", "NumericGroupBy", "StringGroupBy", "TimestampGroupBy"];
|
|
645
|
+
const reexportFiles = [...groupBys, "GroupKeyType"];
|
|
646
|
+
for (const key of reexportFiles) {
|
|
647
|
+
await fs2.writeFile(path16.join(aggregationsDir, "groupBy", `${key}.ts`), await formatTs(`export {${key}} from "./index${importExt}";`));
|
|
825
648
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
649
|
+
await fs2.writeFile(path16.join(aggregationsDir, "groupBy", "index.ts"), await formatTs(`import { Bucketing, BucketKey, Duration, Range, Rangeable } from "../Aggregations${importExt}";` + reexportConsts(groupBys) + reexportTypes(groupBys, "<T extends BucketKey>") + `export {GroupKeyType} from "@osdk/legacy-client";
|
|
650
|
+
`));
|
|
651
|
+
}
|
|
652
|
+
async function generateMetrics(fs2, aggregationsDir, importExt = "") {
|
|
653
|
+
const metricsDir = path16.join(aggregationsDir, "metrics");
|
|
654
|
+
await fs2.mkdir(metricsDir, {
|
|
655
|
+
recursive: true
|
|
656
|
+
});
|
|
657
|
+
await fs2.writeFile(path16.join(metricsDir, "metrics.ts"), await formatTs(`export {MetricValueType} from "@osdk/legacy-client";`));
|
|
658
|
+
await fs2.writeFile(path16.join(metricsDir, "ApproximateDistinctCountAggregatableProperty.ts"), await formatTs(reexportConsts(["ApproximateDistinctCountAggregatableProperty"]) + reexportTypes(["ApproximateDistinctCountAggregatableProperty"])));
|
|
659
|
+
await fs2.writeFile(path16.join(metricsDir, "MultipleAggregatableProperty.ts"), await formatTs(`
|
|
660
|
+
import { Double, MetricValue, MultipleAggregationsOperations } from "../Aggregations${importExt}";
|
|
661
|
+
import { MetricValueType } from "./metrics/index${importExt}";
|
|
662
|
+
` + reexportConsts(["MultipleAggregatableProperty"]) + reexportTypes(["MultipleAggregatableProperty"], "<TResult extends MetricValue = Double>")));
|
|
663
|
+
for (const typeName of ["DefaultAggregatableProperty", "LocalDatePropertyMetric", "NumericPropertyMetric", "TimestampPropertyMetric"]) {
|
|
664
|
+
await fs2.writeFile(path16.join(metricsDir, `${typeName}.ts`), await formatTs(`
|
|
665
|
+
import { MultipleAggregatableProperty } from "./MultipleAggregatableProperty${importExt}";
|
|
666
|
+
` + reexportConsts([typeName])));
|
|
835
667
|
}
|
|
836
|
-
|
|
668
|
+
await fs2.writeFile(path16.join(metricsDir, "index.ts"), await formatTs(`
|
|
669
|
+
export * from "./ApproximateDistinctCountAggregatableProperty${importExt}";
|
|
670
|
+
export * from "./DefaultAggregatableProperty${importExt}";
|
|
671
|
+
export * from "./LocalDatePropertyMetric${importExt}";
|
|
672
|
+
export * from "./metrics${importExt}";
|
|
673
|
+
export * from "./MultipleAggregatableProperty${importExt}";
|
|
674
|
+
export * from "./NumericPropertyMetric${importExt}";
|
|
675
|
+
export * from "./TimestampPropertyMetric${importExt}";
|
|
676
|
+
`));
|
|
837
677
|
}
|
|
838
678
|
|
|
839
|
-
// src/
|
|
840
|
-
function
|
|
841
|
-
|
|
679
|
+
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateAggregationsDir.ts
|
|
680
|
+
async function generateAggregationsDir(fs2, runtimeDistDir, importExt = "") {
|
|
681
|
+
const aggregationsDir = path16.join(runtimeDistDir, "aggregations");
|
|
682
|
+
await fs2.mkdir(aggregationsDir, {
|
|
683
|
+
recursive: true
|
|
684
|
+
});
|
|
685
|
+
await generateGroupBy(fs2, aggregationsDir, importExt);
|
|
686
|
+
await generateAggregationsAggregations(fs2, aggregationsDir);
|
|
687
|
+
await generateMetrics(fs2, aggregationsDir, importExt);
|
|
688
|
+
await fs2.writeFile(path16.join(aggregationsDir, "index.ts"), await formatTs(`
|
|
689
|
+
${""}
|
|
690
|
+
${""}
|
|
691
|
+
|
|
692
|
+
export * from "./Aggregations${importExt}";
|
|
693
|
+
export * from "./ComputeStep${importExt}";
|
|
694
|
+
export * from "./CountOperation${importExt}";
|
|
695
|
+
export * from "./groupBy/index${importExt}";
|
|
696
|
+
export * from "./internalAggregationRequest${importExt}";
|
|
697
|
+
export * from "./metrics/index${importExt}";
|
|
698
|
+
`));
|
|
699
|
+
await fs2.writeFile(path16.join(aggregationsDir, "ComputeStep.ts"), await formatTs(`
|
|
700
|
+
import { ObjectSetDefinition } from "../baseTypes/index${importExt}";
|
|
701
|
+
import { FoundryClientOptions } from "../client/${importExt}";
|
|
702
|
+
import { AggregateObjectsError, OntologyMetadata, Result } from "../ontologyProvider/index${importExt}";
|
|
703
|
+
import { AggregationClause, AggregationResult, BucketGroup, BucketValue, InternalBucketing, Metrics, MetricValue } from "./Aggregations${importExt}";
|
|
704
|
+
` + reexportConsts(["ComputeStep"]) + reexportTypes(["ComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue> ") + reexportTypes(["AggregationComputeStep"], "<TBucketGroup extends BucketGroup, TMetrics extends Metrics | MetricValue>") + `
|
|
705
|
+
|
|
706
|
+
`));
|
|
707
|
+
await fs2.writeFile(path16.join(aggregationsDir, "CountOperation.ts"), await formatTs(`` + reexportConsts(["CountOperation", "isCountOperation"]) + reexportTypes(["CountOperation"])));
|
|
708
|
+
await fs2.writeFile(path16.join(aggregationsDir, "internalAggregationRequest.ts"), await formatTs(reexportTypes(["InternalAggregationRequest"])));
|
|
709
|
+
}
|
|
710
|
+
async function generateAttachmentsDir(attachmentsDir, fs2, importExt = "") {
|
|
711
|
+
await fs2.mkdir(attachmentsDir, {
|
|
712
|
+
recursive: true
|
|
713
|
+
});
|
|
714
|
+
await fs2.writeFile(path16__default.join(attachmentsDir, "index.ts"), await formatTs(`export * from "./Attachment${importExt}";
|
|
715
|
+
export * from "./Attachments${importExt}";
|
|
716
|
+
`));
|
|
717
|
+
await fs2.writeFile(path16__default.join(attachmentsDir, "Attachment.ts"), await formatTs(reexportTypes(["Attachment", "AttachmentMetadata"])));
|
|
718
|
+
await fs2.writeFile(path16__default.join(attachmentsDir, "Attachments.ts"), await formatTs(reexportTypes(["Attachments"])));
|
|
719
|
+
}
|
|
720
|
+
async function generateGeoshapesDir(runtimeDistDir, fs2, importExt = "") {
|
|
721
|
+
await fs2.mkdir(runtimeDistDir, {
|
|
722
|
+
recursive: true
|
|
723
|
+
});
|
|
724
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "index.ts"), await formatTs(`export * from "./Distance${importExt}";
|
|
725
|
+
export * from "./GeoJson${importExt}";
|
|
726
|
+
export * from "./GeometryCollection${importExt}";
|
|
727
|
+
export * from "./GeoPoint${importExt}";
|
|
728
|
+
export * from "./GeoShape${importExt}";
|
|
729
|
+
export * from "./LineString${importExt}";
|
|
730
|
+
export * from "./MultiGeoPoint${importExt}";
|
|
731
|
+
export * from "./MultiLineString${importExt}";
|
|
732
|
+
export * from "./MultiPolygon${importExt}";
|
|
733
|
+
export * from "./Polygon${importExt}";`));
|
|
734
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "Distance.ts"), await formatTs(`` + reexportConsts(["Distance", "DistanceUnit"]) + reexportTypes(["Distance", "DistanceUnit"])));
|
|
735
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "GeoJson.ts"), await formatTs(reexportTypes(["GeoJsonPoint", "GeoJsonPolygon", "GeoJsonLineString", "GeoJsonMultiPoint", "GeoJsonMultiPolygon", "GeoJsonMultiLineString", "GeoJsonGeometryCollection", "GeoJsonGeometry", "GeoJson"])));
|
|
736
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "GeometryCollection.ts"), await formatTs(reexportConsts(["GeometryCollection"])));
|
|
737
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "GeoPoint.ts"), await formatTs(`` + reexportConsts(["isGeoPoint", "GeoPoint", "mapCoordinatesToGeoPoint"]) + reexportTypes(["GeoHash", "Coordinates", "GeoPoint"])));
|
|
738
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "GeoShape.ts"), await formatTs(reexportConsts(["GeoShape"]) + reexportTypes(["GeoShape"])));
|
|
739
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "LineString.ts"), await formatTs(reexportConsts(["LineString"]) + reexportTypes(["LineString"])));
|
|
740
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "MultiGeoPoint.ts"), await formatTs(reexportConsts(["MultiGeoPoint"]) + reexportTypes(["MultiGeoPoint"])));
|
|
741
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "MultiLineString.ts"), await formatTs(reexportConsts(["MultiLineString"]) + reexportTypes(["MultiLineString"])));
|
|
742
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "MultiPolygon.ts"), await formatTs(reexportConsts(["MultiPolygon"]) + reexportTypes(["MultiPolygon"])));
|
|
743
|
+
await fs2.writeFile(path16.join(runtimeDistDir, "Polygon.ts"), await formatTs(reexportConsts(["Polygon"]) + reexportTypes(["LinearRing", "Polygon"])));
|
|
744
|
+
}
|
|
745
|
+
async function generateObjectSetDir(objectSetDir, fs2, importExt = "") {
|
|
746
|
+
await fs2.mkdir(objectSetDir, {
|
|
747
|
+
recursive: true
|
|
748
|
+
});
|
|
749
|
+
await fs2.writeFile(path16__default.join(objectSetDir, "index.ts"), await formatTs(`
|
|
750
|
+
export * from "./ObjectSetDefinition${importExt}";
|
|
751
|
+
export * from "./OntologyObjectSet${importExt}";
|
|
752
|
+
`));
|
|
753
|
+
await fs2.writeFile(path16__default.join(objectSetDir, "ObjectSetDefinition.ts"), await formatTs(reexportTypes(["BaseObjectSetDefinition", "ReferenceObjectSetDefinition", "StaticObjectSetDefinition", "IntersectObjectSetDefinition", "SubtractObjectSetDefinition", "SearchAroundObjectSetDefinition", "FilterObjectSetDefinition", "ObjectSetDefinition"])));
|
|
754
|
+
await fs2.writeFile(path16__default.join(objectSetDir, "OntologyObjectSet.ts"), await formatTs(reexportTypes(["OntologyObjectSet"])));
|
|
755
|
+
}
|
|
756
|
+
async function generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt = "") {
|
|
757
|
+
await fs2.mkdir(sharedObjectCodeDir, {
|
|
758
|
+
recursive: true
|
|
759
|
+
});
|
|
760
|
+
await fs2.writeFile(path16__default.join(sharedObjectCodeDir, "index.ts"), await formatTs(`
|
|
761
|
+
export * from "./FilteredPropertiesTerminalOperations${importExt}";
|
|
762
|
+
`));
|
|
763
|
+
await fs2.writeFile(path16__default.join(sharedObjectCodeDir, "FilteredPropertiesTerminalOperations.ts"), await formatTs(`import { OntologyObject } from "../OntologyObject${importExt}` + reexportTypes(["FilteredPropertiesTerminalOperations", "FilteredPropertiesTerminalOperationsWithGet"], "<T extends OntologyObject, V extends Array<keyof T>>")));
|
|
764
|
+
}
|
|
765
|
+
async function generateTimeSeriesDir(timeseriesDir, fs2, importExt = "") {
|
|
766
|
+
await fs2.mkdir(timeseriesDir, {
|
|
767
|
+
recursive: true
|
|
768
|
+
});
|
|
769
|
+
await fs2.writeFile(path16.join(timeseriesDir, "index.ts"), await formatTs(`
|
|
770
|
+
export * from "./TimeSeries${importExt}";
|
|
771
|
+
export * from "./TimeSeriesDuration${importExt}";
|
|
772
|
+
export * from "./TimeSeriesPoint${importExt}";
|
|
773
|
+
${""}
|
|
774
|
+
export * from "./TimeSeriesQuery${importExt}";
|
|
775
|
+
export * from "./TimeSeriesTerminalOperations${importExt}";
|
|
776
|
+
`));
|
|
777
|
+
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeries.ts"), await formatTs(reexportTypes(["TimeSeries"], `<T extends number | string>`)));
|
|
778
|
+
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesDuration.ts"), await formatTs(reexportTypes([`WhenUnit`, `DurationUnit`, `TimeSeriesDuration`])));
|
|
779
|
+
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesPoint.ts"), await formatTs(reexportTypes(["TimeSeriesPoint"], `<T extends number | string>`)));
|
|
780
|
+
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesQuery.ts"), await formatTs(reexportTypes(["TimeSeriesQuery"], `<T extends number | string>`)));
|
|
781
|
+
await fs2.writeFile(path16.join(timeseriesDir, "TimeSeriesTerminalOperations.ts"), await formatTs(reexportTypes(["TimeSeriesTerminalOperations", "TimeSeriesIterator"], `<T extends number | string>`)));
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateBaseTypesDir.ts
|
|
785
|
+
async function generateBaseTypesDir(runtimeDistDir, fs2, importExt = "") {
|
|
786
|
+
const baseTypesDir = path16.join(runtimeDistDir, "baseTypes");
|
|
787
|
+
await fs2.mkdir(baseTypesDir, {
|
|
788
|
+
recursive: true
|
|
789
|
+
});
|
|
790
|
+
await fs2.writeFile(path16.join(baseTypesDir, "index.ts"), await formatTs(`export * from "./ActionType${importExt}";
|
|
791
|
+
export * from "./attachments/index${importExt}";
|
|
792
|
+
export * from "./geoshapes/index${importExt}";
|
|
793
|
+
export * from "./links${importExt}";
|
|
794
|
+
export * from "./localDate${importExt}";
|
|
795
|
+
export * from "./objectset/index${importExt}";
|
|
796
|
+
export * from "./ObjectType${importExt}";
|
|
797
|
+
export * from "./OntologyObject${importExt}";
|
|
798
|
+
export * from "./Queries${importExt}";
|
|
799
|
+
export * from "./timeseries/index${importExt}";
|
|
800
|
+
export * from "./timestamp${importExt}";`));
|
|
801
|
+
const geoshapesDir = path16.join(baseTypesDir, "geoshapes");
|
|
802
|
+
await generateGeoshapesDir(geoshapesDir, fs2, importExt);
|
|
803
|
+
const timeseriesDir = path16.join(baseTypesDir, "timeseries");
|
|
804
|
+
await generateTimeSeriesDir(timeseriesDir, fs2, importExt);
|
|
805
|
+
const attachmentsDir = path16.join(baseTypesDir, "attachments");
|
|
806
|
+
await generateAttachmentsDir(attachmentsDir, fs2, importExt);
|
|
807
|
+
const objectSetDir = path16.join(baseTypesDir, "objectset");
|
|
808
|
+
await generateObjectSetDir(objectSetDir, fs2, importExt);
|
|
809
|
+
const sharedObjectCodeDir = path16.join(baseTypesDir, "sharedObjectCode");
|
|
810
|
+
await generateSharedObjectCodeDir(sharedObjectCodeDir, fs2, importExt);
|
|
811
|
+
await fs2.writeFile(path16.join(baseTypesDir, "ActionType.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}";
|
|
812
|
+
` + reexportConsts(["ActionExecutionMode", "ReturnEditsMode", "ActionValidationResult"]) + reexportTypes(["ActionExecutionOptions", "ValidationResponse", "BulkEdits"]) + reexportTypes(["CreatedObjectEdits", "ModifiedObjectEdits"], "<T extends OntologyObject>") + reexportTypes(["Edits"], "<TAddedObjects extends OntologyObject | void, TModifiedObjects extends OntologyObject | void>") + reexportTypes(["ActionResponse"], "<TEdits extends Edits<any, any> | undefined = undefined>", "<TEdits>") + reexportTypes(["ActionResponseFromOptions"], "<TOptions extends ActionExecutionOptions | undefined = undefined, TEdits extends Edits<any, any> | undefined = undefined>", "<TOptions, TEdits>")));
|
|
813
|
+
await fs2.writeFile(path16.join(baseTypesDir, "OntologyObject.ts"), await formatTs(reexportTypes(["OntologyObject"]) + reexportConsts(["isOntologyObject"])));
|
|
814
|
+
await fs2.writeFile(path16.join(baseTypesDir, "links.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}` + reexportTypes(["SingleLink", "MultiLink"], "<T extends OntologyObject = OntologyObject>")));
|
|
815
|
+
await fs2.writeFile(path16.join(baseTypesDir, "localDate.ts"), await formatTs(reexportConsts(["LocalDate"]) + reexportTypes(["LocalDate"])));
|
|
816
|
+
await fs2.writeFile(path16.join(baseTypesDir, "timestamp.ts"), await formatTs(reexportConsts(["Timestamp"]) + reexportTypes(["Timestamp"])));
|
|
817
|
+
await fs2.writeFile(path16.join(baseTypesDir, "Queries.ts"), await formatTs(`import { BucketValue, Range, Rangeable } from "../aggregations/index${importExt}";
|
|
818
|
+
` + reexportTypes(["QueryResponse"], "<T>") + reexportTypes(["BaseBucket"], "<K, V>") + reexportTypes(["NestedBucket"], "<TGroupKey, TSegmentKey, TValue extends BucketValue>") + reexportTypes(["TwoDimensionalAggregation"], "<TGroupKey extends QueryBucketKey, TValue extends BucketValue = number>") + reexportTypes(["ThreeDimensionalAggregation"], "<TGroupKey extends QueryBucketKey, TSegmentKey extends QueryBucketKey, TValue extends BucketValue = number>") + reexportTypes(["QueryBucketKey"])));
|
|
819
|
+
await fs2.writeFile(path16.join(baseTypesDir, "ObjectType.ts"), await formatTs(`import { OntologyObject } from "./OntologyObject${importExt}";` + reexportTypes(["BaseType", "StringType", "IntegerType", "DateType", "BooleanType", "ByteType", "DecimalType", "FloatType", "TimestampType", "ShortType", "LongType", "DoubleType", "GeoPointType", "GeoShapeType", "AttachmentType", "ObjectType", "StructField", "QueryBucketRangeableType", "QueryBucketKeyType", "QueryBucketValueType", "AllValueTypes", "OntologyType", "ObjectTypeProperties", "StructType"]) + reexportTypes(["TimeSeriesType", "ArrayType", "SetType"], "<T extends BaseType>") + reexportTypes(["Property"], "<TType extends OntologyType = OntologyType>") + reexportTypes(["BaseObjectType"], "<TOntologyObject extends OntologyObject = OntologyObject>") + reexportTypes(["ObjectSetType"], "<T extends ObjectType>") + reexportTypes(["RangeType"], "<T extends QueryBucketRangeableType>") + reexportTypes(["TwoDimensionalAggregationType"], "<TGroupKey extends QueryBucketKeyType, TValue extends QueryBucketValueType>") + reexportTypes(["ThreeDimensionalAggregationType"], "<TGroupKey extends QueryBucketKeyType, TSegmentKey extends QueryBucketKeyType, TValue extends QueryBucketValueType>")));
|
|
820
|
+
}
|
|
821
|
+
async function generateClientDir(runtimeDistDir, fs2, importExt = "") {
|
|
822
|
+
const pagingDir = path16__default.join(runtimeDistDir, "client");
|
|
823
|
+
await fs2.mkdir(pagingDir, {
|
|
824
|
+
recursive: true
|
|
825
|
+
});
|
|
826
|
+
await fs2.writeFile(path16__default.join(pagingDir, "index.ts"), await formatTs(`export * from "./clientOptions${importExt}";`));
|
|
827
|
+
await fs2.writeFile(path16__default.join(pagingDir, "clientOptions.ts"), await formatTs(`import {Auth} from "@osdk/legacy-client";` + reexportTypes(["FoundryClientOptions"], "<TAuth extends Auth = Auth>")));
|
|
828
|
+
}
|
|
829
|
+
async function generateFiltersDir(runtimeDistDir, fs2, importExt = "") {
|
|
830
|
+
const pagingDir = path16__default.join(runtimeDistDir, "filters");
|
|
831
|
+
await fs2.mkdir(pagingDir, {
|
|
832
|
+
recursive: true
|
|
833
|
+
});
|
|
834
|
+
await fs2.writeFile(path16__default.join(pagingDir, "index.ts"), await formatTs(`export * from "./ArrayFilter${importExt}";
|
|
835
|
+
export * from "./AttachmentFilter${importExt}";
|
|
836
|
+
export * from "./BooleanFilter${importExt}";
|
|
837
|
+
export * from "./DateTimeFilters${importExt}";
|
|
838
|
+
export * from "./Filters${importExt}";
|
|
839
|
+
export * from "./GeoPointFilter${importExt}";
|
|
840
|
+
export * from "./GeoShapeFilter${importExt}";
|
|
841
|
+
export * from "./NumericFilter${importExt}";
|
|
842
|
+
export * from "./Op${importExt}";
|
|
843
|
+
export * from "./OrderByOption${importExt}";
|
|
844
|
+
export * from "./StringFilter${importExt}";`));
|
|
845
|
+
await fs2.writeFile(path16__default.join(pagingDir, "ArrayFilter.ts"), await formatTs(`import { Attachment, GeoPoint, GeoShape, LocalDate, Timestamp } from "../baseTypes/index${importExt}";` + reexportConsts(["ArrayFilter"]) + reexportTypes(["ArrayFilter"], "<T extends string | number | Timestamp | LocalDate | boolean | GeoShape | GeoPoint | Attachment>")));
|
|
846
|
+
await fs2.writeFile(path16__default.join(pagingDir, "AttachmentFilter.ts"), await formatTs(reexportConsts(["AttachmentFilter"]) + reexportTypes(["AttachmentFilter"])));
|
|
847
|
+
await fs2.writeFile(path16__default.join(pagingDir, "BooleanFilter.ts"), await formatTs(reexportConsts(["BooleanFilter"]) + reexportTypes(["BooleanFilter"])));
|
|
848
|
+
await fs2.writeFile(path16__default.join(pagingDir, "GeoPointFilter.ts"), await formatTs(reexportConsts(["GeoPointFilter"]) + reexportTypes(["GeoPointFilter", "BoundingBox"])));
|
|
849
|
+
await fs2.writeFile(path16__default.join(pagingDir, "DateTimeFilters.ts"), await formatTs(reexportConsts(["TimestampFilter", "LocalDateFilter"]) + reexportTypes(["TimestampFilter", "LocalDateFilter"])));
|
|
850
|
+
await fs2.writeFile(path16__default.join(pagingDir, "GeoShapeFilter.ts"), await formatTs(reexportConsts(["GeoShapeFilter"]) + reexportTypes(["GeoShapeFilter"])));
|
|
851
|
+
await fs2.writeFile(path16__default.join(pagingDir, "NumericFilter.ts"), await formatTs(reexportConsts(["NumericFilter"]) + reexportTypes(["NumericFilter"])));
|
|
852
|
+
await fs2.writeFile(path16__default.join(pagingDir, "Op.ts"), await formatTs(reexportConsts(["Op"])));
|
|
853
|
+
await fs2.writeFile(path16__default.join(pagingDir, "OrderByOption.ts"), await formatTs(reexportConsts(["OrderByOption"]) + reexportTypes(["OrderByOption"])));
|
|
854
|
+
await fs2.writeFile(path16__default.join(pagingDir, "StringFilter.ts"), await formatTs(reexportConsts(["StringFilter"]) + reexportTypes(["StringFilter"])));
|
|
855
|
+
await fs2.writeFile(path16__default.join(pagingDir, "Filters.ts"), await formatTs(`import { OntologyObject } from "@osdk/legacy-client";` + reexportTypes(["ObjectTypeFilterFunction", "ObjectTypeOrderByFunction"], "<T extends OntologyObject>") + reexportTypes(["BoundingBoxFilter", "DistanceOf", "SearchClause", "LtWhereClause", "GtWhereClause", "LteWhereClause", "GteWhereClause", "EqWhereClause", "IsNullWhereClause", "ContainsWhereClause", "StartsWithWhereClause", "ContainsAllTermsInOrderWhereClause", "ContainsAnyTermWhereClause", "ContainsAllTermsWhereClause", "WithinDistanceOfWhereClause", "WithinBoundingBoxWhereClause", "IntersectsBoundingBoxWhereClause", "DoesNotIntersectBoundingBoxWhereClause", "WithinPolygonWhereClause", "IntersectsPolygonWhereClause", "DoesNotIntersectPolygonWhereClause", "AndWhereClause", "OrWhereClause", "NotWhereClause", "WhereClause", "OrderByClause"]) + reexportTypes(["FilterType"], "<T extends string | number>")));
|
|
856
|
+
}
|
|
857
|
+
async function generateErrors(fs2, ontologyProviderDir) {
|
|
858
|
+
await fs2.writeFile(path16.join(ontologyProviderDir, "Errors.ts"), await formatTs(reexportTypes(["PermissionDenied", "Unauthorized", "InvalidAggregationRangeValue", "MalformedPropertyFilters", "PropertiesNotFilterable", "ParametersNotFound", "ApplyActionFailed", "PropertyTypesSearchNotSupported", "InvalidParameterValue", "QueryTimeExceededLimit", "CompositePrimaryKeyNotSupported", "PropertyBaseTypeNotSupported", "PropertiesNotSearchable", "AttachmentNotFound", "ObjectTypeNotFound", "InvalidGroupId", "OntologySyncing", "ActionNotFound", "ParameterObjectSetRidNotFound", "LinkTypeNotFound", "InvalidRangeQuery", "ActionParameterObjectNotFound", "InvalidPropertyValue", "PropertiesNotSortable", "FunctionExecutionTimedOut", "InvalidFields", "ActionTypeNotFound", "ObjectTypeNotSynced", "OntologyEditsExceededLimit", "AggregationGroupCountExceededLimit", "InvalidContentType", "PropertiesNotFound", "FunctionInvalidInput", "InvalidSortOrder", "QueryDepthExceededLimit", "InvalidPropertyFiltersCombination", "ObjectsExceededLimit", "DuplicateOrderBy", "FunctionEncounteredUserFacingError", "InvalidUserId", "QueryNotFound", "InvalidAggregationRange", "ParameterObjectNotFound", "QueryMemoryExceededLimit", "InvalidContentLength", "OntologyNotFound", "ActionParameterObjectTypeNotFound", "UnknownParameter", "InvalidSortType", "PropertyFiltersNotSupported", "ActionValidationFailed", "MultipleGroupByOnFieldNotSupported", "LinkedObjectNotFound", "ActionEditedPropertiesNotFound", "InvalidPropertyFilterValue", "QueryEncounteredUserFacingError", "AttachmentSizeExceededLimit", "ObjectNotFound", "PropertyApiNameNotFound", "ParameterTypeNotSupported", "InvalidAggregationRangePropertyType", "MissingParameter"])));
|
|
859
|
+
}
|
|
860
|
+
async function generateOntologyMetadata(fs2, ontologyProviderDir) {
|
|
861
|
+
await fs2.writeFile(path16.join(ontologyProviderDir, "OntologyMetadata.ts"), await formatTs(reexportTypes(["OntologyMetadata"])));
|
|
862
|
+
}
|
|
863
|
+
async function generateResult(fs2, ontologyProviderDir) {
|
|
864
|
+
await fs2.writeFile(path16.join(ontologyProviderDir, "Result.ts"), await formatTs(`import {FoundryApiError} from "@osdk/legacy-client";
|
|
865
|
+
` + reexportTypes(["Ok", "Err"], "<T>") + reexportTypes(["Result"], "<V, E = FoundryApiError>", "<V,E>") + reexportConsts(["isOk", "isErr", "visitError"]) + reexportTypes(["ErrorVisitor"], "<E extends FoundryApiError, R>", "<E,R>") + reexportTypes(["ExtractKeysWithType"], "<T, K extends keyof T>", "<T,K>")));
|
|
842
866
|
}
|
|
843
867
|
|
|
844
|
-
// src/
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
return entries.join(separator);
|
|
868
|
+
// src/v1.1/backcompat/internal-foundry-ontology-runtime-dist/generateOntologyProviderDir.ts
|
|
869
|
+
async function generateOntologyProviderDir(fs2, runtimeDistDir, importExt = "") {
|
|
870
|
+
const ontologyProviderDir = path16.join(runtimeDistDir, "ontologyProvider");
|
|
871
|
+
await fs2.mkdir(ontologyProviderDir, {
|
|
872
|
+
recursive: true
|
|
873
|
+
});
|
|
874
|
+
await generateErrors(fs2, ontologyProviderDir);
|
|
875
|
+
await generateOntologyMetadata(fs2, ontologyProviderDir);
|
|
876
|
+
await generateResult(fs2, ontologyProviderDir);
|
|
877
|
+
await fs2.writeFile(path16.join(ontologyProviderDir, "index.ts"), await formatTs(`
|
|
878
|
+
${""}
|
|
879
|
+
export * from "./Errors${importExt}";
|
|
880
|
+
export * from "./OntologyMetadata${importExt}";
|
|
881
|
+
${""}
|
|
882
|
+
${""}
|
|
883
|
+
// export * from "./Result${importExt}";
|
|
884
|
+
`));
|
|
864
885
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
886
|
+
async function generatePagingDir(runtimeDistDir, fs2, importExt = "") {
|
|
887
|
+
const pagingDir = path16.join(runtimeDistDir, "paging");
|
|
888
|
+
await fs2.mkdir(pagingDir, {
|
|
889
|
+
recursive: true
|
|
890
|
+
});
|
|
891
|
+
await fs2.writeFile(path16.join(pagingDir, "index.ts"), await formatTs(`export * from "./Page${importExt}";`));
|
|
892
|
+
await fs2.writeFile(path16.join(pagingDir, "Page.ts"), await formatTs(reexportTypes(["Page"], "<T>")));
|
|
869
893
|
}
|
|
870
|
-
function wireObjectTypeV2ToSdkObjectConst(object, importExt, v2 = false) {
|
|
871
|
-
const uniqueLinkTargetTypes = new Set(object.linkTypes.map((a) => a.objectTypeApiName));
|
|
872
|
-
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectTypeDefinition(object, v2));
|
|
873
|
-
const objectDefIdentifier = getObjectDefIdentifier(object.objectType.apiName, v2);
|
|
874
|
-
function getV1Types() {
|
|
875
|
-
return `
|
|
876
|
-
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
877
|
-
${stringify(definition, {
|
|
878
|
-
links: (_value) => `{
|
|
879
|
-
${stringify(definition.links, {
|
|
880
|
-
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
881
|
-
})}
|
|
882
|
-
}`
|
|
883
|
-
})}
|
|
884
|
-
}
|
|
885
|
-
`;
|
|
886
|
-
}
|
|
887
|
-
function getV2Types() {
|
|
888
|
-
return `
|
|
889
|
-
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}> {
|
|
890
|
-
${stringify(definition, {
|
|
891
|
-
type: () => void 0,
|
|
892
|
-
apiName: () => void 0,
|
|
893
|
-
links: (_value) => `{
|
|
894
|
-
${stringify(definition.links, {
|
|
895
|
-
"*": (definition2) => `ObjectTypeLinkDefinition<${getObjectDefIdentifier(definition2.targetType, v2)}, ${definition2.multiplicity}>`
|
|
896
|
-
})}
|
|
897
|
-
}`,
|
|
898
|
-
properties: (_value) => `{
|
|
899
|
-
${stringify(definition.properties, {
|
|
900
|
-
"*": (propertyDefinition) => `PropertyDef<"${propertyDefinition.type}", "${propertyDefinition.nullable ? "nullable" : "non-nullable"}", "${propertyDefinition.multiplicity ? "array" : "single"}">`
|
|
901
|
-
})}
|
|
902
|
-
}`
|
|
903
|
-
})}
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
`;
|
|
907
|
-
}
|
|
908
|
-
const imports = Array.from(uniqueLinkTargetTypes).filter((type) => type !== definition.apiName).map((type) => `import type { ${getObjectDefIdentifier(type, v2)} } from "./${type}${importExt}";`);
|
|
909
|
-
return `${imports.join("\n")}
|
|
910
894
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
895
|
+
// src/v1.1/backcompat/generateOntologyRuntimeDistDir.ts
|
|
896
|
+
async function generateOntologyRuntimeDistDir(outDir, fs2, importExt = "") {
|
|
897
|
+
const runtimeDistDir = path16.join(outDir, "internal", "@foundry", "ontology-runtime", "dist");
|
|
898
|
+
await fs2.mkdir(runtimeDistDir, {
|
|
899
|
+
recursive: true
|
|
900
|
+
});
|
|
901
|
+
await generateOntologyProviderDir(fs2, runtimeDistDir, importExt);
|
|
902
|
+
await generateAggregationsDir(fs2, runtimeDistDir, importExt);
|
|
903
|
+
await generatePagingDir(runtimeDistDir, fs2, importExt);
|
|
904
|
+
await generateBaseTypesDir(runtimeDistDir, fs2, importExt);
|
|
905
|
+
await generateClientDir(runtimeDistDir, fs2, importExt);
|
|
906
|
+
await generateFiltersDir(runtimeDistDir, fs2, importExt);
|
|
907
|
+
await fs2.writeFile(
|
|
908
|
+
path16.join(runtimeDistDir, "index.ts"),
|
|
909
|
+
// TRASHFIXME
|
|
910
|
+
await formatTs(`
|
|
911
|
+
export * from "./aggregations/index${importExt}";
|
|
912
|
+
export * from "./baseTypes/index${importExt}";
|
|
913
|
+
${""}
|
|
914
|
+
// export * from "./filters/index${importExt}";
|
|
915
|
+
${""}
|
|
916
|
+
${""}
|
|
917
|
+
|
|
918
|
+
export * from "./ontologyProvider/index${importExt}";
|
|
919
|
+
export * from "./paging/index${importExt}";
|
|
920
|
+
`)
|
|
921
|
+
);
|
|
916
922
|
}
|
|
917
923
|
|
|
918
|
-
// src/
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
924
|
+
// src/v1.1/generateBackCompatDeprecatedExports.ts
|
|
925
|
+
async function generateBackCompatDeprecatedExports(fs2, outDir, importExt = "") {
|
|
926
|
+
await generateOntologyRuntimeDistDir(outDir, fs2, importExt);
|
|
927
|
+
await generateOAuthClientDistDir(outDir, fs2, importExt);
|
|
922
928
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
readonly $apiName: "${objectTypeWithLinks.objectType.apiName}";
|
|
937
|
-
readonly $primaryKey: ${wirePropertyTypeV2ToTypeScriptType(objectTypeWithLinks.objectType.properties[objectTypeWithLinks.objectType.primaryKey].dataType)};
|
|
938
|
-
${Object.entries(objectTypeWithLinks.objectType.properties).sort((a, b) => a[0].localeCompare(b[0])).flatMap(([propertyName, propertyDefinition]) => {
|
|
939
|
-
const propertyType = wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType);
|
|
940
|
-
const entries = [`${getDescriptionIfPresent(propertyDefinition.description, true)}readonly ${propertyName}: ${propertyType} | undefined`];
|
|
941
|
-
if (isReservedKeyword(propertyName)) {
|
|
942
|
-
entries.push(`/** @deprecated please migrate to '${propertyName}' instead */
|
|
943
|
-
readonly ${propertyName}_: ${propertyType} | undefined`);
|
|
929
|
+
async function generateBulkActions(ontology, fs2, outDir, importExt = "") {
|
|
930
|
+
const importedObjects = /* @__PURE__ */ new Set();
|
|
931
|
+
let actionSignatures = [];
|
|
932
|
+
for (const action of Object.values(ontology.actionTypes)) {
|
|
933
|
+
const entries = Object.entries(action.parameters);
|
|
934
|
+
const modifiedEntityTypes = getModifiedEntityTypes(action);
|
|
935
|
+
const addedObjects = Array.from(modifiedEntityTypes.addedObjects);
|
|
936
|
+
const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);
|
|
937
|
+
addedObjects.forEach(importedObjects.add, importedObjects);
|
|
938
|
+
modifiedObjects.forEach(importedObjects.add, importedObjects);
|
|
939
|
+
let jsDocBlock = ["/**"];
|
|
940
|
+
if (action.description) {
|
|
941
|
+
jsDocBlock.push(`* ${action.description}`);
|
|
944
942
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return "number";
|
|
968
|
-
case "date":
|
|
969
|
-
return "LocalDate";
|
|
970
|
-
case "decimal":
|
|
971
|
-
return "string";
|
|
972
|
-
case "double":
|
|
973
|
-
return "number";
|
|
974
|
-
case "float":
|
|
975
|
-
return "number";
|
|
976
|
-
case "geopoint":
|
|
977
|
-
return "GeoPoint";
|
|
978
|
-
case "geoshape":
|
|
979
|
-
return "GeoShape";
|
|
980
|
-
case "long":
|
|
981
|
-
return "string";
|
|
982
|
-
case "short":
|
|
983
|
-
return "number";
|
|
984
|
-
case "timestamp":
|
|
985
|
-
return "Timestamp";
|
|
986
|
-
case "timeseries":
|
|
987
|
-
return property.itemType.type === "string" ? `TimeSeries<string>` : `TimeSeries<number>`;
|
|
988
|
-
case "marking":
|
|
989
|
-
return "string";
|
|
990
|
-
default:
|
|
991
|
-
throw new Error(`Unknown property type ${property}`);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
function getDescriptionIfPresent(description, includeNewline) {
|
|
995
|
-
if (description) {
|
|
996
|
-
return `/**
|
|
997
|
-
* ${description}
|
|
998
|
-
*/${includeNewline ? "\n" : ""}`;
|
|
943
|
+
let parameterBlock = "";
|
|
944
|
+
if (entries.length > 0) {
|
|
945
|
+
parameterBlock = `params: {
|
|
946
|
+
`;
|
|
947
|
+
for (const [parameterName, parameterData] of entries) {
|
|
948
|
+
parameterBlock += `"${parameterName}"`;
|
|
949
|
+
parameterBlock += parameterData.required ? ": " : "?: ";
|
|
950
|
+
const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);
|
|
951
|
+
parameterBlock += `${typeScriptType};
|
|
952
|
+
`;
|
|
953
|
+
jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);
|
|
954
|
+
}
|
|
955
|
+
parameterBlock += "}[], ";
|
|
956
|
+
} else {
|
|
957
|
+
parameterBlock = `params: Record<string,never>[], `;
|
|
958
|
+
}
|
|
959
|
+
jsDocBlock.push(`*/`);
|
|
960
|
+
actionSignatures.push(`
|
|
961
|
+
${jsDocBlock.join("\n")}
|
|
962
|
+
${action.apiName}<O extends BulkActionExecutionOptions>(${parameterBlock}options?: O):
|
|
963
|
+
Promise<Result<BulkActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(" | ") : "void"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(" | ") : "void"}>>, ActionError>>;
|
|
964
|
+
`);
|
|
999
965
|
}
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
// src/v1.1/generatePerActionDataFiles.ts
|
|
1004
|
-
async function generatePerActionDataFiles(ontology, fs, outDir, importExt, v2) {
|
|
1005
|
-
await fs.mkdir(outDir, {
|
|
966
|
+
await fs2.mkdir(outDir, {
|
|
1006
967
|
recursive: true
|
|
1007
968
|
});
|
|
1008
|
-
await
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
parameters,
|
|
1014
|
-
...actionDefSansParameters
|
|
1015
|
-
} = fullActionDef;
|
|
1016
|
-
const actionDefIdentifier = `ActionDef$${action.apiName}`;
|
|
1017
|
-
const paramsDefIdentifier = `${actionDefIdentifier}$Params`;
|
|
1018
|
-
const paramsIdentifier = `${action.apiName}$Params`;
|
|
1019
|
-
function createParamsDef() {
|
|
1020
|
-
const entries = Object.entries(parameters);
|
|
1021
|
-
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
1022
|
-
if (entries.length === 0) {
|
|
1023
|
-
return `// Represents the definition of the parameters for the action
|
|
1024
|
-
export type ${paramsDefIdentifier} = Record<string, never>;`;
|
|
1025
|
-
}
|
|
1026
|
-
return `// Represents the definition of the parameters for the action
|
|
1027
|
-
export type ${paramsDefIdentifier} = {
|
|
1028
|
-
${entries.map(([key, value]) => {
|
|
1029
|
-
return `"${key}": {
|
|
1030
|
-
${stringify(value, {
|
|
1031
|
-
description: (value2, d) => value2 ? d(value2) : void 0,
|
|
1032
|
-
// trick to remove undefineds
|
|
1033
|
-
type: (type) => {
|
|
1034
|
-
if (typeof type === "string") {
|
|
1035
|
-
return JSON.stringify(type);
|
|
1036
|
-
} else if (type.type === "object") {
|
|
1037
|
-
return `ObjectActionDataType<"${type.object}", ${getObjectDefIdentifier(type.object, v2)}>`;
|
|
1038
|
-
} else if (type.type === "objectSet") {
|
|
1039
|
-
return `ObjectSetActionDataType<"${type.objectSet}", ${getObjectDefIdentifier(type.objectSet, v2)}>`;
|
|
1040
|
-
}
|
|
1041
|
-
return void 0;
|
|
1042
|
-
}
|
|
1043
|
-
})}
|
|
1044
|
-
}`;
|
|
1045
|
-
}).join(";\n")}
|
|
1046
|
-
}`;
|
|
969
|
+
await fs2.writeFile(path16__default.join(outDir, "BulkActions.ts"), await formatTs(`
|
|
970
|
+
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, BulkActionExecutionOptions, ActionError, Result, ActionResponseFromOptions, BulkActionResponseFromOptions } from "@osdk/legacy-client";
|
|
971
|
+
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
972
|
+
export interface BulkActions {
|
|
973
|
+
${actionSignatures.join("\n")}
|
|
1047
974
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
975
|
+
`));
|
|
976
|
+
}
|
|
977
|
+
async function generateFoundryClientFile(fs2, outDir, importExt = "") {
|
|
978
|
+
await fs2.writeFile(path16__default.join(outDir, "FoundryClient.ts"), await formatTs(`
|
|
979
|
+
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
980
|
+
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
981
|
+
import { Ontology } from "./Ontology${importExt}";
|
|
1053
982
|
|
|
1054
|
-
|
|
1055
|
-
|
|
983
|
+
export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {
|
|
984
|
+
constructor(options: FoundryClientOptions<TAuth>) {
|
|
985
|
+
super(options, Ontology);
|
|
986
|
+
}
|
|
1056
987
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
988
|
+
get ontology(): Ontology {
|
|
989
|
+
return super.ontology;
|
|
990
|
+
}
|
|
991
|
+
}`));
|
|
992
|
+
}
|
|
993
|
+
async function generateIndexFile(fs2, outDir, importExt) {
|
|
994
|
+
await fs2.mkdir(outDir, {
|
|
995
|
+
recursive: true
|
|
996
|
+
});
|
|
997
|
+
await fs2.writeFile(path16.join(outDir, "index.ts"), await formatTs(`
|
|
998
|
+
export * from "@osdk/legacy-client";
|
|
999
|
+
export type { Ontology } from "./Ontology${importExt}";
|
|
1000
|
+
export { FoundryClient } from "./FoundryClient${importExt}";
|
|
1001
|
+
`));
|
|
1002
|
+
}
|
|
1063
1003
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
}
|
|
1070
|
-
parameters: ${paramsDefIdentifier}
|
|
1071
|
-
}`;
|
|
1004
|
+
// src/util/commaSeparatedIdentifiers.ts
|
|
1005
|
+
function commaSeparatedIdentifiers(identifiers, alternateNames) {
|
|
1006
|
+
return identifiers.map((i) => {
|
|
1007
|
+
const alt = alternateNames?.get(i);
|
|
1008
|
+
if (alt) {
|
|
1009
|
+
return `${i}: ${alt}`;
|
|
1072
1010
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1011
|
+
return i;
|
|
1012
|
+
}).join(",");
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// src/util/commaSeparatedTypeIdentifiers.ts
|
|
1016
|
+
function commaSeparatedTypeIdentifiers(identifiers, altNames) {
|
|
1017
|
+
return identifiers.map((i) => `${i}: typeof ${altNames?.get(i) ?? i}`).join(",");
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// src/v1.1/generateMetadataFile.ts
|
|
1021
|
+
async function generateMetadataFile(ontology, userAgent, fs2, outDir, importExt = "") {
|
|
1022
|
+
const objectNames = Object.keys(ontology.objectTypes);
|
|
1023
|
+
const actionNames = Object.keys(ontology.actionTypes);
|
|
1024
|
+
const queryNames = Object.keys(ontology.queryTypes);
|
|
1025
|
+
const actionAltNames = /* @__PURE__ */ new Map();
|
|
1026
|
+
const queryAltNames = /* @__PURE__ */ new Map();
|
|
1027
|
+
const seenIdentifiers = new Set(objectNames);
|
|
1028
|
+
for (const actionName of actionNames) {
|
|
1029
|
+
if (seenIdentifiers.has(actionName)) {
|
|
1030
|
+
actionAltNames.set(actionName, `${actionName}Action`);
|
|
1031
|
+
} else {
|
|
1032
|
+
seenIdentifiers.add(actionName);
|
|
1075
1033
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1034
|
+
}
|
|
1035
|
+
for (const queryName of queryNames) {
|
|
1036
|
+
if (seenIdentifiers.has(queryName)) {
|
|
1037
|
+
queryAltNames.set(queryName, `${queryName}Query`);
|
|
1078
1038
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.subType.objectApiName, v2));
|
|
1087
|
-
referencedObjectDefs.add(getObjectDefIdentifier(p.dataType.subType.objectTypeApiName, v2));
|
|
1088
|
-
}
|
|
1039
|
+
}
|
|
1040
|
+
const getImportClause = (name, altNames) => {
|
|
1041
|
+
const alt = altNames.get(name);
|
|
1042
|
+
if (alt) {
|
|
1043
|
+
return `${name} as ${alt}`;
|
|
1044
|
+
} else {
|
|
1045
|
+
return name;
|
|
1089
1046
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1047
|
+
};
|
|
1048
|
+
await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
1049
|
+
import type { OntologyDefinition } from "@osdk/api";
|
|
1050
|
+
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
1051
|
+
import type { Objects } from "./ontology/objects/Objects${importExt}";
|
|
1052
|
+
import type { Actions } from "./ontology/actions/Actions${importExt}";
|
|
1053
|
+
import type { Queries } from "./ontology/queries/Queries${importExt}";
|
|
1054
|
+
import type { BulkActions } from "./ontology/actions/BulkActions${importExt}";
|
|
1055
|
+
${objectNames.map((name) => `import {${name}} from "./ontology/objects/${name}${importExt}";`).join("\n")}
|
|
1056
|
+
${actionNames.map((name) => `import {${getImportClause(name, actionAltNames)}} from "./ontology/actions/${name}${importExt}";`).join("\n")}
|
|
1057
|
+
${queryNames.map((name) => `import {${getImportClause(name, queryAltNames)}} from "./ontology/queries/${name}${importExt}";`).join("\n")}
|
|
1098
1058
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1059
|
+
export const Ontology : {
|
|
1060
|
+
metadata: {
|
|
1061
|
+
ontologyRid: "${ontology.ontology.rid}",
|
|
1062
|
+
ontologyApiName: "${ontology.ontology.apiName}",
|
|
1063
|
+
userAgent: "${userAgent}",
|
|
1064
|
+
},
|
|
1065
|
+
objects: {
|
|
1066
|
+
${commaSeparatedTypeIdentifiers(objectNames)}
|
|
1067
|
+
},
|
|
1068
|
+
actions: {
|
|
1069
|
+
${commaSeparatedTypeIdentifiers(actionNames, actionAltNames)}
|
|
1070
|
+
},
|
|
1071
|
+
queries: {
|
|
1072
|
+
${commaSeparatedTypeIdentifiers(queryNames, queryAltNames)}
|
|
1073
|
+
},
|
|
1074
|
+
} = {
|
|
1075
|
+
metadata: {
|
|
1076
|
+
ontologyRid: "${ontology.ontology.rid}" as const,
|
|
1077
|
+
ontologyApiName: "${ontology.ontology.apiName}" as const,
|
|
1078
|
+
userAgent: "${userAgent}" as const,
|
|
1079
|
+
},
|
|
1080
|
+
objects: {
|
|
1081
|
+
${commaSeparatedIdentifiers(objectNames)}
|
|
1082
|
+
},
|
|
1083
|
+
actions: {
|
|
1084
|
+
${commaSeparatedIdentifiers(actionNames, actionAltNames)}
|
|
1085
|
+
},
|
|
1086
|
+
queries: {
|
|
1087
|
+
${commaSeparatedIdentifiers(queryNames, queryAltNames)}
|
|
1088
|
+
}
|
|
1089
|
+
} satisfies OntologyDefinition<
|
|
1090
|
+
${stringUnionFrom(objectNames)},
|
|
1091
|
+
${stringUnionFrom(Object.values(ontology.actionTypes).map((actionType) => actionType.apiName))},
|
|
1092
|
+
${stringUnionFrom(Object.values(ontology.queryTypes).map((queryType) => queryType.apiName))}>;
|
|
1093
|
+
|
|
1094
|
+
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
1095
|
+
objects: Objects;
|
|
1096
|
+
actions: Actions;
|
|
1097
|
+
bulkActions: BulkActions;
|
|
1098
|
+
queries: Queries;
|
|
1099
|
+
}`));
|
|
1106
1100
|
}
|
|
1107
|
-
function
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1101
|
+
function stringUnionFrom(values) {
|
|
1102
|
+
if (values.length === 0) {
|
|
1103
|
+
return "never";
|
|
1104
|
+
}
|
|
1105
|
+
return values.map((n) => `"${n}"`).join("|");
|
|
1106
|
+
}
|
|
1107
|
+
async function generateObjectsInterfaceFile(ontology, fs2, outDir, importExt = "") {
|
|
1108
|
+
await fs2.mkdir(outDir, {
|
|
1109
|
+
recursive: true
|
|
1113
1110
|
});
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
case "deleteObject":
|
|
1121
|
-
case "createLink":
|
|
1122
|
-
case "deleteLink":
|
|
1123
|
-
return [];
|
|
1111
|
+
await fs2.writeFile(path16__default.join(outDir, "Objects.ts"), await formatTs(`
|
|
1112
|
+
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
1113
|
+
${Array.from(Object.keys(ontology.objectTypes)).map((importedObject) => `import type { ${importedObject} } from "./${importedObject}${importExt}";`).join("\n")}
|
|
1114
|
+
|
|
1115
|
+
export interface Objects {
|
|
1116
|
+
${Object.keys(ontology.objectTypes).map((apiName) => `${apiName} : BaseObjectSet<${apiName}>;`).join("\n")}
|
|
1124
1117
|
}
|
|
1125
|
-
|
|
1126
|
-
return [...referenceObjectsInEdits, ...referencedObjectsInParameters];
|
|
1118
|
+
;`));
|
|
1127
1119
|
}
|
|
1128
|
-
function
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1120
|
+
async function generateObjectsInterfaceSupportFiles(ontology, fs2, outDir, importExt = "") {
|
|
1121
|
+
await fs2.mkdir(outDir, {
|
|
1122
|
+
recursive: true
|
|
1123
|
+
});
|
|
1124
|
+
for (const {
|
|
1125
|
+
objectType: {
|
|
1126
|
+
apiName
|
|
1127
|
+
}
|
|
1128
|
+
} of Object.values(ontology.objectTypes)) {
|
|
1129
|
+
const fileName = join(outDir, `${apiName}.ts`);
|
|
1130
|
+
const localApiName = `OG_${apiName}`;
|
|
1131
|
+
const contents = [];
|
|
1132
|
+
contents.push(`import { ObjectSetAggregateArg, ObjectSetFilterArg, ObjectSetGroupByArg, ObjectSetMultipleAggregateArg, ObjectSetOrderByArg } from "@osdk/legacy-client";`);
|
|
1133
|
+
contents.push(`import { ${apiName} as ${localApiName} } from "../${apiName}${importExt}";`);
|
|
1134
|
+
contents.push("");
|
|
1135
|
+
contents.push(`/** @deprecated Use ${apiName} from ontology/objects instead */`, `export type ${apiName} = ${localApiName};`);
|
|
1136
|
+
contents.push(`/** @deprecated Use ObjectSetFilterArg<${apiName}> instead */`, `export type ${apiName}Filter = ObjectSetFilterArg<${localApiName}>;`);
|
|
1137
|
+
contents.push(`/** @deprecated Use ObjectSetOrderByArg<${apiName}> instead */`, `export type ${apiName}OrderBy = ObjectSetOrderByArg<${localApiName}>;`);
|
|
1138
|
+
contents.push(`/** @deprecated Use ObjectSetGroupByArg<${apiName}> instead */`, `export type ${apiName}GroupByProperties = ObjectSetGroupByArg<${localApiName}>;`);
|
|
1139
|
+
contents.push(`
|
|
1140
|
+
/**
|
|
1141
|
+
* Aggregation properties for ${apiName}
|
|
1142
|
+
* @deprecated Use ObjectSetAggregateArg<${apiName}> instead
|
|
1143
|
+
*/`, `export type ${apiName}AggregationProperties = ObjectSetAggregateArg<${localApiName}>;`);
|
|
1144
|
+
contents.push(`
|
|
1145
|
+
/**
|
|
1146
|
+
* Multiple aggregation properties for ${apiName}.
|
|
1147
|
+
* @deprecated Use ObjectSetMultipleAggregateArg<${apiName}> instead
|
|
1148
|
+
*/`, `export type ${apiName}MultipleAggregationProperties = ObjectSetMultipleAggregateArg<${localApiName}>;`);
|
|
1149
|
+
await fs2.writeFile(fileName, contents.join("\n"));
|
|
1144
1150
|
}
|
|
1145
1151
|
}
|
|
1146
|
-
async function
|
|
1147
|
-
await
|
|
1152
|
+
async function generateOntologyIndexFile(fs2, outDir) {
|
|
1153
|
+
await fs2.mkdir(outDir, {
|
|
1154
|
+
recursive: true
|
|
1155
|
+
});
|
|
1156
|
+
await fs2.writeFile(path16.join(outDir, "index.ts"), await formatTs(`
|
|
1157
|
+
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1158
|
+
`));
|
|
1159
|
+
}
|
|
1160
|
+
async function generatePerObjectInterfaceAndDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1161
|
+
await fs2.mkdir(outDir, {
|
|
1148
1162
|
recursive: true
|
|
1149
1163
|
});
|
|
1150
1164
|
await Promise.all(Object.values(ontology.objectTypes).map(async (object) => {
|
|
1151
1165
|
object.linkTypes;
|
|
1152
|
-
await
|
|
1166
|
+
await fs2.writeFile(path16__default.join(outDir, `${object.objectType.apiName}.ts`), await formatTs(`
|
|
1153
1167
|
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1154
1168
|
${wireObjectTypeV2ToObjectInterfaceStringV1(object, importExt)}
|
|
1155
1169
|
|
|
1156
1170
|
${wireObjectTypeV2ToSdkObjectConst(object, importExt)}
|
|
1157
1171
|
`));
|
|
1158
1172
|
}));
|
|
1159
|
-
await
|
|
1173
|
+
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1160
1174
|
${Object.keys(ontology.objectTypes).map((apiName) => `export * from "./${apiName}${importExt}";`).join("\n")}
|
|
1161
1175
|
export type { ObjectSet } from "@osdk/legacy-client";
|
|
1162
1176
|
|
|
@@ -1316,18 +1330,18 @@ function wireQueryParameterV2ToQueryParameterDefinition(parameter) {
|
|
|
1316
1330
|
}
|
|
1317
1331
|
|
|
1318
1332
|
// src/v1.1/generatePerQueryDataFiles.ts
|
|
1319
|
-
async function generatePerQueryDataFiles(ontology,
|
|
1320
|
-
await
|
|
1333
|
+
async function generatePerQueryDataFiles(ontology, fs2, outDir, importExt = "") {
|
|
1334
|
+
await fs2.mkdir(outDir, {
|
|
1321
1335
|
recursive: true
|
|
1322
1336
|
});
|
|
1323
1337
|
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1324
1338
|
const objectTypes = getObjectTypesFromQuery(query);
|
|
1325
|
-
await
|
|
1339
|
+
await fs2.writeFile(path16__default.join(outDir, `${query.apiName}.ts`), await formatTs(`
|
|
1326
1340
|
import { QueryDefinition } from "@osdk/api";
|
|
1327
1341
|
|
|
1328
1342
|
export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} satisfies QueryDefinition<"${query.apiName}", ${objectTypes.length > 0 ? objectTypes.map((apiName) => `"${apiName}"`).join("|") : "never"}>;`));
|
|
1329
1343
|
}));
|
|
1330
|
-
await
|
|
1344
|
+
await fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1331
1345
|
${Object.values(ontology.queryTypes).map((query) => `export * from "./${query.apiName}${importExt}";`).join("\n")}
|
|
1332
1346
|
`));
|
|
1333
1347
|
}
|
|
@@ -1381,7 +1395,7 @@ function getObjectTypesFromDataType(dataType, types) {
|
|
|
1381
1395
|
throw new Error(`Cannot find object types from unsupported QueryDataType ${dataType.type}`);
|
|
1382
1396
|
}
|
|
1383
1397
|
}
|
|
1384
|
-
async function generateQueries(ontology,
|
|
1398
|
+
async function generateQueries(ontology, fs2, outDir, importExt = "") {
|
|
1385
1399
|
const importedObjects = /* @__PURE__ */ new Set();
|
|
1386
1400
|
const signatures = [];
|
|
1387
1401
|
for (const query of Object.values(ontology.queryTypes)) {
|
|
@@ -1404,10 +1418,10 @@ async function generateQueries(ontology, fs, outDir, importExt = "") {
|
|
|
1404
1418
|
${query.apiName}(${param}): Promise<Result<QueryResponse<${outputType}>, QueryError>>;
|
|
1405
1419
|
`);
|
|
1406
1420
|
}
|
|
1407
|
-
await
|
|
1421
|
+
await fs2.mkdir(outDir, {
|
|
1408
1422
|
recursive: true
|
|
1409
1423
|
});
|
|
1410
|
-
await
|
|
1424
|
+
await fs2.writeFile(path16__default.join(outDir, "Queries.ts"), await formatTs(`
|
|
1411
1425
|
import type { QueryResponse, QueryError, Result, Timestamp, LocalDate, Range, Attachment, ObjectSet, TwoDimensionalAggregation, ThreeDimensionalAggregation } from "@osdk/legacy-client";
|
|
1412
1426
|
${Array.from(importedObjects).map((importedObject) => `import type { ${importedObject} } from "../objects/${importedObject}${importExt}";`).join("\n")}
|
|
1413
1427
|
|
|
@@ -1525,37 +1539,39 @@ function sanitizeDocTypeName(type) {
|
|
|
1525
1539
|
}
|
|
1526
1540
|
|
|
1527
1541
|
// src/v1.1/generateClientSdkVersionOneDotOne.ts
|
|
1528
|
-
async function generateClientSdkVersionOneDotOne(ontology, userAgent,
|
|
1542
|
+
async function generateClientSdkVersionOneDotOne(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1529
1543
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1530
|
-
const objectsDir =
|
|
1531
|
-
const actionsDir =
|
|
1532
|
-
const queriesDir =
|
|
1533
|
-
await verifyOutdir(outDir,
|
|
1534
|
-
await
|
|
1544
|
+
const objectsDir = path16.join(outDir, "ontology", "objects");
|
|
1545
|
+
const actionsDir = path16.join(outDir, "ontology", "actions");
|
|
1546
|
+
const queriesDir = path16.join(outDir, "ontology", "queries");
|
|
1547
|
+
await verifyOutdir(outDir, fs2);
|
|
1548
|
+
await fs2.mkdir(outDir, {
|
|
1535
1549
|
recursive: true
|
|
1536
1550
|
});
|
|
1537
1551
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1538
|
-
await generateFoundryClientFile(
|
|
1539
|
-
await generateMetadataFile(sanitizedOntology, userAgent,
|
|
1540
|
-
await generateOntologyIndexFile(
|
|
1541
|
-
await generateObjectsInterfaceFile(sanitizedOntology,
|
|
1542
|
-
await generateObjectsInterfaceSupportFiles(sanitizedOntology,
|
|
1543
|
-
await generatePerObjectInterfaceAndDataFiles(sanitizedOntology,
|
|
1544
|
-
await generateActions(sanitizedOntology,
|
|
1545
|
-
await generateBulkActions(sanitizedOntology,
|
|
1546
|
-
await generatePerActionDataFiles(sanitizedOntology,
|
|
1547
|
-
await generateQueries(sanitizedOntology,
|
|
1548
|
-
await generatePerQueryDataFiles(sanitizedOntology,
|
|
1549
|
-
await generateIndexFile(
|
|
1550
|
-
await generateBackCompatDeprecatedExports(
|
|
1552
|
+
await generateFoundryClientFile(fs2, outDir, importExt);
|
|
1553
|
+
await generateMetadataFile(sanitizedOntology, userAgent, fs2, outDir, importExt);
|
|
1554
|
+
await generateOntologyIndexFile(fs2, path16.join(outDir, "ontology"));
|
|
1555
|
+
await generateObjectsInterfaceFile(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1556
|
+
await generateObjectsInterfaceSupportFiles(sanitizedOntology, fs2, path16.join(objectsDir, "objects-api"), importExt);
|
|
1557
|
+
await generatePerObjectInterfaceAndDataFiles(sanitizedOntology, fs2, objectsDir, importExt);
|
|
1558
|
+
await generateActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1559
|
+
await generateBulkActions(sanitizedOntology, fs2, actionsDir, importExt);
|
|
1560
|
+
await generatePerActionDataFiles(sanitizedOntology, fs2, actionsDir, importExt, false);
|
|
1561
|
+
await generateQueries(sanitizedOntology, fs2, queriesDir, importExt);
|
|
1562
|
+
await generatePerQueryDataFiles(sanitizedOntology, fs2, queriesDir, importExt);
|
|
1563
|
+
await generateIndexFile(fs2, outDir, importExt);
|
|
1564
|
+
await generateBackCompatDeprecatedExports(fs2, outDir, importExt);
|
|
1551
1565
|
}
|
|
1552
1566
|
function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false) {
|
|
1553
1567
|
const definition = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(interfaceDef, v2));
|
|
1554
1568
|
const objectDefIdentifier = getObjectDefIdentifier(interfaceDef.apiName, v2);
|
|
1555
1569
|
function getV2Types() {
|
|
1556
1570
|
return `
|
|
1557
|
-
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}> {
|
|
1571
|
+
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
|
|
1572
|
+
osdkMetadata: typeof $osdkMetadata;
|
|
1558
1573
|
${stringify(definition, {
|
|
1574
|
+
osdkMetadata: () => void 0,
|
|
1559
1575
|
type: () => void 0,
|
|
1560
1576
|
apiName: () => void 0,
|
|
1561
1577
|
links: (_value) => `{
|
|
@@ -1579,19 +1595,25 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1579
1595
|
${v2 ? getV2Types() : ""}
|
|
1580
1596
|
|
|
1581
1597
|
export const ${definition.apiName}: ${objectDefIdentifier} = {
|
|
1582
|
-
$
|
|
1598
|
+
osdkMetadata: $osdkMetadata,
|
|
1599
|
+
${stringify(definition, {
|
|
1600
|
+
osdkMetadata: () => void 0
|
|
1601
|
+
})}
|
|
1602
|
+
|
|
1583
1603
|
};`;
|
|
1584
1604
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1605
|
+
var ExpectedOsdkVersion = "0.15.1";
|
|
1606
|
+
async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
1607
|
+
fs2.writeFile(path16__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1608
|
+
import { OntologyMetadata as OM } from "@osdk/api";
|
|
1588
1609
|
|
|
1589
|
-
export
|
|
1590
|
-
|
|
1591
|
-
|
|
1610
|
+
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
|
|
1611
|
+
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
|
|
1612
|
+
|
|
1613
|
+
export interface OntologyMetadata extends OM<$ExpectedClientVersion> {};
|
|
1592
1614
|
|
|
1593
1615
|
export const OntologyMetadata: OntologyMetadata = {
|
|
1594
|
-
expectsClientVersion: "${
|
|
1616
|
+
expectsClientVersion: "${ExpectedOsdkVersion}",
|
|
1595
1617
|
ontologyRid: "${ontology.ontology.rid}",
|
|
1596
1618
|
ontologyApiName: "${ontology.ontology.apiName}",
|
|
1597
1619
|
userAgent: "${userAgent}",
|
|
@@ -1600,25 +1622,25 @@ async function generateOntologyMetadataFile(ontology, userAgent, fs, outDir) {
|
|
|
1600
1622
|
}
|
|
1601
1623
|
|
|
1602
1624
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1603
|
-
async function generateClientSdkVersionTwoPointZero(ontology, userAgent,
|
|
1604
|
-
await verifyOutdir(outDir,
|
|
1625
|
+
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs") {
|
|
1626
|
+
await verifyOutdir(outDir, fs2);
|
|
1605
1627
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
1606
1628
|
const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => a.localeCompare(b));
|
|
1607
1629
|
const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => a.localeCompare(b));
|
|
1608
1630
|
Object.keys(sanitizedOntology.queryTypes).sort((a, b) => a.localeCompare(b));
|
|
1609
1631
|
const interfaceNames = Object.keys(sanitizedOntology.interfaceTypes ?? {}).sort((a, b) => a.localeCompare(b));
|
|
1610
1632
|
const importExt = packageType === "module" ? ".js" : "";
|
|
1611
|
-
await
|
|
1633
|
+
await fs2.mkdir(outDir, {
|
|
1612
1634
|
recursive: true
|
|
1613
1635
|
});
|
|
1614
|
-
|
|
1636
|
+
fs2.writeFile(path16__default.join(outDir, "index.ts"), await formatTs(`
|
|
1615
1637
|
export { Ontology } from "./Ontology${importExt}";
|
|
1616
1638
|
export * from "./ontology/actions/index${importExt}";
|
|
1617
1639
|
export * from "./ontology/objects${importExt}";
|
|
1618
1640
|
export * from "./ontology/interfaces${importExt}";
|
|
1619
1641
|
`));
|
|
1620
|
-
await generateOntologyMetadataFile(sanitizedOntology, userAgent,
|
|
1621
|
-
await
|
|
1642
|
+
await generateOntologyMetadataFile(sanitizedOntology, userAgent, fs2, outDir);
|
|
1643
|
+
await fs2.writeFile(path16__default.join(outDir, "Ontology.ts"), await formatTs(`
|
|
1622
1644
|
import type { OntologyDefinition } from "@osdk/api";
|
|
1623
1645
|
import * as Actions from "./ontology/actions/index${importExt}";
|
|
1624
1646
|
import * as Objects from "./ontology/objects${importExt}";
|
|
@@ -1653,25 +1675,27 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs, out
|
|
|
1653
1675
|
export interface Ontology extends _Ontology {}
|
|
1654
1676
|
export const Ontology = _Ontology as Ontology;
|
|
1655
1677
|
`));
|
|
1656
|
-
await
|
|
1678
|
+
await fs2.mkdir(path16__default.join(outDir, "ontology", "objects"), {
|
|
1657
1679
|
recursive: true
|
|
1658
1680
|
});
|
|
1659
1681
|
for (const name of objectNames) {
|
|
1660
1682
|
const obj = ontology.objectTypes[name];
|
|
1661
|
-
await
|
|
1662
|
-
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1683
|
+
await fs2.writeFile(path16__default.join(outDir, "ontology", `objects`, `${name}.ts`), await formatTs(`
|
|
1684
|
+
import type { ObjectTypeDefinition, VersionBound, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1663
1685
|
import { Osdk } from "@osdk/client";
|
|
1686
|
+
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1687
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1664
1688
|
|
|
1665
1689
|
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
|
|
1666
1690
|
`));
|
|
1667
1691
|
}
|
|
1668
|
-
await generateOntologyInterfaces(
|
|
1669
|
-
const actionsDir =
|
|
1670
|
-
await
|
|
1692
|
+
await generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology, importExt);
|
|
1693
|
+
const actionsDir = path16__default.join(outDir, "ontology", "actions");
|
|
1694
|
+
await fs2.mkdir(actionsDir, {
|
|
1671
1695
|
recursive: true
|
|
1672
1696
|
});
|
|
1673
|
-
await generatePerActionDataFiles(sanitizedOntology,
|
|
1674
|
-
await
|
|
1697
|
+
await generatePerActionDataFiles(sanitizedOntology, fs2, actionsDir, importExt, true);
|
|
1698
|
+
await fs2.writeFile(path16__default.join(outDir, "ontology", "objects.ts"), await formatTs(`
|
|
1675
1699
|
${Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map((apiName) => `export * from "./objects/${apiName}${importExt}";`).join("\n")}
|
|
1676
1700
|
${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}
|
|
1677
1701
|
`));
|
|
@@ -1683,26 +1707,128 @@ function stringUnionFrom2(values) {
|
|
|
1683
1707
|
return values.map((v) => `"${v}"`).join("|");
|
|
1684
1708
|
}
|
|
1685
1709
|
}
|
|
1686
|
-
async function generateOntologyInterfaces(
|
|
1687
|
-
const interfacesDir =
|
|
1688
|
-
await
|
|
1710
|
+
async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology, importExt) {
|
|
1711
|
+
const interfacesDir = path16__default.join(outDir, "ontology", "interfaces");
|
|
1712
|
+
await fs2.mkdir(interfacesDir, {
|
|
1689
1713
|
recursive: true
|
|
1690
1714
|
});
|
|
1691
1715
|
for (const name of interfaceNames) {
|
|
1692
1716
|
const obj = ontology.interfaceTypes[name];
|
|
1693
|
-
await
|
|
1717
|
+
await fs2.writeFile(path16__default.join(interfacesDir, `${name}.ts`), await formatTs(`
|
|
1694
1718
|
|
|
1695
|
-
import type { InterfaceDefinition, PropertyDef } from "@osdk/api";
|
|
1719
|
+
import type { InterfaceDefinition, PropertyDef, VersionBound } from "@osdk/api";
|
|
1720
|
+
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1721
|
+
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1696
1722
|
|
|
1697
1723
|
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
|
|
1698
1724
|
`));
|
|
1699
1725
|
}
|
|
1700
|
-
await
|
|
1726
|
+
await fs2.writeFile(interfacesDir + ".ts", await formatTs(`
|
|
1701
1727
|
${Object.keys(ontology.interfaceTypes ?? {}).map((apiName) => `export * from "./interfaces/${apiName}${importExt}";`).join("\n")}
|
|
1702
1728
|
${Object.keys(ontology.interfaceTypes ?? {}).length === 0 ? "export {}" : ""}
|
|
1703
1729
|
`));
|
|
1704
1730
|
}
|
|
1705
1731
|
|
|
1706
|
-
|
|
1732
|
+
// src/generateClientSdkPackage.ts
|
|
1733
|
+
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion) {
|
|
1734
|
+
if (!packageName)
|
|
1735
|
+
throw new Error("Package name is require");
|
|
1736
|
+
for (const packageType of ["module", "commonjs"]) {
|
|
1737
|
+
const outDir = path16.join(baseOutDir, "dist", packageType);
|
|
1738
|
+
await (sdkVersion === "1.1" ? generateClientSdkVersionOneDotOne : sdkVersion === "2.0" ? generateClientSdkVersionTwoPointZero : void 0)(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType);
|
|
1739
|
+
await fs.promises.mkdir(outDir, {
|
|
1740
|
+
recursive: true
|
|
1741
|
+
});
|
|
1742
|
+
await writeJson(minimalFs, path16.join(outDir, "package.json"), {
|
|
1743
|
+
type: packageType
|
|
1744
|
+
});
|
|
1745
|
+
await writeJson(minimalFs, path16.join(outDir, `tsconfig.json`), {
|
|
1746
|
+
compilerOptions: getTsCompilerOptions(packageType)
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
await writeJson(minimalFs, path16.join(baseOutDir, "package.json"), await getPackageJsonContents(packageName, packageVersion, sdkVersion, dependencyVersions));
|
|
1750
|
+
await minimalFs.mkdir(path16.join(baseOutDir, "ontology"), {
|
|
1751
|
+
recursive: true
|
|
1752
|
+
});
|
|
1753
|
+
await minimalFs.writeFile(path16.join(baseOutDir, "ontology", "objects.js"), `module.exports = require("../../dist/module/ontology/objects")`);
|
|
1754
|
+
await minimalFs.writeFile(path16.join(baseOutDir, "ontology", "objects.d.ts"), `export * from "../dist/module/ontology/objects"`);
|
|
1755
|
+
}
|
|
1756
|
+
function getTsCompilerOptions(packageType) {
|
|
1757
|
+
const commonTsconfig = {
|
|
1758
|
+
importHelpers: true,
|
|
1759
|
+
declaration: true,
|
|
1760
|
+
isolatedModules: true,
|
|
1761
|
+
esModuleInterop: true,
|
|
1762
|
+
forceConsistentCasingInFileNames: true,
|
|
1763
|
+
strict: true,
|
|
1764
|
+
skipLibCheck: true
|
|
1765
|
+
};
|
|
1766
|
+
const compilerOptions = packageType === "commonjs" ? {
|
|
1767
|
+
...commonTsconfig,
|
|
1768
|
+
module: "commonjs",
|
|
1769
|
+
target: "es2018"
|
|
1770
|
+
} : {
|
|
1771
|
+
...commonTsconfig,
|
|
1772
|
+
module: "NodeNext",
|
|
1773
|
+
target: "ES2020"
|
|
1774
|
+
};
|
|
1775
|
+
return compilerOptions;
|
|
1776
|
+
}
|
|
1777
|
+
function getPackageJsonContents(name, version, sdkVersion, {
|
|
1778
|
+
typescriptVersion,
|
|
1779
|
+
tslibVersion,
|
|
1780
|
+
areTheTypesWrongVersion,
|
|
1781
|
+
osdkApiVersion,
|
|
1782
|
+
osdkClientVersion,
|
|
1783
|
+
osdkLegacyClientVersion
|
|
1784
|
+
}) {
|
|
1785
|
+
const esmPrefix = "./dist/module";
|
|
1786
|
+
const commonjsPrefix = "./dist/commonjs";
|
|
1787
|
+
return {
|
|
1788
|
+
name,
|
|
1789
|
+
version,
|
|
1790
|
+
main: `${commonjsPrefix}/index.js`,
|
|
1791
|
+
module: `${esmPrefix}/index.js`,
|
|
1792
|
+
exports: {
|
|
1793
|
+
".": {
|
|
1794
|
+
import: `${esmPrefix}/index.js`,
|
|
1795
|
+
require: `${commonjsPrefix}/index.js`
|
|
1796
|
+
},
|
|
1797
|
+
"./ontology/objects": {
|
|
1798
|
+
import: `${esmPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`,
|
|
1799
|
+
require: `${commonjsPrefix}/ontology/objects${sdkVersion === "2.0" ? "" : "/index"}.js`
|
|
1800
|
+
}
|
|
1801
|
+
},
|
|
1802
|
+
scripts: {
|
|
1803
|
+
prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,
|
|
1804
|
+
check: "npm exec attw $(npm pack)"
|
|
1805
|
+
},
|
|
1806
|
+
devDependencies: {
|
|
1807
|
+
"typescript": typescriptVersion,
|
|
1808
|
+
"tslib": tslibVersion,
|
|
1809
|
+
"@arethetypeswrong/cli": areTheTypesWrongVersion,
|
|
1810
|
+
"@osdk/api": osdkApiVersion,
|
|
1811
|
+
...sdkVersion === "2.0" ? {
|
|
1812
|
+
"@osdk/client": osdkClientVersion
|
|
1813
|
+
} : {
|
|
1814
|
+
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1815
|
+
}
|
|
1816
|
+
},
|
|
1817
|
+
peerDependencies: {
|
|
1818
|
+
"@osdk/api": osdkApiVersion,
|
|
1819
|
+
...sdkVersion === "2.0" ? {
|
|
1820
|
+
"@osdk/client": osdkClientVersion
|
|
1821
|
+
} : {
|
|
1822
|
+
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1823
|
+
}
|
|
1824
|
+
},
|
|
1825
|
+
files: ["**/*.js", "**/*.d.ts", "dist/**/package.json"]
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
async function writeJson(minimalFs, filePath, body) {
|
|
1829
|
+
return await minimalFs.writeFile(filePath, JSON.stringify(body, void 0, 2) + "\n");
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero };
|
|
1707
1833
|
//# sourceMappingURL=out.js.map
|
|
1708
1834
|
//# sourceMappingURL=index.mjs.map
|