@payloadcms/plugin-cloud-storage 1.0.14 → 1.0.15
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/.editorconfig +10 -0
- package/.eslintrc.js +14 -14
- package/.gitignore +248 -0
- package/.idea/.gitignore +5 -0
- package/.idea/httpRequests/2023-04-07T152957.206.png +0 -0
- package/.idea/httpRequests/2023-04-07T153025.403.html +10 -0
- package/.idea/httpRequests/2023-04-07T153146.200.png +0 -0
- package/.idea/httpRequests/http-client.cookies +1 -0
- package/.idea/httpRequests/http-requests-log.http +74 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/plugin-cloud-storage.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +269 -0
- package/.prettierignore +1 -0
- package/.prettierrc.js +8 -0
- package/.vscode/launch.json +28 -0
- package/.vscode/settings.json +9 -0
- package/LICENSE.md +22 -22
- package/README.md +178 -174
- package/azure.d.ts +1 -1
- package/azure.js +1 -1
- package/dev/.env +25 -0
- package/dev/.env.example +21 -0
- package/dev/build/127.d2c2ffcfff69fabfdd1b.js +1 -0
- package/dev/build/16.17dbe03b1d0a96f3e564.js +2 -0
- package/dev/build/16.17dbe03b1d0a96f3e564.js.LICENSE.txt +8 -0
- package/dev/build/171.bbcbae3ea90468ad0cad.js +2 -0
- package/dev/build/171.bbcbae3ea90468ad0cad.js.LICENSE.txt +8 -0
- package/dev/build/18.e50c27edff6716f930d9.js +1 -0
- package/dev/build/205.33c7a29683ba98de93e0.js +1 -0
- package/dev/build/2211c49456cd07331ea9.woff +0 -0
- package/dev/build/234.79395f82c18207c13766.js +1 -0
- package/dev/build/266.9d4a240b3e0985bd7dd5.js +1 -0
- package/dev/build/296.4c5d646257b42c915834.js +1 -0
- package/dev/build/304.40dbe690de322c8f7c0d.js +2 -0
- package/dev/build/304.40dbe690de322c8f7c0d.js.LICENSE.txt +37 -0
- package/dev/build/349.446c12bffd3905085fdb.js +1 -0
- package/dev/build/354.5acd04b85b96a9839125.js +1 -0
- package/dev/build/40ad7515b8674bb854a1.woff2 +0 -0
- package/dev/build/422.086542466cdc9f6a2437.js +2 -0
- package/dev/build/422.086542466cdc9f6a2437.js.LICENSE.txt +6 -0
- package/dev/build/491.0bfe1bb0ecfe383179aa.js +1 -0
- package/dev/build/4d8845b830f4e8e2affb.png +0 -0
- package/dev/build/51922ceb71da289688d3.woff2 +0 -0
- package/dev/build/522443364fda49e9e0ed.woff2 +0 -0
- package/dev/build/531.1c6f53f3b44a3c45b444.js +2 -0
- package/dev/build/531.1c6f53f3b44a3c45b444.js.LICENSE.txt +6 -0
- package/dev/build/570.f2d9b99706765fbf0225.js +1 -0
- package/dev/build/599.570a04990d5806004f61.js +1 -0
- package/dev/build/5b718d9772de251a8c0a.woff2 +0 -0
- package/dev/build/778.41ae26bcd617861ad586.js +1 -0
- package/dev/build/783.0117995f2ff6036d6746.js +1 -0
- package/dev/build/787999a6af6a17efbc7c.woff +0 -0
- package/dev/build/78b8935fb481e11c92ce.woff +0 -0
- package/dev/build/860.7688681d3269f3f16e9a.js +1 -0
- package/dev/build/892.1a4ca5ac67d81038ceec.js +1 -0
- package/dev/build/896.d8cb1160388dc29d6364.js +1 -0
- package/dev/build/8b4ddd0d08500553efde.woff +0 -0
- package/dev/build/8f612153248094525d9d.woff +0 -0
- package/dev/build/995.cc11e738ff81a85821b4.js +1 -0
- package/dev/build/9c7dfd0036f7bd24b053.woff2 +0 -0
- package/dev/build/a1cfdc5b5250b7c4b481.woff2 +0 -0
- package/dev/build/d7aeda9e48ce098e7b48.woff +0 -0
- package/dev/build/e009f21405b4d7e89367.woff2 +0 -0
- package/dev/build/e7caa9e17af6ac87d182.woff +0 -0
- package/dev/build/ebcc1430049fddb274f8.svg +15 -0
- package/dev/build/efe8f6a3b46446cc9135.woff +0 -0
- package/dev/build/f53bb8d4b29adc903703.woff2 +0 -0
- package/dev/build/index.html +1 -0
- package/dev/build/main.a2003d502fbb9aaa3e8d.js +2 -0
- package/dev/build/main.a2003d502fbb9aaa3e8d.js.LICENSE.txt +57 -0
- package/dev/build/styles.css +1 -0
- package/dev/build/styles.fa29d16b0baf5b98a1cf.js +1 -0
- package/dev/nodemon.json +8 -0
- package/dev/package.json +32 -0
- package/dev/src/collections/Media.ts +56 -0
- package/dev/src/collections/Users.ts +23 -0
- package/dev/src/mocks/fsMock.js +1 -0
- package/dev/src/mocks/promisifyMock.js +1 -0
- package/dev/src/payload.config.ts +111 -0
- package/dev/src/server.ts +26 -0
- package/dev/tsconfig.json +20 -0
- package/dist/adapters/azure/fileStub.d.ts +2 -0
- package/dist/adapters/azure/fileStub.js +4 -0
- package/dist/adapters/azure/fileStub.js.map +1 -0
- package/dist/adapters/azure/generateURL.d.ts +7 -7
- package/dist/adapters/azure/generateURL.js +15 -15
- package/dist/adapters/azure/handleDelete.d.ts +9 -9
- package/dist/adapters/azure/handleDelete.js +63 -63
- package/dist/adapters/azure/handleUpload.d.ts +10 -10
- package/dist/adapters/azure/handleUpload.js +80 -65
- package/dist/adapters/azure/handleUpload.js.map +1 -1
- package/dist/adapters/azure/index.d.ts +8 -8
- package/dist/adapters/azure/index.js +42 -42
- package/dist/adapters/azure/mock.d.ts +13 -7
- package/dist/adapters/azure/mock.js +12 -8
- package/dist/adapters/azure/mock.js.map +1 -1
- package/dist/adapters/azure/staticHandler.d.ts +9 -9
- package/dist/adapters/azure/staticHandler.js +81 -77
- package/dist/adapters/azure/staticHandler.js.map +1 -1
- package/dist/adapters/azure/webpack.d.ts +2 -2
- package/dist/adapters/azure/webpack.js +24 -24
- package/dist/adapters/azure/webpack.js.map +1 -1
- package/dist/adapters/gcs/generateURL.d.ts +8 -8
- package/dist/adapters/gcs/generateURL.js +15 -15
- package/dist/adapters/gcs/handleDelete.d.ts +8 -8
- package/dist/adapters/gcs/handleDelete.js +62 -62
- package/dist/adapters/gcs/handleUpload.d.ts +12 -12
- package/dist/adapters/gcs/handleUpload.js +72 -72
- package/dist/adapters/gcs/index.d.ts +8 -8
- package/dist/adapters/gcs/index.js +35 -35
- package/dist/adapters/gcs/mock.d.ts +1 -1
- package/dist/adapters/gcs/mock.js +4 -4
- package/dist/adapters/gcs/staticHandler.d.ts +10 -10
- package/dist/adapters/gcs/staticHandler.js +76 -76
- package/dist/adapters/gcs/webpack.d.ts +2 -2
- package/dist/adapters/gcs/webpack.js +24 -24
- package/dist/adapters/s3/fileStub.d.ts +2 -2
- package/dist/adapters/s3/fileStub.js +3 -3
- package/dist/adapters/s3/generateURL.d.ts +8 -8
- package/dist/adapters/s3/generateURL.js +15 -15
- package/dist/adapters/s3/handleDelete.d.ts +8 -8
- package/dist/adapters/s3/handleDelete.js +63 -63
- package/dist/adapters/s3/handleUpload.d.ts +12 -12
- package/dist/adapters/s3/handleUpload.js +93 -93
- package/dist/adapters/s3/index.d.ts +8 -8
- package/dist/adapters/s3/index.js +59 -59
- package/dist/adapters/s3/mock.d.ts +8 -8
- package/dist/adapters/s3/mock.js +9 -9
- package/dist/adapters/s3/staticHandler.d.ts +10 -10
- package/dist/adapters/s3/staticHandler.js +80 -80
- package/dist/adapters/s3/webpack.d.ts +2 -2
- package/dist/adapters/s3/webpack.js +24 -24
- package/dist/fields/getFields.d.ts +11 -11
- package/dist/fields/getFields.js +118 -118
- package/dist/hooks/afterDelete.d.ts +10 -10
- package/dist/hooks/afterDelete.js +88 -88
- package/dist/hooks/afterRead.d.ts +12 -12
- package/dist/hooks/afterRead.js +79 -79
- package/dist/hooks/beforeChange.d.ts +10 -10
- package/dist/hooks/beforeChange.js +77 -77
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.js +124 -124
- package/dist/types.d.ts +62 -62
- package/dist/types.js +2 -2
- package/dist/utilities/getFilePrefix.d.ts +5 -5
- package/dist/utilities/getFilePrefix.js +80 -80
- package/dist/utilities/getIncomingFiles.d.ts +7 -7
- package/dist/utilities/getIncomingFiles.js +37 -37
- package/dist/utilities/getRangeFromHeader.d.ts +6 -0
- package/dist/utilities/getRangeFromHeader.js +67 -0
- package/dist/utilities/getRangeFromHeader.js.map +1 -0
- package/dist/webpack.d.ts +9 -9
- package/dist/webpack.js +39 -39
- package/docs/local-dev.md +47 -0
- package/eslint-config/index.js +15 -0
- package/eslint-config/rules/import.js +38 -0
- package/eslint-config/rules/prettier.js +7 -0
- package/eslint-config/rules/style.js +21 -0
- package/eslint-config/rules/typescript.js +628 -0
- package/gcs.d.ts +1 -1
- package/gcs.js +1 -1
- package/package.json +67 -64
- package/s3.d.ts +1 -1
- package/s3.js +1 -1
- package/src/adapters/azure/emulator/docker-compose.yml +16 -0
- package/src/adapters/azure/fileStub.js +1 -0
- package/src/adapters/azure/generateURL.ts +13 -0
- package/src/adapters/azure/handleDelete.ts +16 -0
- package/src/adapters/azure/handleUpload.ts +41 -0
- package/src/adapters/azure/index.ts +47 -0
- package/src/adapters/azure/mock.js +13 -0
- package/src/adapters/azure/staticHandler.ts +38 -0
- package/src/adapters/azure/webpack.ts +20 -0
- package/src/adapters/gcs/emulator/docker-compose.yml +15 -0
- package/src/adapters/gcs/generateURL.ts +16 -0
- package/src/adapters/gcs/handleDelete.ts +16 -0
- package/src/adapters/gcs/handleUpload.ts +34 -0
- package/src/adapters/gcs/index.ts +37 -0
- package/src/adapters/gcs/mock.js +3 -0
- package/src/adapters/gcs/staticHandler.ts +34 -0
- package/src/adapters/gcs/webpack.ts +17 -0
- package/src/adapters/s3/emulator/docker-compose.yml +15 -0
- package/src/adapters/s3/fileStub.js +1 -0
- package/src/adapters/s3/generateURL.ts +14 -0
- package/src/adapters/s3/handleDelete.ts +17 -0
- package/src/adapters/s3/handleUpload.ts +62 -0
- package/src/adapters/s3/index.ts +38 -0
- package/src/adapters/s3/mock.js +9 -0
- package/src/adapters/s3/staticHandler.ts +40 -0
- package/src/adapters/s3/webpack.ts +19 -0
- package/src/fields/getFields.ts +155 -0
- package/src/hooks/afterDelete.ts +35 -0
- package/src/hooks/afterRead.ts +38 -0
- package/src/hooks/beforeChange.ts +30 -0
- package/src/index.ts +1 -0
- package/src/plugin.ts +94 -0
- package/src/types.ts +73 -0
- package/src/utilities/getFilePrefix.ts +26 -0
- package/src/utilities/getIncomingFiles.ts +44 -0
- package/src/utilities/getRangeFromHeader.ts +27 -0
- package/src/webpack.ts +46 -0
- package/tsconfig.json +23 -0
- package/yarn.lock +8155 -0
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.getAfterDeleteHook = void 0;
|
|
49
|
-
var getAfterDeleteHook = function (_a) {
|
|
50
|
-
var collection = _a.collection, adapter = _a.adapter;
|
|
51
|
-
return function (_a) {
|
|
52
|
-
var req = _a.req, doc = _a.doc;
|
|
53
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var filesToDelete, promises, err_1;
|
|
55
|
-
var _b;
|
|
56
|
-
return __generator(this, function (_c) {
|
|
57
|
-
switch (_c.label) {
|
|
58
|
-
case 0:
|
|
59
|
-
_c.trys.push([0, 2, , 3]);
|
|
60
|
-
filesToDelete = __spreadArray([
|
|
61
|
-
doc.filename
|
|
62
|
-
], Object.values((doc === null || doc === void 0 ? void 0 : doc.sizes) || []).map(function (resizedFileData) { return resizedFileData === null || resizedFileData === void 0 ? void 0 : resizedFileData.filename; }), true);
|
|
63
|
-
promises = filesToDelete.map(function (filename) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
switch (_a.label) {
|
|
66
|
-
case 0: return [4 /*yield*/, adapter.handleDelete({ collection: collection, doc: doc, req: req, filename: filename })];
|
|
67
|
-
case 1:
|
|
68
|
-
_a.sent();
|
|
69
|
-
return [2 /*return*/];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}); });
|
|
73
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
74
|
-
case 1:
|
|
75
|
-
_c.sent();
|
|
76
|
-
return [3 /*break*/, 3];
|
|
77
|
-
case 2:
|
|
78
|
-
err_1 = _c.sent();
|
|
79
|
-
req.payload.logger.error("There was an error while deleting files corresponding to the ".concat((_b = collection.labels) === null || _b === void 0 ? void 0 : _b.singular, " with ID ").concat(doc.id, ":"));
|
|
80
|
-
req.payload.logger.error(err_1);
|
|
81
|
-
return [3 /*break*/, 3];
|
|
82
|
-
case 3: return [2 /*return*/, doc];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
exports.getAfterDeleteHook = getAfterDeleteHook;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.getAfterDeleteHook = void 0;
|
|
49
|
+
var getAfterDeleteHook = function (_a) {
|
|
50
|
+
var collection = _a.collection, adapter = _a.adapter;
|
|
51
|
+
return function (_a) {
|
|
52
|
+
var req = _a.req, doc = _a.doc;
|
|
53
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var filesToDelete, promises, err_1;
|
|
55
|
+
var _b;
|
|
56
|
+
return __generator(this, function (_c) {
|
|
57
|
+
switch (_c.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
_c.trys.push([0, 2, , 3]);
|
|
60
|
+
filesToDelete = __spreadArray([
|
|
61
|
+
doc.filename
|
|
62
|
+
], Object.values((doc === null || doc === void 0 ? void 0 : doc.sizes) || []).map(function (resizedFileData) { return resizedFileData === null || resizedFileData === void 0 ? void 0 : resizedFileData.filename; }), true);
|
|
63
|
+
promises = filesToDelete.map(function (filename) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, adapter.handleDelete({ collection: collection, doc: doc, req: req, filename: filename })];
|
|
67
|
+
case 1:
|
|
68
|
+
_a.sent();
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}); });
|
|
73
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
74
|
+
case 1:
|
|
75
|
+
_c.sent();
|
|
76
|
+
return [3 /*break*/, 3];
|
|
77
|
+
case 2:
|
|
78
|
+
err_1 = _c.sent();
|
|
79
|
+
req.payload.logger.error("There was an error while deleting files corresponding to the ".concat((_b = collection.labels) === null || _b === void 0 ? void 0 : _b.singular, " with ID ").concat(doc.id, ":"));
|
|
80
|
+
req.payload.logger.error(err_1);
|
|
81
|
+
return [3 /*break*/, 3];
|
|
82
|
+
case 3: return [2 /*return*/, doc];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
exports.getAfterDeleteHook = getAfterDeleteHook;
|
|
89
89
|
//# sourceMappingURL=afterDelete.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ImageSize } from 'payload/dist/uploads/types';
|
|
2
|
-
import type { CollectionConfig, FieldHook } from 'payload/types';
|
|
3
|
-
import type { GeneratedAdapter, GenerateFileURL } from '../types';
|
|
4
|
-
interface Args {
|
|
5
|
-
collection: CollectionConfig;
|
|
6
|
-
adapter: GeneratedAdapter;
|
|
7
|
-
disablePayloadAccessControl?: boolean;
|
|
8
|
-
size?: ImageSize;
|
|
9
|
-
generateFileURL?: GenerateFileURL;
|
|
10
|
-
}
|
|
11
|
-
export declare const getAfterReadHook: ({ collection, adapter, size, disablePayloadAccessControl, generateFileURL }: Args) => FieldHook;
|
|
12
|
-
export {};
|
|
1
|
+
import type { ImageSize } from 'payload/dist/uploads/types';
|
|
2
|
+
import type { CollectionConfig, FieldHook } from 'payload/types';
|
|
3
|
+
import type { GeneratedAdapter, GenerateFileURL } from '../types';
|
|
4
|
+
interface Args {
|
|
5
|
+
collection: CollectionConfig;
|
|
6
|
+
adapter: GeneratedAdapter;
|
|
7
|
+
disablePayloadAccessControl?: boolean;
|
|
8
|
+
size?: ImageSize;
|
|
9
|
+
generateFileURL?: GenerateFileURL;
|
|
10
|
+
}
|
|
11
|
+
export declare const getAfterReadHook: ({ collection, adapter, size, disablePayloadAccessControl, generateFileURL }: Args) => FieldHook;
|
|
12
|
+
export {};
|
package/dist/hooks/afterRead.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getAfterReadHook = void 0;
|
|
40
|
-
var getAfterReadHook = function (_a) {
|
|
41
|
-
var collection = _a.collection, adapter = _a.adapter, size = _a.size, disablePayloadAccessControl = _a.disablePayloadAccessControl, generateFileURL = _a.generateFileURL;
|
|
42
|
-
return function (_a) {
|
|
43
|
-
var data = _a.data, value = _a.value;
|
|
44
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var filename, prefix, url;
|
|
46
|
-
var _b, _c;
|
|
47
|
-
return __generator(this, function (_d) {
|
|
48
|
-
switch (_d.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
filename = size ? (_c = (_b = data === null || data === void 0 ? void 0 : data.sizes) === null || _b === void 0 ? void 0 : _b[size.name]) === null || _c === void 0 ? void 0 : _c.filename : data === null || data === void 0 ? void 0 : data.filename;
|
|
51
|
-
prefix = data === null || data === void 0 ? void 0 : data.prefix;
|
|
52
|
-
url = value;
|
|
53
|
-
if (!(disablePayloadAccessControl && filename)) return [3 /*break*/, 2];
|
|
54
|
-
return [4 /*yield*/, adapter.generateURL({
|
|
55
|
-
collection: collection,
|
|
56
|
-
filename: filename,
|
|
57
|
-
prefix: prefix,
|
|
58
|
-
})];
|
|
59
|
-
case 1:
|
|
60
|
-
url = _d.sent();
|
|
61
|
-
_d.label = 2;
|
|
62
|
-
case 2:
|
|
63
|
-
if (!generateFileURL) return [3 /*break*/, 4];
|
|
64
|
-
return [4 /*yield*/, generateFileURL({
|
|
65
|
-
collection: collection,
|
|
66
|
-
filename: filename,
|
|
67
|
-
prefix: prefix,
|
|
68
|
-
size: size,
|
|
69
|
-
})];
|
|
70
|
-
case 3:
|
|
71
|
-
url = _d.sent();
|
|
72
|
-
_d.label = 4;
|
|
73
|
-
case 4: return [2 /*return*/, url];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.getAfterReadHook = getAfterReadHook;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getAfterReadHook = void 0;
|
|
40
|
+
var getAfterReadHook = function (_a) {
|
|
41
|
+
var collection = _a.collection, adapter = _a.adapter, size = _a.size, disablePayloadAccessControl = _a.disablePayloadAccessControl, generateFileURL = _a.generateFileURL;
|
|
42
|
+
return function (_a) {
|
|
43
|
+
var data = _a.data, value = _a.value;
|
|
44
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var filename, prefix, url;
|
|
46
|
+
var _b, _c;
|
|
47
|
+
return __generator(this, function (_d) {
|
|
48
|
+
switch (_d.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
filename = size ? (_c = (_b = data === null || data === void 0 ? void 0 : data.sizes) === null || _b === void 0 ? void 0 : _b[size.name]) === null || _c === void 0 ? void 0 : _c.filename : data === null || data === void 0 ? void 0 : data.filename;
|
|
51
|
+
prefix = data === null || data === void 0 ? void 0 : data.prefix;
|
|
52
|
+
url = value;
|
|
53
|
+
if (!(disablePayloadAccessControl && filename)) return [3 /*break*/, 2];
|
|
54
|
+
return [4 /*yield*/, adapter.generateURL({
|
|
55
|
+
collection: collection,
|
|
56
|
+
filename: filename,
|
|
57
|
+
prefix: prefix,
|
|
58
|
+
})];
|
|
59
|
+
case 1:
|
|
60
|
+
url = _d.sent();
|
|
61
|
+
_d.label = 2;
|
|
62
|
+
case 2:
|
|
63
|
+
if (!generateFileURL) return [3 /*break*/, 4];
|
|
64
|
+
return [4 /*yield*/, generateFileURL({
|
|
65
|
+
collection: collection,
|
|
66
|
+
filename: filename,
|
|
67
|
+
prefix: prefix,
|
|
68
|
+
size: size,
|
|
69
|
+
})];
|
|
70
|
+
case 3:
|
|
71
|
+
url = _d.sent();
|
|
72
|
+
_d.label = 4;
|
|
73
|
+
case 4: return [2 /*return*/, url];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.getAfterReadHook = getAfterReadHook;
|
|
80
80
|
//# sourceMappingURL=afterRead.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { TypeWithID } from 'payload/dist/collections/config/types';
|
|
2
|
-
import type { FileData } from 'payload/dist/uploads/types';
|
|
3
|
-
import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload/types';
|
|
4
|
-
import type { GeneratedAdapter } from '../types';
|
|
5
|
-
interface Args {
|
|
6
|
-
collection: CollectionConfig;
|
|
7
|
-
adapter: GeneratedAdapter;
|
|
8
|
-
}
|
|
9
|
-
export declare const getBeforeChangeHook: ({ collection, adapter }: Args) => CollectionBeforeChangeHook<FileData & TypeWithID>;
|
|
10
|
-
export {};
|
|
1
|
+
import type { TypeWithID } from 'payload/dist/collections/config/types';
|
|
2
|
+
import type { FileData } from 'payload/dist/uploads/types';
|
|
3
|
+
import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload/types';
|
|
4
|
+
import type { GeneratedAdapter } from '../types';
|
|
5
|
+
interface Args {
|
|
6
|
+
collection: CollectionConfig;
|
|
7
|
+
adapter: GeneratedAdapter;
|
|
8
|
+
}
|
|
9
|
+
export declare const getBeforeChangeHook: ({ collection, adapter }: Args) => CollectionBeforeChangeHook<FileData & TypeWithID>;
|
|
10
|
+
export {};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getBeforeChangeHook = void 0;
|
|
40
|
-
var getIncomingFiles_1 = require("../utilities/getIncomingFiles");
|
|
41
|
-
var getBeforeChangeHook = function (_a) {
|
|
42
|
-
var collection = _a.collection, adapter = _a.adapter;
|
|
43
|
-
return function (_a) {
|
|
44
|
-
var req = _a.req, data = _a.data;
|
|
45
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var files, promises, err_1;
|
|
47
|
-
return __generator(this, function (_b) {
|
|
48
|
-
switch (_b.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
_b.trys.push([0, 2, , 3]);
|
|
51
|
-
files = (0, getIncomingFiles_1.getIncomingFiles)({ req: req, data: data });
|
|
52
|
-
promises = files.map(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0: return [4 /*yield*/, adapter.handleUpload({ collection: collection, data: data, req: req, file: file })];
|
|
56
|
-
case 1:
|
|
57
|
-
_a.sent();
|
|
58
|
-
return [2 /*return*/];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}); });
|
|
62
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
63
|
-
case 1:
|
|
64
|
-
_b.sent();
|
|
65
|
-
return [3 /*break*/, 3];
|
|
66
|
-
case 2:
|
|
67
|
-
err_1 = _b.sent();
|
|
68
|
-
req.payload.logger.error("There was an error while uploading files corresponding to the collection ".concat(collection.slug, " with filename ").concat(data.filename, ":"));
|
|
69
|
-
req.payload.logger.error(err_1);
|
|
70
|
-
return [3 /*break*/, 3];
|
|
71
|
-
case 3: return [2 /*return*/, data];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
exports.getBeforeChangeHook = getBeforeChangeHook;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getBeforeChangeHook = void 0;
|
|
40
|
+
var getIncomingFiles_1 = require("../utilities/getIncomingFiles");
|
|
41
|
+
var getBeforeChangeHook = function (_a) {
|
|
42
|
+
var collection = _a.collection, adapter = _a.adapter;
|
|
43
|
+
return function (_a) {
|
|
44
|
+
var req = _a.req, data = _a.data;
|
|
45
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var files, promises, err_1;
|
|
47
|
+
return __generator(this, function (_b) {
|
|
48
|
+
switch (_b.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
_b.trys.push([0, 2, , 3]);
|
|
51
|
+
files = (0, getIncomingFiles_1.getIncomingFiles)({ req: req, data: data });
|
|
52
|
+
promises = files.map(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, adapter.handleUpload({ collection: collection, data: data, req: req, file: file })];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); });
|
|
62
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
63
|
+
case 1:
|
|
64
|
+
_b.sent();
|
|
65
|
+
return [3 /*break*/, 3];
|
|
66
|
+
case 2:
|
|
67
|
+
err_1 = _b.sent();
|
|
68
|
+
req.payload.logger.error("There was an error while uploading files corresponding to the collection ".concat(collection.slug, " with filename ").concat(data.filename, ":"));
|
|
69
|
+
req.payload.logger.error(err_1);
|
|
70
|
+
return [3 /*break*/, 3];
|
|
71
|
+
case 3: return [2 /*return*/, data];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.getBeforeChangeHook = getBeforeChangeHook;
|
|
78
78
|
//# sourceMappingURL=beforeChange.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cloudStorage } from './plugin';
|
|
1
|
+
export { cloudStorage } from './plugin';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloudStorage = void 0;
|
|
4
|
-
var plugin_1 = require("./plugin");
|
|
5
|
-
Object.defineProperty(exports, "cloudStorage", { enumerable: true, get: function () { return plugin_1.cloudStorage; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cloudStorage = void 0;
|
|
4
|
+
var plugin_1 = require("./plugin");
|
|
5
|
+
Object.defineProperty(exports, "cloudStorage", { enumerable: true, get: function () { return plugin_1.cloudStorage; } });
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Config } from 'payload/config';
|
|
2
|
-
import type { PluginOptions } from './types';
|
|
3
|
-
export declare const cloudStorage: (pluginOptions: PluginOptions) => (config: Config) => Config;
|
|
1
|
+
import type { Config } from 'payload/config';
|
|
2
|
+
import type { PluginOptions } from './types';
|
|
3
|
+
export declare const cloudStorage: (pluginOptions: PluginOptions) => (config: Config) => Config;
|