@atscript/typescript 0.1.52 → 0.1.54
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 +5 -7
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{json-schema-DrJMwvm1.mjs → json-schema-Bq1dwNoo.mjs} +6 -8
- package/dist/{json-schema-BgW_S2sP.cjs → json-schema-CeDOlb_F.cjs} +11 -7
- package/dist/{plugin-C_5DTxz9.mjs → plugin-Bmibxc6X.mjs} +1 -1
- package/dist/{plugin-otL5yA8s.cjs → plugin-nPmWdkR5.cjs} +1 -1
- package/dist/test-utils.cjs +2 -2
- package/dist/test-utils.mjs +2 -2
- package/dist/utils.cjs +2 -1
- package/dist/utils.d.ts +24 -2
- package/dist/utils.mjs +2 -2
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -1012,6 +1012,10 @@ else {
|
|
|
1012
1012
|
this.error(`Expected string (decimal), got ${typeOfValue}`);
|
|
1013
1013
|
return false;
|
|
1014
1014
|
}
|
|
1015
|
+
if (!/^[+-]?\d+(\.\d+)?$/.test(value)) {
|
|
1016
|
+
this.error(`Invalid decimal format: ${JSON.stringify(value)}`);
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
|
1015
1019
|
return true;
|
|
1016
1020
|
}
|
|
1017
1021
|
default: throw new Error(`Unknown type "${def.type.designType}"`);
|
|
@@ -1320,13 +1324,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
1320
1324
|
|
|
1321
1325
|
//#endregion
|
|
1322
1326
|
//#region packages/typescript/src/runtime/json-schema.ts
|
|
1323
|
-
|
|
1324
|
-
* Detects a discriminator property across union items.
|
|
1325
|
-
*
|
|
1326
|
-
* Scans all items for object-typed members that share a common property
|
|
1327
|
-
* with distinct const/literal values. If exactly one such property exists,
|
|
1328
|
-
* it is returned as the discriminator.
|
|
1329
|
-
*/ function detectDiscriminator(items) {
|
|
1327
|
+
function detectDiscriminator(items) {
|
|
1330
1328
|
if (items.length < 2) return null;
|
|
1331
1329
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
1332
1330
|
const firstObj = items[0].type;
|
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-nPmWdkR5.cjs');
|
|
3
|
+
require('./json-schema-CeDOlb_F.cjs');
|
|
4
4
|
|
|
5
5
|
exports.default = require_plugin.tsPlugin
|
|
6
6
|
exports.tsPlugin = require_plugin.tsPlugin
|
package/dist/index.mjs
CHANGED
|
@@ -336,6 +336,10 @@ else {
|
|
|
336
336
|
this.error(`Expected string (decimal), got ${typeOfValue}`);
|
|
337
337
|
return false;
|
|
338
338
|
}
|
|
339
|
+
if (!/^[+-]?\d+(\.\d+)?$/.test(value)) {
|
|
340
|
+
this.error(`Invalid decimal format: ${JSON.stringify(value)}`);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
339
343
|
return true;
|
|
340
344
|
}
|
|
341
345
|
default: throw new Error(`Unknown type "${def.type.designType}"`);
|
|
@@ -701,13 +705,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
701
705
|
|
|
702
706
|
//#endregion
|
|
703
707
|
//#region packages/typescript/src/runtime/json-schema.ts
|
|
704
|
-
|
|
705
|
-
* Detects a discriminator property across union items.
|
|
706
|
-
*
|
|
707
|
-
* Scans all items for object-typed members that share a common property
|
|
708
|
-
* with distinct const/literal values. If exactly one such property exists,
|
|
709
|
-
* it is returned as the discriminator.
|
|
710
|
-
*/ function detectDiscriminator(items) {
|
|
708
|
+
function detectDiscriminator(items) {
|
|
711
709
|
if (items.length < 2) return null;
|
|
712
710
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
713
711
|
const firstObj = items[0].type;
|
|
@@ -978,4 +976,4 @@ function mergeJsonSchemas(types) {
|
|
|
978
976
|
}
|
|
979
977
|
|
|
980
978
|
//#endregion
|
|
981
|
-
export { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas };
|
|
979
|
+
export { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, detectDiscriminator, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas };
|
|
@@ -337,6 +337,10 @@ else {
|
|
|
337
337
|
this.error(`Expected string (decimal), got ${typeOfValue}`);
|
|
338
338
|
return false;
|
|
339
339
|
}
|
|
340
|
+
if (!/^[+-]?\d+(\.\d+)?$/.test(value)) {
|
|
341
|
+
this.error(`Invalid decimal format: ${JSON.stringify(value)}`);
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
340
344
|
return true;
|
|
341
345
|
}
|
|
342
346
|
default: throw new Error(`Unknown type "${def.type.designType}"`);
|
|
@@ -702,13 +706,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
702
706
|
|
|
703
707
|
//#endregion
|
|
704
708
|
//#region packages/typescript/src/runtime/json-schema.ts
|
|
705
|
-
|
|
706
|
-
* Detects a discriminator property across union items.
|
|
707
|
-
*
|
|
708
|
-
* Scans all items for object-typed members that share a common property
|
|
709
|
-
* with distinct const/literal values. If exactly one such property exists,
|
|
710
|
-
* it is returned as the discriminator.
|
|
711
|
-
*/ function detectDiscriminator(items) {
|
|
709
|
+
function detectDiscriminator(items) {
|
|
712
710
|
if (items.length < 2) return null;
|
|
713
711
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
714
712
|
const firstObj = items[0].type;
|
|
@@ -1021,6 +1019,12 @@ Object.defineProperty(exports, 'defineAnnotatedType', {
|
|
|
1021
1019
|
return defineAnnotatedType;
|
|
1022
1020
|
}
|
|
1023
1021
|
});
|
|
1022
|
+
Object.defineProperty(exports, 'detectDiscriminator', {
|
|
1023
|
+
enumerable: true,
|
|
1024
|
+
get: function () {
|
|
1025
|
+
return detectDiscriminator;
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1024
1028
|
Object.defineProperty(exports, 'forAnnotatedType', {
|
|
1025
1029
|
enumerable: true,
|
|
1026
1030
|
get: function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildJsonSchema, defineAnnotatedType } from "./json-schema-
|
|
1
|
+
import { buildJsonSchema, defineAnnotatedType } from "./json-schema-Bq1dwNoo.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
|
|
|
@@ -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-CeDOlb_F.cjs');
|
|
26
26
|
const path = __toESM(require("path"));
|
|
27
27
|
const __atscript_core = __toESM(require("@atscript/core"));
|
|
28
28
|
|
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-nPmWdkR5.cjs');
|
|
3
|
+
require('./json-schema-CeDOlb_F.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-Bmibxc6X.mjs";
|
|
2
|
+
import "./json-schema-Bq1dwNoo.mjs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { build } from "@atscript/core";
|
|
5
5
|
import { writeFileSync } from "fs";
|
package/dist/utils.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_json_schema = require('./json-schema-
|
|
2
|
+
const require_json_schema = require('./json-schema-CeDOlb_F.cjs');
|
|
3
3
|
|
|
4
4
|
//#region packages/typescript/src/runtime/default-value.ts
|
|
5
5
|
/**
|
|
@@ -471,6 +471,7 @@ exports.createAnnotatedTypeNode = require_json_schema.createAnnotatedTypeNode
|
|
|
471
471
|
exports.createDataFromAnnotatedType = createDataFromAnnotatedType
|
|
472
472
|
exports.defineAnnotatedType = require_json_schema.defineAnnotatedType
|
|
473
473
|
exports.deserializeAnnotatedType = deserializeAnnotatedType
|
|
474
|
+
exports.detectDiscriminator = require_json_schema.detectDiscriminator
|
|
474
475
|
exports.flattenAnnotatedType = flattenAnnotatedType
|
|
475
476
|
exports.forAnnotatedType = require_json_schema.forAnnotatedType
|
|
476
477
|
exports.fromJsonSchema = require_json_schema.fromJsonSchema
|
package/dist/utils.d.ts
CHANGED
|
@@ -292,6 +292,28 @@ declare function isAnnotatedTypeOfPrimitive(t: TAtscriptAnnotatedType): boolean;
|
|
|
292
292
|
|
|
293
293
|
/** A JSON Schema object (draft-compatible). */
|
|
294
294
|
type TJsonSchema = Record<string, any>;
|
|
295
|
+
/**
|
|
296
|
+
* Describes a discriminator property shared by all variants of a union.
|
|
297
|
+
*
|
|
298
|
+
* Returned by {@link detectDiscriminator} when a union qualifies as a
|
|
299
|
+
* discriminated (a.k.a. tagged) union — every variant is an object that
|
|
300
|
+
* carries the same literal-valued property with a distinct value.
|
|
301
|
+
*/
|
|
302
|
+
type TUnionDiscriminator = {
|
|
303
|
+
/** Name of the discriminator property shared by all variants. */
|
|
304
|
+
propertyName: string;
|
|
305
|
+
/** Maps the literal value of `propertyName` → variant index in `items`. */
|
|
306
|
+
indexMapping: Record<string, number>;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Detects a discriminator property across union items.
|
|
310
|
+
*
|
|
311
|
+
* Scans all items for object-typed members that share a common property
|
|
312
|
+
* with distinct const/literal values. If exactly one such property exists,
|
|
313
|
+
* it is returned as the discriminator. Returns `null` when no qualifying
|
|
314
|
+
* property exists, or when more than one does (ambiguous).
|
|
315
|
+
*/
|
|
316
|
+
declare function detectDiscriminator(items: TAtscriptAnnotatedType[]): TUnionDiscriminator | null;
|
|
295
317
|
/**
|
|
296
318
|
* Builds a JSON Schema from an {@link TAtscriptAnnotatedType}.
|
|
297
319
|
*
|
|
@@ -644,5 +666,5 @@ type NavPropsOf<T> = T extends {
|
|
|
644
666
|
__navProps: infer N extends Record<string, unknown>;
|
|
645
667
|
} ? N : Record<string, never>;
|
|
646
668
|
|
|
647
|
-
export { SERIALIZE_VERSION, Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, createDataFromAnnotatedType, defineAnnotatedType, deserializeAnnotatedType, flattenAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas, serializeAnnotatedType, throwFeatureDisabled };
|
|
648
|
-
export type { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryNode, AtscriptRef, FlatOf, InferDataType, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAnnotatedTypeHandle, TAtscriptAnnotatedType, TAtscriptAnnotatedTypeConstructor, TAtscriptDataType, TAtscriptTypeArray, TAtscriptTypeComplex, TAtscriptTypeDef, TAtscriptTypeFinal, TAtscriptTypeObject, TCreateDataOptions, TFlattenOptions, TJsonSchema, TMetadataMap, TProcessAnnotationContext, TSerializeOptions, TSerializedAnnotatedType, TSerializedAnnotatedTypeInner, TSerializedTypeArray, TSerializedTypeComplex, TSerializedTypeDef, TSerializedTypeFinal, TSerializedTypeObject, TValidatorOptions, TValidatorPlugin, TValidatorPluginContext, TValueResolver };
|
|
669
|
+
export { SERIALIZE_VERSION, Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, createDataFromAnnotatedType, defineAnnotatedType, deserializeAnnotatedType, detectDiscriminator, flattenAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas, serializeAnnotatedType, throwFeatureDisabled };
|
|
670
|
+
export type { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryNode, AtscriptRef, FlatOf, InferDataType, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAnnotatedTypeHandle, TAtscriptAnnotatedType, TAtscriptAnnotatedTypeConstructor, TAtscriptDataType, TAtscriptTypeArray, TAtscriptTypeComplex, TAtscriptTypeDef, TAtscriptTypeFinal, TAtscriptTypeObject, TCreateDataOptions, TFlattenOptions, TJsonSchema, TMetadataMap, TProcessAnnotationContext, TSerializeOptions, TSerializedAnnotatedType, TSerializedAnnotatedTypeInner, TSerializedTypeArray, TSerializedTypeComplex, TSerializedTypeDef, TSerializedTypeFinal, TSerializedTypeObject, TUnionDiscriminator, TValidatorOptions, TValidatorPlugin, TValidatorPluginContext, TValueResolver };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, 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-Bq1dwNoo.mjs";
|
|
2
2
|
|
|
3
3
|
//#region packages/typescript/src/runtime/default-value.ts
|
|
4
4
|
/**
|
|
@@ -460,4 +460,4 @@ function deserializeTypeDef(t, resolved) {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
//#endregion
|
|
463
|
-
export { SERIALIZE_VERSION, Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, createDataFromAnnotatedType, defineAnnotatedType, deserializeAnnotatedType, flattenAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas, serializeAnnotatedType, throwFeatureDisabled };
|
|
463
|
+
export { SERIALIZE_VERSION, Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, createDataFromAnnotatedType, defineAnnotatedType, deserializeAnnotatedType, detectDiscriminator, flattenAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas, serializeAnnotatedType, throwFeatureDisabled };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/typescript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"description": "Atscript: typescript-gen support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"moost": "^0.6.9"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@atscript/db": "^0.1.
|
|
70
|
+
"@atscript/db": "^0.1.74",
|
|
71
71
|
"@uniqu/core": "^0.1.6",
|
|
72
72
|
"vitest": "3.2.4"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atscript/db": "^0.1.
|
|
76
|
-
"@atscript/core": "^0.1.
|
|
75
|
+
"@atscript/db": "^0.1.74",
|
|
76
|
+
"@atscript/core": "^0.1.54"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@atscript/db": {
|