@webiny/api-file-manager 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f
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/createFileManager/checkBasePermissions.d.ts +5 -0
- package/createFileManager/checkBasePermissions.js +24 -0
- package/createFileManager/checkBasePermissions.js.map +1 -0
- package/createFileManager/files.crud.d.ts +3 -0
- package/createFileManager/files.crud.js +318 -0
- package/createFileManager/files.crud.js.map +1 -0
- package/createFileManager/filevalidation.disabled.d.ts +0 -0
- package/createFileManager/filevalidation.disabled.js +55 -0
- package/createFileManager/filevalidation.disabled.js.map +1 -0
- package/createFileManager/index.d.ts +13 -0
- package/createFileManager/index.js +20 -0
- package/createFileManager/index.js.map +1 -0
- package/createFileManager/settings.crud.d.ts +3 -0
- package/createFileManager/settings.crud.js +91 -0
- package/createFileManager/settings.crud.js.map +1 -0
- package/createFileManager/system.crud.d.ts +3 -0
- package/createFileManager/system.crud.js +86 -0
- package/createFileManager/system.crud.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +288 -0
- package/graphql/index.js.map +1 -0
- package/handlers/download/byAlias.d.ts +6 -0
- package/handlers/download/byAlias.js +89 -0
- package/handlers/download/byAlias.js.map +1 -0
- package/handlers/download/byExactKey.d.ts +2 -0
- package/handlers/download/byExactKey.js +57 -0
- package/handlers/download/byExactKey.js.map +1 -0
- package/handlers/download/extractFileInformation.d.ts +9 -0
- package/handlers/download/extractFileInformation.js +20 -0
- package/handlers/download/extractFileInformation.js.map +1 -0
- package/handlers/download/getS3Object.d.ts +10 -0
- package/handlers/download/getS3Object.js +57 -0
- package/handlers/download/getS3Object.js.map +1 -0
- package/handlers/download/index.d.ts +2 -3
- package/handlers/download/index.js +20 -118
- package/handlers/download/index.js.map +1 -0
- package/handlers/manage/index.d.ts +5 -3
- package/handlers/manage/index.js +43 -58
- package/handlers/manage/index.js.map +1 -0
- package/handlers/transform/index.d.ts +2 -3
- package/handlers/transform/index.js +71 -78
- package/handlers/transform/index.js.map +1 -0
- package/handlers/transform/legacyUtils.d.ts +17 -0
- package/handlers/transform/legacyUtils.js +42 -0
- package/handlers/transform/legacyUtils.js.map +1 -0
- package/handlers/transform/loaders/imageLoader.d.ts +26 -9
- package/handlers/transform/loaders/imageLoader.js +13 -25
- package/handlers/transform/loaders/imageLoader.js.map +1 -0
- package/handlers/transform/loaders/index.d.ts +4 -9
- package/handlers/transform/loaders/index.js +1 -4
- package/handlers/transform/loaders/index.js.map +1 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -3
- package/handlers/transform/loaders/sanitizeImageTransformations.js +24 -30
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
- package/handlers/transform/managers/imageManager.d.ts +12 -6
- package/handlers/transform/managers/imageManager.js +46 -27
- package/handlers/transform/managers/imageManager.js.map +1 -0
- package/handlers/transform/managers/index.d.ts +2 -6
- package/handlers/transform/managers/index.js +1 -4
- package/handlers/transform/managers/index.js.map +1 -0
- package/handlers/transform/optimizeImage.d.ts +2 -1
- package/handlers/transform/optimizeImage.js +4 -7
- package/handlers/transform/optimizeImage.js.map +1 -0
- package/handlers/transform/transformImage.d.ts +5 -4
- package/handlers/transform/transformImage.js +4 -9
- package/handlers/transform/transformImage.js.map +1 -0
- package/handlers/transform/utils.d.ts +2 -2
- package/handlers/transform/utils.js +8 -18
- package/handlers/transform/utils.js.map +1 -0
- package/handlers/types.d.ts +8 -0
- package/handlers/types.js +5 -0
- package/handlers/types.js.map +1 -0
- package/handlers/utils/getEnvironment.js +0 -2
- package/handlers/utils/getEnvironment.js.map +1 -0
- package/handlers/utils/getObjectParams.d.ts +3 -4
- package/handlers/utils/getObjectParams.js +1 -7
- package/handlers/utils/getObjectParams.js.map +1 -0
- package/handlers/utils/index.d.ts +0 -1
- package/handlers/utils/index.js +1 -12
- package/handlers/utils/index.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.js +68 -0
- package/index.js.map +1 -0
- package/package.json +29 -30
- package/plugins/FilePhysicalStoragePlugin.d.ts +21 -0
- package/plugins/FilePhysicalStoragePlugin.js +31 -0
- package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/FileStorageTransformPlugin.d.ts +34 -0
- package/plugins/FileStorageTransformPlugin.js +40 -0
- package/plugins/FileStorageTransformPlugin.js.map +1 -0
- package/plugins/crud/files/validation.js +1 -1
- package/plugins/crud/files/validation.js.map +1 -0
- package/plugins/crud/files.crud.d.ts +1 -1
- package/plugins/crud/files.crud.js +48 -44
- package/plugins/crud/files.crud.js.map +1 -0
- package/plugins/crud/settings.crud.d.ts +1 -1
- package/plugins/crud/settings.crud.js +10 -9
- package/plugins/crud/settings.crud.js.map +1 -0
- package/plugins/crud/system.crud.d.ts +1 -1
- package/plugins/crud/system.crud.js +18 -10
- package/plugins/crud/system.crud.js.map +1 -0
- package/plugins/crud/utils/checkBasePermissions.js +1 -1
- package/plugins/crud/utils/checkBasePermissions.js.map +1 -0
- package/plugins/crud/utils/createFileModel.d.ts +3 -0
- package/plugins/crud/utils/createFileModel.js +13 -0
- package/plugins/crud/utils/createFileModel.js.map +1 -0
- package/plugins/crud/utils/lifecycleEvents.d.ts +2 -2
- package/plugins/crud/utils/lifecycleEvents.js +6 -1
- package/plugins/crud/utils/lifecycleEvents.js.map +1 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +10 -11
- package/plugins/definitions/FilePhysicalStoragePlugin.js +1 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/definitions/FilePlugin.d.ts +6 -3
- package/plugins/definitions/FilePlugin.js +9 -3
- package/plugins/definitions/FilePlugin.js.map +1 -0
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +9 -9
- package/plugins/definitions/FileStorageTransformPlugin.js +1 -1
- package/plugins/definitions/FileStorageTransformPlugin.js.map +1 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +4 -4
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +1 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/definitions/InstallationPlugin.d.ts +9 -9
- package/plugins/definitions/InstallationPlugin.js +5 -3
- package/plugins/definitions/InstallationPlugin.js.map +1 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +4 -4
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +1 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +4 -4
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +1 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/graphql.js +20 -4
- package/plugins/graphql.js.map +1 -0
- package/plugins/index.d.ts +2 -2
- package/plugins/index.js +22 -19
- package/plugins/index.js.map +1 -0
- package/plugins/storage/FileStorage.d.ts +23 -24
- package/plugins/storage/FileStorage.js +28 -20
- package/plugins/storage/FileStorage.js.map +1 -0
- package/plugins/storage/index.d.ts +1 -1
- package/plugins/storage/index.js +6 -2
- package/plugins/storage/index.js.map +1 -0
- package/storage/FileStorage.d.ts +32 -0
- package/storage/FileStorage.js +86 -0
- package/storage/FileStorage.js.map +1 -0
- package/types/file.d.ts +33 -0
- package/types/file.js +5 -0
- package/types/file.js.map +1 -0
- package/types/file.lifecycle.d.ts +40 -0
- package/types/file.lifecycle.js +5 -0
- package/types/file.lifecycle.js.map +1 -0
- package/types.d.ts +59 -56
- package/types.js +22 -0
- package/types.js.map +1 -0
- package/utils.js.map +1 -0
- package/handlers/utils/createHandler.d.ts +0 -24
- package/handlers/utils/createHandler.js +0 -68
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export interface ObjectParamsResponse {
|
|
2
2
|
Bucket: string;
|
|
3
3
|
Key: string;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
/**
|
|
6
6
|
* Returns website's Bucket and file's Key values.
|
|
7
|
-
* @param filename
|
|
8
|
-
* @returns {{Bucket: string, Key: string}}
|
|
9
7
|
*/
|
|
8
|
+
declare const _default: (filename: string) => ObjectParamsResponse;
|
|
10
9
|
export default _default;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _getEnvironment = _interopRequireDefault(require("./getEnvironment"));
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Returns website's Bucket and file's Key values.
|
|
14
|
-
* @param filename
|
|
15
|
-
* @returns {{Bucket: string, Key: string}}
|
|
16
11
|
*/
|
|
17
12
|
var _default = filename => {
|
|
18
13
|
const {
|
|
@@ -23,5 +18,4 @@ var _default = filename => {
|
|
|
23
18
|
Key: `${filename}`
|
|
24
19
|
};
|
|
25
20
|
};
|
|
26
|
-
|
|
27
21
|
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filename","bucket","Bucket","getEnvironment","Key"],"sources":["getObjectParams.ts"],"sourcesContent":["import getEnvironment from \"./getEnvironment\";\n\nexport interface ObjectParamsResponse {\n Bucket: string;\n Key: string;\n}\n/**\n * Returns website's Bucket and file's Key values.\n */\nexport default (filename: string): ObjectParamsResponse => {\n const { bucket: Bucket } = getEnvironment();\n\n return {\n Bucket,\n Key: `${filename}`\n };\n};\n"],"mappings":";;;;;;;AAAA;AAMA;AACA;AACA;AAFA,eAGgBA,QAAgB,IAA2B;EACvD,MAAM;IAAEC,MAAM,EAAEC;EAAO,CAAC,GAAG,IAAAC,uBAAc,GAAE;EAE3C,OAAO;IACHD,MAAM;IACNE,GAAG,EAAG,GAAEJ,QAAS;EACrB,CAAC;AACL,CAAC;AAAA"}
|
package/handlers/utils/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
Object.defineProperty(exports, "createHandler", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _createHandler.default;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
7
|
Object.defineProperty(exports, "getEnvironment", {
|
|
15
8
|
enumerable: true,
|
|
16
9
|
get: function () {
|
|
@@ -23,9 +16,5 @@ Object.defineProperty(exports, "getObjectParams", {
|
|
|
23
16
|
return _getObjectParams.default;
|
|
24
17
|
}
|
|
25
18
|
});
|
|
26
|
-
|
|
27
19
|
var _getEnvironment = _interopRequireDefault(require("./getEnvironment"));
|
|
28
|
-
|
|
29
|
-
var _createHandler = _interopRequireDefault(require("./createHandler"));
|
|
30
|
-
|
|
31
20
|
var _getObjectParams = _interopRequireDefault(require("./getObjectParams"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as getEnvironment } from \"./getEnvironment\";\nexport { default as getObjectParams } from \"./getObjectParams\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
import { FileManagerConfig } from "./createFileManager";
|
|
3
|
+
import { FileManagerContext } from "./types";
|
|
4
|
+
export * from "./plugins";
|
|
5
|
+
export declare const createFileManagerContext: (config: Pick<FileManagerConfig, "storageOperations">) => ContextPlugin<FileManagerContext>;
|
|
6
|
+
export declare const createFileManagerGraphQL: () => import("@webiny/handler-graphql").GraphQLSchemaPlugin<FileManagerContext>;
|
package/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
createFileManagerContext: true,
|
|
9
|
+
createFileManagerGraphQL: true
|
|
10
|
+
};
|
|
11
|
+
exports.createFileManagerGraphQL = exports.createFileManagerContext = void 0;
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
var _api = require("@webiny/api");
|
|
14
|
+
var _createFileManager = require("./createFileManager");
|
|
15
|
+
var _graphql = require("./graphql");
|
|
16
|
+
var _FileStorage = require("./storage/FileStorage");
|
|
17
|
+
var _plugins = require("./plugins");
|
|
18
|
+
Object.keys(_plugins).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _plugins[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _plugins[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const createFileManagerContext = config => {
|
|
30
|
+
return new _api.ContextPlugin(async context => {
|
|
31
|
+
const getLocaleCode = () => {
|
|
32
|
+
const locale = context.i18n.getContentLocale();
|
|
33
|
+
if (!locale) {
|
|
34
|
+
throw new _error.default("Missing locale on context.i18n locale in File Manager API.", "LOCALE_ERROR");
|
|
35
|
+
}
|
|
36
|
+
return locale.code;
|
|
37
|
+
};
|
|
38
|
+
const getIdentity = () => {
|
|
39
|
+
return context.security.getIdentity();
|
|
40
|
+
};
|
|
41
|
+
const getTenantId = () => {
|
|
42
|
+
return context.tenancy.getCurrentTenant().id;
|
|
43
|
+
};
|
|
44
|
+
const getPermission = async name => {
|
|
45
|
+
await context.i18n.checkI18NContentPermission();
|
|
46
|
+
return context.security.getPermission(name);
|
|
47
|
+
};
|
|
48
|
+
if (config.storageOperations.beforeInit) {
|
|
49
|
+
await config.storageOperations.beforeInit(context);
|
|
50
|
+
}
|
|
51
|
+
context.fileManager = (0, _createFileManager.createFileManager)({
|
|
52
|
+
storageOperations: config.storageOperations,
|
|
53
|
+
getTenantId,
|
|
54
|
+
getLocaleCode,
|
|
55
|
+
getIdentity,
|
|
56
|
+
getPermission,
|
|
57
|
+
storage: new _FileStorage.FileStorage({
|
|
58
|
+
context
|
|
59
|
+
}),
|
|
60
|
+
WEBINY_VERSION: context.WEBINY_VERSION
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.createFileManagerContext = createFileManagerContext;
|
|
65
|
+
const createFileManagerGraphQL = () => {
|
|
66
|
+
return (0, _graphql.createGraphQLSchemaPlugin)();
|
|
67
|
+
};
|
|
68
|
+
exports.createFileManagerGraphQL = createFileManagerGraphQL;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFileManagerContext","config","ContextPlugin","context","getLocaleCode","locale","i18n","getContentLocale","WebinyError","code","getIdentity","security","getTenantId","tenancy","getCurrentTenant","id","getPermission","name","checkI18NContentPermission","storageOperations","beforeInit","fileManager","createFileManager","storage","FileStorage","WEBINY_VERSION","createFileManagerGraphQL","createGraphQLSchemaPlugin"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { FileManagerConfig, createFileManager } from \"~/createFileManager\";\nimport { FileManagerContext } from \"~/types\";\nimport { createGraphQLSchemaPlugin } from \"./graphql\";\nimport { FileStorage } from \"~/storage/FileStorage\";\n\nexport * from \"./plugins\";\n\nexport const createFileManagerContext = (config: Pick<FileManagerConfig, \"storageOperations\">) => {\n return new ContextPlugin<FileManagerContext>(async context => {\n const getLocaleCode = () => {\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing locale on context.i18n locale in File Manager API.\",\n \"LOCALE_ERROR\"\n );\n }\n return locale.code;\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenantId = () => {\n return context.tenancy.getCurrentTenant().id;\n };\n\n const getPermission = async <T extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<T | null> => {\n await context.i18n.checkI18NContentPermission();\n\n return context.security.getPermission(name);\n };\n\n if (config.storageOperations.beforeInit) {\n await config.storageOperations.beforeInit(context);\n }\n\n context.fileManager = createFileManager({\n storageOperations: config.storageOperations,\n getTenantId,\n getLocaleCode,\n getIdentity,\n getPermission,\n storage: new FileStorage({\n context\n }),\n WEBINY_VERSION: context.WEBINY_VERSION\n });\n });\n};\n\nexport const createFileManagerGraphQL = () => {\n return createGraphQLSchemaPlugin();\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEO,MAAMA,wBAAwB,GAAIC,MAAoD,IAAK;EAC9F,OAAO,IAAIC,kBAAa,CAAqB,MAAMC,OAAO,IAAI;IAC1D,MAAMC,aAAa,GAAG,MAAM;MACxB,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAACC,gBAAgB,EAAE;MAC9C,IAAI,CAACF,MAAM,EAAE;QACT,MAAM,IAAIG,cAAW,CACjB,4DAA4D,EAC5D,cAAc,CACjB;MACL;MACA,OAAOH,MAAM,CAACI,IAAI;IACtB,CAAC;IAED,MAAMC,WAAW,GAAG,MAAM;MACtB,OAAOP,OAAO,CAACQ,QAAQ,CAACD,WAAW,EAAE;IACzC,CAAC;IAED,MAAME,WAAW,GAAG,MAAM;MACtB,OAAOT,OAAO,CAACU,OAAO,CAACC,gBAAgB,EAAE,CAACC,EAAE;IAChD,CAAC;IAED,MAAMC,aAAa,GAAG,MAClBC,IAAY,IACQ;MACpB,MAAMd,OAAO,CAACG,IAAI,CAACY,0BAA0B,EAAE;MAE/C,OAAOf,OAAO,CAACQ,QAAQ,CAACK,aAAa,CAACC,IAAI,CAAC;IAC/C,CAAC;IAED,IAAIhB,MAAM,CAACkB,iBAAiB,CAACC,UAAU,EAAE;MACrC,MAAMnB,MAAM,CAACkB,iBAAiB,CAACC,UAAU,CAACjB,OAAO,CAAC;IACtD;IAEAA,OAAO,CAACkB,WAAW,GAAG,IAAAC,oCAAiB,EAAC;MACpCH,iBAAiB,EAAElB,MAAM,CAACkB,iBAAiB;MAC3CP,WAAW;MACXR,aAAa;MACbM,WAAW;MACXM,aAAa;MACbO,OAAO,EAAE,IAAIC,wBAAW,CAAC;QACrBrB;MACJ,CAAC,CAAC;MACFsB,cAAc,EAAEtB,OAAO,CAACsB;IAC5B,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC;AAEK,MAAMC,wBAAwB,GAAG,MAAM;EAC1C,OAAO,IAAAC,kCAAyB,GAAE;AACtC,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.1145e7667f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fm:base"
|
|
@@ -18,39 +18,38 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@babel/runtime": "7.
|
|
21
|
+
"@babel/runtime": "7.20.13",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
|
-
"@webiny/api
|
|
24
|
-
"@webiny/api-security": "0.0.0-
|
|
25
|
-
"@webiny/api-tenancy": "0.0.0-
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/handler": "0.0.0-
|
|
29
|
-
"@webiny/handler-client": "0.0.0-
|
|
30
|
-
"@webiny/handler-graphql": "0.0.0-
|
|
31
|
-
"@webiny/plugins": "0.0.0-
|
|
32
|
-
"@webiny/project-utils": "0.0.0-
|
|
33
|
-
"@webiny/
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"object-hash": "1.3.1",
|
|
38
|
-
"sanitize-filename": "1.6.3"
|
|
23
|
+
"@webiny/api": "0.0.0-unstable.1145e7667f",
|
|
24
|
+
"@webiny/api-security": "0.0.0-unstable.1145e7667f",
|
|
25
|
+
"@webiny/api-tenancy": "0.0.0-unstable.1145e7667f",
|
|
26
|
+
"@webiny/error": "0.0.0-unstable.1145e7667f",
|
|
27
|
+
"@webiny/handler": "0.0.0-unstable.1145e7667f",
|
|
28
|
+
"@webiny/handler-aws": "0.0.0-unstable.1145e7667f",
|
|
29
|
+
"@webiny/handler-client": "0.0.0-unstable.1145e7667f",
|
|
30
|
+
"@webiny/handler-graphql": "0.0.0-unstable.1145e7667f",
|
|
31
|
+
"@webiny/plugins": "0.0.0-unstable.1145e7667f",
|
|
32
|
+
"@webiny/project-utils": "0.0.0-unstable.1145e7667f",
|
|
33
|
+
"@webiny/pubsub": "0.0.0-unstable.1145e7667f",
|
|
34
|
+
"@webiny/validation": "0.0.0-unstable.1145e7667f",
|
|
35
|
+
"aws-sdk": "2.1310.0",
|
|
36
|
+
"object-hash": "2.2.0"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@babel/cli": "^7.
|
|
42
|
-
"@babel/core": "^7.
|
|
43
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
44
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
45
|
-
"@babel/preset-env": "^7.
|
|
46
|
-
"@babel/preset-typescript": "^7.
|
|
47
|
-
"@webiny/api-i18n": "^0.0.0-
|
|
48
|
-
"@webiny/api-i18n-ddb": "^0.0.0-
|
|
49
|
-
"@webiny/cli": "^0.0.0-
|
|
50
|
-
"jest": "^
|
|
39
|
+
"@babel/cli": "^7.19.3",
|
|
40
|
+
"@babel/core": "^7.19.3",
|
|
41
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
42
|
+
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
43
|
+
"@babel/preset-env": "^7.19.4",
|
|
44
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
45
|
+
"@webiny/api-i18n": "^0.0.0-unstable.1145e7667f",
|
|
46
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.1145e7667f",
|
|
47
|
+
"@webiny/cli": "^0.0.0-unstable.1145e7667f",
|
|
48
|
+
"jest": "^28.1.0",
|
|
49
|
+
"mdbid": "^1.0.0",
|
|
51
50
|
"rimraf": "^3.0.2",
|
|
52
51
|
"ttypescript": "^1.5.12",
|
|
53
|
-
"typescript": "
|
|
52
|
+
"typescript": "4.7.4"
|
|
54
53
|
},
|
|
55
54
|
"publishConfig": {
|
|
56
55
|
"access": "public",
|
|
@@ -71,5 +70,5 @@
|
|
|
71
70
|
]
|
|
72
71
|
}
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "1145e7667ffd3d18bfea1e73d6078cd6a35c1038"
|
|
75
74
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Plugin } from "@webiny/plugins";
|
|
3
|
+
import { FileManagerSettings } from "../types";
|
|
4
|
+
export interface FilePhysicalStoragePluginParams<U extends FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams> {
|
|
5
|
+
upload: (args: U) => Promise<any>;
|
|
6
|
+
delete: (args: D) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface FilePhysicalStoragePluginUploadParams {
|
|
9
|
+
settings: FileManagerSettings;
|
|
10
|
+
buffer: Buffer;
|
|
11
|
+
}
|
|
12
|
+
export interface FilePhysicalStoragePluginDeleteParams {
|
|
13
|
+
key: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class FilePhysicalStoragePlugin<U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams> extends Plugin {
|
|
16
|
+
static readonly type: string;
|
|
17
|
+
private readonly _params;
|
|
18
|
+
constructor(params: FilePhysicalStoragePluginParams<U, D>);
|
|
19
|
+
upload(params: U): Promise<any>;
|
|
20
|
+
delete(params: D): Promise<any>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FilePhysicalStoragePlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
class FilePhysicalStoragePlugin extends _plugins.Plugin {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
super();
|
|
14
|
+
(0, _defineProperty2.default)(this, "_params", void 0);
|
|
15
|
+
this._params = params;
|
|
16
|
+
}
|
|
17
|
+
async upload(params) {
|
|
18
|
+
if (!this._params.upload) {
|
|
19
|
+
throw new _error.default(`You must define the "upload" method of this plugin.`, "UPLOAD_METHOD_ERROR");
|
|
20
|
+
}
|
|
21
|
+
return this._params.upload(params);
|
|
22
|
+
}
|
|
23
|
+
async delete(params) {
|
|
24
|
+
if (!this._params.delete) {
|
|
25
|
+
throw new _error.default(`You must define the "delete" method of this plugin.`, "DELETE_METHOD_ERROR");
|
|
26
|
+
}
|
|
27
|
+
return this._params.delete(params);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.FilePhysicalStoragePlugin = FilePhysicalStoragePlugin;
|
|
31
|
+
(0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAoBO,MAAMA,yBAAyB,SAG5BC,eAAM,CAAC;EAINC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;EAEA,MAAaE,MAAM,CAACF,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,MAAM,EAAE;MACtB,MAAM,IAAIC,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,MAAM,CAACF,MAAM,CAAC;EACtC;EAEA,MAAaI,MAAM,CAACJ,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACG,MAAM,EAAE;MACtB,MAAM,IAAID,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,MAAM,CAACJ,MAAM,CAAC;EACtC;AACJ;AAAC;AAAA,8BA/BYH,yBAAyB,UAIa,0BAA0B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { File } from "../types";
|
|
3
|
+
export interface FileStorageTransformPluginToParams {
|
|
4
|
+
/**
|
|
5
|
+
* File that is being sent to the storage operations method.
|
|
6
|
+
*/
|
|
7
|
+
file: File & Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export interface FileStorageTransformPluginFromParams {
|
|
10
|
+
/**
|
|
11
|
+
* File that was fetched from the storage operations method.
|
|
12
|
+
*/
|
|
13
|
+
file: File & Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
export interface FileStorageTransformPluginParams {
|
|
16
|
+
toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;
|
|
17
|
+
fromStorage?: (params: FileStorageTransformPluginFromParams) => Promise<File & Record<string, any>>;
|
|
18
|
+
}
|
|
19
|
+
export declare class FileStorageTransformPlugin extends Plugin {
|
|
20
|
+
static readonly type: string;
|
|
21
|
+
private readonly _params;
|
|
22
|
+
constructor(params: FileStorageTransformPluginParams);
|
|
23
|
+
/**
|
|
24
|
+
* Transform the file value into something that can be stored.
|
|
25
|
+
* Be aware that you must return the whole file object.
|
|
26
|
+
*/
|
|
27
|
+
toStorage(params: FileStorageTransformPluginToParams): Promise<File & Record<string, any>>;
|
|
28
|
+
/**
|
|
29
|
+
* Transform the file value from the storage type to one required by our system.
|
|
30
|
+
* Be aware that you must return the whole file object.
|
|
31
|
+
* This method MUST reverse what ever toStorage method changed on the file object.
|
|
32
|
+
*/
|
|
33
|
+
fromStorage(params: FileStorageTransformPluginFromParams): Promise<File & Record<string, any>>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FileStorageTransformPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class FileStorageTransformPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "_params", void 0);
|
|
14
|
+
this._params = params;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transform the file value into something that can be stored.
|
|
19
|
+
* Be aware that you must return the whole file object.
|
|
20
|
+
*/
|
|
21
|
+
async toStorage(params) {
|
|
22
|
+
if (!this._params.toStorage) {
|
|
23
|
+
return params.file;
|
|
24
|
+
}
|
|
25
|
+
return this._params.toStorage(params);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Transform the file value from the storage type to one required by our system.
|
|
29
|
+
* Be aware that you must return the whole file object.
|
|
30
|
+
* This method MUST reverse what ever toStorage method changed on the file object.
|
|
31
|
+
*/
|
|
32
|
+
async fromStorage(params) {
|
|
33
|
+
if (!this._params.fromStorage) {
|
|
34
|
+
return params.file;
|
|
35
|
+
}
|
|
36
|
+
return this._params.fromStorage(params);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.FileStorageTransformPlugin = FileStorageTransformPlugin;
|
|
40
|
+
(0, _defineProperty2.default)(FileStorageTransformPlugin, "type", "fm.files.storage.transform");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FileStorageTransformPlugin","Plugin","constructor","params","_params","toStorage","file","fromStorage"],"sources":["FileStorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File } from \"~/types\";\n\nexport interface FileStorageTransformPluginToParams {\n /**\n * File that is being sent to the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginFromParams {\n /**\n * File that was fetched from the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginParams {\n toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;\n fromStorage?: (\n params: FileStorageTransformPluginFromParams\n ) => Promise<File & Record<string, any>>;\n}\n\nexport class FileStorageTransformPlugin extends Plugin {\n public static override readonly type: string = \"fm.files.storage.transform\";\n private readonly _params: FileStorageTransformPluginParams;\n\n public constructor(params: FileStorageTransformPluginParams) {\n super();\n\n this._params = params;\n }\n\n /**\n * Transform the file value into something that can be stored.\n * Be aware that you must return the whole file object.\n */\n public async toStorage(\n params: FileStorageTransformPluginToParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.toStorage) {\n return params.file;\n }\n return this._params.toStorage(params);\n }\n /**\n * Transform the file value from the storage type to one required by our system.\n * Be aware that you must return the whole file object.\n * This method MUST reverse what ever toStorage method changed on the file object.\n */\n public async fromStorage(\n params: FileStorageTransformPluginFromParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.fromStorage) {\n return params.file;\n }\n return this._params.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAwBO,MAAMA,0BAA0B,SAASC,eAAM,CAAC;EAI5CC,WAAW,CAACC,MAAwC,EAAE;IACzD,KAAK,EAAE;IAAC;IAER,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;;EAEA;AACJ;AACA;AACA;EACI,MAAaE,SAAS,CAClBF,MAA0C,EACP;IACnC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,SAAS,EAAE;MACzB,OAAOF,MAAM,CAACG,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,SAAS,CAACF,MAAM,CAAC;EACzC;EACA;AACJ;AACA;AACA;AACA;EACI,MAAaI,WAAW,CACpBJ,MAA4C,EACT;IACnC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACG,WAAW,EAAE;MAC3B,OAAOJ,MAAM,CAACG,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,WAAW,CAACJ,MAAM,CAAC;EAC3C;AACJ;AAAC;AAAA,8BAnCYH,0BAA0B,UACY,4BAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FilePlugin","beforeCreate","data","FileModel","createFileModel","fileData","populate","validate","beforeUpdate","updatedFileData","beforeBatchCreate","input","fileInstance"],"sources":["validation.ts"],"sourcesContent":["import { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport createFileModel from \"~/plugins/crud/utils/createFileModel\";\n\nexport default (): FilePlugin[] => [\n new FilePlugin({\n beforeCreate: async ({ data }) => {\n const FileModel = createFileModel();\n const fileData = new FileModel().populate(data);\n await fileData.validate();\n },\n beforeUpdate: async ({ data }) => {\n const FileModel = createFileModel(false);\n const updatedFileData = new FileModel().populate(data);\n await updatedFileData.validate();\n },\n beforeBatchCreate: async ({ data }) => {\n const FileModel = createFileModel();\n for (const input of data) {\n const fileInstance = new FileModel().populate(input);\n await fileInstance.validate();\n }\n }\n })\n];\n"],"mappings":";;;;;;;;;AAAA;;AACA;;eAEe,MAAoB,CAC/B,IAAIA,sBAAJ,CAAe;EACXC,YAAY,EAAE,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAA,GAAlB;IACA,MAAMC,QAAQ,GAAG,IAAIF,SAAJ,GAAgBG,QAAhB,CAAyBJ,IAAzB,CAAjB;IACA,MAAMG,QAAQ,CAACE,QAAT,EAAN;EACH,CALU;EAMXC,YAAY,EAAE,OAAO;IAAEN;EAAF,CAAP,KAAoB;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAA,EAAgB,KAAhB,CAAlB;IACA,MAAMK,eAAe,GAAG,IAAIN,SAAJ,GAAgBG,QAAhB,CAAyBJ,IAAzB,CAAxB;IACA,MAAMO,eAAe,CAACF,QAAhB,EAAN;EACH,CAVU;EAWXG,iBAAiB,EAAE,OAAO;IAAER;EAAF,CAAP,KAAoB;IACnC,MAAMC,SAAS,GAAG,IAAAC,wBAAA,GAAlB;;IACA,KAAK,MAAMO,KAAX,IAAoBT,IAApB,EAA0B;MACtB,MAAMU,YAAY,GAAG,IAAIT,SAAJ,GAAgBG,QAAhB,CAAyBK,KAAzB,CAArB;MACA,MAAMC,YAAY,CAACL,QAAb,EAAN;IACH;EACJ;AAjBU,CAAf,CAD+B,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FileManagerContext } from "../../types";
|
|
2
|
-
import { ContextPlugin } from "@webiny/
|
|
2
|
+
import { ContextPlugin } from "@webiny/api";
|
|
3
3
|
declare const filesContextCrudPlugin: ContextPlugin<FileManagerContext>;
|
|
4
4
|
export default filesContextCrudPlugin;
|