@aesop-fables/containr-dynamofx 0.1.0
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/LICENSE +21 -0
- package/README.md +14 -0
- package/lib/DynamoFactory.d.ts +4 -0
- package/lib/DynamoFactory.js +10 -0
- package/lib/DynamoServices.d.ts +5 -0
- package/lib/DynamoServices.js +8 -0
- package/lib/IDynamoOperation.d.ts +3 -0
- package/lib/IDynamoOperation.js +2 -0
- package/lib/IDynamoService.d.ts +10 -0
- package/lib/IDynamoService.js +13 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +17 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Aesop
|
|
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,14 @@
|
|
|
1
|
+
@aesop-fables/containr-dynamofx
|
|
2
|
+
|
|
3
|
+
Provides a common bootstrapping configuration for using DynamoDB in your Typescript applications (i.e., `Triginta` microservices).
|
|
4
|
+
|
|
5
|
+
## Sample Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const container = createContainer([
|
|
9
|
+
useDynamo({
|
|
10
|
+
// optionally pass in anything you would to DynamoDB from @aws-sdk/client-dynamodb
|
|
11
|
+
})
|
|
12
|
+
myCustomModule,
|
|
13
|
+
])
|
|
14
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoFactory = void 0;
|
|
4
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
5
|
+
class DynamoFactory {
|
|
6
|
+
static createFullClient(configuration) {
|
|
7
|
+
return new client_dynamodb_1.DynamoDB(configuration !== null && configuration !== void 0 ? configuration : {});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DynamoFactory = DynamoFactory;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IServiceContainer, Newable } from '@aesop-fables/containr';
|
|
2
|
+
import { IDynamoOperation } from './IDynamoOperation';
|
|
3
|
+
export interface IDynamoService {
|
|
4
|
+
execute<Result, Params>(constructor: Newable<IDynamoOperation<Result, Params>>, params?: Params): Promise<Result>;
|
|
5
|
+
}
|
|
6
|
+
export declare class DynamoService implements IDynamoService {
|
|
7
|
+
private readonly container;
|
|
8
|
+
constructor(container: IServiceContainer);
|
|
9
|
+
execute<Result, Params>(constructor: Newable<IDynamoOperation<Result, Params>>, params?: Params | undefined): Promise<Result>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoService = void 0;
|
|
4
|
+
class DynamoService {
|
|
5
|
+
constructor(container) {
|
|
6
|
+
this.container = container;
|
|
7
|
+
}
|
|
8
|
+
execute(constructor, params) {
|
|
9
|
+
const operation = this.container.resolve(constructor);
|
|
10
|
+
return operation.execute(params);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.DynamoService = DynamoService;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IServiceModule } from '@aesop-fables/containr';
|
|
2
|
+
import { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
3
|
+
import { TranslateConfig } from '@aws-sdk/lib-dynamodb';
|
|
4
|
+
import { DynamoFactory } from './DynamoFactory';
|
|
5
|
+
import { DynamoServices } from './DynamoServices';
|
|
6
|
+
import { DynamoService, IDynamoService } from './IDynamoService';
|
|
7
|
+
export { IDynamoService, DynamoService, DynamoFactory, DynamoServices };
|
|
8
|
+
export interface UseDynamoConfiguration {
|
|
9
|
+
core?: DynamoDBClientConfig;
|
|
10
|
+
documentTranslation?: TranslateConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare const useDynamo: (options: UseDynamoConfiguration) => IServiceModule;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDynamo = exports.DynamoServices = exports.DynamoFactory = exports.DynamoService = void 0;
|
|
4
|
+
const containr_1 = require("@aesop-fables/containr");
|
|
5
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
6
|
+
const DynamoFactory_1 = require("./DynamoFactory");
|
|
7
|
+
Object.defineProperty(exports, "DynamoFactory", { enumerable: true, get: function () { return DynamoFactory_1.DynamoFactory; } });
|
|
8
|
+
const DynamoServices_1 = require("./DynamoServices");
|
|
9
|
+
Object.defineProperty(exports, "DynamoServices", { enumerable: true, get: function () { return DynamoServices_1.DynamoServices; } });
|
|
10
|
+
const IDynamoService_1 = require("./IDynamoService");
|
|
11
|
+
Object.defineProperty(exports, "DynamoService", { enumerable: true, get: function () { return IDynamoService_1.DynamoService; } });
|
|
12
|
+
exports.useDynamo = (0, containr_1.createServiceModuleWithOptions)('useDynamo', (services, options) => {
|
|
13
|
+
const client = DynamoFactory_1.DynamoFactory.createFullClient(options.core);
|
|
14
|
+
services.register(DynamoServices_1.DynamoServices.Service, (container) => new IDynamoService_1.DynamoService(container));
|
|
15
|
+
services.register(DynamoServices_1.DynamoServices.Client, client);
|
|
16
|
+
services.register(DynamoServices_1.DynamoServices.DocClient, lib_dynamodb_1.DynamoDBDocumentClient.from(client, options === null || options === void 0 ? void 0 : options.documentTranslation));
|
|
17
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aesop-fables/containr-dynamofx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A collection of services and utilities to make DynamoDb development easier",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
9
|
+
"default": "./lib/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./lib/index.js",
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rimraf ./lib && tsc --p ./tsconfig.build.json",
|
|
16
|
+
"format": "prettier --write \"src/**/*.(js|ts)\"",
|
|
17
|
+
"lint": "eslint src --ext .js,.ts",
|
|
18
|
+
"lint:fix": "eslint src --fix --ext .js,.ts",
|
|
19
|
+
"test": "jest --config jest.config.js",
|
|
20
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
21
|
+
"preversion": "npm run lint",
|
|
22
|
+
"version": "npm run format && git add -A src",
|
|
23
|
+
"postversion": "git push && git push --tags"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@aesop-fables/containr": "^0.2.0",
|
|
27
|
+
"@aws-sdk/client-dynamodb": "^3.267.0",
|
|
28
|
+
"@aws-sdk/lib-dynamodb": "^3.267.0",
|
|
29
|
+
"@types/aws-lambda": "^8.10.110",
|
|
30
|
+
"aws-sdk": "^2.1311.0",
|
|
31
|
+
"reflect-metadata": "^0.1.13"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "^29.2.4",
|
|
35
|
+
"@types/node": "^18.11.11",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.45.1",
|
|
37
|
+
"@typescript-eslint/parser": "5.45.0",
|
|
38
|
+
"esbuild": "^0.16.2",
|
|
39
|
+
"eslint": "8.29.0",
|
|
40
|
+
"eslint-config-prettier": "^8.5.0",
|
|
41
|
+
"eslint-plugin-jest": "27.1.6",
|
|
42
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
43
|
+
"jest": "29.3.1",
|
|
44
|
+
"jest-environment-jsdom": "^29.3.1",
|
|
45
|
+
"prettier": "^2.8.1",
|
|
46
|
+
"ts-jest": "29.0.5",
|
|
47
|
+
"typescript": "4.9.3"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"lib/**/*"
|
|
51
|
+
]
|
|
52
|
+
}
|