@contractkit/plugin-typescript 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$ci.log +5 -5
- package/.turbo/turbo-test$colon$ci.log +14 -14
- package/CHANGELOG.md +11 -0
- package/coverage/clover.xml +855 -839
- package/coverage/coverage-final.json +7 -7
- package/coverage/index.html +20 -20
- package/coverage/src/codegen-contract.ts.html +150 -150
- package/coverage/src/codegen-operation.ts.html +1 -1
- package/coverage/src/codegen-plain-types.ts.html +58 -58
- package/coverage/src/codegen-sdk.ts.html +445 -211
- package/coverage/src/index.html +40 -40
- package/coverage/src/index.ts.html +295 -184
- package/coverage/src/path-utils.ts.html +105 -105
- package/coverage/src/ts-render.ts.html +9 -9
- package/coverage/tests/helpers.ts.html +19 -19
- package/coverage/tests/index.html +1 -1
- package/dist/codegen-sdk.d.ts +22 -0
- package/dist/codegen-sdk.d.ts.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/codegen-sdk.ts +78 -0
- package/src/index.ts +40 -3
- package/tests/codegen-sdk.test.ts +48 -0
- package/tests/codegen-server.test.ts +107 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EAQpB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EAQpB,MAAM,mBAAmB,CAAC;AA6C3B,MAAM,WAAW,YAAY;IACzB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6HAA6H;IAC7H,GAAG,CAAC,EAA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CAOzG"}
|
package/dist/index.js
CHANGED
|
@@ -2590,6 +2590,71 @@ function generateSdkOptions() {
|
|
|
2590
2590
|
].join("\n");
|
|
2591
2591
|
}
|
|
2592
2592
|
__name(generateSdkOptions, "generateSdkOptions");
|
|
2593
|
+
var SCAFFOLD_DEP_VERSIONS = {
|
|
2594
|
+
zod: "^4.3.6",
|
|
2595
|
+
luxon: "^3.5.0",
|
|
2596
|
+
typesLuxon: "^3.4.2",
|
|
2597
|
+
typescript: "^6.0.3"
|
|
2598
|
+
};
|
|
2599
|
+
function generateSdkPackageJson(input) {
|
|
2600
|
+
const dependencies = {};
|
|
2601
|
+
if (input.deps.zod) dependencies.zod = SCAFFOLD_DEP_VERSIONS.zod;
|
|
2602
|
+
if (input.deps.luxon) dependencies.luxon = SCAFFOLD_DEP_VERSIONS.luxon;
|
|
2603
|
+
const devDependencies = {
|
|
2604
|
+
typescript: SCAFFOLD_DEP_VERSIONS.typescript
|
|
2605
|
+
};
|
|
2606
|
+
if (input.deps.luxon) devDependencies["@types/luxon"] = SCAFFOLD_DEP_VERSIONS.typesLuxon;
|
|
2607
|
+
const pkg = {
|
|
2608
|
+
name: input.name,
|
|
2609
|
+
version: "0.0.0",
|
|
2610
|
+
type: "module",
|
|
2611
|
+
main: "./dist/index.js",
|
|
2612
|
+
types: "./dist/index.d.ts",
|
|
2613
|
+
exports: {
|
|
2614
|
+
".": {
|
|
2615
|
+
types: "./dist/index.d.ts",
|
|
2616
|
+
import: "./dist/index.js"
|
|
2617
|
+
}
|
|
2618
|
+
},
|
|
2619
|
+
files: [
|
|
2620
|
+
"dist"
|
|
2621
|
+
],
|
|
2622
|
+
scripts: {
|
|
2623
|
+
build: "tsc -p tsconfig.json"
|
|
2624
|
+
},
|
|
2625
|
+
...Object.keys(dependencies).length > 0 ? {
|
|
2626
|
+
dependencies
|
|
2627
|
+
} : {},
|
|
2628
|
+
devDependencies
|
|
2629
|
+
};
|
|
2630
|
+
return JSON.stringify(pkg, null, 4) + "\n";
|
|
2631
|
+
}
|
|
2632
|
+
__name(generateSdkPackageJson, "generateSdkPackageJson");
|
|
2633
|
+
function generateSdkTsconfig() {
|
|
2634
|
+
const tsconfig = {
|
|
2635
|
+
compilerOptions: {
|
|
2636
|
+
target: "ES2022",
|
|
2637
|
+
module: "NodeNext",
|
|
2638
|
+
moduleResolution: "NodeNext",
|
|
2639
|
+
declaration: true,
|
|
2640
|
+
outDir: "./dist",
|
|
2641
|
+
rootDir: "./src",
|
|
2642
|
+
strict: true,
|
|
2643
|
+
esModuleInterop: true,
|
|
2644
|
+
skipLibCheck: true,
|
|
2645
|
+
forceConsistentCasingInFileNames: true
|
|
2646
|
+
},
|
|
2647
|
+
include: [
|
|
2648
|
+
"src"
|
|
2649
|
+
],
|
|
2650
|
+
exclude: [
|
|
2651
|
+
"dist",
|
|
2652
|
+
"node_modules"
|
|
2653
|
+
]
|
|
2654
|
+
};
|
|
2655
|
+
return JSON.stringify(tsconfig, null, 4) + "\n";
|
|
2656
|
+
}
|
|
2657
|
+
__name(generateSdkTsconfig, "generateSdkTsconfig");
|
|
2593
2658
|
function generateAreaClient(input) {
|
|
2594
2659
|
const { area, outPath, inlineFiles, subareaClients, sdkOptionsPath } = input;
|
|
2595
2660
|
const className = deriveAreaClientClassName(area);
|
|
@@ -3193,8 +3258,10 @@ async function runTypescriptCodegen(inputs, ctx, config, rootDir) {
|
|
|
3193
3258
|
fileExists: existsSync
|
|
3194
3259
|
});
|
|
3195
3260
|
deleteStalePaths(result.deletedPaths);
|
|
3196
|
-
for (const { relativePath, content } of result.filesToWrite) {
|
|
3197
|
-
ctx.emitFile(relativePath, content
|
|
3261
|
+
for (const { relativePath, content, ifAbsent } of result.filesToWrite) {
|
|
3262
|
+
ctx.emitFile(relativePath, content, ifAbsent ? {
|
|
3263
|
+
ifAbsent: true
|
|
3264
|
+
} : void 0);
|
|
3198
3265
|
}
|
|
3199
3266
|
writeManifest(manifestPath, result.manifest);
|
|
3200
3267
|
}
|
|
@@ -3719,6 +3786,26 @@ function collectSdkOutput(config, rootDir, inputs, units, globalFiles) {
|
|
|
3719
3786
|
${rootExports.sort().join("\n")}
|
|
3720
3787
|
`
|
|
3721
3788
|
});
|
|
3789
|
+
if (config.scaffold) {
|
|
3790
|
+
const coveredRoots = sdkContractEntries.map((e) => e.ast);
|
|
3791
|
+
const deps = {
|
|
3792
|
+
zod: !!config.zod,
|
|
3793
|
+
luxon: coveredRoots.some((r) => rootNeedsScalar(r, "datetime") || rootNeedsScalar(r, "date") || rootNeedsScalar(r, "time") || rootNeedsScalar(r, "interval"))
|
|
3794
|
+
};
|
|
3795
|
+
globalFiles.push({
|
|
3796
|
+
relativePath: join2(sdkBase, "package.json"),
|
|
3797
|
+
content: generateSdkPackageJson({
|
|
3798
|
+
name: sdkName ?? "sdk",
|
|
3799
|
+
deps
|
|
3800
|
+
}),
|
|
3801
|
+
ifAbsent: true
|
|
3802
|
+
});
|
|
3803
|
+
globalFiles.push({
|
|
3804
|
+
relativePath: join2(sdkBase, "tsconfig.json"),
|
|
3805
|
+
content: generateSdkTsconfig(),
|
|
3806
|
+
ifAbsent: true
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
3722
3809
|
}
|
|
3723
3810
|
__name(collectSdkOutput, "collectSdkOutput");
|
|
3724
3811
|
function collectZodOutput(config, rootDir, inputs, units) {
|