nextjs-cms 0.5.82 → 0.5.83

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.
@@ -82,6 +82,7 @@ export declare class DocumentField extends FileField<'document', Config> {
82
82
  writeToFile(): Promise<void>;
83
83
  postSubmit(folder: string): Promise<void>;
84
84
  postSubmitRollback(): Promise<void>;
85
+ cleanupReplacedFile(previousValue: string, sectionName: string): Promise<void>;
85
86
  /**
86
87
  * Get the value of the field
87
88
  */
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/core/fields/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAQ1C,QAAA,MAAM,YAAY;IACd;;;;;;;OAOG;;;;;;;;IAEH;;;;;OAKG;;;;;;;;;;;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,aAAc,SAAQ,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5D,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAkB;IAC/D,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAA;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;IAE7B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAqE;IAE1G;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,C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
159
159
  }
160
+ async cleanupReplacedFile(previousValue, sectionName) {
161
+ if (!previousValue)
162
+ return;
163
+ const uploadsFolder = (await getCMSConfig()).media.upload.path;
164
+ await fs.promises.unlink(path.join(uploadsFolder, '.documents', sectionName, previousValue));
165
+ }
160
166
  /**
161
167
  * Get the value of the field
162
168
  */
@@ -10,6 +10,7 @@ export declare abstract class FileField<TType extends FileType = FileType, TExtr
10
10
  abstract writeToFile(): Promise<void>;
11
11
  abstract setFileName(value: string): void;
12
12
  abstract setFile(file: File): void;
13
+ abstract cleanupReplacedFile(previousValue: string, sectionName: string): Promise<void>;
13
14
  }
14
15
  export {};
15
16
  //# sourceMappingURL=fileField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileField.d.ts","sourceRoot":"","sources":["../../../src/core/fields/fileField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAA;AAC9C,8BAAsB,SAAS,CAC3B,KAAK,SAAS,QAAQ,GAAG,QAAQ,EACjC,iBAAiB,SAAS,MAAM,GAAG,MAAM,CAC3C,SAAQ,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC;IACrC,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAc;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IACzC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CACrC"}
1
+ {"version":3,"file":"fileField.d.ts","sourceRoot":"","sources":["../../../src/core/fields/fileField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAA;AAC9C,8BAAsB,SAAS,CAC3B,KAAK,SAAS,QAAQ,GAAG,QAAQ,EACjC,iBAAiB,SAAS,MAAM,GAAG,MAAM,CAC3C,SAAQ,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC;IACrC,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAc;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IACzC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAClC,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC1F"}
@@ -54,10 +54,10 @@ declare const configSchema: z.ZodObject<{
54
54
  * @hint 'jpg' is an alias for 'jpeg'
55
55
  */
56
56
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
57
- webp: "webp";
58
- jpg: "jpg";
59
57
  jpeg: "jpeg";
58
+ jpg: "jpg";
60
59
  png: "png";
60
+ webp: "webp";
61
61
  }>>>;
62
62
  /**
63
63
  * Remove the extension from the file name
@@ -134,6 +134,7 @@ export declare class PhotoField extends FileField<'photo', Config> {
134
134
  writeToFile(): Promise<void>;
135
135
  postSubmit(folder: string): Promise<void>;
136
136
  postSubmitRollback(): Promise<void>;
137
+ cleanupReplacedFile(previousValue: string, sectionName: string): Promise<void>;
137
138
  /**
138
139
  * Get the value of the field
139
140
  */
@@ -200,10 +201,10 @@ declare const optionsSchema: z.ZodObject<{
200
201
  * @hint 'jpg' is an alias for 'jpeg'
201
202
  */
202
203
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
203
- webp: "webp";
204
- jpg: "jpg";
205
204
  jpeg: "jpeg";
205
+ jpg: "jpg";
206
206
  png: "png";
207
+ webp: "webp";
207
208
  }>>>;
208
209
  /**
209
210
  * Remove the extension from the file name
@@ -272,10 +273,10 @@ declare const photoFieldConfigSchema: z.ZodObject<{
272
273
  * @hint 'jpg' is an alias for 'jpeg'
273
274
  */
274
275
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
275
- webp: "webp";
276
- jpg: "jpg";
277
276
  jpeg: "jpeg";
277
+ jpg: "jpg";
278
278
  png: "png";
279
+ webp: "webp";
279
280
  }>>>;
