@orion-js/file-manager 4.0.0-next.3 → 4.0.0-next.5
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 +229 -249
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +219 -252
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,260 +1,106 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create((base == null ? void 0 : base[__knownSymbol("metadata")]) ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
11
18
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
17
40
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
22
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
23
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
24
|
-
if (decorator = decorators[i])
|
|
25
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
26
|
-
if (kind && result) __defProp(target, key, result);
|
|
27
|
-
return result;
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
28
42
|
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
48
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
29
49
|
|
|
30
|
-
// src/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
getAWSCredentials = () => savedOptions;
|
|
39
|
-
getFileManagerOptions = () => savedOptions;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
50
|
+
// src/resolvers/fileManagerFile.ts
|
|
51
|
+
import { createResolver } from "@orion-js/resolvers";
|
|
52
|
+
|
|
53
|
+
// src/Files/index.ts
|
|
54
|
+
import { createCollection as createCollection2 } from "@orion-js/mongodb";
|
|
55
|
+
|
|
56
|
+
// src/File/schema.ts
|
|
57
|
+
import { Prop, TypedSchema } from "@orion-js/typed-model";
|
|
42
58
|
|
|
43
59
|
// src/File/resolvers/genericType.ts
|
|
44
60
|
import { modelResolver } from "@orion-js/resolvers";
|
|
45
|
-
var genericType_default
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (type.startsWith("image/")) return "image";
|
|
54
|
-
if (type.startsWith("application/pdf")) return "pdf";
|
|
55
|
-
return "unknown";
|
|
56
|
-
}
|
|
57
|
-
});
|
|
61
|
+
var genericType_default = modelResolver({
|
|
62
|
+
returns: String,
|
|
63
|
+
async resolve(file, viewer) {
|
|
64
|
+
const { type } = file;
|
|
65
|
+
if (!type) return "unknown";
|
|
66
|
+
if (type.startsWith("image/")) return "image";
|
|
67
|
+
if (type.startsWith("application/pdf")) return "pdf";
|
|
68
|
+
return "unknown";
|
|
58
69
|
}
|
|
59
70
|
});
|
|
60
71
|
|
|
61
72
|
// src/File/resolvers/url.ts
|
|
62
73
|
import { modelResolver as modelResolver2 } from "@orion-js/resolvers";
|
|
74
|
+
|
|
75
|
+
// src/credentials.ts
|
|
76
|
+
var savedOptions = {};
|
|
77
|
+
var setupFileManager = (options) => {
|
|
78
|
+
savedOptions = options;
|
|
79
|
+
};
|
|
80
|
+
var getAWSCredentials = () => savedOptions;
|
|
81
|
+
var getFileManagerOptions = () => savedOptions;
|
|
82
|
+
|
|
83
|
+
// src/File/resolvers/url.ts
|
|
63
84
|
function getFileURL(file) {
|
|
64
85
|
if (file.externalUrl) return file.externalUrl;
|
|
65
86
|
const options = getAWSCredentials();
|
|
66
87
|
if (options.getFileURL) return options.getFileURL(file);
|
|
67
88
|
return `https://s3.amazonaws.com/${file.bucket}/${encodeURIComponent(file.key)}`;
|
|
68
89
|
}
|
|
69
|
-
var url_default
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
url_default = modelResolver2({
|
|
74
|
-
returns: String,
|
|
75
|
-
async resolve(file) {
|
|
76
|
-
return getFileURL(file);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
90
|
+
var url_default = modelResolver2({
|
|
91
|
+
returns: String,
|
|
92
|
+
async resolve(file) {
|
|
93
|
+
return getFileURL(file);
|
|
79
94
|
}
|
|
80
95
|
});
|
|
81
96
|
|
|
82
97
|
// src/File/resolvers/index.ts
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
var resolvers_default;
|
|
88
|
-
var init_resolvers = __esm({
|
|
89
|
-
"src/File/resolvers/index.ts"() {
|
|
90
|
-
init_genericType();
|
|
91
|
-
init_url();
|
|
92
|
-
resolvers_default = {
|
|
93
|
-
url: url_default,
|
|
94
|
-
genericType: genericType_default
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// src/resolvers/fileManagerFile.ts
|
|
100
|
-
import { resolver } from "@orion-js/resolvers";
|
|
101
|
-
|
|
102
|
-
// src/File/index.ts
|
|
103
|
-
import { createModel } from "@orion-js/models";
|
|
104
|
-
|
|
105
|
-
// src/Files/index.ts
|
|
106
|
-
import { createCollection } from "@orion-js/mongodb";
|
|
107
|
-
|
|
108
|
-
// src/File/schema.ts
|
|
109
|
-
import { getModelForClass, Prop, TypedSchema } from "@orion-js/typed-model";
|
|
110
|
-
var FileSchemaResizeData = class {
|
|
111
|
-
thumbnailURL;
|
|
112
|
-
smallURL;
|
|
113
|
-
mediumURL;
|
|
114
|
-
largeURL;
|
|
115
|
-
extraLargeURL;
|
|
116
|
-
// 2400 height max
|
|
117
|
-
};
|
|
118
|
-
__decorateClass([
|
|
119
|
-
Prop({ optional: true })
|
|
120
|
-
], FileSchemaResizeData.prototype, "thumbnailURL", 2);
|
|
121
|
-
__decorateClass([
|
|
122
|
-
Prop({ optional: true })
|
|
123
|
-
], FileSchemaResizeData.prototype, "smallURL", 2);
|
|
124
|
-
__decorateClass([
|
|
125
|
-
Prop({ optional: true })
|
|
126
|
-
], FileSchemaResizeData.prototype, "mediumURL", 2);
|
|
127
|
-
__decorateClass([
|
|
128
|
-
Prop({ optional: true })
|
|
129
|
-
], FileSchemaResizeData.prototype, "largeURL", 2);
|
|
130
|
-
__decorateClass([
|
|
131
|
-
Prop({ optional: true })
|
|
132
|
-
], FileSchemaResizeData.prototype, "extraLargeURL", 2);
|
|
133
|
-
FileSchemaResizeData = __decorateClass([
|
|
134
|
-
TypedSchema()
|
|
135
|
-
], FileSchemaResizeData);
|
|
136
|
-
var FileSchemaDimensionsData = class {
|
|
137
|
-
width;
|
|
138
|
-
height;
|
|
98
|
+
var resolvers_default = {
|
|
99
|
+
url: url_default,
|
|
100
|
+
genericType: genericType_default
|
|
139
101
|
};
|
|
140
|
-
__decorateClass([
|
|
141
|
-
Prop({ optional: true })
|
|
142
|
-
], FileSchemaDimensionsData.prototype, "width", 2);
|
|
143
|
-
__decorateClass([
|
|
144
|
-
Prop({ optional: true })
|
|
145
|
-
], FileSchemaDimensionsData.prototype, "height", 2);
|
|
146
|
-
FileSchemaDimensionsData = __decorateClass([
|
|
147
|
-
TypedSchema()
|
|
148
|
-
], FileSchemaDimensionsData);
|
|
149
|
-
var FileSchemaColorsData = class {
|
|
150
|
-
front;
|
|
151
|
-
background;
|
|
152
|
-
blurhash;
|
|
153
|
-
};
|
|
154
|
-
__decorateClass([
|
|
155
|
-
Prop({ optional: true })
|
|
156
|
-
], FileSchemaColorsData.prototype, "front", 2);
|
|
157
|
-
__decorateClass([
|
|
158
|
-
Prop({ optional: true })
|
|
159
|
-
], FileSchemaColorsData.prototype, "background", 2);
|
|
160
|
-
__decorateClass([
|
|
161
|
-
Prop({ optional: true })
|
|
162
|
-
], FileSchemaColorsData.prototype, "blurhash", 2);
|
|
163
|
-
FileSchemaColorsData = __decorateClass([
|
|
164
|
-
TypedSchema()
|
|
165
|
-
], FileSchemaColorsData);
|
|
166
|
-
var FileSchema = class {
|
|
167
|
-
_id;
|
|
168
|
-
hash;
|
|
169
|
-
externalUrl;
|
|
170
|
-
key;
|
|
171
|
-
bucket;
|
|
172
|
-
name;
|
|
173
|
-
type;
|
|
174
|
-
size;
|
|
175
|
-
status;
|
|
176
|
-
createdBy;
|
|
177
|
-
createdAt;
|
|
178
|
-
dimensions;
|
|
179
|
-
resizedData;
|
|
180
|
-
colorsData;
|
|
181
|
-
};
|
|
182
|
-
__decorateClass([
|
|
183
|
-
Prop({ type: "ID" })
|
|
184
|
-
], FileSchema.prototype, "_id", 2);
|
|
185
|
-
__decorateClass([
|
|
186
|
-
Prop({ optional: true })
|
|
187
|
-
], FileSchema.prototype, "hash", 2);
|
|
188
|
-
__decorateClass([
|
|
189
|
-
Prop({
|
|
190
|
-
optional: true,
|
|
191
|
-
private: true
|
|
192
|
-
})
|
|
193
|
-
], FileSchema.prototype, "externalUrl", 2);
|
|
194
|
-
__decorateClass([
|
|
195
|
-
Prop({ optional: true })
|
|
196
|
-
], FileSchema.prototype, "key", 2);
|
|
197
|
-
__decorateClass([
|
|
198
|
-
Prop({ optional: true })
|
|
199
|
-
], FileSchema.prototype, "bucket", 2);
|
|
200
|
-
__decorateClass([
|
|
201
|
-
Prop({ optional: true })
|
|
202
|
-
], FileSchema.prototype, "name", 2);
|
|
203
|
-
__decorateClass([
|
|
204
|
-
Prop({ optional: true })
|
|
205
|
-
], FileSchema.prototype, "type", 2);
|
|
206
|
-
__decorateClass([
|
|
207
|
-
Prop({ optional: true })
|
|
208
|
-
], FileSchema.prototype, "size", 2);
|
|
209
|
-
__decorateClass([
|
|
210
|
-
Prop({ optional: true })
|
|
211
|
-
], FileSchema.prototype, "status", 2);
|
|
212
|
-
__decorateClass([
|
|
213
|
-
Prop({ optional: true })
|
|
214
|
-
], FileSchema.prototype, "createdBy", 2);
|
|
215
|
-
__decorateClass([
|
|
216
|
-
Prop({ optional: true })
|
|
217
|
-
], FileSchema.prototype, "createdAt", 2);
|
|
218
|
-
__decorateClass([
|
|
219
|
-
Prop({ optional: true, type: getModelForClass(FileSchemaDimensionsData) })
|
|
220
|
-
], FileSchema.prototype, "dimensions", 2);
|
|
221
|
-
__decorateClass([
|
|
222
|
-
Prop({ optional: true, type: getModelForClass(FileSchemaResizeData) })
|
|
223
|
-
], FileSchema.prototype, "resizedData", 2);
|
|
224
|
-
__decorateClass([
|
|
225
|
-
Prop({ optional: true, type: getModelForClass(FileSchemaColorsData) })
|
|
226
|
-
], FileSchema.prototype, "colorsData", 2);
|
|
227
|
-
FileSchema = __decorateClass([
|
|
228
|
-
TypedSchema()
|
|
229
|
-
], FileSchema);
|
|
230
|
-
|
|
231
|
-
// src/Files/index.ts
|
|
232
|
-
var Files = createCollection({
|
|
233
|
-
name: "filemanager_files",
|
|
234
|
-
model: File_default,
|
|
235
|
-
schema: FileSchema,
|
|
236
|
-
indexes: [
|
|
237
|
-
{
|
|
238
|
-
keys: {
|
|
239
|
-
key: 1,
|
|
240
|
-
bucket: 1
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
keys: {
|
|
245
|
-
hash: 1
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// src/File/index.ts
|
|
252
|
-
import pick from "lodash/pick";
|
|
253
|
-
import omit from "lodash/omit";
|
|
254
|
-
import { getModelForClass as getModelForClass2 } from "@orion-js/typed-model";
|
|
255
102
|
|
|
256
103
|
// src/resolvers/generateImageInfo.ts
|
|
257
|
-
init_credentials();
|
|
258
104
|
import { isEmpty } from "lodash";
|
|
259
105
|
|
|
260
106
|
// src/File/resolvers/isImage.ts
|
|
@@ -305,33 +151,160 @@ async function generateImageInfo(file) {
|
|
|
305
151
|
}
|
|
306
152
|
}
|
|
307
153
|
|
|
308
|
-
// src/File/
|
|
309
|
-
|
|
310
|
-
|
|
154
|
+
// src/File/schema.ts
|
|
155
|
+
import { pick } from "lodash";
|
|
156
|
+
|
|
157
|
+
// src/File/getFileData.ts
|
|
158
|
+
import { createCollection } from "@orion-js/mongodb";
|
|
159
|
+
var readOnlyCollection = createCollection({ name: "filemanager_files" });
|
|
160
|
+
async function getFileData(fileId) {
|
|
161
|
+
const file = await readOnlyCollection.findOne({ _id: fileId });
|
|
162
|
+
return file;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/File/schema.ts
|
|
166
|
+
var _extraLargeURL_dec, _largeURL_dec, _mediumURL_dec, _smallURL_dec, _thumbnailURL_dec, _FileSchemaResizeData_decorators, _init;
|
|
167
|
+
_FileSchemaResizeData_decorators = [TypedSchema()], _thumbnailURL_dec = [Prop({ optional: true, type: "string" })], _smallURL_dec = [Prop({ optional: true, type: "string" })], _mediumURL_dec = [Prop({ optional: true, type: "string" })], _largeURL_dec = [Prop({ optional: true, type: "string" })], _extraLargeURL_dec = [Prop({ optional: true, type: "string" })];
|
|
168
|
+
var FileSchemaResizeData = class {
|
|
169
|
+
constructor() {
|
|
170
|
+
__publicField(this, "thumbnailURL", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
171
|
+
__publicField(this, "smallURL", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
172
|
+
__publicField(this, "mediumURL", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
173
|
+
__publicField(this, "largeURL", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
|
|
174
|
+
__publicField(this, "extraLargeURL", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
175
|
+
}
|
|
176
|
+
// 2400 height max
|
|
177
|
+
};
|
|
178
|
+
_init = __decoratorStart(null);
|
|
179
|
+
__decorateElement(_init, 5, "thumbnailURL", _thumbnailURL_dec, FileSchemaResizeData);
|
|
180
|
+
__decorateElement(_init, 5, "smallURL", _smallURL_dec, FileSchemaResizeData);
|
|
181
|
+
__decorateElement(_init, 5, "mediumURL", _mediumURL_dec, FileSchemaResizeData);
|
|
182
|
+
__decorateElement(_init, 5, "largeURL", _largeURL_dec, FileSchemaResizeData);
|
|
183
|
+
__decorateElement(_init, 5, "extraLargeURL", _extraLargeURL_dec, FileSchemaResizeData);
|
|
184
|
+
FileSchemaResizeData = __decorateElement(_init, 0, "FileSchemaResizeData", _FileSchemaResizeData_decorators, FileSchemaResizeData);
|
|
185
|
+
__runInitializers(_init, 1, FileSchemaResizeData);
|
|
186
|
+
var _height_dec, _width_dec, _FileSchemaDimensionsData_decorators, _init2;
|
|
187
|
+
_FileSchemaDimensionsData_decorators = [TypedSchema()], _width_dec = [Prop({ optional: true, type: "number" })], _height_dec = [Prop({ optional: true, type: "number" })];
|
|
188
|
+
var FileSchemaDimensionsData = class {
|
|
189
|
+
constructor() {
|
|
190
|
+
__publicField(this, "width", __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
191
|
+
__publicField(this, "height", __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
_init2 = __decoratorStart(null);
|
|
195
|
+
__decorateElement(_init2, 5, "width", _width_dec, FileSchemaDimensionsData);
|
|
196
|
+
__decorateElement(_init2, 5, "height", _height_dec, FileSchemaDimensionsData);
|
|
197
|
+
FileSchemaDimensionsData = __decorateElement(_init2, 0, "FileSchemaDimensionsData", _FileSchemaDimensionsData_decorators, FileSchemaDimensionsData);
|
|
198
|
+
__runInitializers(_init2, 1, FileSchemaDimensionsData);
|
|
199
|
+
var _blurhash_dec, _background_dec, _front_dec, _FileSchemaColorsData_decorators, _init3;
|
|
200
|
+
_FileSchemaColorsData_decorators = [TypedSchema()], _front_dec = [Prop({ optional: true, type: "string" })], _background_dec = [Prop({ optional: true, type: "string" })], _blurhash_dec = [Prop({ optional: true, type: "string" })];
|
|
201
|
+
var FileSchemaColorsData = class {
|
|
202
|
+
constructor() {
|
|
203
|
+
__publicField(this, "front", __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
|
|
204
|
+
__publicField(this, "background", __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
205
|
+
__publicField(this, "blurhash", __runInitializers(_init3, 16, this)), __runInitializers(_init3, 19, this);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
_init3 = __decoratorStart(null);
|
|
209
|
+
__decorateElement(_init3, 5, "front", _front_dec, FileSchemaColorsData);
|
|
210
|
+
__decorateElement(_init3, 5, "background", _background_dec, FileSchemaColorsData);
|
|
211
|
+
__decorateElement(_init3, 5, "blurhash", _blurhash_dec, FileSchemaColorsData);
|
|
212
|
+
FileSchemaColorsData = __decorateElement(_init3, 0, "FileSchemaColorsData", _FileSchemaColorsData_decorators, FileSchemaColorsData);
|
|
213
|
+
__runInitializers(_init3, 1, FileSchemaColorsData);
|
|
214
|
+
var _colorsData_dec, _resizedData_dec, _dimensions_dec, _createdAt_dec, _createdBy_dec, _status_dec, _size_dec, _type_dec, _name_dec, _bucket_dec, _key_dec, _externalUrl_dec, _hash_dec, __id_dec, _FileSchema_decorators, _init4;
|
|
215
|
+
_FileSchema_decorators = [TypedSchema({
|
|
311
216
|
name: "File",
|
|
312
|
-
|
|
313
|
-
resolvers: () => (init_resolvers(), __toCommonJS(resolvers_exports)),
|
|
217
|
+
resolvers: resolvers_default,
|
|
314
218
|
// this is only called when its child
|
|
315
219
|
async clean(value) {
|
|
316
220
|
if (!value) return null;
|
|
317
221
|
const fileId = value._id;
|
|
318
|
-
const file = await
|
|
222
|
+
const file = await getFileData(fileId);
|
|
319
223
|
if (!file) return null;
|
|
320
224
|
await generateImageInfo(file);
|
|
321
|
-
const keys =
|
|
225
|
+
const keys = [
|
|
226
|
+
"_id",
|
|
227
|
+
"hash",
|
|
228
|
+
"externalUrl",
|
|
229
|
+
"key",
|
|
230
|
+
"bucket",
|
|
231
|
+
"name",
|
|
232
|
+
"type",
|
|
233
|
+
"size",
|
|
234
|
+
// 'status',
|
|
235
|
+
// 'createdBy',
|
|
236
|
+
// 'createdAt',
|
|
237
|
+
"dimensions",
|
|
238
|
+
"resizedData",
|
|
239
|
+
"colorsData"
|
|
240
|
+
];
|
|
322
241
|
const data = pick(file, keys);
|
|
323
242
|
return data;
|
|
324
243
|
}
|
|
244
|
+
})], __id_dec = [Prop({ type: "ID" })], _hash_dec = [Prop({ optional: true, type: "string" })], _externalUrl_dec = [Prop({ optional: true, type: "string" })], _key_dec = [Prop({ optional: true, type: "string" })], _bucket_dec = [Prop({ optional: true, type: "string" })], _name_dec = [Prop({ optional: true, type: "string" })], _type_dec = [Prop({ optional: true, type: "string" })], _size_dec = [Prop({ optional: true, type: "number" })], _status_dec = [Prop({ optional: true, type: "string" })], _createdBy_dec = [Prop({ optional: true, type: "string" })], _createdAt_dec = [Prop({ optional: true, type: Date })], _dimensions_dec = [Prop({ optional: true, type: FileSchemaDimensionsData })], _resizedData_dec = [Prop({ optional: true, type: FileSchemaResizeData })], _colorsData_dec = [Prop({ optional: true, type: FileSchemaColorsData })];
|
|
245
|
+
var FileSchema = class {
|
|
246
|
+
constructor() {
|
|
247
|
+
__publicField(this, "_id", __runInitializers(_init4, 8, this)), __runInitializers(_init4, 11, this);
|
|
248
|
+
__publicField(this, "hash", __runInitializers(_init4, 12, this)), __runInitializers(_init4, 15, this);
|
|
249
|
+
__publicField(this, "externalUrl", __runInitializers(_init4, 16, this)), __runInitializers(_init4, 19, this);
|
|
250
|
+
__publicField(this, "key", __runInitializers(_init4, 20, this)), __runInitializers(_init4, 23, this);
|
|
251
|
+
__publicField(this, "bucket", __runInitializers(_init4, 24, this)), __runInitializers(_init4, 27, this);
|
|
252
|
+
__publicField(this, "name", __runInitializers(_init4, 28, this)), __runInitializers(_init4, 31, this);
|
|
253
|
+
__publicField(this, "type", __runInitializers(_init4, 32, this)), __runInitializers(_init4, 35, this);
|
|
254
|
+
__publicField(this, "size", __runInitializers(_init4, 36, this)), __runInitializers(_init4, 39, this);
|
|
255
|
+
__publicField(this, "status", __runInitializers(_init4, 40, this)), __runInitializers(_init4, 43, this);
|
|
256
|
+
__publicField(this, "createdBy", __runInitializers(_init4, 44, this)), __runInitializers(_init4, 47, this);
|
|
257
|
+
__publicField(this, "createdAt", __runInitializers(_init4, 48, this)), __runInitializers(_init4, 51, this);
|
|
258
|
+
__publicField(this, "dimensions", __runInitializers(_init4, 52, this)), __runInitializers(_init4, 55, this);
|
|
259
|
+
__publicField(this, "resizedData", __runInitializers(_init4, 56, this)), __runInitializers(_init4, 59, this);
|
|
260
|
+
__publicField(this, "colorsData", __runInitializers(_init4, 60, this)), __runInitializers(_init4, 63, this);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
_init4 = __decoratorStart(null);
|
|
264
|
+
__decorateElement(_init4, 5, "_id", __id_dec, FileSchema);
|
|
265
|
+
__decorateElement(_init4, 5, "hash", _hash_dec, FileSchema);
|
|
266
|
+
__decorateElement(_init4, 5, "externalUrl", _externalUrl_dec, FileSchema);
|
|
267
|
+
__decorateElement(_init4, 5, "key", _key_dec, FileSchema);
|
|
268
|
+
__decorateElement(_init4, 5, "bucket", _bucket_dec, FileSchema);
|
|
269
|
+
__decorateElement(_init4, 5, "name", _name_dec, FileSchema);
|
|
270
|
+
__decorateElement(_init4, 5, "type", _type_dec, FileSchema);
|
|
271
|
+
__decorateElement(_init4, 5, "size", _size_dec, FileSchema);
|
|
272
|
+
__decorateElement(_init4, 5, "status", _status_dec, FileSchema);
|
|
273
|
+
__decorateElement(_init4, 5, "createdBy", _createdBy_dec, FileSchema);
|
|
274
|
+
__decorateElement(_init4, 5, "createdAt", _createdAt_dec, FileSchema);
|
|
275
|
+
__decorateElement(_init4, 5, "dimensions", _dimensions_dec, FileSchema);
|
|
276
|
+
__decorateElement(_init4, 5, "resizedData", _resizedData_dec, FileSchema);
|
|
277
|
+
__decorateElement(_init4, 5, "colorsData", _colorsData_dec, FileSchema);
|
|
278
|
+
FileSchema = __decorateElement(_init4, 0, "FileSchema", _FileSchema_decorators, FileSchema);
|
|
279
|
+
__runInitializers(_init4, 1, FileSchema);
|
|
280
|
+
|
|
281
|
+
// src/Files/index.ts
|
|
282
|
+
var Files = createCollection2({
|
|
283
|
+
name: "filemanager_files",
|
|
284
|
+
schema: FileSchema,
|
|
285
|
+
indexes: [
|
|
286
|
+
{
|
|
287
|
+
keys: {
|
|
288
|
+
key: 1,
|
|
289
|
+
bucket: 1
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
keys: {
|
|
294
|
+
hash: 1
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
]
|
|
325
298
|
});
|
|
326
299
|
|
|
327
300
|
// src/resolvers/fileManagerFile.ts
|
|
328
|
-
var fileManagerFile_default =
|
|
301
|
+
var fileManagerFile_default = createResolver({
|
|
329
302
|
params: {
|
|
330
303
|
fileId: {
|
|
331
304
|
type: "ID"
|
|
332
305
|
}
|
|
333
306
|
},
|
|
334
|
-
returns:
|
|
307
|
+
returns: FileSchema,
|
|
335
308
|
async resolve({ fileId }) {
|
|
336
309
|
return await Files.findOne(fileId);
|
|
337
310
|
}
|
|
@@ -347,7 +320,7 @@ var fileManagerFiles = paginatedResolver({
|
|
|
347
320
|
optional: true
|
|
348
321
|
}
|
|
349
322
|
},
|
|
350
|
-
returns:
|
|
323
|
+
returns: FileSchema,
|
|
351
324
|
async getCursor({ filter }, viewer) {
|
|
352
325
|
const query = { status: "uploaded" };
|
|
353
326
|
query.createdBy = viewer.userId;
|
|
@@ -360,14 +333,14 @@ var fileManagerFiles = paginatedResolver({
|
|
|
360
333
|
var fileManagerFiles_default = fileManagerFiles;
|
|
361
334
|
|
|
362
335
|
// src/resolvers/completeUpload.ts
|
|
363
|
-
import {
|
|
364
|
-
var completeUpload_default =
|
|
336
|
+
import { createResolver as createResolver2 } from "@orion-js/resolvers";
|
|
337
|
+
var completeUpload_default = createResolver2({
|
|
365
338
|
params: {
|
|
366
339
|
fileId: {
|
|
367
340
|
type: "ID"
|
|
368
341
|
}
|
|
369
342
|
},
|
|
370
|
-
returns:
|
|
343
|
+
returns: FileSchema,
|
|
371
344
|
mutation: true,
|
|
372
345
|
async resolve({ fileId }, viewer) {
|
|
373
346
|
const file = await Files.findOne({ createdBy: viewer.userId, _id: fileId });
|
|
@@ -378,12 +351,11 @@ var completeUpload_default = resolver2({
|
|
|
378
351
|
});
|
|
379
352
|
|
|
380
353
|
// src/resolvers/generateUploadCredentials.ts
|
|
381
|
-
|
|
382
|
-
import { resolver as resolver3 } from "@orion-js/resolvers";
|
|
354
|
+
import { resolver } from "@orion-js/resolvers";
|
|
383
355
|
import { generateId, generateUUID } from "@orion-js/helpers";
|
|
384
|
-
import { createModel
|
|
356
|
+
import { createModel } from "@orion-js/models";
|
|
385
357
|
import AWS from "aws-sdk";
|
|
386
|
-
var generateUploadCredentials =
|
|
358
|
+
var generateUploadCredentials = resolver({
|
|
387
359
|
params: {
|
|
388
360
|
name: {
|
|
389
361
|
type: String
|
|
@@ -395,7 +367,7 @@ var generateUploadCredentials = resolver3({
|
|
|
395
367
|
type: String
|
|
396
368
|
}
|
|
397
369
|
},
|
|
398
|
-
returns:
|
|
370
|
+
returns: createModel({
|
|
399
371
|
name: "UploadCredentials",
|
|
400
372
|
schema: {
|
|
401
373
|
fileId: {
|
|
@@ -484,12 +456,7 @@ var resolvers = {
|
|
|
484
456
|
generateUploadCredentials
|
|
485
457
|
};
|
|
486
458
|
var resolvers_default2 = resolvers;
|
|
487
|
-
|
|
488
|
-
// src/index.ts
|
|
489
|
-
init_credentials();
|
|
490
|
-
init_url();
|
|
491
459
|
export {
|
|
492
|
-
File_default as File,
|
|
493
460
|
FileSchema,
|
|
494
461
|
Files,
|
|
495
462
|
getAWSCredentials,
|