@bubltec/mycota-dynamo 0.0.1-next.10

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Genome
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.
@@ -0,0 +1,2 @@
1
+ export declare const DYNAMO_DOC_CLIENT: unique symbol;
2
+ //# sourceMappingURL=dynamo.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.constants.d.ts","sourceRoot":"","sources":["../src/dynamo.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,eAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const DYNAMO_DOC_CLIENT = Symbol('DYNAMO_DOC_CLIENT');
2
+ //# sourceMappingURL=dynamo.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.constants.js","sourceRoot":"","sources":["../src/dynamo.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Points at DynamoDB Local when DYNAMODB_ENDPOINT is set (local dev), or real
3
+ * DynamoDB via the Lambda execution role otherwise.
4
+ */
5
+ export declare class DynamoModule {
6
+ }
7
+ //# sourceMappingURL=dynamo.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.module.d.ts","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAqBa,YAAY;CAAG"}
@@ -0,0 +1,41 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Global, Module } from '@nestjs/common';
8
+ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
9
+ import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
10
+ import { DYNAMO_DOC_CLIENT } from './dynamo.constants.js';
11
+ /**
12
+ * Points at DynamoDB Local when DYNAMODB_ENDPOINT is set (local dev), or real
13
+ * DynamoDB via the Lambda execution role otherwise.
14
+ */
15
+ let DynamoModule = class DynamoModule {
16
+ };
17
+ DynamoModule = __decorate([
18
+ Global(),
19
+ 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
+ ],
37
+ exports: [DYNAMO_DOC_CLIENT],
38
+ })
39
+ ], DynamoModule);
40
+ export { DynamoModule };
41
+ //# sourceMappingURL=dynamo.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.module.js","sourceRoot":"","sources":["../src/dynamo.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AAsBI,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IArBxB,MAAM,EAAE;IACR,MAAM,CAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,UAAU,EAAE,GAAG,EAAE;oBACf,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;oBAC/C,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC;wBAChC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;wBAC7C,GAAG,CAAC,QAAQ;4BACV,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE;4BAC/E,CAAC,CAAC,EAAE,CAAC;qBACR,CAAC,CAAC;oBACH,OAAO,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE;wBACzC,eAAe,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE;qBACjD,CAAC,CAAC;gBACL,CAAC;aACF;SACF;QACD,OAAO,EAAE,CAAC,iBAAiB,CAAC;KAC7B,CAAC;GACW,YAAY,CAAG"}
@@ -0,0 +1,5 @@
1
+ declare const DYNAMO_KEYS: readonly ["PK", "SK", "GSI1PK", "GSI1SK", "GSI2PK", "GSI2SK"];
2
+ /** Strips DynamoDB's own key/index attributes before returning an item over the public API. */
3
+ export declare function stripDynamoKeys<T extends Record<string, unknown>>(item: T): Omit<T, (typeof DYNAMO_KEYS)[number]>;
4
+ export {};
5
+ //# sourceMappingURL=dynamo.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.utils.d.ts","sourceRoot":"","sources":["../src/dynamo.utils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW,+DAAgE,CAAC;AAElF,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,IAAI,EAAE,CAAC,GACN,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAIvC"}
@@ -0,0 +1,9 @@
1
+ const DYNAMO_KEYS = ['PK', 'SK', 'GSI1PK', 'GSI1SK', 'GSI2PK', 'GSI2SK'];
2
+ /** Strips DynamoDB's own key/index attributes before returning an item over the public API. */
3
+ export function stripDynamoKeys(item) {
4
+ const clean = { ...item };
5
+ for (const key of DYNAMO_KEYS)
6
+ delete clean[key];
7
+ return clean;
8
+ }
9
+ //# sourceMappingURL=dynamo.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.utils.js","sourceRoot":"","sources":["../src/dynamo.utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAElF,+FAA+F;AAC/F,MAAM,UAAU,eAAe,CAC7B,IAAO;IAEP,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,WAAW;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dynamo.utils.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.utils.spec.d.ts","sourceRoot":"","sources":["../src/dynamo.utils.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { stripDynamoKeys } from './dynamo.utils.js';
3
+ describe('stripDynamoKeys', () => {
4
+ it('removes every DynamoDB key/index attribute', () => {
5
+ const item = {
6
+ id: 'abc',
7
+ name: 'Chocolate',
8
+ PK: 'THING#abc',
9
+ SK: 'META',
10
+ GSI1PK: 'THINGTYPE#food',
11
+ GSI1SK: 'THING#Chocolate',
12
+ GSI2PK: 'STATUS#pending',
13
+ GSI2SK: 'CONTRIB#2026',
14
+ };
15
+ expect(stripDynamoKeys(item)).toEqual({ id: 'abc', name: 'Chocolate' });
16
+ });
17
+ it('is a no-op when none of the key attributes are present', () => {
18
+ const item = { id: 'abc', name: 'Chocolate' };
19
+ expect(stripDynamoKeys(item)).toEqual(item);
20
+ });
21
+ });
22
+ //# sourceMappingURL=dynamo.utils.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamo.utils.spec.js","sourceRoot":"","sources":["../src/dynamo.utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,IAAI,GAAG;YACX,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,WAAW;YACjB,EAAE,EAAE,WAAW;YACf,EAAE,EAAE,MAAM;YACV,MAAM,EAAE,gBAAgB;YACxB,MAAM,EAAE,iBAAiB;YACzB,MAAM,EAAE,gBAAgB;YACxB,MAAM,EAAE,cAAc;SACvB,CAAC;QAEF,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC9C,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { DynamoModule } from './dynamo.module.js';
2
+ export { DYNAMO_DOC_CLIENT } from './dynamo.constants.js';
3
+ export { stripDynamoKeys } from './dynamo.utils.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { DynamoModule } from './dynamo.module.js';
2
+ export { DYNAMO_DOC_CLIENT } from './dynamo.constants.js';
3
+ export { stripDynamoKeys } from './dynamo.utils.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@bubltec/mycota-dynamo",
3
+ "version": "0.0.1-next.10",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "@aws-sdk/client-dynamodb": "^3.716.0",
21
+ "@aws-sdk/lib-dynamodb": "^3.716.0",
22
+ "@nestjs/common": "^10.4.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^22.10.0",
26
+ "typescript": "^5.8.0",
27
+ "vitest": "^2.1.0"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -b",
31
+ "typecheck": "tsc -b --noEmit",
32
+ "lint": "oxlint -c ../../.oxlintrc.json src",
33
+ "test": "vitest run"
34
+ }
35
+ }