@nr1e/aws 0.0.6 → 1.0.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.
@@ -0,0 +1,18 @@
1
+ import { unmarshall } from '@aws-sdk/util-dynamodb';
2
+ import { AttributeValue, StreamRecord } from 'aws-lambda';
3
+ export { unmarshall, StreamRecord, AttributeValue };
4
+ export type AttributeValueMap = {
5
+ [key: string]: AttributeValue;
6
+ };
7
+ export declare function unmarshallAttributeValueMap<T>(map?: AttributeValueMap): T | undefined;
8
+ export interface UnmarshalledStreamRecord {
9
+ ApproximateCreationDateTime?: number | undefined;
10
+ Keys?: object;
11
+ NewImage?: object;
12
+ OldImage?: object;
13
+ SequenceNumber?: string | undefined;
14
+ SizeBytes?: number | undefined;
15
+ StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES' | undefined;
16
+ }
17
+ export declare function unmarshallStreamRecord(record: StreamRecord): UnmarshalledStreamRecord;
18
+ //# sourceMappingURL=dynamodb-stream.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamodb-stream.d.mts","sourceRoot":"","sources":["../src/dynamodb-stream.mts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAC,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAC,CAAC;AAEhE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,GAAG,CAAC,EAAE,iBAAiB,GACtB,CAAC,GAAG,SAAS,CAMf;AAED,MAAM,WAAW,wBAAwB;IACvC,2BAA2B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,cAAc,CAAC,EACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,oBAAoB,GACpB,SAAS,CAAC;CACf;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,GACnB,wBAAwB,CAO1B"}
@@ -0,0 +1,18 @@
1
+ import { unmarshall } from '@aws-sdk/util-dynamodb';
2
+ export { unmarshall };
3
+ export function unmarshallAttributeValueMap(map) {
4
+ if (!map) {
5
+ return undefined;
6
+ }
7
+ // The cast is necessary since there is an AttributeType defined in the client as well as lambda libraries
8
+ return unmarshall(map);
9
+ }
10
+ export function unmarshallStreamRecord(record) {
11
+ return {
12
+ ...record,
13
+ Keys: unmarshallAttributeValueMap(record.Keys),
14
+ NewImage: unmarshallAttributeValueMap(record.NewImage),
15
+ OldImage: unmarshallAttributeValueMap(record.OldImage),
16
+ };
17
+ }
18
+ //# sourceMappingURL=dynamodb-stream.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamodb-stream.mjs","sourceRoot":"","sources":["../src/dynamodb-stream.mts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAIlD,OAAO,EAAC,UAAU,EAA+B,CAAC;AAIlD,MAAM,UAAU,2BAA2B,CACzC,GAAuB;IAEvB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,0GAA0G;IAC1G,OAAO,UAAU,CAAC,GAA8C,CAAM,CAAC;AACzE,CAAC;AAiBD,MAAM,UAAU,sBAAsB,CACpC,MAAoB;IAEpB,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9C,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtD,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC;KACvD,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { test, expect } from 'vitest';
2
- test('Empty test', () => {
2
+ test('Empty test @unit', () => {
3
3
  expect(true).toBe(true);
4
4
  });
5
5
  //# sourceMappingURL=empty.test.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"empty.test.mjs","sourceRoot":"","sources":["../src/empty.test.mts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,QAAQ,CAAC;AAEpC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IACtB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"empty.test.mjs","sourceRoot":"","sources":["../src/empty.test.mts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,QAAQ,CAAC;AAEpC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
- export * from './event-bridge.mjs';
2
1
  export * from './dynamodb.mjs';
2
+ export * from './dynamodb-stream.mjs';
3
+ export * from './event-bridge.mjs';
4
+ export * from './lambda.mjs';
3
5
  export * from './region.mjs';
4
6
  export * from './s3.mjs';
5
7
  export * from './secrets-manager.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,7 @@
1
- export * from './event-bridge.mjs';
2
1
  export * from './dynamodb.mjs';
2
+ export * from './dynamodb-stream.mjs';
3
+ export * from './event-bridge.mjs';
4
+ export * from './lambda.mjs';
3
5
  export * from './region.mjs';
4
6
  export * from './s3.mjs';
5
7
  export * from './secrets-manager.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { LambdaClient, GetFunctionCommand, GetFunctionCommandInput, GetFunctionCommandOutput } from '@aws-sdk/client-lambda';
2
+ export { GetFunctionCommand, GetFunctionCommandInput, GetFunctionCommandOutput };
3
+ export declare function getLambdaClient(region?: string): LambdaClient;
4
+ export declare function getCodeSizeBytes(functionName: string, client?: LambdaClient): Promise<number | null>;
5
+ export declare function getFunction(functionName: string, client?: LambdaClient): Promise<GetFunctionCommandOutput | null>;
6
+ //# sourceMappingURL=lambda.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.d.mts","sourceRoot":"","sources":["../src/lambda.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAC,CAAC;AAI/E,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAQ7D;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED,wBAAsB,WAAW,CAC/B,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAgB1C"}
@@ -0,0 +1,34 @@
1
+ import { LambdaClient, GetFunctionCommand, ResourceNotFoundException, } from '@aws-sdk/client-lambda';
2
+ import { getAwsRegion } from './region.mjs';
3
+ export { GetFunctionCommand };
4
+ const lambdaClients = new Map();
5
+ export function getLambdaClient(region) {
6
+ const regionKey = region || getAwsRegion();
7
+ let client = lambdaClients.get(regionKey);
8
+ if (!client) {
9
+ client = new LambdaClient({ region: regionKey });
10
+ lambdaClients.set(regionKey, client);
11
+ }
12
+ return client;
13
+ }
14
+ export async function getCodeSizeBytes(functionName, client) {
15
+ const response = await getFunction(functionName, client);
16
+ return response?.Configuration?.CodeSize || null;
17
+ }
18
+ export async function getFunction(functionName, client) {
19
+ if (!client) {
20
+ client = getLambdaClient();
21
+ }
22
+ try {
23
+ return await client.send(new GetFunctionCommand({
24
+ FunctionName: functionName,
25
+ }));
26
+ }
27
+ catch (e) {
28
+ if (e instanceof ResourceNotFoundException) {
29
+ return null;
30
+ }
31
+ throw e;
32
+ }
33
+ }
34
+ //# sourceMappingURL=lambda.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.mjs","sourceRoot":"","sources":["../src/lambda.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAGlB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,kBAAkB,EAAoD,CAAC;AAE/E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,MAAM,SAAS,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC;IAC3C,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;QAC/C,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,YAAoB,EACpB,MAAqB;IAErB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACzD,OAAO,QAAQ,EAAE,aAAa,EAAE,QAAQ,IAAI,IAAI,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,YAAoB,EACpB,MAAqB;IAErB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,eAAe,EAAE,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,IAAI,CACtB,IAAI,kBAAkB,CAAC;YACrB,YAAY,EAAE,YAAY;SAC3B,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,yBAAyB,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lambda.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.test.d.mts","sourceRoot":"","sources":["../src/lambda.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { test } from 'vitest';
2
+ import { getCodeSizeBytes } from './lambda.mjs';
3
+ test('Test getCodeSizeBytes @none', async () => {
4
+ const bytes = await getCodeSizeBytes('Platform-DevOhio-Core-GraphA02F0199-Phk5ToXVOcmc');
5
+ console.log(bytes);
6
+ });
7
+ //# sourceMappingURL=lambda.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda.test.mjs","sourceRoot":"","sources":["../src/lambda.test.mts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAE9C,IAAI,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;IAC7C,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAClC,kDAAkD,CACnD,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nr1e/aws",
3
3
  "description": "Provides common AWS utilities",
4
- "version": "0.0.6",
4
+ "version": "1.0.0",
5
5
  "type": "module",
6
6
  "author": "NR1E, Inc.",
7
7
  "publishConfig": {
@@ -25,14 +25,17 @@
25
25
  "vitest": "4.0.6"
26
26
  },
27
27
  "dependencies": {
28
+ "@types/aws-lambda": "8.10.152",
28
29
  "@aws-sdk/client-dynamodb": "3.958.0",
29
30
  "@aws-sdk/client-eventbridge": "3.958.0",
31
+ "@aws-sdk/client-lambda": "3.958.0",
30
32
  "@aws-sdk/client-s3": "3.958.0",
31
33
  "@aws-sdk/client-secrets-manager": "3.958.0",
32
34
  "@aws-sdk/client-ses": "3.958.0",
33
35
  "@aws-sdk/client-sqs": "3.958.0",
34
36
  "@aws-sdk/lib-dynamodb": "3.958.0",
35
37
  "@aws-sdk/s3-request-presigner": "3.958.0",
38
+ "@aws-sdk/util-dynamodb": "3.958.0",
36
39
  "@nr1e/commons": ""
37
40
  },
38
41
  "exports": {
@@ -42,10 +45,12 @@
42
45
  }
43
46
  },
44
47
  "scripts": {
45
- "build": "tsc",
46
48
  "prebuild": "prettier --check . && eslint .",
49
+ "build": "tsc",
47
50
  "watch": "tsc -w",
48
- "test": "vitest run",
51
+ "test": "vitest run -t @unit src",
52
+ "test:int": "dotenv -- vitest run -t @int src",
53
+ "test:only": "dotenv -- vitest run -t @only src",
49
54
  "clean": "rm -rf dist",
50
55
  "fmt": "prettier --write ."
51
56
  }