@fixefy/fixefy-ui-utils 0.0.19 → 0.0.21
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.
|
@@ -44,7 +44,7 @@ declare module '@mui/material/styles' {
|
|
|
44
44
|
pending: Palette['primary'];
|
|
45
45
|
score: ScorePaletteColorOptions;
|
|
46
46
|
invoiceAnalysis: InvoiceAnalysisPaletteColorOptions;
|
|
47
|
-
status:
|
|
47
|
+
status: StatePaletteColorOptions;
|
|
48
48
|
tag: TagPaletteColorOptions;
|
|
49
49
|
invoiceState: InvoiceStatesPaletteColorOptions;
|
|
50
50
|
reconcilationState: RecosStatesPaletteColorOptions;
|
|
@@ -74,7 +74,7 @@ declare module '@mui/material/styles' {
|
|
|
74
74
|
invoiceAnalysis: InvoiceAnalysisPaletteColorOptions;
|
|
75
75
|
trends: TrendsPaletteColorOptions;
|
|
76
76
|
uploader: UploaderPaletteColorOptions;
|
|
77
|
-
status:
|
|
77
|
+
status: StatePaletteColorOptions;
|
|
78
78
|
tag: TagPaletteColorOptions;
|
|
79
79
|
invoiceState: InvoiceStatesPaletteColorOptions;
|
|
80
80
|
reconcilationState: RecosStatesPaletteColorOptions;
|
|
@@ -165,6 +165,23 @@ declare module '@mui/material/styles' {
|
|
|
165
165
|
matching: string;
|
|
166
166
|
invalid: string;
|
|
167
167
|
}
|
|
168
|
+
interface StatePaletteColorOptions {
|
|
169
|
+
active: StatusColorOption;
|
|
170
|
+
approve: StatusColorOption;
|
|
171
|
+
challenge: StatusColorOption;
|
|
172
|
+
challenged: StatusColorOption;
|
|
173
|
+
declined: StatusColorOption;
|
|
174
|
+
discrepancy: StatusColorOption;
|
|
175
|
+
duplicate: StatusColorOption;
|
|
176
|
+
duplicated: StatusColorOption;
|
|
177
|
+
gold: StatusColorOption;
|
|
178
|
+
in_progress: StatusColorOption;
|
|
179
|
+
in_review: StatusColorOption;
|
|
180
|
+
no_pricing: StatusColorOption;
|
|
181
|
+
pending: StatusColorOption;
|
|
182
|
+
pending_approval: StatusColorOption;
|
|
183
|
+
pending_challenge: StatusColorOption;
|
|
184
|
+
}
|
|
168
185
|
interface StatusPaletteColorOptions {
|
|
169
186
|
active: StatusColorOption;
|
|
170
187
|
approve: StatusColorOption;
|
|
@@ -179,34 +196,39 @@ declare module '@mui/material/styles' {
|
|
|
179
196
|
in_review: StatusColorOption;
|
|
180
197
|
no_pricing: StatusColorOption;
|
|
181
198
|
pending: StatusColorOption;
|
|
199
|
+
pending_approval: StatusColorOption;
|
|
200
|
+
pending_challenge: StatusColorOption;
|
|
182
201
|
}
|
|
183
202
|
interface TagPaletteColorOptions {
|
|
184
203
|
approved: StatusColorOption;
|
|
204
|
+
closed: StatusColorOption;
|
|
185
205
|
created: StatusColorOption;
|
|
186
206
|
declined: StatusColorOption;
|
|
187
207
|
in_dispute: StatusColorOption;
|
|
188
208
|
in_progress: StatusColorOption;
|
|
209
|
+
low: StatusColorOption;
|
|
189
210
|
paid: StatusColorOption;
|
|
190
|
-
|
|
211
|
+
pending: StatusColorOption;
|
|
191
212
|
refunded: StatusColorOption;
|
|
192
|
-
low: StatusColorOption;
|
|
193
213
|
}
|
|
194
214
|
interface InvoiceStatesPaletteColorOptions {
|
|
195
215
|
approved: StatusColorOption;
|
|
216
|
+
closed: StatusColorOption;
|
|
196
217
|
created: StatusColorOption;
|
|
197
218
|
declined: StatusColorOption;
|
|
198
219
|
in_dispute: StatusColorOption;
|
|
199
220
|
in_progress: StatusColorOption;
|
|
200
221
|
paid: StatusColorOption;
|
|
201
|
-
|
|
222
|
+
pending: StatusColorOption;
|
|
202
223
|
}
|
|
203
224
|
interface RecosStatesPaletteColorOptions {
|
|
204
|
-
created: StatusColorOption;
|
|
205
|
-
in_progress: StatusColorOption;
|
|
206
225
|
approved: StatusColorOption;
|
|
226
|
+
closed: StatusColorOption;
|
|
227
|
+
created: StatusColorOption;
|
|
207
228
|
declined: StatusColorOption;
|
|
229
|
+
in_progress: StatusColorOption;
|
|
230
|
+
pending: StatusColorOption;
|
|
208
231
|
refunded: StatusColorOption;
|
|
209
|
-
closed: StatusColorOption;
|
|
210
232
|
}
|
|
211
233
|
interface SnackbarPaletteColorOptions {
|
|
212
234
|
info: SnackbarColorOption;
|
|
@@ -269,6 +269,14 @@ const theme = (0, _styles.createTheme)({
|
|
|
269
269
|
pending: {
|
|
270
270
|
border: '#ECC631',
|
|
271
271
|
background: '#FEFDF3'
|
|
272
|
+
},
|
|
273
|
+
pending_approval: {
|
|
274
|
+
border: '#ECC631',
|
|
275
|
+
background: '#FEFDF3'
|
|
276
|
+
},
|
|
277
|
+
pending_challenge: {
|
|
278
|
+
border: '#F7C08F',
|
|
279
|
+
background: '#FEFAF6'
|
|
272
280
|
}
|
|
273
281
|
},
|
|
274
282
|
tag: {
|
|
@@ -276,6 +284,10 @@ const theme = (0, _styles.createTheme)({
|
|
|
276
284
|
border: '#27AE60',
|
|
277
285
|
background: '#27AE60'
|
|
278
286
|
},
|
|
287
|
+
closed: {
|
|
288
|
+
border: '#8B9092',
|
|
289
|
+
background: '#8B9092'
|
|
290
|
+
},
|
|
279
291
|
created: {
|
|
280
292
|
border: '#87ACB6',
|
|
281
293
|
background: '#87ACB6'
|
|
@@ -285,28 +297,28 @@ const theme = (0, _styles.createTheme)({
|
|
|
285
297
|
background: '#EB5757'
|
|
286
298
|
},
|
|
287
299
|
in_dispute: {
|
|
288
|
-
border: '#
|
|
289
|
-
background: '#
|
|
300
|
+
border: '#EC6AC8',
|
|
301
|
+
background: '#EC6AC8'
|
|
290
302
|
},
|
|
291
303
|
in_progress: {
|
|
292
304
|
border: '#56CCF2',
|
|
293
305
|
background: '#56CCF2'
|
|
294
306
|
},
|
|
307
|
+
low: {
|
|
308
|
+
border: '#56CCF2',
|
|
309
|
+
background: '#88C00D'
|
|
310
|
+
},
|
|
295
311
|
paid: {
|
|
296
312
|
border: '#BB6BD9',
|
|
297
313
|
background: '#BB6BD9'
|
|
298
314
|
},
|
|
299
|
-
|
|
300
|
-
border: '#
|
|
301
|
-
background: '#
|
|
315
|
+
pending: {
|
|
316
|
+
border: '#ECC631',
|
|
317
|
+
background: '#ECC631'
|
|
302
318
|
},
|
|
303
319
|
refunded: {
|
|
304
320
|
border: '#BB6BD9',
|
|
305
321
|
background: '#BB6BD9'
|
|
306
|
-
},
|
|
307
|
-
low: {
|
|
308
|
-
border: '#56CCF2',
|
|
309
|
-
background: '#88C00D'
|
|
310
322
|
}
|
|
311
323
|
},
|
|
312
324
|
invoiceState: {
|
|
@@ -314,6 +326,10 @@ const theme = (0, _styles.createTheme)({
|
|
|
314
326
|
border: '#27AE60',
|
|
315
327
|
background: '#27AE60'
|
|
316
328
|
},
|
|
329
|
+
closed: {
|
|
330
|
+
border: '#8B9092',
|
|
331
|
+
background: '#8B9092'
|
|
332
|
+
},
|
|
317
333
|
created: {
|
|
318
334
|
border: '#87ACB6',
|
|
319
335
|
background: '#87ACB6'
|
|
@@ -323,8 +339,8 @@ const theme = (0, _styles.createTheme)({
|
|
|
323
339
|
background: '#EB5757'
|
|
324
340
|
},
|
|
325
341
|
in_dispute: {
|
|
326
|
-
border: '#
|
|
327
|
-
background: '#
|
|
342
|
+
border: '#EC6AC8',
|
|
343
|
+
background: '#EC6AC8'
|
|
328
344
|
},
|
|
329
345
|
in_progress: {
|
|
330
346
|
border: '#56CCF2',
|
|
@@ -334,35 +350,39 @@ const theme = (0, _styles.createTheme)({
|
|
|
334
350
|
border: '#BB6BD9',
|
|
335
351
|
background: '#BB6BD9'
|
|
336
352
|
},
|
|
337
|
-
|
|
338
|
-
border: '#
|
|
339
|
-
background: '#
|
|
353
|
+
pending: {
|
|
354
|
+
border: '#ECC631',
|
|
355
|
+
background: '#ECC631'
|
|
340
356
|
}
|
|
341
357
|
},
|
|
342
358
|
reconcilationState: {
|
|
359
|
+
approved: {
|
|
360
|
+
border: '#27AE60',
|
|
361
|
+
background: '#27AE60'
|
|
362
|
+
},
|
|
363
|
+
closed: {
|
|
364
|
+
border: '#8B9092',
|
|
365
|
+
background: '#8B9092'
|
|
366
|
+
},
|
|
343
367
|
created: {
|
|
344
368
|
border: '#87ACB6',
|
|
345
369
|
background: '#87ACB6'
|
|
346
370
|
},
|
|
371
|
+
declined: {
|
|
372
|
+
border: '#EB5757',
|
|
373
|
+
background: '#EB5757'
|
|
374
|
+
},
|
|
347
375
|
in_progress: {
|
|
348
376
|
border: '#56CCF2',
|
|
349
377
|
background: '#56CCF2'
|
|
350
378
|
},
|
|
351
|
-
|
|
352
|
-
border: '#
|
|
353
|
-
background: '#
|
|
354
|
-
},
|
|
355
|
-
declined: {
|
|
356
|
-
border: '#EB5757',
|
|
357
|
-
background: '#EB5757'
|
|
379
|
+
pending: {
|
|
380
|
+
border: '#ECC631',
|
|
381
|
+
background: '#ECC631'
|
|
358
382
|
},
|
|
359
383
|
refunded: {
|
|
360
384
|
border: '#BB6BD9',
|
|
361
385
|
background: '#BB6BD9'
|
|
362
|
-
},
|
|
363
|
-
closed: {
|
|
364
|
-
border: '#8B9092',
|
|
365
|
-
background: '#8B9092'
|
|
366
386
|
}
|
|
367
387
|
},
|
|
368
388
|
trends: {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"fs": false
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@fixefy/fixefy-ui-components": "0.0.
|
|
7
|
+
"@fixefy/fixefy-ui-components": "0.0.52",
|
|
8
8
|
"@mui/material": "^5.14.11",
|
|
9
9
|
"@mui/styled-engine": "^5.14.11",
|
|
10
10
|
"@mui/styles": "^5.14.11",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"require": "./dist/index.js"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"version": "0.0.
|
|
66
|
+
"version": "0.0.21"
|
|
67
67
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
const _react = /*#__PURE__*/ _interop_require_default(require("react" // //@ts-nocheck
|
|
6
|
-
// import { ListObjectOutput } from './data_models'
|
|
7
|
-
// import { SignedUrl } from './data_models'
|
|
8
|
-
// import AWS from 'aws-sdk'
|
|
9
|
-
// import PaginationHelper from './pagination_helper'
|
|
10
|
-
// const s3Credentials: AWS.Credentials = new AWS.Credentials({
|
|
11
|
-
// accessKeyId: process.env.AWS_S3_ACCESS_KEY || '',
|
|
12
|
-
// secretAccessKey: process.env.AWS_S3_SECRET_KEY || '',
|
|
13
|
-
// }),
|
|
14
|
-
// awsS3: AWS.S3 = new AWS.S3({ credentials: s3Credentials })
|
|
15
|
-
// const AwsS3Helper = {
|
|
16
|
-
// copyMyReport: async (args: any): Promise<any> => {
|
|
17
|
-
// const {
|
|
18
|
-
// data: { from, to },
|
|
19
|
-
// }: { data: { from: string; to: string } } = args
|
|
20
|
-
// // set the params
|
|
21
|
-
// const prefixFrom = `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
22
|
-
// parent,
|
|
23
|
-
// args,
|
|
24
|
-
// ctx,
|
|
25
|
-
// info,
|
|
26
|
-
// rest,
|
|
27
|
-
// )}/${ctx.workspace?.readable_id}/${ctx.user?.username}/${from}`,
|
|
28
|
-
// prefixTo = `${ctx.workspace?.readable_id}/${ctx.user?.username}/${to}`,
|
|
29
|
-
// params: any = {
|
|
30
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
31
|
-
// parent,
|
|
32
|
-
// args,
|
|
33
|
-
// ctx,
|
|
34
|
-
// info,
|
|
35
|
-
// rest,
|
|
36
|
-
// )}`,
|
|
37
|
-
// CopySource: prefixFrom,
|
|
38
|
-
// Key: prefixTo,
|
|
39
|
-
// }
|
|
40
|
-
// const rv: any = await awsS3.copyObject(params).promise()
|
|
41
|
-
// // notify
|
|
42
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
43
|
-
// return rv
|
|
44
|
-
// },
|
|
45
|
-
// createBucket: async (args: any): Promise<AWS.S3.Types.CreateBucketOutput> => {
|
|
46
|
-
// const {
|
|
47
|
-
// data: { name },
|
|
48
|
-
// }: { data: { name: string } } = args,
|
|
49
|
-
// params: AWS.S3.Types.CreateBucketRequest = { Bucket: name }
|
|
50
|
-
// // create bucket
|
|
51
|
-
// const rv = await awsS3.createBucket(params).promise()
|
|
52
|
-
// // notify
|
|
53
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
54
|
-
// return rv
|
|
55
|
-
// },
|
|
56
|
-
// deleteBucket: async (args: any): Promise<any> => {
|
|
57
|
-
// const {
|
|
58
|
-
// data: { name },
|
|
59
|
-
// }: { data: { name: string } } = args,
|
|
60
|
-
// params: AWS.S3.Types.DeleteBucketRequest = { Bucket: name }
|
|
61
|
-
// const rv: any = await awsS3.deleteBucket(params).promise()
|
|
62
|
-
// // notify
|
|
63
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
64
|
-
// return rv
|
|
65
|
-
// },
|
|
66
|
-
// deleteMyReport: async (args: any): Promise<any> => {
|
|
67
|
-
// const {
|
|
68
|
-
// data: { is_notify: isNotify = true, name },
|
|
69
|
-
// }: { data: { is_notify: boolean; name: string } } = args
|
|
70
|
-
// // set the prefix
|
|
71
|
-
// const prefix = `${ctx.workspace?.readable_id}/${ctx.user?.username}/${name}`
|
|
72
|
-
// // set the params
|
|
73
|
-
// const params: AWS.S3.Types.DeleteObjectRequest = {
|
|
74
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
75
|
-
// parent,
|
|
76
|
-
// args,
|
|
77
|
-
// ctx,
|
|
78
|
-
// info,
|
|
79
|
-
// rest,
|
|
80
|
-
// )}`,
|
|
81
|
-
// Key: prefix,
|
|
82
|
-
// }
|
|
83
|
-
// // delete object
|
|
84
|
-
// const rv: any = await awsS3.deleteObject(params).promise()
|
|
85
|
-
// // input check - if is_notify
|
|
86
|
-
// if (isNotify) {
|
|
87
|
-
// // notify
|
|
88
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
89
|
-
// }
|
|
90
|
-
// return rv
|
|
91
|
-
// },
|
|
92
|
-
// deleteMyReports: async (args: any): Promise<any> => {
|
|
93
|
-
// const {
|
|
94
|
-
// data: { names },
|
|
95
|
-
// }: { data: { names: Array<string> } } = args
|
|
96
|
-
// // set the prefix
|
|
97
|
-
// const prefix = `${ctx.workspace?.readable_id}/${ctx.user?.username}`
|
|
98
|
-
// const promises: Array<Promise<any>> = []
|
|
99
|
-
// let currentPromise: Promise<any>
|
|
100
|
-
// for (const name of names) {
|
|
101
|
-
// currentPromise = AwsS3Helper.deleteMyReport(
|
|
102
|
-
// parent,
|
|
103
|
-
// { data: { is_notify: false, name } },
|
|
104
|
-
// ctx,
|
|
105
|
-
// info,
|
|
106
|
-
// rest,
|
|
107
|
-
// )
|
|
108
|
-
// promises.push(currentPromise)
|
|
109
|
-
// }
|
|
110
|
-
// const resultArray: Array<any> = await Promise.all(promises),
|
|
111
|
-
// rv: any = {}
|
|
112
|
-
// // set the params
|
|
113
|
-
// const params: AWS.S3.Types.DeleteObjectRequest = {
|
|
114
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
115
|
-
// parent,
|
|
116
|
-
// args,
|
|
117
|
-
// ctx,
|
|
118
|
-
// info,
|
|
119
|
-
// rest,
|
|
120
|
-
// )}`,
|
|
121
|
-
// Key: prefix,
|
|
122
|
-
// }
|
|
123
|
-
// for (let i = 0; i < resultArray.length; ++i) {
|
|
124
|
-
// rv[names[i]] = resultArray[i]
|
|
125
|
-
// }
|
|
126
|
-
// // notify
|
|
127
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
128
|
-
// return rv
|
|
129
|
-
// },
|
|
130
|
-
// deleteBucket: async (
|
|
131
|
-
// parent: any,
|
|
132
|
-
// args: any,
|
|
133
|
-
// ctx: Context,
|
|
134
|
-
// info: any,
|
|
135
|
-
// rest: any,
|
|
136
|
-
// ): Promise<DeleteBucketCommandOutput> => {
|
|
137
|
-
// const {
|
|
138
|
-
// data: { name },
|
|
139
|
-
// } = args
|
|
140
|
-
// // create the delete command
|
|
141
|
-
// const command: DeleteBucketCommand = new DeleteBucketCommand({
|
|
142
|
-
// Bucket: name,
|
|
143
|
-
// })
|
|
144
|
-
// // delete bucket
|
|
145
|
-
// const rv: DeleteBucketCommandOutput = await s3.deleteBucket(command)
|
|
146
|
-
// return rv
|
|
147
|
-
// },
|
|
148
|
-
// deleteFile: async (
|
|
149
|
-
// parent: any,
|
|
150
|
-
// args: any,
|
|
151
|
-
// ctx: Context,
|
|
152
|
-
// info: any,
|
|
153
|
-
// rest: any,
|
|
154
|
-
// ): Promise<DeleteObjectCommandOutput> => {
|
|
155
|
-
// const {
|
|
156
|
-
// data: { bucket_name, name },
|
|
157
|
-
// } = args
|
|
158
|
-
// // create the delete command
|
|
159
|
-
// const command: DeleteObjectCommand = new DeleteObjectCommand({
|
|
160
|
-
// Bucket: bucket_name,
|
|
161
|
-
// Key: name,
|
|
162
|
-
// })
|
|
163
|
-
// // delete bucket
|
|
164
|
-
// const rv: DeleteObjectCommandOutput = await s3Client.send(command)
|
|
165
|
-
// return rv
|
|
166
|
-
// },
|
|
167
|
-
// downloadObject: async (args: any): Promise<AWS.S3.Types.GetObjectOutput> => {
|
|
168
|
-
// const {
|
|
169
|
-
// data: { bucket_name, name },
|
|
170
|
-
// } = args,
|
|
171
|
-
// params: AWS.S3.Types.GetObjectRequest = { Bucket: bucket_name, Key: name }
|
|
172
|
-
// const rv: AWS.S3.Types.GetObjectOutput = await s3
|
|
173
|
-
// .getObject(params)
|
|
174
|
-
// .promise()
|
|
175
|
-
// return rv
|
|
176
|
-
// },
|
|
177
|
-
// getBucketEnvSuffix: (args: any): string => {
|
|
178
|
-
// const { env } = args
|
|
179
|
-
// let rv: string
|
|
180
|
-
// switch (env) {
|
|
181
|
-
// case 'local':
|
|
182
|
-
// rv = '-dev'
|
|
183
|
-
// break
|
|
184
|
-
// case 'prod':
|
|
185
|
-
// rv = ''
|
|
186
|
-
// break
|
|
187
|
-
// default:
|
|
188
|
-
// rv = `-${env}`
|
|
189
|
-
// break
|
|
190
|
-
// }
|
|
191
|
-
// return rv
|
|
192
|
-
// },
|
|
193
|
-
// getFuegoUploadUrl: (args: any): SignedUrl => {
|
|
194
|
-
// const {
|
|
195
|
-
// username,
|
|
196
|
-
// workspace,
|
|
197
|
-
// where: { expires_in, name },
|
|
198
|
-
// } = args
|
|
199
|
-
// if (name == null || name.length == 0)
|
|
200
|
-
// throw new Error('name is an empty string')
|
|
201
|
-
// const currentPrefix = `${workspace}/${username}/${name}`,
|
|
202
|
-
// currentParams: unknown = {
|
|
203
|
-
// Bucket: `fixefy-fuegos${AwsS3Helper.getBucketEnvSuffix(args)}`,
|
|
204
|
-
// Key: currentPrefix,
|
|
205
|
-
// Expires: expires_in || 3600,
|
|
206
|
-
// },
|
|
207
|
-
// url: string = awsS3.getSignedUrl('putObject', currentParams),
|
|
208
|
-
// rv: SignedUrl = { name, url }
|
|
209
|
-
// return rv
|
|
210
|
-
// },
|
|
211
|
-
// getReportDownloadUrl: (args: any): string => {
|
|
212
|
-
// const {
|
|
213
|
-
// where: { expires_in, name },
|
|
214
|
-
// }: { where: { expires_in: string; name: string } } = args,
|
|
215
|
-
// prefix = `${ctx.workspace?.readable_id}/${ctx.user?.username}/${name}`,
|
|
216
|
-
// params: any = {
|
|
217
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
218
|
-
// parent,
|
|
219
|
-
// args,
|
|
220
|
-
// ctx,
|
|
221
|
-
// info,
|
|
222
|
-
// rest,
|
|
223
|
-
// )}`,
|
|
224
|
-
// Key: prefix,
|
|
225
|
-
// Expires: expires_in || 3600,
|
|
226
|
-
// }
|
|
227
|
-
// // get the signed url
|
|
228
|
-
// const rv: string = awsS3.getSignedUrl('getObject', params)
|
|
229
|
-
// return rv
|
|
230
|
-
// },
|
|
231
|
-
// getMyReports: async (args: any): Promise<Array<ListObjectOutput>> => {
|
|
232
|
-
// // set limits
|
|
233
|
-
// PaginationHelper.limitPagination(parent, args, ctx, info, rest)
|
|
234
|
-
// const prefix = `${ctx.workspace?.readable_id}/${ctx.user?.username}/`,
|
|
235
|
-
// params: AWS.S3.ListObjectsV2Request = {
|
|
236
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
237
|
-
// parent,
|
|
238
|
-
// args,
|
|
239
|
-
// ctx,
|
|
240
|
-
// info,
|
|
241
|
-
// rest,
|
|
242
|
-
// )}`,
|
|
243
|
-
// Prefix: prefix,
|
|
244
|
-
// },
|
|
245
|
-
// result: AWS.S3.ListObjectsV2Output = await awsS3
|
|
246
|
-
// .listObjectsV2(params)
|
|
247
|
-
// .promise(),
|
|
248
|
-
// rv: Array<ListObjectOutput> = []
|
|
249
|
-
// let headParams: AWS.S3.Types.HeadObjectRequest,
|
|
250
|
-
// headResult: AWS.S3.Types.HeadObjectOutput,
|
|
251
|
-
// currentObject: ListObjectOutput,
|
|
252
|
-
// currentFileName: Maybe<string>,
|
|
253
|
-
// currentUrl: Maybe<string>
|
|
254
|
-
// for (const content of result?.Contents || []) {
|
|
255
|
-
// // input check - if key is invalid - continue loop
|
|
256
|
-
// if (ValidateHelper.isStringValid(content?.Key) == false) continue
|
|
257
|
-
// currentFileName = content?.Key?.split('/').pop()
|
|
258
|
-
// // input check - if file_name is invalid - continue loop
|
|
259
|
-
// if (ValidateHelper.isStringValid(currentFileName) == false) continue
|
|
260
|
-
// currentUrl = AwsS3Helper.getReportDownloadUrl(
|
|
261
|
-
// parent,
|
|
262
|
-
// { where: { name: currentFileName } },
|
|
263
|
-
// ctx,
|
|
264
|
-
// info,
|
|
265
|
-
// rest,
|
|
266
|
-
// )
|
|
267
|
-
// currentObject = {
|
|
268
|
-
// name: currentFileName,
|
|
269
|
-
// size: content.Size,
|
|
270
|
-
// updated_at: content.LastModified?.getTime(),
|
|
271
|
-
// url: currentUrl,
|
|
272
|
-
// }
|
|
273
|
-
// headParams = {
|
|
274
|
-
// Bucket: `fixefy-reports${AwsS3Helper.getBucketEnvSuffix(
|
|
275
|
-
// parent,
|
|
276
|
-
// args,
|
|
277
|
-
// ctx,
|
|
278
|
-
// info,
|
|
279
|
-
// rest,
|
|
280
|
-
// )}`,
|
|
281
|
-
// Key: content.Key as string,
|
|
282
|
-
// }
|
|
283
|
-
// headResult = await awsS3.headObject(headParams).promise()
|
|
284
|
-
// // input check - if headResult.Metadata is valid
|
|
285
|
-
// if (ValidateHelper.isObjectValid(headResult?.Metadata)) {
|
|
286
|
-
// currentObject.description = headResult?.Metadata?.description
|
|
287
|
-
// currentObject.report = headResult?.Metadata?.report
|
|
288
|
-
// currentObject.title = headResult?.Metadata?.title
|
|
289
|
-
// currentObject.updated_by = headResult?.Metadata?.updated_by
|
|
290
|
-
// }
|
|
291
|
-
// rv.push(currentObject)
|
|
292
|
-
// }
|
|
293
|
-
// return rv
|
|
294
|
-
// },
|
|
295
|
-
// listObjectsV2: async (args: any): Promise<AWS.S3.ListObjectsV2Output> => {
|
|
296
|
-
// // set first/last limits
|
|
297
|
-
// PaginationHelper.limitPagination(parent, args, ctx, info, rest)
|
|
298
|
-
// const {
|
|
299
|
-
// where: { bucket_name },
|
|
300
|
-
// first,
|
|
301
|
-
// skip,
|
|
302
|
-
// } = args
|
|
303
|
-
// const params: AWS.S3.ListObjectsV2Request = {
|
|
304
|
-
// Bucket: `${bucket_name}${AwsS3Helper.getBucketEnvSuffix(
|
|
305
|
-
// parent,
|
|
306
|
-
// args,
|
|
307
|
-
// ctx,
|
|
308
|
-
// info,
|
|
309
|
-
// rest,
|
|
310
|
-
// )}`,
|
|
311
|
-
// MaxKeys: first,
|
|
312
|
-
// StartAfter: `${skip}`,
|
|
313
|
-
// }
|
|
314
|
-
// const rv: AWS.S3.ListObjectsV2Output = await awsS3
|
|
315
|
-
// .listObjectsV2(params)
|
|
316
|
-
// .promise()
|
|
317
|
-
// return rv
|
|
318
|
-
// },
|
|
319
|
-
// moveMyReport: async (args: any): Promise<never> => {
|
|
320
|
-
// throw new ApolloError('not yet implemented')
|
|
321
|
-
// },
|
|
322
|
-
// renameMyReport: async (args: any): Promise<any> => {
|
|
323
|
-
// const {
|
|
324
|
-
// data: { from },
|
|
325
|
-
// }: { data: { from: string } } = args
|
|
326
|
-
// const copyResult: any = await AwsS3Helper.copyMyReport(
|
|
327
|
-
// parent,
|
|
328
|
-
// args,
|
|
329
|
-
// ctx,
|
|
330
|
-
// info,
|
|
331
|
-
// rest,
|
|
332
|
-
// ),
|
|
333
|
-
// rv: any = await AwsS3Helper.deleteMyReport(
|
|
334
|
-
// parent,
|
|
335
|
-
// { data: { name: from } },
|
|
336
|
-
// ctx,
|
|
337
|
-
// info,
|
|
338
|
-
// rest,
|
|
339
|
-
// )
|
|
340
|
-
// // notify
|
|
341
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
342
|
-
// return rv
|
|
343
|
-
// },
|
|
344
|
-
// toListObject: (args: any): ListObject => {
|
|
345
|
-
// const result: AWS.S3.ListObjectsV2Output = args.data.result,
|
|
346
|
-
// rv: ListObject = {
|
|
347
|
-
// common_prefixes: AwsHelper.toListObjectCommonPrefixArray(
|
|
348
|
-
// parent,
|
|
349
|
-
// { data: { prefixes: result.CommonPrefixes } },
|
|
350
|
-
// ctx,
|
|
351
|
-
// info,
|
|
352
|
-
// rest,
|
|
353
|
-
// ),
|
|
354
|
-
// contents: AwsHelper.toListObjectContentArray(
|
|
355
|
-
// parent,
|
|
356
|
-
// { data: { contents: result.Contents } },
|
|
357
|
-
// ctx,
|
|
358
|
-
// info,
|
|
359
|
-
// rest,
|
|
360
|
-
// ),
|
|
361
|
-
// is_truncated: result.IsTruncated,
|
|
362
|
-
// key_count: result.KeyCount,
|
|
363
|
-
// max_keys: result.MaxKeys,
|
|
364
|
-
// name: result.Name,
|
|
365
|
-
// prefix: result.Prefix,
|
|
366
|
-
// start_after: result.StartAfter,
|
|
367
|
-
// }
|
|
368
|
-
// return rv
|
|
369
|
-
// },
|
|
370
|
-
// toListObjectCommonPrefixArray: (args: any): Array<ListObjectCommonPrefix> => {
|
|
371
|
-
// const prefixes: Array<AWS.S3.Types.CommonPrefix> = args.data.prefixes,
|
|
372
|
-
// rv: Array<ListObjectCommonPrefix> = prefixes.map((p) => {
|
|
373
|
-
// return { prefix: p.Prefix }
|
|
374
|
-
// })
|
|
375
|
-
// return rv
|
|
376
|
-
// },
|
|
377
|
-
// toListObjectContentArray: (args: any): Array<ListObjectContent> => {
|
|
378
|
-
// const contents: Array<AWS.S3.Types.Object> = args.data.contents,
|
|
379
|
-
// rv: Array<ListObjectContent> = contents.map((c) => {
|
|
380
|
-
// return {
|
|
381
|
-
// e_tag: c.ETag,
|
|
382
|
-
// name: c.Key,
|
|
383
|
-
// last_modified:
|
|
384
|
-
// c.LastModified != null
|
|
385
|
-
// ? new Date(c.LastModified).getTime()
|
|
386
|
-
// : undefined,
|
|
387
|
-
// size: c.Size,
|
|
388
|
-
// storage_class: c.StorageClass,
|
|
389
|
-
// }
|
|
390
|
-
// })
|
|
391
|
-
// return rv
|
|
392
|
-
// },
|
|
393
|
-
// uploadObject: async (args: any): Promise<AWS.S3.ManagedUpload.SendData> => {
|
|
394
|
-
// const {
|
|
395
|
-
// data: {
|
|
396
|
-
// bucket_name,
|
|
397
|
-
// content,
|
|
398
|
-
// description = '',
|
|
399
|
-
// file_name: fileName,
|
|
400
|
-
// name,
|
|
401
|
-
// title = '',
|
|
402
|
-
// },
|
|
403
|
-
// }: {
|
|
404
|
-
// data: {
|
|
405
|
-
// bucket_name: string
|
|
406
|
-
// content: string
|
|
407
|
-
// description: string
|
|
408
|
-
// file_name: string
|
|
409
|
-
// name: string
|
|
410
|
-
// title: string
|
|
411
|
-
// }
|
|
412
|
-
// } = args
|
|
413
|
-
// const params: AWS.S3.Types.PutObjectRequest = {
|
|
414
|
-
// Bucket: `${bucket_name}${AwsS3Helper.getBucketEnvSuffix(
|
|
415
|
-
// parent,
|
|
416
|
-
// args,
|
|
417
|
-
// ctx,
|
|
418
|
-
// info,
|
|
419
|
-
// rest,
|
|
420
|
-
// )}`,
|
|
421
|
-
// Key: fileName,
|
|
422
|
-
// Body: content,
|
|
423
|
-
// Metadata: {
|
|
424
|
-
// description,
|
|
425
|
-
// name,
|
|
426
|
-
// //report: report?.readable_id,
|
|
427
|
-
// title,
|
|
428
|
-
// updated_by: ctx.user.username,
|
|
429
|
-
// },
|
|
430
|
-
// }
|
|
431
|
-
// const rv: AWS.S3.ManagedUpload.SendData = await awsS3
|
|
432
|
-
// .upload(params)
|
|
433
|
-
// .promise()
|
|
434
|
-
// // notify
|
|
435
|
-
// NotifyHelper.notify(parent, { data: { payload: rv } }, ctx, info, rest)
|
|
436
|
-
// return rv
|
|
437
|
-
// },
|
|
438
|
-
// validateCreateFolder: async (
|
|
439
|
-
// parent: any,
|
|
440
|
-
// args: any,
|
|
441
|
-
// ctx: Context,
|
|
442
|
-
// info: any,
|
|
443
|
-
// rest: any,
|
|
444
|
-
// ): Promise<any> => {
|
|
445
|
-
// let {
|
|
446
|
-
// data: { bucket_name, name },
|
|
447
|
-
// } = args
|
|
448
|
-
// if (name == null) throw new ApolloError('name cannot be null')
|
|
449
|
-
// name = name.trim()
|
|
450
|
-
// if (ValidateHelper.isStringValid(name) == false)
|
|
451
|
-
// throw new ApolloError(
|
|
452
|
-
// 'name must contain at least one non-space character',
|
|
453
|
-
// )
|
|
454
|
-
// if (name.includes('/')) throw new ApolloError('name cannot contain slashes')
|
|
455
|
-
// // const headRes = await s3.headObject({ Bucket: bucket_name, Key: name }, () => { })).promise()
|
|
456
|
-
// // if(headRes. )
|
|
457
|
-
// },
|
|
458
|
-
// }
|
|
459
|
-
// export { AwsS3Helper }
|
|
460
|
-
));
|
|
461
|
-
function _interop_require_default(obj) {
|
|
462
|
-
return obj && obj.__esModule ? obj : {
|
|
463
|
-
default: obj
|
|
464
|
-
};
|
|
465
|
-
}
|