@orion-js/file-manager 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 +16 -12
- package/dist/index.d.ts +7 -855
- package/dist/index.js +16 -12
- package/package.json +8 -9
package/dist/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ var __legacyMetadataTS = (k, v) => {
|
|
|
55
55
|
};
|
|
56
56
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// node_modules/@orion-js/resolvers/dist/index.js
|
|
59
59
|
function hashObject_default(object) {
|
|
60
60
|
return import_object_hash.default(object);
|
|
61
61
|
}
|
|
@@ -23367,7 +23367,7 @@ var require_v358 = __commonJS((exports2) => {
|
|
|
23367
23367
|
var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
23368
23368
|
exports2.URL = URL2;
|
|
23369
23369
|
function _default(name, version, hashfunc) {
|
|
23370
|
-
var
|
|
23370
|
+
var generateUUID3 = function(value, namespace, buf, offset) {
|
|
23371
23371
|
var off = buf && offset || 0;
|
|
23372
23372
|
if (typeof value == "string")
|
|
23373
23373
|
value = stringToBytes(value);
|
|
@@ -23388,12 +23388,12 @@ var require_v358 = __commonJS((exports2) => {
|
|
|
23388
23388
|
return buf || (0, _bytesToUuid.default)(bytes);
|
|
23389
23389
|
};
|
|
23390
23390
|
try {
|
|
23391
|
-
|
|
23391
|
+
generateUUID3.name = name;
|
|
23392
23392
|
} catch (err) {
|
|
23393
23393
|
}
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
return
|
|
23394
|
+
generateUUID3.DNS = DNS;
|
|
23395
|
+
generateUUID3.URL = URL2;
|
|
23396
|
+
return generateUUID3;
|
|
23397
23397
|
}
|
|
23398
23398
|
});
|
|
23399
23399
|
|
|
@@ -886650,7 +886650,7 @@ module.exports = __toCommonJS(exports_src);
|
|
|
886650
886650
|
// src/resolvers/fileManagerFile.ts
|
|
886651
886651
|
init_dist();
|
|
886652
886652
|
|
|
886653
|
-
//
|
|
886653
|
+
// node_modules/@orion-js/models/dist/index.js
|
|
886654
886654
|
var __create5 = Object.create;
|
|
886655
886655
|
var __getProtoOf5 = Object.getPrototypeOf;
|
|
886656
886656
|
var __defProp5 = Object.defineProperty;
|
|
@@ -891537,7 +891537,7 @@ function createModel(modelOptions) {
|
|
|
891537
891537
|
return model;
|
|
891538
891538
|
}
|
|
891539
891539
|
|
|
891540
|
-
//
|
|
891540
|
+
// node_modules/@orion-js/mongodb/dist/index.js
|
|
891541
891541
|
var import_node_module2 = require("node:module");
|
|
891542
891542
|
var import_node_module3 = require("node:module");
|
|
891543
891543
|
var import_crypto2 = __toESM(require("crypto"));
|
|
@@ -972560,7 +972560,7 @@ var export_Service = import_typedi2.Service;
|
|
|
972560
972560
|
var export_Inject = import_typedi2.Inject;
|
|
972561
972561
|
var export_Container = import_typedi2.Container;
|
|
972562
972562
|
|
|
972563
|
-
//
|
|
972563
|
+
// node_modules/@orion-js/typed-model/dist/index.js
|
|
972564
972564
|
var import_node_module6 = require("node:module");
|
|
972565
972565
|
var import_crypto3 = __toESM(require("crypto"));
|
|
972566
972566
|
var __create8 = Object.create;
|
|
@@ -979470,7 +979470,7 @@ var fileManagerFile_default = resolver({
|
|
|
979470
979470
|
}
|
|
979471
979471
|
});
|
|
979472
979472
|
|
|
979473
|
-
//
|
|
979473
|
+
// node_modules/@orion-js/paginated-mongodb/dist/index.js
|
|
979474
979474
|
var import_node_module7 = require("node:module");
|
|
979475
979475
|
var import_crypto4 = __toESM(require("crypto"));
|
|
979476
979476
|
var __create9 = Object.create;
|
|
@@ -998226,7 +998226,7 @@ var completeUpload_default = resolver({
|
|
|
998226
998226
|
// src/resolvers/generateUploadCredentials.ts
|
|
998227
998227
|
init_dist();
|
|
998228
998228
|
|
|
998229
|
-
//
|
|
998229
|
+
// node_modules/@orion-js/helpers/dist/index.js
|
|
998230
998230
|
var import_node_module8 = require("node:module");
|
|
998231
998231
|
var import_crypto5 = __toESM(require("crypto"));
|
|
998232
998232
|
var __create10 = Object.create;
|
|
@@ -998953,6 +998953,9 @@ var v15 = import_dist5.default.v1;
|
|
|
998953
998953
|
var v35 = import_dist5.default.v3;
|
|
998954
998954
|
var v45 = import_dist5.default.v4;
|
|
998955
998955
|
var v55 = import_dist5.default.v5;
|
|
998956
|
+
function generateUUID2() {
|
|
998957
|
+
return v45();
|
|
998958
|
+
}
|
|
998956
998959
|
|
|
998957
998960
|
// src/resolvers/generateUploadCredentials.ts
|
|
998958
998961
|
var import_aws_sdk = __toESM(require_aws2());
|
|
@@ -999010,7 +999013,8 @@ var generateUploadCredentials_default = resolver({
|
|
|
999010
999013
|
return null;
|
|
999011
999014
|
}
|
|
999012
999015
|
const key = `${basePath}/${generateId5()}-${params.name}`;
|
|
999013
|
-
const fileId = await Files.insertOne({
|
|
999016
|
+
const fileId = await Files.rawCollection.insertOne({
|
|
999017
|
+
_id: `ofl-${generateUUID2()}`,
|
|
999014
999018
|
key,
|
|
999015
999019
|
bucket,
|
|
999016
999020
|
name: params.name,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +1,14 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { Db, MongoClient } from 'mongodb';
|
|
3
|
+
import { Collection } from '@orion-js/mongodb';
|
|
5
4
|
|
|
6
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
7
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
8
|
-
export interface StoredCacheData {
|
|
9
|
-
value: any;
|
|
10
|
-
expires?: Date;
|
|
11
|
-
}
|
|
12
|
-
export interface SetCacheOptions {
|
|
13
|
-
ttl?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface GetCacheOptions {
|
|
16
|
-
ttl?: number;
|
|
17
|
-
fallback?(): Promise<any>;
|
|
18
|
-
}
|
|
19
|
-
export interface OrionCache {
|
|
20
|
-
/**
|
|
21
|
-
* Save data in the cache
|
|
22
|
-
*/
|
|
23
|
-
set(key: string, value: any, options?: SetCacheOptions): Promise<void> | void;
|
|
24
|
-
/**
|
|
25
|
-
* Get data from the cache
|
|
26
|
-
*/
|
|
27
|
-
get(key: string, options?: GetCacheOptions): Promise<StoredCacheData>;
|
|
28
|
-
/**
|
|
29
|
-
* Removes data from the cache
|
|
30
|
-
*/
|
|
31
|
-
invalidate(key: string): Promise<void> | void;
|
|
32
|
-
}
|
|
33
|
-
export type Blackbox = {
|
|
34
|
-
[name: string]: any;
|
|
35
|
-
};
|
|
36
|
-
export type GlobalCheckPermissions = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
37
|
-
export type ModelCheckPermissions = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
38
|
-
export type GlobalGetCacheKey = (params: any, viewer: any, info: any) => Promise<any>;
|
|
39
|
-
export type ModelGetCacheKey = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
40
|
-
export interface ExecuteOptions {
|
|
41
|
-
params: Blackbox;
|
|
42
|
-
viewer: any;
|
|
43
|
-
parent?: any;
|
|
44
|
-
info?: any;
|
|
45
|
-
options: ResolverOptions;
|
|
46
|
-
}
|
|
47
|
-
export type Parameters$1<T> = T extends (...args: infer P) => any ? P : never;
|
|
48
|
-
export type ReturnType$1<T> = T extends (...args: any) => infer R ? R : any;
|
|
49
|
-
export type ResolverParams<Resolve, IsModel> = IsModel extends undefined ? Parameters$1<Resolve>[0] : Parameters$1<Resolve>[1];
|
|
50
|
-
export interface ExecuteParams<Resolve = Function, IsModel = undefined> {
|
|
51
|
-
params?: ResolverParams<Resolve, IsModel>;
|
|
52
|
-
viewer?: any;
|
|
53
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1<Resolve>[0];
|
|
54
|
-
info?: any;
|
|
55
|
-
}
|
|
56
|
-
export type Execute<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams<Resolve, IsModel>) => ReturnType$1<Resolve>;
|
|
57
|
-
export interface SharedResolverOptions {
|
|
58
|
-
resolverId?: string;
|
|
59
|
-
params?: any;
|
|
60
|
-
returns?: any;
|
|
61
|
-
mutation?: boolean;
|
|
62
|
-
private?: boolean;
|
|
63
|
-
checkPermission?: GlobalCheckPermissions | ModelCheckPermissions;
|
|
64
|
-
getCacheKey?: GlobalGetCacheKey | ModelGetCacheKey;
|
|
65
|
-
cache?: number;
|
|
66
|
-
cacheProvider?: OrionCache;
|
|
67
|
-
permissionsOptions?: any;
|
|
68
|
-
middlewares?: ResolverMiddleware[];
|
|
69
|
-
}
|
|
70
|
-
export interface ResolverOptions<Resolve = Function> extends SharedResolverOptions {
|
|
71
|
-
resolve: Resolve;
|
|
72
|
-
}
|
|
73
|
-
export type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
74
|
-
export interface Resolver<Resolve = Function, IsModel = undefined> extends SharedResolverOptions {
|
|
75
|
-
execute: Execute<Resolve, IsModel>;
|
|
76
|
-
resolve: Resolve;
|
|
77
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg<Resolve>;
|
|
78
|
-
}
|
|
79
|
-
export type ResolverMiddleware = (executeOptions: ExecuteOptions, next: () => Promise<any>) => Promise<any>;
|
|
80
5
|
declare const _default: {
|
|
81
|
-
fileManagerFile: Resolver<({ fileId }: any) => Promise<FileSchema>, undefined>;
|
|
82
|
-
fileManagerFiles: Resolver<Function, undefined>;
|
|
83
|
-
completeUpload: Resolver<({ fileId }: any, viewer: any) => Promise<FileSchema>, undefined>;
|
|
84
|
-
generateUploadCredentials: Resolver<(params: any, viewer: any) => Promise<{
|
|
6
|
+
fileManagerFile: import("@orion-js/resolvers").Resolver<({ fileId }: any) => Promise<FileSchema>, undefined>;
|
|
7
|
+
fileManagerFiles: import("@orion-js/resolvers").Resolver<Function, undefined>;
|
|
8
|
+
completeUpload: import("@orion-js/resolvers").Resolver<({ fileId }: any, viewer: any) => Promise<FileSchema>, undefined>;
|
|
9
|
+
generateUploadCredentials: import("@orion-js/resolvers").Resolver<(params: any, viewer: any) => Promise<{
|
|
85
10
|
key: string;
|
|
86
|
-
fileId:
|
|
11
|
+
fileId: import("mongodb").InsertOneResult<FileSchema>;
|
|
87
12
|
}>, undefined>;
|
|
88
13
|
};
|
|
89
14
|
declare class FileSchemaResizeData {
|
|
@@ -137,780 +62,7 @@ export declare const setupFileManager: (options: FileManagerOptions) => void;
|
|
|
137
62
|
* @deprecated use getFileManagerOptions instead
|
|
138
63
|
*/
|
|
139
64
|
export declare const getAWSCredentials: () => Partial<FileManagerOptions>;
|
|
140
|
-
|
|
141
|
-
value: any;
|
|
142
|
-
expires?: Date;
|
|
143
|
-
}
|
|
144
|
-
interface SetCacheOptions$1 {
|
|
145
|
-
ttl?: number;
|
|
146
|
-
}
|
|
147
|
-
interface GetCacheOptions$1 {
|
|
148
|
-
ttl?: number;
|
|
149
|
-
fallback?(): Promise<any>;
|
|
150
|
-
}
|
|
151
|
-
interface OrionCache$1 {
|
|
152
|
-
/**
|
|
153
|
-
* Save data in the cache
|
|
154
|
-
*/
|
|
155
|
-
set(key: string, value: any, options?: SetCacheOptions$1): Promise<void> | void;
|
|
156
|
-
/**
|
|
157
|
-
* Get data from the cache
|
|
158
|
-
*/
|
|
159
|
-
get(key: string, options?: GetCacheOptions$1): Promise<StoredCacheData$1>;
|
|
160
|
-
/**
|
|
161
|
-
* Removes data from the cache
|
|
162
|
-
*/
|
|
163
|
-
invalidate(key: string): Promise<void> | void;
|
|
164
|
-
}
|
|
165
|
-
type Blackbox$1 = {
|
|
166
|
-
[name: string]: any;
|
|
167
|
-
};
|
|
168
|
-
export type ModelResolverResolve = (item: any, params: any, viewer: any, info?: any) => Promise<any>;
|
|
169
|
-
type GlobalCheckPermissions$1 = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
170
|
-
type ModelCheckPermissions$1 = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
171
|
-
type GlobalGetCacheKey$1 = (params: any, viewer: any, info: any) => Promise<any>;
|
|
172
|
-
type ModelGetCacheKey$1 = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
173
|
-
interface ExecuteOptions$1 {
|
|
174
|
-
params: Blackbox$1;
|
|
175
|
-
viewer: any;
|
|
176
|
-
parent?: any;
|
|
177
|
-
info?: any;
|
|
178
|
-
options: ResolverOptions$1;
|
|
179
|
-
}
|
|
180
|
-
type Parameters$1$1<T> = T extends (...args: infer P) => any ? P : never;
|
|
181
|
-
type ReturnType$1$1<T> = T extends (...args: any) => infer R ? R : any;
|
|
182
|
-
type ResolverParams$1<Resolve, IsModel> = IsModel extends undefined ? Parameters$1$1<Resolve>[0] : Parameters$1$1<Resolve>[1];
|
|
183
|
-
interface ExecuteParams$1<Resolve = Function, IsModel = undefined> {
|
|
184
|
-
params?: ResolverParams$1<Resolve, IsModel>;
|
|
185
|
-
viewer?: any;
|
|
186
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1$1<Resolve>[0];
|
|
187
|
-
info?: any;
|
|
188
|
-
}
|
|
189
|
-
type Execute$1<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams$1<Resolve, IsModel>) => ReturnType$1$1<Resolve>;
|
|
190
|
-
interface SharedResolverOptions$1 {
|
|
191
|
-
resolverId?: string;
|
|
192
|
-
params?: any;
|
|
193
|
-
returns?: any;
|
|
194
|
-
mutation?: boolean;
|
|
195
|
-
private?: boolean;
|
|
196
|
-
checkPermission?: GlobalCheckPermissions$1 | ModelCheckPermissions$1;
|
|
197
|
-
getCacheKey?: GlobalGetCacheKey$1 | ModelGetCacheKey$1;
|
|
198
|
-
cache?: number;
|
|
199
|
-
cacheProvider?: OrionCache$1;
|
|
200
|
-
permissionsOptions?: any;
|
|
201
|
-
middlewares?: ResolverMiddleware$1[];
|
|
202
|
-
}
|
|
203
|
-
interface ResolverOptions$1<Resolve = Function> extends SharedResolverOptions$1 {
|
|
204
|
-
resolve: Resolve;
|
|
205
|
-
}
|
|
206
|
-
type OmitFirstArg$1<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
207
|
-
interface Resolver$1<Resolve = Function, IsModel = undefined> extends SharedResolverOptions$1 {
|
|
208
|
-
execute: Execute$1<Resolve, IsModel>;
|
|
209
|
-
resolve: Resolve;
|
|
210
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg$1<Resolve>;
|
|
211
|
-
}
|
|
212
|
-
export type ModelResolver<Resolve = Function> = Resolver$1<Resolve, true>;
|
|
213
|
-
type ResolverMiddleware$1 = (executeOptions: ExecuteOptions$1, next: () => Promise<any>) => Promise<any>;
|
|
214
|
-
export interface FieldType {
|
|
215
|
-
name: string;
|
|
216
|
-
validate: ValidateFunction;
|
|
217
|
-
clean: CleanFunction;
|
|
218
|
-
meta?: any;
|
|
219
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
220
|
-
_isFieldType: boolean;
|
|
221
|
-
}
|
|
222
|
-
export type Constructor<T> = new (...args: any[]) => T;
|
|
223
|
-
export type FieldTypesList = "string" | "date" | "integer" | "number" | "ID" | "boolean" | "email" | "blackbox" | "any";
|
|
224
|
-
export type TypedModelOnSchema = Function;
|
|
225
|
-
export type ConstructorsTypesList = Constructor<String> | Constructor<Number> | Constructor<Boolean> | Constructor<Date>;
|
|
226
|
-
export type SchemaRecursiveNodeTypeExtras = {
|
|
227
|
-
_isFieldType?: boolean;
|
|
228
|
-
__clean?: CleanFunction;
|
|
229
|
-
__validate?: ValidateFunction;
|
|
230
|
-
__skipChildValidation?: (value: any, info: CurrentNodeInfo) => Promise<boolean>;
|
|
231
|
-
};
|
|
232
|
-
export interface Schema {
|
|
233
|
-
[key: string]: SchemaNode | Function;
|
|
234
|
-
}
|
|
235
|
-
export type SchemaRecursiveNodeType = Schema & SchemaRecursiveNodeTypeExtras;
|
|
236
|
-
export type SchemaMetaFieldTypeSingle = FieldTypesList | ConstructorsTypesList | SchemaRecursiveNodeType | FieldType | TypedModelOnSchema;
|
|
237
|
-
export type SchemaMetaFieldType = SchemaMetaFieldTypeSingle | SchemaMetaFieldTypeSingle[];
|
|
238
|
-
export type ValidateFunction = (value: any, info?: Partial<CurrentNodeInfo>, ...args: any[]) => object | string | void | Promise<object | string | void>;
|
|
239
|
-
export type CleanFunction = (value: any, info?: Partial<CurrentNodeInfo>, ...args: any[]) => any | Promise<any>;
|
|
240
|
-
export interface SchemaNode {
|
|
241
|
-
/**
|
|
242
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
243
|
-
*/
|
|
244
|
-
type: SchemaMetaFieldType;
|
|
245
|
-
/**
|
|
246
|
-
* Defaults to false
|
|
247
|
-
*/
|
|
248
|
-
optional?: boolean;
|
|
249
|
-
allowedValues?: Array<any>;
|
|
250
|
-
defaultValue?: ((info: CurrentNodeInfo, ...args: any[]) => any | Promise<any>) | any;
|
|
251
|
-
/**
|
|
252
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
253
|
-
*/
|
|
254
|
-
validate?: ValidateFunction;
|
|
255
|
-
/**
|
|
256
|
-
* Function that preprocesses a value before it is set.
|
|
257
|
-
*/
|
|
258
|
-
clean?: CleanFunction;
|
|
259
|
-
autoValue?: (value: any, info: CurrentNodeInfo, ...args: any[]) => any | Promise<any>;
|
|
260
|
-
/**
|
|
261
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
262
|
-
*/
|
|
263
|
-
min?: number;
|
|
264
|
-
/**
|
|
265
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
266
|
-
*/
|
|
267
|
-
max?: number;
|
|
268
|
-
/**
|
|
269
|
-
* Internal use only.
|
|
270
|
-
*/
|
|
271
|
-
isBlackboxChild?: boolean;
|
|
272
|
-
/**
|
|
273
|
-
* @deprecated
|
|
274
|
-
*/
|
|
275
|
-
custom?: ValidateFunction;
|
|
276
|
-
/**
|
|
277
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
278
|
-
*/
|
|
279
|
-
private?: boolean;
|
|
280
|
-
/**
|
|
281
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
282
|
-
*/
|
|
283
|
-
graphQLResolver?: (...args: any) => any;
|
|
284
|
-
/**
|
|
285
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
286
|
-
*/
|
|
287
|
-
key?: string;
|
|
288
|
-
/**
|
|
289
|
-
* The name that would be displayed in a front-end form
|
|
290
|
-
*/
|
|
291
|
-
label?: string;
|
|
292
|
-
/**
|
|
293
|
-
* The description that would be displayed in a front-end form
|
|
294
|
-
*/
|
|
295
|
-
description?: string;
|
|
296
|
-
/**
|
|
297
|
-
* The placeholder that would be displayed in a front-end form
|
|
298
|
-
*/
|
|
299
|
-
placeholder?: string;
|
|
300
|
-
/**
|
|
301
|
-
* The field type that would be used in a front-end form
|
|
302
|
-
*/
|
|
303
|
-
fieldType?: string;
|
|
304
|
-
/**
|
|
305
|
-
* The field options that will be passed as props to the front-end field
|
|
306
|
-
*/
|
|
307
|
-
fieldOptions?: any;
|
|
308
|
-
}
|
|
309
|
-
export interface CurrentNodeInfoOptions {
|
|
310
|
-
autoConvert?: boolean;
|
|
311
|
-
filter?: boolean;
|
|
312
|
-
trimStrings?: boolean;
|
|
313
|
-
removeEmptyStrings?: boolean;
|
|
314
|
-
forceDoc?: any;
|
|
315
|
-
omitRequired?: boolean;
|
|
316
|
-
}
|
|
317
|
-
export interface CurrentNodeInfo {
|
|
318
|
-
/**
|
|
319
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
320
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
321
|
-
*/
|
|
322
|
-
schema?: SchemaNode | Schema;
|
|
323
|
-
/**
|
|
324
|
-
* The current node subschema
|
|
325
|
-
*/
|
|
326
|
-
currentSchema?: Partial<SchemaNode>;
|
|
327
|
-
value: any;
|
|
328
|
-
doc?: any;
|
|
329
|
-
currentDoc?: any;
|
|
330
|
-
options?: CurrentNodeInfoOptions;
|
|
331
|
-
args?: any[];
|
|
332
|
-
type?: SchemaMetaFieldType;
|
|
333
|
-
keys?: string[];
|
|
334
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
335
|
-
}
|
|
336
|
-
export interface ModelResolversMap {
|
|
337
|
-
[key: string]: ModelResolver<ModelResolverResolve>;
|
|
338
|
-
}
|
|
339
|
-
export interface CloneOptions {
|
|
340
|
-
name: string;
|
|
341
|
-
omitFields?: string[];
|
|
342
|
-
pickFields?: string[];
|
|
343
|
-
mapFields?: (field: any, key: string) => any;
|
|
344
|
-
extendSchema?: Schema;
|
|
345
|
-
extendResolvers?: ModelResolversMap;
|
|
346
|
-
}
|
|
347
|
-
export interface Model<TSchema = any> {
|
|
348
|
-
__isModel: boolean;
|
|
349
|
-
/**
|
|
350
|
-
* The name of the model, used for example for GraphQL
|
|
351
|
-
*/
|
|
352
|
-
name: string;
|
|
353
|
-
/**
|
|
354
|
-
* Returns the schema of the model
|
|
355
|
-
*/
|
|
356
|
-
getSchema: () => Schema & {
|
|
357
|
-
__model: Model;
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* Returns the schema without adding __model to the schema
|
|
361
|
-
*/
|
|
362
|
-
getCleanSchema: () => Schema;
|
|
363
|
-
/**
|
|
364
|
-
* Returns the model resolvers
|
|
365
|
-
*/
|
|
366
|
-
getResolvers: () => ModelResolversMap;
|
|
367
|
-
/**
|
|
368
|
-
* Adds the model resolvers to a item
|
|
369
|
-
*/
|
|
370
|
-
initItem: (item: any) => any;
|
|
371
|
-
/**
|
|
372
|
-
* Validates an item using @orion-js/schema
|
|
373
|
-
*/
|
|
374
|
-
validate: (item: any) => Promise<any>;
|
|
375
|
-
/**
|
|
376
|
-
* Cleans an item using @orion-js/schema
|
|
377
|
-
*/
|
|
378
|
-
clean: (item: any) => Promise<TSchema>;
|
|
379
|
-
/**
|
|
380
|
-
* Cleans and validates an item using @orion-js/schema
|
|
381
|
-
*/
|
|
382
|
-
cleanAndValidate: (item: any) => Promise<TSchema>;
|
|
383
|
-
/**
|
|
384
|
-
* Creates a new model using this one as a base
|
|
385
|
-
*/
|
|
386
|
-
clone: (cloneOptions: CloneOptions) => Model;
|
|
387
|
-
/**
|
|
388
|
-
* The type of the model. Only use this in typescript
|
|
389
|
-
*/
|
|
390
|
-
type: TSchema;
|
|
391
|
-
}
|
|
392
|
-
declare const _default$1: Model<FileSchema>;
|
|
393
|
-
interface StoredCacheData$2 {
|
|
394
|
-
value: any;
|
|
395
|
-
expires?: Date;
|
|
396
|
-
}
|
|
397
|
-
interface SetCacheOptions$2 {
|
|
398
|
-
ttl?: number;
|
|
399
|
-
}
|
|
400
|
-
interface GetCacheOptions$2 {
|
|
401
|
-
ttl?: number;
|
|
402
|
-
fallback?(): Promise<any>;
|
|
403
|
-
}
|
|
404
|
-
interface OrionCache$2 {
|
|
405
|
-
/**
|
|
406
|
-
* Save data in the cache
|
|
407
|
-
*/
|
|
408
|
-
set(key: string, value: any, options?: SetCacheOptions$2): Promise<void> | void;
|
|
409
|
-
/**
|
|
410
|
-
* Get data from the cache
|
|
411
|
-
*/
|
|
412
|
-
get(key: string, options?: GetCacheOptions$2): Promise<StoredCacheData$2>;
|
|
413
|
-
/**
|
|
414
|
-
* Removes data from the cache
|
|
415
|
-
*/
|
|
416
|
-
invalidate(key: string): Promise<void> | void;
|
|
417
|
-
}
|
|
418
|
-
type Blackbox$2 = {
|
|
419
|
-
[name: string]: any;
|
|
420
|
-
};
|
|
421
|
-
type ModelResolverResolve$1 = (item: any, params: any, viewer: any, info?: any) => Promise<any>;
|
|
422
|
-
type GlobalCheckPermissions$2 = (params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
423
|
-
type ModelCheckPermissions$2 = (parent: any, params: any, viewer: any, info?: any) => Promise<string | void>;
|
|
424
|
-
type GlobalGetCacheKey$2 = (params: any, viewer: any, info: any) => Promise<any>;
|
|
425
|
-
type ModelGetCacheKey$2 = (parent: any, params: any, viewer: any, info: any) => Promise<any>;
|
|
426
|
-
interface ExecuteOptions$2 {
|
|
427
|
-
params: Blackbox$2;
|
|
428
|
-
viewer: any;
|
|
429
|
-
parent?: any;
|
|
430
|
-
info?: any;
|
|
431
|
-
options: ResolverOptions$2;
|
|
432
|
-
}
|
|
433
|
-
type Parameters$1$2<T> = T extends (...args: infer P) => any ? P : never;
|
|
434
|
-
type ReturnType$1$2<T> = T extends (...args: any) => infer R ? R : any;
|
|
435
|
-
type ResolverParams$2<Resolve, IsModel> = IsModel extends undefined ? Parameters$1$2<Resolve>[0] : Parameters$1$2<Resolve>[1];
|
|
436
|
-
interface ExecuteParams$2<Resolve = Function, IsModel = undefined> {
|
|
437
|
-
params?: ResolverParams$2<Resolve, IsModel>;
|
|
438
|
-
viewer?: any;
|
|
439
|
-
parent?: IsModel extends undefined ? undefined : Parameters$1$2<Resolve>[0];
|
|
440
|
-
info?: any;
|
|
441
|
-
}
|
|
442
|
-
type Execute$2<Resolve = Function, IsModel = undefined> = (executeOptions: ExecuteParams$2<Resolve, IsModel>) => ReturnType$1$2<Resolve>;
|
|
443
|
-
interface SharedResolverOptions$2 {
|
|
444
|
-
resolverId?: string;
|
|
445
|
-
params?: any;
|
|
446
|
-
returns?: any;
|
|
447
|
-
mutation?: boolean;
|
|
448
|
-
private?: boolean;
|
|
449
|
-
checkPermission?: GlobalCheckPermissions$2 | ModelCheckPermissions$2;
|
|
450
|
-
getCacheKey?: GlobalGetCacheKey$2 | ModelGetCacheKey$2;
|
|
451
|
-
cache?: number;
|
|
452
|
-
cacheProvider?: OrionCache$2;
|
|
453
|
-
permissionsOptions?: any;
|
|
454
|
-
middlewares?: ResolverMiddleware$2[];
|
|
455
|
-
}
|
|
456
|
-
interface ResolverOptions$2<Resolve = Function> extends SharedResolverOptions$2 {
|
|
457
|
-
resolve: Resolve;
|
|
458
|
-
}
|
|
459
|
-
type OmitFirstArg$2<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
460
|
-
interface Resolver$2<Resolve = Function, IsModel = undefined> extends SharedResolverOptions$2 {
|
|
461
|
-
execute: Execute$2<Resolve, IsModel>;
|
|
462
|
-
resolve: Resolve;
|
|
463
|
-
modelResolve: IsModel extends undefined ? undefined : OmitFirstArg$2<Resolve>;
|
|
464
|
-
}
|
|
465
|
-
type ModelResolver$1<Resolve = Function> = Resolver$2<Resolve, true>;
|
|
466
|
-
type ResolverMiddleware$2 = (executeOptions: ExecuteOptions$2, next: () => Promise<any>) => Promise<any>;
|
|
467
|
-
interface FieldType$1 {
|
|
468
|
-
name: string;
|
|
469
|
-
validate: ValidateFunction$1;
|
|
470
|
-
clean: CleanFunction$1;
|
|
471
|
-
meta?: any;
|
|
472
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
473
|
-
_isFieldType: boolean;
|
|
474
|
-
}
|
|
475
|
-
type Constructor$1<T> = new (...args: any[]) => T;
|
|
476
|
-
type FieldTypesList$1 = "string" | "date" | "integer" | "number" | "ID" | "boolean" | "email" | "blackbox" | "any";
|
|
477
|
-
type TypedModelOnSchema$1 = Function;
|
|
478
|
-
type ConstructorsTypesList$1 = Constructor$1<String> | Constructor$1<Number> | Constructor$1<Boolean> | Constructor$1<Date>;
|
|
479
|
-
type SchemaRecursiveNodeTypeExtras$1 = {
|
|
480
|
-
_isFieldType?: boolean;
|
|
481
|
-
__clean?: CleanFunction$1;
|
|
482
|
-
__validate?: ValidateFunction$1;
|
|
483
|
-
__skipChildValidation?: (value: any, info: CurrentNodeInfo$1) => Promise<boolean>;
|
|
484
|
-
};
|
|
485
|
-
interface Schema$1 {
|
|
486
|
-
[key: string]: SchemaNode$1 | Function;
|
|
487
|
-
}
|
|
488
|
-
type SchemaRecursiveNodeType$1 = Schema$1 & SchemaRecursiveNodeTypeExtras$1;
|
|
489
|
-
type SchemaMetaFieldTypeSingle$1 = FieldTypesList$1 | ConstructorsTypesList$1 | SchemaRecursiveNodeType$1 | FieldType$1 | TypedModelOnSchema$1;
|
|
490
|
-
type SchemaMetaFieldType$1 = SchemaMetaFieldTypeSingle$1 | SchemaMetaFieldTypeSingle$1[];
|
|
491
|
-
type ValidateFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => object | string | void | Promise<object | string | void>;
|
|
492
|
-
type CleanFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => any | Promise<any>;
|
|
493
|
-
interface SchemaNode$1 {
|
|
494
|
-
/**
|
|
495
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
496
|
-
*/
|
|
497
|
-
type: SchemaMetaFieldType$1;
|
|
498
|
-
/**
|
|
499
|
-
* Defaults to false
|
|
500
|
-
*/
|
|
501
|
-
optional?: boolean;
|
|
502
|
-
allowedValues?: Array<any>;
|
|
503
|
-
defaultValue?: ((info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>) | any;
|
|
504
|
-
/**
|
|
505
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
506
|
-
*/
|
|
507
|
-
validate?: ValidateFunction$1;
|
|
508
|
-
/**
|
|
509
|
-
* Function that preprocesses a value before it is set.
|
|
510
|
-
*/
|
|
511
|
-
clean?: CleanFunction$1;
|
|
512
|
-
autoValue?: (value: any, info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>;
|
|
513
|
-
/**
|
|
514
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
515
|
-
*/
|
|
516
|
-
min?: number;
|
|
517
|
-
/**
|
|
518
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
519
|
-
*/
|
|
520
|
-
max?: number;
|
|
521
|
-
/**
|
|
522
|
-
* Internal use only.
|
|
523
|
-
*/
|
|
524
|
-
isBlackboxChild?: boolean;
|
|
525
|
-
/**
|
|
526
|
-
* @deprecated
|
|
527
|
-
*/
|
|
528
|
-
custom?: ValidateFunction$1;
|
|
529
|
-
/**
|
|
530
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
531
|
-
*/
|
|
532
|
-
private?: boolean;
|
|
533
|
-
/**
|
|
534
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
535
|
-
*/
|
|
536
|
-
graphQLResolver?: (...args: any) => any;
|
|
537
|
-
/**
|
|
538
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
539
|
-
*/
|
|
540
|
-
key?: string;
|
|
541
|
-
/**
|
|
542
|
-
* The name that would be displayed in a front-end form
|
|
543
|
-
*/
|
|
544
|
-
label?: string;
|
|
545
|
-
/**
|
|
546
|
-
* The description that would be displayed in a front-end form
|
|
547
|
-
*/
|
|
548
|
-
description?: string;
|
|
549
|
-
/**
|
|
550
|
-
* The placeholder that would be displayed in a front-end form
|
|
551
|
-
*/
|
|
552
|
-
placeholder?: string;
|
|
553
|
-
/**
|
|
554
|
-
* The field type that would be used in a front-end form
|
|
555
|
-
*/
|
|
556
|
-
fieldType?: string;
|
|
557
|
-
/**
|
|
558
|
-
* The field options that will be passed as props to the front-end field
|
|
559
|
-
*/
|
|
560
|
-
fieldOptions?: any;
|
|
561
|
-
}
|
|
562
|
-
interface CurrentNodeInfoOptions$1 {
|
|
563
|
-
autoConvert?: boolean;
|
|
564
|
-
filter?: boolean;
|
|
565
|
-
trimStrings?: boolean;
|
|
566
|
-
removeEmptyStrings?: boolean;
|
|
567
|
-
forceDoc?: any;
|
|
568
|
-
omitRequired?: boolean;
|
|
569
|
-
}
|
|
570
|
-
interface CurrentNodeInfo$1 {
|
|
571
|
-
/**
|
|
572
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
573
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
574
|
-
*/
|
|
575
|
-
schema?: SchemaNode$1 | Schema$1;
|
|
576
|
-
/**
|
|
577
|
-
* The current node subschema
|
|
578
|
-
*/
|
|
579
|
-
currentSchema?: Partial<SchemaNode$1>;
|
|
580
|
-
value: any;
|
|
581
|
-
doc?: any;
|
|
582
|
-
currentDoc?: any;
|
|
583
|
-
options?: CurrentNodeInfoOptions$1;
|
|
584
|
-
args?: any[];
|
|
585
|
-
type?: SchemaMetaFieldType$1;
|
|
586
|
-
keys?: string[];
|
|
587
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
588
|
-
}
|
|
589
|
-
interface ModelResolversMap$1 {
|
|
590
|
-
[key: string]: ModelResolver$1<ModelResolverResolve$1>;
|
|
591
|
-
}
|
|
592
|
-
interface CloneOptions$1 {
|
|
593
|
-
name: string;
|
|
594
|
-
omitFields?: string[];
|
|
595
|
-
pickFields?: string[];
|
|
596
|
-
mapFields?: (field: any, key: string) => any;
|
|
597
|
-
extendSchema?: Schema$1;
|
|
598
|
-
extendResolvers?: ModelResolversMap$1;
|
|
599
|
-
}
|
|
600
|
-
interface Model$1<TSchema = any> {
|
|
601
|
-
__isModel: boolean;
|
|
602
|
-
/**
|
|
603
|
-
* The name of the model, used for example for GraphQL
|
|
604
|
-
*/
|
|
605
|
-
name: string;
|
|
606
|
-
/**
|
|
607
|
-
* Returns the schema of the model
|
|
608
|
-
*/
|
|
609
|
-
getSchema: () => Schema$1 & {
|
|
610
|
-
__model: Model$1;
|
|
611
|
-
};
|
|
612
|
-
/**
|
|
613
|
-
* Returns the schema without adding __model to the schema
|
|
614
|
-
*/
|
|
615
|
-
getCleanSchema: () => Schema$1;
|
|
616
|
-
/**
|
|
617
|
-
* Returns the model resolvers
|
|
618
|
-
*/
|
|
619
|
-
getResolvers: () => ModelResolversMap$1;
|
|
620
|
-
/**
|
|
621
|
-
* Adds the model resolvers to a item
|
|
622
|
-
*/
|
|
623
|
-
initItem: (item: any) => any;
|
|
624
|
-
/**
|
|
625
|
-
* Validates an item using @orion-js/schema
|
|
626
|
-
*/
|
|
627
|
-
validate: (item: any) => Promise<any>;
|
|
628
|
-
/**
|
|
629
|
-
* Cleans an item using @orion-js/schema
|
|
630
|
-
*/
|
|
631
|
-
clean: (item: any) => Promise<TSchema>;
|
|
632
|
-
/**
|
|
633
|
-
* Cleans and validates an item using @orion-js/schema
|
|
634
|
-
*/
|
|
635
|
-
cleanAndValidate: (item: any) => Promise<TSchema>;
|
|
636
|
-
/**
|
|
637
|
-
* Creates a new model using this one as a base
|
|
638
|
-
*/
|
|
639
|
-
clone: (cloneOptions: CloneOptions$1) => Model$1;
|
|
640
|
-
/**
|
|
641
|
-
* The type of the model. Only use this in typescript
|
|
642
|
-
*/
|
|
643
|
-
type: TSchema;
|
|
644
|
-
}
|
|
645
|
-
export interface FieldType$1 {
|
|
646
|
-
name: string;
|
|
647
|
-
validate: ValidateFunction$1;
|
|
648
|
-
clean: CleanFunction$1;
|
|
649
|
-
meta?: any;
|
|
650
|
-
toGraphQLType?: (GraphQL: any) => any;
|
|
651
|
-
_isFieldType: boolean;
|
|
652
|
-
}
|
|
653
|
-
export type Constructor$1<T> = new (...args: any[]) => T;
|
|
654
|
-
export type Blackbox$1 = {
|
|
655
|
-
[name: string]: any;
|
|
656
|
-
};
|
|
657
|
-
export type FieldTypesList$1 = "string" | "date" | "integer" | "number" | "ID" | "boolean" | "email" | "blackbox" | "any";
|
|
658
|
-
export type TypedModelOnSchema$1 = Function;
|
|
659
|
-
export type ConstructorsTypesList$1 = Constructor$1<String> | Constructor$1<Number> | Constructor$1<Boolean> | Constructor$1<Date>;
|
|
660
|
-
export type SchemaRecursiveNodeTypeExtras$1 = {
|
|
661
|
-
_isFieldType?: boolean;
|
|
662
|
-
__clean?: CleanFunction$1;
|
|
663
|
-
__validate?: ValidateFunction$1;
|
|
664
|
-
__skipChildValidation?: (value: any, info: CurrentNodeInfo$1) => Promise<boolean>;
|
|
665
|
-
};
|
|
666
|
-
export interface Schema$1 {
|
|
667
|
-
[key: string]: SchemaNode$1 | Function;
|
|
668
|
-
}
|
|
669
|
-
export type SchemaRecursiveNodeType$1 = Schema$1 & SchemaRecursiveNodeTypeExtras$1;
|
|
670
|
-
export type SchemaMetaFieldTypeSingle$1 = FieldTypesList$1 | ConstructorsTypesList$1 | SchemaRecursiveNodeType$1 | FieldType$1 | TypedModelOnSchema$1;
|
|
671
|
-
export type SchemaMetaFieldType$1 = SchemaMetaFieldTypeSingle$1 | SchemaMetaFieldTypeSingle$1[];
|
|
672
|
-
export type ValidateFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => object | string | void | Promise<object | string | void>;
|
|
673
|
-
export type CleanFunction$1 = (value: any, info?: Partial<CurrentNodeInfo$1>, ...args: any[]) => any | Promise<any>;
|
|
674
|
-
export interface SchemaNode$1 {
|
|
675
|
-
/**
|
|
676
|
-
* The type of the field. Used for type validations. Can also contain a subschema.
|
|
677
|
-
*/
|
|
678
|
-
type: SchemaMetaFieldType$1;
|
|
679
|
-
/**
|
|
680
|
-
* Defaults to false
|
|
681
|
-
*/
|
|
682
|
-
optional?: boolean;
|
|
683
|
-
allowedValues?: Array<any>;
|
|
684
|
-
defaultValue?: ((info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>) | any;
|
|
685
|
-
/**
|
|
686
|
-
* Function that takes a value and returns an error message if there are any errors. Must return null or undefined otherwise.
|
|
687
|
-
*/
|
|
688
|
-
validate?: ValidateFunction$1;
|
|
689
|
-
/**
|
|
690
|
-
* Function that preprocesses a value before it is set.
|
|
691
|
-
*/
|
|
692
|
-
clean?: CleanFunction$1;
|
|
693
|
-
autoValue?: (value: any, info: CurrentNodeInfo$1, ...args: any[]) => any | Promise<any>;
|
|
694
|
-
/**
|
|
695
|
-
* The minimum value if it's a number, the minimum length if it's a string or array.
|
|
696
|
-
*/
|
|
697
|
-
min?: number;
|
|
698
|
-
/**
|
|
699
|
-
* The maximum value if it's a number, the maximum length if it's a string or array.
|
|
700
|
-
*/
|
|
701
|
-
max?: number;
|
|
702
|
-
/**
|
|
703
|
-
* Internal use only.
|
|
704
|
-
*/
|
|
705
|
-
isBlackboxChild?: boolean;
|
|
706
|
-
/**
|
|
707
|
-
* @deprecated
|
|
708
|
-
*/
|
|
709
|
-
custom?: ValidateFunction$1;
|
|
710
|
-
/**
|
|
711
|
-
* Used in GraphQL. If true, the field will be omitted from the schema.
|
|
712
|
-
*/
|
|
713
|
-
private?: boolean;
|
|
714
|
-
/**
|
|
715
|
-
* Used in GraphQL. When in GraphQL, this resolver will replace the static field.
|
|
716
|
-
*/
|
|
717
|
-
graphQLResolver?: (...args: any) => any;
|
|
718
|
-
/**
|
|
719
|
-
* Used in GraphQL. Sets the key of the field in the GraphQL schema. You must set this value when building your schema.
|
|
720
|
-
*/
|
|
721
|
-
key?: string;
|
|
722
|
-
/**
|
|
723
|
-
* The name that would be displayed in a front-end form
|
|
724
|
-
*/
|
|
725
|
-
label?: string;
|
|
726
|
-
/**
|
|
727
|
-
* The description that would be displayed in a front-end form
|
|
728
|
-
*/
|
|
729
|
-
description?: string;
|
|
730
|
-
/**
|
|
731
|
-
* The placeholder that would be displayed in a front-end form
|
|
732
|
-
*/
|
|
733
|
-
placeholder?: string;
|
|
734
|
-
/**
|
|
735
|
-
* The field type that would be used in a front-end form
|
|
736
|
-
*/
|
|
737
|
-
fieldType?: string;
|
|
738
|
-
/**
|
|
739
|
-
* The field options that will be passed as props to the front-end field
|
|
740
|
-
*/
|
|
741
|
-
fieldOptions?: any;
|
|
742
|
-
}
|
|
743
|
-
export interface CurrentNodeInfoOptions$1 {
|
|
744
|
-
autoConvert?: boolean;
|
|
745
|
-
filter?: boolean;
|
|
746
|
-
trimStrings?: boolean;
|
|
747
|
-
removeEmptyStrings?: boolean;
|
|
748
|
-
forceDoc?: any;
|
|
749
|
-
omitRequired?: boolean;
|
|
750
|
-
}
|
|
751
|
-
export interface CurrentNodeInfo$1 {
|
|
752
|
-
/**
|
|
753
|
-
* The global schema, prefaced by {type: {...}} to be compatible with subschemas
|
|
754
|
-
* Sometimes it's given without {type: {...}}. TODO: Normalize this.
|
|
755
|
-
*/
|
|
756
|
-
schema?: SchemaNode$1 | Schema$1;
|
|
757
|
-
/**
|
|
758
|
-
* The current node subschema
|
|
759
|
-
*/
|
|
760
|
-
currentSchema?: Partial<SchemaNode$1>;
|
|
761
|
-
value: any;
|
|
762
|
-
doc?: any;
|
|
763
|
-
currentDoc?: any;
|
|
764
|
-
options?: CurrentNodeInfoOptions$1;
|
|
765
|
-
args?: any[];
|
|
766
|
-
type?: SchemaMetaFieldType$1;
|
|
767
|
-
keys?: string[];
|
|
768
|
-
addError?: (keys: string[], code: string | object) => void;
|
|
769
|
-
}
|
|
770
|
-
export interface OrionMongoClient {
|
|
771
|
-
client: MongoClient;
|
|
772
|
-
db: Db;
|
|
773
|
-
uri: string;
|
|
774
|
-
dbName: string;
|
|
775
|
-
connectionPromise: Promise<MongoClient>;
|
|
776
|
-
connectionName: string;
|
|
777
|
-
}
|
|
778
|
-
export type RemoveFunctions<T extends ModelClassBase> = Pick<T, {
|
|
779
|
-
[Key in keyof T]-?: T[Key] extends Function ? never : Key;
|
|
780
|
-
}[keyof T]> & {
|
|
781
|
-
_id: ModelClassBase["_id"];
|
|
782
|
-
};
|
|
783
|
-
export type ModelClassBase = {
|
|
784
|
-
_id: string;
|
|
785
|
-
} & Blackbox$1;
|
|
786
|
-
export type DocumentWithIdOptional<T extends ModelClassBase> = Omit<T, "_id"> & {
|
|
787
|
-
/**
|
|
788
|
-
* The ID of the document
|
|
789
|
-
*/
|
|
790
|
-
_id?: T["_id"];
|
|
791
|
-
};
|
|
792
|
-
export type DocumentWithoutId<T> = Omit<T, "_id">;
|
|
793
|
-
export type ModelToDocumentType<ModelClass extends ModelClassBase> = RemoveFunctions<ModelClass>;
|
|
794
|
-
export type ModelToDocumentTypeWithoutId<ModelClass extends ModelClassBase> = DocumentWithoutId<ModelToDocumentType<ModelClass>>;
|
|
795
|
-
export type ModelToDocumentTypeWithIdOptional<ModelClass extends ModelClassBase> = DocumentWithIdOptional<ModelToDocumentType<ModelClass>>;
|
|
796
|
-
export type ModelToMongoSelector<ModelClass extends ModelClassBase> = MongoSelector<ModelToDocumentType<ModelClass>>;
|
|
797
|
-
export type ModelToUpdateFilter<ModelClass extends ModelClassBase> = MongoDB.UpdateFilter<ModelToDocumentTypeWithoutId<ModelClass>> | Partial<ModelToDocumentTypeWithoutId<ModelClass>>;
|
|
798
|
-
export interface CollectionIndex {
|
|
799
|
-
keys: MongoDB.IndexSpecification;
|
|
800
|
-
options?: MongoDB.CreateIndexesOptions;
|
|
801
|
-
}
|
|
802
|
-
declare namespace DataLoader {
|
|
803
|
-
interface LoadDataOptionsBase<ModelClass extends ModelClassBase> {
|
|
804
|
-
key: keyof ModelClass;
|
|
805
|
-
match?: MongoFilter<ModelClass>;
|
|
806
|
-
sort?: MongoDB.Sort;
|
|
807
|
-
project?: MongoDB.Document;
|
|
808
|
-
timeout?: number;
|
|
809
|
-
debug?: boolean;
|
|
810
|
-
}
|
|
811
|
-
export interface LoadDataOptions<ModelClass extends ModelClassBase> extends LoadDataOptionsBase<ModelClass> {
|
|
812
|
-
value?: any;
|
|
813
|
-
values?: Array<any>;
|
|
814
|
-
}
|
|
815
|
-
export interface LoadOneOptions<ModelClass extends ModelClassBase> extends LoadDataOptionsBase<ModelClass> {
|
|
816
|
-
value: any;
|
|
817
|
-
}
|
|
818
|
-
export type LoadData<ModelClass extends ModelClassBase> = (options: LoadDataOptions<ModelClass>) => Promise<Array<ModelClass>>;
|
|
819
|
-
export type LoadOne<ModelClass extends ModelClassBase> = (options: LoadOneOptions<ModelClass>) => Promise<ModelClass>;
|
|
820
|
-
export type LoadMany<ModelClass extends ModelClassBase> = (options: LoadDataOptions<ModelClass>) => Promise<Array<ModelClass>>;
|
|
821
|
-
export type LoadById<ModelClass extends ModelClassBase> = (id: ModelClass["_id"]) => Promise<ModelClass>;
|
|
822
|
-
export {};
|
|
823
|
-
}
|
|
824
|
-
export type MongoFilter<ModelClass extends ModelClassBase = ModelClassBase> = MongoDB.Filter<ModelClass> & ({
|
|
825
|
-
_id?: ModelClass["_id"];
|
|
826
|
-
} | {
|
|
827
|
-
_id?: {
|
|
828
|
-
$in: ModelClass["_id"][];
|
|
829
|
-
};
|
|
830
|
-
});
|
|
831
|
-
export type MongoSelector<ModelClass extends ModelClassBase = ModelClassBase> = ModelClass["_id"] | MongoFilter<ModelClass>;
|
|
832
|
-
export interface FindCursor<ModelClass> extends MongoDB.FindCursor {
|
|
833
|
-
toArray: () => Promise<Array<ModelClass>>;
|
|
834
|
-
}
|
|
835
|
-
export interface UpdateOptions {
|
|
836
|
-
clean?: boolean;
|
|
837
|
-
validate?: boolean;
|
|
838
|
-
mongoOptions?: MongoDB.UpdateOptions;
|
|
839
|
-
}
|
|
840
|
-
export interface FindOneAndUpdateUpdateOptions {
|
|
841
|
-
clean?: boolean;
|
|
842
|
-
validate?: boolean;
|
|
843
|
-
mongoOptions?: MongoDB.FindOneAndUpdateOptions;
|
|
844
|
-
}
|
|
845
|
-
export interface InsertOptions {
|
|
846
|
-
clean?: boolean;
|
|
847
|
-
validate?: boolean;
|
|
848
|
-
mongoOptions?: MongoDB.InsertOneOptions;
|
|
849
|
-
}
|
|
850
|
-
export type InitItem<ModelClass extends ModelClassBase> = (doc: any) => ModelClass;
|
|
851
|
-
export type FindOne<ModelClass extends ModelClassBase> = (selector?: ModelToMongoSelector<ModelClass>, options?: MongoDB.FindOptions) => Promise<ModelClass>;
|
|
852
|
-
export type Find<ModelClass extends ModelClassBase> = (selector?: ModelToMongoSelector<ModelClass>, options?: MongoDB.FindOptions) => FindCursor<ModelClass>;
|
|
853
|
-
export type FindOneAndUpdate<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<ModelClass>;
|
|
854
|
-
export type UpdateAndFind<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<ModelClass>;
|
|
855
|
-
export type UpdateItem<ModelClass extends ModelClassBase> = (item: ModelClass, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<void>;
|
|
856
|
-
export type InsertOne<ModelClass extends ModelClassBase> = (doc: ModelToDocumentTypeWithIdOptional<ModelClass>, options?: InsertOptions) => Promise<ModelClass["_id"]>;
|
|
857
|
-
export type InsertMany<ModelClass extends ModelClassBase> = (doc: Array<ModelToDocumentTypeWithIdOptional<ModelClass>>, options?: InsertOptions) => Promise<Array<ModelClass["_id"]>>;
|
|
858
|
-
export type InsertAndFind<ModelClass extends ModelClassBase> = (doc: ModelToDocumentTypeWithIdOptional<ModelClass>, options?: InsertOptions) => Promise<ModelClass>;
|
|
859
|
-
export type DeleteMany<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, options?: MongoDB.DeleteOptions) => Promise<MongoDB.DeleteResult>;
|
|
860
|
-
export type DeleteOne<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, options?: MongoDB.DeleteOptions) => Promise<MongoDB.DeleteResult>;
|
|
861
|
-
export type UpdateOne<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: UpdateOptions) => Promise<MongoDB.UpdateResult>;
|
|
862
|
-
export type UpdateMany<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: UpdateOptions) => Promise<MongoDB.UpdateResult | MongoDB.Document>;
|
|
863
|
-
export type Upsert<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: UpdateOptions) => Promise<MongoDB.UpdateResult>;
|
|
864
|
-
export type EstimatedDocumentCount<ModelClass extends ModelClassBase> = (options?: MongoDB.EstimatedDocumentCountOptions) => Promise<number>;
|
|
865
|
-
export type CountDocuments<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, options?: MongoDB.CountDocumentsOptions) => Promise<number>;
|
|
866
|
-
export interface Collection<ModelClass extends ModelClassBase = ModelClassBase> {
|
|
867
|
-
name: string;
|
|
868
|
-
connectionName?: string;
|
|
869
|
-
schema?: Schema$1;
|
|
870
|
-
/**
|
|
871
|
-
* @deprecated Use schema instead. If you use model, all items will be initialized with the model to add resolvers (which are also deprecated)
|
|
872
|
-
*/
|
|
873
|
-
model?: Model$1;
|
|
874
|
-
indexes: Array<CollectionIndex>;
|
|
875
|
-
generateId: () => ModelClass["_id"];
|
|
876
|
-
getSchema: () => Schema$1;
|
|
877
|
-
db: MongoDB.Db;
|
|
878
|
-
client: OrionMongoClient;
|
|
879
|
-
rawCollection: MongoDB.Collection<ModelClass>;
|
|
880
|
-
initItem: InitItem<ModelClass>;
|
|
881
|
-
findOne: FindOne<ModelClass>;
|
|
882
|
-
find: Find<ModelClass>;
|
|
883
|
-
insertOne: InsertOne<ModelClass>;
|
|
884
|
-
insertMany: InsertMany<ModelClass>;
|
|
885
|
-
insertAndFind: InsertAndFind<ModelClass>;
|
|
886
|
-
deleteMany: DeleteMany<ModelClass>;
|
|
887
|
-
deleteOne: DeleteOne<ModelClass>;
|
|
888
|
-
updateOne: UpdateOne<ModelClass>;
|
|
889
|
-
updateMany: UpdateMany<ModelClass>;
|
|
890
|
-
upsert: Upsert<ModelClass>;
|
|
891
|
-
findOneAndUpdate: FindOneAndUpdate<ModelClass>;
|
|
892
|
-
/**
|
|
893
|
-
* Updates a document and returns the updated document with the changes
|
|
894
|
-
*/
|
|
895
|
-
updateAndFind: UpdateAndFind<ModelClass>;
|
|
896
|
-
updateItem: UpdateItem<ModelClass>;
|
|
897
|
-
estimatedDocumentCount: EstimatedDocumentCount<ModelClass>;
|
|
898
|
-
countDocuments: CountDocuments<ModelClass>;
|
|
899
|
-
aggregate: <T = MongoDB.Document>(pipeline?: MongoDB.Document[], options?: MongoDB.AggregateOptions) => MongoDB.AggregationCursor<T>;
|
|
900
|
-
watch: <T = MongoDB.Document>(pipeline?: MongoDB.Document[], options?: MongoDB.ChangeStreamOptions) => MongoDB.ChangeStream<T>;
|
|
901
|
-
loadData: DataLoader.LoadData<ModelClass>;
|
|
902
|
-
loadOne: DataLoader.LoadOne<ModelClass>;
|
|
903
|
-
loadMany: DataLoader.LoadMany<ModelClass>;
|
|
904
|
-
loadById: DataLoader.LoadById<ModelClass>;
|
|
905
|
-
/**
|
|
906
|
-
* Use this function if you are using tests and you pass the
|
|
907
|
-
* env var DONT_CREATE_INDEXES_AUTOMATICALLY and you need to
|
|
908
|
-
* create the indexes for this collection
|
|
909
|
-
*/
|
|
910
|
-
createIndexes: () => Promise<string[]>;
|
|
911
|
-
createIndexesPromise: Promise<string[]>;
|
|
912
|
-
connectionPromise: Promise<MongoDB.MongoClient>;
|
|
913
|
-
}
|
|
65
|
+
declare const _default$1: import("@orion-js/models").Model<FileSchema>;
|
|
914
66
|
export declare const Files: Collection<FileSchema>;
|
|
915
67
|
export declare function getFileURL(file: FileSchema): string;
|
|
916
68
|
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var __legacyMetadataTS = (k, v) => {
|
|
|
57
57
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
58
58
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
59
59
|
|
|
60
|
-
//
|
|
60
|
+
// node_modules/@orion-js/resolvers/dist/index.js
|
|
61
61
|
import { createRequire as createRequire2 } from "node:module";
|
|
62
62
|
import crypto2 from "crypto";
|
|
63
63
|
function hashObject_default(object) {
|
|
@@ -23369,7 +23369,7 @@ var require_v358 = __commonJS((exports) => {
|
|
|
23369
23369
|
var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
23370
23370
|
exports.URL = URL2;
|
|
23371
23371
|
function _default(name, version, hashfunc) {
|
|
23372
|
-
var
|
|
23372
|
+
var generateUUID3 = function(value, namespace, buf, offset) {
|
|
23373
23373
|
var off = buf && offset || 0;
|
|
23374
23374
|
if (typeof value == "string")
|
|
23375
23375
|
value = stringToBytes(value);
|
|
@@ -23390,12 +23390,12 @@ var require_v358 = __commonJS((exports) => {
|
|
|
23390
23390
|
return buf || (0, _bytesToUuid.default)(bytes);
|
|
23391
23391
|
};
|
|
23392
23392
|
try {
|
|
23393
|
-
|
|
23393
|
+
generateUUID3.name = name;
|
|
23394
23394
|
} catch (err) {
|
|
23395
23395
|
}
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
return
|
|
23396
|
+
generateUUID3.DNS = DNS;
|
|
23397
|
+
generateUUID3.URL = URL2;
|
|
23398
|
+
return generateUUID3;
|
|
23399
23399
|
}
|
|
23400
23400
|
});
|
|
23401
23401
|
|
|
@@ -886639,7 +886639,7 @@ var require_aws2 = __commonJS((exports, module) => {
|
|
|
886639
886639
|
// src/resolvers/fileManagerFile.ts
|
|
886640
886640
|
init_dist();
|
|
886641
886641
|
|
|
886642
|
-
//
|
|
886642
|
+
// node_modules/@orion-js/models/dist/index.js
|
|
886643
886643
|
var __create5 = Object.create;
|
|
886644
886644
|
var __getProtoOf5 = Object.getPrototypeOf;
|
|
886645
886645
|
var __defProp5 = Object.defineProperty;
|
|
@@ -891526,7 +891526,7 @@ function createModel(modelOptions) {
|
|
|
891526
891526
|
return model;
|
|
891527
891527
|
}
|
|
891528
891528
|
|
|
891529
|
-
//
|
|
891529
|
+
// node_modules/@orion-js/mongodb/dist/index.js
|
|
891530
891530
|
import { createRequire as createRequire3 } from "node:module";
|
|
891531
891531
|
import { createRequire as createRequire22 } from "node:module";
|
|
891532
891532
|
import crypto22 from "crypto";
|
|
@@ -972549,7 +972549,7 @@ var export_Service = import_typedi2.Service;
|
|
|
972549
972549
|
var export_Inject = import_typedi2.Inject;
|
|
972550
972550
|
var export_Container = import_typedi2.Container;
|
|
972551
972551
|
|
|
972552
|
-
//
|
|
972552
|
+
// node_modules/@orion-js/typed-model/dist/index.js
|
|
972553
972553
|
import { createRequire as createRequire5 } from "node:module";
|
|
972554
972554
|
import crypto23 from "crypto";
|
|
972555
972555
|
var __create8 = Object.create;
|
|
@@ -979459,7 +979459,7 @@ var fileManagerFile_default = resolver({
|
|
|
979459
979459
|
}
|
|
979460
979460
|
});
|
|
979461
979461
|
|
|
979462
|
-
//
|
|
979462
|
+
// node_modules/@orion-js/paginated-mongodb/dist/index.js
|
|
979463
979463
|
import { createRequire as createRequire7 } from "node:module";
|
|
979464
979464
|
import crypto24 from "crypto";
|
|
979465
979465
|
var __create9 = Object.create;
|
|
@@ -998215,7 +998215,7 @@ var completeUpload_default = resolver({
|
|
|
998215
998215
|
// src/resolvers/generateUploadCredentials.ts
|
|
998216
998216
|
init_dist();
|
|
998217
998217
|
|
|
998218
|
-
//
|
|
998218
|
+
// node_modules/@orion-js/helpers/dist/index.js
|
|
998219
998219
|
import { createRequire as createRequire8 } from "node:module";
|
|
998220
998220
|
import crypto3 from "crypto";
|
|
998221
998221
|
var __create10 = Object.create;
|
|
@@ -998942,6 +998942,9 @@ var v15 = import_dist5.default.v1;
|
|
|
998942
998942
|
var v35 = import_dist5.default.v3;
|
|
998943
998943
|
var v45 = import_dist5.default.v4;
|
|
998944
998944
|
var v55 = import_dist5.default.v5;
|
|
998945
|
+
function generateUUID2() {
|
|
998946
|
+
return v45();
|
|
998947
|
+
}
|
|
998945
998948
|
|
|
998946
998949
|
// src/resolvers/generateUploadCredentials.ts
|
|
998947
998950
|
var import_aws_sdk = __toESM(require_aws2(), 1);
|
|
@@ -998999,7 +999002,8 @@ var generateUploadCredentials_default = resolver({
|
|
|
998999
999002
|
return null;
|
|
999000
999003
|
}
|
|
999001
999004
|
const key = `${basePath}/${generateId5()}-${params.name}`;
|
|
999002
|
-
const fileId = await Files.insertOne({
|
|
999005
|
+
const fileId = await Files.rawCollection.insertOne({
|
|
999006
|
+
_id: `ofl-${generateUUID2()}`,
|
|
999003
999007
|
key,
|
|
999004
999008
|
bucket,
|
|
999005
999009
|
name: params.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/file-manager",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-next.0",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"dev": "bun --watch src/index.ts"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@orion-js/helpers": "
|
|
17
|
-
"@orion-js/models": "
|
|
18
|
-
"@orion-js/mongodb": "
|
|
19
|
-
"@orion-js/paginated-mongodb": "
|
|
20
|
-
"@orion-js/resolvers": "
|
|
21
|
-
"@orion-js/schema": "
|
|
22
|
-
"@orion-js/typed-model": "
|
|
16
|
+
"@orion-js/helpers": "4.0.0-next.0",
|
|
17
|
+
"@orion-js/models": "4.0.0-next.0",
|
|
18
|
+
"@orion-js/mongodb": "4.0.0-next.0",
|
|
19
|
+
"@orion-js/paginated-mongodb": "4.0.0-next.0",
|
|
20
|
+
"@orion-js/resolvers": "4.0.0-next.0",
|
|
21
|
+
"@orion-js/schema": "4.0.0-next.0",
|
|
22
|
+
"@orion-js/typed-model": "4.0.0-next.0",
|
|
23
23
|
"aws-sdk": "^2.1367.0",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/dot-object": "^2.1.2",
|
|
30
30
|
"@types/lodash": "4.14.181",
|
|
31
|
-
"@types/node": "16.11.7",
|
|
32
31
|
"typescript": "^5.4.5",
|
|
33
32
|
"@types/bun": "^1.2.4"
|
|
34
33
|
},
|