@digitraffic/common 2022.11.22-1 → 2022.11.23-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 (156) hide show
  1. package/dist/aws/infra/api/integration.d.ts +21 -0
  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 +29 -0
  5. package/dist/aws/infra/api/response.js +36 -11
  6. package/dist/aws/infra/api/response.js.map +1 -0
  7. package/dist/aws/infra/api/responses.d.ts +47 -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.d.ts +15 -0
  11. package/dist/aws/infra/api/static-integration.js.map +1 -0
  12. package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
  13. package/dist/aws/infra/canaries/canary-alarm.js.map +1 -0
  14. package/dist/aws/infra/canaries/canary-keys.d.ts +3 -0
  15. package/dist/aws/infra/canaries/canary-keys.js.map +1 -0
  16. package/dist/aws/infra/canaries/canary-parameters.d.ts +18 -0
  17. package/dist/aws/infra/canaries/canary-parameters.js.map +1 -0
  18. package/dist/aws/infra/canaries/canary-role.d.ts +6 -0
  19. package/dist/aws/infra/canaries/canary-role.js.map +1 -0
  20. package/dist/aws/infra/canaries/canary.d.ts +8 -0
  21. package/dist/aws/infra/canaries/canary.js.map +1 -0
  22. package/dist/aws/infra/canaries/database-canary.d.ts +18 -0
  23. package/dist/aws/infra/canaries/database-canary.js.map +1 -0
  24. package/dist/aws/infra/canaries/database-checker.d.ts +33 -0
  25. package/dist/aws/infra/canaries/database-checker.js.map +1 -0
  26. package/dist/aws/infra/canaries/url-canary.d.ts +16 -0
  27. package/dist/aws/infra/canaries/url-canary.js.map +1 -0
  28. package/dist/aws/infra/canaries/url-checker.d.ts +46 -0
  29. package/dist/aws/infra/canaries/url-checker.js.map +1 -0
  30. package/dist/aws/infra/documentation.d.ts +56 -0
  31. package/dist/aws/infra/documentation.js.map +1 -0
  32. package/dist/aws/infra/import-util.d.ts +21 -0
  33. package/dist/aws/infra/import-util.js.map +1 -0
  34. package/dist/aws/infra/scheduler.d.ts +12 -0
  35. package/dist/aws/infra/scheduler.js.map +1 -0
  36. package/dist/aws/infra/security-rule.d.ts +12 -0
  37. package/dist/aws/infra/security-rule.js.map +1 -0
  38. package/dist/aws/infra/sqs-integration.d.ts +7 -0
  39. package/dist/aws/infra/sqs-integration.js.map +1 -0
  40. package/dist/aws/infra/sqs-queue.d.ts +16 -0
  41. package/dist/aws/infra/sqs-queue.js.map +1 -0
  42. package/dist/aws/infra/stack/lambda-configs.d.ts +64 -0
  43. package/dist/aws/infra/stack/lambda-configs.js.map +1 -0
  44. package/dist/aws/infra/stack/monitoredfunction.d.ts +84 -0
  45. package/dist/aws/infra/stack/monitoredfunction.js +31 -31
  46. package/dist/aws/infra/stack/monitoredfunction.js.map +1 -0
  47. package/dist/aws/infra/stack/rest_apis.d.ts +41 -0
  48. package/dist/aws/infra/stack/rest_apis.js.map +1 -0
  49. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +21 -0
  50. package/dist/aws/infra/stack/stack-checking-aspect.js.map +1 -0
  51. package/dist/aws/infra/stack/stack.d.ts +45 -0
  52. package/dist/aws/infra/stack/stack.js.map +1 -0
  53. package/dist/aws/infra/stack/subscription.d.ts +17 -0
  54. package/dist/aws/infra/stack/subscription.js.map +1 -0
  55. package/dist/aws/infra/stacks/db-dns-stack.d.ts +11 -0
  56. package/dist/aws/infra/stacks/db-dns-stack.js.map +1 -0
  57. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +19 -0
  58. package/dist/aws/infra/stacks/db-proxy-stack.js.map +1 -0
  59. package/dist/aws/infra/stacks/db-stack.d.ts +31 -0
  60. package/dist/aws/infra/stacks/db-stack.js.map +1 -0
  61. package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +5 -0
  62. package/dist/aws/infra/stacks/intra-stack-configuration.js.map +1 -0
  63. package/dist/aws/infra/stacks/network-stack.d.ts +12 -0
  64. package/dist/aws/infra/stacks/network-stack.js.map +1 -0
  65. package/dist/aws/infra/usage-plans.d.ts +16 -0
  66. package/dist/aws/infra/usage-plans.js.map +1 -0
  67. package/dist/aws/runtime/apikey.d.ts +2 -0
  68. package/dist/aws/runtime/apikey.js.map +1 -0
  69. package/dist/aws/runtime/digitraffic-integration-response.d.ts +8 -0
  70. package/dist/aws/runtime/digitraffic-integration-response.js.map +1 -0
  71. package/dist/aws/runtime/environment.d.ts +1 -0
  72. package/dist/aws/runtime/environment.js.map +1 -0
  73. package/dist/aws/runtime/messaging.d.ts +10 -0
  74. package/dist/aws/runtime/messaging.js.map +1 -0
  75. package/dist/aws/runtime/s3.d.ts +2 -0
  76. package/dist/aws/runtime/s3.js.map +1 -0
  77. package/dist/aws/runtime/secrets/dbsecret.d.ts +54 -0
  78. package/dist/aws/runtime/secrets/dbsecret.js +4 -4
  79. package/dist/aws/runtime/secrets/dbsecret.js.map +1 -0
  80. package/dist/aws/runtime/secrets/proxy-holder.d.ts +9 -0
  81. package/dist/aws/runtime/secrets/proxy-holder.js.map +1 -0
  82. package/dist/aws/runtime/secrets/rds-holder.d.ts +9 -0
  83. package/dist/aws/runtime/secrets/rds-holder.js.map +1 -0
  84. package/dist/aws/runtime/secrets/secret-holder.d.ts +26 -0
  85. package/dist/aws/runtime/secrets/secret-holder.js.map +1 -0
  86. package/dist/aws/runtime/secrets/secret.d.ts +8 -0
  87. package/dist/aws/runtime/secrets/secret.js.map +1 -0
  88. package/dist/aws/types/errors.d.ts +8 -0
  89. package/dist/aws/types/errors.js.map +1 -0
  90. package/dist/aws/types/lambda-response.d.ts +13 -0
  91. package/dist/aws/types/lambda-response.js.map +1 -0
  92. package/dist/aws/types/mediatypes.d.ts +11 -0
  93. package/dist/aws/types/mediatypes.js.map +1 -0
  94. package/dist/aws/types/model-with-reference.d.ts +7 -0
  95. package/dist/aws/types/model-with-reference.js.map +1 -0
  96. package/dist/aws/types/proxytypes.d.ts +26 -0
  97. package/dist/aws/types/proxytypes.js.map +1 -0
  98. package/dist/aws/types/tags.d.ts +2 -0
  99. package/dist/aws/types/tags.js.map +1 -0
  100. package/dist/database/cached.d.ts +7 -0
  101. package/dist/database/cached.js.map +1 -0
  102. package/dist/database/database.d.ts +19 -0
  103. package/dist/database/database.js.map +1 -0
  104. package/dist/database/last-updated.d.ts +16 -0
  105. package/dist/database/last-updated.js.map +1 -0
  106. package/dist/database/models.d.ts +6 -0
  107. package/dist/database/models.js.map +1 -0
  108. package/dist/marine/id_utils.d.ts +3 -0
  109. package/dist/marine/id_utils.js.map +1 -0
  110. package/dist/marine/rtz.d.ts +48 -0
  111. package/dist/marine/rtz.js.map +1 -0
  112. package/dist/test/asserter.d.ts +11 -0
  113. package/dist/test/asserter.js.map +1 -0
  114. package/dist/test/db-testutils.d.ts +3 -0
  115. package/dist/test/db-testutils.js.map +1 -0
  116. package/dist/test/httpserver.d.ts +19 -0
  117. package/dist/test/httpserver.js.map +1 -0
  118. package/dist/test/secret.d.ts +3 -0
  119. package/dist/test/secret.js.map +1 -0
  120. package/dist/test/secrets-manager.d.ts +9 -0
  121. package/dist/test/secrets-manager.js.map +1 -0
  122. package/dist/test/testutils.d.ts +12 -0
  123. package/dist/test/testutils.js.map +1 -0
  124. package/dist/types/either.d.ts +9 -0
  125. package/dist/types/either.js.map +1 -0
  126. package/dist/types/input-error.d.ts +2 -0
  127. package/dist/types/input-error.js.map +1 -0
  128. package/dist/types/language.d.ts +5 -0
  129. package/dist/types/language.js.map +1 -0
  130. package/dist/types/traffictype.d.ts +8 -0
  131. package/dist/types/traffictype.js.map +1 -0
  132. package/dist/types/validator.d.ts +4 -0
  133. package/dist/types/validator.js.map +1 -0
  134. package/dist/utils/api-model.d.ts +87 -0
  135. package/dist/utils/api-model.js.map +1 -0
  136. package/dist/utils/base64.d.ts +12 -0
  137. package/dist/utils/base64.js.map +1 -0
  138. package/dist/utils/date-utils.d.ts +17 -0
  139. package/dist/utils/date-utils.js.map +1 -0
  140. package/dist/utils/geojson-types.d.ts +14 -0
  141. package/dist/utils/geojson-types.js.map +1 -0
  142. package/dist/utils/geometry.d.ts +36 -0
  143. package/dist/utils/geometry.js.map +1 -0
  144. package/dist/utils/retry.d.ts +13 -0
  145. package/dist/utils/retry.js.map +1 -0
  146. package/dist/utils/slack.d.ts +5 -0
  147. package/dist/utils/slack.js.map +1 -0
  148. package/dist/utils/utils.d.ts +46 -0
  149. package/dist/utils/utils.js.map +1 -0
  150. package/package.json +19 -29
  151. package/src/aws/infra/api/integration.ts +30 -14
  152. package/src/aws/infra/api/response.ts +83 -20
  153. package/src/aws/infra/api/responses.ts +8 -0
  154. package/src/aws/runtime/secrets/dbsecret.ts +23 -54
  155. package/src/aws/runtime/secrets/secret-holder.ts +6 -3
  156. package/src/database/database.ts +1 -1
