@digitraffic/common 2022.10.5

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 (199) hide show
  1. package/LICENSE +291 -0
  2. package/aws/infra/api/integration.d.ts +21 -0
  3. package/aws/infra/api/integration.js +52 -0
  4. package/aws/infra/api/response.d.ts +22 -0
  5. package/aws/infra/api/response.js +61 -0
  6. package/aws/infra/api/responses.d.ts +39 -0
  7. package/aws/infra/api/responses.js +79 -0
  8. package/aws/infra/api/static-integration.d.ts +15 -0
  9. package/aws/infra/api/static-integration.js +54 -0
  10. package/aws/infra/canaries/canary-alarm.d.ts +6 -0
  11. package/aws/infra/canaries/canary-alarm.js +26 -0
  12. package/aws/infra/canaries/canary-parameters.d.ts +18 -0
  13. package/aws/infra/canaries/canary-parameters.js +3 -0
  14. package/aws/infra/canaries/canary-role.d.ts +6 -0
  15. package/aws/infra/canaries/canary-role.js +46 -0
  16. package/aws/infra/canaries/canary.d.ts +8 -0
  17. package/aws/infra/canaries/canary.js +29 -0
  18. package/aws/infra/canaries/database-canary.d.ts +18 -0
  19. package/aws/infra/canaries/database-canary.js +55 -0
  20. package/aws/infra/canaries/database-checker.d.ts +21 -0
  21. package/aws/infra/canaries/database-checker.js +109 -0
  22. package/aws/infra/canaries/url-canary.d.ts +19 -0
  23. package/aws/infra/canaries/url-canary.js +46 -0
  24. package/aws/infra/canaries/url-checker.d.ts +46 -0
  25. package/aws/infra/canaries/url-checker.js +238 -0
  26. package/aws/infra/documentation.d.ts +56 -0
  27. package/aws/infra/documentation.js +95 -0
  28. package/aws/infra/scheduler.d.ts +12 -0
  29. package/aws/infra/scheduler.js +31 -0
  30. package/aws/infra/security-rule.d.ts +12 -0
  31. package/aws/infra/security-rule.js +39 -0
  32. package/aws/infra/sqs-integration.d.ts +7 -0
  33. package/aws/infra/sqs-integration.js +93 -0
  34. package/aws/infra/sqs-queue.d.ts +16 -0
  35. package/aws/infra/sqs-queue.js +130 -0
  36. package/aws/infra/stack/lambda-configs.d.ts +72 -0
  37. package/aws/infra/stack/lambda-configs.js +93 -0
  38. package/aws/infra/stack/monitoredfunction.d.ts +84 -0
  39. package/aws/infra/stack/monitoredfunction.js +135 -0
  40. package/aws/infra/stack/rest_apis.d.ts +40 -0
  41. package/aws/infra/stack/rest_apis.js +179 -0
  42. package/aws/infra/stack/stack-checking-aspect.d.ts +20 -0
  43. package/aws/infra/stack/stack-checking-aspect.js +163 -0
  44. package/aws/infra/stack/stack.d.ts +41 -0
  45. package/aws/infra/stack/stack.js +58 -0
  46. package/aws/infra/stack/subscription.d.ts +17 -0
  47. package/aws/infra/stack/subscription.js +41 -0
  48. package/aws/infra/usage-plans.d.ts +15 -0
  49. package/aws/infra/usage-plans.js +42 -0
  50. package/aws/runtime/apikey.d.ts +2 -0
  51. package/aws/runtime/apikey.js +13 -0
  52. package/aws/runtime/digitraffic-integration-response.d.ts +8 -0
  53. package/aws/runtime/digitraffic-integration-response.js +26 -0
  54. package/aws/runtime/messaging.d.ts +10 -0
  55. package/aws/runtime/messaging.js +31 -0
  56. package/aws/runtime/s3.d.ts +2 -0
  57. package/aws/runtime/s3.js +30 -0
  58. package/aws/runtime/secrets/dbsecret.d.ts +54 -0
  59. package/aws/runtime/secrets/dbsecret.js +96 -0
  60. package/aws/runtime/secrets/proxy-holder.d.ts +9 -0
  61. package/aws/runtime/secrets/proxy-holder.js +26 -0
  62. package/aws/runtime/secrets/rds-holder.d.ts +9 -0
  63. package/aws/runtime/secrets/rds-holder.js +26 -0
  64. package/aws/runtime/secrets/secret-holder.d.ts +26 -0
  65. package/aws/runtime/secrets/secret-holder.js +73 -0
  66. package/aws/runtime/secrets/secret.d.ts +8 -0
  67. package/aws/runtime/secrets/secret.js +43 -0
  68. package/aws/types/errors.d.ts +4 -0
  69. package/aws/types/errors.js +9 -0
  70. package/aws/types/lambda-response.d.ts +12 -0
  71. package/aws/types/lambda-response.js +28 -0
  72. package/aws/types/mediatypes.d.ts +10 -0
  73. package/aws/types/mediatypes.js +15 -0
  74. package/aws/types/model-with-reference.d.ts +7 -0
  75. package/aws/types/model-with-reference.js +3 -0
  76. package/aws/types/proxytypes.d.ts +26 -0
  77. package/aws/types/proxytypes.js +3 -0
  78. package/aws/types/tags.d.ts +2 -0
  79. package/aws/types/tags.js +7 -0
  80. package/database/cached.d.ts +7 -0
  81. package/database/cached.js +32 -0
  82. package/database/database.d.ts +19 -0
  83. package/database/database.js +62 -0
  84. package/database/last-updated.d.ts +16 -0
  85. package/database/last-updated.js +54 -0
  86. package/index.d.ts +1 -0
  87. package/index.js +18 -0
  88. package/marine/id_utils.d.ts +3 -0
  89. package/marine/id_utils.js +33 -0
  90. package/marine/rtz.d.ts +48 -0
  91. package/marine/rtz.js +3 -0
  92. package/package.json +55 -0
  93. package/src/aws/infra/api/integration.js +52 -0
  94. package/src/aws/infra/api/response.js +61 -0
  95. package/src/aws/infra/api/responses.js +79 -0
  96. package/src/aws/infra/api/static-integration.js +54 -0
  97. package/src/aws/infra/canaries/canary-alarm.js +26 -0
  98. package/src/aws/infra/canaries/canary-parameters.js +3 -0
  99. package/src/aws/infra/canaries/canary-role.js +46 -0
  100. package/src/aws/infra/canaries/canary.js +29 -0
  101. package/src/aws/infra/canaries/database-canary.js +55 -0
  102. package/src/aws/infra/canaries/database-checker.js +109 -0
  103. package/src/aws/infra/canaries/url-canary.js +46 -0
  104. package/src/aws/infra/canaries/url-checker.js +238 -0
  105. package/src/aws/infra/documentation.js +95 -0
  106. package/src/aws/infra/scheduler.js +31 -0
  107. package/src/aws/infra/security-rule.js +39 -0
  108. package/src/aws/infra/sqs-integration.js +93 -0
  109. package/src/aws/infra/sqs-queue.js +130 -0
  110. package/src/aws/infra/stack/lambda-configs.js +93 -0
  111. package/src/aws/infra/stack/monitoredfunction.js +135 -0
  112. package/src/aws/infra/stack/rest_apis.js +179 -0
  113. package/src/aws/infra/stack/stack-checking-aspect.js +163 -0
  114. package/src/aws/infra/stack/stack.js +58 -0
  115. package/src/aws/infra/stack/subscription.js +41 -0
  116. package/src/aws/infra/usage-plans.js +42 -0
  117. package/src/aws/runtime/apikey.js +13 -0
  118. package/src/aws/runtime/digitraffic-integration-response.js +26 -0
  119. package/src/aws/runtime/messaging.js +31 -0
  120. package/src/aws/runtime/s3.js +30 -0
  121. package/src/aws/runtime/secrets/dbsecret.js +96 -0
  122. package/src/aws/runtime/secrets/proxy-holder.js +26 -0
  123. package/src/aws/runtime/secrets/rds-holder.js +26 -0
  124. package/src/aws/runtime/secrets/secret-holder.js +73 -0
  125. package/src/aws/runtime/secrets/secret.js +43 -0
  126. package/src/aws/types/errors.js +9 -0
  127. package/src/aws/types/lambda-response.js +28 -0
  128. package/src/aws/types/mediatypes.js +15 -0
  129. package/src/aws/types/model-with-reference.js +3 -0
  130. package/src/aws/types/proxytypes.js +3 -0
  131. package/src/aws/types/tags.js +7 -0
  132. package/src/database/cached.js +32 -0
  133. package/src/database/database.js +62 -0
  134. package/src/database/last-updated.js +54 -0
  135. package/src/marine/id_utils.js +33 -0
  136. package/src/marine/rtz.js +3 -0
  137. package/src/test/asserter.js +45 -0
  138. package/src/test/db-testutils.js +31 -0
  139. package/src/test/httpserver.js +67 -0
  140. package/src/test/secret.js +25 -0
  141. package/src/test/secrets-manager.js +59 -0
  142. package/src/test/testutils.js +44 -0
  143. package/src/types/input-error.js +7 -0
  144. package/src/types/language.js +10 -0
  145. package/src/types/traffictype.js +13 -0
  146. package/src/types/validator.js +14 -0
  147. package/src/utils/api-model.js +129 -0
  148. package/src/utils/base64.js +21 -0
  149. package/src/utils/date-utils.js +34 -0
  150. package/src/utils/geojson-types.js +18 -0
  151. package/src/utils/geometry.js +140 -0
  152. package/src/utils/retry.js +50 -0
  153. package/src/utils/slack.js +25 -0
  154. package/src/utils/utils.js +40 -0
  155. package/test/asserter.d.ts +11 -0
  156. package/test/asserter.js +45 -0
  157. package/test/db-testutils.d.ts +2 -0
  158. package/test/db-testutils.js +31 -0
  159. package/test/httpserver.d.ts +18 -0
  160. package/test/httpserver.js +67 -0
  161. package/test/marine/id_utils.test.js +69 -0
  162. package/test/promise/promise.test.js +125 -0
  163. package/test/secret.d.ts +3 -0
  164. package/test/secret.js +25 -0
  165. package/test/secrets/dbsecret.test.js +71 -0
  166. package/test/secrets/secret-holder.test.js +124 -0
  167. package/test/secrets/secret.test.js +66 -0
  168. package/test/secrets-manager.d.ts +9 -0
  169. package/test/secrets-manager.js +59 -0
  170. package/test/test/httpserver.test.js +87 -0
  171. package/test/testutils.d.ts +12 -0
  172. package/test/testutils.js +44 -0
  173. package/test/utils/date-utils.test.js +51 -0
  174. package/test/utils/geometry.test.js +49 -0
  175. package/test/utils/utils.test.js +49 -0
  176. package/types/input-error.d.ts +2 -0
  177. package/types/input-error.js +7 -0
  178. package/types/language.d.ts +5 -0
  179. package/types/language.js +10 -0
  180. package/types/traffictype.d.ts +8 -0
  181. package/types/traffictype.js +13 -0
  182. package/types/validator.d.ts +4 -0
  183. package/types/validator.js +14 -0
  184. package/utils/api-model.d.ts +87 -0
  185. package/utils/api-model.js +129 -0
  186. package/utils/base64.d.ts +12 -0
  187. package/utils/base64.js +21 -0
  188. package/utils/date-utils.d.ts +17 -0
  189. package/utils/date-utils.js +34 -0
  190. package/utils/geojson-types.d.ts +14 -0
  191. package/utils/geojson-types.js +18 -0
  192. package/utils/geometry.d.ts +36 -0
  193. package/utils/geometry.js +140 -0
  194. package/utils/retry.d.ts +13 -0
  195. package/utils/retry.js +50 -0
  196. package/utils/slack.d.ts +5 -0
  197. package/utils/slack.js +25 -0
  198. package/utils/utils.d.ts +22 -0
  199. package/utils/utils.js +40 -0