280
281
  /**
281
282
  * Remove the extension from the file name
@@ -1 +1 @@
1
- {"version":3,"file":"photo.d.ts","sourceRoot":"","sources":["../../../src/core/fields/photo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAmC1C,QAAA,MAAM,YAAY;IACd,yCAAyC;;;;;;QA7BzC;;;;;;;;;;;;WAYG;;;;;;;;;IAsBH;;;;;;;OAOG;;;;;;;;IAEH;;;;;;;OAOG;;;;;;;IAEH;;;OAGG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,UAAW,SAAQ,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IACtD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAe;IAC5D,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;IAC9C,QAAQ,CAAC,eAAe,EAAE,OAAO,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M,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBnC,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpG;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIX,WAAW,CAAC,KAAK,EAAE,MAAM;IAIvB,QAAQ,CAAC,KAAK,EAAE,GAAG;IAQ5B,OAAO,CAAC,IAAI,EAAE,IAAI;IAKlB,aAAa;IAab;;OAEG;IACG,oBAAoB;CAqJ7B;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE9E,QAAA,MAAM,aAAa;IAnaf,yCAAyC;;;;;;QA7BzC;;;;;;;;;;;;WAYG;;;;;;;;;IAsBH;;;;;;;OAOG;;;;;;;;IAEH;;;;;;;OAOG;;;;;;;IAEH;;;OAGG;;;;;;;;;kBA4YL,CAAA;AAEF,QAAA,MAAM,sBAAsB;;;IAxaxB,yCAAyC;;;;;;QA7BzC;;;;;;;;;;;;WAYG;;;;;;;;;IAsBH;;;;;;;OAOG;;;;;;;;IAEH;;;;;;;OAOG;;;;;;;IAEH;;;OAGG;;;;;;;;;kBAkZL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,gBAAgB,CAmBjF"}
@@ -241,6 +241,13 @@ export class PhotoField extends FileField {
241
241
  throw new Error(`${this.label}: Error deleting file from disk`);
242
242
  }
243
243
  }
244
+ async cleanupReplacedFile(previousValue, sectionName) {
245
+ if (!previousValue)
246
+ return;
247
+ const uploadsFolder = (await getCMSConfig()).media.upload.path;
248
+ await fs.promises.unlink(path.join(uploadsFolder, '.photos', sectionName, previousValue));
249
+ await fs.promises.unlink(path.join(uploadsFolder, '.thumbs', sectionName, previousValue));
250
+ }
244
251
  /**
245
252
  * Get the value of the field
246
253
  */
@@ -31,10 +31,10 @@ declare const allowImageUploadsSchema: z.ZodObject<{
31
31
  */
32
32
  omitExtension: z.ZodOptional<z.ZodBoolean>;
33
33
  format: z.ZodOptional<z.ZodEnum<{
34
- webp: "webp";
35
- jpg: "jpg";
36
34
  jpeg: "jpeg";
35
+ jpg: "jpg";
37
36
  png: "png";
37
+ webp: "webp";
38
38
  }>>;
39
39
  }, z.core.$strict>;
40
40
  declare const configSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -72,10 +72,10 @@ declare const configSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
72
72
  */
73
73
  omitExtension: z.ZodOptional<z.ZodBoolean>;
74
74
  format: z.ZodOptional<z.ZodEnum<{
75
- webp: "webp";
76
- jpg: "jpg";
77
75
  jpeg: "jpeg";
76
+ jpg: "jpg";
78
77
  png: "png";
78
+ webp: "webp";
79
79
  }>>;
80
80
  }, z.core.$strict>>;
81
81
  }, z.core.$strict>, z.ZodObject<{
@@ -118,7 +118,7 @@ export declare class RichTextField extends Field<'rich_text', Config> {
118
118
  } | undefined;
119
119
  handleMethod?: "base64" | "tempSave" | undefined;
120
120
  omitExtension?: boolean | undefined;
121
- format?: "webp" | "jpg" | "jpeg" | "png" | undefined;
121
+ format?: "jpeg" | "jpg" | "png" | "webp" | undefined;
122
122
  };
