@webiny/api-file-manager-ddb 0.0.0-mt-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/definitions/filesEntity.d.ts +7 -0
  4. package/definitions/filesEntity.js +80 -0
  5. package/definitions/settingsEntity.d.ts +7 -0
  6. package/definitions/settingsEntity.js +56 -0
  7. package/definitions/systemEntity.d.ts +7 -0
  8. package/definitions/systemEntity.js +44 -0
  9. package/definitions/table.d.ts +6 -0
  10. package/definitions/table.js +28 -0
  11. package/index.d.ts +5 -0
  12. package/index.js +16 -0
  13. package/operations/configurations.d.ts +14 -0
  14. package/operations/configurations.js +22 -0
  15. package/operations/files/FilesStorageOperations.d.ts +22 -0
  16. package/operations/files/FilesStorageOperations.js +345 -0
  17. package/operations/files/fields.d.ts +3 -0
  18. package/operations/files/fields.js +42 -0
  19. package/operations/files/index.d.ts +6 -0
  20. package/operations/files/index.js +35 -0
  21. package/operations/settings/SettingsStorageOperations.d.ts +15 -0
  22. package/operations/settings/SettingsStorageOperations.js +120 -0
  23. package/operations/settings/index.d.ts +8 -0
  24. package/operations/settings/index.js +32 -0
  25. package/operations/system/SystemStorageOperations.d.ts +14 -0
  26. package/operations/system/SystemStorageOperations.js +108 -0
  27. package/operations/system/index.d.ts +8 -0
  28. package/operations/system/index.js +32 -0
  29. package/operations/utils.d.ts +4 -0
  30. package/operations/utils.js +36 -0
  31. package/package.json +67 -0
  32. package/plugins/FileAttributePlugin.d.ts +4 -0
  33. package/plugins/FileAttributePlugin.js +27 -0
  34. package/plugins/FileDynamoDbFieldPlugin.d.ts +4 -0
  35. package/plugins/FileDynamoDbFieldPlugin.js +17 -0
  36. package/plugins/SettingsAttributePlugin.d.ts +4 -0
  37. package/plugins/SettingsAttributePlugin.js +27 -0
  38. package/plugins/SystemAttributePlugin.d.ts +4 -0
  39. package/plugins/SystemAttributePlugin.js +27 -0
  40. package/types.d.ts +0 -0
  41. package/types.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @webiny/api-file-manager-ddb
