@atscript/typescript 0.1.52 → 0.1.53
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 +1 -7
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{json-schema-DrJMwvm1.mjs → json-schema-D_wrIxzk.mjs} +2 -8
- package/dist/{json-schema-BgW_S2sP.cjs → json-schema-Zi4TJzJJ.cjs} +7 -7
- package/dist/{plugin-otL5yA8s.cjs → plugin-C90RBCnx.cjs} +1 -1
- package/dist/{plugin-C_5DTxz9.mjs → plugin-PADgal82.mjs} +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 +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1320,13 +1320,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
1320
1320
|
|
|
1321
1321
|
//#endregion
|
|
1322
1322
|
//#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) {
|
|
1323
|
+
function detectDiscriminator(items) {
|
|
1330
1324
|
if (items.length < 2) return null;
|
|
1331
1325
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
1332
1326
|
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-C90RBCnx.cjs');
|
|
3
|
+
require('./json-schema-Zi4TJzJJ.cjs');
|
|
4
4
|
|
|
5
5
|
exports.default = require_plugin.tsPlugin
|
|
6
6
|
exports.tsPlugin = require_plugin.tsPlugin
|
package/dist/index.mjs
CHANGED
|
@@ -701,13 +701,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
701
701
|
|
|
702
702
|
//#endregion
|
|
703
703
|
//#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) {
|
|
704
|
+
function detectDiscriminator(items) {
|
|
711
705
|
if (items.length < 2) return null;
|
|
712
706
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
713
707
|
const firstObj = items[0].type;
|
|
@@ -978,4 +972,4 @@ function mergeJsonSchemas(types) {
|
|
|
978
972
|
}
|
|
979
973
|
|
|
980
974
|
//#endregion
|
|
981
|
-
export { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas };
|
|
975
|
+
export { Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, createAnnotatedTypeNode, defineAnnotatedType, detectDiscriminator, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas };
|
|
@@ -702,13 +702,7 @@ function forAnnotatedType(def, handlers) {
|
|
|
702
702
|
|
|
703
703
|
//#endregion
|
|
704
704
|
//#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) {
|
|
705
|
+
function detectDiscriminator(items) {
|
|
712
706
|
if (items.length < 2) return null;
|
|
713
707
|
for (const item of items) if (item.type.kind !== "object") return null;
|
|
714
708
|
const firstObj = items[0].type;
|
|
@@ -1021,6 +1015,12 @@ Object.defineProperty(exports, 'defineAnnotatedType', {
|
|
|
1021
1015
|
return defineAnnotatedType;
|
|
1022
1016
|
}
|
|
1023
1017
|
});
|
|
1018
|
+
Object.defineProperty(exports, 'detectDiscriminator', {
|
|
1019
|
+
enumerable: true,
|
|
1020
|
+
get: function () {
|
|
1021
|
+
return detectDiscriminator;
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
1024
|
Object.defineProperty(exports, 'forAnnotatedType', {
|
|
1025
1025
|
enumerable: true,
|
|
1026
1026
|
get: function () {
|
|
@@ -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-Zi4TJzJJ.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-D_wrIxzk.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-C90RBCnx.cjs');
|
|
3
|
+
require('./json-schema-Zi4TJzJJ.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-PADgal82.mjs";
|
|
2
|
+
import "./json-schema-D_wrIxzk.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-Zi4TJzJJ.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-D_wrIxzk.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.53",
|
|
4
4
|
"description": "Atscript: typescript-gen support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@atscript/db": "^0.1.48",
|
|
76
|
-
"@atscript/core": "^0.1.
|
|
76
|
+
"@atscript/core": "^0.1.53"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@atscript/db": {
|