thinkwell 0.5.2 → 0.5.4
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/bin/thinkwell +6 -4
- package/dist/agent.d.ts +3 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +3 -3
- package/dist/agent.js.map +1 -1
- package/dist/build.d.ts +28 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +110 -0
- package/dist/build.js.map +1 -0
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +7 -4
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/bundle.d.ts.map +1 -1
- package/dist/cli/bundle.js +21 -3
- package/dist/cli/bundle.js.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +7 -4
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/commands.d.ts +15 -2
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +152 -7
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/compiler-host.d.ts +16 -0
- package/dist/cli/compiler-host.d.ts.map +1 -1
- package/dist/cli/compiler-host.js +13 -7
- package/dist/cli/compiler-host.js.map +1 -1
- package/dist/cli/dependency-check.d.ts +7 -0
- package/dist/cli/dependency-check.d.ts.map +1 -1
- package/dist/cli/dependency-check.js +20 -1
- package/dist/cli/dependency-check.js.map +1 -1
- package/dist/cli/dependency-errors.d.ts +17 -0
- package/dist/cli/dependency-errors.d.ts.map +1 -1
- package/dist/cli/dependency-errors.js +31 -0
- package/dist/cli/dependency-errors.js.map +1 -1
- package/dist/cli/loader.d.ts +9 -0
- package/dist/cli/loader.d.ts.map +1 -1
- package/dist/cli/loader.js +43 -12
- package/dist/cli/loader.js.map +1 -1
- package/dist/cli/schema.d.ts +15 -3
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +48 -76
- package/dist/cli/schema.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +3 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/think-builder.d.ts +31 -105
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +82 -116
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-stream.d.ts +1 -1
- package/dist/thought-stream.d.ts.map +1 -1
- package/dist/thought-stream.js +1 -1
- package/dist/thought-stream.js.map +1 -1
- package/dist-pkg/cli-build.cjs +166 -125
- package/dist-pkg/cli-bundle.cjs +560 -185
- package/dist-pkg/cli-check.cjs +156 -119
- package/dist-pkg/cli-dependency-check.cjs +312 -0
- package/dist-pkg/cli-dependency-errors.cjs +92 -0
- package/dist-pkg/cli-loader.cjs +144 -103
- package/dist-pkg/pkg-cli.cjs +119 -1
- package/dist-pkg/thinkwell.cjs +80 -109
- package/package.json +9 -4
package/dist-pkg/cli-build.cjs
CHANGED
|
@@ -532,16 +532,16 @@ var require_typescript = __commonJS({
|
|
|
532
532
|
var tsp;
|
|
533
533
|
(function(tsp2) {
|
|
534
534
|
const activeProgramTransformers = /* @__PURE__ */ new Set();
|
|
535
|
-
const { dirname:
|
|
535
|
+
const { dirname: dirname5 } = require("path");
|
|
536
536
|
function getProjectDir(compilerOptions) {
|
|
537
|
-
return compilerOptions.configFilePath &&
|
|
537
|
+
return compilerOptions.configFilePath && dirname5(compilerOptions.configFilePath);
|
|
538
538
|
}
|
|
539
539
|
__name(getProjectDir, "getProjectDir");
|
|
540
540
|
function getProjectConfig(compilerOptions, rootFileNames) {
|
|
541
541
|
let configFilePath = compilerOptions.configFilePath;
|
|
542
542
|
let projectDir = getProjectDir(compilerOptions);
|
|
543
543
|
if (configFilePath === void 0) {
|
|
544
|
-
const baseDir = rootFileNames.length > 0 ?
|
|
544
|
+
const baseDir = rootFileNames.length > 0 ? dirname5(rootFileNames[0]) : projectDir ?? process.cwd();
|
|
545
545
|
configFilePath = tsp2.tsShim.findConfigFile(baseDir, tsp2.tsShim.sys.fileExists);
|
|
546
546
|
if (configFilePath) {
|
|
547
547
|
const config = readConfig(configFilePath);
|
|
@@ -553,7 +553,7 @@ var require_typescript = __commonJS({
|
|
|
553
553
|
}
|
|
554
554
|
__name(getProjectConfig, "getProjectConfig");
|
|
555
555
|
function readConfig(configFileNamePath) {
|
|
556
|
-
const projectDir =
|
|
556
|
+
const projectDir = dirname5(configFileNamePath);
|
|
557
557
|
const result = tsp2.tsShim.readConfigFile(configFileNamePath, tsp2.tsShim.sys.readFile);
|
|
558
558
|
if (result.error)
|
|
559
559
|
throw new tsp2.TsPatchError("Error in tsconfig.json: " + result.error.messageText);
|
|
@@ -223419,7 +223419,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
223419
223419
|
return circularValue;
|
|
223420
223420
|
}
|
|
223421
223421
|
let res = "";
|
|
223422
|
-
let
|
|
223422
|
+
let join8 = ",";
|
|
223423
223423
|
const originalIndentation = indentation;
|
|
223424
223424
|
if (Array.isArray(value)) {
|
|
223425
223425
|
if (value.length === 0) {
|
|
@@ -223433,7 +223433,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
223433
223433
|
indentation += spacer;
|
|
223434
223434
|
res += `
|
|
223435
223435
|
${indentation}`;
|
|
223436
|
-
|
|
223436
|
+
join8 = `,
|
|
223437
223437
|
${indentation}`;
|
|
223438
223438
|
}
|
|
223439
223439
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -223441,13 +223441,13 @@ ${indentation}`;
|
|
|
223441
223441
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223442
223442
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
223443
223443
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
223444
|
-
res +=
|
|
223444
|
+
res += join8;
|
|
223445
223445
|
}
|
|
223446
223446
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
223447
223447
|
res += tmp !== void 0 ? tmp : "null";
|
|
223448
223448
|
if (value.length - 1 > maximumBreadth) {
|
|
223449
223449
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223450
|
-
res += `${
|
|
223450
|
+
res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223451
223451
|
}
|
|
223452
223452
|
if (spacer !== "") {
|
|
223453
223453
|
res += `
|
|
@@ -223468,7 +223468,7 @@ ${originalIndentation}`;
|
|
|
223468
223468
|
let separator = "";
|
|
223469
223469
|
if (spacer !== "") {
|
|
223470
223470
|
indentation += spacer;
|
|
223471
|
-
|
|
223471
|
+
join8 = `,
|
|
223472
223472
|
${indentation}`;
|
|
223473
223473
|
whitespace = " ";
|
|
223474
223474
|
}
|
|
@@ -223482,13 +223482,13 @@ ${indentation}`;
|
|
|
223482
223482
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
223483
223483
|
if (tmp !== void 0) {
|
|
223484
223484
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
223485
|
-
separator =
|
|
223485
|
+
separator = join8;
|
|
223486
223486
|
}
|
|
223487
223487
|
}
|
|
223488
223488
|
if (keyLength > maximumBreadth) {
|
|
223489
223489
|
const removedKeys = keyLength - maximumBreadth;
|
|
223490
223490
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
223491
|
-
separator =
|
|
223491
|
+
separator = join8;
|
|
223492
223492
|
}
|
|
223493
223493
|
if (spacer !== "" && separator.length > 1) {
|
|
223494
223494
|
res = `
|
|
@@ -223530,7 +223530,7 @@ ${originalIndentation}`;
|
|
|
223530
223530
|
}
|
|
223531
223531
|
const originalIndentation = indentation;
|
|
223532
223532
|
let res = "";
|
|
223533
|
-
let
|
|
223533
|
+
let join8 = ",";
|
|
223534
223534
|
if (Array.isArray(value)) {
|
|
223535
223535
|
if (value.length === 0) {
|
|
223536
223536
|
return "[]";
|
|
@@ -223543,7 +223543,7 @@ ${originalIndentation}`;
|
|
|
223543
223543
|
indentation += spacer;
|
|
223544
223544
|
res += `
|
|
223545
223545
|
${indentation}`;
|
|
223546
|
-
|
|
223546
|
+
join8 = `,
|
|
223547
223547
|
${indentation}`;
|
|
223548
223548
|
}
|
|
223549
223549
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -223551,13 +223551,13 @@ ${indentation}`;
|
|
|
223551
223551
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223552
223552
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
223553
223553
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
223554
|
-
res +=
|
|
223554
|
+
res += join8;
|
|
223555
223555
|
}
|
|
223556
223556
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
223557
223557
|
res += tmp !== void 0 ? tmp : "null";
|
|
223558
223558
|
if (value.length - 1 > maximumBreadth) {
|
|
223559
223559
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223560
|
-
res += `${
|
|
223560
|
+
res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223561
223561
|
}
|
|
223562
223562
|
if (spacer !== "") {
|
|
223563
223563
|
res += `
|
|
@@ -223570,7 +223570,7 @@ ${originalIndentation}`;
|
|
|
223570
223570
|
let whitespace = "";
|
|
223571
223571
|
if (spacer !== "") {
|
|
223572
223572
|
indentation += spacer;
|
|
223573
|
-
|
|
223573
|
+
join8 = `,
|
|
223574
223574
|
${indentation}`;
|
|
223575
223575
|
whitespace = " ";
|
|
223576
223576
|
}
|
|
@@ -223579,7 +223579,7 @@ ${indentation}`;
|
|
|
223579
223579
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
223580
223580
|
if (tmp !== void 0) {
|
|
223581
223581
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
223582
|
-
separator =
|
|
223582
|
+
separator = join8;
|
|
223583
223583
|
}
|
|
223584
223584
|
}
|
|
223585
223585
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -223638,20 +223638,20 @@ ${originalIndentation}`;
|
|
|
223638
223638
|
indentation += spacer;
|
|
223639
223639
|
let res2 = `
|
|
223640
223640
|
${indentation}`;
|
|
223641
|
-
const
|
|
223641
|
+
const join9 = `,
|
|
223642
223642
|
${indentation}`;
|
|
223643
223643
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
223644
223644
|
let i = 0;
|
|
223645
223645
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223646
223646
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
223647
223647
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
223648
|
-
res2 +=
|
|
223648
|
+
res2 += join9;
|
|
223649
223649
|
}
|
|
223650
223650
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
223651
223651
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
223652
223652
|
if (value.length - 1 > maximumBreadth) {
|
|
223653
223653
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223654
|
-
res2 += `${
|
|
223654
|
+
res2 += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223655
223655
|
}
|
|
223656
223656
|
res2 += `
|
|
223657
223657
|
${originalIndentation}`;
|
|
@@ -223667,16 +223667,16 @@ ${originalIndentation}`;
|
|
|
223667
223667
|
return '"[Object]"';
|
|
223668
223668
|
}
|
|
223669
223669
|
indentation += spacer;
|
|
223670
|
-
const
|
|
223670
|
+
const join8 = `,
|
|
223671
223671
|
${indentation}`;
|
|
223672
223672
|
let res = "";
|
|
223673
223673
|
let separator = "";
|
|
223674
223674
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
223675
223675
|
if (isTypedArrayWithEntries(value)) {
|
|
223676
|
-
res += stringifyTypedArray(value,
|
|
223676
|
+
res += stringifyTypedArray(value, join8, maximumBreadth);
|
|
223677
223677
|
keys = keys.slice(value.length);
|
|
223678
223678
|
maximumPropertiesToStringify -= value.length;
|
|
223679
|
-
separator =
|
|
223679
|
+
separator = join8;
|
|
223680
223680
|
}
|
|
223681
223681
|
if (deterministic) {
|
|
223682
223682
|
keys = sort(keys, comparator);
|
|
@@ -223687,13 +223687,13 @@ ${indentation}`;
|
|
|
223687
223687
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
223688
223688
|
if (tmp !== void 0) {
|
|
223689
223689
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
223690
|
-
separator =
|
|
223690
|
+
separator = join8;
|
|
223691
223691
|
}
|
|
223692
223692
|
}
|
|
223693
223693
|
if (keyLength > maximumBreadth) {
|
|
223694
223694
|
const removedKeys = keyLength - maximumBreadth;
|
|
223695
223695
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
223696
|
-
separator =
|
|
223696
|
+
separator = join8;
|
|
223697
223697
|
}
|
|
223698
223698
|
if (separator !== "") {
|
|
223699
223699
|
res = `
|
|
@@ -238603,20 +238603,95 @@ __export(build_exports, {
|
|
|
238603
238603
|
});
|
|
238604
238604
|
module.exports = __toCommonJS(build_exports);
|
|
238605
238605
|
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
238606
|
-
var
|
|
238607
|
-
var
|
|
238606
|
+
var import_node_fs6 = require("node:fs");
|
|
238607
|
+
var import_node_path7 = require("node:path");
|
|
238608
238608
|
var import_node_util3 = require("node:util");
|
|
238609
238609
|
|
|
238610
238610
|
// dist/cli/compiler-host.js
|
|
238611
238611
|
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
238612
|
-
var
|
|
238612
|
+
var import_node_path3 = require("node:path");
|
|
238613
238613
|
var import_node_fs2 = require("node:fs");
|
|
238614
238614
|
|
|
238615
238615
|
// dist/cli/schema.js
|
|
238616
238616
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
238617
|
+
var import_node_path2 = require("node:path");
|
|
238618
|
+
var import_node_module = require("node:module");
|
|
238619
|
+
|
|
238620
|
+
// dist/build.js
|
|
238617
238621
|
var import_node_path = require("node:path");
|
|
238618
238622
|
var import_node_fs = require("node:fs");
|
|
238619
238623
|
var import_ts_json_schema_generator = __toESM(require_dist(), 1);
|
|
238624
|
+
function findTsConfig(startDir) {
|
|
238625
|
+
let dir = startDir;
|
|
238626
|
+
while (true) {
|
|
238627
|
+
const configPath = (0, import_node_path.join)(dir, "tsconfig.json");
|
|
238628
|
+
if ((0, import_node_fs.existsSync)(configPath)) {
|
|
238629
|
+
return configPath;
|
|
238630
|
+
}
|
|
238631
|
+
const parent = (0, import_node_path.dirname)(dir);
|
|
238632
|
+
if (parent === dir) {
|
|
238633
|
+
return void 0;
|
|
238634
|
+
}
|
|
238635
|
+
dir = parent;
|
|
238636
|
+
}
|
|
238637
|
+
}
|
|
238638
|
+
__name(findTsConfig, "findTsConfig");
|
|
238639
|
+
function inlineRefs(obj, definitions) {
|
|
238640
|
+
if (obj === null || typeof obj !== "object") {
|
|
238641
|
+
return obj;
|
|
238642
|
+
}
|
|
238643
|
+
if (Array.isArray(obj)) {
|
|
238644
|
+
return obj.map((item) => inlineRefs(item, definitions));
|
|
238645
|
+
}
|
|
238646
|
+
const record = obj;
|
|
238647
|
+
if (typeof record["$ref"] === "string") {
|
|
238648
|
+
const ref = record["$ref"];
|
|
238649
|
+
const match = ref.match(/^#\/definitions\/(.+)$/);
|
|
238650
|
+
if (match && definitions[match[1]]) {
|
|
238651
|
+
return inlineRefs(definitions[match[1]], definitions);
|
|
238652
|
+
}
|
|
238653
|
+
}
|
|
238654
|
+
const result = {};
|
|
238655
|
+
for (const [key2, value] of Object.entries(record)) {
|
|
238656
|
+
result[key2] = inlineRefs(value, definitions);
|
|
238657
|
+
}
|
|
238658
|
+
return result;
|
|
238659
|
+
}
|
|
238660
|
+
__name(inlineRefs, "inlineRefs");
|
|
238661
|
+
function cleanSchema(typeName, schema) {
|
|
238662
|
+
const definitions = schema.definitions || {};
|
|
238663
|
+
let result = definitions[typeName] || schema;
|
|
238664
|
+
result = inlineRefs(result, definitions);
|
|
238665
|
+
if (typeof result === "object" && result !== null) {
|
|
238666
|
+
const cleaned = { ...result };
|
|
238667
|
+
delete cleaned["$schema"];
|
|
238668
|
+
delete cleaned["definitions"];
|
|
238669
|
+
return cleaned;
|
|
238670
|
+
}
|
|
238671
|
+
return result;
|
|
238672
|
+
}
|
|
238673
|
+
__name(cleanSchema, "cleanSchema");
|
|
238674
|
+
function generateSchemas(filePath, typeNames) {
|
|
238675
|
+
const schemas = /* @__PURE__ */ new Map();
|
|
238676
|
+
if (typeNames.length === 0) {
|
|
238677
|
+
return schemas;
|
|
238678
|
+
}
|
|
238679
|
+
const configPath = findTsConfig((0, import_node_path.dirname)(filePath));
|
|
238680
|
+
const generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
238681
|
+
path: filePath,
|
|
238682
|
+
...configPath && { tsconfig: configPath },
|
|
238683
|
+
skipTypeCheck: true,
|
|
238684
|
+
encodeRefs: false
|
|
238685
|
+
});
|
|
238686
|
+
for (const typeName of typeNames) {
|
|
238687
|
+
const schema = generator.createSchema(typeName);
|
|
238688
|
+
schemas.set(typeName, cleanSchema(typeName, schema));
|
|
238689
|
+
}
|
|
238690
|
+
return schemas;
|
|
238691
|
+
}
|
|
238692
|
+
__name(generateSchemas, "generateSchemas");
|
|
238693
|
+
|
|
238694
|
+
// dist/cli/schema.js
|
|
238620
238695
|
var JSONSCHEMA_TAG = "JSONSchema";
|
|
238621
238696
|
function hasJsDocTag(node, tagName) {
|
|
238622
238697
|
const jsDocNodes = import_typescript.default.getJSDocTags(node);
|
|
@@ -238665,74 +238740,31 @@ function findMarkedTypes(path, source) {
|
|
|
238665
238740
|
return results;
|
|
238666
238741
|
}
|
|
238667
238742
|
__name(findMarkedTypes, "findMarkedTypes");
|
|
238668
|
-
function
|
|
238669
|
-
|
|
238670
|
-
|
|
238671
|
-
const
|
|
238672
|
-
if (
|
|
238673
|
-
return
|
|
238674
|
-
}
|
|
238675
|
-
const parent = (0, import_node_path.dirname)(dir);
|
|
238676
|
-
if (parent === dir) {
|
|
238677
|
-
return void 0;
|
|
238678
|
-
}
|
|
238679
|
-
dir = parent;
|
|
238680
|
-
}
|
|
238681
|
-
}
|
|
238682
|
-
__name(findTsConfig, "findTsConfig");
|
|
238683
|
-
function inlineRefs(obj, definitions) {
|
|
238684
|
-
if (obj === null || typeof obj !== "object") {
|
|
238685
|
-
return obj;
|
|
238686
|
-
}
|
|
238687
|
-
if (Array.isArray(obj)) {
|
|
238688
|
-
return obj.map((item) => inlineRefs(item, definitions));
|
|
238689
|
-
}
|
|
238690
|
-
const record = obj;
|
|
238691
|
-
if (typeof record["$ref"] === "string") {
|
|
238692
|
-
const ref = record["$ref"];
|
|
238693
|
-
const match = ref.match(/^#\/definitions\/(.+)$/);
|
|
238694
|
-
if (match && definitions[match[1]]) {
|
|
238695
|
-
return inlineRefs(definitions[match[1]], definitions);
|
|
238743
|
+
function resolveGenerateSchemas(projectDir) {
|
|
238744
|
+
if (projectDir) {
|
|
238745
|
+
const projectRequire = (0, import_node_module.createRequire)((0, import_node_path2.join)(projectDir, "package.json"));
|
|
238746
|
+
const buildMod = projectRequire("thinkwell/build");
|
|
238747
|
+
if (typeof buildMod.generateSchemas === "function") {
|
|
238748
|
+
return buildMod.generateSchemas;
|
|
238696
238749
|
}
|
|
238750
|
+
throw new Error(`thinkwell/build resolved from ${projectDir} but does not export generateSchemas. This may indicate a version mismatch \u2014 try updating the thinkwell dependency.`);
|
|
238697
238751
|
}
|
|
238698
|
-
|
|
238699
|
-
for (const [key2, value] of Object.entries(record)) {
|
|
238700
|
-
result[key2] = inlineRefs(value, definitions);
|
|
238701
|
-
}
|
|
238702
|
-
return result;
|
|
238752
|
+
return generateSchemas;
|
|
238703
238753
|
}
|
|
238704
|
-
__name(
|
|
238705
|
-
function
|
|
238706
|
-
const configPath = findTsConfig((0, import_node_path.dirname)(filePath));
|
|
238707
|
-
const config = {
|
|
238708
|
-
path: filePath,
|
|
238709
|
-
...configPath && { tsconfig: configPath },
|
|
238710
|
-
skipTypeCheck: true,
|
|
238711
|
-
encodeRefs: false
|
|
238712
|
-
};
|
|
238713
|
-
return (0, import_ts_json_schema_generator.createGenerator)(config);
|
|
238714
|
-
}
|
|
238715
|
-
__name(createSchemaGenerator, "createSchemaGenerator");
|
|
238716
|
-
function generateSchemas(path, types, sourceCode) {
|
|
238754
|
+
__name(resolveGenerateSchemas, "resolveGenerateSchemas");
|
|
238755
|
+
function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
238717
238756
|
const schemas = /* @__PURE__ */ new Map();
|
|
238718
238757
|
if (types.length === 0) {
|
|
238719
238758
|
return schemas;
|
|
238720
238759
|
}
|
|
238721
|
-
const
|
|
238760
|
+
const buildGenerateSchemas = resolveGenerateSchemas(projectDir);
|
|
238722
238761
|
for (const typeInfo of types) {
|
|
238723
|
-
const { name, line, column
|
|
238762
|
+
const { name, line, column } = typeInfo;
|
|
238724
238763
|
try {
|
|
238725
|
-
const
|
|
238726
|
-
const
|
|
238727
|
-
|
|
238728
|
-
|
|
238729
|
-
if (typeof result === "object" && result !== null) {
|
|
238730
|
-
const cleaned = { ...result };
|
|
238731
|
-
delete cleaned["$schema"];
|
|
238732
|
-
delete cleaned["definitions"];
|
|
238733
|
-
schemas.set(name, cleaned);
|
|
238734
|
-
} else {
|
|
238735
|
-
schemas.set(name, result);
|
|
238764
|
+
const result = buildGenerateSchemas(path, [name]);
|
|
238765
|
+
const schema = result.get(name);
|
|
238766
|
+
if (schema) {
|
|
238767
|
+
schemas.set(name, schema);
|
|
238736
238768
|
}
|
|
238737
238769
|
} catch (error) {
|
|
238738
238770
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -238743,7 +238775,7 @@ function generateSchemas(path, types, sourceCode) {
|
|
|
238743
238775
|
}
|
|
238744
238776
|
return schemas;
|
|
238745
238777
|
}
|
|
238746
|
-
__name(
|
|
238778
|
+
__name(generateSchemas2, "generateSchemas");
|
|
238747
238779
|
var ACP_NAMESPACE = "$$__thinkwell__acp__$$";
|
|
238748
238780
|
function generateNamespace(name, schema, isExported) {
|
|
238749
238781
|
const schemaJson = JSON.stringify(schema, null, 2).split("\n").map((line, i) => i === 0 ? line : " " + line).join("\n");
|
|
@@ -238788,7 +238820,7 @@ function hasJsonSchemaMarkers(source) {
|
|
|
238788
238820
|
return source.includes("@JSONSchema");
|
|
238789
238821
|
}
|
|
238790
238822
|
__name(hasJsonSchemaMarkers, "hasJsonSchemaMarkers");
|
|
238791
|
-
function transformJsonSchemas(path, source) {
|
|
238823
|
+
function transformJsonSchemas(path, source, projectDir) {
|
|
238792
238824
|
if (!hasJsonSchemaMarkers(source)) {
|
|
238793
238825
|
return source;
|
|
238794
238826
|
}
|
|
@@ -238796,7 +238828,7 @@ function transformJsonSchemas(path, source) {
|
|
|
238796
238828
|
if (markedTypes.length === 0) {
|
|
238797
238829
|
return source;
|
|
238798
238830
|
}
|
|
238799
|
-
const schemas =
|
|
238831
|
+
const schemas = generateSchemas2(path, markedTypes, source, projectDir);
|
|
238800
238832
|
const insertions = generateInsertions(markedTypes, schemas);
|
|
238801
238833
|
let modifiedSource = applyInsertions(source, insertions);
|
|
238802
238834
|
modifiedSource = generateSchemaImport() + "\n" + modifiedSource;
|
|
@@ -238812,7 +238844,7 @@ function getTypeScriptLibDir() {
|
|
|
238812
238844
|
return snapshotLibDir;
|
|
238813
238845
|
}
|
|
238814
238846
|
}
|
|
238815
|
-
return (0,
|
|
238847
|
+
return (0, import_node_path3.dirname)(import_typescript2.default.getDefaultLibFilePath({}));
|
|
238816
238848
|
}
|
|
238817
238849
|
__name(getTypeScriptLibDir, "getTypeScriptLibDir");
|
|
238818
238850
|
function parseTsConfig(configPath) {
|
|
@@ -238824,7 +238856,7 @@ function parseTsConfig(configPath) {
|
|
|
238824
238856
|
errors: [configFile.error]
|
|
238825
238857
|
};
|
|
238826
238858
|
}
|
|
238827
|
-
const configDir = (0,
|
|
238859
|
+
const configDir = (0, import_node_path3.dirname)(configPath);
|
|
238828
238860
|
const parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238829
238861
|
configFile.config,
|
|
238830
238862
|
import_typescript2.default.sys,
|
|
@@ -238855,12 +238887,15 @@ __name(isThinkwellHostOptions, "isThinkwellHostOptions");
|
|
|
238855
238887
|
function createThinkwellHost(options) {
|
|
238856
238888
|
let compilerOptions;
|
|
238857
238889
|
let fileFilter;
|
|
238890
|
+
let projectDir;
|
|
238858
238891
|
if (isThinkwellHostOptions(options)) {
|
|
238859
238892
|
compilerOptions = options.compilerOptions;
|
|
238860
238893
|
fileFilter = options.fileFilter;
|
|
238894
|
+
projectDir = options.projectDir;
|
|
238861
238895
|
} else {
|
|
238862
238896
|
compilerOptions = options;
|
|
238863
238897
|
fileFilter = void 0;
|
|
238898
|
+
projectDir = void 0;
|
|
238864
238899
|
}
|
|
238865
238900
|
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions);
|
|
238866
238901
|
const tsLibDir = getTypeScriptLibDir();
|
|
@@ -238873,7 +238908,7 @@ function createThinkwellHost(options) {
|
|
|
238873
238908
|
return tsLibDir;
|
|
238874
238909
|
},
|
|
238875
238910
|
getDefaultLibFileName(options2) {
|
|
238876
|
-
return (0,
|
|
238911
|
+
return (0, import_node_path3.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options2));
|
|
238877
238912
|
},
|
|
238878
238913
|
getSourceFile(fileName, languageVersionOrOptions) {
|
|
238879
238914
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
@@ -238882,7 +238917,7 @@ function createThinkwellHost(options) {
|
|
|
238882
238917
|
}
|
|
238883
238918
|
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source)) {
|
|
238884
238919
|
if (!fileFilter || fileFilter(fileName)) {
|
|
238885
|
-
const transformed = transformJsonSchemas(fileName, source);
|
|
238920
|
+
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238886
238921
|
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238887
238922
|
}
|
|
238888
238923
|
}
|
|
@@ -238894,10 +238929,11 @@ __name(createThinkwellHost, "createThinkwellHost");
|
|
|
238894
238929
|
function createThinkwellProgram(configPathOrOptions) {
|
|
238895
238930
|
const configPath = typeof configPathOrOptions === "string" ? configPathOrOptions : configPathOrOptions.configPath;
|
|
238896
238931
|
const fileFilter = typeof configPathOrOptions === "object" ? configPathOrOptions.fileFilter : void 0;
|
|
238897
|
-
const
|
|
238932
|
+
const projectDir = typeof configPathOrOptions === "object" ? configPathOrOptions.projectDir : void 0;
|
|
238933
|
+
const resolvedConfigPath = (0, import_node_path3.resolve)(configPath);
|
|
238898
238934
|
const { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238899
238935
|
function makeHost() {
|
|
238900
|
-
return fileFilter ? createThinkwellHost({ compilerOptions: options, fileFilter }) : createThinkwellHost(options);
|
|
238936
|
+
return fileFilter || projectDir ? createThinkwellHost({ compilerOptions: options, fileFilter, projectDir }) : createThinkwellHost(options);
|
|
238901
238937
|
}
|
|
238902
238938
|
__name(makeHost, "makeHost");
|
|
238903
238939
|
if (errors.length > 0) {
|
|
@@ -238913,11 +238949,11 @@ function createThinkwellProgram(configPathOrOptions) {
|
|
|
238913
238949
|
return { program, configErrors: errors };
|
|
238914
238950
|
}
|
|
238915
238951
|
__name(createThinkwellProgram, "createThinkwellProgram");
|
|
238916
|
-
function patchHost(host, fileFilter) {
|
|
238952
|
+
function patchHost(host, fileFilter, projectDir) {
|
|
238917
238953
|
const originalGetSourceFile = host.getSourceFile.bind(host);
|
|
238918
238954
|
const tsLibDir = getTypeScriptLibDir();
|
|
238919
238955
|
host.getDefaultLibLocation = () => tsLibDir;
|
|
238920
|
-
host.getDefaultLibFileName = (options) => (0,
|
|
238956
|
+
host.getDefaultLibFileName = (options) => (0, import_node_path3.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options));
|
|
238921
238957
|
host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
238922
238958
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238923
238959
|
if (source === void 0) {
|
|
@@ -238925,7 +238961,7 @@ function patchHost(host, fileFilter) {
|
|
|
238925
238961
|
}
|
|
238926
238962
|
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source)) {
|
|
238927
238963
|
if (!fileFilter || fileFilter(fileName)) {
|
|
238928
|
-
const transformed = transformJsonSchemas(fileName, source);
|
|
238964
|
+
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238929
238965
|
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238930
238966
|
}
|
|
238931
238967
|
}
|
|
@@ -238934,15 +238970,15 @@ function patchHost(host, fileFilter) {
|
|
|
238934
238970
|
}
|
|
238935
238971
|
__name(patchHost, "patchHost");
|
|
238936
238972
|
function createThinkwellWatchHost(options) {
|
|
238937
|
-
const { configPath, fileFilter, reportDiagnostic, reportWatchStatus } = options;
|
|
238973
|
+
const { configPath, fileFilter, projectDir, reportDiagnostic, reportWatchStatus } = options;
|
|
238938
238974
|
const createProgram = /* @__PURE__ */ __name((rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
238939
238975
|
if (host) {
|
|
238940
|
-
patchHost(host, fileFilter);
|
|
238976
|
+
patchHost(host, fileFilter, projectDir);
|
|
238941
238977
|
}
|
|
238942
238978
|
return import_typescript2.default.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
238943
238979
|
}, "createProgram");
|
|
238944
238980
|
return import_typescript2.default.createWatchCompilerHost(
|
|
238945
|
-
(0,
|
|
238981
|
+
(0, import_node_path3.resolve)(configPath),
|
|
238946
238982
|
/* optionsToExtend */
|
|
238947
238983
|
void 0,
|
|
238948
238984
|
import_typescript2.default.sys,
|
|
@@ -238962,6 +238998,9 @@ var whiteBold = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)(["
|
|
|
238962
238998
|
var dim = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)("dim", t), "dim");
|
|
238963
238999
|
|
|
238964
239000
|
// dist/cli/commands.js
|
|
239001
|
+
var import_node_fs3 = require("node:fs");
|
|
239002
|
+
var import_node_path4 = require("node:path");
|
|
239003
|
+
var import_node_os = require("node:os");
|
|
238965
239004
|
var import_node_util2 = require("node:util");
|
|
238966
239005
|
var redBold = /* @__PURE__ */ __name((t) => (0, import_node_util2.styleText)(["red", "bold"], t), "redBold");
|
|
238967
239006
|
function fmtError(message) {
|
|
@@ -238970,13 +239009,13 @@ function fmtError(message) {
|
|
|
238970
239009
|
__name(fmtError, "fmtError");
|
|
238971
239010
|
|
|
238972
239011
|
// dist/cli/dependency-check.js
|
|
238973
|
-
var
|
|
238974
|
-
var
|
|
239012
|
+
var import_node_fs5 = require("node:fs");
|
|
239013
|
+
var import_node_path6 = require("node:path");
|
|
238975
239014
|
var import_node_child_process = require("node:child_process");
|
|
238976
239015
|
|
|
238977
239016
|
// dist/cli/package-manager.js
|
|
238978
|
-
var
|
|
238979
|
-
var
|
|
239017
|
+
var import_node_fs4 = require("node:fs");
|
|
239018
|
+
var import_node_path5 = require("node:path");
|
|
238980
239019
|
var LOCKFILES = [
|
|
238981
239020
|
{ file: "pnpm-lock.yaml", pm: "pnpm" },
|
|
238982
239021
|
{ file: "yarn.lock", pm: "yarn" },
|
|
@@ -238984,8 +239023,8 @@ var LOCKFILES = [
|
|
|
238984
239023
|
];
|
|
238985
239024
|
function detectByLockfile(projectDir) {
|
|
238986
239025
|
for (const { file, pm } of LOCKFILES) {
|
|
238987
|
-
const lockfilePath = (0,
|
|
238988
|
-
if ((0,
|
|
239026
|
+
const lockfilePath = (0, import_node_path5.join)(projectDir, file);
|
|
239027
|
+
if ((0, import_node_fs4.existsSync)(lockfilePath)) {
|
|
238989
239028
|
return { pm, lockfile: file };
|
|
238990
239029
|
}
|
|
238991
239030
|
}
|
|
@@ -239005,12 +239044,12 @@ function parsePackageManagerField(value) {
|
|
|
239005
239044
|
}
|
|
239006
239045
|
__name(parsePackageManagerField, "parsePackageManagerField");
|
|
239007
239046
|
function detectByPackageJson(projectDir) {
|
|
239008
|
-
const pkgPath = (0,
|
|
239009
|
-
if (!(0,
|
|
239047
|
+
const pkgPath = (0, import_node_path5.join)(projectDir, "package.json");
|
|
239048
|
+
if (!(0, import_node_fs4.existsSync)(pkgPath)) {
|
|
239010
239049
|
return null;
|
|
239011
239050
|
}
|
|
239012
239051
|
try {
|
|
239013
|
-
const content = (0,
|
|
239052
|
+
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8");
|
|
239014
239053
|
const pkg = JSON.parse(content);
|
|
239015
239054
|
return parsePackageManagerField(pkg.packageManager);
|
|
239016
239055
|
} catch {
|
|
@@ -239060,12 +239099,12 @@ __name(detectPackageManager, "detectPackageManager");
|
|
|
239060
239099
|
|
|
239061
239100
|
// dist/cli/dependency-check.js
|
|
239062
239101
|
function readPackageJson(dir) {
|
|
239063
|
-
const pkgPath = (0,
|
|
239064
|
-
if (!(0,
|
|
239102
|
+
const pkgPath = (0, import_node_path6.join)(dir, "package.json");
|
|
239103
|
+
if (!(0, import_node_fs5.existsSync)(pkgPath)) {
|
|
239065
239104
|
return null;
|
|
239066
239105
|
}
|
|
239067
239106
|
try {
|
|
239068
|
-
const content = (0,
|
|
239107
|
+
const content = (0, import_node_fs5.readFileSync)(pkgPath, "utf-8");
|
|
239069
239108
|
return JSON.parse(content);
|
|
239070
239109
|
} catch {
|
|
239071
239110
|
return null;
|
|
@@ -239231,7 +239270,7 @@ async function checkDependencies(projectDir) {
|
|
|
239231
239270
|
}
|
|
239232
239271
|
__name(checkDependencies, "checkDependencies");
|
|
239233
239272
|
function hasPackageJson(projectDir) {
|
|
239234
|
-
return (0,
|
|
239273
|
+
return (0, import_node_fs5.existsSync)((0, import_node_path6.join)(projectDir, "package.json"));
|
|
239235
239274
|
}
|
|
239236
239275
|
__name(hasPackageJson, "hasPackageJson");
|
|
239237
239276
|
|
|
@@ -239274,12 +239313,12 @@ __name(hasMissingDependencies, "hasMissingDependencies");
|
|
|
239274
239313
|
|
|
239275
239314
|
// dist/cli/build.js
|
|
239276
239315
|
function readPackageJsonConfig(dir) {
|
|
239277
|
-
const pkgPath = (0,
|
|
239278
|
-
if (!(0,
|
|
239316
|
+
const pkgPath = (0, import_node_path7.join)(dir, "package.json");
|
|
239317
|
+
if (!(0, import_node_fs6.existsSync)(pkgPath)) {
|
|
239279
239318
|
return void 0;
|
|
239280
239319
|
}
|
|
239281
239320
|
try {
|
|
239282
|
-
const content = (0,
|
|
239321
|
+
const content = (0, import_node_fs6.readFileSync)(pkgPath, "utf-8");
|
|
239283
239322
|
const pkg = JSON.parse(content);
|
|
239284
239323
|
const config = pkg?.thinkwell?.build;
|
|
239285
239324
|
if (!config || typeof config !== "object") {
|
|
@@ -239309,13 +239348,13 @@ function createFileFilter(config) {
|
|
|
239309
239348
|
return (fileName) => {
|
|
239310
239349
|
if (hasExclude) {
|
|
239311
239350
|
for (const pattern of exclude) {
|
|
239312
|
-
if ((0,
|
|
239351
|
+
if ((0, import_node_path7.matchesGlob)(fileName, pattern))
|
|
239313
239352
|
return false;
|
|
239314
239353
|
}
|
|
239315
239354
|
}
|
|
239316
239355
|
if (hasInclude) {
|
|
239317
239356
|
for (const pattern of include) {
|
|
239318
|
-
if ((0,
|
|
239357
|
+
if ((0, import_node_path7.matchesGlob)(fileName, pattern))
|
|
239319
239358
|
return true;
|
|
239320
239359
|
}
|
|
239321
239360
|
return false;
|
|
@@ -239344,8 +239383,8 @@ async function runBuild(options) {
|
|
|
239344
239383
|
process.exit(2);
|
|
239345
239384
|
}
|
|
239346
239385
|
}
|
|
239347
|
-
const configPath = options.project ? (0,
|
|
239348
|
-
if (!(0,
|
|
239386
|
+
const configPath = options.project ? (0, import_node_path7.resolve)(cwd, options.project) : (0, import_node_path7.resolve)(cwd, "tsconfig.json");
|
|
239387
|
+
if (!(0, import_node_fs6.existsSync)(configPath)) {
|
|
239349
239388
|
console.error(fmtError(`Cannot find ${options.project ?? "tsconfig.json"}`));
|
|
239350
239389
|
console.error("");
|
|
239351
239390
|
console.error(" Run this command from a directory with a tsconfig.json,");
|
|
@@ -239362,10 +239401,11 @@ async function runBuild(options) {
|
|
|
239362
239401
|
console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`);
|
|
239363
239402
|
}
|
|
239364
239403
|
}
|
|
239404
|
+
const projectDir = hasPackageJson(cwd) ? cwd : void 0;
|
|
239365
239405
|
if (options.watch) {
|
|
239366
|
-
return runWatch(configPath, fileFilter);
|
|
239406
|
+
return runWatch(configPath, fileFilter, projectDir);
|
|
239367
239407
|
}
|
|
239368
|
-
const { program, configErrors } = fileFilter ? createThinkwellProgram({ configPath, fileFilter }) : createThinkwellProgram(configPath);
|
|
239408
|
+
const { program, configErrors } = fileFilter || projectDir ? createThinkwellProgram({ configPath, fileFilter, projectDir }) : createThinkwellProgram(configPath);
|
|
239369
239409
|
if (configErrors.length > 0) {
|
|
239370
239410
|
console.error(formatDiagnostics(configErrors));
|
|
239371
239411
|
const hasFatal = configErrors.some((d) => d.category === import_typescript3.default.DiagnosticCategory.Error);
|
|
@@ -239394,7 +239434,7 @@ async function runBuild(options) {
|
|
|
239394
239434
|
}
|
|
239395
239435
|
}
|
|
239396
239436
|
__name(runBuild, "runBuild");
|
|
239397
|
-
function runWatch(configPath, fileFilter) {
|
|
239437
|
+
function runWatch(configPath, fileFilter, projectDir) {
|
|
239398
239438
|
const reportDiagnostic = /* @__PURE__ */ __name((diagnostic) => {
|
|
239399
239439
|
console.error(import_typescript3.default.formatDiagnosticsWithColorAndContext([diagnostic], diagnosticsHost));
|
|
239400
239440
|
}, "reportDiagnostic");
|
|
@@ -239404,6 +239444,7 @@ function runWatch(configPath, fileFilter) {
|
|
|
239404
239444
|
const watchHost = createThinkwellWatchHost({
|
|
239405
239445
|
configPath,
|
|
239406
239446
|
fileFilter,
|
|
239447
|
+
projectDir,
|
|
239407
239448
|
reportDiagnostic,
|
|
239408
239449
|
reportWatchStatus
|
|
239409
239450
|
});
|