@orion-js/models 4.0.0-alpha.2 → 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 +1 -1
- package/dist/index.d.ts +3 -199
- package/dist/index.js +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1918,7 +1918,7 @@ function resolveParam_default(param) {
|
|
|
1918
1918
|
return result || {};
|
|
1919
1919
|
}
|
|
1920
1920
|
|
|
1921
|
-
//
|
|
1921
|
+
// node_modules/@orion-js/schema/dist/index.js
|
|
1922
1922
|
var __create2 = Object.create;
|
|
1923
1923
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
1924
1924
|
var __defProp2 = Object.defineProperty;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,204 +1,8 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: any;
|
|
7
|
-
expires?: Date;
|
|
8
|
-
}
|
|
9
|
-
export interface SetCacheOptions {
|
|
10
|
-
ttl?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface GetCacheOptions {
|
|
13
|
-
ttl?: number;
|
|
14
|
-
fallback?(): Promise<any>;
|
|
15
|
-
}
|
|
16
|
-
export interface OrionCache {
|
|
17
|
-
/**
|
|
18
|
-
* Save data in the cache
|
|
19
|
-
*/
|
|
20
|
-
set(key: string, value: any, options?: SetCacheOptions): Promise<void> | void;
|
|
21
|
-
/**
|
|
22
|
-
* Get data from the cache
|
|
23
|
-
*/
|
|
24
|
-
get(key: string, options?: GetCacheOptions): Promise<StoredCacheData>;
|
|
25
|
-
/**
|
|
26
|
-
* Removes data from the cache
|
|
27
|
-
*/
|
|
28
|
-
invalidate(key: string): Promise<void> | void;
|
|
29
|
-
}
|
|
30
|
-
export type Blackbox = {
|
|
31
|
-
[name: string]: any;
|
|
32
|
-
};
|
|
33
|
-
export type GlobalResolverResolve = (params: any, viewer: any, info?: any) => Promise<any>;
|
|
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
|
-
}
|
|
3
|
+
import { GlobalResolverResolve, ModelResolver, ModelResolverResolve, Resolver } from '@orion-js/resolvers';
|
|
4
|
+
import { Schema, SchemaMetaFieldType, SchemaNode } from '@orion-js/schema';
|
|
5
|
+
|
|
202
6
|
export interface ModelsSchemaNode extends Omit<SchemaNode, "type"> {
|
|
203
7
|
type: Model | [
|
|
204
8
|
Model
|
package/dist/index.js
CHANGED
|
@@ -1885,7 +1885,7 @@ function resolveParam_default(param) {
|
|
|
1885
1885
|
return result || {};
|
|
1886
1886
|
}
|
|
1887
1887
|
|
|
1888
|
-
//
|
|
1888
|
+
// node_modules/@orion-js/schema/dist/index.js
|
|
1889
1889
|
var __create2 = Object.create;
|
|
1890
1890
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
1891
1891
|
var __defProp2 = Object.defineProperty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/models",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-next.0",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"dev": "bun --watch src/index.ts"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@orion-js/helpers": "^4.0.0-
|
|
22
|
-
"@orion-js/resolvers": "^4.0.0-
|
|
23
|
-
"@orion-js/schema": "^4.0.0-
|
|
21
|
+
"@orion-js/helpers": "^4.0.0-next.0",
|
|
22
|
+
"@orion-js/resolvers": "^4.0.0-next.0",
|
|
23
|
+
"@orion-js/schema": "^4.0.0-next.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@orion-js/cache": "^
|
|
26
|
+
"@orion-js/cache": "^4.0.0-next.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@orion-js/cache": "^4.0.0-
|
|
29
|
+
"@orion-js/cache": "^4.0.0-next.0",
|
|
30
30
|
"@types/lodash": "4.14.176",
|
|
31
31
|
"typescript": "^5.4.5",
|
|
32
32
|
"@types/bun": "^1.2.4"
|