@digitraffic/common 2022.11.11-1 → 2022.11.22-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 (149) hide show
  1. package/dist/aws/infra/stack/monitoredfunction.js +31 -31
  2. package/dist/aws/runtime/secrets/dbsecret.js +4 -4
  3. package/package.json +27 -16
  4. package/src/aws/runtime/secrets/dbsecret.ts +54 -23
  5. package/src/aws/runtime/secrets/secret-holder.ts +3 -6
  6. package/dist/aws/infra/api/integration.d.ts +0 -21
  7. package/dist/aws/infra/api/integration.js.map +0 -1
  8. package/dist/aws/infra/api/response.d.ts +0 -22
  9. package/dist/aws/infra/api/response.js.map +0 -1
  10. package/dist/aws/infra/api/responses.d.ts +0 -39
  11. package/dist/aws/infra/api/responses.js.map +0 -1
  12. package/dist/aws/infra/api/static-integration.d.ts +0 -15
  13. package/dist/aws/infra/api/static-integration.js.map +0 -1
  14. package/dist/aws/infra/canaries/canary-alarm.d.ts +0 -6
  15. package/dist/aws/infra/canaries/canary-alarm.js.map +0 -1
  16. package/dist/aws/infra/canaries/canary-keys.d.ts +0 -3
  17. package/dist/aws/infra/canaries/canary-keys.js.map +0 -1
  18. package/dist/aws/infra/canaries/canary-parameters.d.ts +0 -18
  19. package/dist/aws/infra/canaries/canary-parameters.js.map +0 -1
  20. package/dist/aws/infra/canaries/canary-role.d.ts +0 -6
  21. package/dist/aws/infra/canaries/canary-role.js.map +0 -1
  22. package/dist/aws/infra/canaries/canary.d.ts +0 -8
  23. package/dist/aws/infra/canaries/canary.js.map +0 -1
  24. package/dist/aws/infra/canaries/database-canary.d.ts +0 -18
  25. package/dist/aws/infra/canaries/database-canary.js.map +0 -1
  26. package/dist/aws/infra/canaries/database-checker.d.ts +0 -33
  27. package/dist/aws/infra/canaries/database-checker.js.map +0 -1
  28. package/dist/aws/infra/canaries/url-canary.d.ts +0 -16
  29. package/dist/aws/infra/canaries/url-canary.js.map +0 -1
  30. package/dist/aws/infra/canaries/url-checker.d.ts +0 -46
  31. package/dist/aws/infra/canaries/url-checker.js.map +0 -1
  32. package/dist/aws/infra/documentation.d.ts +0 -56
  33. package/dist/aws/infra/documentation.js.map +0 -1
  34. package/dist/aws/infra/import-util.d.ts +0 -21
  35. package/dist/aws/infra/import-util.js.map +0 -1
  36. package/dist/aws/infra/scheduler.d.ts +0 -12
  37. package/dist/aws/infra/scheduler.js.map +0 -1
  38. package/dist/aws/infra/security-rule.d.ts +0 -12
  39. package/dist/aws/infra/security-rule.js.map +0 -1
  40. package/dist/aws/infra/sqs-integration.d.ts +0 -7
  41. package/dist/aws/infra/sqs-integration.js.map +0 -1
  42. package/dist/aws/infra/sqs-queue.d.ts +0 -16
  43. package/dist/aws/infra/sqs-queue.js.map +0 -1
  44. package/dist/aws/infra/stack/lambda-configs.d.ts +0 -64
  45. package/dist/aws/infra/stack/lambda-configs.js.map +0 -1
  46. package/dist/aws/infra/stack/monitoredfunction.d.ts +0 -84
  47. package/dist/aws/infra/stack/monitoredfunction.js.map +0 -1
  48. package/dist/aws/infra/stack/rest_apis.d.ts +0 -41
  49. package/dist/aws/infra/stack/rest_apis.js.map +0 -1
  50. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +0 -21
  51. package/dist/aws/infra/stack/stack-checking-aspect.js.map +0 -1
  52. package/dist/aws/infra/stack/stack.d.ts +0 -45
  53. package/dist/aws/infra/stack/stack.js.map +0 -1
  54. package/dist/aws/infra/stack/subscription.d.ts +0 -17
  55. package/dist/aws/infra/stack/subscription.js.map +0 -1
  56. package/dist/aws/infra/stacks/db-dns-stack.d.ts +0 -11
  57. package/dist/aws/infra/stacks/db-dns-stack.js.map +0 -1
  58. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +0 -19
  59. package/dist/aws/infra/stacks/db-proxy-stack.js.map +0 -1
  60. package/dist/aws/infra/stacks/db-stack.d.ts +0 -31
  61. package/dist/aws/infra/stacks/db-stack.js.map +0 -1
  62. package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +0 -5
  63. package/dist/aws/infra/stacks/intra-stack-configuration.js.map +0 -1
  64. package/dist/aws/infra/stacks/network-stack.d.ts +0 -12
  65. package/dist/aws/infra/stacks/network-stack.js.map +0 -1
  66. package/dist/aws/infra/usage-plans.d.ts +0 -16
  67. package/dist/aws/infra/usage-plans.js.map +0 -1
  68. package/dist/aws/runtime/apikey.d.ts +0 -2
  69. package/dist/aws/runtime/apikey.js.map +0 -1
  70. package/dist/aws/runtime/digitraffic-integration-response.d.ts +0 -8
  71. package/dist/aws/runtime/digitraffic-integration-response.js.map +0 -1
  72. package/dist/aws/runtime/environment.d.ts +0 -1
  73. package/dist/aws/runtime/environment.js.map +0 -1
  74. package/dist/aws/runtime/messaging.d.ts +0 -10
  75. package/dist/aws/runtime/messaging.js.map +0 -1
  76. package/dist/aws/runtime/s3.d.ts +0 -2
  77. package/dist/aws/runtime/s3.js.map +0 -1
  78. package/dist/aws/runtime/secrets/dbsecret.d.ts +0 -54
  79. package/dist/aws/runtime/secrets/dbsecret.js.map +0 -1
  80. package/dist/aws/runtime/secrets/proxy-holder.d.ts +0 -9
  81. package/dist/aws/runtime/secrets/proxy-holder.js.map +0 -1
  82. package/dist/aws/runtime/secrets/rds-holder.d.ts +0 -9
  83. package/dist/aws/runtime/secrets/rds-holder.js.map +0 -1
  84. package/dist/aws/runtime/secrets/secret-holder.d.ts +0 -26
  85. package/dist/aws/runtime/secrets/secret-holder.js.map +0 -1
  86. package/dist/aws/runtime/secrets/secret.d.ts +0 -8
  87. package/dist/aws/runtime/secrets/secret.js.map +0 -1
  88. package/dist/aws/types/errors.d.ts +0 -8
  89. package/dist/aws/types/errors.js.map +0 -1
  90. package/dist/aws/types/lambda-response.d.ts +0 -13
  91. package/dist/aws/types/lambda-response.js.map +0 -1
  92. package/dist/aws/types/mediatypes.d.ts +0 -11
  93. package/dist/aws/types/mediatypes.js.map +0 -1
  94. package/dist/aws/types/model-with-reference.d.ts +0 -7
  95. package/dist/aws/types/model-with-reference.js.map +0 -1
  96. package/dist/aws/types/proxytypes.d.ts +0 -26
  97. package/dist/aws/types/proxytypes.js.map +0 -1
  98. package/dist/aws/types/tags.d.ts +0 -2
  99. package/dist/aws/types/tags.js.map +0 -1
  100. package/dist/database/cached.d.ts +0 -7
  101. package/dist/database/cached.js.map +0 -1
  102. package/dist/database/database.d.ts +0 -19
  103. package/dist/database/database.js.map +0 -1
  104. package/dist/database/last-updated.d.ts +0 -16
  105. package/dist/database/last-updated.js.map +0 -1
  106. package/dist/database/models.d.ts +0 -6
  107. package/dist/database/models.js.map +0 -1
  108. package/dist/marine/id_utils.d.ts +0 -3
  109. package/dist/marine/id_utils.js.map +0 -1
  110. package/dist/marine/rtz.d.ts +0 -48
  111. package/dist/marine/rtz.js.map +0 -1
  112. package/dist/test/asserter.d.ts +0 -11
  113. package/dist/test/asserter.js.map +0 -1
  114. package/dist/test/db-testutils.d.ts +0 -3
  115. package/dist/test/db-testutils.js.map +0 -1
  116. package/dist/test/httpserver.d.ts +0 -19
  117. package/dist/test/httpserver.js.map +0 -1
  118. package/dist/test/secret.d.ts +0 -3
  119. package/dist/test/secret.js.map +0 -1
  120. package/dist/test/secrets-manager.d.ts +0 -9
  121. package/dist/test/secrets-manager.js.map +0 -1
  122. package/dist/test/testutils.d.ts +0 -12
  123. package/dist/test/testutils.js.map +0 -1
  124. package/dist/types/either.d.ts +0 -9
  125. package/dist/types/either.js.map +0 -1
  126. package/dist/types/input-error.d.ts +0 -2
  127. package/dist/types/input-error.js.map +0 -1
  128. package/dist/types/language.d.ts +0 -5
  129. package/dist/types/language.js.map +0 -1
  130. package/dist/types/traffictype.d.ts +0 -8
  131. package/dist/types/traffictype.js.map +0 -1
  132. package/dist/types/validator.d.ts +0 -4
  133. package/dist/types/validator.js.map +0 -1
  134. package/dist/utils/api-model.d.ts +0 -87
  135. package/dist/utils/api-model.js.map +0 -1
  136. package/dist/utils/base64.d.ts +0 -12
  137. package/dist/utils/base64.js.map +0 -1
  138. package/dist/utils/date-utils.d.ts +0 -17
  139. package/dist/utils/date-utils.js.map +0 -1
  140. package/dist/utils/geojson-types.d.ts +0 -14
  141. package/dist/utils/geojson-types.js.map +0 -1
  142. package/dist/utils/geometry.d.ts +0 -36
  143. package/dist/utils/geometry.js.map +0 -1
  144. package/dist/utils/retry.d.ts +0 -13
  145. package/dist/utils/retry.js.map +0 -1
  146. package/dist/utils/slack.d.ts +0 -5
  147. package/dist/utils/slack.js.map +0 -1
  148. package/dist/utils/utils.d.ts +0 -46
  149. package/dist/utils/utils.js.map +0 -1
