@payloadcms/plugin-cloud-storage 1.0.2 → 1.0.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/README.md +29 -6
- package/azure.js +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +1 -4
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/webpack.js +4 -6
- package/dist/webpack.js.map +1 -1
- package/gcs.d.ts +1 -0
- package/gcs.js +1 -0
- package/package.json +8 -2
- package/s3.js +1 -1
package/README.md
CHANGED
|
@@ -18,10 +18,11 @@ import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
|
|
|
18
18
|
export default buildConfig({
|
|
19
19
|
plugins: [
|
|
20
20
|
cloudStorage({
|
|
21
|
-
collections:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
collections: {
|
|
22
|
+
'my-collection-slug': {
|
|
23
|
+
adapter: theAdapterToUse, // see docs for the adapter you want to use
|
|
24
|
+
},
|
|
25
|
+
},
|
|
25
26
|
}),
|
|
26
27
|
],
|
|
27
28
|
// The rest of your config goes here
|
|
@@ -36,6 +37,7 @@ This plugin supports the following adapters:
|
|
|
36
37
|
|
|
37
38
|
- [Azure Blob Storage](#azure-blob-storage-adapter)
|
|
38
39
|
- [AWS S3-style Storage](#s3-adapter)
|
|
40
|
+
- [Google Cloud Storage](#gcs-adapter)
|
|
39
41
|
|
|
40
42
|
However, you can create your own adapter for any third-party service you would like to use.
|
|
41
43
|
|
|
@@ -45,13 +47,12 @@ This plugin is configurable to work across many different Payload collections. A
|
|
|
45
47
|
|
|
46
48
|
| Option | Description |
|
|
47
49
|
| ----------------------- | ----------- |
|
|
48
|
-
| `collections` * |
|
|
50
|
+
| `collections` * | Object with keys set to the slug of collections you want to enable the plugin for, and values set to collection-specific options. |
|
|
49
51
|
|
|
50
52
|
**Collection-specific options:**
|
|
51
53
|
|
|
52
54
|
| Option | Description |
|
|
53
55
|
|------------------------------|---------------------------------|
|
|
54
|
-
| `slug` * | The collection slug to extend. |
|
|
55
56
|
| `adapter` * | Pass in the adapter that you'd like to use for this collection. |
|
|
56
57
|
| `disableLocalStorage` | Choose to disable local storage on this collection. Defaults to `true`. |
|
|
57
58
|
| `disablePayloadAccessControl` | Set to `true` to disable Payload's access control. [More](#payload-access-control) |
|
|
@@ -98,6 +99,28 @@ const adapter = s3Adapter({
|
|
|
98
99
|
// Now you can pass this adapter to the plugin
|
|
99
100
|
```
|
|
100
101
|
|
|
102
|
+
### GCS Adapter
|
|
103
|
+
|
|
104
|
+
To use the GCS adapter, you need to have `@google-cloud/storage` installed in your project dependencies. To do so, run `yarn add @google-storage/cloud`.
|
|
105
|
+
|
|
106
|
+
From there, create the adapter, passing in all of its required properties:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs';
|
|
110
|
+
|
|
111
|
+
const adapter = gcsAdapter({
|
|
112
|
+
options: {
|
|
113
|
+
// you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
|
|
114
|
+
keyFilename: './gcs-credentials.json',
|
|
115
|
+
//OR
|
|
116
|
+
credentials: JSON.parse(process.env.GCS_CREDENTIALS) // this env variable will have stringify version of your credentials.json file
|
|
117
|
+
},
|
|
118
|
+
bucket: process.env.GCS_BUCKET,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// Now you can pass this adapter to the plugin
|
|
122
|
+
```
|
|
123
|
+
|
|
101
124
|
### Payload Access Control
|
|
102
125
|
|
|
103
126
|
Payload ships with access control that runs _even on statically served files_. The same `read` access control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
|
package/azure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
exports.azureBlobStorageAdapter = require('./dist/adapters/azure')
|
|
1
|
+
exports.azureBlobStorageAdapter = require('./dist/adapters/azure').azureBlobStorageAdapter
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.cloudStorage = void 0;
|
|
4
4
|
var plugin_1 = require("./plugin");
|
|
5
5
|
Object.defineProperty(exports, "cloudStorage", { enumerable: true, get: function () { return plugin_1.cloudStorage; } });
|
|
6
|
-
var azure_1 = require("./adapters/azure");
|
|
7
|
-
Object.defineProperty(exports, "azureBlobStorageAdapter", { enumerable: true, get: function () { return azure_1.azureBlobStorageAdapter; } });
|
|
8
|
-
var s3_1 = require("./adapters/s3");
|
|
9
|
-
Object.defineProperty(exports, "s3Adapter", { enumerable: true, get: function () { return s3_1.s3Adapter; } });
|
|
10
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAA9B,sGAAA,YAAY,OAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAA9B,sGAAA,YAAY,OAAA"}
|
package/dist/plugin.js
CHANGED
|
@@ -39,10 +39,7 @@ var cloudStorage = function (pluginOptions) {
|
|
|
39
39
|
webpack: webpack,
|
|
40
40
|
}, collections: (config.collections || []).map(function (existingCollection) {
|
|
41
41
|
var _a, _b;
|
|
42
|
-
var options = allCollectionOptions.
|
|
43
|
-
var slug = _a.slug;
|
|
44
|
-
return slug === existingCollection.slug;
|
|
45
|
-
});
|
|
42
|
+
var options = allCollectionOptions[existingCollection.slug];
|
|
46
43
|
if (options) {
|
|
47
44
|
var adapter = options.adapter({ collection: existingCollection });
|
|
48
45
|
var fields = (0, getFields_1.getFields)({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,qCAA+C;AAE/C,qDAA0D;AAC1D,mDAAwD;AACxD,gDAA8C;AAE9C,4EAA4E;AAC5E,4DAA4D;AAE5D,4FAA4F;AAC5F,kFAAkF;AAClF,mDAAmD;AAEnD,0FAA0F;AAEnF,IAAM,YAAY,GACvB,UAAC,aAA4B;IAC7B,OAAA,UAAC,MAAc;QACL,IAAa,oBAAoB,GAAK,aAAa,YAAlB,CAAkB;QAE3D,IAAM,OAAO,GAAG,IAAA,6BAAmB,EAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAA,EAAE,CAAC,CAAA;QAEvE,6BACK,MAAM,KACT,KAAK,EAAE;gBACL,OAAO,SAAA;aACR,EACD,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAA,kBAAkB;;gBAC5D,IAAM,OAAO,GAAG,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,qCAA+C;AAE/C,qDAA0D;AAC1D,mDAAwD;AACxD,gDAA8C;AAE9C,4EAA4E;AAC5E,4DAA4D;AAE5D,4FAA4F;AAC5F,kFAAkF;AAClF,mDAAmD;AAEnD,0FAA0F;AAEnF,IAAM,YAAY,GACvB,UAAC,aAA4B;IAC7B,OAAA,UAAC,MAAc;QACL,IAAa,oBAAoB,GAAK,aAAa,YAAlB,CAAkB;QAE3D,IAAM,OAAO,GAAG,IAAA,6BAAmB,EAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAA,EAAE,CAAC,CAAA;QAEvE,6BACK,MAAM,KACT,KAAK,EAAE;gBACL,OAAO,SAAA;aACR,EACD,WAAW,EAAE,CAAC,MAAM,CAAC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AC,EAAE,OAAO,SAAA,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;uCAElE,WAAW,kCACN,CAAC,CAAA,MAAA,kBAAkB,CAAC,KAAK,0CAAE,WAAW,KAAI,EAAE,CAAC;gCAChD,IAAA,gCAAkB,EAAC,EAAE,OAAO,SAAA,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;0CAGnE,MAAM,QAAA,IACP;iBACF;gBAED,OAAO,kBAAkB,CAAA;YAC3B,CAAC,CAAC,IACH;IACH,CAAC;AA7DD,CA6DC,CAAA;AA/DU,QAAA,YAAY,gBA+DtB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -37,11 +37,10 @@ export declare type Adapter = (args: {
|
|
|
37
37
|
collection: CollectionConfig;
|
|
38
38
|
}) => GeneratedAdapter;
|
|
39
39
|
export interface CollectionOptions {
|
|
40
|
-
slug: string;
|
|
41
40
|
disableLocalStorage?: boolean;
|
|
42
41
|
disablePayloadAccessControl?: true;
|
|
43
42
|
adapter: Adapter;
|
|
44
43
|
}
|
|
45
44
|
export interface PluginOptions {
|
|
46
|
-
collections: CollectionOptions
|
|
45
|
+
collections: Record<string, CollectionOptions>;
|
|
47
46
|
}
|
package/dist/webpack.js
CHANGED
|
@@ -20,12 +20,10 @@ var extendWebpackConfig = function (_a) {
|
|
|
20
20
|
? config.admin.webpack(webpackConfig)
|
|
21
21
|
: webpackConfig;
|
|
22
22
|
var newConfig = __assign(__assign({}, existingWebpackConfig), { resolve: __assign(__assign({}, (existingWebpackConfig.resolve || {})), { alias: __assign({}, (((_b = existingWebpackConfig.resolve) === null || _b === void 0 ? void 0 : _b.alias) ? existingWebpackConfig.resolve.alias : {})) }) });
|
|
23
|
-
return options.collections.reduce(function (resultingWebpackConfig,
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
return slug === collectionOptions.slug;
|
|
28
|
-
});
|
|
23
|
+
return Object.entries(options.collections).reduce(function (resultingWebpackConfig, _a) {
|
|
24
|
+
var _b;
|
|
25
|
+
var slug = _a[0], collectionOptions = _a[1];
|
|
26
|
+
var matchedCollection = (_b = config.collections) === null || _b === void 0 ? void 0 : _b.find(function (coll) { return coll.slug === slug; });
|
|
29
27
|
if (matchedCollection) {
|
|
30
28
|
var adapter = collectionOptions.adapter({
|
|
31
29
|
collection: matchedCollection,
|
package/dist/webpack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AASO,IAAM,mBAAmB,GAC9B,UAAC,EAAyB;QAAvB,MAAM,YAAA,EAAE,OAAO,aAAA;IAClB,OAAA,UAAA,aAAa;;QACX,IAAM,qBAAqB,GACzB,OAAO,CAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,OAAO,CAAA,KAAK,UAAU;YACzC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC;YACrC,CAAC,CAAC,aAAa,CAAA;QAEnB,IAAM,SAAS,yBACV,qBAAqB,KACxB,OAAO,wBACF,CAAC,qBAAqB,CAAC,OAAO,IAAI,EAAE,CAAC,KACxC,KAAK,eACA,CAAC,CAAA,MAAA,qBAAqB,CAAC,OAAO,0CAAE,KAAK,EAAC,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAGzF,CAAA;QAED,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AASO,IAAM,mBAAmB,GAC9B,UAAC,EAAyB;QAAvB,MAAM,YAAA,EAAE,OAAO,aAAA;IAClB,OAAA,UAAA,aAAa;;QACX,IAAM,qBAAqB,GACzB,OAAO,CAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,OAAO,CAAA,KAAK,UAAU;YACzC,CAAC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2
2
|
"name": "@payloadcms/plugin-cloud-storage",
|
|
3
3
|
"description": "The official cloud storage plugin for Payload CMS",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE.MD",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@aws-sdk/client-s3": "^3.142.0",
|
|
15
|
-
"@azure/storage-blob": "^12.11.0"
|
|
15
|
+
"@azure/storage-blob": "^12.11.0",
|
|
16
|
+
"@google-cloud/storage": "^6.4.1",
|
|
17
|
+
"payload": "^1.0.27"
|
|
16
18
|
},
|
|
17
19
|
"peerDependenciesMeta": {
|
|
18
20
|
"@aws-sdk/client-s3": {
|
|
@@ -20,6 +22,9 @@
|
|
|
20
22
|
},
|
|
21
23
|
"@azure/storage-blob": {
|
|
22
24
|
"optional": true
|
|
25
|
+
},
|
|
26
|
+
"@google-cloud/storage": {
|
|
27
|
+
"optional": true
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"files": [
|
|
@@ -31,6 +36,7 @@
|
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"@aws-sdk/client-s3": "^3.142.0",
|
|
33
38
|
"@azure/storage-blob": "^12.11.0",
|
|
39
|
+
"@google-cloud/storage": "^6.4.1",
|
|
34
40
|
"@types/express": "^4.17.9",
|
|
35
41
|
"@typescript-eslint/eslint-plugin": "5.12.1",
|
|
36
42
|
"@typescript-eslint/parser": "5.12.1",
|
package/s3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
exports.s3Adapter = require('./dist/adapters/s3')
|
|
1
|
+
exports.s3Adapter = require('./dist/adapters/s3').s3Adapter
|