2
+
3
+ [![](https://img.shields.io/npm/dw/@webiny/api-file-manager-ddb.svg)](https://www.npmjs.com/package/@webiny/api-file-manager-ddb)
4
+ [![](https://img.shields.io/npm/v/@webiny/api-file-manager-ddb.svg)](https://www.npmjs.com/package/@webiny/api-file-manager-ddb)
5
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
7
+
8
+ ## Install
9
+
10
+ ```
11
+ npm install --save @webiny/api-file-manager-ddb
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+
16
+ ```
17
+ yarn add @webiny/api-file-manager-ddb
18
+ ```
19
+
20
+
21
+ ## Testing
22
+ To run the tests only for this package you must filter it with keywords.
23
+
24
+ ### Env variables
25
+
26
+
27
+ ### Command
28
+ ````
29
+ yarn test packages/api-file-manager --keyword=fm:ddb --keyword=fm:base
30
+ ````
@@ -0,0 +1,7 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { FileManagerContext } from "@webiny/api-file-manager/types";
3
+ declare const _default: (params: {
4
+ context: FileManagerContext;
5
+ table: Table;
6
+ }) => Entity<any>;
7
+ export default _default;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
14
+ var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ var _default = params => {
21
+ const {
22
+ context,
23
+ table
24
+ } = params;
25
+ const entityName = "Files";
26
+ const attributes = (0, _attributes.getExtraAttributes)(context, entityName);
27
+ return new _dynamodbToolbox.Entity({
28
+ name: entityName,
29
+ table,
30
+ attributes: _objectSpread({
31
+ PK: {
32
+ partitionKey: true
33
+ },
34
+ SK: {
35
+ sortKey: true
36
+ },
37
+ TYPE: {
38
+ type: "string"
39
+ },
40
+ id: {
41
+ type: "string"
42
+ },
43
+ key: {
44
+ type: "string"
45
+ },
46
+ size: {
47
+ type: "number"
48
+ },
49
+ type: {
50
+ type: "string"
51
+ },
52
+ name: {
53
+ type: "string"
54
+ },
55
+ meta: {
56
+ type: "map"
57
+ },
58
+ tags: {
59
+ type: "list"
60
+ },
61
+ createdOn: {
62
+ type: "string"
63
+ },
64
+ createdBy: {
65
+ type: "map"
66
+ },
67
+ tenant: {
68
+ type: "string"
69
+ },
70
+ locale: {
71
+ type: "string"
72
+ },
73
+ webinyVersion: {
74
+ type: "string"
75
+ }
76
+ }, attributes)
77
+ });
78
+ };
79
+
80
+ exports.default = _default;
@@ -0,0 +1,7 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { FileManagerContext } from "@webiny/api-file-manager/types";
3
+ declare const _default: (params: {
4
+ context: FileManagerContext;
5
+ table: Table;
6
+ }) => Entity<any>;
7
+ export default _default;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
14
+ var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ var _default = params => {
21
+ const {
22
+ context,
23
+ table
24
+ } = params;
25
+ const entityName = "Settings";
26
+ const attributes = (0, _attributes.getExtraAttributes)(context, entityName);
27
+ return new _dynamodbToolbox.Entity({
28
+ name: entityName,
29
+ table,
30
+ attributes: _objectSpread({
31
+ PK: {
32
+ partitionKey: true
33
+ },
34
+ SK: {
35
+ sortKey: true
36
+ },
37
+ TYPE: {
38
+ type: "string"
39
+ },
40
+ key: {
41
+ type: "string"
42
+ },
43
+ uploadMinFileSize: {
44
+ type: "number"
45
+ },
46
+ uploadMaxFileSize: {
47
+ type: "number"
48
+ },
49
+ srcPrefix: {
50
+ type: "string"
51
+ }
52
+ }, attributes)
53
+ });
54
+ };
55
+
56
+ exports.default = _default;
@@ -0,0 +1,7 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { FileManagerContext } from "@webiny/api-file-manager/types";
3
+ declare const _default: (params: {
4
+ context: FileManagerContext;
5
+ table: Table;
6
+ }) => Entity<any>;
7
+ export default _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
14
+ var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ var _default = params => {
21
+ const {
22
+ context,
23
+ table
24
+ } = params;
25
+ const entityName = "System";
26
+ const attributes = (0, _attributes.getExtraAttributes)(context, entityName);
27
+ return new _dynamodbToolbox.Entity({
28
+ name: entityName,
29
+ table,
30
+ attributes: _objectSpread({
31
+ PK: {
32
+ partitionKey: true
33
+ },
34
+ SK: {
35
+ sortKey: true
36
+ },
37
+ version: {
38
+ type: "string"
39
+ }
40
+ }, attributes)
41
+ });
42
+ };
43
+
44
+ exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import { Table } from "dynamodb-toolbox";
2
+ import { FileManagerContext } from "@webiny/api-file-manager/types";
3
+ declare const _default: (params: {
4
+ context: FileManagerContext;
5
+ }) => Table;
6
+ export default _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _dynamodbToolbox = require("dynamodb-toolbox");
11
+
12
+ var _configurations = _interopRequireDefault(require("../operations/configurations"));
13
+
14
+ var _utils = require("../operations/utils");
15
+
16
+ var _default = params => {
17
+ const {
18
+ context
19
+ } = params;
20
+ return new _dynamodbToolbox.Table({
21
+ name: _configurations.default.db().table || (0, _utils.getTable)(context),
22
+ partitionKey: "PK",
23
+ sortKey: "SK",
24
+ DocumentClient: (0, _utils.getDocumentClient)(context)
25
+ });
26
+ };
27
+
28
+ exports.default = _default;
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { FilesStorageOperationsProviderDdb } from "./operations/files";
2
+ import { SettingsStorageOperationsProviderDdbPlugin } from "./operations/settings";
3
+ import { SystemStorageOperationsProviderDdbPlugin } from "./operations/system";
4
+ declare const _default: () => (FilesStorageOperationsProviderDdb | SettingsStorageOperationsProviderDdbPlugin | SystemStorageOperationsProviderDdbPlugin)[];
5
+ export default _default;
package/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _files = require("./operations/files");
9
+
10
+ var _settings = require("./operations/settings");
11
+
12
+ var _system = require("./operations/system");
13
+
14
+ var _default = () => [new _files.FilesStorageOperationsProviderDdb(), new _settings.SettingsStorageOperationsProviderDdbPlugin(), new _system.SystemStorageOperationsProviderDdbPlugin()];
15
+
16
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ declare const _default: {
2
+ db: () => {
3
+ table: string;
4
+ keys: {
5
+ primary: boolean;
6
+ unique: boolean;
7
+ name: string;
8
+ fields: {
9
+ name: string;
10
+ }[];
11
+ }[];
12
+ };
13
+ };
14
+ export default _default;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ db: () => ({
9
+ table: process.env.DB_TABLE_FILE_MANGER || process.env.DB_TABLE,
10
+ keys: [{
11
+ primary: true,
12
+ unique: true,
13
+ name: "primary",
14
+ fields: [{
15
+ name: "PK"
16
+ }, {
17
+ name: "SK"
18
+ }]
19
+ }]
20
+ })
21
+ };
22
+ exports.default = _default;
@@ -0,0 +1,22 @@
1
+ import { File, FileManagerContext, FileManagerFilesStorageOperations, FileManagerFilesStorageOperationsCreateBatchParams, FileManagerFilesStorageOperationsCreateParams, FileManagerFilesStorageOperationsDeleteParams, FileManagerFilesStorageOperationsGetParams, FileManagerFilesStorageOperationsListParams, FileManagerFilesStorageOperationsListResponse, FileManagerFilesStorageOperationsTagsParams, FileManagerFilesStorageOperationsTagsResponse, FileManagerFilesStorageOperationsUpdateParams } from "@webiny/api-file-manager/types";
2
+ interface ConstructorParams {
3
+ context: FileManagerContext;
4
+ }
5
+ export declare class FilesStorageOperations implements FileManagerFilesStorageOperations {
6
+ private readonly _context;
7
+ private readonly table;
8
+ private readonly entity;
9
+ private get context();
10
+ constructor({ context }: ConstructorParams);
11
+ get(params: FileManagerFilesStorageOperationsGetParams): Promise<File | null>;
12
+ create(params: FileManagerFilesStorageOperationsCreateParams): Promise<File>;
13
+ update(params: FileManagerFilesStorageOperationsUpdateParams): Promise<File>;
14
+ delete(params: FileManagerFilesStorageOperationsDeleteParams): Promise<void>;
15
+ createBatch(params: FileManagerFilesStorageOperationsCreateBatchParams): Promise<File[]>;
16
+ list(params: FileManagerFilesStorageOperationsListParams): Promise<FileManagerFilesStorageOperationsListResponse>;
17
+ tags(params: FileManagerFilesStorageOperationsTagsParams): Promise<FileManagerFilesStorageOperationsTagsResponse>;
18
+ private createQueryAllOptions;
19
+ private createPartitionKey;
20
+ private createSortKey;
21
+ }
22
+ export {};