package/LICENSE ADDED
@@ -0,0 +1,291 @@
1
+ European Union Public Licence
2
+ V. 1.2
3
+
4
+
5
+ EUPL © the European Union 2007, 2013
6
+
7
+
8
+ This European Union Public Licence (the “EUPL”) applies to the Work (as defined
9
+ below) which is provided under the terms of this Licence. Any use of the Work, other
10
+ than as authorised under this Licence is prohibited (to the extent such use is covered by
11
+ a right of the copyright holder of the Work).
12
+
13
+ The Original Work is provided under the terms of this Licence when the Licensor (as
14
+ defined below) has placed the following notice immediately following the copyright
15
+ notice for the Original Work:
16
+
17
+ Licensed under the EUPL
18
+
19
+ or has expressed by any other means his willingness to license under the EUPL.
20
+
21
+ 1. Definitions
22
+
23
+ In this Licence, the following terms have the following meaning:
24
+
25
+ - The Licence: this Licence.
26
+
27
+ - The Original Work: the work or software distributed and/or communicated by the
28
+ Licensor under this Licence, available as Source Code and also as Executable Code as
29
+ the case may be.
30
+
31
+ - Derivative Works: the works or software that could be created by the Licensee, based
32
+ upon the Original Work or modifications thereof. This Licence does not define the
33
+ extent of modification or dependence on the Original Work required in order to classify
34
+ a work as a Derivative Work; this extent is determined by copyright law applicable in
35
+ the country mentioned in Article 15.
36
+
37
+ - The Work: the Original Work and/or its Derivative Works.
38
+
39
+ - The Source Code: the human-readable form of the Work which is the most convenient
40
+ for people to study and modify.
41
+
42
+ - The Executable Code: any code which has generally been compiled and which is
43
+ meant to be interpreted by a computer as a program.
44
+
45
+ - The Licensor: the natural or legal person that distributes and/or communicates the
46
+ Work under the Licence.
47
+
48
+ - Contributor(s): any natural or legal person who modifies the Work under the Licence,
49
+ or otherwise contributes to the creation of a Derivative Work.
50
+
51
+ - The Licensee or “You”: any natural or legal person who makes any usage of the Work
52
+ under the terms of the Licence.
53
+
54
+ - Distribution and/or Communication: any act of selling, giving, lending, renting,
55
+ distributing, communicating, transmitting, or otherwise making available, on-line or
56
+ off-line, copies of the Work or providing access to its essential functionalities at the
57
+ disposal of any other natural or legal person.
58
+
59
+ 2. Scope of the rights granted by the Licence
60
+
61
+ The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, sub-
62
+ licensable licence to do the following, for the duration of copyright vested in the
63
+ Original Work:
64
+
65
+ - use the Work in any circumstance and for all usage,
66
+ - reproduce the Work,
67
+ - modify the Original Work, and make Derivative Works based upon the Work,
68
+ - communicate to the public, including the right to make available or display the
69
+ Work or copies thereof to the public and perform publicly, as the case may be,
70
+ the Work,
71
+ - distribute the Work or copies thereof,
72
+ - lend and rent the Work or copies thereof,
73
+ - sub-license rights in the Work or copies thereof.
74
+
75
+ Those rights can be exercised on any media, supports and formats, whether now known
76
+ or later invented, as far as the applicable law permits so.
77
+
78
+ In the countries where moral rights apply, the Licensor waives his right to exercise his
79
+ moral right to the extent allowed by law in order to make effective the licence of the
80
+ economic rights here above listed.
81
+
82
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any
83
+ patents held by the Licensor, to the extent necessary to make use of the rights granted
84
+ on the Work under this Licence.
85
+
86
+ 3. Communication of the Source Code
87
+
88
+ The Licensor may provide the Work either in its Source Code form, or as Executable
89
+ Code. If the Work is provided as Executable Code, the Licensor provides in addition a
90
+ machine-readable copy of the Source Code of the Work along with each copy of the
91
+ Work that the Licensor distributes or indicates, in a notice following the copyright
92
+ notice attached to the Work, a repository where the Source Code is easily and freely
93
+ accessible for as long as the Licensor continues to distribute and/or communicate the
94
+ Work.
95
+
96
+ 4. Limitations on copyright
97
+
98
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any
99
+ exception or limitation to the exclusive rights of the rights owners in the Original Work,
100
+ of the exhaustion of those rights or of other applicable limitations thereto.
101
+
102
+ 5. Obligations of the Licensee
103
+
104
+ The grant of the rights mentioned above is subject to some restrictions and obligations
105
+ imposed on the Licensee. Those obligations are the following:
106
+
107
+ Attribution right: the Licensee shall keep intact all copyright, patent or trademarks
108
+ notices and all notices that refer to the Licence and to the disclaimer of warranties. The
109
+ Licensee must include a copy of such notices and a copy of the Licence with every copy
110
+ of the Work he/she distributes and/or communicates. The Licensee must cause any
111
+ Derivative Work to carry prominent notices stating that the Work has been modified
112
+ and the date of modification.
113
+
114
+ Copyleft clause: If the Licensee distributes or communicates copies of the Original
115
+ Works or Derivative Works, this Distribution or Communication will be done under the
116
+ terms of this Licence or of a later version of this Licence unless the Original Work is
117
+ expressly distributed only under this version of the Licence – for example by stating
118
+ “EUPL v. 1.2 only”. The Licensee (becoming Licensor) cannot offer or impose any
119
+ additional terms or conditions on the Work or Derivative Work that alter or restrict the
120
+ terms of the Licence.
121
+
122
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative Works
123
+ or copies thereof based upon both the Original Work and another work licensed under
124
+ a Compatible Licence, this Distribution or Communication can be done under the terms
125
+ of this Compatible Licence. For the sake of this clause, “Compatible Licence” refers to
126
+ the licences listed in the appendix attached to this Licence. Should the Licensee’s
127
+ obligations under the Compatible Licence conflict with his/her obligations under this
128
+ Licence, the obligations of the Compatible Licence shall prevail.
129
+
130
+ Provision of Source Code: When distributing and/or communicating copies of the
131
+ Work, the Licensee will provide a machine-readable copy of the Source Code or
132
+ indicate a repository where this Source will be easily and freely available for as long as
133
+ the Licensee continues to distribute and/or communicate the Work.
134
+
135
+ Legal Protection: This Licence does not grant permission to use the trade names,
136
+ trademarks, service marks, or names of the Licensor, except as required for reasonable
137
+ and customary use in describing the origin of the Work and reproducing the content of
138
+ the copyright notice.
139
+
140
+ 6. Chain of Authorship
141
+
142
+ The original Licensor warrants that the copyright in the Original Work granted
143
+ hereunder is owned by him/her or licensed to him/her and that he/she has the power and
144
+ authority to grant the Licence.
145
+
146
+ Each Contributor warrants that the copyright in the modifications he/she brings to the
147
+ Work are owned by him/her or licensed to him/her and that he/she has the power and
148
+ authority to grant the Licence.
149
+
150
+ Each time You accept the Licence, the original Licensor and subsequent Contributors
151
+ grant You a licence to their contributions to the Work, under the terms of this Licence.
152
+
153
+ 7. Disclaimer of Warranty
154
+
155
+ The Work is a work in progress, which is continuously improved by numerous
156
+ Contributors. It is not a finished work and may therefore contain defects or “bugs”
157
+ inherent to this type of development.
158
+
159
+ For the above reason, the Work is provided under the Licence on an “as is” basis and
160
+ without warranties of any kind concerning the Work, including without limitation
161
+ merchantability, fitness for a particular purpose, absence of defects or errors, accuracy,
162
+ non-infringement of intellectual property rights other than copyright as stated in Article
163
+ 6 of this Licence.
164
+
165
+ This disclaimer of warranty is an essential part of the Licence and a condition for the
166
+ grant of any rights to the Work.
167
+
168
+ 8. Disclaimer of Liability
169
+
170
+ Except in the cases of wilful misconduct or damages directly caused to natural persons,
171
+ the Licensor will in no event be liable for any direct or indirect, material or moral,
172
+ damages of any kind, arising out of the Licence or of the use of the Work, including
173
+ without limitation, damages for loss of goodwill, work stoppage, computer failure or
174
+ malfunction, loss of data or any commercial damage, even if the Licensor has been
175
+ advised of the possibility of such damage. However, the Licensor will be liable under
176
+ statutory product liability laws as far such laws apply to the Work.
177
+
178
+ 9. Additional agreements
179
+
180
+ While distributing the Original Work or Derivative Works, You may choose to
181
+ conclude an additional agreement, defining obligations and/or services consistent with
182
+ this Licence. However, if accepting obligations, You may act only on your own behalf
183
+ and on your sole responsibility, not on behalf of the original Licensor or any other
184
+ Contributor, and only if You agree to indemnify, defend, and hold each Contributor
185
+ harmless for any liability incurred by, or claims asserted against such Contributor by
186
+ the fact You have accepted any warranty or additional liability.
187
+
188
+ 10. Acceptance of the Licence
189
+
190
+ The provisions of this Licence can be accepted by clicking on an icon “I agree” placed
191
+ under the bottom of a window displaying the text of this Licence or by affirming
192
+ consent in any other similar way, in accordance with the rules of applicable law.
193
+ Clicking on that icon indicates your clear and irrevocable acceptance of this Licence
194
+ and all of its terms and conditions.
195
+
196
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by
197
+ exercising any rights granted to You by Article 2 of this Licence, such as the use of the
198
+ Work, the creation by You of a Derivative Work or the Distribution or Communication
199
+ by You of the Work or copies thereof.
200
+
201
+ 11. Information to the public
202
+
203
+ In case of any Distribution and/or Communication of the Work by means of electronic
204
+ communication by You (for example, by offering to download the Work from a remote
205
+ location) the distribution channel or media (for example, a website) must at least
206
+ provide to the public the information requested by the applicable law regarding the
207
+ Licensor, the Licence and the way it may be accessible, concluded, stored and
208
+ reproduced by the Licensee.
209
+
210
+ 12. Termination of the Licence
211
+
212
+ The Licence and the rights granted hereunder will terminate automatically upon any
213
+ breach by the Licensee of the terms of the Licence.
214
+
215
+ Such a termination will not terminate the licences of any person who has received the
216
+ Work from the Licensee under the Licence, provided such persons remain in full
217
+ compliance with the Licence.
218
+
219
+ 13. Miscellaneous
220
+
221
+ Without prejudice of Article 9 above, the Licence represents the complete agreement
222
+ between the Parties as to the Work.
223
+
224
+ If any provision of the Licence is invalid or unenforceable under applicable law, this
225
+ will not affect the validity or enforceability of the Licence as a whole. Such provision
226
+ will be construed and/or reformed so as necessary to make it valid and enforceable.
227
+
228
+ The European Commission may publish other linguistic versions and/or new versions
229
+ of this Licence and/or updated versions of the Appendix, so far this is required and
230
+ reasonable, without reducing the scope of the rights granted by the Licence. New
231
+ versions of the Licence will be published with a unique version number.
232
+
233
+ All linguistic versions of this Licence, approved by the European Commission, have
234
+ identical value. Parties can take advantage of the linguistic version of their choice.
235
+
236
+ 14. Jurisdiction
237
+
238
+ Without prejudice to specific agreement between parties,
239
+ - any litigation resulting from the interpretation of this License, arising between the
240
+ European Union institutions, bodies, offices or agencies, as a Licensor, and any
241
+ Licensee, will be subject to the jurisdiction of the Court of Justice of the European
242
+ Union, as laid down in article 272 of the Treaty on the Functioning of the European
243
+ Union,
244
+ - any litigation arising between other parties and resulting from the interpretation of
245
+ this License, will be subject to the exclusive jurisdiction of the competent court
246
+ where the Licensor resides or conducts its primary business.
247
+
248
+ 15. Applicable Law
249
+
250
+ Without prejudice to specific agreement between parties,
251
+ - this Licence shall be governed by the law of the European Union Member State
252
+ where the Licensor has his seat, resides or has his registered office,
253
+ - this licence shall be governed by Belgian law if the Licensor has no seat, residence
254
+ or registered office inside a European Union Member State.
255
+
256
+ ===
257
+
258
+
259
+ Appendix
260
+
261
+
262
+
263
+ “Compatible Licences” according to Article 5 EUPL are:
264
+
265
+
266
+ - GNU General Public License (GPL) v. 2, v. 3
267
+
268
+ - GNU Affero General Public License (AGPL) v. 3
269
+
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+
272
+ - Eclipse Public License (EPL) v. 1.0
273
+
274
+ - Cecill v. 2.0, v. 2.1
275
+
276
+ - Mozilla Public Licence (MPL) v. 2
277
+
278
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
279
+
280
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported
281
+ (CC BY-SA 3.0) for works other than software
282
+
283
+ - European Union Public Licence (EUPL)v. 1.1, v. 1.2
284
+
285
+ - The European Commission may update this Appendix to later versions of
286
+ the above licences without producing a new version of the EUPL, as long
287
+ as they provide the rights granted in Article 2 of this Licence and protect
288
+ the covered Source Code from exclusive appropriation.
289
+ - All other changes or additions to this Appendix require the production of a
290
+ new EUPL version.
291
+
@@ -0,0 +1,21 @@
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 {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DigitrafficIntegration = void 0;
4
+ const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
5
+ const mediatypes_1 = require("../../types/mediatypes");
6
+ const digitraffic_integration_response_1 = require("../../runtime/digitraffic-integration-response");
7
+ class DigitrafficIntegration {
8
+ constructor(lambda, mediaType = mediatypes_1.MediaType.TEXT_PLAIN) {
9
+ this.parameters = [];
10
+ this.lambda = lambda;
11
+ this.mediaType = mediaType;
12
+ }
13
+ addPathParameter(...names) {
14
+ names.forEach(name => this.parameters.push({ type: 'path', name }));
15
+ return this;
16
+ }
17
+ addQueryParameter(...names) {
18
+ names.forEach(name => this.parameters.push({ type: 'querystring', name }));
19
+ return this;
20
+ }
21
+ build() {
22
+ const integrationResponses = this.createResponses();
23
+ return new aws_apigateway_1.LambdaIntegration(this.lambda, {
24
+ proxy: false,
25
+ integrationResponses,
26
+ requestParameters: this.parameters.length == 0 ? undefined : this.createRequestParameters(),
27
+ requestTemplates: this.parameters.length == 0 ? undefined : this.createRequestTemplates(),
28
+ passthroughBehavior: aws_apigateway_1.PassthroughBehavior.WHEN_NO_MATCH,
29
+ });
30
+ }
31
+ createRequestParameters() {
32
+ const requestParameters = {};
33
+ this.parameters.forEach((parameter) => {
34
+ requestParameters[`integration.request.${parameter.type}.${parameter.name}`] = `method.request.${parameter.type}.${parameter.name}`;
35
+ });
36
+ return requestParameters;
37
+ }
38
+ createRequestTemplates() {
39
+ const requestJson = {};
40
+ this.parameters.forEach((parameter) => {
41
+ requestJson[parameter.name] = `$util.escapeJavaScript($input.params('${parameter.name}'))`;
42
+ });
43
+ return {
44
+ [mediatypes_1.MediaType.APPLICATION_JSON]: JSON.stringify(requestJson),
45
+ };
46
+ }
47
+ createResponses() {
48
+ return [digitraffic_integration_response_1.DigitrafficIntegrationResponse.ok(this.mediaType)];
49
+ }
50
+ }
51
+ exports.DigitrafficIntegration = DigitrafficIntegration;
52
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZWdyYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXdzL2luZnJhL2FwaS9pbnRlZ3JhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrREFBdUc7QUFFdkcsdURBQWlEO0FBQ2pELHFHQUE4RjtBQVM5RixNQUFhLHNCQUFzQjtJQU0vQ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0FUSU9OX0pTT05dOiBKU09OLnN0cmluZ2lmeShyZXF1ZXN0SnNvbiksXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgY3JlYXRlUmVzcG9uc2VzKCk6IEludGVncmF0aW9uUmVzcG9uc2VbXSB7XG4gICAgICAgIHJldHVybiBbRGlnaXRyYWZmaWNJbnRlZ3JhdGlvblJlc3BvbnNlLm9rKHRoaXMubWVkaWFUeXBlKV07XG4gICAgfVxufSJdfQ==
@@ -0,0 +1,22 @@
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>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createResponses = exports.InternalServerErrorResponseTemplate = exports.SvgResponseTemplate = exports.XmlResponseTemplate = exports.NotFoundResponseTemplate = exports.BadRequestResponseTemplate = exports.NotFoundResponse = exports.MessageModel = exports.RESPONSE_DEFAULT_LAMBDA = void 0;
4
+ const apigateway = require("aws-cdk-lib/aws-apigateway");
5
+ const mediatypes_1 = require("../../types/mediatypes");
6
+ /**
7
+ * This is velocity-script, that assumes the response to be LambdaResponse(status and body).
8
+ * It will always return the body and status, but if status in something else than 200 OK the content-type
9
+ * will be overridden to text/plain. (it's assumed, that lambda will return error text).
10
+ *
11
+ * If fileName is set, then Content-Disposition-header will be set to use it
12
+ */
13
+ exports.RESPONSE_DEFAULT_LAMBDA = `#set($inputRoot = $input.path('$'))
14
+ $inputRoot.body
15
+ #if ($inputRoot.status != 200)
16
+ #set ($context.responseOverride.status = $inputRoot.status)
17
+ #set ($context.responseOverride.header.Content-Type = 'text/plain')
18
+ #end
19
+ #set ($context.responseOverride.header.Access-Control-Allow-Origin = '*')
20
+ #if ("$!inputRoot.fileName" != "")
21
+ #set ($disposition = 'attachment; filename="FN"')
22
+ #set ($context.responseOverride.header.Content-Disposition = $disposition.replaceAll('FN', $inputRoot.fileName))
23
+ #end
24
+ `;
25
+ const BODY_FROM_INPUT_PATH = "$input.path('$').body";
26
+ // DEPRECATED
27
+ const messageSchema = {
28
+ schema: apigateway.JsonSchemaVersion.DRAFT4,
29
+ type: apigateway.JsonSchemaType.OBJECT,
30
+ description: 'Response with message',
31
+ properties: {
32
+ message: {
33
+ type: apigateway.JsonSchemaType.STRING,
34
+ description: 'Response message',
35
+ },
36
+ },
37
+ };
38
+ // DEPRECATED
39
+ exports.MessageModel = {
40
+ contentType: mediatypes_1.MediaType.APPLICATION_JSON,
41
+ modelName: 'MessageResponseModel',
42
+ schema: messageSchema,
43
+ };
44
+ const NotFoundMessage = 'Not found';
45
+ exports.NotFoundResponse = JSON.stringify({ message: NotFoundMessage });
46
+ const InternalServerErrorMessage = 'Error';
47
+ const InternalServerErrorResponse = JSON.stringify({ message: InternalServerErrorMessage });
48
+ const BadRequestMessage = 'Bad request';
49
+ const BadRequestResponse = JSON.stringify({ message: BadRequestMessage });
50
+ exports.BadRequestResponseTemplate = createResponses(mediatypes_1.MediaType.APPLICATION_JSON, BadRequestResponse);
51
+ exports.NotFoundResponseTemplate = createResponses(mediatypes_1.MediaType.APPLICATION_JSON, exports.NotFoundResponse);
52
+ exports.XmlResponseTemplate = createResponses(mediatypes_1.MediaType.APPLICATION_XML, BODY_FROM_INPUT_PATH);
53
+ exports.SvgResponseTemplate = createResponses(mediatypes_1.MediaType.IMAGE_SVG, BODY_FROM_INPUT_PATH);
54
+ exports.InternalServerErrorResponseTemplate = createResponses(mediatypes_1.MediaType.APPLICATION_JSON, InternalServerErrorResponse);
55
+ function createResponses(key, value) {
56
+ const map = {};
57
+ map[key] = value;
58
+ return map;
59
+ }
60
+ exports.createResponses = createResponses;
61
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXdzL2luZnJhL2FwaS9yZXNwb25zZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5REFBMEQ7QUFDMUQsdURBQWlEO0FBRWpEOzs7Ozs7R0FNRztBQUNVLFFBQUEsdUJBQXVCLEdBQUc7Ozs7Ozs7Ozs7O0NBV3RDLENBQUM7QUFFRixNQUFNLG9CQUFvQixHQUFHLHVCQUF1QixDQUFDO0FBRXJELGFBQWE7QUFDYixNQUFNLGFBQWEsR0FBMEI7SUFDekMsTUFBTSxFQUFFLFVBQVUsQ0FBQyxpQkFBaUIsQ0FBQyxNQUFNO0lBQzNDLElBQUksRUFBRSxVQUFVLENBQUMsY0FBYyxDQUFDLE1BQU07SUFDdEMs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NlVGVtcGxhdGUgPSBjcmVhdGVSZXNwb25zZXMoTWVkaWFUeXBlLkFQUExJQ0FUSU9OX0pTT04sIEJhZFJlcXVlc3RSZXNwb25zZSk7XG5leHBvcnQgY29uc3QgTm90Rm91bmRSZXNwb25zZVRlbXBsYXRlID0gY3JlYXRlUmVzcG9uc2VzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9KU09OLCBOb3RGb3VuZFJlc3BvbnNlKTtcbmV4cG9ydCBjb25zdCBYbWxSZXNwb25zZVRlbXBsYXRlID0gY3JlYXRlUmVzcG9uc2VzKE1lZGlhVHlwZS5BUFBMSUNBVElPTl9YTUwsIEJPRFlfRlJPTV9JTlBVVF9QQVRIKTtcbmV4cG9ydCBjb25zdCBTdmdSZXNwb25zZVRlbXBsYXRlID0gY3JlYXRlUmVzcG9uc2VzKE1lZGlhVHlwZS5JTUFHRV9TVkcsIEJPRFlfRlJPTV9JTlBVVF9QQVRIKTtcbmV4cG9ydCBjb25zdCBJbnRlcm5hbFNlcnZlckVycm9yUmVzcG9uc2VUZW1wbGF0ZSA9IGNyZWF0ZVJlc3BvbnNlcyhNZWRpYVR5cGUuQVBQTElDQVRJT05fSlNPTiwgSW50ZXJuYWxTZXJ2ZXJFcnJvclJlc3BvbnNlKTtcblxuZXhwb3J0IGZ1bmN0aW9uIGNyZWF0ZVJlc3BvbnNlczxUPihrZXk6IE1lZGlhVHlwZSwgdmFsdWU6IFQpOiBSZWNvcmQ8c3RyaW5nLCBUPiB7XG4gICAgY29uc3QgbWFwOiBSZWNvcmQ8c3RyaW5nLCBUPiA9IHt9O1xuXG4gICAgbWFwW2tleV0gPSB2YWx1ZTtcblxuICAgIHJldHVybiBtYXA7XG59XG4iXX0=
@@ -0,0 +1,39 @@
1
+ import { LambdaIntegration, MethodResponse, IntegrationResponse, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
2
+ import { Function } 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: Function, options?: IntegrationOptions): LambdaIntegration;
38
+ export declare function getResponse(response: IntegrationResponse, options?: IntegrationOptions): IntegrationResponse;
39
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResponse = exports.defaultIntegration = exports.corsMethod = exports.methodResponse = exports.RESPONSE_404_NOT_FOUND = exports.RESPONSE_CORS_INTEGRATION = exports.RESPONSE_500_SERVER_ERROR = exports.RESPONSE_400_BAD_REQUEST = exports.RESPONSE_200_OK = void 0;
4
+ const response_1 = require("./response");
5
+ const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
6
+ const errors_1 = require("../../types/errors");
7
+ exports.RESPONSE_200_OK = {
8
+ statusCode: '200',
9
+ };
10
+ exports.RESPONSE_400_BAD_REQUEST = {
11
+ statusCode: '400',
12
+ selectionPattern: errors_1.BAD_REQUEST_MESSAGE,
13
+ responseTemplates: response_1.BadRequestResponseTemplate,
14
+ };
15
+ exports.RESPONSE_500_SERVER_ERROR = {
16
+ statusCode: '500',
17
+ selectionPattern: errors_1.ERROR_MESSAGE,
18
+ responseTemplates: response_1.InternalServerErrorResponseTemplate,
19
+ };
20
+ const RESPONSE_XML = {
21
+ responseTemplates: response_1.XmlResponseTemplate,
22
+ };
23
+ exports.RESPONSE_CORS_INTEGRATION = {
24
+ responseParameters: {
25
+ 'method.response.header.Access-Control-Allow-Origin': "'*'",
26
+ },
27
+ };
28
+ exports.RESPONSE_404_NOT_FOUND = {
29
+ statusCode: '404',
30
+ selectionPattern: errors_1.NOT_FOUND_MESSAGE,
31
+ responseTemplates: response_1.NotFoundResponseTemplate,
32
+ };
33
+ function methodResponse(status, contentType, model, parameters) {
34
+ return {
35
+ statusCode: status,
36
+ responseModels: (0, response_1.createResponses)(contentType, model),
37
+ responseParameters: parameters || {},
38
+ };
39
+ }
40
+ exports.methodResponse = methodResponse;
41
+ function corsMethod(response) {
42
+ return { ...response, ...{
43
+ responseParameters: {
44
+ 'method.response.header.Access-Control-Allow-Origin': true,
45
+ },
46
+ } };
47
+ }
48
+ exports.corsMethod = corsMethod;
49
+ /**
50
+ * Creates a default Lambda integration for a REST API resource _root_
51
+ * @param lambdaFunction The Lambda function
52
+ * @param options Options
53
+ */
54
+ function defaultIntegration(lambdaFunction, options) {
55
+ return new aws_apigateway_1.LambdaIntegration(lambdaFunction, {
56
+ proxy: false,
57
+ integrationResponses: options?.responses || [
58
+ getResponse(exports.RESPONSE_200_OK, options),
59
+ getResponse(exports.RESPONSE_400_BAD_REQUEST, options),
60
+ getResponse(exports.RESPONSE_404_NOT_FOUND, options),
61
+ getResponse(exports.RESPONSE_500_SERVER_ERROR, options),
62
+ ],
63
+ requestParameters: options?.requestParameters || {},
64
+ requestTemplates: options?.requestTemplates || {},
65
+ passthroughBehavior: options?.passthroughBehavior ?? aws_apigateway_1.PassthroughBehavior.WHEN_NO_MATCH,
66
+ });
67
+ }
68
+ exports.defaultIntegration = defaultIntegration;
69
+ function getResponse(response, options) {
70
+ if (options?.xml) {
71
+ response = { ...response, ...RESPONSE_XML };
72
+ }
73
+ if (!options?.disableCors) {
74
+ response = { ...response, ...exports.RESPONSE_CORS_INTEGRATION };
75
+ }
76
+ return response;
77
+ }
78
+ exports.getResponse = getResponse;
79
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2F3cy9pbmZyYS9hcGkvcmVzcG9uc2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHlDQUlvQjtBQUNwQiwrREFBdUg7QUFHdkgsK0NBQXlGO0FBRzVFLFFBQUEsZUFBZSxHQUF3QjtJQUNoRCxVQUFVLEVBQUUsS0FBSztDQUNwQixDQUFDO0FBRVcsUUFBQSx3QkFBd0IsR0FBd0I7SUFDekQsVUFBVSxFQUFFLEtBQUs7SUFDakIsZ0JBQWdCLEVBQUUsNEJBQW1CO0lBQ3JDLGlCQUFpQixFQUFFLHFDQUEwQjtDQUNoRCxDQUFDO0FBRVcsUUFBQSx5QkFBeUIsR0FBd0I7SUFDMUQsVUFBVSxFQUFFLEtBQUs7SUFDakIsZ0JBQWdCLEVBQUUsc0JBQWE7SUFDL0IsaUJBQWlCLEVBQUUsOENBQW1DO0NBQ3pELENBQUM7QUFFRixNQUFNLFlBQVksR0FBRztJQUNqQixpQkFBaUIsRUFBRSw4QkFBbUI7Q0FDekMsQ0FBQztBQUVXLFFBQUEseUJBQXlCLEdBQUc7SUFDckMsa0JBQWtCLEVBQUU7UUFDaEIsb0RBQW9ELEVBQUUsS0FBSztLQUM5RDtDQU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U19JTlRFR1JBVElPTn07XHJcbiAgICB9XHJcblxyXG4gICAgcmV0dXJuIHJlc3BvbnNlO1xyXG59XHJcbiJdfQ==
@@ -0,0 +1,15 @@
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
+ }