@aeriajs/builtins 0.0.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.
Files changed (63) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +6 -0
  3. package/dist/collections/file/description.d.ts +50 -0
  4. package/dist/collections/file/description.js +70 -0
  5. package/dist/collections/file/description.mjs +258 -0
  6. package/dist/collections/file/download.d.ts +13 -0
  7. package/dist/collections/file/download.js +78 -0
  8. package/dist/collections/file/download.mjs +232 -0
  9. package/dist/collections/file/index.d.ts +1183 -0
  10. package/dist/collections/file/index.js +49 -0
  11. package/dist/collections/file/index.mjs +46 -0
  12. package/dist/collections/file/insert.d.ts +7 -0
  13. package/dist/collections/file/insert.js +44 -0
  14. package/dist/collections/file/insert.mjs +246 -0
  15. package/dist/collections/file/remove.d.ts +3 -0
  16. package/dist/collections/file/remove.js +28 -0
  17. package/dist/collections/file/remove.mjs +184 -0
  18. package/dist/collections/file/removeAll.d.ts +3 -0
  19. package/dist/collections/file/removeAll.js +30 -0
  20. package/dist/collections/file/removeAll.mjs +194 -0
  21. package/dist/collections/index.d.ts +4 -0
  22. package/dist/collections/index.js +20 -0
  23. package/dist/collections/index.mjs +4 -0
  24. package/dist/collections/log/index.d.ts +458 -0
  25. package/dist/collections/log/index.js +46 -0
  26. package/dist/collections/log/index.mjs +45 -0
  27. package/dist/collections/resourceUsage/index.d.ts +57 -0
  28. package/dist/collections/resourceUsage/index.js +19 -0
  29. package/dist/collections/resourceUsage/index.mjs +16 -0
  30. package/dist/collections/user/activate.d.ts +10 -0
  31. package/dist/collections/user/activate.js +65 -0
  32. package/dist/collections/user/activate.mjs +247 -0
  33. package/dist/collections/user/authenticate.d.ts +24 -0
  34. package/dist/collections/user/authenticate.js +103 -0
  35. package/dist/collections/user/authenticate.mjs +398 -0
  36. package/dist/collections/user/createAccount.d.ts +101 -0
  37. package/dist/collections/user/createAccount.js +66 -0
  38. package/dist/collections/user/createAccount.mjs +219 -0
  39. package/dist/collections/user/description.d.ts +103 -0
  40. package/dist/collections/user/description.js +146 -0
  41. package/dist/collections/user/description.mjs +151 -0
  42. package/dist/collections/user/getActivationLink.d.ts +2 -0
  43. package/dist/collections/user/getActivationLink.js +15 -0
  44. package/dist/collections/user/getActivationLink.mjs +156 -0
  45. package/dist/collections/user/getInfo.d.ts +14 -0
  46. package/dist/collections/user/getInfo.js +39 -0
  47. package/dist/collections/user/getInfo.mjs +192 -0
  48. package/dist/collections/user/index.d.ts +3992 -0
  49. package/dist/collections/user/index.js +37 -0
  50. package/dist/collections/user/index.mjs +36 -0
  51. package/dist/collections/user/insert.d.ts +5 -0
  52. package/dist/collections/user/insert.js +35 -0
  53. package/dist/collections/user/insert.mjs +156 -0
  54. package/dist/functions/describe.d.ts +2 -0
  55. package/dist/functions/describe.js +54 -0
  56. package/dist/functions/describe.mjs +302 -0
  57. package/dist/functions/index.d.ts +1 -0
  58. package/dist/functions/index.js +17 -0
  59. package/dist/functions/index.mjs +1 -0
  60. package/dist/index.d.ts +5701 -0
  61. package/dist/index.js +39 -0
  62. package/dist/index.mjs +11 -0
  63. package/package.json +60 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.file = exports.tempFile = void 0;
