@bifravst/aws-cdk-lambda-helpers 1.2.1 → 1.2.3

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 (76) hide show
  1. package/dist/cdk/TestApp.d.ts +5 -0
  2. package/dist/cdk/TestApp.js +12 -0
  3. package/dist/cdk/TestStack.d.ts +12 -0
  4. package/dist/cdk/TestStack.js +39 -0
  5. package/dist/cdk/baseLayer.d.ts +2 -0
  6. package/dist/cdk/baseLayer.js +5 -0
  7. package/dist/cdk/e2e.js +11 -0
  8. package/dist/cdk/lambda.d.ts +2 -0
  9. package/dist/cdk/lambda.js +5 -0
  10. package/dist/cdk/packTestLambdas.d.ts +5 -0
  11. package/dist/cdk/packTestLambdas.js +4 -0
  12. package/dist/e2e.spec.js +17 -0
  13. package/dist/lambdas/test.zip +0 -0
  14. package/dist/layers/baseLayer/nodejs/node_modules/.package-lock.json +16 -0
  15. package/dist/layers/baseLayer/nodejs/node_modules/id128/CHANGES +20 -0
  16. package/dist/layers/baseLayer/nodejs/node_modules/id128/LICENSE +18 -0
  17. package/dist/layers/baseLayer/nodejs/node_modules/id128/README.md +853 -0
  18. package/dist/layers/baseLayer/nodejs/node_modules/id128/index.d.ts +167 -0
  19. package/dist/layers/baseLayer/nodejs/node_modules/id128/index.js +49 -0
  20. package/dist/layers/baseLayer/nodejs/node_modules/id128/package.json +68 -0
  21. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/coder/base.js +53 -0
  22. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/coder/crockford32.js +114 -0
  23. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/coder/hex.js +63 -0
  24. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/coder/uuid.js +77 -0
  25. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/byte-array.js +26 -0
  26. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/epoch-converter.js +32 -0
  27. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/exception.js +18 -0
  28. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/fake-machine.js +26 -0
  29. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/machine.js +37 -0
  30. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/random-bytes-browser.js +9 -0
  31. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/common/random-bytes.js +17 -0
  32. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/factory/id.js +96 -0
  33. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/factory/versioned-id.js +72 -0
  34. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/base.js +39 -0
  35. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/ulid-monotonic.js +71 -0
  36. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/ulid.js +64 -0
  37. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/uuid-1.js +149 -0
  38. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/uuid-4.js +24 -0
  39. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/uuid-6.js +146 -0
  40. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/uuid-nil.js +33 -0
  41. package/dist/layers/baseLayer/nodejs/node_modules/id128/src/id/uuid.js +58 -0
  42. package/dist/layers/baseLayer/nodejs/node_modules/id128/utils.js +35 -0
  43. package/dist/layers/baseLayer/nodejs/package-lock.json +6671 -0
  44. package/dist/layers/baseLayer/nodejs/package.json +1 -0
  45. package/dist/layers/baseLayer.zip +0 -0
  46. package/dist/src/checkSumOfFiles.spec.d.ts +1 -0
  47. package/dist/src/commonParent.spec.d.ts +1 -0
  48. package/dist/{packLambda.d.ts → src/packLambda.d.ts} +2 -2
  49. package/package.json +20 -14
  50. /package/dist/{checkSumOfFiles.spec.d.ts → cdk/e2e.d.ts} +0 -0
  51. /package/dist/{commonParent.spec.d.ts → e2e.spec.d.ts} +0 -0
  52. /package/dist/{LambdaLogGroup.d.ts → src/LambdaLogGroup.d.ts} +0 -0
  53. /package/dist/{LambdaLogGroup.js → src/LambdaLogGroup.js} +0 -0
  54. /package/dist/{LambdaSource.d.ts → src/LambdaSource.d.ts} +0 -0
  55. /package/dist/{LambdaSource.js → src/LambdaSource.js} +0 -0
  56. /package/dist/{cdk.d.ts → src/cdk.d.ts} +0 -0
  57. /package/dist/{cdk.js → src/cdk.js} +0 -0
  58. /package/dist/{checkSumOfFiles.spec.js → src/checkSumOfFiles.spec.js} +0 -0
  59. /package/dist/{checksumOfFiles.d.ts → src/checksumOfFiles.d.ts} +0 -0
  60. /package/dist/{checksumOfFiles.js → src/checksumOfFiles.js} +0 -0
  61. /package/dist/{commonParent.d.ts → src/commonParent.d.ts} +0 -0
  62. /package/dist/{commonParent.js → src/commonParent.js} +0 -0
  63. /package/dist/{commonParent.spec.js → src/commonParent.spec.js} +0 -0
  64. /package/dist/{findDependencies.d.ts → src/findDependencies.d.ts} +0 -0
  65. /package/dist/{findDependencies.js → src/findDependencies.js} +0 -0
  66. /package/dist/{lambda.d.ts → src/lambda.d.ts} +0 -0
  67. /package/dist/{lambda.js → src/lambda.js} +0 -0
  68. /package/dist/{layer.d.ts → src/layer.d.ts} +0 -0
  69. /package/dist/{layer.js → src/layer.js} +0 -0
  70. /package/dist/{packLambda.js → src/packLambda.js} +0 -0
  71. /package/dist/{packLambdaFromPath.d.ts → src/packLambdaFromPath.d.ts} +0 -0
  72. /package/dist/{packLambdaFromPath.js → src/packLambdaFromPath.js} +0 -0
  73. /package/dist/{packLayer.d.ts → src/packLayer.d.ts} +0 -0
  74. /package/dist/{packLayer.js → src/packLayer.js} +0 -0
  75. /package/dist/{util.d.ts → src/util.d.ts} +0 -0
  76. /package/dist/{util.js → src/util.js} +0 -0
