@digitraffic/common 2024.1.10-1 → 2024.1.19-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 (166) hide show
  1. package/dist/aws/infra/api/handler-factory.d.ts +2 -2
  2. package/dist/aws/infra/api/handler-factory.js +4 -9
  3. package/dist/aws/infra/api/integration.d.ts +1 -1
  4. package/dist/aws/infra/api/integration.js +9 -13
  5. package/dist/aws/infra/api/response.d.ts +2 -3
  6. package/dist/aws/infra/api/response.js +25 -30
  7. package/dist/aws/infra/api/responses.d.ts +2 -3
  8. package/dist/aws/infra/api/responses.js +25 -31
  9. package/dist/aws/infra/api/static-integration.d.ts +1 -1
  10. package/dist/aws/infra/api/static-integration.js +7 -11
  11. package/dist/aws/infra/canaries/canary-alarm.d.ts +1 -1
  12. package/dist/aws/infra/canaries/canary-alarm.js +7 -11
  13. package/dist/aws/infra/canaries/canary-keys.js +3 -6
  14. package/dist/aws/infra/canaries/canary-parameters.js +1 -2
  15. package/dist/aws/infra/canaries/canary-role.js +8 -12
  16. package/dist/aws/infra/canaries/canary.d.ts +2 -2
  17. package/dist/aws/infra/canaries/canary.js +9 -13
  18. package/dist/aws/infra/canaries/database-canary.d.ts +3 -3
  19. package/dist/aws/infra/canaries/database-canary.js +8 -12
  20. package/dist/aws/infra/canaries/database-checker.d.ts +1 -1
  21. package/dist/aws/infra/canaries/database-checker.js +10 -14
  22. package/dist/aws/infra/canaries/url-canary.d.ts +4 -4
  23. package/dist/aws/infra/canaries/url-canary.js +8 -12
  24. package/dist/aws/infra/canaries/url-checker.d.ts +2 -2
  25. package/dist/aws/infra/canaries/url-checker.js +33 -40
  26. package/dist/aws/infra/documentation.js +8 -16
  27. package/dist/aws/infra/import-util.js +10 -18
  28. package/dist/aws/infra/scheduler.js +10 -14
  29. package/dist/aws/infra/security-rule.js +4 -8
  30. package/dist/aws/infra/sqs-integration.d.ts +1 -2
  31. package/dist/aws/infra/sqs-integration.js +11 -15
  32. package/dist/aws/infra/sqs-queue.d.ts +1 -1
  33. package/dist/aws/infra/sqs-queue.js +30 -35
  34. package/dist/aws/infra/stack/lambda-configs.d.ts +2 -2
  35. package/dist/aws/infra/stack/lambda-configs.js +14 -20
  36. package/dist/aws/infra/stack/monitoredfunction.d.ts +3 -3
  37. package/dist/aws/infra/stack/monitoredfunction.js +19 -27
  38. package/dist/aws/infra/stack/parameters.d.ts +1 -1
  39. package/dist/aws/infra/stack/parameters.js +5 -10
  40. package/dist/aws/infra/stack/rest_apis.d.ts +3 -3
  41. package/dist/aws/infra/stack/rest_apis.js +41 -54
  42. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +1 -1
  43. package/dist/aws/infra/stack/stack-checking-aspect.js +24 -31
  44. package/dist/aws/infra/stack/stack.d.ts +3 -4
  45. package/dist/aws/infra/stack/stack.js +16 -20
  46. package/dist/aws/infra/stack/subscription.d.ts +2 -2
  47. package/dist/aws/infra/stack/subscription.js +5 -10
  48. package/dist/aws/infra/stacks/db-dns-stack.d.ts +2 -2
  49. package/dist/aws/infra/stacks/db-dns-stack.js +25 -29
  50. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +2 -2
  51. package/dist/aws/infra/stacks/db-proxy-stack.js +23 -27
  52. package/dist/aws/infra/stacks/db-stack.d.ts +3 -4
  53. package/dist/aws/infra/stacks/db-stack.js +30 -34
  54. package/dist/aws/infra/stacks/intra-stack-configuration.js +1 -2
  55. package/dist/aws/infra/stacks/network-stack.d.ts +2 -2
  56. package/dist/aws/infra/stacks/network-stack.js +14 -18
  57. package/dist/aws/infra/usage-plans.js +2 -7
  58. package/dist/aws/runtime/apikey.js +3 -7
  59. package/dist/aws/runtime/digitraffic-integration-response.d.ts +1 -1
  60. package/dist/aws/runtime/digitraffic-integration-response.js +7 -11
  61. package/dist/aws/runtime/dt-logger-default.d.ts +2 -2
  62. package/dist/aws/runtime/dt-logger-default.js +2 -5
  63. package/dist/aws/runtime/dt-logger.d.ts +1 -1
  64. package/dist/aws/runtime/dt-logger.js +3 -10
  65. package/dist/aws/runtime/environment.js +3 -7
  66. package/dist/aws/runtime/messaging.js +1 -5
  67. package/dist/aws/runtime/s3.js +3 -7
  68. package/dist/aws/runtime/secrets/dbsecret.d.ts +1 -1
  69. package/dist/aws/runtime/secrets/dbsecret.js +5 -9
  70. package/dist/aws/runtime/secrets/proxy-holder.js +12 -16
  71. package/dist/aws/runtime/secrets/rds-holder.js +12 -16
  72. package/dist/aws/runtime/secrets/secret-holder.d.ts +1 -1
  73. package/dist/aws/runtime/secrets/secret-holder.js +9 -13
  74. package/dist/aws/runtime/secrets/secret.js +7 -11
  75. package/dist/aws/types/errors.js +5 -9
  76. package/dist/aws/types/lambda-response.js +3 -10
  77. package/dist/aws/types/mediatypes.js +2 -5
  78. package/dist/aws/types/model-with-reference.js +1 -2
  79. package/dist/aws/types/proxytypes.js +1 -2
  80. package/dist/aws/types/tags.js +2 -5
  81. package/dist/database/cached.d.ts +1 -1
  82. package/dist/database/cached.js +8 -14
  83. package/dist/database/database.js +14 -21
  84. package/dist/database/last-updated.d.ts +1 -1
  85. package/dist/database/last-updated.js +8 -17
  86. package/dist/database/models.js +1 -2
  87. package/dist/index.d.ts +1 -0
  88. package/dist/index.js +2 -0
  89. package/dist/marine/id_utils.js +3 -9
  90. package/dist/marine/rtz.js +1 -2
  91. package/dist/test/asserter.js +1 -5
  92. package/dist/test/db-testutils.d.ts +1 -1
  93. package/dist/test/db-testutils.js +8 -13
  94. package/dist/test/httpserver.js +10 -14
  95. package/dist/test/secrets-manager.js +9 -35
  96. package/dist/test/testutils.js +8 -19
  97. package/dist/types/async-timeout-error.js +1 -5
  98. package/dist/types/aws-env.js +1 -2
  99. package/dist/types/either.js +1 -2
  100. package/dist/types/http-error.js +1 -5
  101. package/dist/types/input-error.js +1 -5
  102. package/dist/types/language.js +2 -5
  103. package/dist/types/nullable.d.ts +1 -1
  104. package/dist/types/nullable.js +1 -2
  105. package/dist/types/traffictype.js +2 -5
  106. package/dist/types/urn.js +1 -2
  107. package/dist/types/util-types.js +1 -2
  108. package/dist/types/validator.js +4 -9
  109. package/dist/utils/api-model.d.ts +1 -1
  110. package/dist/utils/api-model.js +17 -27
  111. package/dist/utils/base64.d.ts +1 -1
  112. package/dist/utils/base64.js +2 -7
  113. package/dist/utils/date-utils.js +9 -16
  114. package/dist/utils/geojson-types.js +2 -7
  115. package/dist/utils/geometry.js +15 -48
  116. package/dist/utils/logging.d.ts +1 -1
  117. package/dist/utils/logging.js +8 -13
  118. package/dist/utils/retry.js +21 -26
  119. package/dist/utils/slack.js +7 -14
  120. package/dist/utils/utils.d.ts +2 -2
  121. package/dist/utils/utils.js +14 -29
  122. package/package.json +107 -18
  123. package/src/aws/infra/api/handler-factory.ts +3 -3
  124. package/src/aws/infra/api/integration.ts +2 -2
  125. package/src/aws/infra/api/response.ts +3 -3
  126. package/src/aws/infra/api/responses.ts +4 -4
  127. package/src/aws/infra/api/static-integration.ts +2 -2
  128. package/src/aws/infra/canaries/canary-alarm.ts +1 -1
  129. package/src/aws/infra/canaries/canary.ts +3 -3
  130. package/src/aws/infra/canaries/database-canary.ts +3 -3
  131. package/src/aws/infra/canaries/database-checker.ts +6 -6
  132. package/src/aws/infra/canaries/url-canary.ts +6 -6
  133. package/src/aws/infra/canaries/url-checker.ts +8 -8
  134. package/src/aws/infra/sqs-integration.ts +1 -1
  135. package/src/aws/infra/sqs-queue.ts +2 -2
  136. package/src/aws/infra/stack/lambda-configs.ts +2 -2
  137. package/src/aws/infra/stack/monitoredfunction.ts +4 -4
  138. package/src/aws/infra/stack/parameters.ts +1 -1
  139. package/src/aws/infra/stack/rest_apis.ts +6 -6
  140. package/src/aws/infra/stack/stack-checking-aspect.ts +1 -1
  141. package/src/aws/infra/stack/stack.ts +4 -5
  142. package/src/aws/infra/stack/subscription.ts +2 -2
  143. package/src/aws/infra/stacks/db-dns-stack.ts +4 -4
  144. package/src/aws/infra/stacks/db-proxy-stack.ts +5 -5
  145. package/src/aws/infra/stacks/db-stack.ts +5 -5
  146. package/src/aws/infra/stacks/network-stack.ts +3 -3
  147. package/src/aws/runtime/digitraffic-integration-response.ts +2 -2
  148. package/src/aws/runtime/dt-logger-default.ts +2 -2
  149. package/src/aws/runtime/secrets/dbsecret.ts +1 -1
  150. package/src/aws/runtime/secrets/proxy-holder.ts +4 -4
  151. package/src/aws/runtime/secrets/rds-holder.ts +4 -4
  152. package/src/aws/runtime/secrets/secret-holder.ts +4 -4
  153. package/src/aws/runtime/secrets/secret.ts +2 -2
  154. package/src/database/cached.ts +1 -1
  155. package/src/database/database.ts +3 -3
  156. package/src/database/last-updated.ts +1 -1
  157. package/src/index.ts +2 -0
  158. package/src/test/db-testutils.ts +2 -2
  159. package/src/test/secrets-manager.ts +2 -2
  160. package/src/types/nullable.ts +1 -1
  161. package/src/utils/api-model.ts +1 -1
  162. package/src/utils/geometry.ts +5 -3
  163. package/src/utils/logging.ts +2 -2
  164. package/src/utils/retry.ts +3 -3
  165. package/src/utils/slack.ts +2 -2
  166. package/src/utils/utils.ts +3 -3
