@bifravst/http-api-mock 2.0.76 → 2.0.77

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/cdk/App.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { App } from 'aws-cdk-lib'
2
- import { HTTPAPIMockStack } from './Stack.js'
3
1
  import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers'
4
2
  import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
3
+ import { App } from 'aws-cdk-lib'
4
+ import { HTTPAPIMockStack } from './Stack.js'
5
5
 
6
6
  export class HTTPAPIMockApp extends App {
7
7
  public constructor(
package/cdk/Stack.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { App } from 'aws-cdk-lib'
2
- import { CfnOutput, aws_lambda as Lambda, Stack } from 'aws-cdk-lib'
3
1
  import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers'
4
- import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
5
2
  import { LambdaSource } from '@bifravst/aws-cdk-lambda-helpers/cdk'
3
+ import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
4
+ import type { App } from 'aws-cdk-lib'
5
+ import { CfnOutput, aws_lambda as Lambda, Stack } from 'aws-cdk-lib'
6
6
  import { HttpApiMock } from './resources/HttpApiMock.js'
7
7
 
8
8
  /**
@@ -1,12 +1,12 @@
1
- import { packLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
2
1
  import { packLambdaFromPath } from '@bifravst/aws-cdk-lambda-helpers'
3
- import { HTTPAPIMockApp } from './App.js'
2
+ import { packLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
4
3
  import { fromEnv } from '@bifravst/from-env'
5
- import path from 'node:path'
6
- import { fileURLToPath } from 'node:url'
7
4
  import fs from 'node:fs/promises'
8
5
  import os from 'node:os'
6
+ import path from 'node:path'
7
+ import { fileURLToPath } from 'node:url'
9
8
  import type pJSON from '../package.json'
9
+ import { HTTPAPIMockApp } from './App.js'
10
10
 
11
11
  const { stackName } = fromEnv({ stackName: 'HTTP_API_MOCK_STACK_NAME' })(
12
12
  process.env,
@@ -1,3 +1,8 @@
1
+ import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers'
2
+ import {
3
+ LambdaLogGroup,
4
+ LambdaSource,
5
+ } from '@bifravst/aws-cdk-lambda-helpers/cdk'
1
6
  import {
2
7
  aws_apigateway as ApiGateway,
3
8
  Duration,
@@ -9,11 +14,6 @@ import {
9
14
  Resource,
10
15
  } from 'aws-cdk-lib'
11
16
  import type { Construct } from 'constructs'
12
- import {
13
- LambdaSource,
14
- LambdaLogGroup,
15
- } from '@bifravst/aws-cdk-lambda-helpers/cdk'
16
- import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers'
17
17
 
18
18
  export class HttpApiMock extends Resource {
19
19
  public readonly api: ApiGateway.RestApi
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test'
2
1
  import assert from 'node:assert/strict'
2
+ import { describe, it } from 'node:test'
3
3
  import { checkMatchingQueryParams } from './checkMatchingQueryParams.js'
4
4
 
5
5
  void describe('checkMatchingQueryParams', () => {
@@ -11,9 +11,9 @@ import type {
11
11
  Context,
12
12
  } from 'aws-lambda'
13
13
  import { URLSearchParams } from 'url'
14
+ import { sortQueryString } from '../../src/sortQueryString.js'
14
15
  import { checkMatchingQueryParams } from './checkMatchingQueryParams.js'
15
16
  import { splitMockResponse } from './splitMockResponse.js'
16
- import { sortQueryString } from '../../src/sortQueryString.js'
17
17
 
18
18
  const db = new DynamoDBClient({})
19
19
 
@@ -1,6 +1,6 @@
1
- import { splitMockResponse } from './splitMockResponse.js'
2
- import { describe, it } from 'node:test'
3
1
  import assert from 'node:assert'
2
+ import { describe, it } from 'node:test'
3
+ import { splitMockResponse } from './splitMockResponse.js'
4
4
  void describe('split mock response', () => {
5
5
  void it('should parse headers and body', () =>
6
6
  assert.deepEqual(
package/dist/cdk/App.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { App } from 'aws-cdk-lib';
2
1
  import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers';
3
2
  import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer';
3
+ import { App } from 'aws-cdk-lib';
4
4
  export declare class HTTPAPIMockApp extends App {
5
5
  constructor(stackName: string, { lambdaSources, layer, }: {
6
6
  lambdaSources: {
@@ -1,7 +1,7 @@
1
- import type { App } from 'aws-cdk-lib';
2
- import { Stack } from 'aws-cdk-lib';
3
1
  import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers';
4
2
  import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer';
3
+ import type { App } from 'aws-cdk-lib';
4
+ import { Stack } from 'aws-cdk-lib';
5
5
  /**
6
6
  * This is CloudFormation stack sets up a dummy HTTP API which stores all requests in SQS for inspection
7
7
  */
package/dist/cdk/Stack.js CHANGED
@@ -1,5 +1,5 @@
1
- import { CfnOutput, aws_lambda as Lambda, Stack } from 'aws-cdk-lib';
2
1
  import { LambdaSource } from '@bifravst/aws-cdk-lambda-helpers/cdk';
2
+ import { CfnOutput, aws_lambda as Lambda, Stack } from 'aws-cdk-lib';
3
3
  import { HttpApiMock } from './resources/HttpApiMock.js';
4
4
  /**
5
5
  * This is CloudFormation stack sets up a dummy HTTP API which stores all requests in SQS for inspection
@@ -1,11 +1,11 @@
1
- import { packLayer } from '@bifravst/aws-cdk-lambda-helpers/layer';
2
1
  import { packLambdaFromPath } from '@bifravst/aws-cdk-lambda-helpers';
3
- import { HTTPAPIMockApp } from './App.js';
2
+ import { packLayer } from '@bifravst/aws-cdk-lambda-helpers/layer';
4
3
  import { fromEnv } from '@bifravst/from-env';
5
- import path from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
4
  import fs from 'node:fs/promises';
8
5
  import os from 'node:os';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { HTTPAPIMockApp } from './App.js';
9
9
  const { stackName } = fromEnv({ stackName: 'HTTP_API_MOCK_STACK_NAME' })(process.env);
10
10
  const baseDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
11
11
  const distDir = await fs.mkdtemp(path.join(os.tmpdir(), 'temp-'));
@@ -1,6 +1,6 @@
1
+ import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers';
1
2
  import { aws_apigateway as ApiGateway, aws_dynamodb as DynamoDB, aws_lambda as Lambda, Resource } from 'aws-cdk-lib';
2
3
  import type { Construct } from 'constructs';
3
- import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers';
4
4
  export declare class HttpApiMock extends Resource {
5
5
  readonly api: ApiGateway.RestApi;
6
6
  readonly requestsTable: DynamoDB.ITable;
@@ -1,5 +1,5 @@
1
+ import { LambdaLogGroup, LambdaSource, } from '@bifravst/aws-cdk-lambda-helpers/cdk';
1
2
  import { aws_apigateway as ApiGateway, Duration, aws_dynamodb as DynamoDB, aws_iam as IAM, aws_lambda as Lambda, aws_logs as Logs, RemovalPolicy, Resource, } from 'aws-cdk-lib';
2
- import { LambdaSource, LambdaLogGroup, } from '@bifravst/aws-cdk-lambda-helpers/cdk';
3
3
  export class HttpApiMock extends Resource {
4
4
  api;
5
5
  requestsTable;
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test';
2
1
  import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
3
  import { checkMatchingQueryParams } from './checkMatchingQueryParams.js';
4
4
  void describe('checkMatchingQueryParams', () => {
5
5
  void it('should return true when expected is subset of actual parameters', () => {
@@ -1,9 +1,9 @@
1
1
  import { DeleteItemCommand, DynamoDBClient, PutItemCommand, ScanCommand, } from '@aws-sdk/client-dynamodb';
2
2
  import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
3
3
  import { URLSearchParams } from 'url';
4
+ import { sortQueryString } from '../../src/sortQueryString.js';
4
5
  import { checkMatchingQueryParams } from './checkMatchingQueryParams.js';
5
6
  import { splitMockResponse } from './splitMockResponse.js';
6
- import { sortQueryString } from '../../src/sortQueryString.js';
7
7
  const db = new DynamoDBClient({});
8
8
  export const handler = async (event, context) => {
9
9
  console.log(JSON.stringify({ event }));
@@ -1,6 +1,6 @@
1
- import { splitMockResponse } from './splitMockResponse.js';
2
- import { describe, it } from 'node:test';
3
1
  import assert from 'node:assert';
2
+ import { describe, it } from 'node:test';
3
+ import { splitMockResponse } from './splitMockResponse.js';
4
4
  void describe('split mock response', () => {
5
5
  void it('should parse headers and body', () => assert.deepEqual(splitMockResponse(`Content-Type: application/octet-stream
6
6
 
package/dist/src/cli.js CHANGED
@@ -1,11 +1,11 @@
1
- import { randomString } from './randomString.js';
2
- import run from '@bifravst/run';
1
+ import { CloudFormationClient } from '@aws-sdk/client-cloudformation';
3
2
  import { GetCallerIdentityCommand, STSClient } from '@aws-sdk/client-sts';
4
- import chalk from 'chalk';
5
3
  import { stackOutput } from '@bifravst/cloudformation-helpers';
6
- import { CloudFormationClient } from '@aws-sdk/client-cloudformation';
4
+ import run from '@bifravst/run';
5
+ import chalk from 'chalk';
7
6
  import path, { dirname } from 'node:path';
8
7
  import { fileURLToPath } from 'node:url';
8
+ import { randomString } from './randomString.js';
9
9
  const die = (err) => {
10
10
  console.error('');
11
11
  console.error(chalk.yellow('⚠️'), chalk.red.bold(err.message));
@@ -1,7 +1,7 @@
1
- import { describe, it, mock as testMock } from 'node:test';
1
+ import { unmarshall } from '@aws-sdk/util-dynamodb';
2
2
  import assert from 'node:assert/strict';
3
+ import { describe, it, mock as testMock } from 'node:test';
3
4
  import { mock } from './mock.js';
4
- import { unmarshall } from '@aws-sdk/util-dynamodb';
5
5
  void describe('mock()', () => {
6
6
  void it('should register a response', async () => {
7
7
  const db = {
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test';
2
1
  import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
3
  import { parseMockRequest } from './parseMockRequest.js';
4
4
  void describe('parseMockRequest()', () => {
5
5
  void it('should parse method, resource, protocol, headers and body', () => assert.deepEqual(parseMockRequest([
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test';
2
1
  import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
3
  import { parseMockResponse } from './parseMockResponse.js';
4
4
  void describe('parseMockResponse()', () => {
5
5
  void it('should parse protocol, statusCode, headers and body', () => assert.deepEqual(parseMockResponse([
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
2
  import { describe, test as it } from 'node:test';
3
- import { sortQuery, sortQueryString } from './sortQueryString.js';
4
3
  import { URLSearchParams } from 'node:url';
4
+ import { sortQuery, sortQueryString } from './sortQueryString.js';
5
5
  void describe('sortQueryString', () => {
6
6
  void it('should sort the query part of a mock URL', () => assert.deepStrictEqual(sortQueryString('api.nrfcloud.com/v1/location/agps?eci=73393515&tac=132&requestType=custom&mcc=397&mnc=73&customTypes=2'), 'api.nrfcloud.com/v1/location/agps?customTypes=2&eci=73393515&mcc=397&mnc=73&requestType=custom&tac=132'));
7
7
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/http-api-mock",
3
- "version": "2.0.76",
3
+ "version": "2.0.77",
4
4
  "description": "Helper functions for AWS lambdas written in TypeScript.",
5
5
  "exports": {
6
6
  "./*": {
@@ -79,10 +79,10 @@
79
79
  ],
80
80
  "prettier": "@bifravst/prettier-config",
81
81
  "dependencies": {
82
- "@aws-sdk/client-cloudformation": "^3.624.0",
83
- "@aws-sdk/client-dynamodb": "^3.624.0",
84
- "@aws-sdk/client-sts": "^3.624.0",
85
- "@aws-sdk/util-dynamodb": "^3.624.0",
82
+ "@aws-sdk/client-cloudformation": "^3.629.0",
83
+ "@aws-sdk/client-dynamodb": "^3.629.0",
84
+ "@aws-sdk/client-sts": "^3.629.0",
85
+ "@aws-sdk/util-dynamodb": "^3.629.0",
86
86
  "@bifravst/aws-cdk-lambda-helpers": "^1.9.23",
87
87
  "@bifravst/cloudformation-helpers": "9.1.1",
88
88
  "@bifravst/from-env": "3.0.2",
@@ -94,7 +94,7 @@
94
94
  },
95
95
  "devDependencies": {
96
96
  "@bifravst/eslint-config-typescript": "6.1.13",
97
- "@bifravst/prettier-config": "1.0.4",
97
+ "@bifravst/prettier-config": "1.1.0",
98
98
  "@commitlint/config-conventional": "19.2.2",
99
99
  "@types/aws-lambda": "8.10.143",
100
100
  "@types/node": "20.14.15",
package/src/cli.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { randomString } from './randomString.js'
2
- import run from '@bifravst/run'
1
+ import { CloudFormationClient } from '@aws-sdk/client-cloudformation'
3
2
  import { GetCallerIdentityCommand, STSClient } from '@aws-sdk/client-sts'
4
- import chalk from 'chalk'
5
3
  import { stackOutput } from '@bifravst/cloudformation-helpers'
6
- import type { StackOutputs } from '../cdk/Stack.js'
7
- import { CloudFormationClient } from '@aws-sdk/client-cloudformation'
4
+ import run from '@bifravst/run'
5
+ import chalk from 'chalk'
8
6
  import path, { dirname } from 'node:path'
9
7
  import { fileURLToPath } from 'node:url'
8
+ import type { StackOutputs } from '../cdk/Stack.js'
9
+ import { randomString } from './randomString.js'
10
10
 
11
11
  const die = (err: Error): void => {
12
12
  console.error('')
package/src/mock.spec.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { describe, it, mock as testMock } from 'node:test'
2
- import assert from 'node:assert/strict'
3
- import { mock } from './mock.js'
4
1
  import type { AttributeValue, DynamoDBClient } from '@aws-sdk/client-dynamodb'
5
2
  import { unmarshall } from '@aws-sdk/util-dynamodb'
3
+ import assert from 'node:assert/strict'
4
+ import { describe, it, mock as testMock } from 'node:test'
5
+ import { mock } from './mock.js'
6
6
 
7
7
  void describe('mock()', () => {
8
8
  void it('should register a response', async () => {
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test'
2
1
  import assert from 'node:assert/strict'
2
+ import { describe, it } from 'node:test'
3
3
  import { parseMockRequest } from './parseMockRequest.js'
4
4
 
5
5
  void describe('parseMockRequest()', () => {
@@ -1,5 +1,5 @@
1
- import { describe, it } from 'node:test'
2
1
  import assert from 'node:assert/strict'
2
+ import { describe, it } from 'node:test'
3
3
  import { parseMockResponse } from './parseMockResponse.js'
4
4
 
5
5
  void describe('parseMockResponse()', () => {
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert'
2
2
  import { describe, test as it } from 'node:test'
3
- import { sortQuery, sortQueryString } from './sortQueryString.js'
4
3
  import { URLSearchParams } from 'node:url'
4
+ import { sortQuery, sortQueryString } from './sortQueryString.js'
5
5
 
6
6
  void describe('sortQueryString', () => {
7
7
  void it('should sort the query part of a mock URL', () =>