@routier/core 0.2.0 → 0.2.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 (85) hide show
  1. package/dist/assertions/index.d.ts +30 -0
  2. package/dist/assertions/index.js +88 -4
  3. package/dist/assertions/index.js.map +1 -1
  4. package/dist/capabilities/index.js +25 -16
  5. package/dist/capabilities/index.js.map +1 -1
  6. package/dist/codegen/blocks.test.d.ts +1 -0
  7. package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
  8. package/dist/codegen/handlers/index.d.ts +1 -0
  9. package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
  10. package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
  11. package/dist/codegen/index.js +1 -0
  12. package/dist/codegen/index.js.map +1 -1
  13. package/dist/codegen/utils.test.d.ts +1 -0
  14. package/dist/collections/Changes.d.ts +2 -2
  15. package/dist/collections/IdSet.test.d.ts +1 -0
  16. package/dist/collections/TagCollection.contract.test.d.ts +1 -0
  17. package/dist/collections/TagCollection.d.ts +7 -7
  18. package/dist/collections/index.js +1 -1
  19. package/dist/collections/index.js.map +1 -1
  20. package/dist/expressions/constants.d.ts +2 -0
  21. package/dist/expressions/index.d.ts +2 -0
  22. package/dist/expressions/index.js +401 -34
  23. package/dist/expressions/index.js.map +1 -1
  24. package/dist/expressions/sql.d.ts +28 -0
  25. package/dist/expressions/sql.test.d.ts +1 -0
  26. package/dist/expressions/utils.d.ts +1 -2
  27. package/dist/index.js +1669 -610
  28. package/dist/index.js.map +1 -1
  29. package/dist/performance/index.js +18 -7
  30. package/dist/performance/index.js.map +1 -1
  31. package/dist/pipeline/index.js +18 -7
  32. package/dist/pipeline/index.js.map +1 -1
  33. package/dist/plugins/index.d.ts +0 -1
  34. package/dist/plugins/index.js +126 -694
  35. package/dist/plugins/index.js.map +1 -1
  36. package/dist/plugins/query/Query.test.d.ts +1 -0
  37. package/dist/plugins/query/QueryOptionsCollection.d.ts +1 -0
  38. package/dist/plugins/translators/SqlTranslator.test.d.ts +1 -0
  39. package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
  40. package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
  41. package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
  42. package/dist/plugins/translators/TranslatedValues.test.d.ts +1 -0
  43. package/dist/plugins/translators/types.d.ts +8 -1
  44. package/dist/plugins/types.d.ts +6 -10
  45. package/dist/results/Result.d.ts +2 -2
  46. package/dist/results/Result.test.d.ts +1 -0
  47. package/dist/results/index.js.map +1 -1
  48. package/dist/results/utils.test.d.ts +1 -0
  49. package/dist/schema/PropertyInfo.d.ts +5 -1
  50. package/dist/schema/SchemaDefinition.d.ts +29 -1
  51. package/dist/schema/communication/broadcast.test.d.ts +1 -0
  52. package/dist/schema/index.d.ts +2 -0
  53. package/dist/schema/index.js +1151 -132
  54. package/dist/schema/index.js.map +1 -1
  55. package/dist/schema/property/base/SchemaBase.d.ts +3 -1
  56. package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
  57. package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
  58. package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
  59. package/dist/schema/property/modifiers/SchemaNullable.d.ts +5 -1
  60. package/dist/schema/property/modifiers/SchemaOptional.d.ts +3 -1
  61. package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
  62. package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
  63. package/dist/schema/property/modifiers/index.d.ts +2 -0
  64. package/dist/schema/property/types/SchemaArray.d.ts +2 -0
  65. package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
  66. package/dist/schema/property/types/SchemaDate.d.ts +2 -0
  67. package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
  68. package/dist/schema/property/types/SchemaObject.d.ts +2 -0
  69. package/dist/schema/property/types/SchemaString.d.ts +5 -1
  70. package/dist/schema/types.d.ts +37 -27
  71. package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
  72. package/dist/schema/utils/standardJsonSchema.test.d.ts +1 -0
  73. package/dist/utilities/functions.d.ts +1 -1
  74. package/dist/utilities/index.js +153 -15
  75. package/dist/utilities/index.js.map +1 -1
  76. package/dist/utilities/runtime.test.d.ts +1 -0
  77. package/dist/utilities/uuid.test.d.ts +1 -0
  78. package/package.json +2 -2
  79. package/readme.md +1 -1
  80. package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
  81. package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
  82. package/dist/plugins/replication/index.d.ts +0 -3
  83. package/dist/plugins/replication/types.d.ts +0 -5
  84. package/dist/schema/testSchemas.test.d.ts +0 -314
  85. /package/dist/{pipeline/WorkPipeline.test.d.ts → codegen/SlotPath.test.d.ts} +0 -0
