@orion-js/typed-model 4.0.0-alpha.3 → 4.0.0-next.0
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/index.cjs +2 -2
- package/dist/index.d.ts +11 -458
- package/dist/index.js +2 -2
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -196,7 +196,7 @@ class PropertyAlreadyExistsError extends Error {
|
|
|
196
196
|
super(`Schema with name "${schemaName}" already contains property "${propertyName}".`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
//
|
|
199
|
+
// node_modules/@orion-js/helpers/dist/index.js
|
|
200
200
|
var import_node_module = require("node:module");
|
|
201
201
|
var import_crypto = __toESM(require("crypto"));
|
|
202
202
|
var __create2 = Object.create;
|
|
@@ -1821,7 +1821,7 @@ function getSchemaForClassRecursive(target) {
|
|
|
1821
1821
|
function getSchemaForClass(target) {
|
|
1822
1822
|
return getSchemaForClassRecursive(target);
|
|
1823
1823
|
}
|
|
1824
|
-
//
|
|
1824
|
+
// node_modules/@orion-js/models/dist/index.js
|
|
1825
1825
|
var __create3 = Object.create;
|
|
1826
1826
|
var __getProtoOf3 = Object.getPrototypeOf;
|
|
1827
1827
|
var __defProp3 = Object.defineProperty;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,476 +1,29 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value: any;
|
|
8
|
-
expires?: Date;
|
|
9
|
-
}
|
|
10
|
-
export interface SetCacheOptions {
|
|
11
|
-
ttl?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface GetCacheOptions {
|
|
14
|
-
ttl?: number;
|
|
15
|
-
fallback?(): Promise<any>;
|
|
16
|
-
}
|
|
17
|
-
export interface OrionCache {
|
|
18
|
-
/**
|
|
19
|
-
* Save data in the cache
|
|
20
|
-
*/
|
|
21
|
-
set(key: string, value: any, options?: SetCacheOptions): Promise<void> | void;
|
|
22
|
-
/**
|
|
23
|
-
* Get data from the cache
|
|
24
|
-
*/
|
|
25
|
-
get(key: string, options?: GetCacheOptions): Promise<StoredCacheData>;
|
|
26
|
-
/**
|
|
27
|
-
* Removes data from the cache
|
|
28
|
-
*/
|
|
29
|
-
invalidate(key: string): Promise<void> | void;
|
|
30
|
-
}
|
|
31
|
-
export type Blackbox = {
|
|
32
|
-
[name: string]: any;
|
|
33
|
-
};
|
|
34
|
-
export type ModelResolverResolve = (item: any, params: any, viewer: any, info?: any) => Promise<any>;
|
|
35
|
-
export type GlobalCheckPermissions = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
36
|
-
export type ModelCheckPermissions = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
37
|
-
export type GlobalGetCacheKey = (params: any, viewer: any, info: any) => Promise<any>;
|
|
38
|
-
export type ModelGetCacheKey = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
39
|
-
export interface ExecuteOptions {
|
|
40
|
-
params: Blackbox;
|
|
41
|
-
viewer: any;
|
|
42
|
-
parent?: any;
|
|
43
|
-
info?: any;
|
|
44
|
-
options: ResolverOptions;
|
|
45
|
-
}
|
|
46
|
-
export type Parameters$1<T> = T extends (...args: infer P) => any ? P : never;
|
|
47
|
-
export type ReturnType$1<T> = T extends (...args: any) => infer R ? R : any;
|
|
48
|
-
export type ResolverParams<Resolve, IsModel> = IsModel extends undefined ? Parameters$1<Resolve>[0] : Parameters$1<Resolve>[1];
|
|
49
|
-
export interface ExecuteParams<Resolve = Function, IsModel = undefined> {
|
|
50
|
-
params?: ResolverParams<Resolve, IsModel>;
|
|
51
|
-
viewer?: any;
|
|
52
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1<Resolve>[0];
|
|
53
|
-
info?: any;
|
|
54
|
-
}
|
|
55
|
-
export type Execute<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams<Resolve, IsModel>) => ReturnType$1<Resolve>;
|
|
56
|
-
export interface SharedResolverOptions {
|
|
57
|
-
resolverId?: string;
|
|
58
|
-
params?: any;
|
|
59
|
-
returns?: any;
|
|
60
|
-
mutation?: boolean;
|
|
61
|
-
private?: boolean;
|
|
62
|
-
checkPermission?: GlobalCheckPermissions | ModelCheckPermissions;
|
|
63
|
-
getCacheKey?: GlobalGetCacheKey | ModelGetCacheKey;
|
|
64
|
-
cache?: number;
|
|
65
|
-
cacheProvider?: OrionCache;
|
|
66
|
-
permissionsOptions?: any;
|
|
67
|
-
middlewares?: ResolverMiddleware[];
|
|
68
|
-
}
|
|
69
|
-
export interface ResolverOptions<Resolve = Function> extends SharedResolverOptions {
|
|
70
|
-
resolve: Resolve;
|
|
71
|
-
}
|
|
72
|
-
export type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
73
|
-
export interface Resolver<Resolve = Function, IsModel = undefined> extends SharedResolverOptions {
|
|
74
|
-
execute: Execute<Resolve, IsModel>;
|
|
75
|
-
resolve: Resolve;
|
|
76
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg<Resolve>;
|
|
77
|
-
}
|
|
78
|
-
export type ModelResolver<Resolve = Function> = Resolver<Resolve, true>;
|
|
79
|
-
export type ResolverMiddleware = (executeOptions: ExecuteOptions, next: () => Promise<any>) => Promise<any>;
|
|
80
|
-
export interface FieldType {
|
|
81
|
-
name: string;
|
|
82
|
-
validate: ValidateFunction;
|
|
83
|
-
clean: CleanFunction;
|
|
84
|
-
meta?: any;
|
|
85
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
86
|
-
_isFieldType: boolean;
|
|
87
|
-
}
|
|
88
|
-
export type Constructor<T> = new (...args: any[]) => T;
|
|
89
|
-
export type FieldTypesList = "string" | "date" | "integer" | "number" | "ID" | "boolean" | "email" | "blackbox" | "any";
|
|
90
|
-
export type TypedModelOnSchema = Function;
|
|
91
|
-
export type ConstructorsTypesList = Constructor<String> | Constructor<Number> | Constructor<Boolean> | Constructor<Date>;
|
|
92
|
-
export type SchemaRecursiveNodeTypeExtras = {
|
|
93
|
-
_isFieldType?: boolean;
|
|
94
|
-
__clean?: CleanFunction;
|
|
95
|
-
__validate?: ValidateFunction;
|
|
96
|
-
__skipChildValidation?: (value: any, info: CurrentNodeInfo) => Promise<boolean>;
|
|
97
|
-
};
|
|
98
|
-
export interface Schema {
|
|
99
|
-
[key: string]: SchemaNode | Function;
|
|
100
|
-
}
|
|
101
|
-
export type SchemaRecursiveNodeType = Schema & SchemaRecursiveNodeTypeExtras;
|
|
102
|
-
export type SchemaMetaFieldTypeSingle = FieldTypesList | ConstructorsTypesList | SchemaRecursiveNodeType | FieldType | TypedModelOnSchema;
|
|
103
|
-
export type SchemaMetaFieldType = SchemaMetaFieldTypeSingle | SchemaMetaFieldTypeSingle[];
|
|
104
|
-
export type ValidateFunction = (value: any, info?: Partial<CurrentNodeInfo>, ...args: any[]) => object | string | void | Promise<object | string | void>;
|
|
105
|
-
export type CleanFunction = (value: any, info?: Partial<CurrentNodeInfo>, ...args: any[]) => any | Promise<any>;
|
|
106
|
-
export interface SchemaNode {
|
|
107
|
-
/**
|
|
108
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
109
|
-
*/
|
|
110
|
-
type: SchemaMetaFieldType;
|
|
111
|
-
/**
|
|
112
|
-
* Defaults to false
|
|
113
|
-
*/
|
|
114
|
-
optional?: boolean;
|
|
115
|
-
allowedValues?: Array<any>;
|
|
116
|
-
defaultValue?: ((info: CurrentNodeInfo, ...args: any[]) => any | Promise<any>) | any;
|
|
117
|
-
/**
|
|
118
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
119
|
-
*/
|
|
120
|
-
validate?: ValidateFunction;
|
|
121
|
-
/**
|
|
122
|
-
* Function that preprocesses a value before it is set.
|
|
123
|
-
*/
|
|
124
|
-
clean?: CleanFunction;
|
|
125
|
-
autoValue?: (value: any, info: CurrentNodeInfo, ...args: any[]) => any | Promise<any>;
|
|
126
|
-
/**
|
|
127
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
128
|
-
*/
|
|
129
|
-
min?: number;
|
|
130
|
-
/**
|
|
131
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
132
|
-
*/
|
|
133
|
-
max?: number;
|
|
134
|
-
/**
|
|
135
|
-
* Internal use only.
|
|
136
|
-
*/
|
|
137
|
-
isBlackboxChild?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated
|
|
140
|
-
*/
|
|
141
|
-
custom?: ValidateFunction;
|
|
142
|
-
/**
|
|
143
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
144
|
-
*/
|
|
145
|
-
private?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
148
|
-
*/
|
|
149
|
-
graphQLResolver?: (...args: any) => any;
|
|
150
|
-
/**
|
|
151
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
152
|
-
*/
|
|
153
|
-
key?: string;
|
|
154
|
-
/**
|
|
155
|
-
* The name that would be displayed in a front-end form
|
|
156
|
-
*/
|
|
157
|
-
label?: string;
|
|
158
|
-
/**
|
|
159
|
-
* The description that would be displayed in a front-end form
|
|
160
|
-
*/
|
|
161
|
-
description?: string;
|
|
162
|
-
/**
|
|
163
|
-
* The placeholder that would be displayed in a front-end form
|
|
164
|
-
*/
|
|
165
|
-
placeholder?: string;
|
|
166
|
-
/**
|
|
167
|
-
* The field type that would be used in a front-end form
|
|
168
|
-
*/
|
|
169
|
-
fieldType?: string;
|
|
170
|
-
/**
|
|
171
|
-
* The field options that will be passed as props to the front-end field
|
|
172
|
-
*/
|
|
173
|
-
fieldOptions?: any;
|
|
174
|
-
}
|
|
175
|
-
export interface CurrentNodeInfoOptions {
|
|
176
|
-
autoConvert?: boolean;
|
|
177
|
-
filter?: boolean;
|
|
178
|
-
trimStrings?: boolean;
|
|
179
|
-
removeEmptyStrings?: boolean;
|
|
180
|
-
forceDoc?: any;
|
|
181
|
-
omitRequired?: boolean;
|
|
182
|
-
}
|
|
183
|
-
export interface CurrentNodeInfo {
|
|
184
|
-
/**
|
|
185
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
186
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
187
|
-
*/
|
|
188
|
-
schema?: SchemaNode | Schema;
|
|
189
|
-
/**
|
|
190
|
-
* The current node subschema
|
|
191
|
-
*/
|
|
192
|
-
currentSchema?: Partial<SchemaNode>;
|
|
193
|
-
value: any;
|
|
194
|
-
doc?: any;
|
|
195
|
-
currentDoc?: any;
|
|
196
|
-
options?: CurrentNodeInfoOptions;
|
|
197
|
-
args?: any[];
|
|
198
|
-
type?: SchemaMetaFieldType;
|
|
199
|
-
keys?: string[];
|
|
200
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
201
|
-
}
|
|
202
|
-
export interface ModelResolversMap {
|
|
203
|
-
[key: string]: ModelResolver<ModelResolverResolve>;
|
|
204
|
-
}
|
|
205
|
-
export interface CloneOptions {
|
|
206
|
-
name: string;
|
|
207
|
-
omitFields?: string[];
|
|
208
|
-
pickFields?: string[];
|
|
209
|
-
mapFields?: (field: any, key: string) => any;
|
|
210
|
-
extendSchema?: Schema;
|
|
211
|
-
extendResolvers?: ModelResolversMap;
|
|
212
|
-
}
|
|
213
|
-
export interface Model<TSchema = any> {
|
|
214
|
-
__isModel: boolean;
|
|
215
|
-
/**
|
|
216
|
-
* The name of the model, used for example for GraphQL
|
|
217
|
-
*/
|
|
218
|
-
name: string;
|
|
219
|
-
/**
|
|
220
|
-
* Returns the schema of the model
|
|
221
|
-
*/
|
|
222
|
-
getSchema: () => Schema & {
|
|
223
|
-
__model: Model;
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Returns the schema without adding __model to the schema
|
|
227
|
-
*/
|
|
228
|
-
getCleanSchema: () => Schema;
|
|
229
|
-
/**
|
|
230
|
-
* Returns the model resolvers
|
|
231
|
-
*/
|
|
232
|
-
getResolvers: () => ModelResolversMap;
|
|
233
|
-
/**
|
|
234
|
-
* Adds the model resolvers to a item
|
|
235
|
-
*/
|
|
236
|
-
initItem: (item: any) => any;
|
|
237
|
-
/**
|
|
238
|
-
* Validates an item using @orion-js/schema
|
|
239
|
-
*/
|
|
240
|
-
validate: (item: any) => Promise<any>;
|
|
241
|
-
/**
|
|
242
|
-
* Cleans an item using @orion-js/schema
|
|
243
|
-
*/
|
|
244
|
-
clean: (item: any) => Promise<TSchema>;
|
|
245
|
-
/**
|
|
246
|
-
* Cleans and validates an item using @orion-js/schema
|
|
247
|
-
*/
|
|
248
|
-
cleanAndValidate: (item: any) => Promise<TSchema>;
|
|
249
|
-
/**
|
|
250
|
-
* Creates a new model using this one as a base
|
|
251
|
-
*/
|
|
252
|
-
clone: (cloneOptions: CloneOptions) => Model;
|
|
253
|
-
/**
|
|
254
|
-
* The type of the model. Only use this in typescript
|
|
255
|
-
*/
|
|
256
|
-
type: TSchema;
|
|
257
|
-
}
|
|
258
|
-
interface StoredCacheData$1 {
|
|
259
|
-
value: any;
|
|
260
|
-
expires?: Date;
|
|
261
|
-
}
|
|
262
|
-
interface SetCacheOptions$1 {
|
|
263
|
-
ttl?: number;
|
|
264
|
-
}
|
|
265
|
-
interface GetCacheOptions$1 {
|
|
266
|
-
ttl?: number;
|
|
267
|
-
fallback?(): Promise<any>;
|
|
268
|
-
}
|
|
269
|
-
interface OrionCache$1 {
|
|
270
|
-
/**
|
|
271
|
-
* Save data in the cache
|
|
272
|
-
*/
|
|
273
|
-
set(key: string, value: any, options?: SetCacheOptions$1): Promise<void> | void;
|
|
274
|
-
/**
|
|
275
|
-
* Get data from the cache
|
|
276
|
-
*/
|
|
277
|
-
get(key: string, options?: GetCacheOptions$1): Promise<StoredCacheData$1>;
|
|
278
|
-
/**
|
|
279
|
-
* Removes data from the cache
|
|
280
|
-
*/
|
|
281
|
-
invalidate(key: string): Promise<void> | void;
|
|
282
|
-
}
|
|
283
|
-
type Blackbox$1 = {
|
|
284
|
-
[name: string]: any;
|
|
285
|
-
};
|
|
286
|
-
type ModelResolverResolve$1 = (item: any, params: any, viewer: any, info?: any) => Promise<any>;
|
|
287
|
-
type GlobalCheckPermissions$1 = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
288
|
-
type ModelCheckPermissions$1 = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
289
|
-
type GlobalGetCacheKey$1 = (params: any, viewer: any, info: any) => Promise<any>;
|
|
290
|
-
type ModelGetCacheKey$1 = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
291
|
-
interface ExecuteOptions$1 {
|
|
292
|
-
params: Blackbox$1;
|
|
293
|
-
viewer: any;
|
|
294
|
-
parent?: any;
|
|
295
|
-
info?: any;
|
|
296
|
-
options: ResolverOptions$1;
|
|
297
|
-
}
|
|
298
|
-
type Parameters$1$1<T> = T extends (...args: infer P) => any ? P : never;
|
|
299
|
-
type ReturnType$1$1<T> = T extends (...args: any) => infer R ? R : any;
|
|
300
|
-
type ResolverParams$1<Resolve, IsModel> = IsModel extends undefined ? Parameters$1$1<Resolve>[0] : Parameters$1$1<Resolve>[1];
|
|
301
|
-
interface ExecuteParams$1<Resolve = Function, IsModel = undefined> {
|
|
302
|
-
params?: ResolverParams$1<Resolve, IsModel>;
|
|
303
|
-
viewer?: any;
|
|
304
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1$1<Resolve>[0];
|
|
305
|
-
info?: any;
|
|
306
|
-
}
|
|
307
|
-
type Execute$1<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams$1<Resolve, IsModel>) => ReturnType$1$1<Resolve>;
|
|
308
|
-
interface SharedResolverOptions$1 {
|
|
309
|
-
resolverId?: string;
|
|
310
|
-
params?: any;
|
|
311
|
-
returns?: any;
|
|
312
|
-
mutation?: boolean;
|
|
313
|
-
private?: boolean;
|
|
314
|
-
checkPermission?: GlobalCheckPermissions$1 | ModelCheckPermissions$1;
|
|
315
|
-
getCacheKey?: GlobalGetCacheKey$1 | ModelGetCacheKey$1;
|
|
316
|
-
cache?: number;
|
|
317
|
-
cacheProvider?: OrionCache$1;
|
|
318
|
-
permissionsOptions?: any;
|
|
319
|
-
middlewares?: ResolverMiddleware$1[];
|
|
320
|
-
}
|
|
321
|
-
interface ResolverOptions$1<Resolve = Function> extends SharedResolverOptions$1 {
|
|
322
|
-
resolve: Resolve;
|
|
323
|
-
}
|
|
324
|
-
type OmitFirstArg$1<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
325
|
-
interface Resolver$1<Resolve = Function, IsModel = undefined> extends SharedResolverOptions$1 {
|
|
326
|
-
execute: Execute$1<Resolve, IsModel>;
|
|
327
|
-
resolve: Resolve;
|
|
328
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg$1<Resolve>;
|
|
329
|
-
}
|
|
330
|
-
type ModelResolver$1<Resolve = Function> = Resolver$1<Resolve, true>;
|
|
331
|
-
type ResolverMiddleware$1 = (executeOptions: ExecuteOptions$1, next: () => Promise<any>) => Promise<any>;
|
|
3
|
+
import { CloneOptions, Model } from '@orion-js/models';
|
|
4
|
+
import { ModelResolver, ModelResolverResolve } from '@orion-js/resolvers';
|
|
5
|
+
import { Constructor, Schema, SchemaMetaFieldType, SchemaNode } from '@orion-js/schema';
|
|
6
|
+
|
|
332
7
|
export type TypedModelOptions = Record<string, never>;
|
|
333
8
|
/**
|
|
334
9
|
* @deprecated Please use @TypedSchema instead
|
|
335
10
|
*/
|
|
336
11
|
export declare function TypedModel(options?: TypedModelOptions): ClassDecorator;
|
|
337
12
|
export declare function TypedSchema(options?: TypedModelOptions): ClassDecorator;
|
|
338
|
-
interface
|
|
339
|
-
|
|
340
|
-
validate: ValidateFunction$1;
|
|
341
|
-
clean: CleanFunction$1;
|
|
342
|
-
meta?: any;
|
|
343
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
344
|
-
_isFieldType: boolean;
|
|
345
|
-
}
|
|
346
|
-
type Constructor$1<T> = new (...args: any[]) => T;
|
|
347
|
-
type FieldTypesList$1 = "string" | "date" | "integer" | "number" | "ID" | "boolean" | "email" | "blackbox" | "any";
|
|
348
|
-
type TypedModelOnSchema$1 = Function;
|
|
349
|
-
type ConstructorsTypesList$1 = Constructor$1<String> | Constructor$1<Number> | Constructor$1<Boolean> | Constructor$1<Date>;
|
|
350
|
-
type SchemaRecursiveNodeTypeExtras$1 = {
|
|
351
|
-
_isFieldType?: boolean;
|
|
352
|
-
__clean?: CleanFunction$1;
|
|
353
|
-
__validate?: ValidateFunction$1;
|
|
354
|
-
__skipChildValidation?: (value: any, info: CurrentNodeInfo$1) => Promise<boolean>;
|
|
355
|
-
};
|
|
356
|
-
interface Schema$1 {
|
|
357
|
-
[key: string]: SchemaNode$1 | Function;
|
|
358
|
-
}
|
|
359
|
-
type SchemaRecursiveNodeType$1 = Schema$1 & SchemaRecursiveNodeTypeExtras$1;
|
|
360
|
-
type SchemaMetaFieldTypeSingle$1 = FieldTypesList$1 | ConstructorsTypesList$1 | SchemaRecursiveNodeType$1 | FieldType$1 | TypedModelOnSchema$1;
|
|
361
|
-
type SchemaMetaFieldType$1 = SchemaMetaFieldTypeSingle$1 | SchemaMetaFieldTypeSingle$1[];
|
|
362
|
-
type ValidateFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => object | string | void | Promise<object | string | void>;
|
|
363
|
-
type CleanFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => any | Promise<any>;
|
|
364
|
-
interface SchemaNode$1 {
|
|
365
|
-
/**
|
|
366
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
367
|
-
*/
|
|
368
|
-
type: SchemaMetaFieldType$1;
|
|
369
|
-
/**
|
|
370
|
-
* Defaults to false
|
|
371
|
-
*/
|
|
372
|
-
optional?: boolean;
|
|
373
|
-
allowedValues?: Array<any>;
|
|
374
|
-
defaultValue?: ((info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>) | any;
|
|
375
|
-
/**
|
|
376
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
377
|
-
*/
|
|
378
|
-
validate?: ValidateFunction$1;
|
|
379
|
-
/**
|
|
380
|
-
* Function that preprocesses a value before it is set.
|
|
381
|
-
*/
|
|
382
|
-
clean?: CleanFunction$1;
|
|
383
|
-
autoValue?: (value: any, info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>;
|
|
384
|
-
/**
|
|
385
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
386
|
-
*/
|
|
387
|
-
min?: number;
|
|
388
|
-
/**
|
|
389
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
390
|
-
*/
|
|
391
|
-
max?: number;
|
|
392
|
-
/**
|
|
393
|
-
* Internal use only.
|
|
394
|
-
*/
|
|
395
|
-
isBlackboxChild?: boolean;
|
|
396
|
-
/**
|
|
397
|
-
* @deprecated
|
|
398
|
-
*/
|
|
399
|
-
custom?: ValidateFunction$1;
|
|
400
|
-
/**
|
|
401
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
402
|
-
*/
|
|
403
|
-
private?: boolean;
|
|
404
|
-
/**
|
|
405
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
406
|
-
*/
|
|
407
|
-
graphQLResolver?: (...args: any) => any;
|
|
408
|
-
/**
|
|
409
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
410
|
-
*/
|
|
411
|
-
key?: string;
|
|
412
|
-
/**
|
|
413
|
-
* The name that would be displayed in a front-end form
|
|
414
|
-
*/
|
|
415
|
-
label?: string;
|
|
416
|
-
/**
|
|
417
|
-
* The description that would be displayed in a front-end form
|
|
418
|
-
*/
|
|
419
|
-
description?: string;
|
|
420
|
-
/**
|
|
421
|
-
* The placeholder that would be displayed in a front-end form
|
|
422
|
-
*/
|
|
423
|
-
placeholder?: string;
|
|
424
|
-
/**
|
|
425
|
-
* The field type that would be used in a front-end form
|
|
426
|
-
*/
|
|
427
|
-
fieldType?: string;
|
|
428
|
-
/**
|
|
429
|
-
* The field options that will be passed as props to the front-end field
|
|
430
|
-
*/
|
|
431
|
-
fieldOptions?: any;
|
|
432
|
-
}
|
|
433
|
-
interface CurrentNodeInfoOptions$1 {
|
|
434
|
-
autoConvert?: boolean;
|
|
435
|
-
filter?: boolean;
|
|
436
|
-
trimStrings?: boolean;
|
|
437
|
-
removeEmptyStrings?: boolean;
|
|
438
|
-
forceDoc?: any;
|
|
439
|
-
omitRequired?: boolean;
|
|
440
|
-
}
|
|
441
|
-
interface CurrentNodeInfo$1 {
|
|
442
|
-
/**
|
|
443
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
444
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
445
|
-
*/
|
|
446
|
-
schema?: SchemaNode$1 | Schema$1;
|
|
447
|
-
/**
|
|
448
|
-
* The current node subschema
|
|
449
|
-
*/
|
|
450
|
-
currentSchema?: Partial<SchemaNode$1>;
|
|
451
|
-
value: any;
|
|
452
|
-
doc?: any;
|
|
453
|
-
currentDoc?: any;
|
|
454
|
-
options?: CurrentNodeInfoOptions$1;
|
|
455
|
-
args?: any[];
|
|
456
|
-
type?: SchemaMetaFieldType$1;
|
|
457
|
-
keys?: string[];
|
|
458
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
459
|
-
}
|
|
460
|
-
export interface SchemaNodeForClasses extends Omit<SchemaNode$1, "type"> {
|
|
461
|
-
type: SchemaMetaFieldType$1 | Constructor$1<any> | Model | Model[];
|
|
13
|
+
export interface SchemaNodeForClasses extends Omit<SchemaNode, "type"> {
|
|
14
|
+
type: SchemaMetaFieldType | Constructor<any> | Model | Model[];
|
|
462
15
|
}
|
|
463
16
|
export type PropOptions = Partial<SchemaNodeForClasses>;
|
|
464
17
|
export declare function Prop(options?: PropOptions): PropertyDecorator;
|
|
465
18
|
/**
|
|
466
19
|
* @deprecated Please use a @TypedSchema and a @Model a @ModelResolver instead
|
|
467
20
|
*/
|
|
468
|
-
export declare function ResolverProp(options: ModelResolver
|
|
469
|
-
interface Constructor$
|
|
21
|
+
export declare function ResolverProp(options: ModelResolver<ModelResolverResolve>): PropertyDecorator;
|
|
22
|
+
interface Constructor$1<T> extends Function {
|
|
470
23
|
new (...args: unknown[]): T;
|
|
471
24
|
}
|
|
472
|
-
export declare function getSchemaForClass<TClass>(target: Constructor$
|
|
473
|
-
export declare function getModelForClass<TClass>(target: Constructor$
|
|
25
|
+
export declare function getSchemaForClass<TClass>(target: Constructor$1<TClass>): Schema;
|
|
26
|
+
export declare function getModelForClass<TClass>(target: Constructor$1<TClass>): Model;
|
|
474
27
|
export interface CloneSchemaClassOptions<TClass, TFields extends keyof TClass> {
|
|
475
28
|
name: string;
|
|
476
29
|
pickFields: readonly TFields[];
|
|
@@ -490,6 +43,6 @@ export interface CloneSchemaClassOptions<TClass, TFields extends keyof TClass> {
|
|
|
490
43
|
* type ClonedType = typeof ClonedModel.type
|
|
491
44
|
* ```
|
|
492
45
|
*/
|
|
493
|
-
export declare function cloneSchemaClass<TClass, TFields extends keyof TClass>(schema: Constructor$
|
|
46
|
+
export declare function cloneSchemaClass<TClass, TFields extends keyof TClass>(schema: Constructor$1<TClass>, options: CloneSchemaClassOptions<TClass, TFields>): Model<Pick<TClass, TFields>>;
|
|
494
47
|
|
|
495
48
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -159,7 +159,7 @@ class PropertyAlreadyExistsError extends Error {
|
|
|
159
159
|
super(`Schema with name "${schemaName}" already contains property "${propertyName}".`);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
//
|
|
162
|
+
// node_modules/@orion-js/helpers/dist/index.js
|
|
163
163
|
import { createRequire } from "node:module";
|
|
164
164
|
import crypto2 from "crypto";
|
|
165
165
|
var __create2 = Object.create;
|
|
@@ -1784,7 +1784,7 @@ function getSchemaForClassRecursive(target) {
|
|
|
1784
1784
|
function getSchemaForClass(target) {
|
|
1785
1785
|
return getSchemaForClassRecursive(target);
|
|
1786
1786
|
}
|
|
1787
|
-
//
|
|
1787
|
+
// node_modules/@orion-js/models/dist/index.js
|
|
1788
1788
|
var __create3 = Object.create;
|
|
1789
1789
|
var __getProtoOf3 = Object.getPrototypeOf;
|
|
1790
1790
|
var __defProp3 = Object.defineProperty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/typed-model",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"clean": "rm -rf ./dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@orion-js/helpers": "
|
|
26
|
-
"@orion-js/models": "
|
|
27
|
-
"@orion-js/resolvers": "
|
|
28
|
-
"@orion-js/schema": "
|
|
29
|
-
"@orion-js/services": "
|
|
25
|
+
"@orion-js/helpers": "4.0.0-next.0",
|
|
26
|
+
"@orion-js/models": "4.0.0-next.0",
|
|
27
|
+
"@orion-js/resolvers": "4.0.0-next.0",
|
|
28
|
+
"@orion-js/schema": "4.0.0-next.0",
|
|
29
|
+
"@orion-js/services": "4.0.0-next.0",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
31
|
"reflect-metadata": "0.1.13"
|
|
32
32
|
},
|