@atscript/typescript 0.1.77 → 0.1.78
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/dist/cli.cjs +51 -13
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{json-schema-CeDOlb_F.cjs → json-schema-3mti4G4J.cjs} +15 -13
- package/dist/{json-schema-Bq1dwNoo.mjs → json-schema-B64qclVa.mjs} +15 -13
- package/dist/{plugin-nPmWdkR5.cjs → plugin-Dpxtfrdy.cjs} +1 -1
- package/dist/{plugin-Bmibxc6X.mjs → plugin-MGtqc_Ev.mjs} +1 -1
- package/dist/test-utils.cjs +2 -2
- package/dist/test-utils.mjs +2 -2
- package/dist/utils.cjs +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -1174,8 +1174,45 @@ else metadata.set(key, [a, value]);
|
|
|
1174
1174
|
} else metadata.set(key, [value]);
|
|
1175
1175
|
else metadata.set(key, value);
|
|
1176
1176
|
}
|
|
1177
|
+
function cloneTypeDef(type) {
|
|
1178
|
+
if (type.kind === "object") {
|
|
1179
|
+
const obj = type;
|
|
1180
|
+
const props = new Map();
|
|
1181
|
+
for (const [k, v] of obj.props) props.set(k, createAnnotatedTypeNode(v.type, new Map(v.metadata), {
|
|
1182
|
+
id: v.id,
|
|
1183
|
+
optional: v.optional
|
|
1184
|
+
}));
|
|
1185
|
+
return {
|
|
1186
|
+
kind: "object",
|
|
1187
|
+
props,
|
|
1188
|
+
propsPatterns: [...obj.propsPatterns],
|
|
1189
|
+
tags: new Set(obj.tags)
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
if (type.kind === "array") {
|
|
1193
|
+
const arr = type;
|
|
1194
|
+
return {
|
|
1195
|
+
kind: "array",
|
|
1196
|
+
of: arr.of,
|
|
1197
|
+
tags: new Set(arr.tags)
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
if (type.kind === "union" || type.kind === "intersection" || type.kind === "tuple") {
|
|
1201
|
+
const complex = type;
|
|
1202
|
+
return {
|
|
1203
|
+
kind: type.kind,
|
|
1204
|
+
items: [...complex.items],
|
|
1205
|
+
tags: new Set(complex.tags)
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
return {
|
|
1209
|
+
...type,
|
|
1210
|
+
tags: new Set(type.tags)
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1177
1213
|
function defineAnnotatedType(_kind, base) {
|
|
1178
1214
|
const kind = _kind || "";
|
|
1215
|
+
const baseProvided = base !== undefined;
|
|
1179
1216
|
const type = base?.type || {};
|
|
1180
1217
|
type.kind = kind;
|
|
1181
1218
|
if (COMPLEX_KINDS.has(kind)) type.items = [];
|
|
@@ -1236,6 +1273,7 @@ function defineAnnotatedType(_kind, base) {
|
|
|
1236
1273
|
return this;
|
|
1237
1274
|
},
|
|
1238
1275
|
refTo(type$1, chain) {
|
|
1276
|
+
const node = this.$type;
|
|
1239
1277
|
if (isAnnotatedType(type$1)) {
|
|
1240
1278
|
let newBase = type$1;
|
|
1241
1279
|
const typeName = type$1.name || "Unknown";
|
|
@@ -1247,20 +1285,19 @@ else {
|
|
|
1247
1285
|
throw new Error(`Can't find prop ${typeName}${keys}`);
|
|
1248
1286
|
}
|
|
1249
1287
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
});
|
|
1288
|
+
node.type = baseProvided ? cloneTypeDef(newBase.type) : newBase.type;
|
|
1289
|
+
node.id = node.id ?? newBase.id;
|
|
1290
|
+
if (chain && chain.length > 0) node.ref = {
|
|
1291
|
+
type: () => type$1,
|
|
1292
|
+
field: chain.join(".")
|
|
1293
|
+
};
|
|
1257
1294
|
} else if (typeof type$1 === "function") {
|
|
1258
1295
|
const lazyType = type$1;
|
|
1259
|
-
|
|
1296
|
+
const ownId = node.id;
|
|
1297
|
+
node.ref = {
|
|
1260
1298
|
type: lazyType,
|
|
1261
1299
|
field: chain ? chain.join(".") : ""
|
|
1262
|
-
}
|
|
1263
|
-
const node = this.$type;
|
|
1300
|
+
};
|
|
1264
1301
|
const placeholder = node.type;
|
|
1265
1302
|
Object.defineProperty(node, "type", {
|
|
1266
1303
|
get() {
|
|
@@ -1276,13 +1313,14 @@ else {
|
|
|
1276
1313
|
let target = t;
|
|
1277
1314
|
if (chain) for (const c of chain) if (target.type.kind === "object" && target.type.props.has(c)) target = target.type.props.get(c);
|
|
1278
1315
|
else return t.type;
|
|
1279
|
-
node.id =
|
|
1316
|
+
node.id = ownId ?? target.id;
|
|
1317
|
+
const resolved = baseProvided ? cloneTypeDef(target.type) : target.type;
|
|
1280
1318
|
Object.defineProperty(node, "type", {
|
|
1281
|
-
value:
|
|
1319
|
+
value: resolved,
|
|
1282
1320
|
writable: false,
|
|
1283
1321
|
configurable: true
|
|
1284
1322
|
});
|
|
1285
|
-
return
|
|
1323
|
+
return resolved;
|
|
1286
1324
|
},
|
|
1287
1325
|
configurable: true
|
|
1288
1326
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_plugin = require('./plugin-
|
|
3
|
-
require('./json-schema-
|
|
2
|
+
const require_plugin = require('./plugin-Dpxtfrdy.cjs');
|
|
3
|
+
require('./json-schema-3mti4G4J.cjs');
|
|
4
4
|
|
|
5
5
|
exports.default = require_plugin.tsPlugin
|
|
6
6
|
exports.tsPlugin = require_plugin.tsPlugin
|
package/dist/index.mjs
CHANGED
|
@@ -549,6 +549,7 @@ function cloneTypeDef(type) {
|
|
|
549
549
|
}
|
|
550
550
|
function defineAnnotatedType(_kind, base) {
|
|
551
551
|
const kind = _kind || "";
|
|
552
|
+
const baseProvided = base !== undefined;
|
|
552
553
|
const type = base?.type || {};
|
|
553
554
|
type.kind = kind;
|
|
554
555
|
if (COMPLEX_KINDS.has(kind)) type.items = [];
|
|
@@ -609,6 +610,7 @@ function defineAnnotatedType(_kind, base) {
|
|
|
609
610
|
return this;
|
|
610
611
|
},
|
|
611
612
|
refTo(type$1, chain) {
|
|
613
|
+
const node = this.$type;
|
|
612
614
|
if (isAnnotatedType(type$1)) {
|
|
613
615
|
let newBase = type$1;
|
|
614
616
|
const typeName = type$1.name || "Unknown";
|
|
@@ -620,20 +622,19 @@ else {
|
|
|
620
622
|
throw new Error(`Can't find prop ${typeName}${keys}`);
|
|
621
623
|
}
|
|
622
624
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
});
|
|
625
|
+
node.type = baseProvided ? cloneTypeDef(newBase.type) : newBase.type;
|
|
626
|
+
node.id = node.id ?? newBase.id;
|
|
627
|
+
if (chain && chain.length > 0) node.ref = {
|
|
628
|
+
type: () => type$1,
|
|
629
|
+
field: chain.join(".")
|
|
630
|
+
};
|
|
630
631
|
} else if (typeof type$1 === "function") {
|
|
631
632
|
const lazyType = type$1;
|
|
632
|
-
|
|
633
|
+
const ownId = node.id;
|
|
634
|
+
node.ref = {
|
|
633
635
|
type: lazyType,
|
|
634
636
|
field: chain ? chain.join(".") : ""
|
|
635
|
-
}
|
|
636
|
-
const node = this.$type;
|
|
637
|
+
};
|
|
637
638
|
const placeholder = node.type;
|
|
638
639
|
Object.defineProperty(node, "type", {
|
|
639
640
|
get() {
|
|
@@ -649,13 +650,14 @@ else {
|
|
|
649
650
|
let target = t;
|
|
650
651
|
if (chain) for (const c of chain) if (target.type.kind === "object" && target.type.props.has(c)) target = target.type.props.get(c);
|
|
651
652
|
else return t.type;
|
|
652
|
-
node.id =
|
|
653
|
+
node.id = ownId ?? target.id;
|
|
654
|
+
const resolved = baseProvided ? cloneTypeDef(target.type) : target.type;
|
|
653
655
|
Object.defineProperty(node, "type", {
|
|
654
|
-
value:
|
|
656
|
+
value: resolved,
|
|
655
657
|
writable: false,
|
|
656
658
|
configurable: true
|
|
657
659
|
});
|
|
658
|
-
return
|
|
660
|
+
return resolved;
|
|
659
661
|
},
|
|
660
662
|
configurable: true
|
|
661
663
|
});
|
|
@@ -548,6 +548,7 @@ function cloneTypeDef(type) {
|
|
|
548
548
|
}
|
|
549
549
|
function defineAnnotatedType(_kind, base) {
|
|
550
550
|
const kind = _kind || "";
|
|
551
|
+
const baseProvided = base !== undefined;
|
|
551
552
|
const type = base?.type || {};
|
|
552
553
|
type.kind = kind;
|
|
553
554
|
if (COMPLEX_KINDS.has(kind)) type.items = [];
|
|
@@ -608,6 +609,7 @@ function defineAnnotatedType(_kind, base) {
|
|
|
608
609
|
return this;
|
|
609
610
|
},
|
|
610
611
|
refTo(type$1, chain) {
|
|
612
|
+
const node = this.$type;
|
|
611
613
|
if (isAnnotatedType(type$1)) {
|
|
612
614
|
let newBase = type$1;
|
|
613
615
|
const typeName = type$1.name || "Unknown";
|
|
@@ -619,20 +621,19 @@ else {
|
|
|
619
621
|
throw new Error(`Can't find prop ${typeName}${keys}`);
|
|
620
622
|
}
|
|
621
623
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
});
|
|
624
|
+
node.type = baseProvided ? cloneTypeDef(newBase.type) : newBase.type;
|
|
625
|
+
node.id = node.id ?? newBase.id;
|
|
626
|
+
if (chain && chain.length > 0) node.ref = {
|
|
627
|
+
type: () => type$1,
|
|
628
|
+
field: chain.join(".")
|
|
629
|
+
};
|
|
629
630
|
} else if (typeof type$1 === "function") {
|
|
630
631
|
const lazyType = type$1;
|
|
631
|
-
|
|
632
|
+
const ownId = node.id;
|
|
633
|
+
node.ref = {
|
|
632
634
|
type: lazyType,
|
|
633
635
|
field: chain ? chain.join(".") : ""
|
|
634
|
-
}
|
|
635
|
-
const node = this.$type;
|
|
636
|
+
};
|
|
636
637
|
const placeholder = node.type;
|
|
637
638
|
Object.defineProperty(node, "type", {
|
|
638
639
|
get() {
|
|
@@ -648,13 +649,14 @@ else {
|
|
|
648
649
|
let target = t;
|
|
649
650
|
if (chain) for (const c of chain) if (target.type.kind === "object" && target.type.props.has(c)) target = target.type.props.get(c);
|
|
650
651
|
else return t.type;
|
|
651
|
-
node.id =
|
|
652
|
+
node.id = ownId ?? target.id;
|
|
653
|
+
const resolved = baseProvided ? cloneTypeDef(target.type) : target.type;
|
|
652
654
|
Object.defineProperty(node, "type", {
|
|
653
|
-
value:
|
|
655
|
+
value: resolved,
|
|
654
656
|
writable: false,
|
|
655
657
|
configurable: true
|
|
656
658
|
});
|
|
657
|
-
return
|
|
659
|
+
return resolved;
|
|
658
660
|
},
|
|
659
661
|
configurable: true
|
|
660
662
|
});
|
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
const require_json_schema = require('./json-schema-
|
|
25
|
+
const require_json_schema = require('./json-schema-3mti4G4J.cjs');
|
|
26
26
|
const path = __toESM(require("path"));
|
|
27
27
|
const __atscript_core = __toESM(require("@atscript/core"));
|
|
28
28
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildJsonSchema, defineAnnotatedType } from "./json-schema-
|
|
1
|
+
import { buildJsonSchema, defineAnnotatedType } from "./json-schema-B64qclVa.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { DEFAULT_FORMAT, flattenInterfaceNode, getRelPath, hasNavPropAnnotation, isArray, isBareId, isConst, isGroup, isInterface, isPrimitive, isProp, isQueryLogical, isRef, isStructure } from "@atscript/core";
|
|
4
4
|
|
package/dist/test-utils.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_plugin = require('./plugin-
|
|
3
|
-
require('./json-schema-
|
|
2
|
+
const require_plugin = require('./plugin-Dpxtfrdy.cjs');
|
|
3
|
+
require('./json-schema-3mti4G4J.cjs');
|
|
4
4
|
const path = require_plugin.__toESM(require("path"));
|
|
5
5
|
const __atscript_core = require_plugin.__toESM(require("@atscript/core"));
|
|
6
6
|
const fs = require_plugin.__toESM(require("fs"));
|
package/dist/test-utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { tsPlugin } from "./plugin-
|
|
2
|
-
import "./json-schema-
|
|
1
|
+
import { tsPlugin } from "./plugin-MGtqc_Ev.mjs";
|
|
2
|
+
import "./json-schema-B64qclVa.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { build } from "@atscript/core";
|
|
5
5
|
import { readFileSync, writeFileSync } from "fs";
|
package/dist/utils.cjs
CHANGED
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, detectDiscriminator, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas } from "./json-schema-
|
|
1
|
+
import { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, detectDiscriminator, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas } from "./json-schema-B64qclVa.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/typescript/src/runtime/default-value.ts
|
|
4
4
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/typescript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.78",
|
|
4
4
|
"description": "Atscript: typescript-gen support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"./package.json": "./package.json"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@moostjs/event-cli": "^0.6.
|
|
67
|
-
"moost": "^0.6.
|
|
66
|
+
"@moostjs/event-cli": "^0.6.28",
|
|
67
|
+
"moost": "^0.6.28"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@atscript/db": "^0.1.97",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@atscript/db": "^0.1.97",
|
|
76
|
-
"@atscript/core": "^0.1.
|
|
76
|
+
"@atscript/core": "^0.1.78"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@atscript/db": {
|