@@ -1,6 +1,8 @@
1
1
  import { ITranslatedValue } from './types';
2
2
  export declare class TranslatedArrayValue<T> implements ITranslatedValue<T> {
3
3
  readonly value: T;
4
- constructor(value: unknown);
4
+ readonly isTransformed: boolean;
5
+ readonly isEmpty: boolean;
6
+ constructor(value: unknown, isTransformed: boolean);
5
7
  forEach(callback: (item: unknown) => unknown): void;
6
8
  }
@@ -1,6 +1,8 @@
1
1
  import { ITranslatedValue } from './types';
2
2
  export declare class TranslatedGroupValue<T> implements ITranslatedValue<T> {
3
3
  readonly value: T;
4
- constructor(value: unknown);
4
+ readonly isTransformed: boolean;
5
+ readonly isEmpty: boolean;
6
+ constructor(value: unknown, isTransformed: boolean);
5
7
  forEach(callback: (item: unknown) => unknown): void;
6
8
  }
@@ -1,6 +1,8 @@
1
1
  import { ITranslatedValue } from './types';
2
2
  export declare class TranslatedSingleValue<T> implements ITranslatedValue<T> {
3
3
  value: T;
4
- constructor(value: unknown);
4
+ readonly isTransformed: boolean;
5
+ readonly isEmpty: boolean;
6
+ constructor(value: unknown, isTransformed: boolean);
5
7
  forEach(callback: (item: unknown) => unknown): void;
6
8
  }
@@ -2,9 +2,16 @@ export interface ITranslatedValue<T> {
2
2
  readonly value: T;
3
3
  /**
4
4
  * Iterates over items in the collection, calling the callback for each item.
5
- * If the callback returns a value, that value will replace the original item in the collection.
5
+ * If the callback returns a value, that value replaces the original item (e.g. so
6
+ * changeTracker.resolve() can swap in attached/merged entities).
6
7
  *
7
8
  * @param callback Function called for each item. If it returns a value, that value replaces the original item.
8
9
  */
9
10
  forEach(callback: (item: unknown) => unknown): void;
11
+ /**
12
+ * True if the translator remapped or transformed the data from the database shape;
13
+ * false if the data is unchanged and in the same shape as the database.
14
+ */
15
+ readonly isTransformed: boolean;
16
+ readonly isEmpty: boolean;
10
17
  }
@@ -41,8 +41,12 @@ export type DbPluginEvent = {
41
41
  schemas: SchemaCollection;
42
42
  /** Unique id of the event. */
43
43
  id: string;
44
- /** Source of the request */
45
- source: "data-store" | "collection" | "view" | "capability";
44
+ /** The class/component that triggered this event */
45
+ source: string;
46
+ /** The action/operation type being performed */
47
+ action: "query" | "persist" | "destroy";
48
+ /** Optional context about why this operation is happening */
49
+ reason?: string;
46
50
  };
47
51
  /**
48
52
  * Event for a specific plugin operation, extending the base event with an operation payload.
@@ -67,14 +71,6 @@ export type ReplicationPluginOptions = {
67
71
  */
68
72
  read?: IDbPlugin;
69
73
  };
