@bubltec/mycota-dynamo 1.2.0 → 1.4.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/dist/aws-client-defaults.d.ts +21 -0
- package/dist/aws-client-defaults.d.ts.map +1 -0
- package/dist/aws-client-defaults.js +14 -0
- package/dist/aws-client-defaults.js.map +1 -0
- package/dist/dynamo.module.d.ts +9 -1
- package/dist/dynamo.module.d.ts.map +1 -1
- package/dist/dynamo.module.js +28 -20
- package/dist/dynamo.module.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Resilience knobs for AWS SDK clients. Every field is optional; see the defaults below. */
|
|
2
|
+
export interface AwsClientSettings {
|
|
3
|
+
/** Total attempts per call, including the first. Default 3. */
|
|
4
|
+
maxAttempts?: number;
|
|
5
|
+
/** Max time to open a connection. Default 3000. */
|
|
6
|
+
connectionTimeoutMs?: number;
|
|
7
|
+
/** Max time to wait for a response on an open connection. Default 10000. */
|
|
8
|
+
requestTimeoutMs?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Settings to spread into an AWS SDK client config. The SDK retries 3 times by default but
|
|
12
|
+
* has no request or connection timeout, so a hung socket would otherwise block forever.
|
|
13
|
+
*/
|
|
14
|
+
export declare function awsClientDefaults(settings?: AwsClientSettings, fallbackRequestTimeoutMs?: number): {
|
|
15
|
+
maxAttempts: number;
|
|
16
|
+
requestHandler: {
|
|
17
|
+
connectionTimeout: number;
|
|
18
|
+
requestTimeout: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=aws-client-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-client-defaults.d.ts","sourceRoot":"","sources":["../src/aws-client-defaults.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,GAAE,iBAAsB,EAAE,wBAAwB,SAAS;IAEjG,WAAW;IACX,cAAc;QACZ,iBAAiB;QACjB,cAAc;;EAGnB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings to spread into an AWS SDK client config. The SDK retries 3 times by default but
|
|
3
|
+
* has no request or connection timeout, so a hung socket would otherwise block forever.
|
|
4
|
+
*/
|
|
5
|
+
export function awsClientDefaults(settings = {}, fallbackRequestTimeoutMs = 10_000) {
|
|
6
|
+
return {
|
|
7
|
+
maxAttempts: settings.maxAttempts ?? 3,
|
|
8
|
+
requestHandler: {
|
|
9
|
+
connectionTimeout: settings.connectionTimeoutMs ?? 3_000,
|
|
10
|
+
requestTimeout: settings.requestTimeoutMs ?? fallbackRequestTimeoutMs,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=aws-client-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-client-defaults.js","sourceRoot":"","sources":["../src/aws-client-defaults.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAQ,GAAsB,EAAE,EAAE,wBAAwB,GAAG,MAAM;IACnG,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,CAAC;QACtC,cAAc,EAAE;YACd,iBAAiB,EAAE,QAAQ,CAAC,mBAAmB,IAAI,KAAK;YACxD,cAAc,EAAE,QAAQ,CAAC,gBAAgB,IAAI,wBAAwB;SACtE;KACF,CAAC;AACJ,CAAC"}
|
package/dist/dynamo.module.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { type AwsClientSettings } from './aws-client-defaults.js';
|
|
3
|
+
export interface DynamoModuleOptions {
|
|
4
|
+
/** Timeout and retry settings for the DynamoDB client. */
|
|
5
|
+
aws?: AwsClientSettings;
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* Points at DynamoDB Local when DYNAMODB_ENDPOINT is set (local dev), or real
|
|
3
|
-
* DynamoDB via the Lambda execution role otherwise.
|
|
9
|
+
* DynamoDB via the Lambda execution role otherwise. Import `DynamoModule` for the
|
|
10
|
+
* defaults, or `DynamoModule.forRoot({ aws })` to tune timeouts and retries.
|
|
4
11
|
*/
|
|
5
12
|
export declare class DynamoModule {
|
|
13
|
+
static forRoot(options?: DynamoModuleOptions): DynamicModule;
|
|
6
14
|
}
|
|
7
15
|
//# sourceMappingURL=dynamo.module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo.module.d.ts","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamo.module.d.ts","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGrF,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAgBD;;;;GAIG;AACH,qBAKa,YAAY;IACvB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,aAAa,CAO/D;CACF"}
|
package/dist/dynamo.module.js
CHANGED
|
@@ -4,36 +4,44 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var DynamoModule_1;
|
|
7
8
|
import { Global, Module } from '@nestjs/common';
|
|
8
9
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
9
10
|
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
11
|
+
import { awsClientDefaults } from './aws-client-defaults.js';
|
|
10
12
|
import { DYNAMO_DOC_CLIENT } from './dynamo.constants.js';
|
|
13
|
+
function createDocClient(options = {}) {
|
|
14
|
+
const endpoint = process.env.DYNAMODB_ENDPOINT;
|
|
15
|
+
const client = new DynamoDBClient({
|
|
16
|
+
region: process.env.AWS_REGION ?? 'us-east-1',
|
|
17
|
+
...awsClientDefaults(options.aws),
|
|
18
|
+
...(endpoint
|
|
19
|
+
? { endpoint, credentials: { accessKeyId: 'local', secretAccessKey: 'local' } }
|
|
20
|
+
: {}),
|
|
21
|
+
});
|
|
22
|
+
return DynamoDBDocumentClient.from(client, {
|
|
23
|
+
marshallOptions: { removeUndefinedValues: true },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
11
26
|
/**
|
|
12
27
|
* Points at DynamoDB Local when DYNAMODB_ENDPOINT is set (local dev), or real
|
|
13
|
-
* DynamoDB via the Lambda execution role otherwise.
|
|
28
|
+
* DynamoDB via the Lambda execution role otherwise. Import `DynamoModule` for the
|
|
29
|
+
* defaults, or `DynamoModule.forRoot({ aws })` to tune timeouts and retries.
|
|
14
30
|
*/
|
|
15
|
-
let DynamoModule = class DynamoModule {
|
|
31
|
+
let DynamoModule = DynamoModule_1 = class DynamoModule {
|
|
32
|
+
static forRoot(options = {}) {
|
|
33
|
+
return {
|
|
34
|
+
module: DynamoModule_1,
|
|
35
|
+
global: true,
|
|
36
|
+
providers: [{ provide: DYNAMO_DOC_CLIENT, useFactory: () => createDocClient(options) }],
|
|
37
|
+
exports: [DYNAMO_DOC_CLIENT],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
16
40
|
};
|
|
17
|
-
DynamoModule = __decorate([
|
|
41
|
+
DynamoModule = DynamoModule_1 = __decorate([
|
|
18
42
|
Global(),
|
|
19
43
|
Module({
|
|
20
|
-
providers: [
|
|
21
|
-
{
|
|
22
|
-
provide: DYNAMO_DOC_CLIENT,
|
|
23
|
-
useFactory: () => {
|
|
24
|
-
const endpoint = process.env.DYNAMODB_ENDPOINT;
|
|
25
|
-
const client = new DynamoDBClient({
|
|
26
|
-
region: process.env.AWS_REGION ?? 'us-east-1',
|
|
27
|
-
...(endpoint
|
|
28
|
-
? { endpoint, credentials: { accessKeyId: 'local', secretAccessKey: 'local' } }
|
|
29
|
-
: {}),
|
|
30
|
-
});
|
|
31
|
-
return DynamoDBDocumentClient.from(client, {
|
|
32
|
-
marshallOptions: { removeUndefinedValues: true },
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
44
|
+
providers: [{ provide: DYNAMO_DOC_CLIENT, useFactory: () => createDocClient() }],
|
|
37
45
|
exports: [DYNAMO_DOC_CLIENT],
|
|
38
46
|
})
|
|
39
47
|
], DynamoModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo.module.js","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamo.module.js","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAA0B,MAAM,0BAA0B,CAAC;AACrF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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { DynamoModule } from './dynamo.module.js';
|
|
1
|
+
export { DynamoModule, type DynamoModuleOptions } from './dynamo.module.js';
|
|
2
2
|
export { DYNAMO_DOC_CLIENT } from './dynamo.constants.js';
|
|
3
3
|
export { stripDynamoKeys } from './dynamo.utils.js';
|
|
4
|
+
export { awsClientDefaults, type AwsClientSettings } from './aws-client-defaults.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAA0B,MAAM,0BAA0B,CAAC"}
|