@alexify/metaschema 3.3.0 → 3.4.1

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +251 -1
  2. package/README.md +31 -20
  3. package/SECURITY.md +24 -1
  4. package/index.d.ts +280 -48
  5. package/package.json +13 -3
  6. package/src/checks.js +789 -0
  7. package/src/codec.js +37 -13
  8. package/src/coerce/index.js +34 -1
  9. package/src/compile/emit.js +87 -28
  10. package/src/compile/index.js +9 -4
  11. package/src/definition/index.d.ts +19 -0
  12. package/src/definition/index.js +27 -0
  13. package/src/derive/index.js +23 -13
  14. package/src/errors.js +23 -0
  15. package/src/generators/fromjsonschema.js +14 -0
  16. package/src/generators/index.js +1 -1
  17. package/src/generators/jsonschema.js +44 -7
  18. package/src/generators/typescript.js +11 -0
  19. package/src/index.js +3 -2
  20. package/src/issues.js +9 -7
  21. package/src/kinds.js +24 -2
  22. package/src/lint.js +64 -2
  23. package/src/locales/en.js +6 -0
  24. package/src/locales/uk.js +6 -0
  25. package/src/metadata.js +2 -24
  26. package/src/model/data.js +68 -11
  27. package/src/model/diff.js +7 -4
  28. package/src/model/index.js +1 -1
  29. package/src/model/infer.js +13 -6
  30. package/src/model/merge.js +7 -3
  31. package/src/model/restore.js +60 -8
  32. package/src/model/sample.js +26 -1
  33. package/src/model.js +25 -53
  34. package/src/mongodb/bson.js +15 -3
  35. package/src/mongodb/document.js +10 -2
  36. package/src/preprocessor.js +14 -5
  37. package/src/prototypes/abstract.js +32 -64
  38. package/src/prototypes/collections.js +3 -90
  39. package/src/prototypes/flags.js +34 -0
  40. package/src/prototypes/json.js +0 -11
  41. package/src/prototypes/reference.js +0 -76
  42. package/src/prototypes/scalars.js +17 -96
  43. package/src/prototypes/schema.js +1 -10
  44. package/src/prototypes/tuple.js +5 -31
  45. package/src/prototypes/union.js +12 -82
  46. package/src/rules.js +33 -157
  47. package/src/schema.js +108 -233
  48. package/src/snapshot.js +216 -41
  49. package/src/stream/index.js +1 -1
  50. package/src/struct.js +6 -91
  51. package/src/types.js +31 -10
  52. package/src/util.js +48 -0
  53. package/src/validation.js +313 -0
package/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export type IssueCode =
38
38
  | 'range'
39
39
  | 'pattern'
40
40
  | 'format'
41
+ | 'decimals'
41
42
  | 'union'
42
43
  | 'reference'
43
44
  | 'circular'
