@digitraffic/common 2022.11.23-test-2 → 2022.11.25-1

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 (88) hide show
  1. package/dist/aws/infra/api/integration.d.ts +1 -1
  2. package/dist/aws/infra/api/integration.js +8 -4
  3. package/dist/aws/infra/api/integration.js.map +1 -0
  4. package/dist/aws/infra/api/response.d.ts +10 -4
  5. package/dist/aws/infra/api/response.js +53 -18
  6. package/dist/aws/infra/api/response.js.map +1 -0
  7. package/dist/aws/infra/api/responses.d.ts +8 -0
  8. package/dist/aws/infra/api/responses.js +8 -0
  9. package/dist/aws/infra/api/responses.js.map +1 -0
  10. package/dist/aws/infra/api/static-integration.js +12 -6
  11. package/dist/aws/infra/api/static-integration.js.map +1 -0
  12. package/dist/aws/infra/canaries/canary-alarm.js.map +1 -0
  13. package/dist/aws/infra/canaries/canary-keys.js.map +1 -0
  14. package/dist/aws/infra/canaries/canary-parameters.js.map +1 -0
  15. package/dist/aws/infra/canaries/canary-role.js.map +1 -0
  16. package/dist/aws/infra/canaries/canary.js.map +1 -0
  17. package/dist/aws/infra/canaries/database-canary.js.map +1 -0
  18. package/dist/aws/infra/canaries/database-checker.js.map +1 -0
  19. package/dist/aws/infra/canaries/url-canary.js.map +1 -0
  20. package/dist/aws/infra/canaries/url-checker.js.map +1 -0
  21. package/dist/aws/infra/documentation.js.map +1 -0
  22. package/dist/aws/infra/import-util.js.map +1 -0
  23. package/dist/aws/infra/scheduler.js.map +1 -0
  24. package/dist/aws/infra/security-rule.js.map +1 -0
  25. package/dist/aws/infra/sqs-integration.js.map +1 -0
  26. package/dist/aws/infra/sqs-queue.js.map +1 -0
  27. package/dist/aws/infra/stack/lambda-configs.js.map +1 -0
  28. package/dist/aws/infra/stack/monitoredfunction.js.map +1 -0
  29. package/dist/aws/infra/stack/rest_apis.js.map +1 -0
  30. package/dist/aws/infra/stack/stack-checking-aspect.js.map +1 -0
  31. package/dist/aws/infra/stack/stack.js.map +1 -0
  32. package/dist/aws/infra/stack/subscription.js.map +1 -0
  33. package/dist/aws/infra/stacks/db-dns-stack.js.map +1 -0
  34. package/dist/aws/infra/stacks/db-proxy-stack.js.map +1 -0
  35. package/dist/aws/infra/stacks/db-stack.js.map +1 -0
  36. package/dist/aws/infra/stacks/intra-stack-configuration.js.map +1 -0
  37. package/dist/aws/infra/stacks/network-stack.js.map +1 -0
  38. package/dist/aws/infra/usage-plans.js.map +1 -0
  39. package/dist/aws/runtime/apikey.js.map +1 -0
  40. package/dist/aws/runtime/digitraffic-integration-response.js.map +1 -0
  41. package/dist/aws/runtime/environment.js.map +1 -0
  42. package/dist/aws/runtime/messaging.js.map +1 -0
  43. package/dist/aws/runtime/s3.js.map +1 -0
  44. package/dist/aws/runtime/secrets/dbsecret.js.map +1 -0
  45. package/dist/aws/runtime/secrets/proxy-holder.js.map +1 -0
  46. package/dist/aws/runtime/secrets/rds-holder.js.map +1 -0
  47. package/dist/aws/runtime/secrets/secret-holder.js.map +1 -0
  48. package/dist/aws/runtime/secrets/secret.js.map +1 -0
  49. package/dist/aws/types/errors.js.map +1 -0
  50. package/dist/aws/types/lambda-response.d.ts +9 -0
  51. package/dist/aws/types/lambda-response.js +11 -0
  52. package/dist/aws/types/lambda-response.js.map +1 -0
  53. package/dist/aws/types/mediatypes.js.map +1 -0
  54. package/dist/aws/types/model-with-reference.js.map +1 -0
  55. package/dist/aws/types/proxytypes.js.map +1 -0
  56. package/dist/aws/types/tags.js.map +1 -0
  57. package/dist/database/cached.js.map +1 -0
  58. package/dist/database/database.js.map +1 -0
  59. package/dist/database/last-updated.js.map +1 -0
  60. package/dist/database/models.js.map +1 -0
  61. package/dist/marine/id_utils.js.map +1 -0
  62. package/dist/marine/rtz.js.map +1 -0
  63. package/dist/test/asserter.js.map +1 -0
  64. package/dist/test/db-testutils.js.map +1 -0
  65. package/dist/test/httpserver.js.map +1 -0
  66. package/dist/test/secret.js.map +1 -0
  67. package/dist/test/secrets-manager.js.map +1 -0
  68. package/dist/test/testutils.js.map +1 -0
  69. package/dist/types/either.js.map +1 -0
  70. package/dist/types/input-error.js.map +1 -0
  71. package/dist/types/language.js.map +1 -0
  72. package/dist/types/traffictype.js.map +1 -0
  73. package/dist/types/validator.js.map +1 -0
  74. package/dist/utils/api-model.js.map +1 -0
  75. package/dist/utils/base64.js.map +1 -0
  76. package/dist/utils/date-utils.js.map +1 -0
  77. package/dist/utils/geojson-types.js.map +1 -0
  78. package/dist/utils/geometry.js.map +1 -0
  79. package/dist/utils/retry.js.map +1 -0
  80. package/dist/utils/slack.js.map +1 -0
  81. package/dist/utils/utils.js.map +1 -0
  82. package/package.json +31 -29
  83. package/src/aws/infra/api/integration.ts +30 -14
  84. package/src/aws/infra/api/response.ts +111 -26
  85. package/src/aws/infra/api/responses.ts +8 -0
  86. package/src/aws/infra/api/static-integration.ts +48 -14
  87. package/src/aws/types/lambda-response.ts +12 -0
  88. package/src/database/database.ts +1 -1
