@fluojs/core 1.0.0-beta.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/LICENSE +21 -0
- package/README.ko.md +165 -0
- package/README.md +167 -0
- package/dist/decorators.d.ts +51 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +79 -0
- package/dist/errors.d.ts +60 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +89 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +2 -0
- package/dist/metadata/class-di.d.ts +30 -0
- package/dist/metadata/class-di.d.ts.map +1 -0
- package/dist/metadata/class-di.js +72 -0
- package/dist/metadata/controller-route.d.ts +7 -0
- package/dist/metadata/controller-route.d.ts.map +1 -0
- package/dist/metadata/controller-route.js +109 -0
- package/dist/metadata/injection.d.ts +5 -0
- package/dist/metadata/injection.d.ts.map +1 -0
- package/dist/metadata/injection.js +31 -0
- package/dist/metadata/module.d.ts +16 -0
- package/dist/metadata/module.d.ts.map +1 -0
- package/dist/metadata/module.js +57 -0
- package/dist/metadata/shared.d.ts +128 -0
- package/dist/metadata/shared.d.ts.map +1 -0
- package/dist/metadata/shared.js +231 -0
- package/dist/metadata/store.d.ts +16 -0
- package/dist/metadata/store.d.ts.map +1 -0
- package/dist/metadata/store.js +25 -0
- package/dist/metadata/symbol-metadata-polyfill.d.ts +2 -0
- package/dist/metadata/symbol-metadata-polyfill.d.ts.map +1 -0
- package/dist/metadata/symbol-metadata-polyfill.js +4 -0
- package/dist/metadata/types.d.ts +210 -0
- package/dist/metadata/types.d.ts.map +1 -0
- package/dist/metadata/types.js +1 -0
- package/dist/metadata/validation.d.ts +11 -0
- package/dist/metadata/validation.d.ts.map +1 -0
- package/dist/metadata/validation.js +93 -0
- package/dist/metadata.d.ts +9 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +7 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +103 -0
- package/package.json +52 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { fallbackClone } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic metadata bag shape used by the TC39 `Symbol.metadata` integration points.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const symbolWithMetadata = Symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Active symbol key used to read and write standard metadata bags.
|
|
10
|
+
*/
|
|
11
|
+
export let metadataSymbol = symbolWithMetadata.metadata ?? Symbol.for('fluo.symbol.metadata');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Ensures `Symbol.metadata` exists and returns the symbol used by Fluo metadata helpers.
|
|
15
|
+
*
|
|
16
|
+
* @returns The resolved metadata symbol.
|
|
17
|
+
*/
|
|
18
|
+
export function ensureMetadataSymbol() {
|
|
19
|
+
if (symbolWithMetadata.metadata) {
|
|
20
|
+
metadataSymbol = symbolWithMetadata.metadata;
|
|
21
|
+
return metadataSymbol;
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(Symbol, 'metadata', {
|
|
24
|
+
configurable: true,
|
|
25
|
+
value: metadataSymbol
|
|
26
|
+
});
|
|
27
|
+
return metadataSymbol;
|
|
28
|
+
}
|
|
29
|
+
void ensureMetadataSymbol();
|
|
30
|
+
function isPlainObject(value) {
|
|
31
|
+
if (typeof value !== 'object' || value === null) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35
|
+
return prototype === Object.prototype || prototype === null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Clones mutable metadata payloads before storing or returning them from shared metadata helpers.
|
|
40
|
+
*
|
|
41
|
+
* @param value Metadata value to clone defensively.
|
|
42
|
+
* @returns A detached clone for supported mutable shapes, or the original value for immutable references.
|
|
43
|
+
*/
|
|
44
|
+
export function cloneMutableValue(value) {
|
|
45
|
+
if (Array.isArray(value) || value instanceof Date || value instanceof Map || value instanceof Set || isPlainObject(value)) {
|
|
46
|
+
return fallbackClone(value);
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Canonical symbol keys for metadata emitted through the standard decorator metadata bag.
|
|
53
|
+
*/
|
|
54
|
+
export const standardMetadataKeys = {
|
|
55
|
+
classValidation: Symbol.for('fluo.standard.class-validation'),
|
|
56
|
+
controller: Symbol.for('fluo.standard.controller'),
|
|
57
|
+
dtoFieldBinding: Symbol.for('fluo.standard.dto-binding'),
|
|
58
|
+
dtoFieldValidation: Symbol.for('fluo.standard.dto-validation'),
|
|
59
|
+
injection: Symbol.for('fluo.standard.injection'),
|
|
60
|
+
route: Symbol.for('fluo.standard.route')
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Canonical symbol keys for Fluo-owned metadata stores.
|
|
65
|
+
*/
|
|
66
|
+
export const metadataKeys = {
|
|
67
|
+
module: Symbol.for('fluo.metadata.module'),
|
|
68
|
+
controller: Symbol.for('fluo.metadata.controller'),
|
|
69
|
+
route: Symbol.for('fluo.metadata.route'),
|
|
70
|
+
dtoFieldBinding: Symbol.for('fluo.metadata.dto-field-binding'),
|
|
71
|
+
dtoFieldValidation: Symbol.for('fluo.metadata.dto-field-validation'),
|
|
72
|
+
injection: Symbol.for('fluo.metadata.injection'),
|
|
73
|
+
classDi: Symbol.for('fluo.metadata.class-di'),
|
|
74
|
+
classValidation: Symbol.for('fluo.metadata.class-validation')
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Clones a readonly collection into a mutable array for defensive metadata reads and writes.
|
|
79
|
+
*
|
|
80
|
+
* @param collection Collection to clone.
|
|
81
|
+
* @returns A cloned mutable array, or `undefined` when the collection is absent.
|
|
82
|
+
*/
|
|
83
|
+
export function cloneCollection(collection) {
|
|
84
|
+
return collection ? collection.map(value => cloneMutableValue(value)) : undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Looks up or creates a property-keyed metadata map for a target object.
|
|
89
|
+
*
|
|
90
|
+
* @param store WeakMap-backed metadata store.
|
|
91
|
+
* @param target Target object that owns the metadata map.
|
|
92
|
+
* @returns The existing or newly created metadata map for the target.
|
|
93
|
+
*/
|
|
94
|
+
export function getOrCreatePropertyMap(store, target) {
|
|
95
|
+
let map = store.get(target);
|
|
96
|
+
if (!map) {
|
|
97
|
+
map = new Map();
|
|
98
|
+
store.set(target, map);
|
|
99
|
+
}
|
|
100
|
+
return map;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Merges two arrays into a single deduplicated array, preserving insertion order.
|
|
105
|
+
* Deduplication uses reference equality (===), so two objects with identical shapes
|
|
106
|
+
* are treated as distinct entries unless they are the exact same reference.
|
|
107
|
+
* Returns `undefined` when both inputs are empty or absent.
|
|
108
|
+
*
|
|
109
|
+
* @param existing Existing values in insertion order.
|
|
110
|
+
* @param values Additional values to merge.
|
|
111
|
+
* @returns A deduplicated merged array, or `undefined` when both inputs are empty.
|
|
112
|
+
*/
|
|
113
|
+
export function mergeUnique(existing, values) {
|
|
114
|
+
if (!existing?.length && !values?.length) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const merged = [...(existing ?? [])];
|
|
118
|
+
const seen = new Set(merged);
|
|
119
|
+
for (const value of values ?? []) {
|
|
120
|
+
if (!seen.has(value)) {
|
|
121
|
+
seen.add(value);
|
|
122
|
+
merged.push(value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return merged;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Reads the standard metadata bag stored directly on a target.
|
|
130
|
+
*
|
|
131
|
+
* @param target Target object that may own standard metadata.
|
|
132
|
+
* @returns The metadata bag when present, otherwise `undefined`.
|
|
133
|
+
*/
|
|
134
|
+
export function getStandardMetadataBag(target) {
|
|
135
|
+
const metadata = Reflect.get(target, metadataSymbol);
|
|
136
|
+
if (typeof metadata !== 'object' || metadata === null) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
return metadata;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Reads the standard metadata bag stored on a target's constructor.
|
|
144
|
+
*
|
|
145
|
+
* @param target Instance or prototype whose constructor metadata should be inspected.
|
|
146
|
+
* @returns The constructor metadata bag when present, otherwise `undefined`.
|
|
147
|
+
*/
|
|
148
|
+
export function getStandardConstructorMetadataBag(target) {
|
|
149
|
+
const constructor = target.constructor;
|
|
150
|
+
return constructor ? getStandardMetadataBag(constructor) : undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Reads a constructor-level metadata record from the standard metadata bag.
|
|
155
|
+
*
|
|
156
|
+
* @param target Instance or prototype whose constructor metadata should be inspected.
|
|
157
|
+
* @param key Symbol key of the stored metadata record.
|
|
158
|
+
* @returns The stored record when present, otherwise `undefined`.
|
|
159
|
+
*/
|
|
160
|
+
export function getStandardConstructorMetadataRecord(target, key) {
|
|
161
|
+
return getStandardConstructorMetadataBag(target)?.[key];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Reads a constructor-level property map from the standard metadata bag.
|
|
166
|
+
*
|
|
167
|
+
* @param target Instance or prototype whose constructor metadata should be inspected.
|
|
168
|
+
* @param key Symbol key of the stored metadata map.
|
|
169
|
+
* @returns The stored property map when present, otherwise `undefined`.
|
|
170
|
+
*/
|
|
171
|
+
export function getStandardConstructorMetadataMap(target, key) {
|
|
172
|
+
return getStandardConstructorMetadataRecord(target, key);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Merges stored and standard metadata property keys while preserving first-seen order.
|
|
177
|
+
*
|
|
178
|
+
* @param stored Property keys from the explicit Fluo store.
|
|
179
|
+
* @param standard Property keys from the standard metadata bag.
|
|
180
|
+
* @returns A deduplicated ordered list of metadata property keys.
|
|
181
|
+
*/
|
|
182
|
+
export function mergeMetadataPropertyKeys(stored, standard) {
|
|
183
|
+
const keys = [];
|
|
184
|
+
const seen = new Set();
|
|
185
|
+
for (const source of [stored, standard]) {
|
|
186
|
+
if (!source) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
for (const key of source.keys()) {
|
|
190
|
+
if (!seen.has(key)) {
|
|
191
|
+
seen.add(key);
|
|
192
|
+
keys.push(key);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return keys;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Appends a value into a property-keyed array store, creating the array on first write.
|
|
201
|
+
*
|
|
202
|
+
* @param store WeakMap-backed property store.
|
|
203
|
+
* @param target Target object that owns the property map.
|
|
204
|
+
* @param propertyKey Property key associated with the array entry.
|
|
205
|
+
* @param value Value to append.
|
|
206
|
+
*/
|
|
207
|
+
export function appendPropertyMapValue(store, target, propertyKey, value) {
|
|
208
|
+
const map = getOrCreatePropertyMap(store, target);
|
|
209
|
+
const existing = map.get(propertyKey);
|
|
210
|
+
if (existing) {
|
|
211
|
+
existing.push(value);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
map.set(propertyKey, [value]);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Appends a value into a WeakMap-backed array store, creating the array on first write.
|
|
219
|
+
*
|
|
220
|
+
* @param store WeakMap-backed array store.
|
|
221
|
+
* @param target Target function used as the WeakMap key.
|
|
222
|
+
* @param value Value to append.
|
|
223
|
+
*/
|
|
224
|
+
export function appendWeakMapValue(store, target, value) {
|
|
225
|
+
const existing = store.get(target);
|
|
226
|
+
if (existing) {
|
|
227
|
+
existing.push(value);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
store.set(target, [value]);
|
|
231
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clone-on-read/write metadata store contract for function/object keyed metadata records.
|
|
3
|
+
*/
|
|
4
|
+
export interface ClonedWeakMapStore<TKey extends object, TValue> {
|
|
5
|
+
read(target: TKey): TValue | undefined;
|
|
6
|
+
update(target: TKey, updateValue: (current: TValue | undefined) => TValue): void;
|
|
7
|
+
write(target: TKey, value: TValue): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a WeakMap-backed store that clones values when they enter or leave the cache.
|
|
11
|
+
*
|
|
12
|
+
* @param cloneValue Clone routine used to isolate stored metadata from caller mutations.
|
|
13
|
+
* @returns A cloned WeakMap store for metadata helpers.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createClonedWeakMapStore<TKey extends object, TValue>(cloneValue: (value: TValue) => TValue): ClonedWeakMapStore<TKey, TValue>;
|
|
16
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/metadata/store.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM;IAC7D,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,IAAI,CAAC;IACjF,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,EAClE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACpC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAelC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clone-on-read/write metadata store contract for function/object keyed metadata records.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a WeakMap-backed store that clones values when they enter or leave the cache.
|
|
7
|
+
*
|
|
8
|
+
* @param cloneValue Clone routine used to isolate stored metadata from caller mutations.
|
|
9
|
+
* @returns A cloned WeakMap store for metadata helpers.
|
|
10
|
+
*/
|
|
11
|
+
export function createClonedWeakMapStore(cloneValue) {
|
|
12
|
+
const store = new WeakMap();
|
|
13
|
+
return {
|
|
14
|
+
read(target) {
|
|
15
|
+
const value = store.get(target);
|
|
16
|
+
return value !== undefined ? cloneValue(value) : undefined;
|
|
17
|
+
},
|
|
18
|
+
update(target, updateValue) {
|
|
19
|
+
store.set(target, cloneValue(updateValue(store.get(target))));
|
|
20
|
+
},
|
|
21
|
+
write(target, value) {
|
|
22
|
+
store.set(target, cloneValue(value));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbol-metadata-polyfill.d.ts","sourceRoot":"","sources":["../../src/metadata/symbol-metadata-polyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,4BAA4B,IAAI,MAAM,CAErD"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { Constructor, MaybePromise, MetadataPropertyKey, MetadataSource, Token } from '../types.js';
|
|
2
|
+
export type MetadataCollection<T = unknown> = T[];
|
|
3
|
+
export interface ModuleMetadata {
|
|
4
|
+
imports?: MetadataCollection;
|
|
5
|
+
providers?: MetadataCollection;
|
|
6
|
+
controllers?: MetadataCollection;
|
|
7
|
+
exports?: MetadataCollection;
|
|
8
|
+
middleware?: MetadataCollection;
|
|
9
|
+
global?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ControllerMetadata {
|
|
12
|
+
basePath: string;
|
|
13
|
+
guards?: MetadataCollection;
|
|
14
|
+
interceptors?: MetadataCollection;
|
|
15
|
+
version?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RouteHeader {
|
|
18
|
+
name: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RouteRedirect {
|
|
22
|
+
url: string;
|
|
23
|
+
statusCode?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface RouteMetadata {
|
|
26
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
27
|
+
path: string;
|
|
28
|
+
request?: new (...args: never[]) => unknown;
|
|
29
|
+
guards?: MetadataCollection;
|
|
30
|
+
headers?: RouteHeader[];
|
|
31
|
+
interceptors?: MetadataCollection;
|
|
32
|
+
redirect?: RouteRedirect;
|
|
33
|
+
successStatus?: number;
|
|
34
|
+
version?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DtoFieldBindingMetadata {
|
|
37
|
+
source: MetadataSource;
|
|
38
|
+
key?: string;
|
|
39
|
+
optional?: boolean;
|
|
40
|
+
converter?: Token | {
|
|
41
|
+
convert(value: unknown, target: unknown): MaybePromise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface ValidationIssueMetadata {
|
|
45
|
+
code: string;
|
|
46
|
+
field?: string;
|
|
47
|
+
message: string;
|
|
48
|
+
source?: MetadataSource;
|
|
49
|
+
}
|
|
50
|
+
export type ValidationRuleResult = boolean | void | ValidationIssueMetadata | readonly ValidationIssueMetadata[];
|
|
51
|
+
export interface ValidationDecoratorOptions {
|
|
52
|
+
code?: string;
|
|
53
|
+
each?: boolean;
|
|
54
|
+
message?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CustomValidationDecoratorOptions extends ValidationDecoratorOptions {
|
|
57
|
+
source?: MetadataSource;
|
|
58
|
+
}
|
|
59
|
+
export interface CustomFieldValidationContext<T = unknown> {
|
|
60
|
+
dto: T;
|
|
61
|
+
propertyKey: MetadataPropertyKey;
|
|
62
|
+
}
|
|
63
|
+
export type CustomFieldValidator<T = unknown> = (value: unknown, context: CustomFieldValidationContext<T>) => MaybePromise<ValidationRuleResult>;
|
|
64
|
+
export type CustomClassValidator<T = unknown> = (value: T) => MaybePromise<ValidationRuleResult>;
|
|
65
|
+
export type ConditionalFieldValidator<T = unknown> = (dto: T, value: unknown) => MaybePromise<boolean>;
|
|
66
|
+
export type DtoFieldValidationRule = ({
|
|
67
|
+
kind: 'validateIf';
|
|
68
|
+
validateIf: ConditionalFieldValidator;
|
|
69
|
+
} & ValidationDecoratorOptions) | ({
|
|
70
|
+
kind: 'defined';
|
|
71
|
+
} & ValidationDecoratorOptions) | ({
|
|
72
|
+
kind: 'optional';
|
|
73
|
+
} & ValidationDecoratorOptions) | ({
|
|
74
|
+
kind: 'equals';
|
|
75
|
+
value: unknown;
|
|
76
|
+
} & ValidationDecoratorOptions) | ({
|
|
77
|
+
kind: 'notEquals';
|
|
78
|
+
value: unknown;
|
|
79
|
+
} & ValidationDecoratorOptions) | ({
|
|
80
|
+
kind: 'empty';
|
|
81
|
+
} & ValidationDecoratorOptions) | ({
|
|
82
|
+
kind: 'notEmpty';
|
|
83
|
+
} & ValidationDecoratorOptions) | ({
|
|
84
|
+
kind: 'in';
|
|
85
|
+
values: readonly unknown[];
|
|
86
|
+
} & ValidationDecoratorOptions) | ({
|
|
87
|
+
kind: 'notIn';
|
|
88
|
+
values: readonly unknown[];
|
|
89
|
+
} & ValidationDecoratorOptions) | ({
|
|
90
|
+
kind: 'string';
|
|
91
|
+
} & ValidationDecoratorOptions) | ({
|
|
92
|
+
kind: 'number';
|
|
93
|
+
allowNaN?: boolean;
|
|
94
|
+
} & ValidationDecoratorOptions) | ({
|
|
95
|
+
kind: 'boolean';
|
|
96
|
+
} & ValidationDecoratorOptions) | ({
|
|
97
|
+
kind: 'date';
|
|
98
|
+
} & ValidationDecoratorOptions) | ({
|
|
99
|
+
kind: 'array';
|
|
100
|
+
} & ValidationDecoratorOptions) | ({
|
|
101
|
+
kind: 'object';
|
|
102
|
+
} & ValidationDecoratorOptions) | ({
|
|
103
|
+
kind: 'enum';
|
|
104
|
+
values: readonly unknown[];
|
|
105
|
+
} & ValidationDecoratorOptions) | ({
|
|
106
|
+
kind: 'int';
|
|
107
|
+
} & ValidationDecoratorOptions) | ({
|
|
108
|
+
kind: 'divisibleBy';
|
|
109
|
+
value: number;
|
|
110
|
+
} & ValidationDecoratorOptions) | ({
|
|
111
|
+
kind: 'positive';
|
|
112
|
+
} & ValidationDecoratorOptions) | ({
|
|
113
|
+
kind: 'negative';
|
|
114
|
+
} & ValidationDecoratorOptions) | ({
|
|
115
|
+
kind: 'min';
|
|
116
|
+
value: number;
|
|
117
|
+
} & ValidationDecoratorOptions) | ({
|
|
118
|
+
kind: 'max';
|
|
119
|
+
value: number;
|
|
120
|
+
} & ValidationDecoratorOptions) | ({
|
|
121
|
+
kind: 'minDate';
|
|
122
|
+
value: Date;
|
|
123
|
+
} & ValidationDecoratorOptions) | ({
|
|
124
|
+
kind: 'maxDate';
|
|
125
|
+
value: Date;
|
|
126
|
+
} & ValidationDecoratorOptions) | ({
|
|
127
|
+
kind: 'contains';
|
|
128
|
+
value: string;
|
|
129
|
+
} & ValidationDecoratorOptions) | ({
|
|
130
|
+
kind: 'notContains';
|
|
131
|
+
value: string;
|
|
132
|
+
} & ValidationDecoratorOptions) | ({
|
|
133
|
+
kind: 'length';
|
|
134
|
+
min: number;
|
|
135
|
+
max?: number;
|
|
136
|
+
} & ValidationDecoratorOptions) | ({
|
|
137
|
+
kind: 'minLength';
|
|
138
|
+
value: number;
|
|
139
|
+
} & ValidationDecoratorOptions) | ({
|
|
140
|
+
kind: 'maxLength';
|
|
141
|
+
value: number;
|
|
142
|
+
} & ValidationDecoratorOptions) | ({
|
|
143
|
+
kind: 'nested';
|
|
144
|
+
dto: Constructor | (() => Constructor);
|
|
145
|
+
} & ValidationDecoratorOptions) | ({
|
|
146
|
+
kind: 'validatorjs';
|
|
147
|
+
validator: 'alpha' | 'alphanumeric' | 'ascii' | 'base64' | 'booleanString' | 'currency' | 'dataURI' | 'dateString' | 'decimal' | 'email' | 'fqdn' | 'hexColor' | 'hexadecimal' | 'ip' | 'isbn' | 'issn' | 'json' | 'jwt' | 'locale' | 'lowercase' | 'magnetURI' | 'matches' | 'mimeType' | 'mobilePhone' | 'mongoId' | 'numberString' | 'port' | 'postalCode' | 'rgbColor' | 'rfc3339' | 'semVer' | 'uppercase' | 'url' | 'uuid' | 'iso8601' | 'latitude' | 'longitude' | 'latLong';
|
|
148
|
+
args?: readonly unknown[];
|
|
149
|
+
} & ValidationDecoratorOptions) | ({
|
|
150
|
+
kind: 'arrayContains';
|
|
151
|
+
values: readonly unknown[];
|
|
152
|
+
} & ValidationDecoratorOptions) | ({
|
|
153
|
+
kind: 'arrayNotContains';
|
|
154
|
+
values: readonly unknown[];
|
|
155
|
+
} & ValidationDecoratorOptions) | ({
|
|
156
|
+
kind: 'arrayNotEmpty';
|
|
157
|
+
} & ValidationDecoratorOptions) | ({
|
|
158
|
+
kind: 'arrayMinSize';
|
|
159
|
+
value: number;
|
|
160
|
+
} & ValidationDecoratorOptions) | ({
|
|
161
|
+
kind: 'arrayMaxSize';
|
|
162
|
+
value: number;
|
|
163
|
+
} & ValidationDecoratorOptions) | ({
|
|
164
|
+
kind: 'arrayUnique';
|
|
165
|
+
selector?: (value: unknown) => unknown;
|
|
166
|
+
} & ValidationDecoratorOptions) | ({
|
|
167
|
+
kind: 'custom';
|
|
168
|
+
validate: CustomFieldValidator;
|
|
169
|
+
source?: MetadataSource;
|
|
170
|
+
} & ValidationDecoratorOptions);
|
|
171
|
+
export interface ClassValidationRule {
|
|
172
|
+
code?: string;
|
|
173
|
+
message?: string;
|
|
174
|
+
validate: CustomClassValidator;
|
|
175
|
+
}
|
|
176
|
+
export interface InjectionMetadata {
|
|
177
|
+
token: unknown;
|
|
178
|
+
optional?: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface ClassDiMetadata {
|
|
181
|
+
inject?: Token[];
|
|
182
|
+
scope?: 'singleton' | 'request' | 'transient';
|
|
183
|
+
}
|
|
184
|
+
export interface DtoBindingSchemaEntry {
|
|
185
|
+
propertyKey: MetadataPropertyKey;
|
|
186
|
+
metadata: DtoFieldBindingMetadata;
|
|
187
|
+
}
|
|
188
|
+
export interface DtoValidationSchemaEntry {
|
|
189
|
+
propertyKey: MetadataPropertyKey;
|
|
190
|
+
rules: readonly DtoFieldValidationRule[];
|
|
191
|
+
}
|
|
192
|
+
export interface InjectionSchemaEntry {
|
|
193
|
+
propertyKey: MetadataPropertyKey;
|
|
194
|
+
metadata: InjectionMetadata;
|
|
195
|
+
}
|
|
196
|
+
export interface StandardRouteMetadataRecord {
|
|
197
|
+
guards?: MetadataCollection;
|
|
198
|
+
headers?: RouteHeader[];
|
|
199
|
+
interceptors?: MetadataCollection;
|
|
200
|
+
method?: RouteMetadata['method'];
|
|
201
|
+
path?: string;
|
|
202
|
+
redirect?: RouteRedirect;
|
|
203
|
+
request?: new (...args: never[]) => unknown;
|
|
204
|
+
successStatus?: number;
|
|
205
|
+
version?: string;
|
|
206
|
+
}
|
|
207
|
+
export type StandardDtoBindingRecord = Partial<DtoFieldBindingMetadata>;
|
|
208
|
+
export type StandardDtoValidationRecord = DtoFieldValidationRule[];
|
|
209
|
+
export type StandardInjectionRecord = Partial<InjectionMetadata>;
|
|
210
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC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,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,EAAE,CAAC;AACnE,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClassValidationRule, DtoBindingSchemaEntry, DtoFieldBindingMetadata, DtoFieldValidationRule, DtoValidationSchemaEntry } from './types.js';
|
|
2
|
+
import type { Constructor, MetadataPropertyKey } from '../types.js';
|
|
3
|
+
export declare function getDtoFieldBindingMetadata(target: object, propertyKey: MetadataPropertyKey): DtoFieldBindingMetadata | undefined;
|
|
4
|
+
export declare function defineDtoFieldBindingMetadata(target: object, propertyKey: MetadataPropertyKey, metadata: DtoFieldBindingMetadata): void;
|
|
5
|
+
export declare function appendDtoFieldValidationRule(target: object, propertyKey: MetadataPropertyKey, rule: DtoFieldValidationRule): void;
|
|
6
|
+
export declare function appendClassValidationRule(target: Function, rule: ClassValidationRule): void;
|
|
7
|
+
export declare function getDtoBindingSchema(dto: Constructor): DtoBindingSchemaEntry[];
|
|
8
|
+
export declare function getDtoFieldValidationRules(target: object, propertyKey: MetadataPropertyKey): readonly DtoFieldValidationRule[];
|
|
9
|
+
export declare function getDtoValidationSchema(dto: Constructor): DtoValidationSchemaEntry[];
|
|
10
|
+
export declare function getClassValidationRules(target: Function): readonly ClassValidationRule[];
|
|
11
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/metadata/validation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EAGzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAsBpE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,SAAS,CAiBhI;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,uBAAuB,GAChC,IAAI,CAEN;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,EAChC,IAAI,EAAE,sBAAsB,GAC3B,IAAI,CAEN;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAI3F;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,qBAAqB,EAAE,CA8B7E;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,GAAG,SAAS,sBAAsB,EAAE,CAQ9H;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,WAAW,GAAG,wBAAwB,EAAE,CAiBnF;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,mBAAmB,EAAE,CAExF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { appendPropertyMapValue, cloneMutableValue, getOrCreatePropertyMap, getStandardConstructorMetadataMap, getStandardMetadataBag, mergeMetadataPropertyKeys, standardMetadataKeys } from './shared.js';
|
|
2
|
+
import { createClonedWeakMapStore } from './store.js';
|
|
3
|
+
const dtoFieldBindingStore = new WeakMap();
|
|
4
|
+
const dtoFieldValidationStore = new WeakMap();
|
|
5
|
+
const classValidationStore = createClonedWeakMapStore(rules => rules.map(rule => cloneMutableValue(rule)));
|
|
6
|
+
function getStandardDtoBindingMap(target) {
|
|
7
|
+
return getStandardConstructorMetadataMap(target, standardMetadataKeys.dtoFieldBinding);
|
|
8
|
+
}
|
|
9
|
+
function getStandardDtoValidationMap(target) {
|
|
10
|
+
return getStandardConstructorMetadataMap(target, standardMetadataKeys.dtoFieldValidation);
|
|
11
|
+
}
|
|
12
|
+
function getStandardClassValidationRules(target) {
|
|
13
|
+
const rules = getStandardMetadataBag(target)?.[standardMetadataKeys.classValidation];
|
|
14
|
+
return rules ? rules.map(rule => cloneMutableValue(rule)) : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function getDtoFieldBindingMetadata(target, propertyKey) {
|
|
17
|
+
const stored = dtoFieldBindingStore.get(target)?.get(propertyKey);
|
|
18
|
+
const standard = getStandardDtoBindingMap(target)?.get(propertyKey);
|
|
19
|
+
const source = stored?.source ?? standard?.source;
|
|
20
|
+
if (!source) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const converter = stored?.converter ?? standard?.converter;
|
|
24
|
+
return {
|
|
25
|
+
...(converter === undefined ? {} : {
|
|
26
|
+
converter
|
|
27
|
+
}),
|
|
28
|
+
key: stored?.key ?? standard?.key,
|
|
29
|
+
optional: stored?.optional ?? standard?.optional,
|
|
30
|
+
source
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function defineDtoFieldBindingMetadata(target, propertyKey, metadata) {
|
|
34
|
+
getOrCreatePropertyMap(dtoFieldBindingStore, target).set(propertyKey, {
|
|
35
|
+
...metadata
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export function appendDtoFieldValidationRule(target, propertyKey, rule) {
|
|
39
|
+
appendPropertyMapValue(dtoFieldValidationStore, target, propertyKey, cloneMutableValue(rule));
|
|
40
|
+
}
|
|
41
|
+
export function appendClassValidationRule(target, rule) {
|
|
42
|
+
const rules = classValidationStore.read(target) ?? [];
|
|
43
|
+
rules.push(cloneMutableValue(rule));
|
|
44
|
+
classValidationStore.write(target, rules);
|
|
45
|
+
}
|
|
46
|
+
export function getDtoBindingSchema(dto) {
|
|
47
|
+
const stored = dtoFieldBindingStore.get(dto.prototype) ?? new Map();
|
|
48
|
+
const standard = getStandardMetadataBag(dto)?.[standardMetadataKeys.dtoFieldBinding] ?? new Map();
|
|
49
|
+
const keys = mergeMetadataPropertyKeys(stored, standard);
|
|
50
|
+
return keys.flatMap(propertyKey => {
|
|
51
|
+
const storedEntry = stored.get(propertyKey);
|
|
52
|
+
const standardEntry = standard.get(propertyKey);
|
|
53
|
+
const source = storedEntry?.source ?? standardEntry?.source;
|
|
54
|
+
if (!source) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const converter = storedEntry?.converter ?? standardEntry?.converter;
|
|
58
|
+
return [{
|
|
59
|
+
propertyKey,
|
|
60
|
+
metadata: {
|
|
61
|
+
...(converter === undefined ? {} : {
|
|
62
|
+
converter
|
|
63
|
+
}),
|
|
64
|
+
key: storedEntry?.key ?? standardEntry?.key,
|
|
65
|
+
optional: storedEntry?.optional ?? standardEntry?.optional,
|
|
66
|
+
source
|
|
67
|
+
}
|
|
68
|
+
}];
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function getDtoFieldValidationRules(target, propertyKey) {
|
|
72
|
+
const stored = dtoFieldValidationStore.get(target)?.get(propertyKey) ?? [];
|
|
73
|
+
const standard = getStandardDtoValidationMap(target)?.get(propertyKey) ?? [];
|
|
74
|
+
return [...standard.map(rule => cloneMutableValue(rule)), ...stored.map(rule => cloneMutableValue(rule))];
|
|
75
|
+
}
|
|
76
|
+
export function getDtoValidationSchema(dto) {
|
|
77
|
+
const stored = dtoFieldValidationStore.get(dto.prototype) ?? new Map();
|
|
78
|
+
const standard = getStandardDtoValidationMap(dto.prototype) ?? new Map();
|
|
79
|
+
const keys = mergeMetadataPropertyKeys(stored, standard);
|
|
80
|
+
return keys.flatMap(propertyKey => {
|
|
81
|
+
const rules = [...(standard.get(propertyKey) ?? []).map(rule => cloneMutableValue(rule)), ...(stored.get(propertyKey) ?? []).map(rule => cloneMutableValue(rule))];
|
|
82
|
+
if (rules.length === 0) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
return [{
|
|
86
|
+
propertyKey,
|
|
87
|
+
rules
|
|
88
|
+
}];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export function getClassValidationRules(target) {
|
|
92
|
+
return [...(getStandardClassValidationRules(target) ?? []), ...(classValidationStore.read(target) ?? [])];
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { getClassDiMetadata, getInheritedClassDiMetadata, getOwnClassDiMetadata, defineClassDiMetadata } from './metadata/class-di.js';
|
|
2
|
+
export { defineControllerMetadata, defineRouteMetadata, getControllerMetadata, getRouteMetadata } from './metadata/controller-route.js';
|
|
3
|
+
export { defineInjectionMetadata, getInjectionSchema } from './metadata/injection.js';
|
|
4
|
+
export { defineModuleMetadata, getModuleMetadata } from './metadata/module.js';
|
|
5
|
+
export { ensureMetadataSymbol, metadataKeys, metadataSymbol } from './metadata/shared.js';
|
|
6
|
+
export { ensureSymbolMetadataPolyfill } from './metadata/symbol-metadata-polyfill.js';
|
|
7
|
+
export { appendClassValidationRule, appendDtoFieldValidationRule, defineDtoFieldBindingMetadata, getClassValidationRules, getDtoBindingSchema, getDtoFieldBindingMetadata, getDtoFieldValidationRules, getDtoValidationSchema, } from './metadata/validation.js';
|
|
8
|
+
export type { ClassDiMetadata, ClassValidationRule, ConditionalFieldValidator, ControllerMetadata, CustomClassValidator, CustomFieldValidationContext, CustomFieldValidator, CustomValidationDecoratorOptions, DtoBindingSchemaEntry, DtoFieldBindingMetadata, DtoFieldValidationRule, DtoValidationSchemaEntry, InjectionMetadata, InjectionSchemaEntry, MetadataCollection, ModuleMetadata, RouteHeader, RouteMetadata, RouteRedirect, ValidationDecoratorOptions, ValidationIssueMetadata, ValidationRuleResult, } from './metadata/types.js';
|
|
9
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACvI,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACxI,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,EACpB,gCAAgC,EAChC,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,aAAa,EACb,aAAa,EACb,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getClassDiMetadata, getInheritedClassDiMetadata, getOwnClassDiMetadata, defineClassDiMetadata } from './metadata/class-di.js';
|
|
2
|
+
export { defineControllerMetadata, defineRouteMetadata, getControllerMetadata, getRouteMetadata } from './metadata/controller-route.js';
|
|
3
|
+
export { defineInjectionMetadata, getInjectionSchema } from './metadata/injection.js';
|
|
4
|
+
export { defineModuleMetadata, getModuleMetadata } from './metadata/module.js';
|
|
5
|
+
export { ensureMetadataSymbol, metadataKeys, metadataSymbol } from './metadata/shared.js';
|
|
6
|
+
export { ensureSymbolMetadataPolyfill } from './metadata/symbol-metadata-polyfill.js';
|
|
7
|
+
export { appendClassValidationRule, appendDtoFieldValidationRule, defineDtoFieldBindingMetadata, getClassValidationRules, getDtoBindingSchema, getDtoFieldBindingMetadata, getDtoFieldValidationRules, getDtoValidationSchema } from './metadata/validation.js';
|