@flink-app/s3-plugin 0.3.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 (165) hide show
  1. package/.flink/generated-schemas.json +311 -0
  2. package/.flink/generatedHandlers.ts +7 -0
  3. package/.flink/generatedRepos.ts +5 -0
  4. package/.flink/schemas/schemas.json +5 -0
  5. package/.flink/schemas/schemas.ts +1 -0
  6. package/.flink/start.ts +4 -0
  7. package/dist/.flink/generatedHandlers.d.ts +1 -0
  8. package/dist/.flink/generatedHandlers.js +7 -0
  9. package/dist/.flink/generatedRepos.d.ts +1 -0
  10. package/dist/.flink/generatedRepos.js +7 -0
  11. package/dist/.flink/schemas/schemas.d.ts +0 -0
  12. package/dist/.flink/schemas/schemas.js +2 -0
  13. package/dist/.flink/schemas/schemas.json +5 -0
  14. package/dist/.flink/start.d.ts +3 -0
  15. package/dist/.flink/start.js +6 -0
  16. package/dist/index.d.ts +4 -0
  17. package/dist/index.js +172 -0
  18. package/dist/s3Client.d.ts +36 -0
  19. package/dist/s3Client.js +233 -0
  20. package/dist/s3PluginContext.d.ts +6 -0
  21. package/dist/s3PluginContext.js +2 -0
  22. package/dist/schemas/ListObjectsResponse.d.ts +5 -0
  23. package/dist/schemas/ListObjectsResponse.js +2 -0
  24. package/dist/schemas/s3ClientOptions.d.ts +7 -0
  25. package/dist/schemas/s3ClientOptions.js +2 -0
  26. package/dist/schemas/s3PluginOptions.d.ts +11 -0
  27. package/dist/schemas/s3PluginOptions.js +2 -0
  28. package/dist/src/Ctx.d.ts +19 -0
  29. package/dist/src/Ctx.js +2 -0
  30. package/dist/src/handlers/HandlebarsTemplateHandler.d.ts +5 -0
  31. package/dist/src/handlers/HandlebarsTemplateHandler.js +63 -0
  32. package/dist/src/handlers/Management/Get.d.ts +7 -0
  33. package/dist/src/handlers/Management/Get.js +53 -0
  34. package/dist/src/handlers/Management/GetManagement.d.ts +8 -0
  35. package/dist/src/handlers/Management/GetManagement.js +53 -0
  36. package/dist/src/handlers/User/DeleteByUserid.d.ts +9 -0
  37. package/dist/src/handlers/User/DeleteByUserid.js +70 -0
  38. package/dist/src/handlers/User/GetByUserid.d.ts +9 -0
  39. package/dist/src/handlers/User/GetByUserid.js +71 -0
  40. package/dist/src/handlers/User/GetList.d.ts +9 -0
  41. package/dist/src/handlers/User/GetList.js +64 -0
  42. package/dist/src/handlers/User/GetMe.d.ts +8 -0
  43. package/dist/src/handlers/User/GetMe.js +81 -0
  44. package/dist/src/handlers/User/Post.d.ts +10 -0
  45. package/dist/src/handlers/User/Post.js +87 -0
  46. package/dist/src/handlers/User/PostLogin.d.ts +10 -0
  47. package/dist/src/handlers/User/PostLogin.js +86 -0
  48. package/dist/src/handlers/User/PutByUserid.d.ts +9 -0
  49. package/dist/src/handlers/User/PutByUserid.js +97 -0
  50. package/dist/src/index.d.ts +4 -0
  51. package/dist/src/index.js +380 -0
  52. package/dist/src/lib/customer.d.ts +6 -0
  53. package/dist/src/lib/customer.js +121 -0
  54. package/dist/src/lib/payment.d.ts +6 -0
  55. package/dist/src/lib/payment.js +113 -0
  56. package/dist/src/managementApiContext.d.ts +7 -0
  57. package/dist/src/managementApiContext.js +2 -0
  58. package/dist/src/models/ManagementApi.d.ts +28 -0
  59. package/dist/src/models/ManagementApi.js +8 -0
  60. package/dist/src/repos/ConnectSessionRepo.d.ts +5 -0
  61. package/dist/src/repos/ConnectSessionRepo.js +26 -0
  62. package/dist/src/repos/ManagementUserRepo.d.ts +5 -0
  63. package/dist/src/repos/ManagementUserRepo.js +26 -0
  64. package/dist/src/reposx/ConnectSessionRepo.d.ts +5 -0
  65. package/dist/src/reposx/ConnectSessionRepo.js +26 -0
  66. package/dist/src/schemas/ConnectSession.d.ts +4 -0
  67. package/dist/src/schemas/ConnectSession.js +2 -0
  68. package/dist/src/schemas/Management/GetReq.d.ts +2 -0
  69. package/dist/src/schemas/Management/GetReq.js +2 -0
  70. package/dist/src/schemas/Management/GetRes.d.ts +3 -0
  71. package/dist/src/schemas/Management/GetRes.js +2 -0
  72. package/dist/src/schemas/ManagementUser.d.ts +6 -0
  73. package/dist/src/schemas/ManagementUser.js +2 -0
  74. package/dist/src/schemas/ManagementUserViewModel.d.ts +4 -0
  75. package/dist/src/schemas/ManagementUserViewModel.js +19 -0
  76. package/dist/src/schemas/ModuleList.d.ts +18 -0
  77. package/dist/src/schemas/ModuleList.js +2 -0
  78. package/dist/src/schemas/User/DeleteByUseridReq.d.ts +2 -0
  79. package/dist/src/schemas/User/DeleteByUseridReq.js +2 -0
  80. package/dist/src/schemas/User/DeleteByUseridRes.d.ts +2 -0
  81. package/dist/src/schemas/User/DeleteByUseridRes.js +2 -0
  82. package/dist/src/schemas/User/GetByUseridReq.d.ts +2 -0
  83. package/dist/src/schemas/User/GetByUseridReq.js +2 -0
  84. package/dist/src/schemas/User/GetByUseridRes.d.ts +3 -0
  85. package/dist/src/schemas/User/GetByUseridRes.js +2 -0
  86. package/dist/src/schemas/User/GetListReq.d.ts +2 -0
  87. package/dist/src/schemas/User/GetListReq.js +2 -0
  88. package/dist/src/schemas/User/GetListRes.d.ts +4 -0
  89. package/dist/src/schemas/User/GetListRes.js +2 -0
  90. package/dist/src/schemas/User/GetMeReq.d.ts +2 -0
  91. package/dist/src/schemas/User/GetMeReq.js +2 -0
  92. package/dist/src/schemas/User/GetMeRes.d.ts +3 -0
  93. package/dist/src/schemas/User/GetMeRes.js +2 -0
  94. package/dist/src/schemas/User/PostLoginReq.d.ts +4 -0
  95. package/dist/src/schemas/User/PostLoginReq.js +2 -0
  96. package/dist/src/schemas/User/PostLoginRes.d.ts +5 -0
  97. package/dist/src/schemas/User/PostLoginRes.js +2 -0
  98. package/dist/src/schemas/User/PostReq.d.ts +3 -0
  99. package/dist/src/schemas/User/PostReq.js +2 -0
  100. package/dist/src/schemas/User/PostRes.d.ts +3 -0
  101. package/dist/src/schemas/User/PostRes.js +2 -0
  102. package/dist/src/schemas/User/PutByUseridReq.d.ts +3 -0
  103. package/dist/src/schemas/User/PutByUseridReq.js +2 -0
  104. package/dist/src/schemas/User/PutByUseridRes.d.ts +3 -0
  105. package/dist/src/schemas/User/PutByUseridRes.js +2 -0
  106. package/dist/src/schemas/createStripeCustomerOptions.d.ts +11 -0
  107. package/dist/src/schemas/createStripeCustomerOptions.js +2 -0
  108. package/dist/src/schemas/customer/connectToStripeConnectOptions.d.ts +3 -0
  109. package/dist/src/schemas/customer/connectToStripeConnectOptions.js +2 -0
  110. package/dist/src/schemas/customer/hasPaymentMethodOptions.d.ts +3 -0
  111. package/dist/src/schemas/customer/hasPaymentMethodOptions.js +2 -0
  112. package/dist/src/schemas/customer/setupCardOptions.d.ts +3 -0
  113. package/dist/src/schemas/customer/setupCardOptions.js +2 -0
  114. package/dist/src/schemas/customer/setupCardResponse.d.ts +4 -0
  115. package/dist/src/schemas/customer/setupCardResponse.js +2 -0
  116. package/dist/src/schemas/customer/setupCardTokenOptions.d.ts +4 -0
  117. package/dist/src/schemas/customer/setupCardTokenOptions.js +2 -0
  118. package/dist/src/schemas/payment/capturePaymentOptions.d.ts +4 -0
  119. package/dist/src/schemas/payment/capturePaymentOptions.js +2 -0
  120. package/dist/src/schemas/payment/confirmPaymentOptions.d.ts +4 -0
  121. package/dist/src/schemas/payment/confirmPaymentOptions.js +2 -0
  122. package/dist/src/schemas/payment/confirmPaymentResponse.d.ts +7 -0
  123. package/dist/src/schemas/payment/confirmPaymentResponse.js +2 -0
  124. package/dist/src/schemas/payment/confirmPaymentTokenOptions.d.ts +4 -0
  125. package/dist/src/schemas/payment/confirmPaymentTokenOptions.js +2 -0
  126. package/dist/src/schemas/payment/createPaymentResponse.d.ts +5 -0
  127. package/dist/src/schemas/payment/createPaymentResponse.js +2 -0
  128. package/dist/src/schemas/stripeAPIToken.d.ts +4 -0
  129. package/dist/src/schemas/stripeAPIToken.js +2 -0
  130. package/dist/src/schemas/stripePluginOptions.d.ts +31 -0
  131. package/dist/src/schemas/stripePluginOptions.js +2 -0
  132. package/dist/src/stripeAPI.d.ts +32 -0
  133. package/dist/src/stripeAPI.js +163 -0
  134. package/dist/src/stripePlguinContext.d.ts +5 -0
  135. package/dist/src/stripePlguinContext.js +2 -0
  136. package/dist/src/stripePluginContext.d.ts +6 -0
  137. package/dist/src/stripePluginContext.js +2 -0
  138. package/dist/src/templates/connect-done.d.ts +1 -0
  139. package/dist/src/templates/connect-done.js +4 -0
  140. package/dist/src/templates/error.d.ts +1 -0
  141. package/dist/src/templates/error.js +4 -0
  142. package/dist/src/templates/master.d.ts +1 -0
  143. package/dist/src/templates/master.js +4 -0
  144. package/dist/src/templates/pay-enter-card.d.ts +1 -0
  145. package/dist/src/templates/pay-enter-card.js +4 -0
  146. package/dist/src/templates/pay-select-card.d.ts +1 -0
  147. package/dist/src/templates/pay-select-card.js +4 -0
  148. package/dist/src/templates/setup-card.d.ts +1 -0
  149. package/dist/src/templates/setup-card.js +4 -0
  150. package/dist/src/templates/setup-done.d.ts +1 -0
  151. package/dist/src/templates/setup-done.js +4 -0
  152. package/dist/src/templates/style.d.ts +1 -0
  153. package/dist/src/templates/style.js +4 -0
  154. package/dist/src/utils/bcrypt.d.ts +2 -0
  155. package/dist/src/utils/bcrypt.js +28 -0
  156. package/nodemon.json +7 -0
  157. package/package.json +34 -0
  158. package/readme.md +57 -0
  159. package/src/index.ts +100 -0
  160. package/src/s3Client.ts +150 -0
  161. package/src/s3PluginContext.ts +8 -0
  162. package/src/schemas/ListObjectsResponse.ts +3 -0
  163. package/src/schemas/s3ClientOptions.ts +7 -0
  164. package/src/schemas/s3PluginOptions.ts +11 -0
  165. package/tsconfig.json +23 -0
