@osdk/generator 2.8.0-beta.25 → 2.8.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/build/browser/GenerateContext/EnhancedAction.js +13 -0
- package/build/browser/GenerateContext/EnhancedAction.js.map +1 -1
- package/build/browser/GenerateContext/GenerateContext.js.map +1 -1
- package/build/browser/generateClientSdkPackage.js +1 -1
- package/build/browser/generateClientSdkPackage.js.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +1 -4
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.js +2 -6
- package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/cjs/index.cjs +17 -73
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +12 -1
- package/build/esm/GenerateContext/EnhancedAction.js +13 -0
- package/build/esm/GenerateContext/EnhancedAction.js.map +1 -1
- package/build/esm/GenerateContext/GenerateContext.js.map +1 -1
- package/build/esm/generateClientSdkPackage.js +1 -1
- package/build/esm/generateClientSdkPackage.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +1 -4
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.js +2 -6
- package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/types/GenerateContext/EnhancedAction.d.ts +2 -0
- package/build/types/GenerateContext/EnhancedAction.d.ts.map +1 -1
- package/build/types/GenerateContext/GenerateContext.d.ts +0 -2
- package/build/types/GenerateContext/GenerateContext.d.ts.map +1 -1
- package/build/types/generateClientSdkPackage.d.ts +11 -0
- package/build/types/generateClientSdkPackage.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/types/v2.0/generatePerActionDataFiles.d.ts +1 -1
- package/build/types/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/package.json +3 -3
- package/build/browser/shared/sanitizeMetadata.js +0 -42
- package/build/browser/shared/sanitizeMetadata.js.map +0 -1
- package/build/esm/shared/sanitizeMetadata.js +0 -42
- package/build/esm/shared/sanitizeMetadata.js.map +0 -1
- package/build/types/shared/sanitizeMetadata.d.ts +0 -1
- package/build/types/shared/sanitizeMetadata.d.ts.map +0 -1
package/build/cjs/index.d.cts
CHANGED
|
@@ -14,6 +14,17 @@ interface WireOntologyDefinition extends gateway.OntologyFullMetadata {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
declare function generateClientSdkPackage(packageName: string, packageVersion: string, sdkVersion: "1.1" | "2.0", baseOutDir: string, ontology: WireOntologyDefinition, minimalFs: MinimalFs, dependencyVersions: DependencyVersions, cliVersion: string, externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>): Promise<void>;
|
|
17
|
+
declare function getTsCompilerOptions(packageType: "commonjs" | "module"): {
|
|
18
|
+
importHelpers: boolean;
|
|
19
|
+
declaration: boolean;
|
|
20
|
+
isolatedModules: boolean;
|
|
21
|
+
esModuleInterop: boolean;
|
|
22
|
+
forceConsistentCasingInFileNames: boolean;
|
|
23
|
+
strict: boolean;
|
|
24
|
+
skipLibCheck: boolean;
|
|
25
|
+
module: string;
|
|
26
|
+
target: string;
|
|
27
|
+
};
|
|
17
28
|
interface DependencyVersions {
|
|
18
29
|
typescriptVersion: string;
|
|
19
30
|
tslibVersion: string;
|
|
@@ -28,4 +39,4 @@ declare function getExpectedDependencies({ osdkApiVersion, osdkClientVersion, }:
|
|
|
28
39
|
|
|
29
40
|
declare function generateClientSdkVersionTwoPointZero(ontology: WireOntologyDefinition, userAgent: string, fs: MinimalFs, outDir: string, packageType?: "module" | "commonjs", externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>, externalSpts?: Map<string, string>, forInternalUse?: boolean, fixedVersionQueryTypes?: string[]): Promise<void>;
|
|
30
41
|
|
|
31
|
-
export { type MinimalFs, type WireOntologyDefinition, generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionTwoPointZero, getExpectedDependencies };
|
|
42
|
+
export { type MinimalFs, type WireOntologyDefinition, generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionTwoPointZero, getExpectedDependencies, getTsCompilerOptions };
|
|
@@ -16,13 +16,23 @@
|
|
|
16
16
|
|
|
17
17
|
import { EnhancedBase } from "./EnhancedBase.js";
|
|
18
18
|
export class EnhancedAction extends EnhancedBase {
|
|
19
|
+
#unsanitizedApiName;
|
|
19
20
|
constructor(common, raw) {
|
|
21
|
+
const unsanitizedApiName = raw.apiName;
|
|
22
|
+
raw = {
|
|
23
|
+
...raw,
|
|
24
|
+
apiName: camelize(raw.apiName)
|
|
25
|
+
};
|
|
20
26
|
super(common, raw, raw.apiName, "./ontology/actions");
|
|
21
27
|
this.raw = raw;
|
|
28
|
+
this.#unsanitizedApiName = unsanitizedApiName;
|
|
22
29
|
}
|
|
23
30
|
get description() {
|
|
24
31
|
return this.raw.description;
|
|
25
32
|
}
|
|
33
|
+
get unsanitizedApiName() {
|
|
34
|
+
return this.#unsanitizedApiName;
|
|
35
|
+
}
|
|
26
36
|
get parameters() {
|
|
27
37
|
return this.raw.parameters;
|
|
28
38
|
}
|
|
@@ -39,4 +49,7 @@ export class EnhancedAction extends EnhancedBase {
|
|
|
39
49
|
return `${this.shortApiName}.ParamsDefinition`;
|
|
40
50
|
}
|
|
41
51
|
}
|
|
52
|
+
function camelize(name) {
|
|
53
|
+
return name.replace(/-./g, segment => segment[1].toUpperCase());
|
|
54
|
+
}
|
|
42
55
|
//# sourceMappingURL=EnhancedAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedAction.js","names":["EnhancedBase","EnhancedAction","constructor","common","raw","apiName","description","parameters","operations","paramsIdentifier","shortApiName","definitionIdentifier","definitionParamsIdentifier"],"sources":["EnhancedAction.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionTypeV2, LogicRule } from \"@osdk/foundry.ontologies\";\nimport type { EnhanceCommon } from \"./EnhanceCommon.js\";\nimport { EnhancedBase } from \"./EnhancedBase.js\";\n\nexport class EnhancedAction extends EnhancedBase<ActionTypeV2> {\n constructor(common: EnhanceCommon, public raw: ActionTypeV2) {\n super(common, raw, raw.apiName, \"./ontology/actions\");\n }\n\n get description(): string | undefined {\n return this.raw.description;\n }\n\n get parameters(): ActionTypeV2[\"parameters\"] {\n return this.raw.parameters;\n }\n\n get operations(): LogicRule[] {\n return this.raw.operations;\n }\n\n get paramsIdentifier() {\n return `${this.shortApiName}.Params`;\n }\n\n get definitionIdentifier() {\n return `${this.shortApiName}.Definition`;\n }\n\n get definitionParamsIdentifier() {\n return `${this.shortApiName}.ParamsDefinition`;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,YAAY,QAAQ,mBAAmB;AAEhD,OAAO,MAAMC,cAAc,SAASD,YAAY,CAAe;
|
|
1
|
+
{"version":3,"file":"EnhancedAction.js","names":["EnhancedBase","EnhancedAction","unsanitizedApiName","constructor","common","raw","apiName","camelize","description","parameters","operations","paramsIdentifier","shortApiName","definitionIdentifier","definitionParamsIdentifier","name","replace","segment","toUpperCase"],"sources":["EnhancedAction.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionTypeV2, LogicRule } from \"@osdk/foundry.ontologies\";\nimport type { EnhanceCommon } from \"./EnhanceCommon.js\";\nimport { EnhancedBase } from \"./EnhancedBase.js\";\n\nexport class EnhancedAction extends EnhancedBase<ActionTypeV2> {\n #unsanitizedApiName?: string;\n constructor(common: EnhanceCommon, public raw: ActionTypeV2) {\n const unsanitizedApiName = raw.apiName;\n raw = { ...raw, apiName: camelize(raw.apiName) };\n super(common, raw, raw.apiName, \"./ontology/actions\");\n this.#unsanitizedApiName = unsanitizedApiName;\n }\n\n get description(): string | undefined {\n return this.raw.description;\n }\n\n get unsanitizedApiName(): string | undefined {\n return this.#unsanitizedApiName;\n }\n\n get parameters(): ActionTypeV2[\"parameters\"] {\n return this.raw.parameters;\n }\n\n get operations(): LogicRule[] {\n return this.raw.operations;\n }\n\n get paramsIdentifier() {\n return `${this.shortApiName}.Params`;\n }\n\n get definitionIdentifier() {\n return `${this.shortApiName}.Definition`;\n }\n\n get definitionParamsIdentifier() {\n return `${this.shortApiName}.ParamsDefinition`;\n }\n}\n\nfunction camelize(name: string) {\n return name.replace(/-./g, segment => segment[1]!.toUpperCase());\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,YAAY,QAAQ,mBAAmB;AAEhD,OAAO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"version":3,"file":"GenerateContext.js","names":[],"sources":["GenerateContext.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MinimalFs } from \"../MinimalFs.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"GenerateContext.js","names":[],"sources":["GenerateContext.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MinimalFs } from \"../MinimalFs.js\";\nimport type { EnhancedOntologyDefinition } from \"./EnhancedOntologyDefinition.js\";\n\nexport interface GenerateContext {\n ontology: EnhancedOntologyDefinition;\n\n importExt?: string;\n fs: MinimalFs;\n\n outDir: string;\n fixedVersionQueryTypes: string[];\n ontologyApiNamespace?: string | undefined;\n apiNamespacePackageMap?: Map<string, string>;\n forInternalUse?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -44,7 +44,7 @@ export async function generateClientSdkPackage(packageName, packageVersion, sdkV
|
|
|
44
44
|
await minimalFs.writeFile(path.join(baseOutDir, "ontology", "objects.js"), `module.exports = require("../../dist/module/ontology/objects")`);
|
|
45
45
|
await minimalFs.writeFile(path.join(baseOutDir, "ontology", "objects.d.ts"), `export * from "../dist/module/ontology/objects"`);
|
|
46
46
|
}
|
|
47
|
-
function getTsCompilerOptions(packageType) {
|
|
47
|
+
export function getTsCompilerOptions(packageType) {
|
|
48
48
|
const commonTsconfig = {
|
|
49
49
|
importHelpers: true,
|
|
50
50
|
declaration: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClientSdkPackage.js","names":["fs","path","generateClientSdkVersionTwoPointZero","generateClientSdkPackage","packageName","packageVersion","sdkVersion","baseOutDir","ontology","minimalFs","dependencyVersions","cliVersion","externalObjects","Map","externalInterfaces","Error","packageType","outDir","join","promises","mkdir","recursive","writeJson","type","compilerOptions","getTsCompilerOptions","getPackageJsonContents","writeFile","commonTsconfig","importHelpers","declaration","isolatedModules","esModuleInterop","forceConsistentCasingInFileNames","strict","skipLibCheck","module","target","getExpectedDependencies","osdkApiVersion","osdkClientVersion","devDependencies","peerDependencies","getExpectedDependenciesFull","typescriptVersion","tslibVersion","areTheTypesWrongVersion","base","name","version","esmPrefix","commonjsPrefix","main","exports","import","require","scripts","prepack","check","files","filePath","body","JSON","stringify","undefined"],"sources":["generateClientSdkPackage.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { MinimalFs } from \"./MinimalFs.js\";\nimport { generateClientSdkVersionTwoPointZero } from \"./v2.0/generateClientSdkVersionTwoPointZero.js\";\nimport type { WireOntologyDefinition } from \"./WireOntologyDefinition.js\";\n\nexport async function generateClientSdkPackage(\n packageName: string,\n packageVersion: string,\n sdkVersion: \"1.1\" | \"2.0\",\n baseOutDir: string,\n ontology: WireOntologyDefinition,\n minimalFs: MinimalFs,\n dependencyVersions: DependencyVersions,\n cliVersion: string,\n externalObjects: Map<string, string> = new Map(),\n externalInterfaces: Map<string, string> = new Map(),\n): Promise<void> {\n if (!packageName) throw new Error(\"Package name is required\");\n if (sdkVersion === \"1.1\") {\n throw new Error(\n \"This generator version does not support generating v1 sdks\",\n );\n }\n\n for (const packageType of [\"module\", \"commonjs\"] as const) {\n const outDir = path.join(baseOutDir, \"dist\", packageType);\n\n await generateClientSdkVersionTwoPointZero(\n ontology,\n `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`,\n minimalFs,\n outDir,\n packageType,\n externalObjects,\n externalInterfaces,\n );\n\n await fs.promises.mkdir(outDir, { recursive: true });\n await writeJson(\n minimalFs,\n path.join(outDir, \"package.json\"),\n { type: packageType },\n );\n\n await writeJson(\n minimalFs,\n path.join(outDir, `tsconfig.json`),\n {\n compilerOptions: getTsCompilerOptions(packageType),\n },\n );\n }\n\n await writeJson(\n minimalFs,\n path.join(baseOutDir, \"package.json\"),\n getPackageJsonContents(\n packageName,\n packageVersion,\n dependencyVersions,\n ),\n );\n\n // we need to shim for the node10 resolver\n await minimalFs.mkdir(path.join(baseOutDir, \"ontology\"), {\n recursive: true,\n });\n await minimalFs.writeFile(\n path.join(baseOutDir, \"ontology\", \"objects.js\"),\n `module.exports = require(\"../../dist/module/ontology/objects\")`,\n );\n await minimalFs.writeFile(\n path.join(baseOutDir, \"ontology\", \"objects.d.ts\"),\n `export * from \"../dist/module/ontology/objects\"`,\n );\n}\n\nfunction getTsCompilerOptions(packageType: \"commonjs\" | \"module\") {\n const commonTsconfig = {\n importHelpers: true,\n\n declaration: true,\n\n isolatedModules: true,\n esModuleInterop: true,\n\n forceConsistentCasingInFileNames: true,\n strict: true,\n\n skipLibCheck: true,\n };\n\n const compilerOptions = packageType === \"commonjs\"\n ? {\n ...commonTsconfig,\n module: \"commonjs\",\n target: \"es2018\",\n }\n : {\n ...commonTsconfig,\n module: \"NodeNext\",\n target: \"ES2020\",\n };\n return compilerOptions;\n}\n\nexport interface DependencyVersions {\n typescriptVersion: string;\n tslibVersion: string;\n areTheTypesWrongVersion: string;\n osdkApiVersion: string;\n osdkClientVersion: string;\n}\n\nexport function getExpectedDependencies(\n {\n osdkApiVersion,\n osdkClientVersion,\n }: DependencyVersions,\n): {\n devDependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n} {\n return {\n devDependencies: {\n \"@osdk/api\": osdkApiVersion,\n },\n peerDependencies: {\n \"@osdk/api\": osdkApiVersion,\n \"@osdk/client\": osdkClientVersion,\n },\n };\n}\n\nfunction getExpectedDependenciesFull(\n dependencyVersions: DependencyVersions,\n) {\n const {\n typescriptVersion,\n tslibVersion,\n areTheTypesWrongVersion,\n } = dependencyVersions;\n\n const base = getExpectedDependencies(dependencyVersions);\n\n return {\n devDependencies: {\n ...base.devDependencies,\n \"typescript\": typescriptVersion,\n \"tslib\": tslibVersion,\n \"@arethetypeswrong/cli\": areTheTypesWrongVersion,\n },\n peerDependencies: {\n ...base.peerDependencies,\n },\n };\n}\n\nexport function getPackageJsonContents(\n name: string,\n version: string,\n dependencyVersions: DependencyVersions,\n): {\n files: string[];\n devDependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n name: string;\n version: string;\n main: string;\n module: string;\n exports: {\n \".\": {\n import: string;\n require: string;\n };\n };\n scripts: {\n prepack: string;\n check: string;\n };\n} {\n const esmPrefix = \"./dist/module\";\n const commonjsPrefix = \"./dist/commonjs\";\n return {\n name,\n version,\n main: `${commonjsPrefix}/index.js`,\n module: `${esmPrefix}/index.js`,\n exports: {\n \".\": {\n import: `${esmPrefix}/index.js`,\n require: `${commonjsPrefix}/index.js`,\n },\n },\n scripts: {\n prepack:\n `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,\n check: \"npm exec attw $(npm pack)\",\n },\n ...getExpectedDependenciesFull(dependencyVersions),\n files: [\n \"**/*.js\",\n \"**/*.d.ts\",\n \"dist/**/package.json\",\n ],\n };\n}\n\nasync function writeJson(\n minimalFs: MinimalFs,\n filePath: string,\n body: unknown,\n) {\n // consola.info(`Writing ${filePath}`);\n // consola.debug(`Writing ${filePath} with body`, body);\n return void await minimalFs.writeFile(\n filePath,\n JSON.stringify(body, undefined, 2) + \"\\n\",\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AAEjC,SAASC,oCAAoC,QAAQ,gDAAgD;AAGrG,OAAO,eAAeC,wBAAwBA,CAC5CC,WAAmB,EACnBC,cAAsB,EACtBC,UAAyB,EACzBC,UAAkB,EAClBC,QAAgC,EAChCC,SAAoB,EACpBC,kBAAsC,EACtCC,UAAkB,EAClBC,eAAoC,GAAG,IAAIC,GAAG,CAAC,CAAC,EAChDC,kBAAuC,GAAG,IAAID,GAAG,CAAC,CAAC,EACpC;EACf,IAAI,CAACT,WAAW,EAAE,MAAM,IAAIW,KAAK,CAAC,0BAA0B,CAAC;EAC7D,IAAIT,UAAU,KAAK,KAAK,EAAE;IACxB,MAAM,IAAIS,KAAK,CACb,4DACF,CAAC;EACH;EAEA,KAAK,MAAMC,WAAW,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAW;IACzD,MAAMC,MAAM,GAAGhB,IAAI,CAACiB,IAAI,CAACX,UAAU,EAAE,MAAM,EAAES,WAAW,CAAC;IAEzD,MAAMd,oCAAoC,CACxCM,QAAQ,EACR,kBAAkBH,cAAc,aAAaM,UAAU,EAAE,EACzDF,SAAS,EACTQ,MAAM,EACND,WAAW,EACXJ,eAAe,EACfE,kBACF,CAAC;IAED,MAAMd,EAAE,CAACmB,QAAQ,CAACC,K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,GAAGf,2BAA2B,CAACjC,kBAAkB,CAAC;IAClDiD,KAAK,EAAE,CACL,SAAS,EACT,WAAW,EACX,sBAAsB;EAE1B,CAAC;AACH;AAEA,eAAerC,SAASA,CACtBb,SAAoB,EACpBmD,QAAgB,EAChBC,IAAa,EACb;EACA;EACA;EACA,OAAO,MAAK,MAAMpD,SAAS,CAACkB,SAAS,CACnCiC,QAAQ,EACRE,IAAI,CAACC,SAAS,CAACF,IAAI,EAAEG,SAAS,EAAE,CAAC,CAAC,GAAG,IACvC,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generateClientSdkPackage.js","names":["fs","path","generateClientSdkVersionTwoPointZero","generateClientSdkPackage","packageName","packageVersion","sdkVersion","baseOutDir","ontology","minimalFs","dependencyVersions","cliVersion","externalObjects","Map","externalInterfaces","Error","packageType","outDir","join","promises","mkdir","recursive","writeJson","type","compilerOptions","getTsCompilerOptions","getPackageJsonContents","writeFile","commonTsconfig","importHelpers","declaration","isolatedModules","esModuleInterop","forceConsistentCasingInFileNames","strict","skipLibCheck","module","target","getExpectedDependencies","osdkApiVersion","osdkClientVersion","devDependencies","peerDependencies","getExpectedDependenciesFull","typescriptVersion","tslibVersion","areTheTypesWrongVersion","base","name","version","esmPrefix","commonjsPrefix","main","exports","import","require","scripts","prepack","check","files","filePath","body","JSON","stringify","undefined"],"sources":["generateClientSdkPackage.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { MinimalFs } from \"./MinimalFs.js\";\nimport { generateClientSdkVersionTwoPointZero } from \"./v2.0/generateClientSdkVersionTwoPointZero.js\";\nimport type { WireOntologyDefinition } from \"./WireOntologyDefinition.js\";\n\nexport async function generateClientSdkPackage(\n packageName: string,\n packageVersion: string,\n sdkVersion: \"1.1\" | \"2.0\",\n baseOutDir: string,\n ontology: WireOntologyDefinition,\n minimalFs: MinimalFs,\n dependencyVersions: DependencyVersions,\n cliVersion: string,\n externalObjects: Map<string, string> = new Map(),\n externalInterfaces: Map<string, string> = new Map(),\n): Promise<void> {\n if (!packageName) throw new Error(\"Package name is required\");\n if (sdkVersion === \"1.1\") {\n throw new Error(\n \"This generator version does not support generating v1 sdks\",\n );\n }\n\n for (const packageType of [\"module\", \"commonjs\"] as const) {\n const outDir = path.join(baseOutDir, \"dist\", packageType);\n\n await generateClientSdkVersionTwoPointZero(\n ontology,\n `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`,\n minimalFs,\n outDir,\n packageType,\n externalObjects,\n externalInterfaces,\n );\n\n await fs.promises.mkdir(outDir, { recursive: true });\n await writeJson(\n minimalFs,\n path.join(outDir, \"package.json\"),\n { type: packageType },\n );\n\n await writeJson(\n minimalFs,\n path.join(outDir, `tsconfig.json`),\n {\n compilerOptions: getTsCompilerOptions(packageType),\n },\n );\n }\n\n await writeJson(\n minimalFs,\n path.join(baseOutDir, \"package.json\"),\n getPackageJsonContents(\n packageName,\n packageVersion,\n dependencyVersions,\n ),\n );\n\n // we need to shim for the node10 resolver\n await minimalFs.mkdir(path.join(baseOutDir, \"ontology\"), {\n recursive: true,\n });\n await minimalFs.writeFile(\n path.join(baseOutDir, \"ontology\", \"objects.js\"),\n `module.exports = require(\"../../dist/module/ontology/objects\")`,\n );\n await minimalFs.writeFile(\n path.join(baseOutDir, \"ontology\", \"objects.d.ts\"),\n `export * from \"../dist/module/ontology/objects\"`,\n );\n}\n\nexport function getTsCompilerOptions(packageType: \"commonjs\" | \"module\"): {\n importHelpers: boolean;\n declaration: boolean;\n isolatedModules: boolean;\n esModuleInterop: boolean;\n forceConsistentCasingInFileNames: boolean;\n strict: boolean;\n skipLibCheck: boolean;\n module: string;\n target: string;\n} {\n const commonTsconfig = {\n importHelpers: true,\n\n declaration: true,\n\n isolatedModules: true,\n esModuleInterop: true,\n\n forceConsistentCasingInFileNames: true,\n strict: true,\n\n skipLibCheck: true,\n };\n\n const compilerOptions = packageType === \"commonjs\"\n ? {\n ...commonTsconfig,\n module: \"commonjs\",\n target: \"es2018\",\n }\n : {\n ...commonTsconfig,\n module: \"NodeNext\",\n target: \"ES2020\",\n };\n return compilerOptions;\n}\n\nexport interface DependencyVersions {\n typescriptVersion: string;\n tslibVersion: string;\n areTheTypesWrongVersion: string;\n osdkApiVersion: string;\n osdkClientVersion: string;\n}\n\nexport function getExpectedDependencies(\n {\n osdkApiVersion,\n osdkClientVersion,\n }: DependencyVersions,\n): {\n devDependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n} {\n return {\n devDependencies: {\n \"@osdk/api\": osdkApiVersion,\n },\n peerDependencies: {\n \"@osdk/api\": osdkApiVersion,\n \"@osdk/client\": osdkClientVersion,\n },\n };\n}\n\nfunction getExpectedDependenciesFull(\n dependencyVersions: DependencyVersions,\n) {\n const {\n typescriptVersion,\n tslibVersion,\n areTheTypesWrongVersion,\n } = dependencyVersions;\n\n const base = getExpectedDependencies(dependencyVersions);\n\n return {\n devDependencies: {\n ...base.devDependencies,\n \"typescript\": typescriptVersion,\n \"tslib\": tslibVersion,\n \"@arethetypeswrong/cli\": areTheTypesWrongVersion,\n },\n peerDependencies: {\n ...base.peerDependencies,\n },\n };\n}\n\nexport function getPackageJsonContents(\n name: string,\n version: string,\n dependencyVersions: DependencyVersions,\n): {\n files: string[];\n devDependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n name: string;\n version: string;\n main: string;\n module: string;\n exports: {\n \".\": {\n import: string;\n require: string;\n };\n };\n scripts: {\n prepack: string;\n check: string;\n };\n} {\n const esmPrefix = \"./dist/module\";\n const commonjsPrefix = \"./dist/commonjs\";\n return {\n name,\n version,\n main: `${commonjsPrefix}/index.js`,\n module: `${esmPrefix}/index.js`,\n exports: {\n \".\": {\n import: `${esmPrefix}/index.js`,\n require: `${commonjsPrefix}/index.js`,\n },\n },\n scripts: {\n prepack:\n `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,\n check: \"npm exec attw $(npm pack)\",\n },\n ...getExpectedDependenciesFull(dependencyVersions),\n files: [\n \"**/*.js\",\n \"**/*.d.ts\",\n \"dist/**/package.json\",\n ],\n };\n}\n\nasync function writeJson(\n minimalFs: MinimalFs,\n filePath: string,\n body: unknown,\n) {\n // consola.info(`Writing ${filePath}`);\n // consola.debug(`Writing ${filePath} with body`, body);\n return void await minimalFs.writeFile(\n filePath,\n JSON.stringify(body, undefined, 2) + \"\\n\",\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AAEjC,SAASC,oCAAoC,QAAQ,gDAAgD;AAGrG,OAAO,eAAeC,wBAAwBA,CAC5CC,WAAmB,EACnBC,cAAsB,EACtBC,UAAyB,EACzBC,UAAkB,EAClBC,QAAgC,EAChCC,SAAoB,EACpBC,kBAAsC,EACtCC,UAAkB,EAClBC,eAAoC,GAAG,IAAIC,GAAG,CAAC,CAAC,EAChDC,kBAAuC,GAAG,IAAID,GAAG,CAAC,CAAC,EACpC;EACf,IAAI,CAACT,WAAW,EAAE,MAAM,IAAIW,KAAK,CAAC,0BAA0B,CAAC;EAC7D,IAAIT,UAAU,KAAK,KAAK,EAAE;IACxB,MAAM,IAAIS,KAAK,CACb,4DACF,CAAC;EACH;EAEA,KAAK,MAAMC,WAAW,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAW;IACzD,MAAMC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,MAAM,EAAE,GAAGc,SAAS,WAAW;IAC/BG,OAAO,EAAE;MACP,GAAG,EAAE;QACHC,MAAM,EAAE,GAAGJ,SAAS,WAAW;QAC/BK,OAAO,EAAE,GAAGJ,cAAc;MAC5B;IACF,CAAC;IACDK,OAAO,EAAE;MACPC,OAAO,EACL,UAAUP,SAAS,4BAA4BC,cAAc,gBAAgB;MAC/EO,KAAK,EAAE;IACT,CAAC;IACD,GAAGf,2BAA2B,CAACjC,kBAAkB,CAAC;IAClDiD,KAAK,EAAE,CACL,SAAS,EACT,WAAW,EACX,sBAAsB;EAE1B,CAAC;AACH;AAEA,eAAerC,SAASA,CACtBb,SAAoB,EACpBmD,QAAgB,EAChBC,IAAa,EACb;EACA;EACA;EACA,OAAO,MAAK,MAAMpD,SAAS,CAACkB,SAAS,CACnCiC,QAAQ,EACRE,IAAI,CAACC,SAAS,CAACF,IAAI,EAAEG,SAAS,EAAE,CAAC,CAAC,GAAG,IACvC,CAAC;AACH","ignoreList":[]}
|
package/build/esm/index.js
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, getExpectedDependencies } from "./generateClientSdkPackage.js";
|
|
17
|
+
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, getExpectedDependencies, getTsCompilerOptions } from "./generateClientSdkPackage.js";
|
|
18
18
|
export { generateClientSdkVersionTwoPointZero } from "./v2.0/generateClientSdkVersionTwoPointZero.js";
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["generateClientSdkPackage","__UNSTABLE_generateClientSdkPackage","getExpectedDependencies","generateClientSdkVersionTwoPointZero"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport {\n generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage,\n getExpectedDependencies,\n} from \"./generateClientSdkPackage.js\";\nexport type { MinimalFs } from \"./MinimalFs.js\";\nexport { generateClientSdkVersionTwoPointZero } from \"./v2.0/generateClientSdkVersionTwoPointZero.js\";\nexport type { WireOntologyDefinition } from \"./WireOntologyDefinition.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,wBAAwB,IAAIC,mCAAmC,EAC/DC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","names":["generateClientSdkPackage","__UNSTABLE_generateClientSdkPackage","getExpectedDependencies","getTsCompilerOptions","generateClientSdkVersionTwoPointZero"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport {\n generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage,\n getExpectedDependencies,\n getTsCompilerOptions,\n} from \"./generateClientSdkPackage.js\";\nexport type { MinimalFs } from \"./MinimalFs.js\";\nexport { generateClientSdkVersionTwoPointZero } from \"./v2.0/generateClientSdkVersionTwoPointZero.js\";\nexport type { WireOntologyDefinition } from \"./WireOntologyDefinition.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,wBAAwB,IAAIC,mCAAmC,EAC/DC,uBAAuB,EACvBC,oBAAoB,QACf,+BAA+B;AAEtC,SAASC,oCAAoC,QAAQ,gDAAgD","ignoreList":[]}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { enhanceOntology } from "../GenerateContext/enhanceOntology.js";
|
|
18
|
-
import { sanitizeMetadata } from "../shared/sanitizeMetadata.js";
|
|
19
18
|
import { verifyOutDir } from "../util/verifyOutDir.js";
|
|
20
19
|
import { generateOntologyMetadataFile } from "./generateMetadata.js";
|
|
21
20
|
import { generatePerActionDataFiles } from "./generatePerActionDataFiles.js";
|
|
@@ -30,19 +29,17 @@ export async function generateClientSdkVersionTwoPointZero(ontology, userAgent,
|
|
|
30
29
|
// with one per package.
|
|
31
30
|
|
|
32
31
|
await verifyOutDir(outDir, fs);
|
|
33
|
-
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
34
32
|
await fs.mkdir(outDir, {
|
|
35
33
|
recursive: true
|
|
36
34
|
});
|
|
37
35
|
const enhancedOntology = enhanceOntology({
|
|
38
|
-
sanitized:
|
|
36
|
+
sanitized: ontology,
|
|
39
37
|
importExt,
|
|
40
38
|
externalObjects,
|
|
41
39
|
externalInterfaces,
|
|
42
40
|
externalSpts
|
|
43
41
|
});
|
|
44
42
|
const ctx = {
|
|
45
|
-
sanitizedOntology,
|
|
46
43
|
ontology: enhancedOntology,
|
|
47
44
|
importExt,
|
|
48
45
|
fs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClientSdkVersionTwoPointZero.js","names":["enhanceOntology","
|
|
1
|
+
{"version":3,"file":"generateClientSdkVersionTwoPointZero.js","names":["enhanceOntology","verifyOutDir","generateOntologyMetadataFile","generatePerActionDataFiles","generatePerInterfaceDataFiles","generatePerObjectDataFiles","generatePerQueryDataFilesV2","generateRootIndexTsFile","generateClientSdkVersionTwoPointZero","ontology","userAgent","fs","outDir","packageType","externalObjects","Map","externalInterfaces","externalSpts","forInternalUse","fixedVersionQueryTypes","importExt","mkdir","recursive","enhancedOntology","sanitized","ctx"],"sources":["generateClientSdkVersionTwoPointZero.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport type { MinimalFs } from \"../MinimalFs.js\";\nimport { verifyOutDir } from \"../util/verifyOutDir.js\";\nimport type { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\nimport { generateOntologyMetadataFile } from \"./generateMetadata.js\";\nimport { generatePerActionDataFiles } from \"./generatePerActionDataFiles.js\";\nimport { generatePerInterfaceDataFiles } from \"./generatePerInterfaceDataFiles.js\";\nimport { generatePerObjectDataFiles } from \"./generatePerObjectDataFiles.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\nimport { generateRootIndexTsFile } from \"./generateRootIndexTsFile.js\";\n\nexport async function generateClientSdkVersionTwoPointZero(\n ontology: WireOntologyDefinition,\n userAgent: string,\n fs: MinimalFs,\n outDir: string,\n packageType: \"module\" | \"commonjs\" = \"commonjs\",\n externalObjects: Map<string, string> = new Map(),\n externalInterfaces: Map<string, string> = new Map(),\n externalSpts: Map<string, string> = new Map(),\n forInternalUse: boolean = false,\n fixedVersionQueryTypes: string[] = [],\n): Promise<void> {\n const importExt = \".js\"; // turns out you can always use the extension\n\n // Structurally, we need to have multiple ontologies read in\n // with one per package.\n\n await verifyOutDir(outDir, fs);\n\n await fs.mkdir(outDir, { recursive: true });\n const enhancedOntology = enhanceOntology({\n sanitized: ontology,\n importExt,\n externalObjects,\n externalInterfaces,\n externalSpts,\n });\n\n const ctx: GenerateContext = {\n ontology: enhancedOntology,\n importExt,\n fs,\n outDir,\n forInternalUse,\n fixedVersionQueryTypes,\n };\n\n await generateRootIndexTsFile(ctx);\n await generateOntologyMetadataFile(ctx, userAgent);\n await generatePerObjectDataFiles(ctx);\n await generatePerInterfaceDataFiles(ctx);\n await generatePerActionDataFiles(ctx);\n await generatePerQueryDataFilesV2(ctx, true);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,uCAAuC;AAGvE,SAASC,YAAY,QAAQ,yBAAyB;AAEtD,SAASC,4BAA4B,QAAQ,uBAAuB;AACpE,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,6BAA6B,QAAQ,oCAAoC;AAClF,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,eAAeC,oCAAoCA,CACxDC,QAAgC,EAChCC,SAAiB,EACjBC,EAAa,EACbC,MAAc,EACdC,WAAkC,GAAG,UAAU,EAC/CC,eAAoC,GAAG,IAAIC,GAAG,CAAC,CAAC,EAChDC,kBAAuC,GAAG,IAAID,GAAG,CAAC,CAAC,EACnDE,YAAiC,GAAG,IAAIF,GAAG,CAAC,CAAC,EAC7CG,cAAuB,GAAG,KAAK,EAC/BC,sBAAgC,GAAG,EAAE,EACtB;EACf,MAAMC,SAAS,GAAG,KAAK,CAAC,CAAC;;EAEzB;EACA;;EAEA,MAAMnB,YAAY,CAACW,MAAM,EAAED,EAAE,CAAC;EAE9B,MAAMA,EAAE,CAACU,KAAK,CAACT,MAAM,EAAE;IAAEU,SAAS,EAAE;EAAK,CAAC,CAAC;EAC3C,MAAMC,gBAAgB,GAAGvB,eAAe,CAAC;IACvCwB,SAAS,EAAEf,QAAQ;IACnBW,SAAS;IACTN,eAAe;IACfE,kBAAkB;IAClBC;EACF,CAAC,CAAC;EAEF,MAAMQ,GAAoB,GAAG;IAC3BhB,QAAQ,EAAEc,gBAAgB;IAC1BH,SAAS;IACTT,EAAE;IACFC,MAAM;IACNM,cAAc;IACdC;EACF,CAAC;EAED,MAAMZ,uBAAuB,CAACkB,GAAG,CAAC;EAClC,MAAMvB,4BAA4B,CAACuB,GAAG,EAAEf,SAAS,CAAC;EAClD,MAAML,0BAA0B,CAACoB,GAAG,CAAC;EACrC,MAAMrB,6BAA6B,CAACqB,GAAG,CAAC;EACxC,MAAMtB,0BAA0B,CAACsB,GAAG,CAAC;EACrC,MAAMnB,2BAA2B,CAACmB,GAAG,EAAE,IAAI,CAAC;AAC9C","ignoreList":[]}
|
|
@@ -19,11 +19,10 @@ import path from "node:path";
|
|
|
19
19
|
import { getObjectImports } from "../shared/getObjectImports.js";
|
|
20
20
|
import { deleteUndefineds } from "../util/deleteUndefineds.js";
|
|
21
21
|
import { stringify } from "../util/stringify.js";
|
|
22
|
-
import { stringUnionFrom } from "../util/stringUnionFrom.js";
|
|
23
22
|
import { formatTs } from "../util/test/formatTs.js";
|
|
24
23
|
import { getDescriptionIfPresent } from "./getDescriptionIfPresent.js";
|
|
25
24
|
export async function generatePerActionDataFiles({
|
|
26
|
-
|
|
25
|
+
ontology,
|
|
27
26
|
fs,
|
|
28
27
|
outDir: rootOutDir,
|
|
29
28
|
importExt = "",
|
|
@@ -36,10 +35,7 @@ export async function generatePerActionDataFiles({
|
|
|
36
35
|
});
|
|
37
36
|
await Promise.all(Object.values(enhancedOntology.actionTypes).map(async action => {
|
|
38
37
|
const currentFilePath = path.join("ontology", "actions", `${action.shortApiName}.ts`);
|
|
39
|
-
const
|
|
40
|
-
const uniqueApiNames = new Set(uniqueApiNamesArray);
|
|
41
|
-
stringUnionFrom([...uniqueApiNames]);
|
|
42
|
-
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionMetadata(action.raw));
|
|
38
|
+
const fullActionDef = deleteUndefineds(wireActionTypeV2ToSdkActionMetadata(action.raw, action.unsanitizedApiName));
|
|
43
39
|
function createParamsDef() {
|
|
44
40
|
const entries = Object.entries(fullActionDef.parameters ?? {});
|
|
45
41
|
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePerActionDataFiles.js","names":["wireActionTypeV2ToSdkActionMetadata","path","getObjectImports","deleteUndefineds","stringify","stringUnionFrom","formatTs","getDescriptionIfPresent","generatePerActionDataFiles","sanitizedOntology","ontology","fs","outDir","rootOutDir","importExt","enhancedOntology","forInternalUse","join","mkdir","recursive","Promise","all","Object","values","actionTypes","map","action","currentFilePath","shortApiName","uniqueApiNamesArray","extractReferencedObjectsFromAction","raw","uniqueApiNames","Set","fullActionDef","createParamsDef","entries","parameters","sort","a","b","localeCompare","length","key","value","description","d","undefined","type","JSON","obj","requireObjectType","object","getImportedDefinitionIdentifier","objectSet","requireInterfaceType","interface","struct","getActionParamType","input","referencedObjectDefs","p","dataType","objectApiName","add","objectTypeApiName","interfaceTypeApiName","subType","imports","writeFile","jsDocBlock","push","hasNullableParams","some","param","nullable","*","ogValue","_","ogKey","multiplicity","paramsIdentifier","definitionParamsIdentifier","displayName","modifiedEntities","rid","status","indexFileRelPath","exportConstLine","getImportPathRelTo","keys","actionType","referencedObjectsInParameters","flatMap","objectTypeReference","extractReferencedObjectsFromActionParameter","referenceObjectsInEdits","operations","actionParameter"],"sources":["generatePerActionDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionMetadata } from \"@osdk/api\";\nimport type {\n ActionParameterType,\n ActionTypeV2,\n} from \"@osdk/foundry.ontologies\";\nimport { wireActionTypeV2ToSdkActionMetadata } from \"@osdk/generator-converters\";\nimport path from \"node:path\";\nimport type { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { stringUnionFrom } from \"../util/stringUnionFrom.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { getDescriptionIfPresent } from \"./getDescriptionIfPresent.js\";\n\nexport async function generatePerActionDataFiles(\n {\n sanitizedOntology: ontology,\n fs,\n outDir: rootOutDir,\n importExt = \"\",\n ontology: enhancedOntology,\n forInternalUse = false,\n }: Pick<\n GenerateContext,\n | \"sanitizedOntology\"\n | \"fs\"\n | \"outDir\"\n | \"importExt\"\n | \"ontology\"\n | \"forInternalUse\"\n >,\n): Promise<void> {\n const outDir = path.join(rootOutDir, \"ontology\", \"actions\");\n\n await fs.mkdir(outDir, { recursive: true });\n await Promise.all(\n Object.values(enhancedOntology.actionTypes).map(async (action) => {\n const currentFilePath = path.join(\n \"ontology\",\n \"actions\",\n `${action.shortApiName}.ts`,\n );\n\n const uniqueApiNamesArray = extractReferencedObjectsFromAction(\n action.raw,\n );\n const uniqueApiNames = new Set(uniqueApiNamesArray);\n\n const uniqueApiNamesString = stringUnionFrom([...uniqueApiNames]);\n\n const fullActionDef = deleteUndefineds(\n wireActionTypeV2ToSdkActionMetadata(action.raw),\n );\n\n function createParamsDef() {\n const entries = Object.entries(fullActionDef.parameters ?? {});\n entries.sort((a, b) => a[0].localeCompare(b[0]));\n\n if (entries.length === 0) {\n return `// Represents the definition of the parameters for the action\n export type ParamsDefinition = Record<string, never>;`;\n }\n\n return `// Represents the definition of the parameters for the action\n export type ParamsDefinition = {\n ${\n entries.map(([key, value]) => {\n return `\"${key}\": {\n ${\n stringify(value, {\n description: (value, d) => value ? d(value) : undefined, // trick to remove undefineds\n type: (type) => {\n if (typeof type === \"string\") {\n return JSON.stringify(type);\n } else if (type.type === \"object\") {\n const obj = enhancedOntology.requireObjectType(type.object);\n return `ActionMetadata.DataType.Object<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"objectSet\") {\n const obj = enhancedOntology.requireObjectType(\n type.objectSet,\n );\n return `ActionMetadata.DataType.ObjectSet<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"interface\") {\n const obj = enhancedOntology.requireInterfaceType(\n type.interface,\n );\n return `ActionMetadata.DataType.Interface<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"struct\") {\n return `ActionMetadata.DataType.Struct<${\n JSON.stringify(type.struct)\n }>`;\n }\n return undefined;\n },\n })\n }\n }`;\n })\n .join(\";\\n\")\n }\n }`;\n }\n\n function getActionParamType(\n input: ActionMetadata.Parameter[\"type\"],\n ) {\n if (typeof input === \"string\") {\n return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;\n } else if (input.type === \"object\") {\n return `ActionParam.ObjectType<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"objectSet\") {\n return `ActionParam.ObjectSetType<${\n enhancedOntology.requireObjectType(input.objectSet)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"interface\") {\n return `ActionParam.InterfaceType<${\n enhancedOntology.requireInterfaceType(input.interface)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"struct\") {\n return `ActionParam.StructType<${JSON.stringify(input.struct)}>`;\n }\n }\n\n function createV2Types() {\n const oldParamsIdentifier = `${action.shortApiName}$Params`;\n const jsDocBlock = [\"/**\"];\n if (action.description != null) {\n jsDocBlock.push(`* ${action.description}`);\n\n // Add note about null values to the action description if there are nullable parameters\n const hasNullableParams = Object.values(\n fullActionDef.parameters || {},\n ).some(param => param.nullable === true);\n if (hasNullableParams) {\n jsDocBlock.push(`* `);\n jsDocBlock.push(\n `* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined`,\n );\n jsDocBlock.push(\n `* can change the behavior of the applied action. If prefills are configured, null prevents them`,\n );\n jsDocBlock.push(\n `* from being applied. If a parameter modifies an object's property, null will clear the data from`,\n );\n jsDocBlock.push(\n `* the object, whereas undefined would not modify that property._`,\n );\n }\n }\n // the params must be a `type` to align properly with the `ActionDefinition` interface\n // this way we can generate a strict type for the function itself and reference it from the Action Definition\n return `\n \n export namespace ${action.shortApiName}{\n ${createParamsDef()}\n\n ${getDescriptionIfPresent(action.description)}\n export interface Params {\n ${\n stringify(fullActionDef.parameters, {\n \"*\": (ogValue, _, ogKey) => {\n const key = `${getDescriptionIfPresent(ogValue.description)}\n readonly \"${ogKey}\"${ogValue.nullable ? \"?\" : \"\"}`;\n\n const value = (ogValue.multiplicity\n ? `ReadonlyArray<${getActionParamType(ogValue.type)}>`\n : `${getActionParamType(ogValue.type)}`)\n + (ogValue.nullable ? \" | null\" : \"\");\n jsDocBlock.push(\n `* @param {${getActionParamType(ogValue.type)}} ${\n ogValue.nullable ? `[${ogKey}]` : ogKey\n } ${ogValue.description ?? \"\"}`,\n );\n return [key, value];\n },\n })\n }\n }\n\n // Represents a fqn of the action\n export interface Signatures {\n ${getDescriptionIfPresent(action.description)}\n applyAction<OP extends ApplyActionOptions>(args: ${action.paramsIdentifier}, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;\n \n batchApplyAction<OP extends ApplyBatchActionOptions>(args: ReadonlyArray<${action.paramsIdentifier}>, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;\n }\n \n }\n\n \n ${jsDocBlock.join(\"\\n\")}\n */\n export interface ${action.shortApiName} extends ActionDefinition<${action.shortApiName}.Signatures> {\n __DefinitionMetadata?: {\n ${\n stringify(fullActionDef, {\n \"parameters\": () => action.definitionParamsIdentifier,\n })\n }\n \n signatures: ${action.shortApiName}.Signatures;\n },\n ${\n stringify(fullActionDef, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"modifiedEntities\": () => undefined,\n \"parameters\": () => undefined,\n \"rid\": () => undefined,\n \"status\": () => undefined,\n })\n }\n osdkMetadata: typeof $osdkMetadata;\n }\n `;\n }\n\n function createV2Object() {\n return ` export const ${action.shortApiName}: ${action.shortApiName} = \n {\n ${\n stringify(fullActionDef, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"modifiedEntities\": () => undefined,\n \"parameters\": () => undefined,\n \"rid\": () => undefined,\n \"status\": () => undefined,\n })\n },\n osdkMetadata: $osdkMetadata\n }\n `;\n }\n\n const referencedObjectDefs = new Set<EnhancedObjectType | ForeignType>();\n for (const p of Object.values(action.parameters)) {\n if (p.dataType.type === \"object\" || p.dataType.type === \"objectSet\") {\n if (p.dataType.objectApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(p.dataType.objectApiName),\n );\n }\n if (p.dataType.objectTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(p.dataType.objectTypeApiName),\n );\n }\n }\n if (p.dataType.type === \"interfaceObject\") {\n if (p.dataType.interfaceTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireInterfaceType(\n p.dataType.interfaceTypeApiName,\n ),\n );\n }\n }\n if (p.dataType.type === \"array\") {\n if (\n p.dataType.subType.type === \"object\"\n || p.dataType.subType.type === \"objectSet\"\n ) {\n if (p.dataType.subType.objectApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(\n p.dataType.subType.objectApiName,\n ),\n );\n }\n if (p.dataType.subType.objectTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(\n p.dataType.subType.objectTypeApiName,\n ),\n );\n }\n }\n if (\n p.dataType.subType.type === \"interfaceObject\"\n ) {\n if (p.dataType.subType.interfaceTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireInterfaceType(\n p.dataType.subType.interfaceTypeApiName,\n ),\n );\n }\n }\n }\n }\n\n const imports = getObjectImports(\n referencedObjectDefs,\n undefined,\n currentFilePath,\n true,\n );\n\n await fs.writeFile(\n path.join(rootOutDir, currentFilePath),\n await formatTs(`\n import type {\n ActionDefinition,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n import { $osdkMetadata} from \"../../OntologyMetadata${importExt}\";\n ${imports}\n\n \n ${createV2Types()}\n\n ${createV2Object()}\n `),\n );\n }),\n );\n\n const indexFileRelPath = path.join(\"ontology\", \"actions.ts\");\n\n await fs.writeFile(\n path.join(rootOutDir, indexFileRelPath),\n await formatTs(`\n ${\n Object.values(enhancedOntology.actionTypes).map(action => {\n const exportConstLine = `export {${action.shortApiName} } from \"${\n action.getImportPathRelTo(indexFileRelPath)\n }\";`;\n\n return exportConstLine;\n })\n .join(\"\\n\")\n }\n ${Object.keys(ontology.actionTypes).length === 0 ? \"export {};\" : \"\"}\n `),\n );\n}\n\nfunction extractReferencedObjectsFromAction(\n actionType: ActionTypeV2,\n): string[] {\n const referencedObjectsInParameters = Object.values(actionType.parameters)\n .flatMap(({ dataType }) => {\n const objectTypeReference = extractReferencedObjectsFromActionParameter(\n dataType,\n );\n return objectTypeReference ? [objectTypeReference] : [];\n });\n\n const referenceObjectsInEdits = actionType.operations.flatMap(value => {\n switch (value.type) {\n case \"createObject\":\n return [value.objectTypeApiName];\n case \"modifyObject\":\n return [value.objectTypeApiName];\n case \"deleteObject\":\n case \"createLink\":\n case \"deleteLink\":\n default:\n return [];\n }\n });\n\n return [...referenceObjectsInEdits, ...referencedObjectsInParameters];\n}\n\nfunction extractReferencedObjectsFromActionParameter(\n actionParameter: ActionParameterType,\n): string | undefined {\n switch (actionParameter.type) {\n case \"objectSet\":\n case \"object\":\n return actionParameter.objectTypeApiName;\n case \"array\":\n return extractReferencedObjectsFromActionParameter(\n actionParameter.subType,\n );\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"date\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"timestamp\":\n return undefined;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,mCAAmC,QAAQ,4BAA4B;AAChF,OAAOC,IAAI,MAAM,WAAW;AAI5B,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,eAAeC,0BAA0BA,CAC9C;EACEC,iBAAiB,EAAEC,QAAQ;EAC3BC,EAAE;EACFC,MAAM,EAAEC,UAAU;EAClBC,SAAS,GAAG,EAAE;EACdJ,QAAQ,EAAEK,gBAAgB;EAC1BC,cAAc,GAAG;AASnB,CAAC,EACc;EACf,MAAMJ,MAAM,GAAGX,IAAI,CAACgB,IAAI,CAACJ,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC;EAE3D,MAAMF,EAAE,CAACO,KAAK,CAACN,MAAM,EAAE;IAAEO,SAAS,EAAE;EAAK,CAAC,CAAC;EAC3C,M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,UAAU,CAACtD,UAAU,CAAC,CACvEwD,OAAO,CAAC,CAAC;IAAE/B;EAAS,CAAC,KAAK;IACzB,MAAMgC,mBAAmB,GAAGC,2CAA2C,CACrEjC,QACF,CAAC;IACD,OAAOgC,mBAAmB,GAAG,CAACA,mBAAmB,CAAC,GAAG,EAAE;EACzD,CAAC,CAAC;EAEJ,MAAME,uBAAuB,GAAGL,UAAU,CAACM,UAAU,CAACJ,OAAO,CAACjD,KAAK,IAAI;IACrE,QAAQA,KAAK,CAACI,IAAI;MAChB,KAAK,cAAc;QACjB,OAAO,CAACJ,KAAK,CAACqB,iBAAiB,CAAC;MAClC,KAAK,cAAc;QACjB,OAAO,CAACrB,KAAK,CAACqB,iBAAiB,CAAC;MAClC,KAAK,cAAc;MACnB,KAAK,YAAY;MACjB,KAAK,YAAY;MACjB;QACE,OAAO,EAAE;IACb;EACF,CAAC,CAAC;EAEF,OAAO,CAAC,GAAG+B,uBAAuB,EAAE,GAAGJ,6BAA6B,CAAC;AACvE;AAEA,SAASG,2CAA2CA,CAClDG,eAAoC,EAChB;EACpB,QAAQA,eAAe,CAAClD,IAAI;IAC1B,KAAK,WAAW;IAChB,KAAK,QAAQ;MACX,OAAOkD,eAAe,CAACjC,iBAAiB;IAC1C,KAAK,OAAO;MACV,OAAO8B,2CAA2C,CAChDG,eAAe,CAAC/B,OAClB,CAAC;IACH,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,YAAY;IACjB,KAAK,MAAM;IACX,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,WAAW;MACd,OAAOpB,SAAS;EACpB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generatePerActionDataFiles.js","names":["wireActionTypeV2ToSdkActionMetadata","path","getObjectImports","deleteUndefineds","stringify","formatTs","getDescriptionIfPresent","generatePerActionDataFiles","ontology","fs","outDir","rootOutDir","importExt","enhancedOntology","forInternalUse","join","mkdir","recursive","Promise","all","Object","values","actionTypes","map","action","currentFilePath","shortApiName","fullActionDef","raw","unsanitizedApiName","createParamsDef","entries","parameters","sort","a","b","localeCompare","length","key","value","description","d","undefined","type","JSON","obj","requireObjectType","object","getImportedDefinitionIdentifier","objectSet","requireInterfaceType","interface","struct","getActionParamType","input","referencedObjectDefs","Set","p","dataType","objectApiName","add","objectTypeApiName","interfaceTypeApiName","subType","imports","writeFile","jsDocBlock","push","hasNullableParams","some","param","nullable","*","ogValue","_","ogKey","multiplicity","paramsIdentifier","definitionParamsIdentifier","displayName","modifiedEntities","rid","status","indexFileRelPath","exportConstLine","getImportPathRelTo","keys","extractReferencedObjectsFromAction","actionType","referencedObjectsInParameters","flatMap","objectTypeReference","extractReferencedObjectsFromActionParameter","referenceObjectsInEdits","operations","actionParameter"],"sources":["generatePerActionDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionMetadata } from \"@osdk/api\";\nimport type {\n ActionParameterType,\n ActionTypeV2,\n} from \"@osdk/foundry.ontologies\";\nimport { wireActionTypeV2ToSdkActionMetadata } from \"@osdk/generator-converters\";\nimport path from \"node:path\";\nimport type { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { getDescriptionIfPresent } from \"./getDescriptionIfPresent.js\";\n\nexport async function generatePerActionDataFiles(\n {\n ontology,\n fs,\n outDir: rootOutDir,\n importExt = \"\",\n ontology: enhancedOntology,\n forInternalUse = false,\n }: Pick<\n GenerateContext,\n | \"fs\"\n | \"outDir\"\n | \"importExt\"\n | \"ontology\"\n | \"forInternalUse\"\n >,\n): Promise<void> {\n const outDir = path.join(rootOutDir, \"ontology\", \"actions\");\n\n await fs.mkdir(outDir, { recursive: true });\n await Promise.all(\n Object.values(enhancedOntology.actionTypes).map(async (action) => {\n const currentFilePath = path.join(\n \"ontology\",\n \"actions\",\n `${action.shortApiName}.ts`,\n );\n\n const fullActionDef = deleteUndefineds(\n wireActionTypeV2ToSdkActionMetadata(\n action.raw,\n action.unsanitizedApiName,\n ),\n );\n\n function createParamsDef() {\n const entries = Object.entries(fullActionDef.parameters ?? {});\n entries.sort((a, b) => a[0].localeCompare(b[0]));\n\n if (entries.length === 0) {\n return `// Represents the definition of the parameters for the action\n export type ParamsDefinition = Record<string, never>;`;\n }\n\n return `// Represents the definition of the parameters for the action\n export type ParamsDefinition = {\n ${\n entries.map(([key, value]) => {\n return `\"${key}\": {\n ${\n stringify(value, {\n description: (value, d) => value ? d(value) : undefined, // trick to remove undefineds\n type: (type) => {\n if (typeof type === \"string\") {\n return JSON.stringify(type);\n } else if (type.type === \"object\") {\n const obj = enhancedOntology.requireObjectType(type.object);\n return `ActionMetadata.DataType.Object<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"objectSet\") {\n const obj = enhancedOntology.requireObjectType(\n type.objectSet,\n );\n return `ActionMetadata.DataType.ObjectSet<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"interface\") {\n const obj = enhancedOntology.requireInterfaceType(\n type.interface,\n );\n return `ActionMetadata.DataType.Interface<${\n obj.getImportedDefinitionIdentifier(true)\n }>`;\n } else if (type.type === \"struct\") {\n return `ActionMetadata.DataType.Struct<${\n JSON.stringify(type.struct)\n }>`;\n }\n return undefined;\n },\n })\n }\n }`;\n })\n .join(\";\\n\")\n }\n }`;\n }\n\n function getActionParamType(\n input: ActionMetadata.Parameter[\"type\"],\n ) {\n if (typeof input === \"string\") {\n return `ActionParam.PrimitiveType<${JSON.stringify(input)}>`;\n } else if (input.type === \"object\") {\n return `ActionParam.ObjectType<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"objectSet\") {\n return `ActionParam.ObjectSetType<${\n enhancedOntology.requireObjectType(input.objectSet)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"interface\") {\n return `ActionParam.InterfaceType<${\n enhancedOntology.requireInterfaceType(input.interface)\n .getImportedDefinitionIdentifier(true)\n }>`;\n } else if (input.type === \"struct\") {\n return `ActionParam.StructType<${JSON.stringify(input.struct)}>`;\n }\n }\n\n function createV2Types() {\n const oldParamsIdentifier = `${action.shortApiName}$Params`;\n const jsDocBlock = [\"/**\"];\n if (action.description != null) {\n jsDocBlock.push(`* ${action.description}`);\n\n // Add note about null values to the action description if there are nullable parameters\n const hasNullableParams = Object.values(\n fullActionDef.parameters || {},\n ).some(param => param.nullable === true);\n if (hasNullableParams) {\n jsDocBlock.push(`* `);\n jsDocBlock.push(\n `* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined`,\n );\n jsDocBlock.push(\n `* can change the behavior of the applied action. If prefills are configured, null prevents them`,\n );\n jsDocBlock.push(\n `* from being applied. If a parameter modifies an object's property, null will clear the data from`,\n );\n jsDocBlock.push(\n `* the object, whereas undefined would not modify that property._`,\n );\n }\n }\n // the params must be a `type` to align properly with the `ActionDefinition` interface\n // this way we can generate a strict type for the function itself and reference it from the Action Definition\n return `\n \n export namespace ${action.shortApiName}{\n ${createParamsDef()}\n\n ${getDescriptionIfPresent(action.description)}\n export interface Params {\n ${\n stringify(fullActionDef.parameters, {\n \"*\": (ogValue, _, ogKey) => {\n const key = `${getDescriptionIfPresent(ogValue.description)}\n readonly \"${ogKey}\"${ogValue.nullable ? \"?\" : \"\"}`;\n\n const value = (ogValue.multiplicity\n ? `ReadonlyArray<${getActionParamType(ogValue.type)}>`\n : `${getActionParamType(ogValue.type)}`)\n + (ogValue.nullable ? \" | null\" : \"\");\n jsDocBlock.push(\n `* @param {${getActionParamType(ogValue.type)}} ${\n ogValue.nullable ? `[${ogKey}]` : ogKey\n } ${ogValue.description ?? \"\"}`,\n );\n return [key, value];\n },\n })\n }\n }\n\n // Represents a fqn of the action\n export interface Signatures {\n ${getDescriptionIfPresent(action.description)}\n applyAction<OP extends ApplyActionOptions>(args: ${action.paramsIdentifier}, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;\n \n batchApplyAction<OP extends ApplyBatchActionOptions>(args: ReadonlyArray<${action.paramsIdentifier}>, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;\n }\n \n }\n\n \n ${jsDocBlock.join(\"\\n\")}\n */\n export interface ${action.shortApiName} extends ActionDefinition<${action.shortApiName}.Signatures> {\n __DefinitionMetadata?: {\n ${\n stringify(fullActionDef, {\n \"parameters\": () => action.definitionParamsIdentifier,\n })\n }\n \n signatures: ${action.shortApiName}.Signatures;\n },\n ${\n stringify(fullActionDef, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"modifiedEntities\": () => undefined,\n \"parameters\": () => undefined,\n \"rid\": () => undefined,\n \"status\": () => undefined,\n })\n }\n osdkMetadata: typeof $osdkMetadata;\n }\n `;\n }\n\n function createV2Object() {\n return ` export const ${action.shortApiName}: ${action.shortApiName} = \n {\n ${\n stringify(fullActionDef, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"modifiedEntities\": () => undefined,\n \"parameters\": () => undefined,\n \"rid\": () => undefined,\n \"status\": () => undefined,\n })\n },\n osdkMetadata: $osdkMetadata\n }\n `;\n }\n\n const referencedObjectDefs = new Set<EnhancedObjectType | ForeignType>();\n for (const p of Object.values(action.parameters)) {\n if (p.dataType.type === \"object\" || p.dataType.type === \"objectSet\") {\n if (p.dataType.objectApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(p.dataType.objectApiName),\n );\n }\n if (p.dataType.objectTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(p.dataType.objectTypeApiName),\n );\n }\n }\n if (p.dataType.type === \"interfaceObject\") {\n if (p.dataType.interfaceTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireInterfaceType(\n p.dataType.interfaceTypeApiName,\n ),\n );\n }\n }\n if (p.dataType.type === \"array\") {\n if (\n p.dataType.subType.type === \"object\"\n || p.dataType.subType.type === \"objectSet\"\n ) {\n if (p.dataType.subType.objectApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(\n p.dataType.subType.objectApiName,\n ),\n );\n }\n if (p.dataType.subType.objectTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireObjectType(\n p.dataType.subType.objectTypeApiName,\n ),\n );\n }\n }\n if (\n p.dataType.subType.type === \"interfaceObject\"\n ) {\n if (p.dataType.subType.interfaceTypeApiName) {\n referencedObjectDefs.add(\n enhancedOntology.requireInterfaceType(\n p.dataType.subType.interfaceTypeApiName,\n ),\n );\n }\n }\n }\n }\n\n const imports = getObjectImports(\n referencedObjectDefs,\n undefined,\n currentFilePath,\n true,\n );\n\n await fs.writeFile(\n path.join(rootOutDir, currentFilePath),\n await formatTs(`\n import type {\n ActionDefinition,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n import { $osdkMetadata} from \"../../OntologyMetadata${importExt}\";\n ${imports}\n\n \n ${createV2Types()}\n\n ${createV2Object()}\n `),\n );\n }),\n );\n\n const indexFileRelPath = path.join(\"ontology\", \"actions.ts\");\n\n await fs.writeFile(\n path.join(rootOutDir, indexFileRelPath),\n await formatTs(`\n ${\n Object.values(enhancedOntology.actionTypes).map(action => {\n const exportConstLine = `export {${action.shortApiName} } from \"${\n action.getImportPathRelTo(indexFileRelPath)\n }\";`;\n\n return exportConstLine;\n })\n .join(\"\\n\")\n }\n ${Object.keys(ontology.actionTypes).length === 0 ? \"export {};\" : \"\"}\n `),\n );\n}\n\nfunction extractReferencedObjectsFromAction(\n actionType: ActionTypeV2,\n): string[] {\n const referencedObjectsInParameters = Object.values(actionType.parameters)\n .flatMap(({ dataType }) => {\n const objectTypeReference = extractReferencedObjectsFromActionParameter(\n dataType,\n );\n return objectTypeReference ? [objectTypeReference] : [];\n });\n\n const referenceObjectsInEdits = actionType.operations.flatMap(value => {\n switch (value.type) {\n case \"createObject\":\n return [value.objectTypeApiName];\n case \"modifyObject\":\n return [value.objectTypeApiName];\n case \"deleteObject\":\n case \"createLink\":\n case \"deleteLink\":\n default:\n return [];\n }\n });\n\n return [...referenceObjectsInEdits, ...referencedObjectsInParameters];\n}\n\nfunction extractReferencedObjectsFromActionParameter(\n actionParameter: ActionParameterType,\n): string | undefined {\n switch (actionParameter.type) {\n case \"objectSet\":\n case \"object\":\n return actionParameter.objectTypeApiName;\n case \"array\":\n return extractReferencedObjectsFromActionParameter(\n actionParameter.subType,\n );\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"date\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"timestamp\":\n return undefined;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,mCAAmC,QAAQ,4BAA4B;AAChF,OAAOC,IAAI,MAAM,WAAW;AAI5B,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,eAAeC,0BAA0BA,CAC9C;EACEC,QAAQ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,GAAG,EAAE;AACxE,OAAO,CACL,CAAC;AACH;AAEA,SAASkD,kCAAkCA,CACzCC,UAAwB,EACd;EACV,MAAMC,6BAA6B,GAAGrE,MAAM,CAACC,MAAM,CAACmE,UAAU,CAACxD,UAAU,CAAC,CACvE0D,OAAO,CAAC,CAAC;IAAEhC;EAAS,CAAC,KAAK;IACzB,MAAMiC,mBAAmB,GAAGC,2CAA2C,CACrElC,QACF,CAAC;IACD,OAAOiC,mBAAmB,GAAG,CAACA,mBAAmB,CAAC,GAAG,EAAE;EACzD,CAAC,CAAC;EAEJ,MAAME,uBAAuB,GAAGL,UAAU,CAACM,UAAU,CAACJ,OAAO,CAACnD,KAAK,IAAI;IACrE,QAAQA,KAAK,CAACI,IAAI;MAChB,KAAK,cAAc;QACjB,OAAO,CAACJ,KAAK,CAACsB,iBAAiB,CAAC;MAClC,KAAK,cAAc;QACjB,OAAO,CAACtB,KAAK,CAACsB,iBAAiB,CAAC;MAClC,KAAK,cAAc;MACnB,KAAK,YAAY;MACjB,KAAK,YAAY;MACjB;QACE,OAAO,EAAE;IACb;EACF,CAAC,CAAC;EAEF,OAAO,CAAC,GAAGgC,uBAAuB,EAAE,GAAGJ,6BAA6B,CAAC;AACvE;AAEA,SAASG,2CAA2CA,CAClDG,eAAoC,EAChB;EACpB,QAAQA,eAAe,CAACpD,IAAI;IAC1B,KAAK,WAAW;IAChB,KAAK,QAAQ;MACX,OAAOoD,eAAe,CAAClC,iBAAiB;IAC1C,KAAK,OAAO;MACV,OAAO+B,2CAA2C,CAChDG,eAAe,CAAChC,OAClB,CAAC;IACH,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,YAAY;IACjB,KAAK,MAAM;IACX,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,WAAW;MACd,OAAOrB,SAAS;EACpB;AACF","ignoreList":[]}
|
|
@@ -2,9 +2,11 @@ import type { ActionTypeV2, LogicRule } from "@osdk/foundry.ontologies";
|
|
|
2
2
|
import type { EnhanceCommon } from "./EnhanceCommon.js";
|
|
3
3
|
import { EnhancedBase } from "./EnhancedBase.js";
|
|
4
4
|
export declare class EnhancedAction extends EnhancedBase<ActionTypeV2> {
|
|
5
|
+
#private;
|
|
5
6
|
raw: ActionTypeV2;
|
|
6
7
|
constructor(common: EnhanceCommon, raw: ActionTypeV2);
|
|
7
8
|
get description(): string | undefined;
|
|
9
|
+
get unsanitizedApiName(): string | undefined;
|
|
8
10
|
get parameters(): ActionTypeV2["parameters"];
|
|
9
11
|
get operations(): LogicRule[];
|
|
10
12
|
get paramsIdentifier(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,cAAc,iBAAiB,0BAA2B;AACxE,cAAc,qBAAqB,oBAAqB;AACxD,SAAS,oBAAoB,mBAAoB;AAEjD,OAAO,cAAM,uBAAuB,aAAa,cAAc
|
|
1
|
+
{"mappings":"AAgBA,cAAc,cAAc,iBAAiB,0BAA2B;AACxE,cAAc,qBAAqB,oBAAqB;AACxD,SAAS,oBAAoB,mBAAoB;AAEjD,OAAO,cAAM,uBAAuB,aAAa,cAAc;;CAE1B,KAAY;CAA/C,YAAYA,QAAQ,eAAsBC,KAAK;CAO/C,IAAI;CAIJ,IAAI;CAIJ,IAAI,cAAc,aAAa;CAI/B,IAAI,cAAc;CAIlB,IAAI;CAIJ,IAAI;CAIJ,IAAI;AAGL","names":["common: EnhanceCommon","raw: ActionTypeV2"],"sources":["../../../src/GenerateContext/EnhancedAction.ts"],"version":3,"file":"EnhancedAction.d.ts"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { MinimalFs } from "../MinimalFs.js";
|
|
2
|
-
import type { WireOntologyDefinition } from "../WireOntologyDefinition.js";
|
|
3
2
|
import type { EnhancedOntologyDefinition } from "./EnhancedOntologyDefinition.js";
|
|
4
3
|
export interface GenerateContext {
|
|
5
|
-
sanitizedOntology: WireOntologyDefinition;
|
|
6
4
|
ontology: EnhancedOntologyDefinition;
|
|
7
5
|
importExt?: string;
|
|
8
6
|
fs: MinimalFs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,iBAAiB,iBAAkB;AACjD,cAAc,
|
|
1
|
+
{"mappings":"AAgBA,cAAc,iBAAiB,iBAAkB;AACjD,cAAc,kCAAkC,iCAAkC;AAElF,iBAAiB,gBAAgB;CAC/B,UAAU;CAEV;CACA,IAAI;CAEJ;CACA;CACA;CACA,yBAAyB;CACzB;AACD","names":[],"sources":["../../../src/GenerateContext/GenerateContext.ts"],"version":3,"file":"GenerateContext.d.ts"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { MinimalFs } from "./MinimalFs.js";
|
|
2
2
|
import type { WireOntologyDefinition } from "./WireOntologyDefinition.js";
|
|
3
3
|
export declare function generateClientSdkPackage(packageName: string, packageVersion: string, sdkVersion: "1.1" | "2.0", baseOutDir: string, ontology: WireOntologyDefinition, minimalFs: MinimalFs, dependencyVersions: DependencyVersions, cliVersion: string, externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>): Promise<void>;
|
|
4
|
+
export declare function getTsCompilerOptions(packageType: "commonjs" | "module"): {
|
|
5
|
+
importHelpers: boolean
|
|
6
|
+
declaration: boolean
|
|
7
|
+
isolatedModules: boolean
|
|
8
|
+
esModuleInterop: boolean
|
|
9
|
+
forceConsistentCasingInFileNames: boolean
|
|
10
|
+
strict: boolean
|
|
11
|
+
skipLibCheck: boolean
|
|
12
|
+
module: string
|
|
13
|
+
target: string
|
|
14
|
+
};
|
|
4
15
|
export interface DependencyVersions {
|
|
5
16
|
typescriptVersion: string;
|
|
6
17
|
tslibVersion: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAkBA,cAAc,iBAAiB,gBAAiB;AAEhD,cAAc,8BAA8B,6BAA8B;AAE1E,OAAO,iBAAe,yBACpBA,qBACAC,wBACAC,YAAY,QAAQ,OACpBC,oBACAC,UAAU,wBACVC,WAAW,WACXC,oBAAoB,oBACpBC,oBACAC,kBAAiB,qBACjBC,qBAAoB,sBACnB;
|
|
1
|
+
{"mappings":"AAkBA,cAAc,iBAAiB,gBAAiB;AAEhD,cAAc,8BAA8B,6BAA8B;AAE1E,OAAO,iBAAe,yBACpBA,qBACAC,wBACAC,YAAY,QAAQ,OACpBC,oBACAC,UAAU,wBACVC,WAAW,WACXC,oBAAoB,oBACpBC,oBACAC,kBAAiB,qBACjBC,qBAAoB,sBACnB;AA6DH,OAAO,iBAAS,qBAAqBC,aAAa,aAAa,WAAW;CACxE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AA6BD,iBAAiB,mBAAmB;CAClC;CACA;CACA;CACA;CACA;AACD;AAED,OAAO,iBAAS,wBACd,EACE,gBACA,mBACmB,EAAlB,qBACF;CACD,iBAAiB;CACjB,kBAAkB;AACnB;AAoCD,OAAO,iBAAS,uBACdC,cACAC,iBACAN,oBAAoB,qBACnB;CACD;CACA,iBAAiB;CACjB,kBAAkB;CAClB;CACA;CACA;CACA;CACA,SAAS;EACP,KAAK;GACH;GACA;EACD;CACF;CACD,SAAS;EACP;EACA;CACD;AACF","names":["packageName: string","packageVersion: string","sdkVersion: \"1.1\" | \"2.0\"","baseOutDir: string","ontology: WireOntologyDefinition","minimalFs: MinimalFs","dependencyVersions: DependencyVersions","cliVersion: string","externalObjects: Map<string, string>","externalInterfaces: Map<string, string>","packageType: \"commonjs\" | \"module\"","name: string","version: string"],"sources":["../../src/generateClientSdkPackage.ts"],"version":3,"file":"generateClientSdkPackage.d.ts"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, getExpectedDependencies } from "./generateClientSdkPackage.js";
|
|
1
|
+
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, getExpectedDependencies, getTsCompilerOptions } from "./generateClientSdkPackage.js";
|
|
2
2
|
export type { MinimalFs } from "./MinimalFs.js";
|
|
3
3
|
export { generateClientSdkVersionTwoPointZero } from "./v2.0/generateClientSdkVersionTwoPointZero.js";
|
|
4
4
|
export type { WireOntologyDefinition } from "./WireOntologyDefinition.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,SACE,4BAA4B,qCAC5B
|
|
1
|
+
{"mappings":"AAgBA,SACE,4BAA4B,qCAC5B,yBACA,4BACK;AACP,cAAc,iBAAiB;AAC/B,SAAS,4CAA4C;AACrD,cAAc,8BAA8B","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAkBA,cAAc,iBAAiB,iBAAkB;
|
|
1
|
+
{"mappings":"AAkBA,cAAc,iBAAiB,iBAAkB;AAEjD,cAAc,8BAA8B,8BAA+B;AAQ3E,OAAO,iBAAe,qCACpBA,UAAU,wBACVC,mBACAC,IAAI,WACJC,gBACAC,cAAa,WAAW,YACxBC,kBAAiB,qBACjBC,qBAAoB,qBACpBC,eAAc,qBACdC,0BACAC,oCACC","names":["ontology: WireOntologyDefinition","userAgent: string","fs: MinimalFs","outDir: string","packageType: \"module\" | \"commonjs\"","externalObjects: Map<string, string>","externalInterfaces: Map<string, string>","externalSpts: Map<string, string>","forInternalUse: boolean","fixedVersionQueryTypes: string[]"],"sources":["../../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"version":3,"file":"generateClientSdkVersionTwoPointZero.d.ts"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { GenerateContext } from "../GenerateContext/GenerateContext.js";
|
|
2
|
-
export declare function generatePerActionDataFiles({
|
|
2
|
+
export declare function generatePerActionDataFiles({ ontology, fs, outDir: rootOutDir, importExt, ontology: enhancedOntology, forInternalUse }: Pick<GenerateContext, "fs" | "outDir" | "importExt" | "ontology" | "forInternalUse">): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAyBA,cAAc,uBAAuB,uCAAwC;
|
|
1
|
+
{"mappings":"AAyBA,cAAc,uBAAuB,uCAAwC;AAO7E,OAAO,iBAAe,2BACpB,EACE,UACA,IACA,QAAQ,YACR,WACA,UAAU,kBACV,gBAQD,EAPE,KACD,iBACE,OACA,WACA,cACA,aACA,oBAEH","names":[],"sources":["../../../src/v2.0/generatePerActionDataFiles.ts"],"version":3,"file":"generatePerActionDataFiles.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/generator",
|
|
3
|
-
"version": "2.8.0-beta.
|
|
3
|
+
"version": "2.8.0-beta.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"fetch-retry": "^6.0.0",
|
|
36
36
|
"prettier": "^3.6.2",
|
|
37
37
|
"tiny-invariant": "^1.3.3",
|
|
38
|
-
"@osdk/
|
|
39
|
-
"@osdk/
|
|
38
|
+
"@osdk/api": "~2.8.0-beta.27",
|
|
39
|
+
"@osdk/generator-converters": "~2.8.0-beta.27"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^18.19.124",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export function sanitizeMetadata(ontology) {
|
|
29
|
-
return {
|
|
30
|
-
...ontology,
|
|
31
|
-
actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map(actionType => {
|
|
32
|
-
return [camelize(actionType.apiName), {
|
|
33
|
-
...actionType,
|
|
34
|
-
apiName: camelize(actionType.apiName)
|
|
35
|
-
}];
|
|
36
|
-
}))
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function camelize(name) {
|
|
40
|
-
return name.replace(/-./g, segment => segment[1].toUpperCase());
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=sanitizeMetadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeMetadata.js","names":["sanitizeMetadata","ontology","actionTypes","Object","fromEntries","values","map","actionType","camelize","apiName","name","replace","segment","toUpperCase"],"sources":["sanitizeMetadata.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\n\n/**\n * @internal\n */\nexport function sanitizeMetadata(\n ontology: WireOntologyDefinition,\n): WireOntologyDefinition;\n/**\n * @internal\n */\nexport function sanitizeMetadata(\n ontology: WireOntologyDefinition,\n): WireOntologyDefinition;\n/**\n * @internal\n */\nexport function sanitizeMetadata<\n T extends WireOntologyDefinition | WireOntologyDefinition,\n>(\n ontology: T,\n): T {\n return {\n ...ontology,\n actionTypes: Object.fromEntries(\n Object.values(ontology.actionTypes).map(actionType => {\n return [camelize(actionType.apiName), {\n ...actionType,\n apiName: camelize(actionType.apiName),\n }];\n }),\n ),\n };\n}\nfunction camelize(name: string) {\n return name.replace(/-./g, segment => segment[1]!.toUpperCase());\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAG9BC,QAAW,EACR;EACH,OAAO;IACL,GAAGA,QAAQ;IACXC,WAAW,EAAEC,MAAM,CAACC,WAAW,CAC7BD,MAAM,CAACE,MAAM,CAACJ,QAAQ,CAACC,WAAW,CAAC,CAACI,GAAG,CAACC,UAAU,IAAI;MACpD,OAAO,CAACC,QAAQ,CAACD,UAAU,CAACE,OAAO,CAAC,EAAE;QACpC,GAAGF,UAAU;QACbE,OAAO,EAAED,QAAQ,CAACD,UAAU,CAACE,OAAO;MACtC,CAAC,CAAC;IACJ,CAAC,CACH;EACF,CAAC;AACH;AACA,SAASD,QAAQA,CAACE,IAAY,EAAE;EAC9B,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAEC,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC,CAAEC,WAAW,CAAC,CAAC,CAAC;AAClE","ignoreList":[]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export function sanitizeMetadata(ontology) {
|
|
29
|
-
return {
|
|
30
|
-
...ontology,
|
|
31
|
-
actionTypes: Object.fromEntries(Object.values(ontology.actionTypes).map(actionType => {
|
|
32
|
-
return [camelize(actionType.apiName), {
|
|
33
|
-
...actionType,
|
|
34
|
-
apiName: camelize(actionType.apiName)
|
|
35
|
-
}];
|
|
36
|
-
}))
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function camelize(name) {
|
|
40
|
-
return name.replace(/-./g, segment => segment[1].toUpperCase());
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=sanitizeMetadata.js.map
|