@routier/core 0.1.0-rc.2 → 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.
- package/dist/assertions/index.d.ts +30 -0
- package/dist/assertions/index.js +92 -19
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.js +75 -105
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/blocks.test.d.ts +1 -0
- package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/index.d.ts +1 -0
- package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
- package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
- package/dist/codegen/index.js +22 -36
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/utils.test.d.ts +1 -0
- package/dist/collections/Changes.d.ts +2 -2
- package/dist/collections/IdSet.test.d.ts +1 -0
- package/dist/collections/TagCollection.contract.test.d.ts +1 -0
- package/dist/collections/TagCollection.d.ts +7 -7
- package/dist/collections/index.js +50 -93
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/index.js +4 -15
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/constants.d.ts +2 -0
- package/dist/expressions/index.d.ts +2 -0
- package/dist/expressions/index.js +450 -114
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/sql.d.ts +28 -0
- package/dist/expressions/sql.test.d.ts +1 -0
- package/dist/expressions/utils.d.ts +1 -2
- package/dist/index.js +3058 -2618
- package/dist/index.js.map +1 -1
- package/dist/performance/index.js +22 -22
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.js +48 -60
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +268 -937
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/Query.test.d.ts +1 -0
- package/dist/plugins/query/QueryOptionsCollection.d.ts +1 -0
- package/dist/plugins/translators/SqlTranslator.test.d.ts +1 -0
- package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +1 -0
- package/dist/plugins/translators/types.d.ts +8 -1
- package/dist/plugins/types.d.ts +6 -10
- package/dist/results/Result.d.ts +2 -2
- package/dist/results/Result.test.d.ts +1 -0
- package/dist/results/index.js +11 -26
- package/dist/results/index.js.map +1 -1
- package/dist/results/utils.test.d.ts +1 -0
- package/dist/schema/PropertyInfo.d.ts +5 -1
- package/dist/schema/SchemaDefinition.d.ts +35 -6
- package/dist/schema/communication/broadcast.test.d.ts +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2115 -1513
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +3 -1
- package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
- package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +3 -1
- package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
- package/dist/schema/property/modifiers/index.d.ts +2 -0
- package/dist/schema/property/types/SchemaArray.d.ts +2 -0
- package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
- package/dist/schema/property/types/SchemaDate.d.ts +2 -0
- package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
- package/dist/schema/property/types/SchemaObject.d.ts +2 -0
- package/dist/schema/property/types/SchemaString.d.ts +5 -1
- package/dist/schema/types.d.ts +41 -29
- package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
- package/dist/schema/utils/standardJsonSchema.test.d.ts +1 -0
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/functions.d.ts +1 -1
- package/dist/utilities/index.js +213 -138
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/runtime.test.d.ts +1 -0
- package/dist/utilities/types.d.ts +17 -2
- package/dist/utilities/uuid.test.d.ts +1 -0
- package/package.json +2 -2
- package/readme.md +1 -1
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -22
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
- package/dist/plugins/replication/index.d.ts +0 -3
- package/dist/plugins/replication/types.d.ts +0 -4
- package/dist/schema/testSchemas.test.d.ts +0 -314
- /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 TranslatedGroupValue<T> implements ITranslatedValue<T> {
|
|
3
3
|
readonly value: T;
|
|
4
|
-
|
|
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
|
-
|
|
4
|
+
readonly isTransformed: boolean;
|
|
5
|
+
readonly isEmpty: boolean;
|
|
6
|
+
constructor(value: unknown, isTransformed: boolean);
|
|
5
7
|
forEach(callback: (item: unknown) => unknown): void;
|
|
6
8
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
|
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
|
}
|
package/dist/plugins/types.d.ts
CHANGED
|
@@ -41,8 +41,12 @@ export type DbPluginEvent = {
|
|
|
41
41
|
schemas: SchemaCollection;
|
|
42
42
|
/** Unique id of the event. */
|
|
43
43
|
id: string;
|
|
44
|
-
/**
|
|
45
|
-
source:
|
|
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;
|
package/dist/results/Result.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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 {};
|
package/dist/results/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
var __webpack_modules__ = ({
|
|
2
|
-
"./src/results/Result.ts"
|
|
3
|
-
/*!*******************************!*\
|
|
4
|
-
!*** ./src/results/Result.ts ***!
|
|
5
|
-
\*******************************/
|
|
6
|
-
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2
|
+
"./src/results/Result.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
7
3
|
__webpack_require__.r(__webpack_exports__);
|
|
8
4
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
5
|
PluginEventResult: () => (PluginEventResult),
|
|
@@ -85,22 +81,18 @@ class PluginEventResult extends BaseResult {
|
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
|
|
88
|
-
}
|
|
89
|
-
"./src/results/utils.ts"
|
|
90
|
-
/*!******************************!*\
|
|
91
|
-
!*** ./src/results/utils.ts ***!
|
|
92
|
-
\******************************/
|
|
93
|
-
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
84
|
+
},
|
|
85
|
+
"./src/results/utils.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
94
86
|
__webpack_require__.r(__webpack_exports__);
|
|
95
87
|
__webpack_require__.d(__webpack_exports__, {
|
|
96
88
|
toPromise: () => (toPromise)
|
|
97
89
|
});
|
|
98
|
-
/*
|
|
90
|
+
/* import */ var _Result__rspack_import_0 = __webpack_require__("./src/results/Result.ts");
|
|
99
91
|
|
|
100
92
|
function toPromise(fn) {
|
|
101
93
|
return new Promise((resolve, reject) => {
|
|
102
94
|
fn((r) => {
|
|
103
|
-
if (r.ok ===
|
|
95
|
+
if (r.ok === _Result__rspack_import_0.Result.ERROR) {
|
|
104
96
|
reject(r.error);
|
|
105
97
|
return;
|
|
106
98
|
}
|
|
@@ -110,10 +102,9 @@ function toPromise(fn) {
|
|
|
110
102
|
}
|
|
111
103
|
|
|
112
104
|
|
|
113
|
-
}
|
|
105
|
+
},
|
|
114
106
|
|
|
115
107
|
});
|
|
116
|
-
/************************************************************************/
|
|
117
108
|
// The module cache
|
|
118
109
|
var __webpack_module_cache__ = {};
|
|
119
110
|
|
|
@@ -137,7 +128,6 @@ return module.exports;
|
|
|
137
128
|
|
|
138
129
|
}
|
|
139
130
|
|
|
140
|
-
/************************************************************************/
|
|
141
131
|
// webpack/runtime/define_property_getters
|
|
142
132
|
(() => {
|
|
143
133
|
__webpack_require__.d = (exports, definition) => {
|
|
@@ -162,22 +152,17 @@ __webpack_require__.r = (exports) => {
|
|
|
162
152
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
163
153
|
};
|
|
164
154
|
})();
|
|
165
|
-
/************************************************************************/
|
|
166
155
|
var __webpack_exports__ = {};
|
|
167
156
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
168
157
|
(() => {
|
|
169
|
-
|
|
170
|
-
/*!******************************!*\
|
|
171
|
-
!*** ./src/results/index.ts ***!
|
|
172
|
-
\******************************/
|
|
173
158
|
__webpack_require__.r(__webpack_exports__);
|
|
174
159
|
__webpack_require__.d(__webpack_exports__, {
|
|
175
|
-
PluginEventResult: () => (/* reexport safe */
|
|
176
|
-
Result: () => (/* reexport safe */
|
|
177
|
-
toPromise: () => (/* reexport safe */
|
|
160
|
+
PluginEventResult: () => (/* reexport safe */ _Result__rspack_import_0.PluginEventResult),
|
|
161
|
+
Result: () => (/* reexport safe */ _Result__rspack_import_0.Result),
|
|
162
|
+
toPromise: () => (/* reexport safe */ _utils__rspack_import_1.toPromise)
|
|
178
163
|
});
|
|
179
|
-
/*
|
|
180
|
-
/*
|
|
164
|
+
/* import */ var _Result__rspack_import_0 = __webpack_require__("./src/results/Result.ts");
|
|
165
|
+
/* import */ var _utils__rspack_import_1 = __webpack_require__("./src/results/utils.ts");
|
|
181
166
|
|
|
182
167
|
|
|
183
168
|
|
|
@@ -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
|
|
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,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,aAAa,CAAI,MAAW;QAC/B,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;;AAGE,MAAM,MAAO,SAAQ,UAAU;IAGlC,MAAM,CAAC,OAAO,CAAI,IAAQ;QACtB,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,OAAO;YAClB,IAAI;SACP;IACL,CAAC;IAED,MAAM,CAAC,KAAK,CAAI,KAAU;QACtB,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,KAAK;YAChB,KAAK;SACR;IACL,CAAC;IAED,MAAM,CAAC,OAAO,CAAI,IAAO,EAAE,KAAU;QACjC,OAAO;YACH,EAAE,EAAE,MAAM,CAAC,OAAO;YAClB,IAAI;YACJ,KAAK;SACR;IACL,CAAC;CACJ;AAEM,MAAM,iBAAkB,SAAQ,UAAU;IAG7C,MAAM,CAAC,OAAO,CAAI,EAAU,EAAE,IAAQ;QAClC,OAAO;YACH,EAAE;YACF,EAAE,EAAE,MAAM,CAAC,OAAO;YAClB,IAAI;SACP;IACL,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"}
|
|
@@ -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,17 +1,46 @@
|
|
|
1
1
|
import { SchemaFunction } from './table/SchemaFunction';
|
|
2
2
|
import { SchemaComputed } from './table/SchemaComputed';
|
|
3
3
|
import { SchemaBase } from "./property/base/SchemaBase";
|
|
4
|
-
import { 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
|
-
collectionName:
|
|
9
|
-
constructor(collectionName:
|
|
9
|
+
collectionName: CollectionName;
|
|
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>>;
|
|
37
|
+
private createReturnFunction;
|
|
38
|
+
private createFunction;
|
|
10
39
|
modify<R>(builder: (d: {
|
|
11
|
-
function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName:
|
|
12
|
-
computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName:
|
|
40
|
+
function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, "unmapped">;
|
|
41
|
+
computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, "computed" | "unmapped">;
|
|
13
42
|
}) => R): SchemaDefinition<R & T>;
|
|
14
43
|
private _iterate;
|
|
15
|
-
|
|
44
|
+
compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>;
|
|
16
45
|
compile(): CompiledSchema<T>;
|
|
17
46
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|