From 5a802d0d94891c871f49d95a3d174b350bf553c3 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 24 Aug 2022 11:41:49 -0700 Subject: [PATCH] feat: allows adapter to be set to null, which will fall back to local storage --- dev/yarn.lock | 2 +- package.json | 2 +- src/plugin.ts | 2 +- src/types.ts | 2 +- yarn.lock | 84 ++++++++++++++++++++++++++++----------------------- 5 files changed, 51 insertions(+), 41 deletions(-) diff --git a/dev/yarn.lock b/dev/yarn.lock index 265c9588ea..efea6b37b5 100644 --- a/dev/yarn.lock +++ b/dev/yarn.lock @@ -7826,7 +7826,7 @@ pause@0.0.1: payload@^1.0.27: version "1.0.27" - resolved "https://registry.yarnpkg.com/payload/-/payload-1.0.27.tgz#6ac1ecf7800ec0c55638942bbbbf5688180fd6c3" + resolved "https://registry.npmjs.org/payload/-/payload-1.0.27.tgz#6ac1ecf7800ec0c55638942bbbbf5688180fd6c3" integrity sha512-tCiVH9GuhGtgGJ4ICPOKPv7BySVOwyOx6BekClp+WBLxe6Z2Wmd33bTY4X9/ZdllsdxATwmrMItUWpv0VEMEKw== dependencies: "@babel/cli" "^7.12.8" diff --git a/package.json b/package.json index be482f83de..1bee859e9a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "eslint-plugin-import": "2.25.4", "eslint-plugin-prettier": "^4.0.0", "nodemon": "^2.0.6", - "payload": "^1.0.19", + "payload": "^1.0.27", "prettier": "^2.7.1", "ts-node": "^9.1.1", "typescript": "^4.1.3" diff --git a/src/plugin.ts b/src/plugin.ts index ed7f7e274b..a6de8350e2 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -30,7 +30,7 @@ export const cloudStorage = collections: (config.collections || []).map(existingCollection => { const options = allCollectionOptions[existingCollection.slug] - if (options) { + if (options?.adapter) { const adapter = options.adapter({ collection: existingCollection }) const fields = getFields({ diff --git a/src/types.ts b/src/types.ts index 2806991e1e..6b672cd79d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,7 +48,7 @@ export type Adapter = (args: { collection: CollectionConfig }) => GeneratedAdapt export interface CollectionOptions { disableLocalStorage?: boolean disablePayloadAccessControl?: true - adapter: Adapter + adapter: Adapter | null } export interface PluginOptions { diff --git a/yarn.lock b/yarn.lock index b53b4f161b..919f9d12bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1967,7 +1967,7 @@ pirates "^4.0.5" source-map-support "^0.5.16" -"@babel/runtime@^7.1.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.15.4", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.15.4", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": version "7.18.9" resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a" integrity sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw== @@ -3775,12 +3775,12 @@ buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" -busboy@^0.3.1: - version "0.3.1" - resolved "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b" - integrity sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw== +busboy@^1.6.0: + version "1.6.0" + resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" + integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== dependencies: - dicer "0.3.0" + streamsearch "^1.1.0" bytes@3.0.0: version "3.0.0" @@ -4648,13 +4648,6 @@ detect-newline@^3.0.0: resolved "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== -dicer@0.3.0: - version "0.3.0" - resolved "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz#eacd98b3bfbf92e8ab5c2fdb71aaac44bb06b872" - integrity sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA== - dependencies: - streamsearch "0.1.2" - diff-sequences@^26.6.2: version "26.6.2" resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" @@ -5275,12 +5268,12 @@ expect@^26.6.2: jest-message-util "^26.6.2" jest-regex-util "^26.0.0" -express-fileupload@1.3.1: - version "1.3.1" - resolved "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.3.1.tgz#3238472def305b8cb4cc5936a953761d0c442011" - integrity sha512-LD1yabD3exmWIFujKGDnT1rmxSomaqQSlUvzIsrA1ZgwCJ6ci7lg2YHFGM3Q6DfK+Yk0gAVU7GWLE7qDMwZLkw== +express-fileupload@1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.4.0.tgz#be9d70a881d6c2b1ce668df86e4f89ddbf238ec7" + integrity sha512-RjzLCHxkv3umDeZKeFeMg8w7qe0V09w3B7oGZprr/oO2H/ISCgNzuqzn7gV3HRWb37GjRk429CCpSLS2KNTqMQ== dependencies: - busboy "^0.3.1" + busboy "^1.6.0" express-graphql@0.12.0: version "0.12.0" @@ -6233,6 +6226,13 @@ interpret@^2.2.0: resolved "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + ip@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" @@ -7127,7 +7127,7 @@ json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: resolved "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== -json-schema-to-typescript@^11.0.0: +json-schema-to-typescript@^11.0.2: version "11.0.2" resolved "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-11.0.2.tgz#80348391abb4ffb75daf312380c2f01c552ffba8" integrity sha512-XRyeXBJeo/IH4eTP5D1ptX78vCvH86nMDt2k3AxO28C3uYWEDmy4mgPyMpb8bLJ/pJMElOGuQbnKR5Y6NSh3QQ== @@ -7726,10 +7726,10 @@ mongoose-paginate-v2@^1.6.1: resolved "https://registry.npmjs.org/mongoose-paginate-v2/-/mongoose-paginate-v2-1.7.0.tgz#989a97160b5aa18b4bb16fb9ac3a80c6c33837ec" integrity sha512-r9bns1sMWRl0QO3YXVZ/uGOL/CYcDXTmapGHlddIgzbfOhVxUWKHKItwJO8rZICF1ooOukLQv8qQLVTc3qSLpQ== -mongoose@^6.2.0: - version "6.5.1" - resolved "https://registry.npmjs.org/mongoose/-/mongoose-6.5.1.tgz#bcf28700ce3552fcdd4d6d4078d0127290020928" - integrity sha512-8C0213y279nrSp6Au+WB+l/VczcotMU65jalTJJxU6KYf/Kd8gNW9+B3giWNJOVd8VvKvUQG0suWv/Vngp/83A== +mongoose@6.5.0: + version "6.5.0" + resolved "https://registry.npmjs.org/mongoose/-/mongoose-6.5.0.tgz#5c71aa8d4027e50bfe8d29d6e955e378e010d174" + integrity sha512-swOX8ZEbmCeJaEs29B1j67StBIhuOccNNkipbVhsnLYYCDpNE7heM9W54MFGwN5es9tGGoxINHSzOhJ9kTOZGg== dependencies: bson "^4.6.5" kareem "2.4.1" @@ -8375,10 +8375,10 @@ pause@0.0.1: resolved "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz#1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d" integrity sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg== -payload@^1.0.19: - version "1.0.19" - resolved "https://registry.npmjs.org/payload/-/payload-1.0.19.tgz#7344e93a0fc8187069fef1a690f865d4926b20b5" - integrity sha512-8vOybSd4TMkq+nwiigz4DXbrBlCrSIfEQSexsLj/HsjcTYLDOWdVz5UK3v3oYY4H2RuSIv+Hi7Kja//R1X7IRw== +payload@^1.0.27: + version "1.0.27" + resolved "https://registry.npmjs.org/payload/-/payload-1.0.27.tgz#6ac1ecf7800ec0c55638942bbbbf5688180fd6c3" + integrity sha512-tCiVH9GuhGtgGJ4ICPOKPv7BySVOwyOx6BekClp+WBLxe6Z2Wmd33bTY4X9/ZdllsdxATwmrMItUWpv0VEMEKw== dependencies: "@babel/cli" "^7.12.8" "@babel/core" "^7.11.6" @@ -8410,7 +8410,7 @@ payload@^1.0.19: deepmerge "^4.2.2" dotenv "^8.2.0" express "^4.17.1" - express-fileupload "1.3.1" + express-fileupload "1.4.0" express-graphql "0.12.0" express-rate-limit "^5.1.3" "falsey" "^1.0.0" @@ -8430,7 +8430,7 @@ payload@^1.0.19: isomorphic-fetch "^3.0.0" jest "^26.6.3" joi "^17.3.0" - json-schema-to-typescript "^11.0.0" + json-schema-to-typescript "^11.0.2" jsonwebtoken "^8.5.1" jwt-decode "^3.1.2" method-override "^3.0.0" @@ -8439,7 +8439,7 @@ payload@^1.0.19: mini-css-extract-plugin "1.3.3" minimist "^1.2.0" mkdirp "^1.0.4" - mongoose "^6.2.0" + mongoose "6.5.0" mongoose-paginate-v2 "^1.6.1" nodemailer "^6.4.2" object-to-formdata "^4.1.0" @@ -8469,9 +8469,10 @@ payload@^1.0.19: react-dom "^18.0.0" react-helmet "^6.1.0" react-router-dom "^5.1.2" - react-router-navigation-prompt "^1.8.11" + react-router-navigation-prompt "^1.9.6" react-select "^3.0.8" react-simple-code-editor "^0.11.0" + react-sortable-hoc "^2.0.0" react-toastify "^8.2.0" sanitize-filename "^1.6.3" sass "^1.52.1" @@ -9166,7 +9167,7 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: version "15.8.1" resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== @@ -9411,7 +9412,7 @@ react-router-dom@^5.1.2: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" -react-router-navigation-prompt@^1.8.11: +react-router-navigation-prompt@^1.9.6: version "1.9.6" resolved "https://registry.npmjs.org/react-router-navigation-prompt/-/react-router-navigation-prompt-1.9.6.tgz#a949252dfbae8c40508671beb6d5995f0b089ac4" integrity sha512-l0sAtbroHK8i1/Eyy29XcrMpBEt0R08BaScgMUt8r5vWWbLz7G0ChOikayTCQm7QgDFsHw8gVnxDJb7TBZCAKg== @@ -9456,6 +9457,15 @@ react-simple-code-editor@^0.11.0: resolved "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.11.2.tgz#af9da6706b76d2a520bd7b82e3383b329f61cd87" integrity sha512-vLMEDj+qLrZ88zK/8bhRdqM2Mp0cQJCUbHPc/QIfxlIYHzAclaAzPX0TQ4ZI5LTYSP3hsYYOT3EciV2dCG4o0Q== +react-sortable-hoc@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/react-sortable-hoc/-/react-sortable-hoc-2.0.0.tgz#f6780d8aa4b922a21f3e754af542f032677078b7" + integrity sha512-JZUw7hBsAHXK7PTyErJyI7SopSBFRcFHDjWW5SWjcugY0i6iH7f+eJkY8cJmGMlZ1C9xz1J3Vjz0plFpavVeRg== + dependencies: + "@babel/runtime" "^7.2.0" + invariant "^2.2.4" + prop-types "^15.5.7" + react-toastify@^8.2.0: version "8.2.0" resolved "https://registry.npmjs.org/react-toastify/-/react-toastify-8.2.0.tgz#ef7d56bdfdc6272ca6b228368ab564721c3a3244" @@ -10292,10 +10302,10 @@ stream-shift@^1.0.0: resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== -streamsearch@0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" - integrity sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA== +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== string-length@^4.0.1: version "4.0.2"