123
123
  sanitize: boolean;
124
124
  type: "rich_text";
@@ -186,10 +186,10 @@ declare const optionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
186
186
  */
187
187
  omitExtension: z.ZodOptional<z.ZodBoolean>;
188
188
  format: z.ZodOptional<z.ZodEnum<{
189
- webp: "webp";
190
- jpg: "jpg";
191
189
  jpeg: "jpeg";
190
+ jpg: "jpg";
192
191
  png: "png";
192
+ webp: "webp";
193
193
  }>>;
194
194
  }, z.core.$strict>>;
195
195
  name: z.ZodString;
@@ -248,10 +248,10 @@ declare const richTextFieldConfigSchema: z.ZodIntersection<z.ZodDiscriminatedUni
248
248
  */
249
249
  omitExtension: z.ZodOptional<z.ZodBoolean>;
250
250
  format: z.ZodOptional<z.ZodEnum<{
251
- webp: "webp";
252
- jpg: "jpg";
253
251
  jpeg: "jpeg";
252
+ jpg: "jpg";
254
253
  png: "png";
254
+ webp: "webp";
255
255
  }>>;
256
256
  }, z.core.$strict>>;
257
257
  name: z.ZodString;
@@ -68,6 +68,7 @@ export declare class VideoField extends FileField<'video', Config> {
68
68
  writeToFile(): Promise<void>;
69
69
  postSubmit(folder: string): Promise<void>;
70
70
  postSubmitRollback(): Promise<void>;
71
+ cleanupReplacedFile(previousValue: string, sectionName: string): Promise<void>;
71
72
  /**
72
73
  * Get the value of the field
73
74
  */
@@ -1 +1 @@
1
- {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/core/fields/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAIhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,YAAY;IACd;;OAEG;;;;;;;;IAQH;;;OAGG;;;;;;kBAKL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,UAAW,SAAQ,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IACtD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAe;IAC5D,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAA;IACzD,QAAQ,CAAC,QA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file from disk`);
131
131
  }
132
132
  }
133
+ async cleanupReplacedFile(previousValue, sectionName) {
134
+ if (!previousValue)
135
+ return;
136
+ const uploadsFolder = (await getCMSConfig()).media.upload.path;
137
+ await fs.promises.unlink(path.join(uploadsFolder, '.videos', sectionName, previousValue));
138
+ }
133
139
  /**
134
140
  * Get the value of the field
135
141
  */
@@ -117,9 +117,9 @@ declare const optionsSchema: z.ZodObject<{
117
117
  */
118
118
  allowRecursiveDelete: z.ZodOptional<z.ZodBoolean>;
119
119
  fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
120
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
120
121
  name: z.ZodString;
121
122
  order: z.ZodNumber;
122
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
123
123
  db: z.ZodObject<{
124
124
  table: z.ZodString;
125
125
  identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
@@ -143,6 +143,7 @@ declare const optionsSchema: z.ZodObject<{
143
143
  name: z.ZodOptional<z.ZodString>;
144
144
  }, z.core.$strict>>>;
145
145
  }, z.core.$strict>;
146
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
146
147
  icon: z.ZodOptional<z.ZodString>;
147
148
  gallery: z.ZodOptional<z.ZodObject<{
148
149
  db: z.ZodObject<{
@@ -159,7 +160,6 @@ declare const optionsSchema: z.ZodObject<{
159
160
  quality: z.ZodNumber;
160
161
  }, z.core.$strict>>;
161
162
  }, z.core.$strict>>;
162
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
163
163
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
164
164
  }, z.core.$strict>;
165
165
  export declare const categorySectionConfigSchema: z.ZodObject<{
@@ -214,9 +214,9 @@ export declare const categorySectionConfigSchema: z.ZodObject<{
214
214
  * @default false
215
215
  */
216
216
  allowRecursiveDelete: z.ZodOptional<z.ZodBoolean>;
217
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
217
218
  name: z.ZodString;
218
219
  order: z.ZodNumber;
219
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
220
220
  db: z.ZodObject<{
221
221
  table: z.ZodString;
222
222
  identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
@@ -240,6 +240,7 @@ export declare const categorySectionConfigSchema: z.ZodObject<{
240
240
  name: z.ZodOptional<z.ZodString>;
241
241
  }, z.core.$strict>>>;
242
242
  }, z.core.$strict>;
243
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
243
244
  icon: z.ZodOptional<z.ZodString>;
244
245
  gallery: z.ZodOptional<z.ZodObject<{
245
246
  db: z.ZodObject<{
@@ -256,7 +257,6 @@ export declare const categorySectionConfigSchema: z.ZodObject<{
256
257
  quality: z.ZodNumber;
257
258
  }, z.core.$strict>>;
258
259
  }, z.core.$strict>>;
259
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
260
260
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
261
261
  }, z.core.$strict>;
262
262
  export type CategorySectionOptions = z.infer<typeof optionsSchema>;
@@ -6,21 +6,7 @@ import { Section } from './section.js';
6
6
  import type { FieldConfig } from '../fields/index.js';
7
7
  import * as z from 'zod';
8
8
  declare const configSchema: z.ZodObject<{
9
- headingField: z.ZodCustom<{
10
- type: "text";
11
- build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
12
- name: string;
13
- placeholder?: string | undefined;
14
- minLength?: number | undefined;
15
- maxLength?: number | undefined;
16
- defaultValue?: string | undefined;
17
- sanitize?: boolean | undefined;
18
- label?: string | undefined;
19
- required?: boolean | undefined;
20
- order?: number | undefined;
21
- conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
22
- adminGenerated?: boolean | "readonly" | undefined;
23
- } | (({
9
+ headingField: z.ZodCustom<(({
24
10
  hasAutoIncrement: true;
25
11
  name: string;
26
12
  format?: "int" | undefined;
@@ -53,7 +39,7 @@ declare const configSchema: z.ZodObject<{
53
39
  }) & {
54
40
  type: "number";
55
41
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
56
- }), {
42
+ }) | {
57
43
  type: "text";
58
44
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
59
45
  name: string;
@@ -67,7 +53,7 @@ declare const configSchema: z.ZodObject<{
67
53
  order?: number | undefined;
68
54
  conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
69
55
  adminGenerated?: boolean | "readonly" | undefined;
70
- } | (({
56
+ }, (({
71
57
  hasAutoIncrement: true;
72
58
  name: string;
73
59
  format?: "int" | undefined;
@@ -100,7 +86,21 @@ declare const configSchema: z.ZodObject<{
100
86
  }) & {
101
87
  type: "number";
102
88
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
103
- })>;
89
+ }) | {
90
+ type: "text";
91
+ build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
92
+ name: string;
93
+ placeholder?: string | undefined;
94
+ minLength?: number | undefined;
95
+ maxLength?: number | undefined;
96
+ defaultValue?: string | undefined;
97
+ sanitize?: boolean | undefined;
98
+ label?: string | undefined;
99
+ required?: boolean | undefined;
100
+ order?: number | undefined;
101
+ conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
102
+ adminGenerated?: boolean | "readonly" | undefined;
103
+ }>;
104
104
  title: z.ZodObject<{
105
105
  section: z.ZodString;
106
106
  singular: z.ZodString;
@@ -134,7 +134,7 @@ declare const configSchema: z.ZodObject<{
134
134
  size: number;
135
135
  unit: "kb" | "mb";
136
136
  } | undefined;
137
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
137
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
138
138
  removeExtension?: boolean | undefined;
139
139
  label?: string | undefined;
140
140
  required?: boolean | undefined;
@@ -163,7 +163,7 @@ declare const configSchema: z.ZodObject<{
163
163
  size: number;
164
164
  unit: "kb" | "mb";
165
165
  } | undefined;
166
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
166
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
167
167
  removeExtension?: boolean | undefined;
168
168
  label?: string | undefined;
169
169
  required?: boolean | undefined;
@@ -200,21 +200,7 @@ export declare class HasItemsSection extends Section<Config> {
200
200
  constructor(config: BaseSectionOptions<Config>);
201
201
  }
202
202
  declare const optionsSchema: z.ZodObject<{
203
- headingField: z.ZodCustom<{
204
- type: "text";
205
- build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
206
- name: string;
207
- placeholder?: string | undefined;
208
- minLength?: number | undefined;
209
- maxLength?: number | undefined;
210
- defaultValue?: string | undefined;
211
- sanitize?: boolean | undefined;
212
- label?: string | undefined;
213
- required?: boolean | undefined;
214
- order?: number | undefined;
215
- conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
216
- adminGenerated?: boolean | "readonly" | undefined;
217
- } | (({
203
+ headingField: z.ZodCustom<(({
218
204
  hasAutoIncrement: true;
219
205
  name: string;
220
206
  format?: "int" | undefined;
@@ -247,7 +233,7 @@ declare const optionsSchema: z.ZodObject<{
247
233
  }) & {
248
234
  type: "number";
249
235
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
250
- }), {
236
+ }) | {
251
237
  type: "text";
252
238
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
253
239
  name: string;
@@ -261,7 +247,7 @@ declare const optionsSchema: z.ZodObject<{
261
247
  order?: number | undefined;
262
248
  conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
263
249
  adminGenerated?: boolean | "readonly" | undefined;
264
- } | (({
250
+ }, (({
265
251
  hasAutoIncrement: true;
266
252
  name: string;
267
253
  format?: "int" | undefined;
@@ -294,7 +280,21 @@ declare const optionsSchema: z.ZodObject<{
294
280
  }) & {
295
281
  type: "number";
296
282
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
297
- })>;
283
+ }) | {
284
+ type: "text";
285
+ build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
286
+ name: string;
287
+ placeholder?: string | undefined;
288
+ minLength?: number | undefined;
289
+ maxLength?: number | undefined;
290
+ defaultValue?: string | undefined;
291
+ sanitize?: boolean | undefined;
292
+ label?: string | undefined;
293
+ required?: boolean | undefined;
294
+ order?: number | undefined;
295
+ conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
296
+ adminGenerated?: boolean | "readonly" | undefined;
297
+ }>;
298
298
  title: z.ZodObject<{
299
299
  section: z.ZodString;
300
300
  singular: z.ZodString;
@@ -328,7 +328,7 @@ declare const optionsSchema: z.ZodObject<{
328
328
  size: number;
329
329
  unit: "kb" | "mb";
330
330
  } | undefined;
331
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
331
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
332
332
  removeExtension?: boolean | undefined;
333
333
  label?: string | undefined;
334
334
  required?: boolean | undefined;
@@ -357,7 +357,7 @@ declare const optionsSchema: z.ZodObject<{
357
357
  size: number;
358
358
  unit: "kb" | "mb";
359
359
  } | undefined;
360
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
360
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
361
361
  removeExtension?: boolean | undefined;
362
362
  label?: string | undefined;
363
363
  required?: boolean | undefined;
@@ -368,9 +368,9 @@ declare const optionsSchema: z.ZodObject<{
368
368
  }>>;
369
369
  generateQR: z.ZodOptional<z.ZodBoolean>;
370
370
  fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
371
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
371
372
  name: z.ZodString;
372
373
  order: z.ZodNumber;
373
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
374
374
  db: z.ZodObject<{
375
375
  table: z.ZodString;
376
376
  identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
@@ -394,6 +394,7 @@ declare const optionsSchema: z.ZodObject<{
394
394
  name: z.ZodOptional<z.ZodString>;
395
395
  }, z.core.$strict>>>;
396
396
  }, z.core.$strict>;
397
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
397
398
  icon: z.ZodOptional<z.ZodString>;
398
399
  gallery: z.ZodOptional<z.ZodObject<{
399
400
  db: z.ZodObject<{
@@ -410,7 +411,6 @@ declare const optionsSchema: z.ZodObject<{
410
411
  quality: z.ZodNumber;
411
412
  }, z.core.$strict>>;
412
413
  }, z.core.$strict>>;
413
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
414
414
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
415
415
  }, z.core.$strict>;
416
416
  declare const hasItemsSectionConfigSchema: z.ZodObject<{
@@ -418,21 +418,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
418
418
  fields: z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>;
419
419
  build: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodCustom<HasItemsSection, HasItemsSection>>;
420
420
  fieldGroups: z.ZodOptional<z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>>;
421
- headingField: z.ZodCustom<{
422
- type: "text";
423
- build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
424
- name: string;
425
- placeholder?: string | undefined;
426
- minLength?: number | undefined;
427
- maxLength?: number | undefined;
428
- defaultValue?: string | undefined;
429
- sanitize?: boolean | undefined;
430
- label?: string | undefined;
431
- required?: boolean | undefined;
432
- order?: number | undefined;
433
- conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
434
- adminGenerated?: boolean | "readonly" | undefined;
435
- } | (({
421
+ headingField: z.ZodCustom<(({
436
422
  hasAutoIncrement: true;
437
423
  name: string;
438
424
  format?: "int" | undefined;
@@ -465,7 +451,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
465
451
  }) & {
466
452
  type: "number";
467
453
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
468
- }), {
454
+ }) | {
469
455
  type: "text";
470
456
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
471
457
  name: string;
@@ -479,7 +465,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
479
465
  order?: number | undefined;
480
466
  conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
481
467
  adminGenerated?: boolean | "readonly" | undefined;
482
- } | (({
468
+ }, (({
483
469
  hasAutoIncrement: true;
484
470
  name: string;
485
471
  format?: "int" | undefined;
@@ -512,7 +498,21 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
512
498
  }) & {
513
499
  type: "number";
514
500
  build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").NumberField, import("../index.js").NumberField>>;
515
- })>;
501
+ }) | {
502
+ type: "text";
503
+ build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").TextField, import("../index.js").TextField>>;
504
+ name: string;
505
+ placeholder?: string | undefined;
506
+ minLength?: number | undefined;
507
+ maxLength?: number | undefined;
508
+ defaultValue?: string | undefined;
509
+ sanitize?: boolean | undefined;
510
+ label?: string | undefined;
511
+ required?: boolean | undefined;
512
+ order?: number | undefined;
513
+ conditionalRules?: import("../types/index.js").ConditionalRule[] | undefined;
514
+ adminGenerated?: boolean | "readonly" | undefined;
515
+ }>;
516
516
  title: z.ZodObject<{
517
517
  section: z.ZodString;
518
518
  singular: z.ZodString;
@@ -546,7 +546,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
546
546
  size: number;
547
547
  unit: "kb" | "mb";
548
548
  } | undefined;
549
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
549
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
550
550
  removeExtension?: boolean | undefined;
551
551
  label?: string | undefined;
552
552
  required?: boolean | undefined;
@@ -575,7 +575,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
575
575
  size: number;
576
576
  unit: "kb" | "mb";
577
577
  } | undefined;
578
- fileType?: ("webp" | "jpg" | "jpeg" | "png")[] | undefined;
578
+ fileType?: ("jpeg" | "jpg" | "png" | "webp")[] | undefined;
579
579
  removeExtension?: boolean | undefined;
580
580
  label?: string | undefined;
581
581
  required?: boolean | undefined;
@@ -585,9 +585,9 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
585
585
  adminGenerated?: boolean | "readonly" | undefined;
586
586
  }>>;
587
587
  generateQR: z.ZodOptional<z.ZodBoolean>;
588
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
588
589
  name: z.ZodString;
589
590
  order: z.ZodNumber;
590
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
591
591
  db: z.ZodObject<{
592
592
  table: z.ZodString;
593
593
  identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
@@ -611,6 +611,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
611
611
  name: z.ZodOptional<z.ZodString>;
612
612
  }, z.core.$strict>>>;
613
613
  }, z.core.$strict>;
614
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
614
615
  icon: z.ZodOptional<z.ZodString>;
615
616
  gallery: z.ZodOptional<z.ZodObject<{
616
617
  db: z.ZodObject<{
@@ -627,7 +628,6 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
627
628
  quality: z.ZodNumber;
628
629
  }, z.core.$strict>>;
629
630
  }, z.core.$strict>>;
630
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
631
631
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
632
632
  }, z.core.$strict>;
633
633
  export type HasItemsSectionOptions = z.infer<typeof optionsSchema>;
@@ -62,9 +62,9 @@ export declare const baseSectionOptionsSchema: z.ZodObject<{
62
62
  */
63
63
  export declare const baseHelperFunctionOptionsSchema: z.ZodObject<{
64
64
  fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
65
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
65
66
  name: z.ZodString;
66
67
  order: z.ZodNumber;
67
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
68
68
  db: z.ZodObject<{
69
69
  table: z.ZodString;
70
70
  identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
@@ -88,6 +88,7 @@ export declare const baseHelperFunctionOptionsSchema: z.ZodObject<{
88
88
  name: z.ZodOptional<z.ZodString>;
89
89
  }, z.core.$strict>>>;
90
90
  }, z.core.$strict>;
91
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<Variant, Variant>>>;
91
92
  icon: z.ZodOptional<z.ZodString>;
92
93
  gallery: z.ZodOptional<z.ZodObject<{
93
94
  db: z.ZodObject<{
@@ -104,7 +105,6 @@ export declare const baseHelperFunctionOptionsSchema: z.ZodObject<{
104
105
  quality: z.ZodNumber;
105
106
  }, z.core.$strict>>;
106
107
  }, z.core.$strict>>;
107
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<Variant, Variant>>>;
108
108
  hooks: z.ZodOptional<z.ZodCustom<Hooks, Hooks>>;
109
109
  }, z.core.$strict>;
110
110
  export declare function validateSectionConfig(config: BaseSectionOptions): void;
@@ -22,9 +22,10 @@ declare const optionsSchema: z.ZodObject<{
22
22
  table: z.ZodString;
23
23
  }, z.core.$strict>;
24
24
  fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
25
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
25
26
  name: z.ZodString;
26
27
  order: z.ZodNumber;
27
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
28
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
28
29
  icon: z.ZodOptional<z.ZodString>;
29
30
  gallery: z.ZodOptional<z.ZodObject<{
30
31
  db: z.ZodObject<{
@@ -41,7 +42,6 @@ declare const optionsSchema: z.ZodObject<{
41
42
  quality: z.ZodNumber;
42
43
  }, z.core.$strict>>;
43
44
  }, z.core.$strict>>;
44
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
45
45
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
46
46
  }, z.core.$strict>;
47
47
  declare const simpleSectionConfigSchema: z.ZodObject<{
@@ -53,9 +53,10 @@ declare const simpleSectionConfigSchema: z.ZodObject<{
53
53
  db: z.ZodObject<{
54
54
  table: z.ZodString;
55
55
  }, z.core.$strict>;
56
+ readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
56
57
  name: z.ZodString;
57
58
  order: z.ZodNumber;
58
- readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
59
+ variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
59
60
  icon: z.ZodOptional<z.ZodString>;
60
61
  gallery: z.ZodOptional<z.ZodObject<{
61
62
  db: z.ZodObject<{
@@ -72,7 +73,6 @@ declare const simpleSectionConfigSchema: z.ZodObject<{
72
73
  quality: z.ZodNumber;
73
74
  }, z.core.$strict>>;
74
75
  }, z.core.$strict>>;
75
- variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
76
76
  hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
77
77
  }, z.core.$strict>;
78
78
  export type SimpleSectionOptions = z.infer<typeof optionsSchema>;
@@ -23,6 +23,7 @@ export declare class EditSubmit extends Submit {
23
23
  * @override
24
24
  */
25
25
  initialize(): Promise<void>;
26
+ submit(): Promise<true | undefined>;
26
27
  private initializeFieldValues;
27
28
  /**
28
29
  * Gets the field values from the associated table declared in the section info
@@ -44,6 +45,7 @@ export declare class EditSubmit extends Submit {
44
45
  * @override
45
46
  */
46
47
  protected submitRollback(): Promise<void>;
48
+ private cleanupReplacedFiles;
47
49
  /**
48
50
  * Build the sql query
49
51
  * @override
@@ -1 +1 @@
1
- {"version":3,"file":"ItemEditSubmit.d.ts","sourceRoot":"","sources":["../../../src/core/submit/ItemEditSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAItC,OAAO,KAAK,EAAuB,KAAK,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,UAAU,EAAM,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,UAAW,SAAQ,MAAM;IAClC,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAe;IAC5D,mBAA4B,OAAO,EAAE,MAAM,CAAA;IAC3C,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAK;IAE3C;;OAEG;gBACS,MAAM,EAAE,eAAe;IAKnC;;;OAGG;IACmB,UAAU;YASlB,qBAAqB;IAuBnC;;;OAGG;YACW,aAAa;YAQb,sBAAsB;IAoBpC;;;;;OAKG;cACsB,kBAAkB;IAI3C;;;;;OAKG;cACsB,cAAc;IAUvC;;;OAGG;cACgB,aAAa,IAAI,GAAG,GAAG,SAAS;IAmBnD;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;IAmBnC;;;;OAIG;IACY,WAAW,CAAC,KAAK,EAAE,KAAK;IAQvC;;OAEG;IACM,iBAAiB;IAI1B;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;CAgBtC"}
1
+ {"version":3,"file":"ItemEditSubmit.d.ts","sourceRoot":"","sources":["../../../src/core/submit/ItemEditSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAItC,OAAO,KAAK,EAAuB,KAAK,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,UAAU,EAAM,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,UAAW,SAAQ,MAAM;IAClC,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAe;IAC5D,mBAA4B,OAAO,EAAE,MAAM,CAAA;IAC3C,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAK;IAE3C;;OAEG;gBACS,MAAM,EAAE,eAAe;IAKnC;;;OAGG;IACmB,UAAU;IASV,MAAM;YAQd,qBAAqB;IAuBnC;;;OAGG;YACW,aAAa;YAQb,sBAAsB;IAoBpC;;;;;OAKG;cACsB,kBAAkB;IAI3C;;;;;OAKG;cACsB,cAAc;YAUzB,oBAAoB;IAoBlC;;;OAGG;cACgB,aAAa,IAAI,GAAG,GAAG,SAAS;IAmBnD;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;IAmBnC;;;;OAIG;IACY,WAAW,CAAC,KAAK,EAAE,KAAK;IAQvC;;OAEG;IACM,iBAAiB;IAI1B;;;;OAIG;IACM,aAAa,CAAC,KAAK,EAAE,KAAK;CAgBtC"}
@@ -25,6 +25,13 @@ export class EditSubmit extends Submit {
25
25
  */
26
26
  await this.initializeFieldValues();
27
27
  }
28
+ async submit() {
29
+ const result = await super.submit();
30
+ if (!this._error && !this.preSubmit) {
31
+ await this.cleanupReplacedFiles();
32
+ }
33
+ return result;
34
+ }
28
35
  async initializeFieldValues() {
29
36
  if (this._error)
30
37
  return;
@@ -94,6 +101,26 @@ export class EditSubmit extends Submit {
94
101
  * and updating the table with the original values
95
102
  */
96
103
  }
104
+ async cleanupReplacedFiles() {
105
+ if (!this._sectionInfo || !this._values)
106
+ return;
107
+ for (const field of this._sectionInfo.fields ?? []) {
108
+ if (!is(field, FileField))
109
+ continue;
110
+ if (!(field.name in this.sqlNamesAndValues))
111
+ continue;
112
+ const previousValue = this._values[field.name];
113
+ const nextValue = field.getValue();
114
+ if (!previousValue || previousValue === nextValue)
115
+ continue;
116
+ try {
117
+ await field.cleanupReplacedFile(previousValue, this._sectionInfo.name);
118
+ }
119
+ catch (error) {
120
+ console.error(`${field.label}: Error deleting old file`, error);
121
+ }
122
+ }
123
+ }
97
124
  /**
98
125
  * Build the sql query
99
126
  * @override
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextjs-cms",
3
- "version": "0.5.82",
3
+ "version": "0.5.83",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -171,8 +171,8 @@
171
171
  "tsx": "^4.20.6",
172
172
  "typescript": "^5.9.2",
173
173
  "@lzcms/eslint-config": "0.3.0",
174
- "@lzcms/tsconfig": "0.1.0",
175
- "@lzcms/prettier-config": "0.1.0"
174
+ "@lzcms/prettier-config": "0.1.0",
175
+ "@lzcms/tsconfig": "0.1.0"
176
176
  },
177
177
  "license": "MIT",
178
178
  "keywords": [