@@ -11,6 +11,37 @@ const subscription_1 = require("../stack/subscription");
11
11
  * Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
12
12
  */
13
13
  class MonitoredFunction extends aws_lambda_1.Function {
14
+ /**
15
+ * Create new MonitoredFunction. Use topics from given DigitrafficStack.
16
+ *
17
+ * @param stack DigitrafficStack
18
+ * @param id Lambda construct Id
19
+ * @param functionProps Lambda function properties
20
+ * @param props Monitored function properties
21
+ */
22
+ static create(stack, id, functionProps, props) {
23
+ if (props === MonitoredFunction.DISABLE_ALARMS &&
24
+ stack.configuration.production) {
25
+ throw new Error(`Function ${functionProps.functionName} has DISABLE_ALARMS. Remove before installing to production or define your own properties!`);
26
+ }
27
+ return new MonitoredFunction(stack, id, functionProps, stack.alarmTopic, stack.warningTopic, stack.configuration.production, stack.configuration.trafficType, props);
28
+ }
29
+ /**
30
+ * Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
31
+ *
32
+ * For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
33
+ *
34
+ * @param stack DigitrafficStack
35
+ * @param name param-case name
36
+ * @param environment Lambda environment
37
+ * @param functionParameters Lambda function parameters
38
+ */
39
+ static createV2(stack, name, environment, functionParameters) {
40
+ const functionName = functionParameters?.functionName ||
41
+ `${stack.configuration.shortName}-${(0, change_case_1.pascalCase)(name)}`;
42
+ const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, environment, functionName, name, functionParameters);
43
+ return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
44
+ }
14
45
  /**
15
46
  * @param scope Stack
16
47
  * @param id Lambda construct Id
@@ -48,37 +79,6 @@ class MonitoredFunction extends aws_lambda_1.Function {
48
79
  this.createAlarm(scope, this.metricThrottles(), "Throttles", "Throttles alarm", "Has throttled", trafficType, this.getAlarmActionForEnv(alarmSnsAction, warningSnsAction, production), 0, 1, 1, aws_cloudwatch_1.ComparisonOperator.GREATER_THAN_THRESHOLD, props?.throttleAlarmProps);
49
80
  }
50
81
  }
51
- /**
52
- * Create new MonitoredFunction. Use topics from given DigitrafficStack.
53
- *
54
- * @param stack DigitrafficStack
55
- * @param id Lambda construct Id
56
- * @param functionProps Lambda function properties
57
- * @param props Monitored function properties
58
- */
59
- static create(stack, id, functionProps, props) {
60
- if (props === MonitoredFunction.DISABLE_ALARMS &&
61
- stack.configuration.production) {
62
- throw new Error(`Function ${functionProps.functionName} has DISABLE_ALARMS. Remove before installing to production or define your own properties!`);
63
- }
64
- return new MonitoredFunction(stack, id, functionProps, stack.alarmTopic, stack.warningTopic, stack.configuration.production, stack.configuration.trafficType, props);
65
- }
66
- /**
67
- * Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
68
- *
69
- * For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
70
- *
71
- * @param stack DigitrafficStack
72
- * @param name param-case name
73
- * @param environment Lambda environment
74
- * @param functionParameters Lambda function parameters
75
- */
76
- static createV2(stack, name, environment, functionParameters) {
77
- const functionName = functionParameters?.functionName ||
78
- `${stack.configuration.shortName}-${(0, change_case_1.pascalCase)(name)}`;
79
- const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, environment, functionName, name, functionParameters);
80
- return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
81
- }
82
82
  createAlarm(stack, metric, alarmId, alarmName, alarmDescription, trafficType, alarmSnsAction, threshold, evaluationPeriods, datapointsToAlarm, comparisonOperator, alarmProps) {
83
83
  metric
84
84
  .createAlarm(stack, `${this.node.id}-${alarmId}`, {
@@ -33,7 +33,7 @@ function setDbSecret(secret) {
33
33
  // cached at Lambda container level
34
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
35
  let cachedSecret;
36
- const missingSecretErrorText = 'Missing or empty secretId';
36
+ const missingSecretErrorText = "Missing or empty secretId";
37
37
  /**
38
38
  * Run the given function with secret retrieved from Secrets Manager. Also injects database-credentials into environment.
39
39
  *
@@ -75,7 +75,7 @@ async function withDbSecret(secretId, fn, options) {
75
75
  return fn(cachedSecret);
76
76
  }
77
77
  catch (error) {
78
- console.error('method=withDbSecret Caught an error, refreshing secret', error);
78
+ console.error("method=withDbSecret Caught an error, refreshing secret", error);
79
79
  // try to refetch secret in case it has changed
80
80
  await (0, secret_1.withSecret)(secretId, (fetchedSecret) => {
81
81
  setDbSecret(fetchedSecret);
@@ -86,10 +86,10 @@ async function withDbSecret(secretId, fn, options) {
86
86
  }
87
87
  exports.withDbSecret = withDbSecret;
88
88
  function checkExpectedSecretKeys(keys, secret) {
89
- const missingKeys = keys.filter(key => !(key in secret));
89
+ const missingKeys = keys.filter((key) => !(key in secret));
90
90
  if (missingKeys.length) {
91
91
  console.error(`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys}`);
92
- throw new Error('Expected keys were not found');
92
+ throw new Error("Expected keys were not found");
93
93
  }
94
94
  }
95
95
  exports.checkExpectedSecretKeys = checkExpectedSecretKeys;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2022.11.11-1",
3
+ "version": "2022.11.22-1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,36 +10,40 @@
10
10
  "node": ">=14 <17",
11
11
  "yarn": ">1.2 <2"
12
12
  },
13
- "scripts": {
14
- "build": "tsc",
15
- "lint": "eslint --cache .",
16
- "eslint-report": "eslint . --format html",
17
- "clean": "rimraf dist output",
18
- "test": "jest --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest",
19
- "prepare": "husky install",
20
- "prepublishOnly": "yarn clean && yarn build && yarn test"
21
- },
22
13
  "license": "EUPL-1.2",
23
14
  "private": false,
24
15
  "files": [
25
16
  "dist/**/*.js",
26
17
  "src/**/*.ts"
27
18
  ],
28
- "dependencies": {
19
+ "peerDependencies": {
20
+ "pg-promise": "^10.12.0",
21
+ "spex": "^3.0.0",
22
+ "constructs": "^10.1.131",
29
23
  "@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
30
24
  "@types/geojson": "^7946.0.10",
31
25
  "aws-cdk-lib": "2.50.0",
32
26
  "aws-sdk": "2.1241.0",
33
27
  "axios": "^0.21.1",
34
28
  "change-case": "4.1.2",
35
- "constructs": "10.1.131",
36
29
  "geojson-validation": "^1.0.2",
37
30
  "moment": "^2.29.4",
38
31
  "node-ttl": "^0.2.0",
39
- "pg-native": "^3.0.1",
40
- "pg-promise": "^10.12.0"
32
+ "pg-native": "^3.0.1"
41
33
  },
42
34
  "devDependencies": {
35
+ "@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
36
+ "@types/geojson": "^7946.0.10",
37
+ "aws-cdk-lib": "2.50.0",
38
+ "aws-sdk": "2.1241.0",
39
+ "axios": "^0.21.1",
40
+ "change-case": "4.1.2",
41
+ "constructs": "10.1.131",
42
+ "geojson-validation": "^1.0.2",
43
+ "moment": "^2.29.4",
44
+ "node-ttl": "^0.2.0",
45
+ "pg-native": "^3.0.1",
46
+ "pg-promise": "^10.12.0",
43
47
  "@types/aws-lambda": "^8.10.106",
44
48
  "@types/jest": "^29.0.3",
45
49
  "@types/node": "^18.7.23",
@@ -58,7 +62,7 @@
58
62
  "rimraf": "^3.0.2",
59
63
  "sinon": "^14.0.0",
60
64
  "ts-jest": "^29.0.2",
61
- "typescript": "^4.8.4"
65
+ "typescript": "^4.7.4"
62
66
  },
63
67
  "externals": [
64
68
  "aws-sdk",
@@ -66,5 +70,12 @@
66
70
  ],
67
71
  "lint-staged": {
68
72
  "*.{js,ts,css,md,yml,yaml,json}": "prettier --write"
73
+ },
74
+ "scripts": {
75
+ "build": "tsc",
76
+ "lint": "eslint --cache .",
77
+ "eslint-report": "eslint . --format html",
78
+ "clean": "rimraf dist output",
79
+ "test": "jest --detectOpenHandles --forceExit --coverage --coverageDirectory=output/coverage/jest"
69
80
  }
70
- }
81
+ }
@@ -1,18 +1,24 @@
1
- import {withSecret, withSecretAndPrefix} from "./secret";
1
+ import { GenericSecret, withSecret, withSecretAndPrefix } from "./secret";
2
2
 
3
3
  export type DbSecret = {
4
- readonly username: string
5
- readonly password: string
6
- readonly host: string
7
- readonly ro_host: string
4
+ readonly username: string;
5
+ readonly password: string;
6
+ readonly host: string;
7
+ readonly ro_host: string;
8
8
  };
9
9
 
10
10
  export enum RdsProxySecretKey {
11
- username = "username", password = "password", proxy_host = "proxy_host", proxy_ro_host = "proxy_ro_host"
11
+ username = "username",
12
+ password = "password",
13
+ proxy_host = "proxy_host",
14
+ proxy_ro_host = "proxy_ro_host",
12
15
  }
13
16
 
14
17
  export enum RdsSecretKey {
15
- username = "username", password = "password", host = "host", ro_host = "ro_host"
18
+ username = "username",
19
+ password = "password",
20
+ host = "host",
21
+ ro_host = "ro_host",
16
22
  }
17
23
 
18
24
  export type RdsProxySecret = Record<RdsProxySecretKey, string>;
@@ -37,7 +43,7 @@ function setDbSecret(secret: DbSecret) {
37
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
44
  let cachedSecret: any;
39
45
 
40
- const missingSecretErrorText = 'Missing or empty secretId';
46
+ const missingSecretErrorText = "Missing or empty secretId";
41
47
 
42
48
  /**
43
49
  * You can give the following options for retrieving a secret:
@@ -48,13 +54,22 @@ const missingSecretErrorText = 'Missing or empty secretId';
48
54
 
49
55
  */
50
56
  export type SecretOptions = {
51
- readonly expectedKeys?: string[],
52
- readonly prefix?: string
53
- }
57
+ readonly expectedKeys?: string[];
58
+ readonly prefix?: string;
59
+ };
54
60
 
55
- export type SecretToPromiseFunction<Secret, Response = void> = (secret: Secret) => Promise<Response> | void;
56
- export type SecretFunction<Secret, Response = void> = (secretId: string, fn: SecretToPromiseFunction<Secret, Response>, options?: SecretOptions) => Promise<Response | void>;
57
- export type EmptySecretFunction<Response = void> = SecretFunction<DbSecret, Response>;
61
+ export type SecretToPromiseFunction<Secret, Response = void> = (
62
+ secret: Secret
63
+ ) => Promise<Response> | void;
64
+ export type SecretFunction<Secret, Response = void> = (
65
+ secretId: string,
66
+ fn: SecretToPromiseFunction<Secret, Response>,
67
+ options?: SecretOptions
68
+ ) => Promise<Response | void>;
69
+ export type EmptySecretFunction<Response = void> = SecretFunction<
70
+ DbSecret,
71
+ Response
72
+ >;
58
73
 
59
74
  /**
60
75
  * Run the given function with secret retrieved from Secrets Manager. Also injects database-credentials into environment.
@@ -66,7 +81,11 @@ export type EmptySecretFunction<Response = void> = SecretFunction<DbSecret, Resp
66
81
  * @param {function} fn
67
82
  * @param {SecretOptions} options
68
83
  */
69
- export async function withDbSecret<Secret, Response>(secretId: string, fn: SecretToPromiseFunction<Secret, Response>, options?: SecretOptions): Promise<Response | void> {
84
+ export async function withDbSecret<Secret, Response>(
85
+ secretId: string,
86
+ fn: SecretToPromiseFunction<Secret, Response>,
87
+ options?: SecretOptions
88
+ ): Promise<Response | void> {
70
89
  if (!secretId) {
71
90
  console.error(missingSecretErrorText);
72
91
  return Promise.reject(missingSecretErrorText);
@@ -81,9 +100,13 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
81
100
  });
82
101
 
83
102
  // then actual secret
84
- await withSecretAndPrefix(secretId, options.prefix, (fetchedSecret: Secret) => {
85
- cachedSecret = fetchedSecret;
86
- });
103
+ await withSecretAndPrefix(
104
+ secretId,
105
+ options.prefix,
106
+ (fetchedSecret: Secret) => {
107
+ cachedSecret = fetchedSecret;
108
+ }
109
+ );
87
110
  } else {
88
111
  await withSecret(secretId, (fetchedSecret: DbSecret) => {
89
112
  setDbSecret(fetchedSecret);
@@ -97,7 +120,10 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
97
120
  }
98
121
  return fn(cachedSecret);
99
122
  } catch (error) {
100
- console.error('method=withDbSecret Caught an error, refreshing secret', error);
123
+ console.error(
124
+ "method=withDbSecret Caught an error, refreshing secret",
125
+ error
126
+ );
101
127
  // try to refetch secret in case it has changed
102
128
  await withSecret(secretId, (fetchedSecret: DbSecret) => {
103
129
  setDbSecret(fetchedSecret);
@@ -107,10 +133,15 @@ export async function withDbSecret<Secret, Response>(secretId: string, fn: Secre
107
133
  }
108
134
  }
109
135
 
110
- export function checkExpectedSecretKeys<Secret>(keys: string[], secret: Secret) {
111
- const missingKeys = keys.filter(key => !(key in secret));
136
+ export function checkExpectedSecretKeys<Secret extends GenericSecret>(
137
+ keys: string[],
138
+ secret: Secret
139
+ ) {
140
+ const missingKeys = keys.filter((key) => !(key in secret));
112
141
  if (missingKeys.length) {
113
- console.error(`method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys}`);
114
- throw new Error('Expected keys were not found');
142
+ console.error(
143
+ `method=checkExpectedSecretKeys secret didn't contain the key(s) ${missingKeys}`
144
+ );
145
+ throw new Error("Expected keys were not found");
115
146
  }
116
147
  }
@@ -23,7 +23,7 @@ const DEFAULT_CONFIGURATION = {
23
23
  *
24
24
  * Supports setting the database environment paramaters from the secret too.
25
25
  */
26
- export class SecretHolder<Secret> {
26
+ export class SecretHolder<Secret extends GenericSecret> {
27
27
  private readonly secretId: string;
28
28
  private readonly prefix: string;
29
29
  private readonly expectedKeys: string[];
@@ -51,7 +51,7 @@ export class SecretHolder<Secret> {
51
51
  this.secretCache.push(DEFAULT_SECRET_KEY, secretValue);
52
52
  }
53
53
 
54
- public static create<S>(
54
+ public static create<S extends GenericSecret>(
55
55
  prefix = DEFAULT_PREFIX,
56
56
  expectedKeys: string[] = []
57
57
  ) {
@@ -67,10 +67,7 @@ export class SecretHolder<Secret> {
67
67
  const parsedSecret =
68
68
  this.prefix === DEFAULT_PREFIX
69
69
  ? secret
70
- : this.parseSecret(
71
- secret as unknown as GenericSecret,
72
- `${this.prefix}.`
73
- );
70
+ : this.parseSecret(secret, `${this.prefix}.`);
74
71
 
75
72
  if (this.expectedKeys.length > 0) {
76
73
  checkExpectedSecretKeys(this.expectedKeys, parsedSecret);
@@ -1,21 +0,0 @@
1
- import { IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
2
- import { IFunction } from "aws-cdk-lib/aws-lambda";
3
- import { MediaType } from "../../types/mediatypes";
4
- declare type ParameterType = 'path' | 'querystring';
5
- interface ApiParameter {
6
- type: ParameterType;
7
- name: string;
8
- }
9
- export declare class DigitrafficIntegration {
10
- readonly lambda: IFunction;
11
- readonly mediaType: MediaType;
12
- readonly parameters: ApiParameter[];
13
- constructor(lambda: IFunction, mediaType?: MediaType);
14
- addPathParameter(...names: string[]): DigitrafficIntegration;
15
- addQueryParameter(...names: string[]): DigitrafficIntegration;
16
- build(): LambdaIntegration;
17
- createRequestParameters(): Record<string, string>;
18
- createRequestTemplates(): Record<string, string>;
19
- createResponses(): IntegrationResponse[];
20
- }
21
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/integration.ts"],"names":[],"mappings":";;;AAAA,+DAAuG;AAEvG,uDAAiD;AACjD,qGAA8F;AAS9F,MAAa,sBAAsB;IAM/B,YAAY,MAAiB,EAAE,SAAS,GAAG,sBAAS,CAAC,UAAU;QAFtD,eAAU,GAAmB,EAAE,CAAC;QAGrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,gBAAgB,CAAC,GAAG,KAAe;QAC/B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,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U,CAAC,OAAO,CAAC,CAAC,SAAuB,EAAE,EAAE;YAChD,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,yCAAyC,SAAS,CAAC,IAAI,KAAK,CAAC;QAC/F,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,CAAC,sBAAS,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;SAC5D,CAAC;IACN,CAAC;IAED,eAAe;QACX,OAAO,CAAC,iEAA8B,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,CAAC;CACJ;AA5DD,wDA4DC"}
@@ -1,22 +0,0 @@
1
- import apigateway = require('aws-cdk-lib/aws-apigateway');
2
- import { MediaType } from "../../types/mediatypes";
3
- /**
4
- * This is velocity-script, that assumes the response to be LambdaResponse(status and body).
5
- * It will always return the body and status, but if status in something else than 200 OK the content-type
6
- * will be overridden to text/plain. (it's assumed, that lambda will return error text).
7
- *
8
- * If fileName is set, then Content-Disposition-header will be set to use it
9
- */
10
- export declare const RESPONSE_DEFAULT_LAMBDA = "#set($inputRoot = $input.path('$'))\n$inputRoot.body\n#if ($inputRoot.status != 200)\n#set ($context.responseOverride.status = $inputRoot.status)\n#set ($context.responseOverride.header.Content-Type = 'text/plain')\n#end\n#set ($context.responseOverride.header.Access-Control-Allow-Origin = '*')\n#if (\"$!inputRoot.fileName\" != \"\")\n#set ($disposition = 'attachment; filename=\"FN\"')\n#set ($context.responseOverride.header.Content-Disposition = $disposition.replaceAll('FN', $inputRoot.fileName))\n#end\n";
11
- export declare const MessageModel: {
12
- contentType: MediaType;
13
- modelName: string;
14
- schema: apigateway.JsonSchema;
15
- };
16
- export declare const NotFoundResponse: string;
17
- export declare const BadRequestResponseTemplate: Record<string, string>;
18
- export declare const NotFoundResponseTemplate: Record<string, string>;
19
- export declare const XmlResponseTemplate: Record<string, string>;
20
- export declare const SvgResponseTemplate: Record<string, string>;
21
- export declare const InternalServerErrorResponseTemplate: Record<string, string>;
22
- export declare function createResponses<T>(key: MediaType, value: T): Record<string, T>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/response.ts"],"names":[],"mappings":";;;AAAA,yDAA0D;AAC1D,uDAAiD;AAEjD;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC;AAEF,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD,aAAa;AACb,MAAM,aAAa,GAA0B;IACzC,MAAM,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM;IAC3C,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;IACtC,WAAW,EAAE,uBAAuB;IACpC,UAAU,EAAE;QACR,OAAO,EAAE;YACL,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,MAAM;YACtC,WAAW,EAAE,kBAAkB;SAClC;KACJ;CACJ,CAAC;AAEF,aAAa;AACA,QAAA,YAAY,GAAG;IACxB,WAAW,EAAE,sBAAS,CAAC,gBAAgB;IACvC,SAAS,EAAE,sBAAsB;IACjC,MAAM,EAAE,aAAa;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG,WAAW,CAAC;AACvB,QAAA,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,eAAe,EAAC,CAAC,CAAC;AAE3E,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAC3C,MAAM,2BAA2B,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,0BAA0B,EAAC,CAAC,CAAC;AAE1F,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,iBAAiB,EAAC,CAAC,CAAC;AAE3D,QAAA,0BAA0B,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAC7F,QAAA,wBAAwB,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,wBAAgB,CAAC,CAAC;AACzF,QAAA,mBAAmB,GAAG,eAAe,CAAC,sBAAS,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;AACvF,QAAA,mBAAmB,GAAG,eAAe,CAAC,sBAAS,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AACjF,QAAA,mCAAmC,GAAG,eAAe,CAAC,sBAAS,CAAC,gBAAgB,EAAE,2BAA2B,CAAC,CAAC;AAE5H,SAAgB,eAAe,CAAI,GAAc,EAAE,KAAQ;IACvD,MAAM,GAAG,GAAsB,EAAE,CAAC;IAElC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEjB,OAAO,GAAG,CAAC;AACf,CAAC;AAND,0CAMC"}
@@ -1,39 +0,0 @@
1
- import { LambdaIntegration, MethodResponse, IntegrationResponse, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
2
- import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
3
- import { IModel } from "aws-cdk-lib/aws-apigateway/lib/model";
4
- import { MediaType } from "../../types/mediatypes";
5
- export declare const RESPONSE_200_OK: IntegrationResponse;
6
- export declare const RESPONSE_400_BAD_REQUEST: IntegrationResponse;
7
- export declare const RESPONSE_500_SERVER_ERROR: IntegrationResponse;
8
- export declare const RESPONSE_CORS_INTEGRATION: {
9
- responseParameters: {
10
- "method.response.header.Access-Control-Allow-Origin": string;
11
- };
12
- };
13
- export declare const RESPONSE_404_NOT_FOUND: {
14
- statusCode: string;
15
- selectionPattern: string;
16
- responseTemplates: Record<string, string>;
17
- };
18
- export declare function methodResponse(status: string, contentType: MediaType, model: IModel, parameters?: Record<string, boolean>): MethodResponse;
19
- export declare function corsMethod(response: MethodResponse): MethodResponse;
20
- interface IntegrationOptions {
21
- requestParameters?: {
22
- [dest: string]: string;
23
- };
24
- requestTemplates?: {
25
- [contentType: string]: string;
26
- };
27
- responses?: IntegrationResponse[];
28
- disableCors?: boolean;
29
- xml?: boolean;
30
- passthroughBehavior?: PassthroughBehavior;
31
- }
32
- /**
33
- * Creates a default Lambda integration for a REST API resource _root_
34
- * @param lambdaFunction The Lambda function
35
- * @param options Options
36
- */
37
- export declare function defaultIntegration(lambdaFunction: AWSFunction, options?: IntegrationOptions): LambdaIntegration;
38
- export declare function getResponse(response: IntegrationResponse, options?: IntegrationOptions): IntegrationResponse;
39
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/responses.ts"],"names":[],"mappings":";;;AAAA,yCAMoB;AACpB,+DAKoC;AAGpC,+CAI4B;AAGf,QAAA,eAAe,GAAwB;IAChD,UAAU,EAAE,KAAK;CACpB,CAAC;AAEW,QAAA,wBAAwB,GAAwB;IACzD,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,4BAAmB;IACrC,iBAAiB,EAAE,qCAA0B;CAChD,CAAC;AAEW,QAAA,yBAAyB,GAAwB;IAC1D,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,sBAAa;IAC/B,iBAAiB,EAAE,8CAAmC;CACzD,CAAC;AAEF,MAAM,YAAY,GAAG;IACjB,iBAAiB,EAAE,8BAAmB;CACzC,CAAC;AAEW,QAAA,yBAAyB,GAAG;IACrC,kBAAkB,EAAE;QAChB,oDAAoD,EAAE,KAAK;KAC9D;CACJ,CAAC;AAEW,QAAA,sBAAsB,GAAG;IAClC,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,0BAAiB;IACnC,iBAAiB,EAAE,mCAAwB;CAC9C,CAAC;AAEF,SAAgB,cAAc,CAC1B,MAAc,EACd,WAAsB,EACtB,KAAa,EACb,UAAoC;IAEpC,OAAO;QACH,UAAU,EAAE,MAAM;QAClB,cAAc,EAAE,IAAA,0BAAe,EAAC,WAAW,EAAE,KAAK,CAAC;QACnD,kBAAkB,EAAE,UAAU,IAAI,EAAE;KACvC,CAAC;AACN,CAAC;AAXD,wCAWC;AAED,SAAgB,UAAU,CAAC,QAAwB;IAC/C,OAAO;QACH,GAAG,QAAQ;QACX,GAAG;YACC,kBAAkB,EAAE;gBAChB,oDAAoD,EAAE,IAAI;aAC7D;SACJ;KACJ,CAAC;AACN,CAAC;AATD,gCASC;AAWD;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,cAA2B,EAC3B,OAA4B;IAE5B,OAAO,IAAI,kCAAiB,CAAC,cAAc,EAAE;QACzC,KAAK,EAAE,KAAK;QACZ,oBAAoB,EAAE,OAAO,EAAE,SAAS,IAAI;YACxC,WAAW,CAAC,uBAAe,EAAE,OAAO,CAAC;YACrC,WAAW,CAAC,gCAAwB,EAAE,OAAO,CAAC;YAC9C,WAAW,CAAC,8BAAsB,EAAE,OAAO,CAAC;YAC5C,WAAW,CAAC,iCAAyB,EAAE,OAAO,CAAC;SAClD;QACD,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,EAAE;QACnD,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,EAAE;QACjD,mBAAmB,EACf,OAAO,EAAE,mBAAmB,IAAI,oCAAmB,CAAC,aAAa;KACxE,CAAC,CAAC;AACP,CAAC;AAjBD,gDAiBC;AAED,SAAgB,WAAW,CACvB,QAA6B,EAC7B,OAA4B;IAE5B,IAAI,OAAO,EAAE,GAAG,EAAE;QACd,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,YAAY,EAAE,CAAC;KAC/C;IACD,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE;QACvB,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,iCAAyB,EAAE,CAAC;KAC5D;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAZD,kCAYC"}
@@ -1,15 +0,0 @@
1
- import { MockIntegration, Resource } from "aws-cdk-lib/aws-apigateway";
2
- import { MediaType } from "../../types/mediatypes";
3
- /**
4
- * Static integration, that returns the given response with given mediaType from given resource.
5
- *
6
- * @param resource
7
- * @param mediaType
8
- * @param response
9
- */
10
- export declare class DigitrafficStaticIntegration extends MockIntegration {
11
- constructor(resource: Resource, mediaType: MediaType, response: string, enableCors?: boolean, apiKeyRequired?: boolean);
12
- static json<K>(resource: Resource, response: K, enableCors?: boolean, apiKeyRequired?: boolean): DigitrafficStaticIntegration;
13
- private static createIntegrationResponse;
14
- private static createMethodResponse;
15
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-integration.js","sourceRoot":"","sources":["../../../../src/aws/infra/api/static-integration.ts"],"names":[],"mappings":";;;AAAA,+DAA0F;AAC1F,uDAAiD;AACjD,2CAAkE;AAElE,MAAM,wBAAwB,GAAG;;EAE/B,CAAC;AAEH,MAAM,mBAAmB,GAAG;IACxB,UAAU,EAAE,KAAK;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,MAAa,4BAA6B,SAAQ,gCAAe;IAC7D,YACI,QAAkB,EAAE,SAAoB,EAAE,QAAgB,EAAE,UAAU,GAAG,IAAI,EAAE,cAAc,GAAG,IAAI;QAEpG,MAAM,mBAAmB,GAAG,4BAA4B,CAAC,yBAAyB,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAEpH,KAAK,CAAC;YACF,mBAAmB,EAAE,oCAAmB,CAAC,iBAAiB;YAC1D,gBAAgB,EAAE;gBACd,CAAC,SAAS,CAAC,EAAE,wBAAwB;aACxC;YACD,oBAAoB,EAAE,CAAC,mBAAmB,CAAC;SAC9C,CAAC,CAAC;QAEH,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACnC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE;gBACjC,cAAc;gBACd,eAAe,EAAE,CAAC,4BAA4B,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;aACnF,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,IAAI,CAAI,QAAkB,EAAE,QAAW,EAAE,UAAU,GAAG,IAAI,EAAE,cAAc,GAAG,IAAI;QACpF,OAAO,IAAI,4BAA4B,CACnC,QAAQ,EAAE,sBAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,cAAc,CAC7F,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,yBAAyB,CAAC,QAAgB,EAAE,SAAoB,EAAE,UAAmB;QAChG,MAAM,mBAAmB,GAAG;YACxB,UAAU,EAAE,KAAK;YACjB,iBAAiB,EAAE;gBACf,CAAC,SAAS,CAAC,EAAE,QAAQ;aACxB;SACJ,CAAC;QAEF,OAAO,UAAU,CAAC,CAAC,CAAC,EAAC,GAAG,mBAAmB,EAAE,GAAG,qCAAyB,EAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACrG,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,UAAmB;QACnD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC9E,CAAC;CACJ;AA1CD,oEA0CC"}
@@ -1,6 +0,0 @@
1
- import { Construct } from "constructs";
2
- import { CanaryParameters } from "./canary-parameters";
3
- import { Canary } from "@aws-cdk/aws-synthetics-alpha";
4
- export declare class CanaryAlarm {
5
- constructor(stack: Construct, canary: Canary, params: CanaryParameters);
6
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"canary-alarm.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/canary-alarm.ts"],"names":[],"mappings":";;;AAEA,+DAAqE;AAErE,+EAA6D;AAC7D,iDAA0C;AAE1C,MAAa,WAAW;IACpB,YAAY,KAAgB,EACxB,MAAc,EACd,MAAwB;QACxB,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE;YACtB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,GAAG,MAAM,CAAC,IAAI,QAAQ,CAAC;YAEpE,MAAM,KAAK,GAAG,IAAI,sBAAK,CAAC,KAAK,EAAE,SAAS,EAAE;gBACtC,SAAS;gBACT,gBAAgB,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW,IAAI,EAAE;gBACjD,MAAM,EAAE,MAAM,CAAC,oBAAoB,EAAE;gBACrC,iBAAiB,EAAE,MAAM,CAAC,KAAK,EAAE,gBAAgB,IAAI,CAAC;gBACtD,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,GAAG;gBACzC,kBAAkB,EAAE,mCAAkB,CAAC,mBAAmB;aAC7D,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE;gBACxB,KAAK,CAAC,cAAc,CAAC,IAAI,kCAAS,CAAC,eAAK,CAAC,YAAY,CAAC,KAAK,EACvD,GAAG,SAAS,SAAS,EACrB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aAChC;SACJ;IACL,CAAC;CACJ;AAvBD,kCAuBC"}
@@ -1,3 +0,0 @@
1
- export declare const ENV_API_KEY = "apiKeyId";
2
- export declare const ENV_HOSTNAME = "hostname";
3
- export declare const ENV_SECRET = "secret";
@@ -1 +0,0 @@
1
- {"version":3,"file":"canary-keys.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/canary-keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,UAAU,CAAC;AACzB,QAAA,YAAY,GAAG,UAAU,CAAC;AAC1B,QAAA,UAAU,GAAG,QAAQ,CAAC"}
@@ -1,18 +0,0 @@
1
- import { Schedule } from "@aws-cdk/aws-synthetics-alpha";
2
- /** Optional env parameters for canary */
3
- declare type CanaryEnv = Record<string, string>;
4
- export declare type CanaryParameters = {
5
- readonly name: string;
6
- readonly schedule?: Schedule;
7
- readonly secret?: string;
8
- readonly handler: string;
9
- readonly alarm?: {
10
- readonly alarmName?: string;
11
- readonly description?: string;
12
- readonly evalutionPeriods?: number;
13
- readonly threshold?: number;
14
- readonly topicArn?: string;
15
- };
16
- readonly canaryEnv?: CanaryEnv;
17
- };
18
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"canary-parameters.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/canary-parameters.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import { Role } from "aws-cdk-lib/aws-iam";
2
- import { Construct } from "constructs";
3
- export declare class DigitrafficCanaryRole extends Role {
4
- constructor(stack: Construct, canaryName: string);
5
- withDatabaseAccess(): DigitrafficCanaryRole;
6
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"canary-role.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/canary-role.ts"],"names":[],"mappings":";;;AAAA,iDAAiH;AAGjH,MAAM,2BAA2B,GAAyB;IACtD,OAAO,EAAE;QACL,sBAAsB;QACtB,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;QACxB,yBAAyB;KAC5B;IACD,SAAS,EAAE,CAAC,GAAG,CAAC;CACnB,CAAC;AAEF,MAAM,0BAA0B,GAAyB;IACrD,OAAO,EAAE;QACL,0BAA0B;KAC7B;IACD,SAAS,EAAE,CAAC,GAAG,CAAC;IAChB,UAAU,EAAE;QACR,cAAc,EAAE;YACZ,sBAAsB,EAAE,sBAAsB;SACjD;KACJ;CACJ,CAAC;AAEF,MAAa,qBAAsB,SAAQ,cAAI;IAC3C,YAAY,KAAgB,EAAE,UAAkB;QAC5C,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,EAAE;YACtC,SAAS,EAAE,IAAI,0BAAgB,CAAC,sBAAsB,CAAC;YACvD,eAAe,EAAE;gBACb,uBAAa,CAAC,wBAAwB,CAAC,gCAAgC,CAAC;aAC3E;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,IAAI,yBAAe,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,WAAW,CAAC,IAAI,yBAAe,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,kBAAkB;QACd,gBAAgB;QAChB,6DAA6D;QAC7D,QAAQ;QACR,IAAI,CAAC,gBAAgB,CAAC,uBAAa,CAAC,wBAAwB,CAAC,8CAA8C,CAAC,CAAC,CAAC;QAC9G,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AApBD,sDAoBC"}
@@ -1,8 +0,0 @@
1
- import { Canary } from "@aws-cdk/aws-synthetics-alpha";
2
- import { Role } from "aws-cdk-lib/aws-iam";
3
- import { CanaryParameters } from "./canary-parameters";
4
- import { Construct } from "constructs";
5
- import { LambdaEnvironment } from "../stack/lambda-configs";
6
- export declare class DigitrafficCanary extends Canary {
7
- constructor(scope: Construct, canaryName: string, role: Role, params: CanaryParameters, environmentVariables: LambdaEnvironment);
8
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"canary.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/canary.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,wEAMuC;AAEvC,iDAA6C;AAK7C,MAAa,iBAAkB,SAAQ,6BAAM;IACzC,YACI,KAAgB,EAChB,UAAkB,EAClB,IAAU,EACV,MAAwB,EACxB,oBAAuC;QAEvC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE;YACrB,OAAO,EAAE,8BAAO,CAAC,+BAA+B;YAChD,IAAI;YACJ,IAAI,EAAE,2BAAI,CAAC,MAAM,CAAC;gBACd,IAAI,EAAE,IAAI,gCAAS,CAAC,MAAM,EAAE;oBACxB,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC;iBACzC,CAAC;gBACF,OAAO,EAAE,MAAM,CAAC,OAAO;aAC1B,CAAC;YACF,oBAAoB,EAAE;gBAClB,GAAG,oBAAoB;gBACvB,GAAG,MAAM,EAAE,SAAS;aACvB;YACD,UAAU;YACV,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,+BAAQ,CAAC,IAAI,CAAC,sBAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SACnE,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE;YACtB,IAAI,0BAAW,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;SACxC;IACL,CAAC;CACJ;AA/BD,8CA+BC"}
@@ -1,18 +0,0 @@
1
- import { Role } from "aws-cdk-lib/aws-iam";
2
- import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
3
- import { CanaryParameters } from "./canary-parameters";
4
- import { DigitrafficCanary } from "./canary";
5
- import { DigitrafficStack } from "../stack/stack";
6
- export declare class DatabaseCanary extends DigitrafficCanary {
7
- constructor(stack: DigitrafficStack, role: Role, secret: ISecret, params: CanaryParameters);
8
- static create(stack: DigitrafficStack, role: Role, params: CanaryParameters): DatabaseCanary;
9
- /**
10
- *
11
- * @param stack
12
- * @param role
13
- * @param name name of the typescipt file without -db -suffix. Max len is 10 char if @param canaryName is not given.
14
- * @param params
15
- * @param canaryName Optional name for canary if multiple canaries is made from same ${name}-db.ts canary file.
16
- */
17
- static createV2(stack: DigitrafficStack, role: Role, name: string, params?: Partial<CanaryParameters>, canaryName?: string): DatabaseCanary;
18
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"database-canary.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/database-canary.ts"],"names":[],"mappings":";;;AAEA,+DAAuD;AACvD,uDAAkD;AAClD,6CAAuC;AAGvC,qCAA6C;AAG7C,MAAa,cAAe,SAAQ,0BAAiB;IACjD,YACI,KAAuB,EACvB,IAAU,EACV,MAAe,EACf,MAAwB;QAExB,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC;QACvC,MAAM,oBAAoB,GAAG,KAAK,CAAC,8BAA8B,CAC7D,cAAc,UAAU,EAAE,CAC7B,CAAC;QAEF,+DAA+D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Z,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CACX,KAAuB,EACvB,IAAU,EACV,IAAY,EACZ,SAAoC,EAAE,EACtC,UAAU,GAAG,IAAI;QAEjB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;YAC3C,GAAG;gBACC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ;gBACpC,QAAQ,EAAE,qBAAQ,CAAC,IAAI,CAAC,sBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1C,OAAO,EAAE,GAAG,IAAI,aAAa;gBAC7B,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE;oBACH,SAAS,EACL,UAAU,KAAK,IAAI;wBACf,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,SAAS,WAAW;wBAC7C,CAAC,CAAC,GAAG,UAAU,WAAW;oBAClC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa;iBAC9C;aACJ;YACD,GAAG,MAAM;SACZ,CAAC,CAAC;IACP,CAAC;CACJ;AAvFD,wCAuFC"}
@@ -1,33 +0,0 @@
1
- import { Countable } from "../../../database/models";
2
- declare abstract class DatabaseCheck<T> {
3
- readonly name: string;
4
- readonly sql: string;
5
- failed: boolean;
6
- protected constructor(name: string, sql: string);
7
- abstract check(value: T): void;
8
- }
9
- /**
10
- * Checker for sql that checks the count. Meaning that the
11
- * sql must be structured as "select count(*) from <table> where <something>".
12
- */
13
- export declare class DatabaseCountChecker {
14
- readonly credentialsFunction: () => Promise<void>;
15
- readonly checks: DatabaseCheck<Countable>[];
16
- private constructor();
17
- static createForProxy(): DatabaseCountChecker;
18
- static createForRds(): DatabaseCountChecker;
19
- /**
20
- * Expect that the count is 1
21
- */
22
- expectOne(name: string, sql: string): this;
23
- /**
24
- * Expect that the count is 0
25
- */
26
- expectZero(name: string, sql: string): this;
27
- /**
28
- * Expect that the count is 1 or more
29
- */
30
- expectOneOrMore(name: string, sql: string): this;
31
- expect(): Promise<string>;
32
- }
33
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"database-checker.js","sourceRoot":"","sources":["../../../../src/aws/infra/canaries/database-checker.ts"],"names":[],"mappings":";;;AAAA,yDAA4E;AAC5E,qEAAiE;AACjE,iEAA6D;AAC7D,gDAAsD;AAGtD,8DAA8D;AAC9D,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAe,aAAa;IAKxB,YAAsB,IAAY,EAAE,GAAW;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;CAGJ;AAED,MAAM,kBAAmB,SAAQ,aAAwB;IAIrD,YACI,IAAY,EACZ,GAAW,EACX,QAAuB,EACvB,QAAuB;QAEvB,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEjB,IACI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACrC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EACtC;YACE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;QAED,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SAC1C;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,KAAgB;QAClB,IAAI,OAAO,IAAI,KAAK,EAAE;YAClB,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,G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CAAC;gBACvB,CAAC,CAAC;gBAEF,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;aACjE;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA3ED,oDA2EC"}
@@ -1,16 +0,0 @@
1
- import { Construct } from "constructs";
2
- import { CanaryParameters } from "./canary-parameters";
3
- import { Role } from "aws-cdk-lib/aws-iam";
4
- import { DigitrafficCanary } from "./canary";
5
- import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
6
- import { DigitrafficStack } from "../stack/stack";
7
- import { DigitrafficRestApi } from "../stack/rest_apis";
8
- export interface UrlCanaryParameters extends CanaryParameters {
9
- readonly hostname: string;
10
- readonly apiKeyId?: string;
11
- }
12
- export declare class UrlCanary extends DigitrafficCanary {
13
- constructor(stack: Construct, role: Role, params: UrlCanaryParameters, secret?: ISecret);
14
- static create(stack: DigitrafficStack, role: Role, publicApi: DigitrafficRestApi, params: Partial<UrlCanaryParameters>): UrlCanary;
15
- static getApiKey(publicApi: DigitrafficRestApi): string | undefined;
16
- }