@balena/pinejs 21.4.0-build-add-actions-example-f26873fd527dfaaabb15c7bc21476f6b48bfc38a-1 → 21.4.0-build-add-odata-actions-459d3f3fccd7ac2f79550ad13c8f3f5a818c9ad5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pinejs-cache.json +1 -1
- package/.versionbot/CHANGELOG.yml +64 -35
- package/CHANGELOG.md +11 -6
- package/out/config-loader/config-loader.js +7 -8
- package/out/config-loader/config-loader.js.map +1 -1
- package/out/config-loader/env.d.ts +0 -4
- package/out/config-loader/env.js +0 -4
- package/out/config-loader/env.js.map +1 -1
- package/out/server-glue/module.js +0 -2
- package/out/server-glue/module.js.map +1 -1
- package/out/tasks/index.d.ts +0 -1
- package/out/tasks/index.js +1 -6
- package/out/tasks/index.js.map +1 -1
- package/out/webresource-handler/index.d.ts +1 -10
- package/out/webresource-handler/index.js +45 -83
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +5 -5
- package/src/config-loader/config-loader.ts +9 -9
- package/src/config-loader/env.ts +0 -11
- package/src/server-glue/module.ts +0 -2
- package/src/tasks/index.ts +1 -9
- package/src/webresource-handler/index.ts +83 -117
- package/out/tasks/pine-tasks.d.ts +0 -1
- package/out/tasks/pine-tasks.js +0 -7
- package/out/tasks/pine-tasks.js.map +0 -1
- package/out/webresource-handler/actions/beginUpload.d.ts +0 -3
- package/out/webresource-handler/actions/beginUpload.js +0 -105
- package/out/webresource-handler/actions/beginUpload.js.map +0 -1
- package/out/webresource-handler/actions/canceUpload.d.ts +0 -3
- package/out/webresource-handler/actions/canceUpload.js +0 -58
- package/out/webresource-handler/actions/canceUpload.js.map +0 -1
- package/out/webresource-handler/actions/commitUpload.d.ts +0 -3
- package/out/webresource-handler/actions/commitUpload.js +0 -85
- package/out/webresource-handler/actions/commitUpload.js.map +0 -1
- package/out/webresource-handler/delete-file-task.d.ts +0 -1
- package/out/webresource-handler/delete-file-task.js +0 -37
- package/out/webresource-handler/delete-file-task.js.map +0 -1
- package/out/webresource-handler/multipartUpload.d.ts +0 -4
- package/out/webresource-handler/multipartUpload.js +0 -14
- package/out/webresource-handler/multipartUpload.js.map +0 -1
- package/out/webresource-handler/webresource.d.ts +0 -42
- package/out/webresource-handler/webresource.js +0 -2
- package/out/webresource-handler/webresource.js.map +0 -1
- package/out/webresource-handler/webresource.sbvr +0 -60
- package/src/tasks/pine-tasks.ts +0 -7
- package/src/webresource-handler/actions/beginUpload.ts +0 -163
- package/src/webresource-handler/actions/canceUpload.ts +0 -92
- package/src/webresource-handler/actions/commitUpload.ts +0 -117
- package/src/webresource-handler/delete-file-task.ts +0 -42
- package/src/webresource-handler/multipartUpload.ts +0 -23
- package/src/webresource-handler/webresource.sbvr +0 -60
- package/src/webresource-handler/webresource.ts +0 -48
@@ -11,20 +11,10 @@ import {
|
|
11
11
|
odataNameToSqlName,
|
12
12
|
sqlNameToODataName,
|
13
13
|
} from '@balena/odata-to-abstract-sql';
|
14
|
-
import type { ConfigLoader } from '../server-glue/module.js';
|
15
14
|
import { errors, permissions } from '../server-glue/module.js';
|
16
15
|
import type { WebResourceType as WebResource } from '@balena/sbvr-types';
|
17
16
|
import { TypedError } from 'typed-error';
|
18
17
|
import type { Resolvable } from '../sbvr-api/common-types.js';
|
19
|
-
import type { Tx } from '../database-layer/db.js';
|
20
|
-
import { isPineTasksAvailable } from '../tasks/index.js';
|
21
|
-
import type WebresourceModel from './webresource.js';
|
22
|
-
import { importSBVR } from '../server-glue/sbvr-loader.js';
|
23
|
-
import { beginUploadAction } from './actions/beginUpload.js';
|
24
|
-
import { isMultipartUploadAvailable } from './multipartUpload.js';
|
25
|
-
import { commitUploadAction } from './actions/commitUpload.js';
|
26
|
-
import { cancelUploadAction } from './actions/canceUpload.js';
|
27
|
-
import { addAction } from '../sbvr-api/actions.js';
|
28
18
|
|
29
19
|
export * from './handlers/index.js';
|
30
20
|
|
@@ -326,34 +316,12 @@ export const getWebResourceFields = (
|
|
326
316
|
.map((f) => sqlNameToODataName(f.fieldName));
|
327
317
|
};
|
328
318
|
|
329
|
-
const
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
passthrough: {
|
336
|
-
req: permissions.root,
|
337
|
-
tx,
|
338
|
-
},
|
339
|
-
body: {
|
340
|
-
key: crypto.randomUUID(),
|
341
|
-
is_executed_by__handler: 'delete_webresource_file',
|
342
|
-
is_executed_with__parameter_set: {
|
343
|
-
fileKey: fileKey,
|
344
|
-
},
|
345
|
-
attempt_limit: 2 ** 31 - 1,
|
346
|
-
},
|
347
|
-
});
|
348
|
-
}),
|
349
|
-
);
|
350
|
-
} else {
|
351
|
-
await Promise.all(
|
352
|
-
keysToDelete.map(async (fileKey) => {
|
353
|
-
return await configuredWebResourceHandler?.removeFile(fileKey);
|
354
|
-
}),
|
355
|
-
);
|
356
|
-
}
|
319
|
+
const deleteFiles = async (
|
320
|
+
keysToDelete: string[],
|
321
|
+
webResourceHandler: WebResourceHandler,
|
322
|
+
) => {
|
323
|
+
const promises = keysToDelete.map((r) => webResourceHandler.removeFile(r));
|
324
|
+
await Promise.all(promises);
|
357
325
|
};
|
358
326
|
|
359
327
|
const throwIfWebresourceNotInMultipart = (
|
@@ -361,13 +329,6 @@ const throwIfWebresourceNotInMultipart = (
|
|
361
329
|
{ req, request }: HookArgs,
|
362
330
|
) => {
|
363
331
|
if (
|
364
|
-
// root needs to be able to bypass the multipart check as
|
365
|
-
// it needs to pass the direct payload on multipart uploads (on storage provider)
|
366
|
-
req.user !== permissions.root.user &&
|
367
|
-
// This is checking for HTTP multipart form submission/request (e.g. send the actual file via the API)
|
368
|
-
// Not to confuse with multipart uploads
|
369
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods/POST#multipart_form_submission
|
370
|
-
// See: https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html
|
371
332
|
!req.is?.('multipart') &&
|
372
333
|
webResourceFields.some((field) => request.values[field] != null)
|
373
334
|
) {
|
@@ -377,22 +338,18 @@ const throwIfWebresourceNotInMultipart = (
|
|
377
338
|
}
|
378
339
|
};
|
379
340
|
|
380
|
-
const getCreateWebResourceHooks = (
|
341
|
+
const getCreateWebResourceHooks = (
|
342
|
+
webResourceHandler: WebResourceHandler,
|
343
|
+
): sbvrUtils.Hooks => {
|
381
344
|
return {
|
382
345
|
PRERUN: (hookArgs) => {
|
383
346
|
const webResourceFields = getWebResourceFields(hookArgs.request);
|
384
347
|
throwIfWebresourceNotInMultipart(webResourceFields, hookArgs);
|
385
348
|
},
|
386
|
-
'POSTRUN-ERROR':
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
return;
|
391
|
-
}
|
392
|
-
|
393
|
-
const keysToDelete = getWebResourcesKeysFromRequest(fields, request);
|
394
|
-
// Explicitely not passing tx as it will be rolledback as it is an error hook
|
395
|
-
await deleteOnStorage(keysToDelete);
|
349
|
+
'POSTRUN-ERROR': ({ tx, request }) => {
|
350
|
+
tx.on('rollback', () => {
|
351
|
+
void deleteRollbackPendingFields(request, webResourceHandler);
|
352
|
+
});
|
396
353
|
},
|
397
354
|
};
|
398
355
|
};
|
@@ -421,12 +378,21 @@ const getWebResourcesKeysFromRequest = (
|
|
421
378
|
.filter((href) => href != null);
|
422
379
|
};
|
423
380
|
|
424
|
-
const getRemoveWebResourceHooks = (
|
381
|
+
const getRemoveWebResourceHooks = (
|
382
|
+
webResourceHandler: WebResourceHandler,
|
383
|
+
): sbvrUtils.Hooks => {
|
425
384
|
return {
|
426
385
|
PRERUN: async (args) => {
|
427
386
|
const { api, request, tx } = args;
|
428
387
|
let webResourceFields = getWebResourceFields(request);
|
429
388
|
|
389
|
+
throwIfWebresourceNotInMultipart(webResourceFields, args);
|
390
|
+
|
391
|
+
// Request failed on DB roundtrip (e.g. DB constraint) and pending files need to be deleted
|
392
|
+
tx.on('rollback', () => {
|
393
|
+
void deleteRollbackPendingFields(request, webResourceHandler);
|
394
|
+
});
|
395
|
+
|
430
396
|
if (request.method === 'PATCH') {
|
431
397
|
webResourceFields = Object.entries(request.values)
|
432
398
|
.filter(
|
@@ -435,8 +401,6 @@ const getRemoveWebResourceHooks = (): sbvrUtils.Hooks => {
|
|
435
401
|
)
|
436
402
|
.map(([key]) => key);
|
437
403
|
}
|
438
|
-
request.custom.webResourceFields = webResourceFields;
|
439
|
-
throwIfWebresourceNotInMultipart(webResourceFields, args);
|
440
404
|
|
441
405
|
if (webResourceFields.length === 0) {
|
442
406
|
// No need to delete anything as no file is in the wire
|
@@ -447,32 +411,43 @@ const getRemoveWebResourceHooks = (): sbvrUtils.Hooks => {
|
|
447
411
|
// This can only be validated here because we need to first ensure the
|
448
412
|
// request is actually modifying a webresource before erroring out
|
449
413
|
if (request.method === 'PATCH' && request.odataQuery?.key == null) {
|
414
|
+
// When we get here, files have already been uploaded. We need to mark them for deletion.
|
415
|
+
const keysToDelete = getWebResourcesKeysFromRequest(
|
416
|
+
webResourceFields,
|
417
|
+
request,
|
418
|
+
);
|
419
|
+
|
420
|
+
// Set deletion of files on the wire as request will throw
|
421
|
+
tx.on('end', () => {
|
422
|
+
deletePendingFiles(keysToDelete, request, webResourceHandler);
|
423
|
+
});
|
424
|
+
|
450
425
|
throw new errors.BadRequestError(
|
451
426
|
'WebResources can only be updated when providing a resource key.',
|
452
427
|
);
|
453
428
|
}
|
454
429
|
|
430
|
+
// This can be > 1 in both DELETE requests or PATCH requests to not accessible IDs.
|
455
431
|
const ids = await sbvrUtils.getAffectedIds(args);
|
456
432
|
if (ids.length === 0) {
|
457
433
|
// Set deletion of files on the wire as no resource was affected
|
458
|
-
request
|
434
|
+
// Note that for DELETE requests it should not find any request on the wire
|
435
|
+
const keysToDelete = getWebResourcesKeysFromRequest(
|
459
436
|
webResourceFields,
|
460
437
|
request,
|
461
438
|
);
|
439
|
+
deletePendingFiles(keysToDelete, request, webResourceHandler);
|
462
440
|
return;
|
463
441
|
}
|
464
442
|
|
465
|
-
// If it reaches here, it means that it will try to patch/delete the webresource
|
466
|
-
// So we need (before postrun) get what are the current keys to be deleted
|
467
|
-
// if post run succeeds
|
468
443
|
const webResources = (await api.get({
|
469
444
|
resource: request.resourceName,
|
470
445
|
passthrough: {
|
471
|
-
tx,
|
446
|
+
tx: args.tx,
|
472
447
|
req: permissions.root,
|
473
448
|
},
|
474
449
|
options: {
|
475
|
-
$select:
|
450
|
+
$select: webResourceFields,
|
476
451
|
$filter: {
|
477
452
|
id: {
|
478
453
|
$in: ids,
|
@@ -480,34 +455,60 @@ const getRemoveWebResourceHooks = (): sbvrUtils.Hooks => {
|
|
480
455
|
},
|
481
456
|
},
|
482
457
|
})) as WebResourcesDbResponse[] | undefined | null;
|
483
|
-
request.custom.onPostRunDelete = getWebResourcesHrefs(webResources);
|
484
|
-
},
|
485
458
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
);
|
495
|
-
// Explicitely not passing tx as it will be rolledback as it is an error hook
|
496
|
-
await deleteOnStorage(keysToDelete);
|
459
|
+
// Deletes previous stored resources in case they were patched or the whole entity was deleted
|
460
|
+
tx.on('end', () => {
|
461
|
+
deletePendingFiles(
|
462
|
+
getWebResourcesHrefs(webResources),
|
463
|
+
request,
|
464
|
+
webResourceHandler,
|
465
|
+
);
|
466
|
+
});
|
497
467
|
},
|
498
468
|
};
|
499
469
|
};
|
500
470
|
|
471
|
+
const deleteRollbackPendingFields = async (
|
472
|
+
request: uriParser.ODataRequest,
|
473
|
+
webResourceHandler: WebResourceHandler,
|
474
|
+
) => {
|
475
|
+
const fields = getWebResourceFields(request);
|
476
|
+
|
477
|
+
if (fields.length === 0) {
|
478
|
+
return;
|
479
|
+
}
|
480
|
+
|
481
|
+
const keysToDelete = getWebResourcesKeysFromRequest(fields, request);
|
482
|
+
await deleteFiles(keysToDelete, webResourceHandler);
|
483
|
+
};
|
484
|
+
|
485
|
+
const deletePendingFiles = (
|
486
|
+
keysToDelete: string[],
|
487
|
+
request: uriParser.ODataRequest,
|
488
|
+
webResourceHandler: WebResourceHandler,
|
489
|
+
): void => {
|
490
|
+
// on purpose does not await for this promise to resolve
|
491
|
+
try {
|
492
|
+
void deleteFiles(keysToDelete, webResourceHandler);
|
493
|
+
} catch (err) {
|
494
|
+
getLogger(request.vocabulary).error(`Failed to delete pending files`, err);
|
495
|
+
}
|
496
|
+
};
|
497
|
+
|
501
498
|
export const getDefaultHandler = (): WebResourceHandler => {
|
502
499
|
return new NoopHandler();
|
503
500
|
};
|
504
501
|
|
505
|
-
export const setupUploadHooks = (
|
502
|
+
export const setupUploadHooks = (
|
503
|
+
handler: WebResourceHandler,
|
504
|
+
apiRoot: string,
|
505
|
+
resourceName: string,
|
506
|
+
) => {
|
506
507
|
sbvrUtils.addPureHook(
|
507
508
|
'DELETE',
|
508
509
|
apiRoot,
|
509
510
|
resourceName,
|
510
|
-
getRemoveWebResourceHooks(),
|
511
|
+
getRemoveWebResourceHooks(handler),
|
511
512
|
);
|
512
513
|
|
513
514
|
sbvrUtils.addPureHook(
|
@@ -515,48 +516,13 @@ export const setupUploadHooks = (apiRoot: string, resourceName: string) => {
|
|
515
516
|
apiRoot,
|
516
517
|
resourceName,
|
517
518
|
// PATCH also needs to remove the old resource in case a webresource was modified
|
518
|
-
getRemoveWebResourceHooks(),
|
519
|
+
getRemoveWebResourceHooks(handler),
|
519
520
|
);
|
520
521
|
|
521
522
|
sbvrUtils.addPureHook(
|
522
523
|
'POST',
|
523
524
|
apiRoot,
|
524
525
|
resourceName,
|
525
|
-
getCreateWebResourceHooks(),
|
526
|
+
getCreateWebResourceHooks(handler),
|
526
527
|
);
|
527
528
|
};
|
528
|
-
|
529
|
-
export const setupUploadActions = (apiRoot: string, resourceName: string) => {
|
530
|
-
const resource = sqlNameToODataName(resourceName);
|
531
|
-
if (isMultipartUploadAvailable(configuredWebResourceHandler)) {
|
532
|
-
addAction(apiRoot, resource, 'beginUpload', beginUploadAction);
|
533
|
-
|
534
|
-
addAction(apiRoot, resource, 'commitUpload', commitUploadAction);
|
535
|
-
|
536
|
-
addAction(apiRoot, resource, 'cancelUpload', cancelUploadAction);
|
537
|
-
}
|
538
|
-
};
|
539
|
-
|
540
|
-
const initSql = `
|
541
|
-
CREATE INDEX IF NOT EXISTS idx_multipart_upload_uuid ON "multipart upload" (uuid);
|
542
|
-
CREATE INDEX IF NOT EXISTS idx_multipart_upload_status ON "multipart upload" (status);
|
543
|
-
`;
|
544
|
-
|
545
|
-
const modelText = await importSBVR('./webresource.sbvr', import.meta);
|
546
|
-
|
547
|
-
declare module '../sbvr-api/sbvr-utils.js' {
|
548
|
-
export interface API {
|
549
|
-
webresource: PinejsClient<WebresourceModel>;
|
550
|
-
}
|
551
|
-
}
|
552
|
-
|
553
|
-
export const config: ConfigLoader.Config = {
|
554
|
-
models: [
|
555
|
-
{
|
556
|
-
modelName: 'webresource',
|
557
|
-
apiRoot: 'webresource',
|
558
|
-
modelText,
|
559
|
-
initSql,
|
560
|
-
},
|
561
|
-
],
|
562
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const addPineTaskHandlers: () => void;
|
package/out/tasks/pine-tasks.js
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import { tasks } from '../server-glue/module.js';
|
2
|
-
import { addDeleteFileTaskHandler } from '../webresource-handler/delete-file-task.js';
|
3
|
-
export const addPineTaskHandlers = () => {
|
4
|
-
addDeleteFileTaskHandler();
|
5
|
-
void tasks.worker?.start();
|
6
|
-
};
|
7
|
-
//# sourceMappingURL=pine-tasks.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"pine-tasks.js","sourceRoot":"","sources":["../../src/tasks/pine-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACvC,wBAAwB,EAAE,CAAC;IAC3B,KAAK,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC"}
|
@@ -1,105 +0,0 @@
|
|
1
|
-
import { api } from '../../sbvr-api/sbvr-utils.js';
|
2
|
-
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
3
|
-
import { getWebResourceFields } from '../index.js';
|
4
|
-
import { BadRequestError, NotImplementedError } from '../../sbvr-api/errors.js';
|
5
|
-
import { permissions, sbvrUtils } from '../../server-glue/module.js';
|
6
|
-
import { randomUUID } from 'crypto';
|
7
|
-
import { ajv } from '../../tasks/common.js';
|
8
|
-
const beginUploadPayloadSchema = {
|
9
|
-
type: 'object',
|
10
|
-
minProperties: 1,
|
11
|
-
maxProperties: 1,
|
12
|
-
additionalProperties: {
|
13
|
-
type: 'object',
|
14
|
-
properties: {
|
15
|
-
filename: { type: 'string' },
|
16
|
-
content_type: { type: 'string' },
|
17
|
-
size: { type: 'number' },
|
18
|
-
chunk_size: { type: 'number' },
|
19
|
-
},
|
20
|
-
required: ['filename', 'content_type', 'size'],
|
21
|
-
additionalProperties: false,
|
22
|
-
},
|
23
|
-
};
|
24
|
-
const validateBeginUpload = ajv.compile(beginUploadPayloadSchema);
|
25
|
-
export const beginUploadAction = async ({ request, tx, id, req, }) => {
|
26
|
-
if (typeof id !== 'number') {
|
27
|
-
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
28
|
-
}
|
29
|
-
const handler = getMultipartUploadHandler();
|
30
|
-
const { fieldName, beginUploadPayload } = parseBeginUpload(request, handler);
|
31
|
-
await runFakeDbPatch(request, {
|
32
|
-
[fieldName]: { ...beginUploadPayload, href: 'fake_patch' },
|
33
|
-
});
|
34
|
-
const { fileKey, uploadId, uploadParts } = await handler.multipartUpload.begin(fieldName, beginUploadPayload);
|
35
|
-
const uuid = randomUUID();
|
36
|
-
await api.webresource.post({
|
37
|
-
resource: 'multipart_upload',
|
38
|
-
body: {
|
39
|
-
uuid,
|
40
|
-
resource_name: request.resourceName,
|
41
|
-
field_name: fieldName,
|
42
|
-
resource_id: id,
|
43
|
-
upload_id: uploadId,
|
44
|
-
file_key: fileKey,
|
45
|
-
status: 'pending',
|
46
|
-
...beginUploadPayload,
|
47
|
-
expiry_date: Date.now() + 7 * 24 * 60 * 60 * 1000,
|
48
|
-
is_created_by__actor: req.user?.actor,
|
49
|
-
},
|
50
|
-
passthrough: {
|
51
|
-
req: permissions.root,
|
52
|
-
tx,
|
53
|
-
},
|
54
|
-
});
|
55
|
-
return {
|
56
|
-
body: { [fieldName]: { uuid, uploadParts } },
|
57
|
-
statusCode: 200,
|
58
|
-
};
|
59
|
-
};
|
60
|
-
const parseBeginUpload = (request, webResourceHandler) => {
|
61
|
-
const { values } = request;
|
62
|
-
const isValid = validateBeginUpload(values);
|
63
|
-
if (!isValid) {
|
64
|
-
throw new BadRequestError('Invalid begin upload payload');
|
65
|
-
}
|
66
|
-
const fieldName = Object.keys(values)[0];
|
67
|
-
const webResourceFields = getWebResourceFields(request, false);
|
68
|
-
if (!webResourceFields.includes(fieldName)) {
|
69
|
-
throw new BadRequestError(`The provided field '${fieldName}' is not a valid webresource`);
|
70
|
-
}
|
71
|
-
const beginUploadPayload = {
|
72
|
-
...values[fieldName],
|
73
|
-
chunk_size: values[fieldName].chunk_size ??
|
74
|
-
webResourceHandler.multipartUpload.getMinimumPartSize(),
|
75
|
-
};
|
76
|
-
if (beginUploadPayload.chunk_size <
|
77
|
-
webResourceHandler.multipartUpload.getMinimumPartSize()) {
|
78
|
-
throw new BadRequestError('Chunk size is too small');
|
79
|
-
}
|
80
|
-
return {
|
81
|
-
beginUploadPayload,
|
82
|
-
fieldName,
|
83
|
-
};
|
84
|
-
};
|
85
|
-
const runFakeDbPatch = async (request, fakeDbPatch) => {
|
86
|
-
const fakeTx = await sbvrUtils.db.transaction();
|
87
|
-
try {
|
88
|
-
const newUrl = request.url
|
89
|
-
.slice(1)
|
90
|
-
.split('?', 1)[0]
|
91
|
-
.replace(/\/beginUpload$/, '');
|
92
|
-
await api[request.vocabulary].request({
|
93
|
-
method: 'PATCH',
|
94
|
-
url: newUrl,
|
95
|
-
body: fakeDbPatch,
|
96
|
-
passthrough: { tx: fakeTx, req: permissions.root },
|
97
|
-
});
|
98
|
-
}
|
99
|
-
finally {
|
100
|
-
if (!fakeTx.isClosed()) {
|
101
|
-
await fakeTx.rollback();
|
102
|
-
}
|
103
|
-
}
|
104
|
-
};
|
105
|
-
//# sourceMappingURL=beginUpload.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"beginUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/beginUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMpC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAS5C,MAAM,wBAAwB,GAAG;IAChC,IAAI,EAAE,QAAQ;IACd,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC;IAChB,oBAAoB,EAAE;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACX,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC5B,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAChC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC9B;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,cAAc,EAAE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;AAWF,MAAM,cAAc,GAAG,KAAK,EAC3B,OAA2B,EAC3B,WAAiC,EAChC,EAAE;IACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;IAChD,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG;aACxB,KAAK,CAAC,CAAC,CAAC;aACR,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAChB,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAEhC,MAAM,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,OAAO;YACf,GAAG,EAAE,MAAM;YACX,IAAI,EAAE,WAAW;YAGjB,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE;SAClD,CAAC,CAAC;IACJ,CAAC;YAAS,CAAC;QACV,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;YACxB,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;AACF,CAAC,CAAC"}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { BadRequestError, NotImplementedError, UnauthorizedError, } from '../../sbvr-api/errors.js';
|
2
|
-
import { api } from '../../sbvr-api/sbvr-utils.js';
|
3
|
-
import { permissions } from '../../server-glue/module.js';
|
4
|
-
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
5
|
-
export const cancelUploadAction = async ({ request, tx, id: resourceId, }) => {
|
6
|
-
if (typeof resourceId !== 'number') {
|
7
|
-
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
8
|
-
}
|
9
|
-
const { id, fileKey, uploadId } = await getOngoingUpload(request, resourceId, tx);
|
10
|
-
const handler = getMultipartUploadHandler();
|
11
|
-
await api.webresource.patch({
|
12
|
-
resource: 'multipart_upload',
|
13
|
-
body: {
|
14
|
-
status: 'cancelled',
|
15
|
-
},
|
16
|
-
id,
|
17
|
-
passthrough: {
|
18
|
-
tx: tx,
|
19
|
-
req: permissions.root,
|
20
|
-
},
|
21
|
-
});
|
22
|
-
await handler.multipartUpload.cancel({ fileKey, uploadId });
|
23
|
-
return {
|
24
|
-
statusCode: 204,
|
25
|
-
};
|
26
|
-
};
|
27
|
-
const getOngoingUpload = async (request, affectedId, tx) => {
|
28
|
-
const { uuid } = request.values;
|
29
|
-
if (uuid == null || typeof uuid !== 'string') {
|
30
|
-
throw new BadRequestError('Invalid uuid type');
|
31
|
-
}
|
32
|
-
const [multipartUpload] = await api.webresource.get({
|
33
|
-
resource: 'multipart_upload',
|
34
|
-
options: {
|
35
|
-
$select: ['id', 'file_key', 'upload_id'],
|
36
|
-
$filter: {
|
37
|
-
uuid,
|
38
|
-
status: 'pending',
|
39
|
-
expiry_date: { $gt: { $now: {} } },
|
40
|
-
resource_name: request.resourceName,
|
41
|
-
resource_id: affectedId,
|
42
|
-
},
|
43
|
-
},
|
44
|
-
passthrough: {
|
45
|
-
tx,
|
46
|
-
req: permissions.rootRead,
|
47
|
-
},
|
48
|
-
});
|
49
|
-
if (multipartUpload == null) {
|
50
|
-
throw new UnauthorizedError();
|
51
|
-
}
|
52
|
-
return {
|
53
|
-
id: multipartUpload.id,
|
54
|
-
fileKey: multipartUpload.file_key,
|
55
|
-
uploadId: multipartUpload.upload_id,
|
56
|
-
};
|
57
|
-
};
|
58
|
-
//# sourceMappingURL=canceUpload.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"canceUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/canceUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,GAAG,EAAiB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;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O,EAAE;YACR,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC;YACxC,OAAO,EAAE;gBAER,IAAI;gBACJ,MAAM,EAAE,SAAS;gBACjB,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBAClC,aAAa,EAAE,OAAO,CAAC,YAAY;gBACnC,WAAW,EAAE,UAAU;aACvB;SACD;QACD,WAAW,EAAE;YACZ,EAAE;YACF,GAAG,EAAE,WAAW,CAAC,QAAQ;SACzB;KACD,CAAC,CAAC;IAEH,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO;QACN,EAAE,EAAE,eAAe,CAAC,EAAE;QACtB,OAAO,EAAE,eAAe,CAAC,QAAQ;QACjC,QAAQ,EAAE,eAAe,CAAC,SAAS;KACnC,CAAC;AACH,CAAC,CAAC"}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { BadRequestError, NotImplementedError, UnauthorizedError, } from '../../sbvr-api/errors.js';
|
2
|
-
import { api } from '../../sbvr-api/sbvr-utils.js';
|
3
|
-
import { permissions } from '../../server-glue/module.js';
|
4
|
-
import { getMultipartUploadHandler } from '../multipartUpload.js';
|
5
|
-
export const commitUploadAction = async ({ request, tx, id, api: applicationApi, }) => {
|
6
|
-
if (typeof id !== 'number') {
|
7
|
-
throw new NotImplementedError('multipart upload do not yet support non-numeric ids');
|
8
|
-
}
|
9
|
-
const multipartUpload = await getOngoingUpload(request, id, tx);
|
10
|
-
const handler = getMultipartUploadHandler();
|
11
|
-
const webresource = await handler.multipartUpload.commit({
|
12
|
-
fileKey: multipartUpload.fileKey,
|
13
|
-
uploadId: multipartUpload.uploadId,
|
14
|
-
filename: multipartUpload.filename,
|
15
|
-
providerCommitData: multipartUpload.providerCommitData,
|
16
|
-
});
|
17
|
-
await Promise.all([
|
18
|
-
api.webresource.patch({
|
19
|
-
resource: 'multipart_upload',
|
20
|
-
body: {
|
21
|
-
status: 'completed',
|
22
|
-
},
|
23
|
-
options: {
|
24
|
-
$filter: {
|
25
|
-
uuid: multipartUpload.uuid,
|
26
|
-
},
|
27
|
-
},
|
28
|
-
passthrough: {
|
29
|
-
tx: tx,
|
30
|
-
req: permissions.root,
|
31
|
-
},
|
32
|
-
}),
|
33
|
-
applicationApi.patch({
|
34
|
-
resource: request.resourceName,
|
35
|
-
id,
|
36
|
-
body: {
|
37
|
-
[multipartUpload.fieldName]: webresource,
|
38
|
-
},
|
39
|
-
passthrough: {
|
40
|
-
tx: tx,
|
41
|
-
req: permissions.root,
|
42
|
-
},
|
43
|
-
}),
|
44
|
-
]);
|
45
|
-
const body = await handler.onPreRespond(webresource);
|
46
|
-
return {
|
47
|
-
body,
|
48
|
-
statusCode: 200,
|
49
|
-
};
|
50
|
-
};
|
51
|
-
const getOngoingUpload = async (request, affectedId, tx) => {
|
52
|
-
const { uuid, providerCommitData } = request.values;
|
53
|
-
if (uuid == null || typeof uuid !== 'string') {
|
54
|
-
throw new BadRequestError('Invalid uuid type');
|
55
|
-
}
|
56
|
-
const [multipartUpload] = await api.webresource.get({
|
57
|
-
resource: 'multipart_upload',
|
58
|
-
options: {
|
59
|
-
$select: ['id', 'file_key', 'upload_id', 'field_name', 'filename'],
|
60
|
-
$filter: {
|
61
|
-
uuid,
|
62
|
-
status: 'pending',
|
63
|
-
expiry_date: { $gt: { $now: {} } },
|
64
|
-
resource_name: request.resourceName,
|
65
|
-
resource_id: affectedId,
|
66
|
-
},
|
67
|
-
},
|
68
|
-
passthrough: {
|
69
|
-
tx,
|
70
|
-
req: permissions.rootRead,
|
71
|
-
},
|
72
|
-
});
|
73
|
-
if (multipartUpload == null) {
|
74
|
-
throw new UnauthorizedError();
|
75
|
-
}
|
76
|
-
return {
|
77
|
-
uuid,
|
78
|
-
providerCommitData,
|
79
|
-
fileKey: multipartUpload.file_key,
|
80
|
-
uploadId: multipartUpload.upload_id,
|
81
|
-
filename: multipartUpload.filename,
|
82
|
-
fieldName: multipartUpload.field_name,
|
83
|
-
};
|
84
|
-
};
|
85
|
-
//# sourceMappingURL=commitUpload.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"commitUpload.js","sourceRoot":"","sources":["../../../src/webresource-handler/actions/commitUpload.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACxC,OAAO,EACP,EAAE,EACF,EAAE,EACF,GAAG,EAAE,cAAc,GACF,EAAqB,EAAE;IACxC,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,mBAAmB,CAC5B,qDAAqD,CACrD,CAAC;IACH,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,yBAAyB,EAAE,CAAC;IAE5C,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC;QACxD,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,kBAAkB,EAAE,eAAe,CAAC,kBAAkB;KACtD,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC;QACjB,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC;YACrB,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE;gBACL,MAAM,EAAE,WAAW;aACnB;YACD,OA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OAAO,CAAC,YAAY;gBACnC,WAAW,EAAE,UAAU;aACvB;SACD;QACD,WAAW,EAAE;YACZ,EAAE;YACF,GAAG,EAAE,WAAW,CAAC,QAAQ;SACzB;KACD,CAAC,CAAC;IAEH,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO;QACN,IAAI;QACJ,kBAAkB;QAClB,OAAO,EAAE,eAAe,CAAC,QAAQ;QACjC,QAAQ,EAAE,eAAe,CAAC,SAAS;QACnC,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,SAAS,EAAE,eAAe,CAAC,UAAU;KACrC,CAAC;AACH,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const addDeleteFileTaskHandler: () => void;
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { addTaskHandler } from '../tasks/index.js';
|
2
|
-
import { getWebresourceHandler } from './index.js';
|
3
|
-
const deleteFileSchema = {
|
4
|
-
type: 'object',
|
5
|
-
properties: {
|
6
|
-
fileKey: {
|
7
|
-
type: 'string',
|
8
|
-
},
|
9
|
-
},
|
10
|
-
required: ['fileKey'],
|
11
|
-
additionalProperties: false,
|
12
|
-
};
|
13
|
-
export const addDeleteFileTaskHandler = () => {
|
14
|
-
addTaskHandler('delete_webresource_file', async (task) => {
|
15
|
-
const handler = getWebresourceHandler();
|
16
|
-
if (!handler) {
|
17
|
-
return {
|
18
|
-
error: 'Webresource handler not available',
|
19
|
-
status: 'failed',
|
20
|
-
};
|
21
|
-
}
|
22
|
-
try {
|
23
|
-
await handler.removeFile(task.params.fileKey);
|
24
|
-
return {
|
25
|
-
status: 'succeeded',
|
26
|
-
};
|
27
|
-
}
|
28
|
-
catch (error) {
|
29
|
-
console.error('Error deleting file:', error);
|
30
|
-
return {
|
31
|
-
error: `${error}`,
|
32
|
-
status: 'failed',
|
33
|
-
};
|
34
|
-
}
|
35
|
-
}, deleteFileSchema);
|
36
|
-
};
|
37
|
-
//# sourceMappingURL=delete-file-task.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"delete-file-task.js","sourceRoot":"","sources":["../../src/webresource-handler/delete-file-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,gBAAgB,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACX,OAAO,EAAE;YACR,IAAI,EAAE,QAAQ;SACd;KACD;IACD,QAAQ,EAAE,CAAC,SAAS,CAAC;IACrB,oBAAoB,EAAE,KAAK;CAClB,CAAC;AAEX,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC5C,cAAc,CACb,yBAAyB,EACzB,KAAK,EAAE,IAAI,EAAE,EAAE;QACd,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO;gBACN,KAAK,EAAE,mCAAmC;gBAC1C,MAAM,EAAE,QAAQ;aAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9C,OAAO;gBACN,MAAM,EAAE,WAAW;aACnB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YAC7C,OAAO;gBACN,KAAK,EAAE,GAAG,KAAK,EAAE;gBACjB,MAAM,EAAE,QAAQ;aAChB,CAAC;QACH,CAAC;IACF,CAAC,EACD,gBAAgB,CAChB,CAAC;AACH,CAAC,CAAC"}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { WebResourceHandler } from './index.js';
|
2
|
-
export type MultipartUploadHandler = WebResourceHandler & Required<Pick<WebResourceHandler, 'multipartUpload'>>;
|
3
|
-
export declare const isMultipartUploadAvailable: (handler: WebResourceHandler | undefined) => handler is MultipartUploadHandler;
|
4
|
-
export declare const getMultipartUploadHandler: () => MultipartUploadHandler;
|