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