4
+ const api_1 = require("@aeriajs/api");
5
+ const description_js_1 = require("./description.js");
6
+ const insert_js_1 = require("./insert.js");
7
+ const download_js_1 = require("./download.js");
8
+ const remove_js_1 = require("./remove.js");
9
+ const removeAll_js_1 = require("./removeAll.js");
10
+ exports.tempFile = (0, api_1.defineCollection)({
11
+ description: {
12
+ $id: 'tempFile',
13
+ temporary: {
14
+ index: 'created_at',
15
+ expireAfterSeconds: 3600,
16
+ },
17
+ properties: {
18
+ created_at: {
19
+ type: 'string',
20
+ format: 'date-time',
21
+ },
22
+ absolute_path: {
23
+ type: 'string',
24
+ },
25
+ size: {
26
+ type: 'number',
27
+ },
28
+ mime: {
29
+ type: 'number',
30
+ },
31
+ collection: {
32
+ type: 'string',
33
+ },
34
+ filename: {
35
+ type: 'string',
36
+ },
37
+ },
38
+ },
39
+ });
40
+ exports.file = (0, api_1.defineCollection)({
41
+ description: description_js_1.description,
42
+ functions: {
43
+ get: api_1.get,
44
+ insert: insert_js_1.insert,
45
+ download: download_js_1.download,
46
+ remove: remove_js_1.remove,
47
+ removeAll: removeAll_js_1.removeAll,
48
+ },
49
+ });
@@ -0,0 +1,46 @@
1
+ import { defineCollection, get } from "@aeriajs/api";
2
+ import { description } from "./description.mjs";
3
+ import { insert } from "./insert.mjs";
4
+ import { download } from "./download.mjs";
5
+ import { remove } from "./remove.mjs";
6
+ import { removeAll } from "./removeAll.mjs";
7
+ export var tempFile = defineCollection({
8
+ description: {
9
+ $id: "tempFile",
10
+ temporary: {
11
+ index: "created_at",
12
+ expireAfterSeconds: 3600
13
+ },
14
+ properties: {
15
+ created_at: {
16
+ type: "string",
17
+ format: "date-time"
18
+ },
19
+ absolute_path: {
20
+ type: "string"
21
+ },
22
+ size: {
23
+ type: "number"
24
+ },
25
+ mime: {
26
+ type: "number"
27
+ },
28
+ collection: {
29
+ type: "string"
30
+ },
31
+ filename: {
32
+ type: "string"
33
+ }
34
+ }
35
+ }
36
+ });
37
+ export var file = defineCollection({
38
+ description: description,
39
+ functions: {
40
+ get: get,
41
+ insert: insert,
42
+ download: download,
43
+ remove: remove,
44
+ removeAll: removeAll
45
+ }
46
+ });
@@ -0,0 +1,7 @@
1
+ import type { Context, SchemaWithId, PackReferences } from '@aeriajs/types';
2
+ import type { description } from './description.js';
3
+ export declare const insert: (payload: {
4
+ what: {
5
+ content: string;
6
+ } & Pick<PackReferences<SchemaWithId<typeof description>>, '_id' | 'filename' | 'owner' | 'absolute_path'>;
7
+ }, context: Context<typeof description>) => Promise<import("@aeriajs/types").Right<any> | import("@aeriajs/types").Left<import("@aeriajs/types").ACErrors | import("@aeriajs/types").ValidationError>>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insert = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const promises_1 = require("fs/promises");
6
+ const api_1 = require("@aeriajs/api");
7
+ const insert = async (payload, context) => {
8
+ if (!context.token.authenticated) {
9
+ throw new Error('');
10
+ }
11
+ const what = Object.assign({}, payload.what);
12
+ what.owner = context.token.sub;
13
+ const extension = what.filename.split('.').pop();
14
+ if (!context.config.storage) {
15
+ throw new Error('config.storage is not set');
16
+ }
17
+ const tempPath = context.config.storage.tempFs || context.config.storage.fs;
18
+ if (!tempPath) {
19
+ throw new Error('config.storage.fs and config.storage.tempFs are not set');
20
+ }
21
+ if (!extension) {
22
+ throw new Error('filename lacks extension');
23
+ }
24
+ const oldFile = await context.collection.model.findOne({
25
+ _id: payload.what._id,
26
+ }, {
27
+ projection: {
28
+ absolute_path: 1,
29
+ },
30
+ });
31
+ if (oldFile && oldFile.absolute_path) {
32
+ await (0, promises_1.unlink)(oldFile.absolute_path).catch(console.trace);
33
+ }
34
+ const filenameHash = (0, crypto_1.createHash)('sha1')
35
+ .update(what.filename + Date.now())
36
+ .digest('hex');
37
+ what.absolute_path = `${tempPath}/${filenameHash}.${extension}`;
38
+ await (0, promises_1.writeFile)(what.absolute_path, Buffer.from(what.content.split(',').pop(), 'base64'));
39
+ return (0, api_1.insert)({
40
+ ...payload,
41
+ what,
42
+ }, context);
43
+ };
44
+ exports.insert = insert;
@@ -0,0 +1,246 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _object_spread_props(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ function _ts_generator(thisArg, body) {
83
+ var f, y, t, g, _ = {
84
+ label: 0,
85
+ sent: function() {
86
+ if (t[0] & 1) throw t[1];
87
+ return t[1];
88
+ },
89
+ trys: [],
90
+ ops: []
91
+ };
92
+ return g = {
93
+ next: verb(0),
94
+ "throw": verb(1),
95
+ "return": verb(2)
96
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
97
+ return this;
98
+ }), g;
99
+ function verb(n) {
100
+ return function(v) {
101
+ return step([
102
+ n,
103
+ v
104
+ ]);
105
+ };
106
+ }
107
+ function step(op) {
108
+ if (f) throw new TypeError("Generator is already executing.");
109
+ while(_)try {
110
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
111
+ if (y = 0, t) op = [
112
+ op[0] & 2,
113
+ t.value
114
+ ];
115
+ switch(op[0]){
116
+ case 0:
117
+ case 1:
118
+ t = op;
119
+ break;
120
+ case 4:
121
+ _.label++;
122
+ return {
123
+ value: op[1],
124
+ done: false
125
+ };
126
+ case 5:
127
+ _.label++;
128
+ y = op[1];
129
+ op = [
130
+ 0
131
+ ];
132
+ continue;
133
+ case 7:
134
+ op = _.ops.pop();
135
+ _.trys.pop();
136
+ continue;
137
+ default:
138
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
139
+ _ = 0;
140
+ continue;
141
+ }
142
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
143
+ _.label = op[1];
144
+ break;
145
+ }
146
+ if (op[0] === 6 && _.label < t[1]) {
147
+ _.label = t[1];
148
+ t = op;
149
+ break;
150
+ }
151
+ if (t && _.label < t[2]) {
152
+ _.label = t[2];
153
+ _.ops.push(op);
154
+ break;
155
+ }
156
+ if (t[2]) _.ops.pop();
157
+ _.trys.pop();
158
+ continue;
159
+ }
160
+ op = body.call(thisArg, _);
161
+ } catch (e) {
162
+ op = [
163
+ 6,
164
+ e
165
+ ];
166
+ y = 0;
167
+ } finally{
168
+ f = t = 0;
169
+ }
170
+ if (op[0] & 5) throw op[1];
171
+ return {
172
+ value: op[0] ? op[1] : void 0,
173
+ done: true
174
+ };
175
+ }
176
+ }
177
+ import { createHash } from "crypto";
178
+ import { writeFile, unlink } from "fs/promises";
179
+ import { insert as originalInsert } from "@aeriajs/api";
180
+ export var insert = function() {
181
+ var _ref = _async_to_generator(function(payload, context) {
182
+ var what, extension, tempPath, oldFile, filenameHash;
183
+ return _ts_generator(this, function(_state) {
184
+ switch(_state.label){
185
+ case 0:
186
+ if (!context.token.authenticated) {
187
+ throw new Error("");
188
+ }
189
+ what = Object.assign({}, payload.what);
190
+ what.owner = context.token.sub;
191
+ extension = what.filename.split(".").pop();
192
+ if (!context.config.storage) {
193
+ throw new Error("config.storage is not set");
194
+ }
195
+ tempPath = context.config.storage.tempFs || context.config.storage.fs;
196
+ if (!tempPath) {
197
+ throw new Error("config.storage.fs and config.storage.tempFs are not set");
198
+ }
199
+ if (!extension) {
200
+ throw new Error("filename lacks extension");
201
+ }
202
+ return [
203
+ 4,
204
+ context.collection.model.findOne({
205
+ _id: payload.what._id
206
+ }, {
207
+ projection: {
208
+ absolute_path: 1
209
+ }
210
+ })
211
+ ];
212
+ case 1:
213
+ oldFile = _state.sent();
214
+ if (!(oldFile && oldFile.absolute_path)) return [
215
+ 3,
216
+ 3
217
+ ];
218
+ return [
219
+ 4,
220
+ unlink(oldFile.absolute_path).catch(console.trace)
221
+ ];
222
+ case 2:
223
+ _state.sent();
224
+ _state.label = 3;
225
+ case 3:
226
+ filenameHash = createHash("sha1").update(what.filename + Date.now()).digest("hex");
227
+ what.absolute_path = "".concat(tempPath, "/").concat(filenameHash, ".").concat(extension);
228
+ return [
229
+ 4,
230
+ writeFile(what.absolute_path, Buffer.from(what.content.split(",").pop(), "base64"))
231
+ ];
232
+ case 4:
233
+ _state.sent();
234
+ return [
235
+ 2,
236
+ originalInsert(_object_spread_props(_object_spread({}, payload), {
237
+ what: what
238
+ }), context)
239
+ ];
240
+ }
241
+ });
242
+ });
243
+ return function insert(payload, context) {
244
+ return _ref.apply(this, arguments);
245
+ };
246
+ }();
@@ -0,0 +1,3 @@
1
+ import type { Context, SchemaWithId, RemovePayload } from '@aeriajs/types';
2
+ import type { description } from './description.js';
3
+ export declare const remove: (payload: RemovePayload<SchemaWithId<typeof description>>, context: Context<typeof description>) => Promise<any>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.remove = void 0;
7
+ const api_1 = require("@aeriajs/api");
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const remove = async (payload, context) => {
10
+ const file = await context.collection.model.findOne({
11
+ _id: payload.filters._id,
12
+ }, {
13
+ projection: {
14
+ absolute_path: 1,
15
+ },
16
+ });
17
+ if (!file) {
18
+ throw new Error('');
19
+ }
20
+ try {
21
+ await promises_1.default.unlink(file.absolute_path);
22
+ }
23
+ catch (err) {
24
+ console.trace(err);
25
+ }
26
+ return (0, api_1.remove)(payload, context);
27
+ };
28
+ exports.remove = remove;
@@ -0,0 +1,184 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _ts_generator(thisArg, body) {
31
+ var f, y, t, g, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ };
40
+ return g = {
41
+ next: verb(0),
42
+ "throw": verb(1),
43
+ "return": verb(2)
44
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
+ return this;
46
+ }), g;
47
+ function verb(n) {
48
+ return function(v) {
49
+ return step([
50
+ n,
51
+ v
52
+ ]);
53
+ };
54
+ }
55
+ function step(op) {
56
+ if (f) throw new TypeError("Generator is already executing.");
57
+ while(_)try {
58
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
+ if (y = 0, t) op = [
60
+ op[0] & 2,
61
+ t.value
62
+ ];
63
+ switch(op[0]){
64
+ case 0:
65
+ case 1:
66
+ t = op;
67
+ break;
68
+ case 4:
69
+ _.label++;
70
+ return {
71
+ value: op[1],
72
+ done: false
73
+ };
74
+ case 5:
75
+ _.label++;
76
+ y = op[1];
77
+ op = [
78
+ 0
79
+ ];
80
+ continue;
81
+ case 7:
82
+ op = _.ops.pop();
83
+ _.trys.pop();
84
+ continue;
85
+ default:
86
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
+ _ = 0;
88
+ continue;
89
+ }
90
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
+ _.label = op[1];
92
+ break;
93
+ }
94
+ if (op[0] === 6 && _.label < t[1]) {
95
+ _.label = t[1];
96
+ t = op;
97
+ break;
98
+ }
99
+ if (t && _.label < t[2]) {
100
+ _.label = t[2];
101
+ _.ops.push(op);
102
+ break;
103
+ }
104
+ if (t[2]) _.ops.pop();
105
+ _.trys.pop();
106
+ continue;
107
+ }
108
+ op = body.call(thisArg, _);
109
+ } catch (e) {
110
+ op = [
111
+ 6,
112
+ e
113
+ ];
114
+ y = 0;
115
+ } finally{
116
+ f = t = 0;
117
+ }
118
+ if (op[0] & 5) throw op[1];
119
+ return {
120
+ value: op[0] ? op[1] : void 0,
121
+ done: true
122
+ };
123
+ }
124
+ }
125
+ import { remove as originalRemove } from "@aeriajs/api";
126
+ import fs from "fs/promises";
127
+ export var remove = function() {
128
+ var _ref = _async_to_generator(function(payload, context) {
129
+ var file, err;
130
+ return _ts_generator(this, function(_state) {
131
+ switch(_state.label){
132
+ case 0:
133
+ return [
134
+ 4,
135
+ context.collection.model.findOne({
136
+ _id: payload.filters._id
137
+ }, {
138
+ projection: {
139
+ absolute_path: 1
140
+ }
141
+ })
142
+ ];
143
+ case 1:
144
+ file = _state.sent();
145
+ if (!file) {
146
+ throw new Error("");
147
+ }
148
+ _state.label = 2;
149
+ case 2:
150
+ _state.trys.push([
151
+ 2,
152
+ 4,
153
+ ,
154
+ 5
155
+ ]);
156
+ return [
157
+ 4,
158
+ fs.unlink(file.absolute_path)
159
+ ];
160
+ case 3:
161
+ _state.sent();
162
+ return [
163
+ 3,
164
+ 5
165
+ ];
166
+ case 4:
167
+ err = _state.sent();
168
+ console.trace(err);
169
+ return [
170
+ 3,
171
+ 5
172
+ ];
173
+ case 5:
174
+ return [
175
+ 2,
176
+ originalRemove(payload, context)
177
+ ];
178
+ }
179
+ });
180
+ });
181
+ return function remove(payload, context) {
182
+ return _ref.apply(this, arguments);
183
+ };
184
+ }();
@@ -0,0 +1,3 @@
1
+ import type { Context, RemoveAllPayload } from '@aeriajs/types';
2
+ import type { description } from './description.js';
3
+ export declare const removeAll: (payload: RemoveAllPayload, context: Context<typeof description>) => Promise<any>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.removeAll = void 0;
7
+ const api_1 = require("@aeriajs/api");
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const removeAll = async (payload, context) => {
10
+ const files = context.collection.model.find({
11
+ _id: {
12
+ $in: payload.filters,
13
+ },
14
+ }, {
15
+ projection: {
16
+ absolute_path: 1,
17
+ },
18
+ });
19
+ let file;
20
+ while (file = await files.next()) {
21
+ try {
22
+ await promises_1.default.unlink(file.absolute_path);
23
+ }
24
+ catch (err) {
25
+ console.trace(err);
26
+ }
27
+ }
28
+ return (0, api_1.removeAll)(payload, context);
29
+ };
30
+ exports.removeAll = removeAll;