70
- export type OptimisticReplicationPluginOptions = {
71
- /** The primary database plugin that handles all write operations, do not include in the list of replicas. */
72
- source: IDbPlugin;
73
- /** Array of replica database plugins that can be used for read operations. */
74
- replicas: IDbPlugin[];
75
- /** Must be a MemoryPlugin */
76
- read: IDbPlugin;
77
- };
78
74
  export type EntityUpdateInfo<T extends {}> = {
79
75
  entity: InferType<T>;
80
76
  changeType: EntityChangeType;
@@ -11,13 +11,13 @@ declare abstract class BaseResult {
11
11
  }
12
12
  export declare class Result extends BaseResult {
13
13
  static success<T>(data: T): ResultType<T>;
14
- static success<T>(): ResultType<never>;
14
+ static success(): ResultType<never>;
15
15
  static error<T>(error: any): ResultType<T>;
16
16
  static partial<T>(data: T, error: any): PartialResultType<T>;
17
17
  }
18
18
  export declare class PluginEventResult extends BaseResult {
19
19
  static success<T>(id: string, data: T): PluginEventResultType<T>;
20
- static success<T>(id: string): PluginEventResultType<never>;
20
+ static success(id: string): PluginEventResultType<never>;
21
21
  static error<T>(id: string, error: any): PluginEventResultType<T>;
22
22
  static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T>;
23
23
  static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is {
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"results/index.js","sources":["webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/results/utils.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/results/index.ts"],"sourcesContent":["import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success<T>(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success<T>(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","import { Result } from \"./Result\";\nimport { CallbackResult } from \"./types\";\n\nexport function toPromise<T>(fn: (callback: CallbackResult<T>) => void) {\n return new Promise<T>((resolve, reject) => {\n fn((r) => {\n if (r.ok === Result.ERROR) {\n reject(r.error);\n return;\n }\n\n resolve(r.data);\n });\n });\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './Result';\nexport * from './types';\nexport * from './utils';"],"names":[],"mappings":";;;;;;;AAEA,MAAe,UAAU;IACrB,MAAM,CAAC,KAAK,GAAG,OAAgB,CAAC;IAChC,MAAM,CAAC,OAAO,GAAG,SAAkB,CAAC;IACpC,MAAM,CAAC,OAAO,GAAG,SAAkB,CAAC;IAEp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L,CAAC;IAED,MAAM,CAAC,KAAK,CAAI,EAAU,EAAE,KAAU;QAClC,OAAO;YACH,EAAE;YACF,EAAE,EAAE,MAAM,CAAC,KAAK;YAChB,KAAK;SACR;IACL,CAAC;IAED,MAAM,CAAC,OAAO,CAAI,EAAU,EAAE,IAAO,EAAE,KAAU;QAC7C,OAAO;YACH,EAAE;YACF,EAAE,EAAE,MAAM,CAAC,OAAO;YAClB,IAAI;YACJ,KAAK;SACR;IACL,CAAC;IAED,MAAM,CAAC,aAAa,CAAI,MAAgC;QACpD,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;CACJ;;;;;;;;;;AC1FiC;AAG3B,SAAS,SAAS,CAAI,EAAyC;IAClE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YACL,IAAI,CAAC,CAAC,EAAE,KAAK,qCAAY,EAAE,CAAC;gBACxB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChB,OAAO;YACX,CAAC;YAED,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;ACNyB;AACD;AACA"}
1
+ {"version":3,"file":"results/index.js","sources":["webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/results/utils.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/results/index.ts"],"sourcesContent":["import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","import { Result } from \"./Result\";\nimport { CallbackResult } from \"./types\";\n\nexport function toPromise<T>(fn: (callback: CallbackResult<T>) => void) {\n return new Promise<T>((resolve, reject) => {\n fn((r) => {\n if (r.ok === Result.ERROR) {\n reject(r.error);\n return;\n }\n\n resolve(r.data);\n });\n });\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './Result';\nexport * from './types';\nexport * from './utils';"],"names":[],"mappings":";;;;;;;AAEA,MAAe,UAAU;IACrB,MAAM,CAAC,KAAK,GAAG,OAAgB,CAAC;IAChC,MAAM,CAAC,OAAO,GAAG,SAAkB,CAAC;IACpC,MAAM,CAAC,OAAO,GAAG,SAAkB,CAAC;IAEpC,MAAM,CAAC,OAAO,CAAI,MAA4C,EAAE,OAA0B,EAAE,MAA6B;QACrH,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO;QACX,CAAC;QAED,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,KAAK,EAAE,MAAM,CAAC,KAAK;aACtB,CAAC,CAAC;YACH,OAAO;QACX,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,KAAK,CAA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oCAAoC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;CACJ;;;;;;;;;;AC1FiC;AAG3B,SAAS,SAAS,CAAI,EAAyC;IAClE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YACL,IAAI,CAAC,CAAC,EAAE,KAAK,qCAAY,EAAE,CAAC;gBACxB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAChB,OAAO;YACX,CAAC;YAED,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;ACNyB;AACD;AACA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { UnknownRecord } from '../utilities';
2
2
  import { SchemaBase } from './property/base/SchemaBase';
3
- import { DefaultValue, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes } from './types';
3
+ import { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes } from './types';
4
4
  /**
5
5
  * Represents metadata and utilities for a property in a schema, including its type, name, parent, children, and serialization details.
6
6
  */
@@ -18,6 +18,8 @@ export declare class PropertyInfo<T extends {}> {
18
18
  readonly isOptional: boolean;
19
19
  /** Whether the property is a key. */
20
20
  readonly isKey: boolean;
21
+ /** Foreign key schema and property */
22
+ readonly foreignKeyDefinition: ForeignKey<unknown> | null;
21
23
  /** Whether the property is an identity property. */
22
24
  readonly isIdentity: boolean;
23
25
  /** Whether the property is readonly. */
@@ -46,6 +48,8 @@ export declare class PropertyInfo<T extends {}> {
46
48
  readonly innerSchema?: SchemaBase<unknown, any>;
47
49
  /** Literal values allowed for this property. */
48
50
  readonly literals: T[];
51
+ /** Tags passed from the schema */
52
+ readonly tags: string[];
49
53
  /** The parent property, if any. */
50
54
  readonly parent?: PropertyInfo<T>;
51
55
  private _propertyChainCache?;
@@ -1,12 +1,39 @@
1
1
  import { SchemaFunction } from './table/SchemaFunction';
2
2
  import { SchemaComputed } from './table/SchemaComputed';
3
3
  import { SchemaBase } from "./property/base/SchemaBase";
4
- import { CollectionName, CompiledSchema, InferType, SchemaTypes } from './types';
4
+ import { CollectionName, CompiledSchema, CompiledSchemaWithMetadata, InferCreateType, InferType, SchemaTypes } from './types';
5
+ import { StandardJSONSchemaV1 } from './utils/standardJsonSchema';
5
6
  export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
6
7
  instance: T;
7
8
  type: SchemaTypes;
8
9
  collectionName: CollectionName;
9
10
  constructor(collectionName: CollectionName, schema: T);
11
+ /**
12
+ * Creates a SchemaDefinition from a JSON string containing a JSON Schema.
13
+ * Parses the JSON string, rehydrates the schema structure, and compiles it.
14
+ *
15
+ * @param jsonString - The JSON string containing the JSON Schema (typically from `schema['~standard'].jsonSchema.input()` or `output()`)
16
+ * @param collectionName - Optional collection name override (if not present in JSON Schema metadata)
17
+ * @returns A compiled schema ready to use
18
+ * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Serialize a schema to JSON
23
+ * const jsonSchema = mySchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
24
+ * const jsonString = JSON.stringify(jsonSchema);
25
+ *
26
+ * // Rehydrate from JSON string
27
+ * const rehydratedSchema = SchemaDefinition.fromJson(jsonString);
28
+ * // Schema is already compiled and ready to use
29
+ * ```
30
+ */
31
+ static fromJson(jsonString: string, collectionName?: string): CompiledSchema<any>;
32
+ /**
33
+ * Standard JSON Schema V1 implementation.
34
+ * Provides JSON Schema conversion for Routier schemas.
35
+ */
36
+ get '~standard'(): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>>;
10
37
  private createReturnFunction;
11
38
  private createFunction;
12
39
  modify<R>(builder: (d: {
@@ -14,5 +41,6 @@ export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
14
41
  computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, "computed" | "unmapped">;
15
42
  }) => R): SchemaDefinition<R & T>;
16
43
  private _iterate;
44
+ compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>;
17
45
  compile(): CompiledSchema<T>;
18
46
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,3 +5,5 @@ export * from './property/modifiers';
5
5
  export * from './property/types';
6
6
  export * from './PropertyInfo';
7
7
  export * from './types';
8
+ export * from './utils/standardJsonSchema';
9
+ export * from './SchemaDefinition';