@osdk/generator 1.11.1-main-20240521212111 → 1.12.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -3
- package/build/browser/index.js +75 -38
- package/build/browser/index.js.map +1 -1
- package/build/cjs/generateClientSdkPackage.d.cts +39 -20
- package/build/cjs/generateClientSdkPackage.d.ts.map +1 -1
- package/build/cjs/index.cjs +75 -37
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/cjs/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/generateClientSdkPackage.d.ts +39 -20
- package/build/esm/generateClientSdkPackage.d.ts.map +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +75 -38
- package/build/esm/index.js.map +1 -1
- package/build/esm/util/test/createMockMinimalFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.12.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 388dba9: Change all internal dependencies to be tilde not caret
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
-
|
|
8
|
-
- @osdk/generator-converters@0.
|
|
11
|
+
- Updated dependencies [388dba9]
|
|
12
|
+
- @osdk/generator-converters@0.7.0-beta.0
|
|
13
|
+
- @osdk/api@1.9.0-beta.0
|
|
14
|
+
|
|
15
|
+
## 1.12.0-beta.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 5378312: Added batch action support for 2.0 client
|
|
20
|
+
- 0ecd42b: Generates 2.0's Ontology.ts in a typescript 5.5.0-beta safe way
|
|
9
21
|
|
|
10
22
|
## 1.11.0
|
|
11
23
|
|
package/build/browser/index.js
CHANGED
|
@@ -331,13 +331,13 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
331
331
|
|
|
332
332
|
|
|
333
333
|
// Represents the runtime arguments for the action
|
|
334
|
-
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}
|
|
334
|
+
export type ${paramsIdentifier} = NOOP<OsdkActionParameters<${paramsDefIdentifier}>> | NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[];
|
|
335
335
|
|
|
336
336
|
|
|
337
337
|
// Represents a fqn of the action
|
|
338
338
|
export interface ${action.apiName} {
|
|
339
339
|
${getDescriptionIfPresent(action.description)}
|
|
340
|
-
<OP extends ApplyActionOptions>(args:
|
|
340
|
+
<P extends ${paramsIdentifier}, OP extends P extends NOOP<OsdkActionParameters<${paramsDefIdentifier}>>[]? ApplyBatchActionOptions: ApplyActionOptions>(args: P, options?: OP): Promise<ActionReturnTypeForOptions<OP>>;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
|
|
@@ -375,7 +375,7 @@ async function generatePerActionDataFiles(ontology, fs2, outDir, importExt, v2)
|
|
|
375
375
|
const importObjects = referencedObjectDefs.size > 0 ? `import type {${[...referencedObjectDefs].join(",")}} from "../objects${importExt}";` : "";
|
|
376
376
|
await fs2.writeFile(path16__default.join(outDir, `${action.apiName}.ts`), await formatTs(`
|
|
377
377
|
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
|
|
378
|
-
import type { ActionSignature, ApplyActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client';
|
|
378
|
+
import type { ActionSignature, ApplyActionOptions, ApplyBatchActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
|
|
379
379
|
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
|
|
380
380
|
${importObjects}
|
|
381
381
|
|
|
@@ -603,8 +603,7 @@ function reexportTypes(typesToExport, genericArgsLeft = "", genericArgsRight = c
|
|
|
603
603
|
var captureInBracketsRegex = /<(.*?)>/;
|
|
604
604
|
var captureGenericParamNameRegex = /^\s?(.+?)( extends .*?)?( = .*?)?\s?$/;
|
|
605
605
|
function cleanup(s) {
|
|
606
|
-
if (s.length === 0)
|
|
607
|
-
return "";
|
|
606
|
+
if (s.length === 0) return "";
|
|
608
607
|
const genericParameterNames = captureInBracketsRegex.exec(s)?.[1]?.split(",")?.map((a) => {
|
|
609
608
|
return captureGenericParamNameRegex.exec(a)?.[1] ?? a;
|
|
610
609
|
});
|
|
@@ -1656,7 +1655,7 @@ function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, v2 = false
|
|
|
1656
1655
|
|
|
1657
1656
|
};`;
|
|
1658
1657
|
}
|
|
1659
|
-
var ExpectedOsdkVersion = "0.
|
|
1658
|
+
var ExpectedOsdkVersion = "0.20.0";
|
|
1660
1659
|
async function generateOntologyMetadataFile(ontology, userAgent, fs2, outDir) {
|
|
1661
1660
|
fs2.writeFile(path16__default.join(outDir, "OntologyMetadata.ts"), await formatTs(`
|
|
1662
1661
|
import { OntologyMetadata as OM } from "@osdk/api";
|
|
@@ -1701,7 +1700,29 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1701
1700
|
import * as Interfaces from "./ontology/interfaces${importExt}";
|
|
1702
1701
|
import { OntologyMetadata } from "./OntologyMetadata${importExt}";
|
|
1703
1702
|
|
|
1704
|
-
|
|
1703
|
+
export interface Ontology extends OntologyDefinition<${stringUnionFrom2(objectNames)}> {
|
|
1704
|
+
metadata: OntologyMetadata,
|
|
1705
|
+
objects: {
|
|
1706
|
+
${objectNames.map((objectName) => {
|
|
1707
|
+
return `${objectName}: Objects.${objectName}`;
|
|
1708
|
+
}).join(",\n")}
|
|
1709
|
+
},
|
|
1710
|
+
actions: {
|
|
1711
|
+
${actionNames.map((actionName) => {
|
|
1712
|
+
return `${actionName}: typeof Actions.${actionName}`;
|
|
1713
|
+
}).join(",\n")}
|
|
1714
|
+
},
|
|
1715
|
+
queries: {
|
|
1716
|
+
// TODO
|
|
1717
|
+
},
|
|
1718
|
+
interfaces: {
|
|
1719
|
+
${interfaceNames.map((objectName) => {
|
|
1720
|
+
return `${objectName}: Interfaces.${objectName}`;
|
|
1721
|
+
}).join(",\n")}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
export const Ontology: Ontology = {
|
|
1705
1726
|
metadata: OntologyMetadata,
|
|
1706
1727
|
objects: {
|
|
1707
1728
|
${objectNames.map((objectName) => {
|
|
@@ -1723,11 +1744,8 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1723
1744
|
}).join(",\n")}
|
|
1724
1745
|
|
|
1725
1746
|
}
|
|
1726
|
-
}
|
|
1747
|
+
};
|
|
1727
1748
|
|
|
1728
|
-
type _Ontology = typeof _Ontology;
|
|
1729
|
-
export interface Ontology extends _Ontology {}
|
|
1730
|
-
export const Ontology = _Ontology as Ontology;
|
|
1731
1749
|
`));
|
|
1732
1750
|
await fs2.mkdir(path16__default.join(outDir, "ontology", "objects"), {
|
|
1733
1751
|
recursive: true
|
|
@@ -1736,7 +1754,7 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1736
1754
|
const obj = ontology.objectTypes[name];
|
|
1737
1755
|
await fs2.writeFile(path16__default.join(outDir, "ontology", `objects`, `${name}.ts`), await formatTs(`
|
|
1738
1756
|
import type { ObjectTypeDefinition, VersionBound, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
|
|
1739
|
-
import { Osdk } from "@osdk/client";
|
|
1757
|
+
import { Osdk } from "@osdk/client.api";
|
|
1740
1758
|
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
|
|
1741
1759
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
1742
1760
|
|
|
@@ -1785,8 +1803,7 @@ async function generateOntologyInterfaces(fs2, outDir, interfaceNames, ontology,
|
|
|
1785
1803
|
|
|
1786
1804
|
// src/generateClientSdkPackage.ts
|
|
1787
1805
|
async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion) {
|
|
1788
|
-
if (!packageName)
|
|
1789
|
-
throw new Error("Package name is require");
|
|
1806
|
+
if (!packageName) throw new Error("Package name is require");
|
|
1790
1807
|
for (const packageType of ["module", "commonjs"]) {
|
|
1791
1808
|
const outDir = path16.join(baseOutDir, "dist", packageType);
|
|
1792
1809
|
await (sdkVersion === "1.1" ? generateClientSdkVersionOneDotOne : sdkVersion === "2.0" ? generateClientSdkVersionTwoPointZero : void 0)(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType);
|
|
@@ -1828,14 +1845,52 @@ function getTsCompilerOptions(packageType) {
|
|
|
1828
1845
|
};
|
|
1829
1846
|
return compilerOptions;
|
|
1830
1847
|
}
|
|
1831
|
-
function
|
|
1832
|
-
typescriptVersion,
|
|
1833
|
-
tslibVersion,
|
|
1834
|
-
areTheTypesWrongVersion,
|
|
1848
|
+
function getExpectedDependencies(sdkVersion, {
|
|
1835
1849
|
osdkApiVersion,
|
|
1836
1850
|
osdkClientVersion,
|
|
1851
|
+
osdkClientApiVersion,
|
|
1837
1852
|
osdkLegacyClientVersion
|
|
1838
1853
|
}) {
|
|
1854
|
+
return {
|
|
1855
|
+
devDependencies: {
|
|
1856
|
+
"@osdk/api": osdkApiVersion,
|
|
1857
|
+
...sdkVersion === "2.0" ? {
|
|
1858
|
+
"@osdk/client.api": osdkClientApiVersion
|
|
1859
|
+
} : {
|
|
1860
|
+
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
peerDependencies: {
|
|
1864
|
+
"@osdk/api": osdkApiVersion,
|
|
1865
|
+
...sdkVersion === "2.0" ? {
|
|
1866
|
+
"@osdk/client.api": osdkClientApiVersion,
|
|
1867
|
+
"@osdk/client": osdkClientVersion
|
|
1868
|
+
} : {
|
|
1869
|
+
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
function getExpectedDependenciesFull(sdkVersion, dependencyVersions) {
|
|
1875
|
+
const {
|
|
1876
|
+
typescriptVersion,
|
|
1877
|
+
tslibVersion,
|
|
1878
|
+
areTheTypesWrongVersion
|
|
1879
|
+
} = dependencyVersions;
|
|
1880
|
+
const base = getExpectedDependencies(sdkVersion, dependencyVersions);
|
|
1881
|
+
return {
|
|
1882
|
+
devDependencies: {
|
|
1883
|
+
...base.devDependencies,
|
|
1884
|
+
"typescript": typescriptVersion,
|
|
1885
|
+
"tslib": tslibVersion,
|
|
1886
|
+
"@arethetypeswrong/cli": areTheTypesWrongVersion
|
|
1887
|
+
},
|
|
1888
|
+
peerDependencies: {
|
|
1889
|
+
...base.peerDependencies
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
function getPackageJsonContents(name, version, sdkVersion, dependencyVersions) {
|
|
1839
1894
|
const esmPrefix = "./dist/module";
|
|
1840
1895
|
const commonjsPrefix = "./dist/commonjs";
|
|
1841
1896
|
return {
|
|
@@ -1857,25 +1912,7 @@ function getPackageJsonContents(name, version, sdkVersion, {
|
|
|
1857
1912
|
prepack: `tsc -p ${esmPrefix}/tsconfig.json && tsc -p ${commonjsPrefix}/tsconfig.json`,
|
|
1858
1913
|
check: "npm exec attw $(npm pack)"
|
|
1859
1914
|
},
|
|
1860
|
-
|
|
1861
|
-
"typescript": typescriptVersion,
|
|
1862
|
-
"tslib": tslibVersion,
|
|
1863
|
-
"@arethetypeswrong/cli": areTheTypesWrongVersion,
|
|
1864
|
-
"@osdk/api": osdkApiVersion,
|
|
1865
|
-
...sdkVersion === "2.0" ? {
|
|
1866
|
-
"@osdk/client": osdkClientVersion
|
|
1867
|
-
} : {
|
|
1868
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1869
|
-
}
|
|
1870
|
-
},
|
|
1871
|
-
peerDependencies: {
|
|
1872
|
-
"@osdk/api": osdkApiVersion,
|
|
1873
|
-
...sdkVersion === "2.0" ? {
|
|
1874
|
-
"@osdk/client": osdkClientVersion
|
|
1875
|
-
} : {
|
|
1876
|
-
"@osdk/legacy-client": osdkLegacyClientVersion
|
|
1877
|
-
}
|
|
1878
|
-
},
|
|
1915
|
+
...getExpectedDependenciesFull(sdkVersion, dependencyVersions),
|
|
1879
1916
|
files: ["**/*.js", "**/*.d.ts", "dist/**/package.json"]
|
|
1880
1917
|
};
|
|
1881
1918
|
}
|
|
@@ -1883,6 +1920,6 @@ async function writeJson(minimalFs, filePath, body) {
|
|
|
1883
1920
|
return await minimalFs.writeFile(filePath, JSON.stringify(body, void 0, 2) + "\n");
|
|
1884
1921
|
}
|
|
1885
1922
|
|
|
1886
|
-
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero };
|
|
1923
|
+
export { generateClientSdkPackage as __UNSTABLE_generateClientSdkPackage, generateClientSdkVersionOneDotOne, generateClientSdkVersionTwoPointZero, getExpectedDependencies };
|
|
1887
1924
|
//# sourceMappingURL=out.js.map
|
|
1888
1925
|
//# sourceMappingURL=index.js.map
|