@@ -1,44 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shuffle = exports.randomBoolean = exports.getRandomBigInt = exports.getRandomIntegerAsString = exports.getRandomInteger = exports.getRandomNumberAsString = exports.getRandomNumber = exports.randomString = void 0;
4
- function randomString() {
1
+ export function randomString() {
5
2
  return Math.random().toString(36).substring(2);
6
3
  }
7
- exports.randomString = randomString;
8
- function getRandomNumber(min, max) {
4
+ export function getRandomNumber(min, max) {
9
5
  return Math.random() * (max - min) + min;
10
6
  }
11
- exports.getRandomNumber = getRandomNumber;
12
- function getRandomNumberAsString(min, max) {
7
+ export function getRandomNumberAsString(min, max) {
13
8
  return getRandomNumber(min, max).toString();
14
9
  }
15
- exports.getRandomNumberAsString = getRandomNumberAsString;
16
- function getRandomInteger(min, max) {
10
+ export function getRandomInteger(min, max) {
17
11
  return Math.round(getRandomNumber(min, max));
18
12
  }
19
- exports.getRandomInteger = getRandomInteger;
20
- function getRandomIntegerAsString(min, max) {
13
+ export function getRandomIntegerAsString(min, max) {
21
14
  return Math.round(getRandomInteger(min, max)).toString();
22
15
  }
23
- exports.getRandomIntegerAsString = getRandomIntegerAsString;
24
- function getRandomBigInt(min, max) {
16
+ export function getRandomBigInt(min, max) {
25
17
  return BigInt(getRandomInteger(min, max));
26
18
  }
27
- exports.getRandomBigInt = getRandomBigInt;
28
- function randomBoolean() {
19
+ export function randomBoolean() {
29
20
  return Math.random() < 0.5;
30
21
  }
31
- exports.randomBoolean = randomBoolean;
32
22
  /**
33
23
  * Returns a new copy of an array, shuffled using Math.random()
34
24
  * @param array Array
35
25
  */
36
- function shuffle(array) {
26
+ export function shuffle(array) {
37
27
  // pretty fast way to copy an array, not necessarily the fastest
38
28
  const newArray = array.slice(0);
39
29
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
30
  newArray.sort((x) => 0.5 - Math.random());
41
31
  return newArray;
42
32
  }
43
- exports.shuffle = shuffle;
44
33
  //# sourceMappingURL=testutils.js.map
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncTimeoutError = void 0;
4
- class AsyncTimeoutError extends Error {
1
+ export class AsyncTimeoutError extends Error {
5
2
  constructor() {
6
3
  super("Async operation timed out");
7
4
  }
8
5
  }
9
- exports.AsyncTimeoutError = AsyncTimeoutError;
10
6
  //# sourceMappingURL=async-timeout-error.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=aws-env.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=either.js.map
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpError = void 0;
4
- class HttpError extends Error {
1
+ export class HttpError extends Error {
5
2
  constructor(statusCode, message) {
6
3
  super(message);
7
4
  this.statusCode = statusCode;
8
5
  }
9
6
  }
10
- exports.HttpError = HttpError;
11
7
  //# sourceMappingURL=http-error.js.map
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InputError = void 0;
4
- class InputError extends Error {
1
+ export class InputError extends Error {
5
2
  }
6
- exports.InputError = InputError;
7
3
  //# sourceMappingURL=input-error.js.map
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Language = void 0;
4
- var Language;
1
+ export var Language;
5
2
  (function (Language) {
6
3
  Language["FI"] = "fi";
7
4
  Language["EN"] = "en";
8
5
  Language["SV"] = "sv";
9
- })(Language || (exports.Language = Language = {}));
6
+ })(Language || (Language = {}));
10
7
  //# sourceMappingURL=language.js.map
@@ -1,4 +1,4 @@
1
- import { ValueOf } from "./util-types";
1
+ import { ValueOf } from "./util-types.js";
2
2
  /**
3
3
  * Adds `null` as an accepted type to all properties in given type.
4
4
  */
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=nullable.js.map
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TrafficType = void 0;
4
- var TrafficType;
1
+ export var TrafficType;
5
2
  (function (TrafficType) {
6
3
  TrafficType["ROAD"] = "Road";
7
4
  TrafficType["MARINE"] = "Marine";
@@ -9,5 +6,5 @@ var TrafficType;
9
6
  TrafficType["AVIATION"] = "Aviation";
10
7
  TrafficType["MCP"] = "MCP";
11
8
  TrafficType["OTHER"] = "Other";
12
- })(TrafficType || (exports.TrafficType = TrafficType = {}));
9
+ })(TrafficType || (TrafficType = {}));
13
10
  //# sourceMappingURL=traffictype.js.map
package/dist/types/urn.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=urn.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=util-types.js.map
@@ -1,14 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateMonth = exports.validateYear = exports.MAX_YEAR = exports.MIN_YEAR = void 0;
4
- exports.MIN_YEAR = 1900;
5
- exports.MAX_YEAR = 2100;
6
- function validateYear(year, minYear = exports.MIN_YEAR, maxYear = exports.MAX_YEAR) {
1
+ export const MIN_YEAR = 1900;
2
+ export const MAX_YEAR = 2100;
3
+ export function validateYear(year, minYear = MIN_YEAR, maxYear = MAX_YEAR) {
7
4
  return year >= minYear && year <= maxYear;
8
5
  }
9
- exports.validateYear = validateYear;
10
- function validateMonth(month) {
6
+ export function validateMonth(month) {
11
7
  return month > 0 && month < 13;
12
8
  }
13
- exports.validateMonth = validateMonth;
14
9
  //# sourceMappingURL=validator.js.map
@@ -1,5 +1,5 @@
1
1
  import { RestApi, Model, JsonSchema, RequestValidator, JsonSchemaType, JsonSchemaVersion } from 'aws-cdk-lib/aws-apigateway';
2
- import { ModelWithReference } from "../aws/types/model-with-reference";
2
+ import { ModelWithReference } from "../aws/types/model-with-reference.js";
3
3
  /**
4
4
  * Get a reference to an OpenAPI model object in a REST API.
5
5
  * Can be used to supply a reference to properties of a GeoJSON feature.
@@ -1,29 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.geojsonSchema = exports.featureSchema = exports.createArraySchema = exports.addSimpleServiceModel = exports.addServiceModel = exports.addDefaultValidator = exports.getModelReference = void 0;
4
- const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
1
+ import { JsonSchemaType, JsonSchemaVersion, } from 'aws-cdk-lib/aws-apigateway';
5
2
  /**
6
3
  * Get a reference to an OpenAPI model object in a REST API.
7
4
  * Can be used to supply a reference to properties of a GeoJSON feature.
8
5
  * @param modelId Id of the referenced object
9
6
  * @param restApiId Id of the REST API
10
7
  */
11
- function getModelReference(modelId, restApiId) {
8
+ export function getModelReference(modelId, restApiId) {
12
9
  return `https://apigateway.amazonaws.com/restapis/${restApiId}/models/${modelId}`;
13
10
  }
14
- exports.getModelReference = getModelReference;
15
11
  /**
16
12
  * Adds a request validator to a REST API to enforce request parameters/body requirements.
17
13
  * https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html
18
14
  * @param api REST API
19
15
  */
20
- function addDefaultValidator(api) {
16
+ export function addDefaultValidator(api) {
21
17
  return api.addRequestValidator('DefaultValidator', {
22
18
  validateRequestParameters: true,
23
19
  validateRequestBody: true,
24
20
  });
25
21
  }
26
- exports.addDefaultValidator = addDefaultValidator;
27
22
  /**
28
23
  * Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
29
24
  * This method adds a schema for _a single object._
@@ -32,7 +27,7 @@ exports.addDefaultValidator = addDefaultValidator;
32
27
  * @param schema JSON Schema
33
28
  * @return ModelWithReference A model object with a reference to an API Gateway model object.
34
29
  */
35
- function addServiceModel(modelName, api, schema) {
30
+ export function addServiceModel(modelName, api, schema) {
36
31
  const mwr = api.addModel(modelName, {
37
32
  contentType: 'application/json',
38
33
  modelName,
@@ -41,7 +36,6 @@ function addServiceModel(modelName, api, schema) {
41
36
  mwr.modelReference = getModelReference(mwr.modelId, api.restApiId);
42
37
  return mwr;
43
38
  }
44
- exports.addServiceModel = addServiceModel;
45
39
  /**
46
40
  * Add an empty JSON schema model to an API Gateway API.
47
41
  * Usable for example if the incoming data is in XML format but some template transformation is necessary.
@@ -49,42 +43,40 @@ exports.addServiceModel = addServiceModel;
49
43
  * @param api
50
44
  * @param contentType
51
45
  */
52
- function addSimpleServiceModel(modelName, api, contentType = 'application/xml') {
46
+ export function addSimpleServiceModel(modelName, api, contentType = 'application/xml') {
53
47
  return api.addModel(modelName, {
54
48
  contentType,
55
49
  modelName,
56
50
  schema: {},
57
51
  });
58
52
  }
59
- exports.addSimpleServiceModel = addSimpleServiceModel;
60
53
  /**
61
54
  * Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
62
55
  * This method adds a schema for _an array._
63
56
  * @param model
64
57
  * @param api
65
58
  */
66
- function createArraySchema(model, api) {
59
+ export function createArraySchema(model, api) {
67
60
  return {
68
- type: aws_apigateway_1.JsonSchemaType.ARRAY,
61
+ type: JsonSchemaType.ARRAY,
69
62
  items: {
70
63
  ref: getModelReference(model.modelId, api.restApiId),
71
64
  },
72
65
  };
73
66
  }
74
- exports.createArraySchema = createArraySchema;
75
67
  /**
76
68
  * Creates a JSON Schema for a GeoJSON Feature. Can be used to generate OpenAPI descriptions.
77
69
  * @param modelReference Reference to a model object
78
70
  */
79
- function featureSchema(modelReference) {
71
+ export function featureSchema(modelReference) {
80
72
  return {
81
- schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
82
- type: aws_apigateway_1.JsonSchemaType.OBJECT,
73
+ schema: JsonSchemaVersion.DRAFT4,
74
+ type: JsonSchemaType.OBJECT,
83
75
  description: 'GeoJson Feature',
84
76
  required: ['type', 'properties', 'geometry'],
85
77
  properties: {
86
78
  type: {
87
- type: aws_apigateway_1.JsonSchemaType.STRING,
79
+ type: JsonSchemaType.STRING,
88
80
  description: 'Feature',
89
81
  enum: ['Feature'],
90
82
  },
@@ -92,32 +84,31 @@ function featureSchema(modelReference) {
92
84
  ref: modelReference,
93
85
  },
94
86
  geometry: {
95
- type: aws_apigateway_1.JsonSchemaType.OBJECT,
87
+ type: JsonSchemaType.OBJECT,
96
88
  description: 'GeoJSON geometry',
97
89
  },
98
90
  },
99
91
  };
100
92
  }
101
- exports.featureSchema = featureSchema;
102
93
  /**
103
94
  *
104
95
  * Creates a JSON Schema for a GeoJSON Feature Collection. Can be used to generate OpenAPI descriptions.
105
96
  * @param modelReference Reference to a model object, in this case Features.
106
97
  */
107
- function geojsonSchema(modelReference) {
98
+ export function geojsonSchema(modelReference) {
108
99
  return {
109
- schema: aws_apigateway_1.JsonSchemaVersion.DRAFT4,
110
- type: aws_apigateway_1.JsonSchemaType.OBJECT,
100
+ schema: JsonSchemaVersion.DRAFT4,
101
+ type: JsonSchemaType.OBJECT,
111
102
  description: 'GeoJson FeatureCollection',
112
103
  required: ['type', 'features'],
113
104
  properties: {
114
105
  type: {
115
- type: aws_apigateway_1.JsonSchemaType.STRING,
106
+ type: JsonSchemaType.STRING,
116
107
  description: 'FeatureCollection',
117
108
  enum: ['FeatureCollection'],
118
109
  },
119
110
  features: {
120
- type: aws_apigateway_1.JsonSchemaType.ARRAY,
111
+ type: JsonSchemaType.ARRAY,
121
112
  items: {
122
113
  ref: modelReference,
123
114
  },
@@ -125,5 +116,4 @@ function geojsonSchema(modelReference) {
125
116
  },
126
117
  };
127
118
  }
128
- exports.geojsonSchema = geojsonSchema;
129
119
  //# sourceMappingURL=api-model.js.map
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  /**
3
3
  * Decode given string from base64 to ascii
4
4
  * @param str string
@@ -1,21 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeBase64 = exports.decodeBase64ToAscii = void 0;
4
1
  /**
5
2
  * Decode given string from base64 to ascii
6
3
  * @param str string
7
4
  */
8
- function decodeBase64ToAscii(str) {
5
+ export function decodeBase64ToAscii(str) {
9
6
  return decodeBase64(str, 'ascii');
10
7
  }
11
- exports.decodeBase64ToAscii = decodeBase64ToAscii;
12
8
  /**
13
9
  * Decode given string from base64 to given encoding
14
10
  * @param str
15
11
  * @param encoding
16
12
  */
17
- function decodeBase64(str, encoding) {
13
+ export function decodeBase64(str, encoding) {
18
14
  return Buffer.from(str, 'base64').toString(encoding);
19
15
  }
20
- exports.decodeBase64 = decodeBase64;
21
16
  //# sourceMappingURL=base64.js.map
@@ -1,51 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateToUTCString = exports.dateFromIsoString = exports.countDiffInSeconds = exports.countDiffMs = exports.MYSQL_DATETIME_FORMAT = exports.UTC = exports.EPOCH = void 0;
4
- const date_fns_tz_1 = require("date-fns-tz");
1
+ import { formatInTimeZone } from "date-fns-tz";
5
2
  /**
6
3
  * Constant for the 1970-01-01T00:00:00Z epoch Date.
7
4
  */
8
- exports.EPOCH = new Date(Date.UTC(1970, 0, 1));
9
- exports.UTC = "UTC";
10
- exports.MYSQL_DATETIME_FORMAT = "yyyy-MM-dd HH:mm";
5
+ export const EPOCH = new Date(Date.UTC(1970, 0, 1));
6
+ export const UTC = "UTC";
7
+ export const MYSQL_DATETIME_FORMAT = "yyyy-MM-dd HH:mm";
11
8
  /**
12
9
  * Counts difference in milliseconds between dates.
13
10
  * @param start
14
11
  * @param end
15
12
  */
16
- function countDiffMs(start, end) {
13
+ export function countDiffMs(start, end) {
17
14
  return end.getTime() - start.getTime();
18
15
  }
19
- exports.countDiffMs = countDiffMs;
20
16
  /**
21
17
  * Counts difference in seconds between dates.
22
18
  * @param start
23
19
  * @param end
24
20
  */
25
- function countDiffInSeconds(start, end) {
21
+ export function countDiffInSeconds(start, end) {
26
22
  return countDiffMs(start, end) / 1000;
27
23
  }
28
- exports.countDiffInSeconds = countDiffInSeconds;
29
24
  /**
30
25
  * Converts ISO 8601 date-time -string to Date object
31
26
  * @param isoString to convert
32
27
  */
33
- function dateFromIsoString(isoString) {
28
+ export function dateFromIsoString(isoString) {
34
29
  const parsed = new Date(isoString);
35
30
  if (!isValidDate(parsed)) {
36
31
  throw new Error(`Could not parse iso date-time string: "${isoString}" to date`);
37
32
  }
38
33
  return parsed;
39
34
  }
40
- exports.dateFromIsoString = dateFromIsoString;
41
35
  function isValidDate(d) {
42
36
  return d instanceof Date && !isNaN(d.getTime());
43
37
  }
44
38
  /**
45
39
  * Formats a date in UTC in the given format, regardless of system time zone
46
40
  */
47
- function dateToUTCString(date, format) {
48
- return (0, date_fns_tz_1.formatInTimeZone)(date, exports.UTC, format);
41
+ export function dateToUTCString(date, format) {
42
+ return formatInTimeZone(date, UTC, format);
49
43
  }
50
- exports.dateToUTCString = dateToUTCString;
51
44
  //# sourceMappingURL=date-utils.js.map
@@ -1,18 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GeoJsonLineString = exports.GeoJsonPoint = void 0;
4
- class GeoJsonPoint {
1
+ export class GeoJsonPoint {
5
2
  constructor(coordinates) {
6
3
  this.type = "Point";
7
4
  this.coordinates = coordinates;
8
5
  }
9
6
  }
10
- exports.GeoJsonPoint = GeoJsonPoint;
11
- class GeoJsonLineString {
7
+ export class GeoJsonLineString {
12
8
  constructor(coordinates) {
13
9
  this.type = "LineString";
14
10
  this.coordinates = coordinates;
15
11
  }
16
12
  }
17
- exports.GeoJsonLineString = GeoJsonLineString;
18
13
  //# sourceMappingURL=geojson-types.js.map
@@ -1,37 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.positionToList = exports.createGmlLineString = exports.distanceBetweenPositionsInM = exports.areDistinctPositions = exports.distanceBetweenPositionsInKm = exports.isFeatureCollection = exports.isValidGeoJson = exports.createFeatureCollection = exports.createGeometry = exports.SRID_WGS84 = void 0;
27
- const geoJsonValidator = __importStar(require("geojson-validation"));
28
- const dt_logger_default_1 = require("../aws/runtime/dt-logger-default");
29
- exports.SRID_WGS84 = 4326;
1
+ import * as geoJsonValidator from "geojson-validation";
2
+ import { logger } from "../aws/runtime/dt-logger-default.js";
3
+ export const SRID_WGS84 = 4326;
30
4
  /**
31
5
  * Creates WKT geometry from GeoJSON geometry
32
6
  * @param geometry GeoJson geometry to convert to WKT
33
7
  */
34
- function createGeometry(geometry) {
8
+ export function createGeometry(geometry) {
35
9
  if (geometry.type === "LineString") {
36
10
  const coordinates = linestring(geometry.coordinates);
37
11
  return `LINESTRING(${coordinates})`;
@@ -48,13 +22,12 @@ function createGeometry(geometry) {
48
22
  const coordinates = multiPolygon(geometry.coordinates);
49
23
  return `MULTIPOLYGON(${coordinates})`;
50
24
  }
51
- dt_logger_default_1.logger.error({
25
+ logger.error({
52
26
  method: "Geometry.createGeometry",
53
27
  message: "Unsupported locationType " + geometry.type,
54
28
  });
55
29
  return "POLYGON EMPTY";
56
30
  }
57
- exports.createGeometry = createGeometry;
58
31
  function linestring(coordinates) {
59
32
  return coordinates.map((c) => coordinatePair(c)).join(",");
60
33
  }
@@ -74,22 +47,21 @@ function coordinatePair(coordinate) {
74
47
  * @param features List of Features
75
48
  * @param lastUpdated Last updated date
76
49
  */
77
- function createFeatureCollection(features, lastUpdated) {
50
+ export function createFeatureCollection(features, lastUpdated) {
78
51
  return {
79
52
  type: "FeatureCollection",
80
53
  lastUpdated: lastUpdated,
81
54
  features: features,
82
55
  };
83
56
  }
84
- exports.createFeatureCollection = createFeatureCollection;
85
- function isValidGeoJson(json) {
57
+ export function isValidGeoJson(json) {
58
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
86
59
  return geoJsonValidator.valid(json);
87
60
  }
88
- exports.isValidGeoJson = isValidGeoJson;
89
- function isFeatureCollection(json) {
61
+ export function isFeatureCollection(json) {
62
+ // Tests complain about this method returning type string[] which is obviously wrong. Therefore, this casting.
90
63
  return geoJsonValidator.isFeatureCollection(json);
91
64
  }
92
- exports.isFeatureCollection = isFeatureCollection;
93
65
  const DEGREES_TO_RADIANS = 0.017453292519943295; // = Math.PI / 180
94
66
  const EARTH_RADIUS_KM = 6371;
95
67
  /**
@@ -114,31 +86,27 @@ function distanceBetweenWGS84PointsInKm(fromXLon, fromYLat, toXLon, toYLat) {
114
86
  * @param pos1
115
87
  * @param pos2
116
88
  */
117
- function distanceBetweenPositionsInKm(pos1, pos2) {
89
+ export function distanceBetweenPositionsInKm(pos1, pos2) {
118
90
  return distanceBetweenWGS84PointsInKm(pos1[0], pos1[1], pos2[0], pos2[1]);
119
91
  }
120
- exports.distanceBetweenPositionsInKm = distanceBetweenPositionsInKm;
121
- function areDistinctPositions(previous, next) {
92
+ export function areDistinctPositions(previous, next) {
122
93
  return previous[0] !== next[0] || previous[1] !== next[1];
123
94
  }
124
- exports.areDistinctPositions = areDistinctPositions;
125
95
  /**
126
96
  * Calculates distance between two GeoJSON points (WGS84)
127
97
  * @param pos1
128
98
  * @param pos2
129
99
  */
130
- function distanceBetweenPositionsInM(pos1, pos2) {
100
+ export function distanceBetweenPositionsInM(pos1, pos2) {
131
101
  return distanceBetweenPositionsInKm(pos1, pos2) * 1000; // km -> m
132
102
  }
133
- exports.distanceBetweenPositionsInM = distanceBetweenPositionsInM;
134
- function createGmlLineString(geometry, srsName = "EPSG:4326") {
103
+ export function createGmlLineString(geometry, srsName = "EPSG:4326") {
135
104
  const posList = createPosList(geometry);
136
105
  return {
137
106
  srsName,
138
107
  posList,
139
108
  };
140
109
  }
141
- exports.createGmlLineString = createGmlLineString;
142
110
  function createPosList(geometry) {
143
111
  if (geometry.type === "Point") {
144
112
  return positionToList(geometry.coordinates);
@@ -157,10 +125,9 @@ function polygonToList(positions, precision = 8) {
157
125
  function lineStringToList(positions, precision = 8) {
158
126
  return positions.map((p) => positionToList(p, precision)).join(" ");
159
127
  }
160
- function positionToList(position, precision = 8) {
128
+ export function positionToList(position, precision = 8) {
161
129
  return position.map((n) => n.toPrecision(precision)).join(" ");
162
130
  }
163
- exports.positionToList = positionToList;
164
131
  // Converts numeric degrees to radians
165
132
  function toRadians(angdeg) {
166
133
  return angdeg * DEGREES_TO_RADIANS;
@@ -1,4 +1,4 @@
1
- import { DtLogger } from "../aws/runtime/dt-logger";
1
+ import { DtLogger } from "../aws/runtime/dt-logger.js";
2
2
  /**
3
3
  * Curried version of logException.
4
4
  *
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logException = exports.createExceptionLogger = void 0;
4
- const axios_1 = require("axios");
5
- const dt_logger_1 = require("../aws/runtime/dt-logger");
6
- const utils_1 = require("./utils");
7
- const functionName = (0, utils_1.getEnvVariableOrElse)("AWS_LAMBDA_FUNCTION_NAME", "test");
1
+ import { AxiosError } from "axios";
2
+ import { DtLogger } from "../aws/runtime/dt-logger.js";
3
+ import { getEnvVariableOrElse } from "./utils.js";
4
+ const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
8
5
  /**
9
6
  * Curried version of logException.
10
7
  *
@@ -21,19 +18,18 @@ const functionName = (0, utils_1.getEnvVariableOrElse)("AWS_LAMBDA_FUNCTION_NAME
21
18
  * @returns Logs the error without rethrowing.
22
19
  * @see {@link logException}
23
20
  */
24
- function createExceptionLogger(logger = undefined, includeStack = false) {
21
+ export function createExceptionLogger(logger = undefined, includeStack = false) {
25
22
  let thatLogger;
26
23
  if (logger) {
27
24
  thatLogger = logger;
28
25
  }
29
26
  else {
30
- thatLogger = new dt_logger_1.DtLogger();
27
+ thatLogger = new DtLogger();
31
28
  }
32
29
  return (error) => {
33
30
  logException(thatLogger, error, includeStack);
34
31
  };
35
32
  }
36
- exports.createExceptionLogger = createExceptionLogger;
37
33
  /**
38
34
  * Log given exception with level ERROR to given logger.
39
35
  *
@@ -46,14 +42,14 @@ exports.createExceptionLogger = createExceptionLogger;
46
42
  * @see {@link DtLogger.log}
47
43
  * @see {@link createExceptionLogger} for a curried setup
48
44
  */
49
- function logException(logger, error, includeStack = false) {
45
+ export function logException(logger, error, includeStack = false) {
50
46
  const message = error instanceof Error
51
47
  ? error.message
52
48
  : typeof error === "string"
53
49
  ? error
54
50
  : JSON.stringify(error);
55
51
  const stack = error instanceof Error && includeStack ? error.stack : undefined;
56
- const customCode = error instanceof axios_1.AxiosError ? error.code : undefined;
52
+ const customCode = error instanceof AxiosError ? error.code : undefined;
57
53
  logger.error({
58
54
  type: "Error",
59
55
  method: `${functionName}.logException`,
@@ -62,5 +58,4 @@ function logException(logger, error, includeStack = false) {
62
58
  stack,
63
59
  });
64
60
  }
65
- exports.logException = logException;
66
61
  //# sourceMappingURL=logging.js.map