@@ -1,13 +1,17 @@
1
- import {MockIntegration, PassthroughBehavior, Resource} from "aws-cdk-lib/aws-apigateway";
2
- import {MediaType} from "../../types/mediatypes";
3
- import {corsMethod, RESPONSE_CORS_INTEGRATION} from "./responses";
1
+ import {
2
+ MockIntegration,
3
+ PassthroughBehavior,
4
+ Resource,
5
+ } from "aws-cdk-lib/aws-apigateway";
6
+ import { MediaType } from "../../types/mediatypes";
7
+ import { corsMethod, RESPONSE_CORS_INTEGRATION } from "./responses";
4
8
 
5
9
  const INTEGRATION_RESPONSE_200 = `{
6
10
  "statusCode": 200
7
11
  }`;
8
12
 
9
13
  const METHOD_RESPONSE_200 = {
10
- statusCode: '200',
14
+ statusCode: "200",
11
15
  };
12
16
 
13
17
  /**
@@ -19,9 +23,18 @@ const METHOD_RESPONSE_200 = {
19
23
  */
20
24
  export class DigitrafficStaticIntegration extends MockIntegration {
21
25
  constructor(
22
- resource: Resource, mediaType: MediaType, response: string, enableCors = true, apiKeyRequired = true,
26
+ resource: Resource,
27
+ mediaType: MediaType,
28
+ response: string,
29
+ enableCors = true,
30
+ apiKeyRequired = true
23
31
  ) {
24
- const integrationResponse = DigitrafficStaticIntegration.createIntegrationResponse(response, mediaType, enableCors);
32
+ const integrationResponse =
33
+ DigitrafficStaticIntegration.createIntegrationResponse(
34
+ response,
35
+ mediaType,
36
+ enableCors
37
+ );
25
38
 
26
39
  super({
27
40
  passthroughBehavior: PassthroughBehavior.WHEN_NO_TEMPLATES,
@@ -31,32 +44,53 @@ export class DigitrafficStaticIntegration extends MockIntegration {
31
44
  integrationResponses: [integrationResponse],
32
45
  });
33
46
 
34
- ['GET', 'HEAD'].forEach((httpMethod) => {
47
+ ["GET", "HEAD"].forEach((httpMethod) => {
35
48
  resource.addMethod(httpMethod, this, {
36
49
  apiKeyRequired,
37
- methodResponses: [DigitrafficStaticIntegration.createMethodResponse(enableCors)],
50
+ methodResponses: [
51
+ DigitrafficStaticIntegration.createMethodResponse(
52
+ enableCors
53
+ ),
54
+ ],
38
55
  });
39
56
  });
40
57
  }
41
58
 
42
- static json<K>(resource: Resource, response: K, enableCors = true, apiKeyRequired = true) {
59
+ static json<K>(
60
+ resource: Resource,
61
+ response: K,
62
+ enableCors = true,
63
+ apiKeyRequired = true
64
+ ) {
43
65
  return new DigitrafficStaticIntegration(
44
- resource, MediaType.APPLICATION_JSON, JSON.stringify(response), enableCors, apiKeyRequired,
66
+ resource,
67
+ MediaType.APPLICATION_JSON,
68
+ JSON.stringify(response),
69
+ enableCors,
70
+ apiKeyRequired
45
71
  );
46
72
  }
47
73
 
48
- private static createIntegrationResponse(response: string, mediaType: MediaType, enableCors: boolean) {
74
+ private static createIntegrationResponse(
75
+ response: string,
76
+ mediaType: MediaType,
77
+ enableCors: boolean
78
+ ) {
49
79
  const integrationResponse = {
50
- statusCode: '200',
80
+ statusCode: "200",
51
81
  responseTemplates: {
52
82
  [mediaType]: response,
53
83
  },
54
84
  };
55
85
 
56
- return enableCors ? {...integrationResponse, ...RESPONSE_CORS_INTEGRATION} : integrationResponse;
86
+ return enableCors
87
+ ? { ...integrationResponse, ...RESPONSE_CORS_INTEGRATION }
88
+ : integrationResponse;
57
89
  }
58
90
 
59
91
  private static createMethodResponse(enableCors: boolean) {
60
- return enableCors ? corsMethod(METHOD_RESPONSE_200) : METHOD_RESPONSE_200;
92
+ return enableCors
93
+ ? corsMethod(METHOD_RESPONSE_200)
94
+ : METHOD_RESPONSE_200;
61
95
  }
62
96
  }
@@ -9,6 +9,18 @@ export class LambdaResponse<T> {
9
9
  this.fileName = fileName;
10
10
  }
11
11
 
12
+ /**
13
+ * When you want to return binary, use LambdaResponse with base64-encoded string and then binary:
14
+ * LambdaResponse.ok(base64EncodedBinary).binary()
15
+ */
16
+ binary() {
17
+ return {
18
+ status: this.status,
19
+ binary: this.body,
20
+ fileName: this.fileName,
21
+ }
22
+ }
23
+
12
24
  static ok<T>(body: T, fileName?: string) {
13
25
  return this.create(200, body, fileName);
14
26
  }
@@ -1,6 +1,6 @@
1
1
  import { IDatabase, ITask } from "pg-promise";
2
2
  import { DatabaseEnvironmentKeys } from "../aws/runtime/secrets/dbsecret";
3
- import { getEnvVariable, getEnvVariableSafe } from "../utils/utils";
3
+ import { getEnvVariable } from "../utils/utils";
4
4
  import { envValue } from "../aws/runtime/environment";
5
5
 
6
6
  // eslint-disable-next-line @typescript-eslint/no-var-requires