@jrmc/adonis-attachment 5.0.0-beta.3 → 5.0.0-beta.4
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/build/providers/attachment_provider.d.ts.map +1 -1
- package/build/providers/attachment_provider.js +9 -1
- package/build/services/regenerate_service.js +3 -3
- package/build/src/adapters/lock.d.ts +9 -0
- package/build/src/adapters/lock.d.ts.map +1 -0
- package/build/src/adapters/lock.js +21 -0
- package/build/src/attachment_manager.d.ts +2 -2
- package/build/src/attachment_manager.d.ts.map +1 -1
- package/build/src/attachment_manager.js +6 -2
- package/build/src/controllers/attachments_controller.d.ts.map +1 -1
- package/build/src/controllers/attachments_controller.js +21 -12
- package/build/src/services/attachment/attachment_detachment_service.d.ts +19 -0
- package/build/src/services/attachment/attachment_detachment_service.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_detachment_service.js +64 -0
- package/build/src/services/attachment/attachment_persister_service.d.ts +22 -0
- package/build/src/services/attachment/attachment_persister_service.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_persister_service.js +93 -0
- package/build/src/services/attachment/attachment_recorder_service.d.ts +68 -0
- package/build/src/services/attachment/attachment_recorder_service.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_recorder_service.js +119 -0
- package/build/src/services/attachment/attachment_transaction_service.d.ts +26 -0
- package/build/src/services/attachment/attachment_transaction_service.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_transaction_service.js +43 -0
- package/build/src/services/attachment/attachment_utils.d.ts +35 -0
- package/build/src/services/attachment/attachment_utils.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_utils.js +71 -0
- package/build/src/services/attachment/attachment_variant_service.d.ts +17 -0
- package/build/src/services/attachment/attachment_variant_service.d.ts.map +1 -0
- package/build/src/services/attachment/attachment_variant_service.js +72 -0
- package/build/src/services/attachment/index.d.ts +15 -0
- package/build/src/services/attachment/index.d.ts.map +1 -0
- package/build/src/services/attachment/index.js +15 -0
- package/build/src/services/attachment_service.d.ts +8 -0
- package/build/src/services/attachment_service.d.ts.map +1 -0
- package/build/src/services/attachment_service.js +7 -0
- package/build/src/services/variant/{variant_generator.d.ts → variant_generator_service.d.ts} +8 -2
- package/build/src/services/variant/variant_generator_service.d.ts.map +1 -0
- package/build/src/services/variant/{variant_generator.js → variant_generator_service.js} +7 -1
- package/build/src/services/variant/{variant_persister.d.ts → variant_persister_service.d.ts} +8 -2
- package/build/src/services/variant/variant_persister_service.d.ts.map +1 -0
- package/build/src/services/variant/{variant_persister.js → variant_persister_service.js} +7 -1
- package/build/src/services/variant/{variant_purger.d.ts → variant_purger_service.d.ts} +7 -1
- package/build/src/services/variant/variant_purger_service.d.ts.map +1 -0
- package/build/src/services/variant/{variant_purger.js → variant_purger_service.js} +6 -0
- package/build/src/services/variant_service.d.ts +6 -0
- package/build/src/services/variant_service.d.ts.map +1 -1
- package/build/src/services/variant_service.js +13 -7
- package/build/src/types/index.d.ts +6 -0
- package/build/src/types/index.d.ts.map +1 -1
- package/build/src/types/index.js +6 -0
- package/build/src/types/lock.d.ts +14 -0
- package/build/src/types/lock.d.ts.map +1 -0
- package/build/src/types/lock.js +7 -0
- package/build/src/types/metadata.d.ts +6 -0
- package/build/src/types/metadata.d.ts.map +1 -1
- package/build/src/types/metadata.js +6 -0
- package/build/src/types/regenerate.d.ts +6 -0
- package/build/src/types/regenerate.d.ts.map +1 -1
- package/build/src/types/regenerate.js +6 -0
- package/build/src/types/service.d.ts +6 -0
- package/build/src/types/service.d.ts.map +1 -1
- package/build/src/types/service.js +6 -0
- package/build/src/utils/hooks.js +5 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -23
- package/build/src/services/record_with_attachment.d.ts +0 -33
- package/build/src/services/record_with_attachment.d.ts.map +0 -1
- package/build/src/services/record_with_attachment.js +0 -316
- package/build/src/services/variant/variant_generator.d.ts.map +0 -1
- package/build/src/services/variant/variant_persister.d.ts.map +0 -1
- package/build/src/services/variant/variant_purger.d.ts.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import attachmentManager from '../../../services/main.js';
|
|
8
|
+
export class AttachmentTransactionService {
|
|
9
|
+
/**
|
|
10
|
+
* During commit, we should cleanup the old detached files
|
|
11
|
+
*/
|
|
12
|
+
async commit(detachedAttachments) {
|
|
13
|
+
await Promise.allSettled(detachedAttachments.map((attachment) => attachmentManager.remove(attachment)));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* During rollback we should remove the attached files.
|
|
17
|
+
*/
|
|
18
|
+
async rollback(attachedAttachments) {
|
|
19
|
+
await Promise.allSettled(attachedAttachments.map((attachment) => attachmentManager.remove(attachment)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Handle transaction lifecycle with commit and rollback hooks
|
|
23
|
+
*/
|
|
24
|
+
async handleTransaction(record, options = { enabledRollback: true }) {
|
|
25
|
+
try {
|
|
26
|
+
if (record.row.$trx) {
|
|
27
|
+
record.row.$trx.after('commit', () => this.commit(record.row.$attachments.detached));
|
|
28
|
+
if (options.enabledRollback) {
|
|
29
|
+
record.row.$trx.after('rollback', () => this.rollback(record.row.$attachments.attached));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
await this.commit(record.row.$attachments.detached);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (options.enabledRollback) {
|
|
38
|
+
await this.rollback(record.row.$attachments.attached);
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { RowWithAttachment } from '../../types/mixin.js';
|
|
8
|
+
import type { Attachment as AttachmentType, LucidOptions } from '../../types/attachment.js';
|
|
9
|
+
export declare class AttachmentUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Get attachments by attribute name, handling both single and array values
|
|
12
|
+
*/
|
|
13
|
+
static getAttachmentsByAttributeName(row: RowWithAttachment, name: string): AttachmentType[];
|
|
14
|
+
/**
|
|
15
|
+
* Get original attachments by attribute name, handling both single and array values
|
|
16
|
+
*/
|
|
17
|
+
static getOriginalAttachmentsByAttributeName(row: RowWithAttachment, name: string): AttachmentType[];
|
|
18
|
+
/**
|
|
19
|
+
* Get dirty attachments by attribute name, handling both single and array values
|
|
20
|
+
*/
|
|
21
|
+
static getDirtyAttachmentsByAttributeName(row: RowWithAttachment, name: string): AttachmentType[];
|
|
22
|
+
/**
|
|
23
|
+
* Get options by attribute name from the model prototype
|
|
24
|
+
*/
|
|
25
|
+
static getOptionsByAttributeName(row: RowWithAttachment, name: string): LucidOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Get all attribute names that contain attachments
|
|
28
|
+
*/
|
|
29
|
+
static getAttributeNamesOfAttachment(row: RowWithAttachment): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Get dirty attribute names that contain attachments
|
|
32
|
+
*/
|
|
33
|
+
static getDirtyAttributeNamesOfAttachment(row: RowWithAttachment): string[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=attachment_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_utils.d.ts","sourceRoot":"","sources":["../../../../src/services/attachment/attachment_utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAI3F,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,6BAA6B,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE;IAO5F;;OAEG;IACH,MAAM,CAAC,qCAAqC,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE;IAOpG;;OAEG;IACH,MAAM,CAAC,kCAAkC,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE;IAOjG;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY;IAIpF;;OAEG;IACH,MAAM,CAAC,6BAA6B,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,EAAE;IAUtE;;OAEG;IACH,MAAM,CAAC,kCAAkC,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,EAAE;CAoB5E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { Attachment } from '../../attachments/attachment.js';
|
|
8
|
+
import { optionsSym } from '../../utils/symbols.js';
|
|
9
|
+
export class AttachmentUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Get attachments by attribute name, handling both single and array values
|
|
12
|
+
*/
|
|
13
|
+
static getAttachmentsByAttributeName(row, name) {
|
|
14
|
+
if (Array.isArray(row.$attributes[name])) {
|
|
15
|
+
return row.$attributes[name];
|
|
16
|
+
}
|
|
17
|
+
return [row.$attributes[name]];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get original attachments by attribute name, handling both single and array values
|
|
21
|
+
*/
|
|
22
|
+
static getOriginalAttachmentsByAttributeName(row, name) {
|
|
23
|
+
if (Array.isArray(row.$original[name])) {
|
|
24
|
+
return row.$original[name];
|
|
25
|
+
}
|
|
26
|
+
return [row.$original[name]];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get dirty attachments by attribute name, handling both single and array values
|
|
30
|
+
*/
|
|
31
|
+
static getDirtyAttachmentsByAttributeName(row, name) {
|
|
32
|
+
if (Array.isArray(row.$dirty[name])) {
|
|
33
|
+
return row.$dirty[name];
|
|
34
|
+
}
|
|
35
|
+
return [row.$dirty[name]];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get options by attribute name from the model prototype
|
|
39
|
+
*/
|
|
40
|
+
static getOptionsByAttributeName(row, name) {
|
|
41
|
+
return row.constructor.prototype[optionsSym]?.[name];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all attribute names that contain attachments
|
|
45
|
+
*/
|
|
46
|
+
static getAttributeNamesOfAttachment(row) {
|
|
47
|
+
return Object.keys(row.$attributes).filter((name) => {
|
|
48
|
+
const value = row.$attributes[name];
|
|
49
|
+
return (value instanceof Attachment ||
|
|
50
|
+
(Array.isArray(value) && value.every((item) => item instanceof Attachment)));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get dirty attribute names that contain attachments
|
|
55
|
+
*/
|
|
56
|
+
static getDirtyAttributeNamesOfAttachment(row) {
|
|
57
|
+
return Object.keys(row.$dirty).filter((name) => {
|
|
58
|
+
const dirtyValue = row.$dirty[name];
|
|
59
|
+
const originalValue = row.$original[name]; // if dirtyValue is null, check original type
|
|
60
|
+
const isDirtyAttachment = dirtyValue instanceof Attachment ||
|
|
61
|
+
(Array.isArray(dirtyValue) &&
|
|
62
|
+
dirtyValue.length &&
|
|
63
|
+
dirtyValue.every((item) => item instanceof Attachment));
|
|
64
|
+
const isOriginalAttachment = originalValue instanceof Attachment ||
|
|
65
|
+
(Array.isArray(originalValue) &&
|
|
66
|
+
originalValue.length &&
|
|
67
|
+
originalValue.every((item) => item instanceof Attachment));
|
|
68
|
+
return isDirtyAttachment || isOriginalAttachment;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RecordWithAttachment as RecordWithAttachmentImplementation } from '../../types/service.js';
|
|
2
|
+
import type { RegenerateOptions } from '../../types/regenerate.js';
|
|
3
|
+
export interface VariantOptions {
|
|
4
|
+
variants?: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare class AttachmentVariantService {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Generate variants for all dirty attachment attributes
|
|
10
|
+
*/
|
|
11
|
+
generateVariants(record: RecordWithAttachmentImplementation): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Regenerate variants with specific options
|
|
14
|
+
*/
|
|
15
|
+
regenerateVariants(record: RecordWithAttachmentImplementation, options?: RegenerateOptions): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=attachment_variant_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_variant_service.d.ts","sourceRoot":"","sources":["../../../../src/services/attachment/attachment_variant_service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,IAAI,kCAAkC,EAAE,MAAM,wBAAwB,CAAA;AACxG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAOlE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,qBAAa,wBAAwB;;IACnC;;OAEG;IACG,gBAAgB,CAAC,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC;IAajF;;OAEG;IACG,kBAAkB,CACtB,MAAM,EAAE,kCAAkC,EAC1C,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC;CAyDjB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import logger from '@adonisjs/core/services/logger';
|
|
2
|
+
import attachmentManager from '../../../services/main.js';
|
|
3
|
+
import VariantService from '../variant_service.js';
|
|
4
|
+
import { AttachmentUtils } from './attachment_utils.js';
|
|
5
|
+
import { E_CANNOT_CREATE_VARIANT } from '../../errors.js';
|
|
6
|
+
export class AttachmentVariantService {
|
|
7
|
+
/**
|
|
8
|
+
* Generate variants for all dirty attachment attributes
|
|
9
|
+
*/
|
|
10
|
+
async generateVariants(record) {
|
|
11
|
+
/* this.#row.$dirty is not available in afterSave hooks */
|
|
12
|
+
const attachmentAttributeNames = record.row.$attachments.dirtied;
|
|
13
|
+
for await (const name of attachmentAttributeNames) {
|
|
14
|
+
if (!record.row.$attributes[name]) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
this.#queueVariantGeneration(name, record, {});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Regenerate variants with specific options
|
|
22
|
+
*/
|
|
23
|
+
async regenerateVariants(record, options = {}) {
|
|
24
|
+
let attachmentAttributeNames;
|
|
25
|
+
if (options.attributes?.length) {
|
|
26
|
+
attachmentAttributeNames = options.attributes;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
attachmentAttributeNames = AttachmentUtils.getAttributeNamesOfAttachment(record.row);
|
|
30
|
+
}
|
|
31
|
+
for await (const name of attachmentAttributeNames) {
|
|
32
|
+
if (!record.row.$attributes[name]) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
this.#queueVariantGeneration(name, record, { variants: options.variants });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Queue variant generation with error handling
|
|
40
|
+
*/
|
|
41
|
+
#queueVariantGeneration(name, record, options) {
|
|
42
|
+
attachmentManager.queue.push({
|
|
43
|
+
name: `${record.row.constructor.name}-${name}`,
|
|
44
|
+
async run() {
|
|
45
|
+
const model = record.row.constructor;
|
|
46
|
+
await attachmentManager.lock.createLock(`attachment.${model.table}-${name}`).run(async () => {
|
|
47
|
+
const variantService = new VariantService({
|
|
48
|
+
record,
|
|
49
|
+
attributeName: name,
|
|
50
|
+
options: AttachmentUtils.getOptionsByAttributeName(record.row, name),
|
|
51
|
+
filters: {
|
|
52
|
+
variants: options.variants
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
await variantService.run();
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
.onError = (error) => this.#handleVariantError(error);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Handle variant generation errors
|
|
63
|
+
*/
|
|
64
|
+
#handleVariantError(error) {
|
|
65
|
+
if (error.message) {
|
|
66
|
+
logger.error(error.message);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new E_CANNOT_CREATE_VARIANT([error]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export { default as AttachmentRecordService } from './attachment_recorder_service.js';
|
|
8
|
+
export { AttachmentTransactionService } from './attachment_transaction_service.js';
|
|
9
|
+
export { AttachmentPersisterService } from './attachment_persister_service.js';
|
|
10
|
+
export { AttachmentVariantService } from './attachment_variant_service.js';
|
|
11
|
+
export { AttachmentDetachmentService } from './attachment_detachment_service.js';
|
|
12
|
+
export { AttachmentUtils } from './attachment_utils.js';
|
|
13
|
+
export type { TransactionOptions } from './attachment_transaction_service.js';
|
|
14
|
+
export type { VariantOptions } from './attachment_variant_service.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/attachment/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAGrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AAGhF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
// Main service
|
|
8
|
+
export { default as AttachmentRecordService } from './attachment_recorder_service.js';
|
|
9
|
+
// Specialized services
|
|
10
|
+
export { AttachmentTransactionService } from './attachment_transaction_service.js';
|
|
11
|
+
export { AttachmentPersisterService } from './attachment_persister_service.js';
|
|
12
|
+
export { AttachmentVariantService } from './attachment_variant_service.js';
|
|
13
|
+
export { AttachmentDetachmentService } from './attachment_detachment_service.js';
|
|
14
|
+
// Utilities
|
|
15
|
+
export { AttachmentUtils } from './attachment_utils.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_service.d.ts","sourceRoot":"","sources":["../../../src/services/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAA"}
|
package/build/src/services/variant/{variant_generator.d.ts → variant_generator_service.d.ts}
RENAMED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import type { Attachment, Variant, LucidOptions } from '../../types/attachment.js';
|
|
2
8
|
import type { Converter } from '../../types/converter.js';
|
|
3
|
-
export default class
|
|
9
|
+
export default class VariantGeneratorService {
|
|
4
10
|
#private;
|
|
5
11
|
generate({ attachments, options, filters }: {
|
|
6
12
|
attachments: Attachment[];
|
|
@@ -15,4 +21,4 @@ export default class VariantGenerator {
|
|
|
15
21
|
converter: Converter;
|
|
16
22
|
}): Promise<Variant | null>;
|
|
17
23
|
}
|
|
18
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=variant_generator_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant_generator_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_generator_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAOzD,MAAM,CAAC,OAAO,OAAO,uBAAuB;;IACpC,QAAQ,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAChD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,OAAO,EAAE,YAAY,CAAC;QACtB,OAAO,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAClC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhB,eAAe,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE;QACpD,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,SAAS,EAAE,SAAS,CAAA;KACrB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAkF5B"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import logger from '@adonisjs/core/services/logger';
|
|
2
8
|
import attachmentManager from '../../../services/main.js';
|
|
3
9
|
import { streamToTempFile } from '../../utils/helpers.js';
|
|
4
|
-
export default class
|
|
10
|
+
export default class VariantGeneratorService {
|
|
5
11
|
async generate({ attachments, options, filters }) {
|
|
6
12
|
const variants = [];
|
|
7
13
|
const variantKeys = this.#getVariantKeysToProcess(options, filters);
|
package/build/src/services/variant/{variant_persister.d.ts → variant_persister_service.d.ts}
RENAMED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import type { Attachment, Variant } from '../../types/attachment.js';
|
|
2
8
|
type PersistAttributes = {
|
|
3
9
|
id: string;
|
|
@@ -5,7 +11,7 @@ type PersistAttributes = {
|
|
|
5
11
|
attributeName: string;
|
|
6
12
|
multiple: boolean;
|
|
7
13
|
};
|
|
8
|
-
export default class
|
|
14
|
+
export default class VariantPersisterService {
|
|
9
15
|
#private;
|
|
10
16
|
constructor({ id, modelTable, attributeName, multiple }: PersistAttributes);
|
|
11
17
|
persist({ attachments, variants }: {
|
|
@@ -14,4 +20,4 @@ export default class VariantPersister {
|
|
|
14
20
|
}): Promise<void>;
|
|
15
21
|
}
|
|
16
22
|
export {};
|
|
17
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=variant_persister_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant_persister_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_persister_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAOpE,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,uBAAuB;;gBAM9B,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,iBAAiB;IAOpE,OAAO,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE;QACvC,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,QAAQ,EAAE,OAAO,EAAE,CAAA;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2ClB"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import logger from '@adonisjs/core/services/logger';
|
|
2
8
|
import string from '@adonisjs/core/helpers/string';
|
|
3
9
|
import db from '@adonisjs/lucid/services/db';
|
|
4
10
|
import attachmentManager from '../../../services/main.js';
|
|
5
|
-
export default class
|
|
11
|
+
export default class VariantPersisterService {
|
|
6
12
|
#id;
|
|
7
13
|
#modelTable;
|
|
8
14
|
#attributeName;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import type { Attachment } from '../../types/attachment.js';
|
|
2
8
|
export default class VariantPurger {
|
|
3
9
|
#private;
|
|
@@ -6,4 +12,4 @@ export default class VariantPurger {
|
|
|
6
12
|
});
|
|
7
13
|
purge(attachments: Attachment[]): Promise<void>;
|
|
8
14
|
}
|
|
9
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=variant_purger_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant_purger_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_purger_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAW,MAAM,2BAA2B,CAAA;AAIpE,MAAM,CAAC,OAAO,OAAO,aAAa;;gBAGpB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;IAIvC,KAAK,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA6CtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant_service.d.ts","sourceRoot":"","sources":["../../../src/services/variant_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"variant_service.d.ts","sourceRoot":"","sources":["../../../src/services/variant_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAO1E,MAAM,CAAC,OAAO,OAAO,cAAc;;gBASrB,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,6BAA6B;IAgBhF,GAAG;CA6BV"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import logger from '@adonisjs/core/services/logger';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
8
|
+
import VariantGeneratorService from './variant/variant_generator_service.js';
|
|
9
|
+
import VariantPurgerService from './variant/variant_purger_service.js';
|
|
10
|
+
import VariantPersisterService from './variant/variant_persister_service.js';
|
|
5
11
|
export default class VariantService {
|
|
6
12
|
#record;
|
|
7
13
|
#attributeName;
|
|
@@ -15,9 +21,9 @@ export default class VariantService {
|
|
|
15
21
|
this.#attributeName = attributeName;
|
|
16
22
|
this.#options = options;
|
|
17
23
|
this.#filters = filters;
|
|
18
|
-
this.#variantGenerator = new
|
|
19
|
-
this.#variantPurger = new
|
|
20
|
-
this.#variantPersister = new
|
|
24
|
+
this.#variantGenerator = new VariantGeneratorService();
|
|
25
|
+
this.#variantPurger = new VariantPurgerService(filters);
|
|
26
|
+
this.#variantPersister = new VariantPersisterService({
|
|
21
27
|
id: record.row.$attributes['id'],
|
|
22
28
|
modelTable: record.row.constructor.table,
|
|
23
29
|
attributeName,
|
|
@@ -41,7 +47,7 @@ export default class VariantService {
|
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
async #getAttachments() {
|
|
44
|
-
await this.#record.row.refresh()
|
|
50
|
+
// await this.#record.row.refresh()
|
|
45
51
|
return this.#record.getAttachments({
|
|
46
52
|
attributeName: this.#attributeName,
|
|
47
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
|
package/build/src/types/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Verrou } from '@verrou/core';
|
|
8
|
+
import type { StoreFactory } from '@verrou/core/types';
|
|
9
|
+
interface LockStoresList {
|
|
10
|
+
}
|
|
11
|
+
export interface LockService extends Verrou<LockStoresList extends Record<string, StoreFactory> ? LockStoresList : never> {
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../../src/types/lock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,UAAU,cAAc;CAAG;AAE3B,MAAM,WAAW,WACf,SAAQ,MAAM,CAAC,cAAc,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,cAAc,GAAG,KAAK,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/types/metadata.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/types/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regenerate.d.ts","sourceRoot":"","sources":["../../../src/types/regenerate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,kBAAkB,CAAC,EAAE,CAAA;CACxC,CAAA"}
|
|
1
|
+
{"version":3,"file":"regenerate.d.ts","sourceRoot":"","sources":["../../../src/types/regenerate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,kBAAkB,CAAC,EAAE,CAAA;CACxC,CAAA"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import type { Attachment } from './attachment.js';
|
|
2
8
|
import type { RowWithAttachment } from './mixin.js';
|
|
3
9
|
export interface RecordWithAttachment {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/types/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,iBAAiB,CAAA;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,cAAc,CAAC,OAAO,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,EAAE,CAAA;CACtH"}
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/types/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,iBAAiB,CAAA;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,cAAc,CAAC,OAAO,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,EAAE,CAAA;CACtH"}
|