@@ -0,0 +1,5 @@
1
+ import { App } from 'aws-cdk-lib';
2
+ import { TestStack } from './TestStack.js';
3
+ export declare class TestApp extends App {
4
+ constructor(id: string, args: ConstructorParameters<typeof TestStack>[2]);
5
+ }
@@ -0,0 +1,12 @@
1
+ import { App } from 'aws-cdk-lib';
2
+ import { TestStack } from './TestStack.js';
3
+ export class TestApp extends App {
4
+ constructor(id, args) {
5
+ super({
6
+ context: {
7
+ isTest: true,
8
+ },
9
+ });
10
+ new TestStack(this, id, args);
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import { App, Stack } from 'aws-cdk-lib';
2
+ import type { PackedLayer } from '../src/layer.js';
3
+ import type { TestLambdas } from './packTestLambdas.js';
4
+ export declare class TestStack extends Stack {
5
+ constructor(parent: App, id: string, { lambdaSources, layer, }: {
6
+ lambdaSources: TestLambdas;
7
+ layer: PackedLayer;
8
+ });
9
+ }
10
+ export type StackOutputs = {
11
+ lambdaURL: string;
12
+ };
@@ -0,0 +1,39 @@
1
+ import { App, CfnOutput, Duration, aws_lambda as Lambda, Stack, } from 'aws-cdk-lib';
2
+ import { LambdaLogGroup, LambdaSource } from '../src/cdk.js';
3
+ export class TestStack extends Stack {
4
+ constructor(parent, id, { lambdaSources, layer, }) {
5
+ super(parent, id, {});
6
+ const baseLayer = new Lambda.LayerVersion(this, 'baseLayer', {
7
+ layerVersionName: `${Stack.of(this).stackName}-baseLayer`,
8
+ code: new LambdaSource(this, {
9
+ id: 'baseLayer',
10
+ zipFile: layer.layerZipFile,
11
+ hash: layer.hash,
12
+ }).code,
13
+ compatibleArchitectures: [Lambda.Architecture.ARM_64],
14
+ compatibleRuntimes: [Lambda.Runtime.NODEJS_20_X],
15
+ });
16
+ const fn = new Lambda.Function(this, 'fn', {
17
+ handler: lambdaSources.test.handler,
18
+ architecture: Lambda.Architecture.ARM_64,
19
+ runtime: Lambda.Runtime.NODEJS_20_X,
20
+ timeout: Duration.seconds(1),
21
+ memorySize: 1792,
22
+ code: new LambdaSource(this, lambdaSources.test).code,
23
+ description: 'Returns a ULID',
24
+ environment: {
25
+ NODE_NO_WARNINGS: '1',
26
+ },
27
+ layers: [baseLayer],
28
+ ...new LambdaLogGroup(this, 'fnLogs'),
29
+ });
30
+ const url = fn.addFunctionUrl({
31
+ authType: Lambda.FunctionUrlAuthType.NONE,
32
+ });
33
+ new CfnOutput(this, 'lambdaURL', {
34
+ exportName: `${this.stackName}:lambdaURL`,
35
+ description: 'API endpoint',
36
+ value: url.url,
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,2 @@
1
+ import { type PackedLayer } from '../src/layer.js';
2
+ export declare const pack: () => Promise<PackedLayer>;
@@ -0,0 +1,5 @@
1
+ import { packLayer } from '../src/layer.js';
2
+ export const pack = async () => packLayer({
3
+ id: 'baseLayer',
4
+ dependencies: ['id128'],
5
+ });
@@ -0,0 +1,11 @@
1
+ import { TestApp } from './TestApp.js';
2
+ import { pack as packBaseLayer } from './baseLayer.js';
3
+ import { packTestLambdas } from './packTestLambdas.js';
4
+ import { fromEnv } from '@nordicsemiconductor/from-env';
5
+ const { stackName } = fromEnv({
6
+ stackName: 'STACK_NAME',
7
+ })(process.env);
8
+ new TestApp(stackName, {
9
+ lambdaSources: await packTestLambdas(),
10
+ layer: await packBaseLayer(),
11
+ });
@@ -0,0 +1,2 @@
1
+ import type { APIGatewayProxyResultV2 } from 'aws-lambda';
2
+ export declare const handler: () => Promise<APIGatewayProxyResultV2>;
@@ -0,0 +1,5 @@
1
+ import id128 from 'id128';
2
+ export const handler = async () => ({
3
+ statusCode: 201,
4
+ body: id128.Ulid.generate().toCanonical(),
5
+ });
@@ -0,0 +1,5 @@
1
+ import type { PackedLambda } from '../src/packLambda.js';
2
+ export type TestLambdas = {
3
+ test: PackedLambda;
4
+ };
5
+ export declare const packTestLambdas: () => Promise<TestLambdas>;
@@ -0,0 +1,4 @@
1
+ import { packLambdaFromPath } from '../src/packLambdaFromPath.js';
2
+ export const packTestLambdas = async () => ({
3
+ test: await packLambdaFromPath('test', 'cdk/lambda.ts'),
4
+ });
@@ -0,0 +1,17 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { stackOutput } from '@nordicsemiconductor/cloudformation-helpers';
4
+ import { CloudFormationClient } from '@aws-sdk/client-cloudformation';
5
+ import { fromEnv } from '@nordicsemiconductor/from-env';
6
+ void describe('end-to-end tests', () => {
7
+ void it('should return an ULID', async () => {
8
+ const { stackName } = fromEnv({
9
+ stackName: 'STACK_NAME',
10
+ })(process.env);
11
+ const { lambdaURL } = await stackOutput(new CloudFormationClient({}))(stackName);
12
+ const res = await fetch(new URL(lambdaURL));
13
+ assert.equal(res.ok, true);
14
+ assert.equal(res.status, 201);
15
+ assert.match(await res.text(), /^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$/);
16
+ });
17
+ });
Binary file
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@bifravst/aws-cdk-lambda-helpers",
3
+ "version": "0.0.0-development",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "node_modules/id128": {
8
+ "version": "1.6.6",
9
+ "resolved": "https://registry.npmjs.org/id128/-/id128-1.6.6.tgz",
10
+ "integrity": "sha512-ExSXL9qcyQ7X/AfyO4ouARLnztm7Nmry1rwGi1nbrtSM90tjjqKzeMKqJfkw5bDdDX7XqdXIRzYYkVj5PU28Hg==",
11
+ "engines": {
12
+ "node": ">=v6.9.0"
13
+ }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,20 @@
1
+ - 0.1.0 : Move extraneous exports from index.js into utils.js.
2
+ - 0.2.0 : Add browser support for Browserify/Webpack.
3
+ - 0.3.0 : Pass named arguments to .generate instead of positional.
4
+ - 1.0.0 : Added support for Uuid V1 and extracted competitive benchmarks.
5
+ - 1.0.1 : Remove lockfile from release.
6
+ - 1.0.2 : Fix bad version push.
7
+ - 1.0.3 : Delete the extra benchmarks for real.
8
+ - 1.1.0 : Performance improvements and renamed resetClockSequence to reset.
9
+ - 1.1.1 : Fixed repo link.
10
+ - 1.2.0 : Added generic UUID factory.
11
+ - 1.3.0 : Added UUID V6 support.
12
+ - 1.4.0 : Exposed encoding verifiers.
13
+ - 1.5.0 : Fixed benchmarks and added support for node +12.5.
14
+ - 1.6.0 : Added Typescript support and top-level id comparators.
15
+ - 1.6.1 : Tweaked random memory allocation and updated benchmarks.
16
+ - 1.6.2 : Fixed docs
17
+ - 1.6.3 : Fixed memory profile by reusing the buffer of random.
18
+ - 1.6.4 : Fixed worker support
19
+ - 1.6.5 : Removed erroneous packaged files
20
+ - 1.6.6 : Fix CHANGES and add credit for worker support
@@ -0,0 +1,18 @@
1
+ Copyright 2018 Aaron Cohen <aarondcohen@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.