@@ -0,0 +1,311 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/Schemas",
4
+ "definitions": {
5
+ "ConnectSession": {
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "type": "string"
10
+ },
11
+ "userId": {
12
+ "type": "string"
13
+ }
14
+ },
15
+ "required": [
16
+ "id",
17
+ "userId"
18
+ ],
19
+ "additionalProperties": false
20
+ },
21
+ "createStripeCustomerOptions": {
22
+ "type": "object",
23
+ "properties": {
24
+ "userId": {
25
+ "type": "string"
26
+ },
27
+ "description": {
28
+ "type": "string"
29
+ },
30
+ "email": {
31
+ "type": "string"
32
+ },
33
+ "metaData": {
34
+ "$ref": "#/definitions/createStripeCustomerMetaData"
35
+ },
36
+ "name": {
37
+ "type": "string"
38
+ },
39
+ "phone": {
40
+ "type": "string"
41
+ }
42
+ },
43
+ "required": [
44
+ "userId"
45
+ ],
46
+ "additionalProperties": false
47
+ },
48
+ "createStripeCustomerMetaData": {
49
+ "type": "object",
50
+ "additionalProperties": {
51
+ "type": "string"
52
+ }
53
+ },
54
+ "stripePluginOptions": {
55
+ "type": "object",
56
+ "properties": {
57
+ "baseUrl": {
58
+ "type": "string"
59
+ },
60
+ "stripeSecreteKey": {
61
+ "type": "string"
62
+ },
63
+ "stripePublishableKey": {
64
+ "type": "string"
65
+ },
66
+ "JTW_TOKEN": {
67
+ "type": "string"
68
+ },
69
+ "logo": {
70
+ "type": "string"
71
+ },
72
+ "redirectUrl": {
73
+ "type": "string"
74
+ },
75
+ "stripeConnectClientID": {
76
+ "type": "string"
77
+ },
78
+ "phrases": {
79
+ "type": "object",
80
+ "properties": {
81
+ "setupDescription": {
82
+ "type": "string"
83
+ },
84
+ "setupButtonText": {
85
+ "type": "string"
86
+ },
87
+ "setupDoneMessage": {
88
+ "type": "string"
89
+ },
90
+ "paymentSelectCardPayButtonText": {
91
+ "type": "string"
92
+ },
93
+ "paymentSelectCardChangeCardButtonText": {
94
+ "type": "string"
95
+ },
96
+ "paymentDoneMessage": {
97
+ "type": "string"
98
+ },
99
+ "paymentEnterCardPayButtonText": {
100
+ "type": "string"
101
+ },
102
+ "connectDoneMessage": {
103
+ "type": "string"
104
+ }
105
+ },
106
+ "required": [
107
+ "setupDoneMessage",
108
+ "connectDoneMessage"
109
+ ],
110
+ "additionalProperties": false
111
+ },
112
+ "templates": {
113
+ "type": "object",
114
+ "properties": {
115
+ "master": {
116
+ "type": "string"
117
+ },
118
+ "style": {
119
+ "type": "string"
120
+ },
121
+ "setupCard": {
122
+ "type": "string"
123
+ },
124
+ "setupDone": {
125
+ "type": "string"
126
+ },
127
+ "error": {
128
+ "type": "string"
129
+ },
130
+ "paySelectCard": {
131
+ "type": "string"
132
+ },
133
+ "payEnterCard": {
134
+ "type": "string"
135
+ },
136
+ "connectDone": {
137
+ "type": "string"
138
+ }
139
+ },
140
+ "additionalProperties": false
141
+ }
142
+ },
143
+ "required": [
144
+ "stripeSecreteKey",
145
+ "stripePublishableKey",
146
+ "JTW_TOKEN"
147
+ ],
148
+ "additionalProperties": false
149
+ },
150
+ "connectToStripeConnectOptions": {
151
+ "type": "object",
152
+ "properties": {
153
+ "userId": {
154
+ "type": "string"
155
+ }
156
+ },
157
+ "required": [
158
+ "userId"
159
+ ],
160
+ "additionalProperties": false
161
+ },
162
+ "hasPaymentMethodOptions": {
163
+ "type": "object",
164
+ "properties": {
165
+ "stripeCustomerId": {
166
+ "type": "string"
167
+ }
168
+ },
169
+ "required": [
170
+ "stripeCustomerId"
171
+ ],
172
+ "additionalProperties": false
173
+ },
174
+ "setupCardOptions": {
175
+ "type": "object",
176
+ "properties": {
177
+ "stripeCustomerId": {
178
+ "type": "string"
179
+ }
180
+ },
181
+ "required": [
182
+ "stripeCustomerId"
183
+ ],
184
+ "additionalProperties": false
185
+ },
186
+ "setupCardResponse": {
187
+ "type": "object",
188
+ "properties": {
189
+ "token": {
190
+ "type": "string"
191
+ },
192
+ "redirectUrl": {
193
+ "type": "string"
194
+ }
195
+ },
196
+ "required": [
197
+ "token",
198
+ "redirectUrl"
199
+ ],
200
+ "additionalProperties": false
201
+ },
202
+ "setupCardTokenOptions": {
203
+ "type": "object",
204
+ "properties": {
205
+ "stripeCustomerId": {
206
+ "type": "string"
207
+ },
208
+ "client_secret": {
209
+ "type": "string"
210
+ }
211
+ },
212
+ "required": [
213
+ "client_secret",
214
+ "stripeCustomerId"
215
+ ],
216
+ "additionalProperties": false
217
+ },
218
+ "capturePaymentOptions": {
219
+ "type": "object",
220
+ "properties": {
221
+ "paymentIntentId": {
222
+ "type": "string"
223
+ },
224
+ "amount": {
225
+ "type": "number"
226
+ }
227
+ },
228
+ "required": [
229
+ "paymentIntentId",
230
+ "amount"
231
+ ],
232
+ "additionalProperties": false
233
+ },
234
+ "confirmPaymentOptions": {
235
+ "type": "object",
236
+ "properties": {
237
+ "paymentIntentId": {
238
+ "type": "string"
239
+ },
240
+ "background": {
241
+ "type": "boolean"
242
+ }
243
+ },
244
+ "required": [
245
+ "paymentIntentId"
246
+ ],
247
+ "additionalProperties": false
248
+ },
249
+ "confirmPaymentResponse": {
250
+ "type": "object",
251
+ "properties": {
252
+ "paymentIntentId": {
253
+ "type": "string"
254
+ },
255
+ "confirmed": {
256
+ "type": "boolean"
257
+ },
258
+ "captured": {
259
+ "type": "boolean"
260
+ },
261
+ "token": {
262
+ "type": "string"
263
+ },
264
+ "redirectUrl": {
265
+ "type": "string"
266
+ }
267
+ },
268
+ "required": [
269
+ "paymentIntentId",
270
+ "confirmed",
271
+ "captured"
272
+ ],
273
+ "additionalProperties": false
274
+ },
275
+ "confirmPaymentTokenOptions": {
276
+ "type": "object",
277
+ "properties": {
278
+ "paymentIntentId": {
279
+ "type": "string"
280
+ },
281
+ "client_secret": {
282
+ "type": "string"
283
+ }
284
+ },
285
+ "required": [
286
+ "paymentIntentId",
287
+ "client_secret"
288
+ ],
289
+ "additionalProperties": false
290
+ },
291
+ "createPaymentResponse": {
292
+ "type": "object",
293
+ "properties": {
294
+ "paymentIntentId": {
295
+ "type": "string"
296
+ },
297
+ "token": {
298
+ "type": "string"
299
+ },
300
+ "paymentUrl": {
301
+ "type": "string"
302
+ }
303
+ },
304
+ "required": [
305
+ "paymentIntentId",
306
+ "token"
307
+ ],
308
+ "additionalProperties": false
309
+ }
310
+ }
311
+ }
@@ -0,0 +1,7 @@
1
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
2
+ import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
3
+ import * as HandlebarsTemplateHandler_0 from "../src/handlers/HandlebarsTemplateHandler";
4
+
5
+ export const handlers = [];
6
+ autoRegisteredHandlers.push(...handlers);
7
+
@@ -0,0 +1,5 @@
1
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
2
+ import { autoRegisteredRepos } from "@flink-app/flink";
3
+ export const repos = [];
4
+ autoRegisteredRepos.push(...repos);
5
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/Schemas",
4
+ "definitions": {}
5
+ }
@@ -0,0 +1 @@
1
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
@@ -0,0 +1,4 @@
1
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
2
+ import "./generatedHandlers";
3
+ import "./generatedRepos";
4
+ import "../src/index";
@@ -0,0 +1 @@
1
+ export declare const handlers: never[];
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handlers = void 0;
4
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
5
+ var flink_1 = require("@flink-app/flink");
6
+ exports.handlers = [];
7
+ flink_1.autoRegisteredHandlers.push.apply(flink_1.autoRegisteredHandlers, exports.handlers);
@@ -0,0 +1 @@
1
+ export declare const repos: never[];
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.repos = void 0;
4
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
5
+ var flink_1 = require("@flink-app/flink");
6
+ exports.repos = [];
7
+ flink_1.autoRegisteredRepos.push.apply(flink_1.autoRegisteredRepos, exports.repos);
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/Schemas",
4
+ "definitions": {}
5
+ }
@@ -0,0 +1,3 @@
1
+ import "./generatedHandlers";
2
+ import "./generatedRepos";
3
+ import "../src/index";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Generated Wed Mar 02 2022 13:43:22 GMT+0100 (Central European Standard Time)
4
+ require("./generatedHandlers");
5
+ require("./generatedRepos");
6
+ require("../src/index");
@@ -0,0 +1,4 @@
1
+ import { FlinkPlugin } from "@flink-app/flink";
2
+ import { s3PluginOptions } from "./schemas/s3PluginOptions";
3
+ export * from "./s3PluginContext";
4
+ export declare const s3Plugin: (options: s3PluginOptions) => FlinkPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,172 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ var __importDefault = (this && this.__importDefault) || function (mod) {
65
+ return (mod && mod.__esModule) ? mod : { "default": mod };
66
+ };
67
+ Object.defineProperty(exports, "__esModule", { value: true });
68
+ exports.s3Plugin = void 0;
69
+ var flink_1 = require("@flink-app/flink");
70
+ __exportStar(require("./s3PluginContext"), exports);
71
+ var s3Client_1 = __importDefault(require("./s3Client"));
72
+ var express_fileupload_1 = __importDefault(require("express-fileupload"));
73
+ var uuid = __importStar(require("uuid"));
74
+ var mime_types_1 = __importDefault(require("mime-types"));
75
+ var s3Plugin = function (options) {
76
+ var s3Client = new s3Client_1.default({
77
+ accessKeyId: options.accessKeyId,
78
+ secretAccessKey: options.secretAccessKey,
79
+ bucket: options.bucket,
80
+ s3Acl: options.s3Acl,
81
+ endpoint: options.endpoint,
82
+ });
83
+ return {
84
+ id: "s3Plugin",
85
+ init: function (app) { return init(app, options); },
86
+ ctx: {
87
+ s3Client: s3Client,
88
+ },
89
+ };
90
+ };
91
+ exports.s3Plugin = s3Plugin;
92
+ function init(app, options) {
93
+ var _this = this;
94
+ if (options.enableUpload) {
95
+ var maxFileSize = options.maxFileSize || 10;
96
+ app.expressApp.use((0, express_fileupload_1.default)({
97
+ limits: { fileSize: maxFileSize * 1024 * 1024 },
98
+ abortOnLimit: true,
99
+ }));
100
+ var uploadUrl = options.uploadUrl || "/file-upload";
101
+ app.expressApp.post(uploadUrl, function (req, res) { return __awaiter(_this, void 0, void 0, function () {
102
+ var authenticated, file, path, s3Client, fileSplit, fileExt, filename, uploadData, ex_1;
103
+ var _a, _b;
104
+ return __generator(this, function (_c) {
105
+ switch (_c.label) {
106
+ case 0:
107
+ if (!options.uploadPermissionRequired) return [3 /*break*/, 2];
108
+ return [4 /*yield*/, ((_a = app.ctx.auth) === null || _a === void 0 ? void 0 : _a.authenticateRequest(req, [options.uploadPermissionRequired]))];
109
+ case 1:
110
+ authenticated = (_c.sent());
111
+ if (!authenticated) {
112
+ res.status(500).json({
113
+ status: 500,
114
+ error: { id: uuid.v4(), title: "Permission denied", detail: "Permission denied to this endpoint", code: "permissionDenied" },
115
+ });
116
+ return [2 /*return*/];
117
+ }
118
+ _c.label = 2;
119
+ case 2:
120
+ file = (_b = req.files) === null || _b === void 0 ? void 0 : _b.file;
121
+ if (!file) {
122
+ res.status(500).json({ status: 500, error: { id: uuid.v4(), title: "No file", detail: "No file specified", code: "badRequest" } });
123
+ return [2 /*return*/];
124
+ }
125
+ path = req.query.path;
126
+ s3Client = app.ctx.plugins.s3Plugin.s3Client;
127
+ if (s3Client == null) {
128
+ res.status(500).json({
129
+ status: 500,
130
+ error: { id: uuid.v4(), title: "Plugin not initialized", detail: "S3 Client not initialized", code: "badRequest" },
131
+ });
132
+ return [2 /*return*/];
133
+ }
134
+ fileSplit = file.name.split(".");
135
+ fileExt = fileSplit.length > 1 ? fileSplit[fileSplit.length - 1] : mime_types_1.default.extension(file.mimetype);
136
+ filename = formatS3Path(path ? path : "") + uuid.v4() + "." + fileExt;
137
+ _c.label = 3;
138
+ case 3:
139
+ _c.trys.push([3, 5, , 6]);
140
+ return [4 /*yield*/, s3Client.uploadFile(filename, file.data, file.mimetype)];
141
+ case 4:
142
+ uploadData = _c.sent();
143
+ res.json({
144
+ url: uploadData.Location,
145
+ });
146
+ return [3 /*break*/, 6];
147
+ case 5:
148
+ ex_1 = _c.sent();
149
+ res.status(500).json({
150
+ status: 500,
151
+ error: { id: uuid.v4(), title: "Internal server error", detail: "Internal server errror while communicating with S3", code: "badRequest" },
152
+ });
153
+ return [3 /*break*/, 6];
154
+ case 6: return [2 /*return*/];
155
+ }
156
+ });
157
+ }); });
158
+ flink_1.log.info("Registered route POST " + uploadUrl);
159
+ }
160
+ }
161
+ function formatS3Path(path) {
162
+ path = path.trim();
163
+ if (path) {
164
+ if (path.startsWith("/")) {
165
+ path = path.substr(1);
166
+ }
167
+ if (!path.endsWith("/")) {
168
+ path = path + "/";
169
+ }
170
+ }
171
+ return path;
172
+ }
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ import AWS from "aws-sdk";
3
+ import S3, { ManagedUpload, ObjectIdentifierList } from "aws-sdk/clients/s3";
4
+ import { ListObjectResponse } from "./schemas/ListObjectsResponse";
5
+ import { s3ClientOptions } from "./schemas/s3ClientOptions";
6
+ declare class S3Client {
7
+ private s3Bucket;
8
+ private awsAccessKeyId;
9
+ private awsSecretAccessKey;
10
+ private s3Endpoint;
11
+ private s3Acl;
12
+ s3: AWS.S3;
13
+ constructor(options: s3ClientOptions);
14
+ checkIfExists(fileName: string): Promise<boolean>;
15
+ uploadFile(fileName: string, data: Buffer, mime?: string): Promise<ManagedUpload.SendData>;
16
+ getSignedUrl(key: string, expires?: number): Promise<unknown>;
17
+ deleteObject(file: string, version?: string): Promise<import("aws-sdk/lib/request").PromiseResult<S3.DeleteObjectOutput, AWS.AWSError>>;
18
+ /**
19
+ * Delete files from s3 bucket
20
+ *
21
+ * @param {Array<Object>} files
22
+ *
23
+ * @returns {Promise}
24
+ */
25
+ deleteObjects(files: ObjectIdentifierList): Promise<import("aws-sdk/lib/request").PromiseResult<S3.DeleteObjectsOutput, AWS.AWSError>>;
26
+ getObject(key: string): Promise<{
27
+ data: S3.Body;
28
+ mimetype: string | undefined;
29
+ }>;
30
+ getObjects(): Promise<ListObjectResponse>;
31
+ /**
32
+ * This use only for unit tests
33
+ */
34
+ deleteBucket(): Promise<void>;
35
+ }
36
+ export default S3Client;