@@ -0,0 +1,5 @@
1
+ export declare enum Language {
2
+ FI = "fi",
3
+ EN = "en",
4
+ SV = "sv"
5
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/types/language.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAEX;AAFD,WAAY,QAAQ;IAChB,qBAAS,CAAA;IAAE,qBAAS,CAAA;IAAE,qBAAS,CAAA;AACnC,CAAC,EAFW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAEnB"}
@@ -0,0 +1,8 @@
1
+ export declare enum TrafficType {
2
+ ROAD = "Road",
3
+ MARINE = "Marine",
4
+ RAIL = "Rail",
5
+ AVIATION = "Aviation",
6
+ MCP = "MCP",
7
+ OTHER = "Other"
8
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traffictype.js","sourceRoot":"","sources":["../../src/types/traffictype.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,4BAAa,CAAA;IACb,gCAAiB,CAAA;IACjB,4BAAa,CAAA;IACb,oCAAqB,CAAA;IACrB,0BAAW,CAAA;IACX,8BAAe,CAAA;AACnB,CAAC,EAPW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAOtB"}
@@ -0,0 +1,4 @@
1
+ export declare const MIN_YEAR = 1900;
2
+ export declare const MAX_YEAR = 2100;
3
+ export declare function validateYear(year: number, minYear?: number, maxYear?: number): boolean;
4
+ export declare function validateMonth(month: number): boolean;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/types/validator.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,IAAI,CAAC;AAChB,QAAA,QAAQ,GAAG,IAAI,CAAC;AAE7B,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAO,GAAG,gBAAQ,EAAE,OAAO,GAAG,gBAAQ;IAC7E,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC;AAC9C,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa,CAAC,KAAa;IACvC,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;AACnC,CAAC;AAFD,sCAEC"}
@@ -0,0 +1,87 @@
1
+ import { RestApi, Model, JsonSchema, RequestValidator, JsonSchemaType, JsonSchemaVersion } from 'aws-cdk-lib/aws-apigateway';
2
+ import { ModelWithReference } from "../aws/types/model-with-reference";
3
+ /**
4
+ * Get a reference to an OpenAPI model object in a REST API.
5
+ * Can be used to supply a reference to properties of a GeoJSON feature.
6
+ * @param modelId Id of the referenced object
7
+ * @param restApiId Id of the REST API
8
+ */
9
+ export declare function getModelReference(modelId: string, restApiId: string): string;
10
+ /**
11
+ * Adds a request validator to a REST API to enforce request parameters/body requirements.
12
+ * https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html
13
+ * @param api REST API
14
+ */
15
+ export declare function addDefaultValidator(api: RestApi): RequestValidator;
16
+ /**
17
+ * Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
18
+ * This method adds a schema for _a single object._
19
+ * @param name Name of the model
20
+ * @param api REST API
21
+ * @param schema JSON Schema
22
+ * @return ModelWithReference A model object with a reference to an API Gateway model object.
23
+ */
24
+ export declare function addServiceModel(modelName: string, api: RestApi, schema: JsonSchema): ModelWithReference;
25
+ /**
26
+ * Add an empty JSON schema model to an API Gateway API.
27
+ * Usable for example if the incoming data is in XML format but some template transformation is necessary.
28
+ * @param modelName
29
+ * @param api
30
+ * @param contentType
31
+ */
32
+ export declare function addSimpleServiceModel(modelName: string, api: RestApi, contentType?: string): Model;
33
+ /**
34
+ * Adds a JSON Schema model to an API Gateway API. Can be used later to generate OpenAPI specifications.
35
+ * This method adds a schema for _an array._
36
+ * @param model
37
+ * @param api
38
+ */
39
+ export declare function createArraySchema(model: Model, api: RestApi): JsonSchema;
40
+ /**
41
+ * Creates a JSON Schema for a GeoJSON Feature. Can be used to generate OpenAPI descriptions.
42
+ * @param modelReference Reference to a model object
43
+ */
44
+ export declare function featureSchema(modelReference: string): {
45
+ schema: JsonSchemaVersion;
46
+ type: JsonSchemaType;
47
+ description: string;
48
+ required: string[];
49
+ properties: {
50
+ type: {
51
+ type: JsonSchemaType;
52
+ description: string;
53
+ enum: string[];
54
+ };
55
+ properties: {
56
+ ref: string;
57
+ };
58
+ geometry: {
59
+ type: JsonSchemaType;
60
+ description: string;
61
+ };
62
+ };
63
+ };
64
+ /**
65
+ *
66
+ * Creates a JSON Schema for a GeoJSON Feature Collection. Can be used to generate OpenAPI descriptions.
67
+ * @param modelReference Reference to a model object, in this case Features.
68
+ */
69
+ export declare function geojsonSchema(modelReference: string): {
70
+ schema: JsonSchemaVersion;
71
+ type: JsonSchemaType;
72
+ description: string;
73
+ required: string[];
74
+ properties: {
75
+ type: {
76
+ type: JsonSchemaType;
77
+ description: string;
78
+ enum: string[];
79
+ };
80
+ features: {
81
+ type: JsonSchemaType;
82
+ items: {
83
+ ref: string;
84
+ };
85
+ };
86
+ };
87
+ };
@@ -0,0 +1 @@
1
+ {"version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PD,8CAOC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,cAAsB;IAChD,OAAO;QACH,MAAM,EAAE,kCAAiB,CAAC,MAAM;QAChC,IAAI,EAAE,+BAAc,CAAC,MAAM;QAC3B,WAAW,EAAE,iBAAiB;QAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC;QAC5C,UAAU,EAAE;YACR,IAAI,EAAE;gBACF,IAAI,EAAE,+BAAc,CAAC,MAAM;gBAC3B,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,CAAC,SAAS,CAAC;aACpB;YACD,UAAU,EAAE;gBACR,GAAG,EAAE,cAAc;aACtB;YACD,QAAQ,EAAE;gBACN,IAAI,EAAE,+BAAc,CAAC,MAAM;gBAC3B,WAAW,EAAE,kBAAkB;aAClC;SACJ;KACJ,CAAC;AACN,CAAC;AArBD,sCAqBC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,cAAsB;IAChD,OAAO;QACH,MAAM,EAAE,kCAAiB,CAAC,MAAM;QAChC,IAAI,EAAE,+BAAc,CAAC,MAAM;QAC3B,WAAW,EAAE,2BAA2B;QACxC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;QAC9B,UAAU,EAAE;YACR,IAAI,EAAE;gBACF,IAAI,EAAE,+BAAc,CAAC,MAAM;gBAC3B,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,CAAC,mBAAmB,CAAC;aAC9B;YACD,QAAQ,EAAE;gBACN,IAAI,EAAE,+BAAc,CAAC,KAAK;gBAC1B,KAAK,EAAE;oBACH,GAAG,EAAE,cAAc;iBACtB;aACJ;SACJ;KACJ,CAAC;AACN,CAAC;AApBD,sCAoBC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Decode given string from base64 to ascii
4
+ * @param str string
5
+ */
6
+ export declare function decodeBase64ToAscii(str: string): string;
7
+ /**
8
+ * Decode given string from base64 to given encoding
9
+ * @param str
10
+ * @param encoding
11
+ */
12
+ export declare function decodeBase64(str: string, encoding: BufferEncoding): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,GAAW;IAC3C,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAFD,kDAEC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAW,EAAE,QAAwB;IAC9D,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC;AAFD,oCAEC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Counts difference in milliseconds between dates.
3
+ * @param start
4
+ * @param end
5
+ */
6
+ export declare function countDiffMs(start: Date, end: Date): number;
7
+ /**
8
+ * Counts difference in seconds between dates.
9
+ * @param start
10
+ * @param end
11
+ */
12
+ export declare function countDiffInSeconds(start: Date, end: Date): number;
13
+ /**
14
+ * Converts ISO 8601 date-time -string to Date object
15
+ * @param isoString to convert
16
+ */
17
+ export declare function dateFromIsoString(isoString: string): Date;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-utils.js","sourceRoot":"","sources":["../../src/utils/date-utils.ts"],"names":[],"mappings":";;;AACA;;;;GAIG;AACH,SAAgB,WAAW,CAAC,KAAW,EAAE,GAAS;IAC9C,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;AAC3C,CAAC;AAFD,kCAEC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,KAAW,EAAE,GAAS;IACrD,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,GAAC,IAAI,CAAC;AACxC,CAAC;AAFD,gDAEC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,SAAiB;IAC/C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;QACtD,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC;KAC7D;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAND,8CAMC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * GeoJSON types
3
+ */
4
+ import { LineString, Point, Position } from "geojson";
5
+ export declare class GeoJsonPoint implements Point {
6
+ readonly type = "Point";
7
+ readonly coordinates: Position;
8
+ constructor(coordinates: Position);
9
+ }
10
+ export declare class GeoJsonLineString implements LineString {
11
+ readonly type = "LineString";
12
+ readonly coordinates: Position[];
13
+ constructor(coordinates: Position[]);
14
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geojson-types.js","sourceRoot":"","sources":["../../src/utils/geojson-types.ts"],"names":[],"mappings":";;;AAKA,MAAa,YAAY;IAIrB,YAAY,WAAqB;QAHxB,SAAI,GAAG,OAAO,CAAC;QAIpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ;AAPD,oCAOC;AAED,MAAa,iBAAiB;IAI1B,YAAY,WAAuB;QAH1B,SAAI,GAAG,YAAY,CAAC;QAIzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ;AAPD,8CAOC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * GeoJSON functions and tools
3
+ */
4
+ import { Feature, FeatureCollection, Geometry, Position } from "geojson";
5
+ export declare const SRID_WGS84 = 4326;
6
+ /**
7
+ * Creates WKT geometry from GeoJSON geometry
8
+ * @param geometry GeoJson geometry to convert to WKT
9
+ */
10
+ export declare function createGeometry(geometry: Geometry): string;
11
+ /**
12
+ * Create a GeoJSON FeatureCollection from a list of GeoJSON features with a 'last updated' property
13
+ * @param features List of Features
14
+ * @param lastUpdated Last updated date
15
+ */
16
+ export declare function createFeatureCollection(features: Feature[], lastUpdated: Date | null): FeatureCollection;
17
+ export declare function isValidGeoJson<T>(json: T): boolean;
18
+ export declare function isFeatureCollection<T>(json: T): boolean;
19
+ /**
20
+ * Calculates distance between two GeoJSON points (WGS84)
21
+ * @param pos1
22
+ * @param pos2
23
+ */
24
+ export declare function distanceBetweenPositionsInKm(pos1: Position, pos2: Position): number;
25
+ export declare function areDistinctPositions(previous: Position, next: Position): boolean;
26
+ /**
27
+ * Calculates distance between two GeoJSON points (WGS84)
28
+ * @param pos1
29
+ * @param pos2
30
+ */
31
+ export declare function distanceBetweenPositionsInM(pos1: Position, pos2: Position): number;
32
+ export declare function createGmlLineString(geometry: Geometry, srsName?: string): {
33
+ srsName: string;
34
+ posList: string;
35
+ };
36
+ export declare function positionToList(position: Position, precision?: number): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/utils/geometry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,qEAAuD;AAE1C,QAAA,UAAU,GAAG,IAAI,CAAC;AAE/B;;;GAGG;AACH,SAAgB,cAAc,CAAC,QAAkB;IAC7C,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE;QAChC,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAErD,OAAO,cAAc,WAAW,GAAG,CAAC;KACvC;SAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE;QAClC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEzD,OAAO,SAAS,WAAW,GAAG,CAAC;KAClC;SAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;QACpC,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAElD,OAAO,WAAW,WAAW,GAAG,CAA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AG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAqB,EAAE,SAAS,GAAG,CAAC;IAC1D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxE,CAAC;AAED,SAAgB,cAAc,CAAC,QAAkB,EAAE,SAAS,GAAG,CAAC;IAC5D,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAFD,wCAEC;AAED,sCAAsC;AACtC,SAAS,SAAS,CAAC,MAAc;IAC7B,OAAO,MAAM,GAAG,kBAAkB,CAAC;AACvC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare enum RetryLogError {
2
+ LOG_ALL_AS_ERRORS = 0,
3
+ LOG_LAST_RETRY_AS_ERROR_OTHERS_AS_WARNS = 1,
4
+ NO_LOGGING = 2
5
+ }
6
+ /**
7
+ * Utility function for retrying async functions.
8
+ * @param asyncFn Function
9
+ * @param retries Amount of retries, default is 3. If set to <= 0, no retries will be done. Using non-finite numbers will throw an error. The maximum allowed retry count is 100.
10
+ * @param logError Logging options
11
+ * @return Promise return value
12
+ */
13
+ export declare function retry<T>(asyncFn: () => Promise<T>, retries?: number, logError?: RetryLogError): Promise<T>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,2EAAiB,CAAA;IACjB,uHAAuC,CAAA;IACvC,6DAAU,C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
1
+ export declare class SlackApi {
2
+ private readonly url;
3
+ constructor(url: string);
4
+ notify(text: string): Promise<void>;
5
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../src/utils/slack.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,MAAa,QAAQ;IAIjB,YAAY,GAAW;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACrB,IAAI;YACA,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;YAC9C,MAAM,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;gBACvB,IAAI;aACP,CAAC,CAAC;SACN;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;IACL,CAAC;CAEJ;AAnBD,4BAmBC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Check if arrays have only elements that also exists also in other array.
3
+ * Individual element count doesn't matter.
4
+ * Function works only for primitive types and for other it just checks the reference to object.
5
+ *
6
+ * Some examples
7
+ * bothArraysHasSameValues( [a, b], [b, a] ) => true
8
+ * bothArraysHasSameValues( [a, a], [a, a, a] ) => true
9
+ * bothArraysHasSameValues( [a, b], [a] ) => false
10
+ *
11
+ * Object references:
12
+ * const o1 = { a: 1, b: 2};
13
+ * const o2 = { a: 1, b: 2};
14
+ * // Arrays has references to same objects
15
+ * bothArraysHasSameValues([o1], [o1])) => true
16
+ * Arrays have references to different objects
17
+ * bothArraysHasSameValues([o1], [o2])) => false
18
+ *
19
+ * @param a first array to compare
20
+ * @param b second array to compare
21
+ */
22
+ import { Either } from "../types/either";
23
+ export declare function bothArraysHasSameValues(a: null | undefined | unknown[], b: null | undefined | unknown[]): boolean;
24
+ /**
25
+ * Returns the last item on the array. If the array is empty, throws an error!
26
+ */
27
+ export declare function getLast<T>(array: T[], sortFunction?: (a: T) => number): T;
28
+ /**
29
+ * Returns the first item on the array. If the array is empty, throws an error!
30
+ */
31
+ export declare function getFirst<T>(array: T[], sortFunction?: (a: T) => number): T;
32
+ /**
33
+ * Gets environment variable. Throws error if variable is not found.
34
+ *
35
+ * @param key Environment key
36
+ * @return string
37
+ */
38
+ export declare function getEnvVariable(key: string): string;
39
+ /**
40
+ * Gets environment variable. Safe version returns object with either ok or error status.
41
+ * Easier to use for recovery than catching an error.
42
+ *
43
+ * @param key Environment key
44
+ * @return Either<string>
45
+ */
46
+ export declare function getEnvVariableSafe(key: string): Either<string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AAuBA,SAAgB,uBAAuB,CACnC,CAA+B,EAC/B,CAA+B;IAE/B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KAChB;SAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;QACjB,OAAO,IAAI,CAAC;KACf;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;QACzB,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC;AAfD,0DAeC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAI,KAAU,EAAE,YAA+B;IAClE,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AACtD,CAAC;AAFD,0BAEC;A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ASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2022.11.22-1",
3
+ "version": "2022.11.23-1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,31 +10,25 @@
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
+ },
13
22
  "license": "EUPL-1.2",
14
23
  "private": false,
15
24
  "files": [
16
25
  "dist/**/*.js",
17
26
  "src/**/*.ts"
18
27
  ],
19
- "peerDependencies": {
20
- "pg-promise": "^10.12.0",
21
- "spex": "^3.0.0",
22
- "constructs": "^10.1.131",
23
- "@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
24
- "@types/geojson": "^7946.0.10",
25
- "aws-cdk-lib": "2.50.0",
26
- "aws-sdk": "2.1241.0",
27
- "axios": "^0.21.1",
28
- "change-case": "4.1.2",
29
- "geojson-validation": "^1.0.2",
30
- "moment": "^2.29.4",
31
- "node-ttl": "^0.2.0",
32
- "pg-native": "^3.0.1"
33
- },
34
- "devDependencies": {
28
+ "dependencies": {
35
29
  "@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
36
30
  "@types/geojson": "^7946.0.10",
37
- "aws-cdk-lib": "2.50.0",
31
+ "aws-cdk-lib": "2.51.1",
38
32
  "aws-sdk": "2.1241.0",
39
33
  "axios": "^0.21.1",
40
34
  "change-case": "4.1.2",
@@ -43,7 +37,9 @@
43
37
  "moment": "^2.29.4",
44
38
  "node-ttl": "^0.2.0",
45
39
  "pg-native": "^3.0.1",
46
- "pg-promise": "^10.12.0",
40
+ "pg-promise": "^10.12.0"
41
+ },
42
+ "devDependencies": {
47
43
  "@types/aws-lambda": "^8.10.106",
48
44
  "@types/jest": "^29.0.3",
49
45
  "@types/node": "^18.7.23",
@@ -53,6 +49,7 @@
53
49
  "@typescript-eslint/parser": "^5.39.0",
54
50
  "eslint": "^8.24.0",
55
51
  "eslint-config-prettier": "^8.5.0",
52
+ "eslint-plugin-deprecation": "1.3.3",
56
53
  "husky": ">=6",
57
54
  "jest": "^29.1.1",
58
55
  "jest-junit": "^14.0.1",
@@ -61,8 +58,8 @@
61
58
  "ramda": "^0.28.0",
62
59
  "rimraf": "^3.0.2",
63
60
  "sinon": "^14.0.0",
64
- "ts-jest": "^29.0.2",
65
- "typescript": "^4.7.4"
61
+ "ts-jest": "^29.0.3",
62
+ "typescript": "^4.8.4"
66
63
  },
67
64
  "externals": [
68
65
  "aws-sdk",
@@ -70,12 +67,5 @@
70
67
  ],
71
68
  "lint-staged": {
72
69
  "*.{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"
80
70
  }
81
- }
71
+ }
@@ -1,13 +1,17 @@
1
- import {IntegrationResponse, LambdaIntegration, PassthroughBehavior} from "aws-cdk-lib/aws-apigateway";
2
- import {IFunction} from "aws-cdk-lib/aws-lambda";
3
- import {MediaType} from "../../types/mediatypes";
4
- import {DigitrafficIntegrationResponse} from "../../runtime/digitraffic-integration-response";
1
+ import {
2
+ IntegrationResponse,
3
+ LambdaIntegration,
4
+ PassthroughBehavior,
5
+ } from "aws-cdk-lib/aws-apigateway";
6
+ import { IFunction } from "aws-cdk-lib/aws-lambda";
7
+ import { MediaType } from "../../types/mediatypes";
8
+ import { DigitrafficIntegrationResponse } from "../../runtime/digitraffic-integration-response";
5
9
 
6
- type ParameterType = 'path' | 'querystring';
10
+ type ParameterType = "path" | "querystring";
7
11
 
8
12
  interface ApiParameter {
9
- type: ParameterType
10
- name: string
13
+ type: ParameterType;
14
+ name: string;
11
15
  }
12
16
 
13
17
  export class DigitrafficIntegration {
@@ -22,13 +26,15 @@ export class DigitrafficIntegration {
22
26
  }
23
27
 
24
28
  addPathParameter(...names: string[]): DigitrafficIntegration {
25
- names.forEach(name => this.parameters.push({type: 'path', name}));
29
+ names.forEach((name) => this.parameters.push({ type: "path", name }));
26
30
 
27
31
  return this;
28
32
  }
29
33
 
30
34
  addQueryParameter(...names: string[]): DigitrafficIntegration {
31
- names.forEach(name => this.parameters.push({type: 'querystring', name}));
35
+ names.forEach((name) =>
36
+ this.parameters.push({ type: "querystring", name })
37
+ );
32
38
 
33
39
  return this;
34
40
  }
@@ -39,8 +45,14 @@ export class DigitrafficIntegration {
39
45
  return new LambdaIntegration(this.lambda, {
40
46
  proxy: false,
41
47
  integrationResponses,
42
- requestParameters: this.parameters.length == 0 ? undefined : this.createRequestParameters(),
43
- requestTemplates: this.parameters.length == 0 ? undefined : this.createRequestTemplates(),
48
+ requestParameters:
49
+ this.parameters.length == 0
50
+ ? undefined
51
+ : this.createRequestParameters(),
52
+ requestTemplates:
53
+ this.parameters.length == 0
54
+ ? undefined
55
+ : this.createRequestTemplates(),
44
56
  passthroughBehavior: PassthroughBehavior.WHEN_NO_MATCH,
45
57
  });
46
58
  }
@@ -49,7 +61,9 @@ export class DigitrafficIntegration {
49
61
  const requestParameters: Record<string, string> = {};
50
62
 
51
63
  this.parameters.forEach((parameter: ApiParameter) => {
52
- requestParameters[`integration.request.${parameter.type}.${parameter.name}`] = `method.request.${parameter.type}.${parameter.name}`;
64
+ requestParameters[
65
+ `integration.request.${parameter.type}.${parameter.name}`
66
+ ] = `method.request.${parameter.type}.${parameter.name}`;
53
67
  });
54
68
 
55
69
  return requestParameters;
@@ -59,7 +73,9 @@ export class DigitrafficIntegration {
59
73
  const requestJson: Record<string, string> = {};
60
74
 
61
75
  this.parameters.forEach((parameter: ApiParameter) => {
62
- requestJson[parameter.name] = `$util.escapeJavaScript($input.params('${parameter.name}'))`;
76
+ requestJson[
77
+ parameter.name
78
+ ] = `$util.escapeJavaScript($input.params('${parameter.name}'))`;
63
79
  });
64
80
 
65
81
  return {
@@ -70,4 +86,4 @@ export class DigitrafficIntegration {
70
86
  createResponses(): IntegrationResponse[] {
71
87
  return [DigitrafficIntegrationResponse.ok(this.mediaType)];
72
88
  }
73
- }
89
+ }
@@ -1,5 +1,7 @@
1
- import apigateway = require('aws-cdk-lib/aws-apigateway');
2
- import {MediaType} from "../../types/mediatypes";
1
+ import apigateway = require("aws-cdk-lib/aws-apigateway");
2
+ import { MediaType } from "../../types/mediatypes";
3
+ import { MethodResponse, Model } from "aws-cdk-lib/aws-apigateway";
4
+ import { IModel } from "aws-cdk-lib/aws-apigateway/lib/model";
3
5
 
4
6
  /**
5
7
  * This is velocity-script, that assumes the response to be LambdaResponse(status and body).
@@ -27,11 +29,11 @@ const BODY_FROM_INPUT_PATH = "$input.path('$').body";
27
29
  const messageSchema: apigateway.JsonSchema = {
28
30
  schema: apigateway.JsonSchemaVersion.DRAFT4,
29
31
  type: apigateway.JsonSchemaType.OBJECT,
30
- description: 'Response with message',
32
+ description: "Response with message",
31
33
  properties: {
32
34
  message: {
33
35
  type: apigateway.JsonSchemaType.STRING,
34
- description: 'Response message',
36
+ description: "Response message",
35
37
  },
36
38
  },
37
39
  };
@@ -39,29 +41,90 @@ const messageSchema: apigateway.JsonSchema = {
39
41
  // DEPRECATED
40
42
  export const MessageModel = {
41
43
  contentType: MediaType.APPLICATION_JSON,
42
- modelName: 'MessageResponseModel',
44
+ modelName: "MessageResponseModel",
43
45
  schema: messageSchema,
44
46
  };
45
47
 
46
- const NotFoundMessage = 'Not found';
47
- export const NotFoundResponse = JSON.stringify({message: NotFoundMessage});
48
+ const NotFoundMessage = "Not found";
49
+ export const NotFoundResponse = JSON.stringify({ message: NotFoundMessage });
48
50
 
49
- const InternalServerErrorMessage = 'Error';
50
- const InternalServerErrorResponse = JSON.stringify({message: InternalServerErrorMessage});
51
+ const InternalServerErrorMessage = "Error";
52
+ const InternalServerErrorResponse = JSON.stringify({
53
+ message: InternalServerErrorMessage,
54
+ });
51
55
 
52
- const BadRequestMessage = 'Bad request';
53
- const BadRequestResponse = JSON.stringify({message: BadRequestMessage});
56
+ const BadRequestMessage = "Bad request";
57
+ const BadRequestResponse = JSON.stringify({ message: BadRequestMessage });
54
58
 
55
- export const BadRequestResponseTemplate = createResponses(MediaType.APPLICATION_JSON, BadRequestResponse);
56
- export const NotFoundResponseTemplate = createResponses(MediaType.APPLICATION_JSON, NotFoundResponse);
57
- export const XmlResponseTemplate = createResponses(MediaType.APPLICATION_XML, BODY_FROM_INPUT_PATH);
58
- export const SvgResponseTemplate = createResponses(MediaType.IMAGE_SVG, BODY_FROM_INPUT_PATH);
59
- export const InternalServerErrorResponseTemplate = createResponses(MediaType.APPLICATION_JSON, InternalServerErrorResponse);
59
+ export const BadRequestResponseTemplate = createResponses(
60
+ MediaType.APPLICATION_JSON,
61
+ BadRequestResponse
62
+ );
63
+ export const NotFoundResponseTemplate = createResponses(
64
+ MediaType.APPLICATION_JSON,
65
+ NotFoundResponse
66
+ );
67
+ export const XmlResponseTemplate = createResponses(
68
+ MediaType.APPLICATION_XML,
69
+ BODY_FROM_INPUT_PATH
70
+ );
71
+ export const SvgResponseTemplate = createResponses(
72
+ MediaType.IMAGE_SVG,
73
+ BODY_FROM_INPUT_PATH
74
+ );
75
+ export const InternalServerErrorResponseTemplate = createResponses(
76
+ MediaType.APPLICATION_JSON,
77
+ InternalServerErrorResponse
78
+ );
60
79
 
61
- export function createResponses<T>(key: MediaType, value: T): Record<string, T> {
62
- const map: Record<string, T> = {};
80
+ export function createResponses<T>(
81
+ key: MediaType,
82
+ value: T
83
+ ): Record<string, T> {
84
+ return {
85
+ [key]: value,
86
+ };
87
+ }
88
+
89
+ export class DigitrafficMethodResponse {
90
+ static response(
91
+ statusCode: string,
92
+ model: IModel,
93
+ mediaType: MediaType,
94
+ disableCors = false
95
+ ): MethodResponse {
96
+ return {
97
+ statusCode,
98
+ responseModels: {
99
+ [mediaType]: model,
100
+ },
101
+ responseParameters: disableCors
102
+ ? {}
103
+ : {
104
+ "method.response.header.Access-Control-Allow-Origin":
105
+ true,
106
+ },
107
+ };
108
+ }
63
109
 
64
- map[key] = value;
110
+ static response200(model: IModel, mediaType = MediaType.APPLICATION_JSON) {
111
+ return DigitrafficMethodResponse.response(
112
+ "200",
113
+ model,
114
+ mediaType,
115
+ false
116
+ );
117
+ }
65
118
 
66
- return map;
119
+ static response500(
120
+ model = Model.EMPTY_MODEL,
121
+ mediaType = MediaType.APPLICATION_JSON
122
+ ) {
123
+ return DigitrafficMethodResponse.response(
124
+ "500",
125
+ model,
126
+ mediaType,
127
+ false
128
+ );
129
+ }
67
130
  }