@@ -59,6 +60,9 @@ export interface IssueParams {
59
60
  pattern: { pattern: string };
60
61
  // The name of the format the string is not of.
61
62
  format: { format: string };
63
+ // The decimals the number may have: it has more, or it is not finite
64
+ // (`received` names NaN or the infinity then).
65
+ decimals: { decimals: number; received?: string };
62
66
  // No branch of a union matched: the branch names, or the discriminator
63
67
  // values when the union has a discriminator (the path then ends with it).
64
68
  union: { expected: unknown[]; discriminator: string | undefined };
@@ -314,7 +318,12 @@ export interface TypeMetadata {
314
318
  }
315
319
 
316
320
  // An entry of the table passed to Model: metadata for a built-in, an alias
317
- // (`js`), or a prototype with its own `construct` and `checkType`.
321
+ // (`js`), or a prototype with its own `construct` and `checkType`. A
322
+ // prototype may bring a `compile` in place of `checkType` (it returns the
323
+ // check, `(value, context, key) => void`): it runs on the first check of a
324
+ // field, not when the schema is built, so it must not be where the
325
+ // definition is checked (`construct` is); what it throws is
326
+ // ERR_INVALID_CUSTOM_TYPE with the error as the cause.
318
327
  export interface TypeEntry {
319
328
  js?: string;
320
329
  metadata?: TypeMetadata;
@@ -440,12 +449,20 @@ export type RuntimeErrorCode =
440
449
  | 'ERR_NOT_REGISTERED';
441
450
 
442
451
  // ---------------------------------------------------------------------------
443
- // The snapshot: `model.toJSON()`, what JSON.stringify(model) writes. The
444
- // entities in dependency order with a fixed key order, the types the
445
- // entities use, and the `database` metadata as given. A function is
446
- // `{ $function: true }` wherever it stands, a bigint `{ $bigint }`, a Date
447
- // `{ $date }`, a RegExp its source (or `{ source, flags }` with flags beyond
448
- // `u`). `fromJSON` of the `@alexify/metaschema/model` subpath reads it back.
452
+ // The snapshot: `model.toJSON()`, what JSON.stringify(model) writes, and
453
+ // `schema.toSnapshot()`, the same for one schema and the entities it
454
+ // reaches. The entities in dependency order with a fixed key order, the
455
+ // types the entities use, and a copy of the `database` metadata. A function
456
+ // is `{ $function: true }` wherever it stands, a bigint `{ $bigint }`, a
457
+ // Date `{ $date }`, bytes `{ $bytes }` (base64), a Map `{ $map }` (its
458
+ // entries), a Set `{ $set }` (its values), a RegExp its source (or
459
+ // `{ source, flags }` with flags beyond `u`). `fromJSON` of the `@alexify/metaschema/model` subpath reads
460
+ // it back. Format 1 is a contract: the fields of a struct come in the order
461
+ // of the definition (the id field a stored kind adds after them, unless the
462
+ // definition has a field of that name), the entities each after the ones
463
+ // they reference (`model.order` for a model, the order a walk from the
464
+ // schema meets them for one schema), and a key is only ever added to it;
465
+ // anything else is a major release.
449
466
  // ---------------------------------------------------------------------------
450
467
 
451
468
  export interface FunctionSnapshot {
@@ -453,14 +470,170 @@ export interface FunctionSnapshot {
453
470
  }
454
471
 
455
472
  // A field of a snapshot: its type and whether it is required first, then
456
- // the other keys of its definition, sorted (a nested struct under `schema`,
457
- // an element under `value`, branches under `union`).
458
- export interface FieldSnapshot {
459
- type: string;
473
+ // the other keys of its definition, sorted. The type decides what else it
474
+ // holds (narrow on `type`): the rules of its type, the element of a
475
+ // collection, the elements of a tuple, the nested struct, the branches of a
476
+ // union, the entity of a reference (its name is the type, capitalized), or
477
+ // the options of a custom type, whose names are those `CustomTypes` declares
478
+ // (as `Infer` reads them). Any field may carry the keys of
479
+ // `FieldSnapshotBase`; a key the definition gave beyond them is kept too.
480
+ export interface FieldSnapshotBase {
460
481
  required: boolean;
482
+ nullable?: boolean;
483
+ coerce?: boolean;
484
+ // A value, `{ $function: true }` for a factory, `{ $bigint }`, `{ $date }`,
485
+ // `{ $bytes }`, `{ $map }`, `{ $set }` for the values that have no JSON form.
486
+ default?: unknown;
487
+ aliases?: string[];
488
+ deprecated?: boolean | string;
489
+ description?: string;
490
+ examples?: unknown[];
491
+ title?: string;
492
+ validate?: FunctionSnapshot;
493
+ parse?: FunctionSnapshot;
494
+ serialize?: FunctionSnapshot;
461
495
  [key: string]: unknown;
462
496
  }
463
497
 
498
+ export interface BigintSnapshot {
499
+ $bigint: string;
500
+ }
501
+
502
+ export interface DateSnapshot {
503
+ $date: string;
504
+ }
505
+
506
+ // Bytes as base64 text, a Map as its entries and a Set as its values, each
507
+ // value of them written as any value of a snapshot is.
508
+ export interface BytesSnapshot {
509
+ $bytes: string;
510
+ }
511
+
512
+ export interface MapSnapshot {
513
+ $map: [unknown, unknown][];
514
+ }
515
+
516
+ export interface SetSnapshot {
517
+ $set: unknown[];
518
+ }
519
+
520
+ // A `length` rule: the bounds it has.
521
+ export interface LengthSnapshot {
522
+ min?: number;
523
+ max?: number;
524
+ }
525
+
526
+ export interface StringFieldSnapshot extends FieldSnapshotBase {
527
+ type: 'string';
528
+ length?: LengthSnapshot;
529
+ unicode?: boolean;
530
+ // The source of a pattern of the `u` flag alone, else its source and flags.
531
+ pattern?: string | { source: string; flags: string };
532
+ format?: string;
533
+ }
534
+
535
+ export interface NumberFieldSnapshot extends FieldSnapshotBase {
536
+ type: 'number';
537
+ min?: number | BigintSnapshot;
538
+ max?: number | BigintSnapshot;
539
+ decimals?: number;
540
+ }
541
+
542
+ export interface IntegerFieldSnapshot extends FieldSnapshotBase {
543
+ type: 'integer' | 'bigint';
544
+ min?: number | BigintSnapshot;
545
+ max?: number | BigintSnapshot;
546
+ }
547
+
548
+ export interface ScalarFieldSnapshot extends FieldSnapshotBase {
549
+ type: 'boolean' | 'date' | 'null' | 'any' | 'unknown' | 'json';
550
+ }
551
+
552
+ // Binary data, its `length` the number of bytes.
553
+ export interface BytesFieldSnapshot extends FieldSnapshotBase {
554
+ type: 'bytes';
555
+ length?: LengthSnapshot;
556
+ }
557
+
558
+ export interface EnumFieldSnapshot extends FieldSnapshotBase {
559
+ type: 'enum';
560
+ enum: unknown[];
561
+ }
562
+
563
+ export interface FlagsFieldSnapshot extends FieldSnapshotBase {
564
+ type: 'flags';
565
+ flags: string[];
566
+ }
567
+
568
+ export interface ListFieldSnapshot extends FieldSnapshotBase {
569
+ type: 'array' | 'set';
570
+ value: FieldSnapshot;
571
+ length?: LengthSnapshot;
572
+ }
573
+
574
+ export interface KeyedFieldSnapshot extends FieldSnapshotBase {
575
+ type: 'object' | 'map';
576
+ key: 'string' | 'number';
577
+ value: FieldSnapshot;
578
+ length?: LengthSnapshot;
579
+ }
580
+
581
+ // An element of a tuple, `name` the one a named element was given.
582
+ export type TupleElementSnapshot = FieldSnapshot & { name?: string };
583
+
584
+ export interface TupleFieldSnapshot extends FieldSnapshotBase {
585
+ type: 'tuple';
586
+ value: TupleElementSnapshot[];
587
+ }
588
+
589
+ // A nested struct, or a Schema of one type held as a field.
590
+ export interface StructFieldSnapshot extends FieldSnapshotBase {
591
+ type: 'schema';
592
+ schema: FieldsSnapshot | FieldSnapshot;
593
+ }
594
+
595
+ export interface UnionFieldSnapshot extends FieldSnapshotBase {
596
+ type: 'union';
597
+ union: FieldSnapshot[];
598
+ discriminator?: string;
599
+ }
600
+
601
+ type UpperLetter =
602
+ | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M'
603
+ | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
604
+
605
+ // A reference: the type is the name of the entity, under `one` or `many`.
606
+ export interface ReferenceFieldSnapshot extends FieldSnapshotBase {
607
+ type: `${UpperLetter}${string}`;
608
+ one?: string;
609
+ many?: string;
610
+ embed?: boolean;
611
+ }
612
+
613
+ // A field of a custom type, by the names `CustomTypes` declares: a snapshot
614
+ // of a model whose custom types are not declared there holds fields of type
615
+ // names no member of `FieldSnapshot` has, which an exhaustive `switch` over
616
+ // `type` does not see; give it a `default`.
617
+ export interface CustomFieldSnapshot extends FieldSnapshotBase {
618
+ type: keyof CustomTypes & string;
619
+ }
620
+
621
+ export type FieldSnapshot =
622
+ | StringFieldSnapshot
623
+ | NumberFieldSnapshot
624
+ | IntegerFieldSnapshot
625
+ | ScalarFieldSnapshot
626
+ | BytesFieldSnapshot
627
+ | EnumFieldSnapshot
628
+ | FlagsFieldSnapshot
629
+ | ListFieldSnapshot
630
+ | KeyedFieldSnapshot
631
+ | TupleFieldSnapshot
632
+ | StructFieldSnapshot
633
+ | UnionFieldSnapshot
634
+ | ReferenceFieldSnapshot
635
+ | CustomFieldSnapshot;
636
+
464
637
  // The fields of a struct in their order: a calculated field, the validate,
465
638
  // parse or serialize of the struct are `{ $function: true }`.
466
639
  export type FieldsSnapshot = Record<string, FieldSnapshot | FunctionSnapshot>;
@@ -495,11 +668,21 @@ export interface TypeSnapshot {
495
668
 
496
669
  export interface ModelSnapshot {
497
670
  format: 1;
671
+ // The entity a snapshot of one schema is about (`schema.toSnapshot()`);
672
+ // a model's snapshot has none.
673
+ root?: string;
498
674
  database: Record<string, unknown> | null;
499
675
  types: Record<string, TypeSnapshot>;
500
676
  entities: Record<string, EntitySnapshot>;
501
677
  }
502
678
 
679
+ // `schema.toSnapshot()`: the schema (under its name, '' when anonymous)
680
+ // and every entity it reaches through its references, in dependency order.
681
+ export interface SchemaSnapshot extends ModelSnapshot {
682
+ root: string;
683
+ database: null;
684
+ }
685
+
503
686
  // The options of `fromJSON` of the `@alexify/metaschema/model` subpath.
504
687
  export interface RestoreOptions {
505
688
  // Entries of the table Model takes, over the types of the snapshot: the
@@ -798,6 +981,9 @@ export interface StandardConverter {
798
981
  // `enum`, `tuple`, `union`, `schema`, `one`, `many`) is that shorthand, and
799
982
  // anything else is a struct. A struct with a field named like one of those
800
983
  // says so with a kind (`{ Struct: {}, ... }`), as the runtime needs it to.
984
+ // A kind key is what the runtime takes for one (`KindKey` below): a name like
985
+ // `Entity` or `Settings` holding an object, never `PORT` or `Name: 'string'`,
986
+ // which are fields.
801
987
  // ---------------------------------------------------------------------------
802
988
 
803
989
  // The value types of custom types, by type name, for module augmentation:
@@ -821,6 +1007,7 @@ type ScalarName =
821
1007
  | 'bigint'
822
1008
  | 'boolean'
823
1009
  | 'date'
1010
+ | 'bytes'
824
1011
  | 'null'
825
1012
  | 'any'
826
1013
  | 'unknown'
@@ -836,6 +1023,7 @@ type CompoundName =
836
1023
  | 'tuple'
837
1024
  | 'union'
838
1025
  | 'schema'
1026
+ | 'flags'
839
1027
  | 'one'
840
1028
  | 'many';
841
1029
 
@@ -851,18 +1039,20 @@ type ScalarOf<N extends string> = N extends 'string'
851
1039
  ? boolean
852
1040
  : N extends 'date'
853
1041
  ? Date
854
- : N extends 'null'
855
- ? null
856
- : N extends 'any'
857
- ? any
858
- : N extends 'unknown' | 'json'
859
- ? unknown
860
- : N extends keyof CustomTypes
861
- ? CustomTypes[N]
862
- : unknown;
1042
+ : N extends 'bytes'
1043
+ ? Uint8Array
1044
+ : N extends 'null'
1045
+ ? null
1046
+ : N extends 'any'
1047
+ ? any
1048
+ : N extends 'unknown' | 'json'
1049
+ ? unknown
1050
+ : N extends keyof CustomTypes
1051
+ ? CustomTypes[N]
1052
+ : unknown;
863
1053
 
864
1054
  // Whether the first character is an uppercase letter: a reference when it is
865
- // the first character of a type name, a kind when it is the first of a key.
1055
+ // the first character of a type name, and what a kind key starts with.
866
1056
  type IsCapitalized<K> = K extends `${infer C}${string}`
867
1057
  ? C extends Uppercase<C>
868
1058
  ? C extends Lowercase<C>
@@ -880,7 +1070,46 @@ type StoredKind =
880
1070
  | 'relation'
881
1071
  | 'view';
882
1072
 
883
- type KindKey<D> = { [K in keyof D]: IsCapitalized<K> extends true ? K : never }[keyof D];
1073
+ // A kind key, as the runtime reads one (`isKindKey` of src/kinds.js): a
1074
+ // capital letter, then letters and digits, one of them lowercase (`Entity`,
1075
+ // `Settings`, never `PORT` or `DATABASE_URL`), holding the metadata of the
1076
+ // kind, an object that is no list, function or Schema. Any other capitalized
1077
+ // key is a field.
1078
+ type KnownKindKey = Capitalize<KnownKind>;
1079
+
1080
+ // The characters of a string as a union, gathered in an accumulator so that
1081
+ // the recursion is a tail call (62 levels of a union are too deep otherwise).
1082
+ type CharsOf<S, A = never> = S extends `${infer C}${infer R}` ? CharsOf<R, A | C> : A;
1083
+
1084
+ type WordChar = CharsOf<'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'>;
1085
+
1086
+ type IsWord<S> = S extends `${infer C}${infer R}` ? (C extends WordChar ? IsWord<R> : false) : true;
1087
+
1088
+ // Read for a capitalized key only, so the walk over its characters is paid
1089
+ // by the few keys that may be kinds.
1090
+ type IsKindName<K> =
1091
+ IsCapitalized<K> extends true ? (K extends Uppercase<K & string> ? false : IsWord<K>) : false;
1092
+
1093
+ type IsKindMeta<V> =
1094
+ IsAny<V> extends true
1095
+ ? false
1096
+ : [V] extends [object]
1097
+ ? [V] extends [readonly unknown[] | Fn | Schema<any>]
1098
+ ? false
1099
+ : true
1100
+ : false;
1101
+
1102
+ type KindCandidates<D> = {
1103
+ [K in keyof D]: IsKindName<K> extends true ? (IsKindMeta<D[K]> extends true ? K : never) : never;
1104
+ }[keyof D];
1105
+
1106
+ // The runtime takes the first key; the keys of a type have no order, so
1107
+ // among the keys that may be the kind a built-in one is it (the others are
1108
+ // fields then, as `{ Struct: {}, Address: { ... } }` says), and without one
1109
+ // every candidate is read as a kind.
1110
+ type KindKey<D> = [Extract<KindCandidates<D>, KnownKindKey>] extends [never]
1111
+ ? KindCandidates<D>
1112
+ : Extract<KindCandidates<D>, KnownKindKey>;
884
1113
 
885
1114
  // The store of an entity definition: its kind metadata, else the default of
886
1115
  // its kind; a definition without a kind is a struct, held in memory.
@@ -960,7 +1189,8 @@ type UnionOf<T extends readonly unknown[], E, M extends Mode> = {
960
1189
  }[number];
961
1190
 
962
1191
  // A one-key object holding a type name names a tuple element (`{ x: 'number'
963
- // }`); the key must not itself be `type`, a type name or a kind.
1192
+ // }`); the key must not itself be `type` or a type name (a string is no
1193
+ // metadata of a kind, so a capitalized key names an element too).
964
1194
  type NamedKey<T> = keyof T extends infer K
965
1195
  ? [K] extends [string]
966
1196
  ? IsUnion<K> extends true
@@ -968,14 +1198,10 @@ type NamedKey<T> = keyof T extends infer K
968
1198
  : K extends `${infer F}?`
969
1199
  ? F extends TypeName | 'type'
970
1200
  ? never
971
- : IsCapitalized<F> extends true
972
- ? never
973
- : K
1201
+ : K
974
1202
  : K extends TypeName | 'type'
975
1203
  ? never
976
- : IsCapitalized<K> extends true
977
- ? never
978
- : K
1204
+ : K
979
1205
  : never
980
1206
  : never;
981
1207
 
@@ -1033,13 +1259,17 @@ type TypeOf<N extends string, D, E, M extends Mode> =
1033
1259
  ? D extends { many: infer T extends string }
1034
1260
  ? Referenced<T, EmbedOf<D>, E, M>[]
1035
1261
  : unknown
1036
- : N extends keyof CustomTypes
1037
- ? CustomTypes[N]
1038
- : N extends ScalarName
1039
- ? ScalarOf<N>
1040
- : D extends { schema: infer S extends object }
1041
- ? Value<S, E, M>
1042
- : unknown;
1262
+ : N extends 'flags'
1263
+ ? D extends { flags: readonly (infer F extends string)[] }
1264
+ ? { [K in F]?: boolean }
1265
+ : Record<string, boolean>
1266
+ : N extends keyof CustomTypes
1267
+ ? CustomTypes[N]
1268
+ : N extends ScalarName
1269
+ ? ScalarOf<N>
1270
+ : D extends { schema: infer S extends object }
1271
+ ? Value<S, E, M>
1272
+ : unknown;
1043
1273
 
1044
1274
  // On the output side a decoder (`parse`) gives the value of its field; a
1045
1275
  // promise of one is awaited.
@@ -1079,7 +1309,9 @@ type Shorthand<D, E, M extends Mode> = D extends { array: unknown }
1079
1309
  ? LongForm<'one', D, E, M>
1080
1310
  : D extends { many: string }
1081
1311
  ? LongForm<'many', D, E, M>
1082
- : Decoded<Struct<D, E, M>, D, M>;
1312
+ : D extends { flags: readonly string[] }
1313
+ ? LongForm<'flags', D, E, M>
1314
+ : Decoded<Struct<D, E, M>, D, M>;
1083
1315
 
1084
1316
  // What is not a field of a struct: a function (a calculated field, or the
1085
1317
  // schema-level validate/parse/serialize/format) and an index definition.
@@ -1167,20 +1399,17 @@ type Projection<D, E, M extends Mode> = D extends {
1167
1399
  : unknown
1168
1400
  : unknown;
1169
1401
 
1170
- type WithKind<D, K extends keyof D, E, M extends Mode> = K extends 'Projection'
1402
+ type WithKind<D, K extends keyof D, E, M extends Mode> = [K] extends ['Projection']
1171
1403
  ? Projection<D, E, M>
1172
1404
  : Struct<Omit<D, K>, E, M>;
1173
1405
 
1174
- type ObjectDef<D, E, M extends Mode> =
1175
- KindKey<D> extends infer K
1176
- ? [K] extends [never]
1177
- ? D extends { type: infer T extends string }
1178
- ? LongForm<T, D, E, M>
1179
- : Shorthand<D, E, M>
1180
- : K extends keyof D
1181
- ? Decoded<WithKind<D, K, E, M>, D, M>
1182
- : never
1183
- : never;
1406
+ // The kind keys are taken as one set, never one by one: a union of structs,
1407
+ // each without one key, is what distributing over them gave.
1408
+ type ObjectDef<D, E, M extends Mode> = [KindKey<D>] extends [never]
1409
+ ? D extends { type: infer T extends string }
1410
+ ? LongForm<T, D, E, M>
1411
+ : Shorthand<D, E, M>
1412
+ : Decoded<WithKind<D, KindKey<D> & keyof D, E, M>, D, M>;
1184
1413
 
1185
1414
  // The id field a stored kind adds, named after the entity.
1186
1415
  type IdOf<Name extends string, Def> =
@@ -1252,6 +1481,7 @@ type IsShorthand<D> = D extends { array: unknown }
1252
1481
  | { schema: object }
1253
1482
  | { one: string }
1254
1483
  | { many: string }
1484
+ | { flags: readonly string[] }
1255
1485
  ? true
1256
1486
  : false;
1257
1487
 
@@ -1667,6 +1897,8 @@ export class Schema<const D extends string | object = string | object> {
1667
1897
  detach(...namespaces: Array<Model>): void;
1668
1898
  toString(): string;
1669
1899
  toJSON(): object;
1900
+ // The schema as plain JSON: see `SchemaSnapshot`.
1901
+ toSnapshot(): SchemaSnapshot;
1670
1902
  validate(value: unknown, path?: string): ValidationResult | null;
1671
1903
  }
1672
1904
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexify/metaschema",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "Fast, zero-dependency metadata schema and interface definition language (IDL) for Node.js and browsers — validation and parsing with a JIT backend, domain models, TypeScript and JSON Schema",
5
5
  "license": "MIT",
6
6
  "author": "Alex Dolid <dolid.sasha@gmail.com>",
@@ -66,6 +66,10 @@
66
66
  "./mongodb": {
67
67
  "types": "./src/mongodb/index.d.ts",
68
68
  "default": "./src/mongodb/index.js"
69
+ },
70
+ "./definition": {
71
+ "types": "./src/definition/index.d.ts",
72
+ "default": "./src/definition/index.js"
69
73
  }
70
74
  },
71
75
  "directories": {
@@ -81,7 +85,12 @@
81
85
  "LICENSE",
82
86
  "SECURITY.md"
83
87
  ],
84
- "sideEffects": false,
88
+ "sideEffects": [
89
+ "./index.js",
90
+ "./browser.js",
91
+ "./src/index.js",
92
+ "./src/validation.js"
93
+ ],
85
94
  "publishConfig": {
86
95
  "access": "public"
87
96
  },
@@ -150,11 +159,12 @@
150
159
  "test:nojit": "node --disallow-code-generation-from-strings --require ./tests/helpers/jit.js --test tests/unit/*.test.js",
151
160
  "test:coverage": "c8 --all --include 'src/**' --check-coverage --lines 98 --statements 98 --branches 90 --functions 100 --reporter text --reporter lcov node --test tests/unit/*.test.js",
152
161
  "test:types": "tsd",
153
- "check:dts": "tsc --noEmit --strict --target es2022 --skipLibCheck false index.d.ts src/locales/en.d.ts src/locales/uk.d.ts src/generators/index.d.ts src/compile/index.d.ts src/model/index.d.ts src/stream/index.d.ts src/formats/index.d.ts src/derive/index.d.ts src/coerce/index.d.ts src/mongodb/index.d.ts",
162
+ "check:dts": "tsc --noEmit --strict --target es2022 --skipLibCheck false index.d.ts src/locales/en.d.ts src/locales/uk.d.ts src/generators/index.d.ts src/compile/index.d.ts src/model/index.d.ts src/stream/index.d.ts src/formats/index.d.ts src/derive/index.d.ts src/coerce/index.d.ts src/mongodb/index.d.ts src/definition/index.d.ts",
154
163
  "lint": "oxlint index.js browser.js src tests scripts bench",
155
164
  "format": "oxfmt index.js browser.js src tests scripts bench",
156
165
  "format:check": "oxfmt --check index.js browser.js src tests scripts bench",
157
166
  "size": "node scripts/size.js",
167
+ "size:gate": "node scripts/size.js --max-gzip 22 --max-gzip-generators 8 --max-gzip-compile 5 --max-gzip-model 13 --max-gzip-stream 1.5 --max-gzip-formats 5 --max-gzip-derive 2.5 --max-gzip-coerce 2 --max-gzip-mongodb 4 --max-gzip-definition 11",
158
168
  "bench": "node bench/bench.js",
159
169
  "bench:compare": "node bench/compare.js",
160
170
  "bench:releases": "node bench/releases.js",