nextjs-cms 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/api/lib/serverActions.js +8 -8
  2. package/dist/api/routers/accountSettings.js +4 -4
  3. package/dist/api/trpc.js +1 -1
  4. package/dist/auth/lib/actions.d.ts.map +1 -1
  5. package/dist/auth/lib/actions.js +6 -5
  6. package/dist/core/config/config-loader.d.ts +4 -4
  7. package/dist/core/config/config-loader.d.ts.map +1 -1
  8. package/dist/core/config/config-loader.js +6 -5
  9. package/dist/core/factories/FieldFactory.d.ts.map +1 -1
  10. package/dist/core/factories/FieldFactory.js +10 -1
  11. package/dist/core/fields/color.d.ts.map +1 -1
  12. package/dist/core/fields/color.js +3 -2
  13. package/dist/core/fields/date.d.ts.map +1 -1
  14. package/dist/core/fields/date.js +3 -2
  15. package/dist/core/fields/document.d.ts.map +1 -1
  16. package/dist/core/fields/document.js +14 -13
  17. package/dist/core/fields/field-group.d.ts +3 -2
  18. package/dist/core/fields/field-group.d.ts.map +1 -1
  19. package/dist/core/fields/field.d.ts +6 -2
  20. package/dist/core/fields/field.d.ts.map +1 -1
  21. package/dist/core/fields/field.js +12 -0
  22. package/dist/core/fields/index.d.ts +1 -1
  23. package/dist/core/fields/index.d.ts.map +1 -1
  24. package/dist/core/fields/map.d.ts.map +1 -1
  25. package/dist/core/fields/map.js +3 -2
  26. package/dist/core/fields/number.d.ts.map +1 -1
  27. package/dist/core/fields/number.js +8 -7
  28. package/dist/core/fields/password.d.ts.map +1 -1
  29. package/dist/core/fields/password.js +5 -4
  30. package/dist/core/fields/photo.d.ts +6 -6
  31. package/dist/core/fields/photo.d.ts.map +1 -1
  32. package/dist/core/fields/photo.js +18 -17
  33. package/dist/core/fields/richText.d.ts +9 -9
  34. package/dist/core/fields/select.js +3 -3
  35. package/dist/core/fields/slug.d.ts +4 -21
  36. package/dist/core/fields/slug.d.ts.map +1 -1
  37. package/dist/core/fields/slug.js +8 -50
  38. package/dist/core/fields/text.d.ts.map +1 -1
  39. package/dist/core/fields/text.js +4 -3
  40. package/dist/core/fields/video.d.ts.map +1 -1
  41. package/dist/core/fields/video.js +13 -12
  42. package/dist/core/sections/category.d.ts +4 -4
  43. package/dist/core/sections/category.js +3 -3
  44. package/dist/core/sections/hasItems.d.ts +10 -10
  45. package/dist/core/sections/section.d.ts +2 -2
  46. package/dist/core/sections/simple.d.ts +4 -4
  47. package/dist/core/submit/ItemEditSubmit.d.ts +6 -0
  48. package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -1
  49. package/dist/core/submit/ItemEditSubmit.js +8 -0
  50. package/dist/core/submit/submit.d.ts +25 -5
  51. package/dist/core/submit/submit.d.ts.map +1 -1
  52. package/dist/core/submit/submit.js +119 -21
  53. package/dist/translations/dictionaries/ar.d.ts +68 -0
  54. package/dist/translations/dictionaries/ar.d.ts.map +1 -1
  55. package/dist/translations/dictionaries/ar.js +81 -0
  56. package/dist/translations/dictionaries/en.d.ts +68 -0
  57. package/dist/translations/dictionaries/en.d.ts.map +1 -1
  58. package/dist/translations/dictionaries/en.js +81 -0
  59. package/dist/translations/index.d.ts +3 -2
  60. package/dist/translations/index.d.ts.map +1 -1
  61. package/dist/translations/index.js +11 -3
  62. package/dist/validators/checkbox.d.ts +1 -1
  63. package/dist/validators/checkbox.d.ts.map +1 -1
  64. package/dist/validators/checkbox.js +7 -3
  65. package/dist/validators/color.d.ts +1 -1
  66. package/dist/validators/color.d.ts.map +1 -1
  67. package/dist/validators/color.js +6 -4
  68. package/dist/validators/date.d.ts +1 -1
  69. package/dist/validators/date.d.ts.map +1 -1
  70. package/dist/validators/date.js +5 -3
  71. package/dist/validators/document.d.ts +1 -1
  72. package/dist/validators/document.d.ts.map +1 -1
  73. package/dist/validators/document.js +10 -8
  74. package/dist/validators/index.d.ts +7 -7
  75. package/dist/validators/index.d.ts.map +1 -1
  76. package/dist/validators/index.js +7 -7
  77. package/dist/validators/map.d.ts +1 -1
  78. package/dist/validators/map.d.ts.map +1 -1
  79. package/dist/validators/map.js +7 -3
  80. package/dist/validators/number.d.ts +1 -1
  81. package/dist/validators/number.d.ts.map +1 -1
  82. package/dist/validators/number.js +19 -10
  83. package/dist/validators/password.d.ts +1 -1
  84. package/dist/validators/password.d.ts.map +1 -1
  85. package/dist/validators/password.js +13 -5
  86. package/dist/validators/photo.d.ts +1 -1
  87. package/dist/validators/photo.d.ts.map +1 -1
  88. package/dist/validators/photo.js +15 -13
  89. package/dist/validators/richText.d.ts +1 -1
  90. package/dist/validators/richText.d.ts.map +1 -1
  91. package/dist/validators/richText.js +14 -6
  92. package/dist/validators/select-multiple.d.ts +1 -1
  93. package/dist/validators/select-multiple.d.ts.map +1 -1
  94. package/dist/validators/select-multiple.js +8 -6
  95. package/dist/validators/select.d.ts +1 -1
  96. package/dist/validators/select.d.ts.map +1 -1
  97. package/dist/validators/select.js +8 -3
  98. package/dist/validators/slug.d.ts +1 -1
  99. package/dist/validators/slug.d.ts.map +1 -1
  100. package/dist/validators/slug.js +14 -8
  101. package/dist/validators/text.d.ts +1 -1
  102. package/dist/validators/text.d.ts.map +1 -1
  103. package/dist/validators/text.js +13 -3
  104. package/dist/validators/textarea.d.ts +1 -1
  105. package/dist/validators/textarea.d.ts.map +1 -1
  106. package/dist/validators/textarea.js +13 -3
  107. package/dist/validators/types.d.ts +7 -0
  108. package/dist/validators/types.d.ts.map +1 -0
  109. package/dist/validators/types.js +0 -0
  110. package/dist/validators/video.d.ts +1 -1
  111. package/dist/validators/video.d.ts.map +1 -1
  112. package/dist/validators/video.js +10 -8
  113. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { Field, baseFieldConfigSchema } from './field.js';
2
2
  import { entityKind } from '../helpers/index.js';
3
3
  import * as z from 'zod';
4
+ import getString from '../../translations/index.js';
4
5
  const configSchema = z.strictObject({
5
6
  center: z
6
7
  .strictObject({
@@ -96,7 +97,7 @@ export class MapField extends Field {
96
97
  */
97
98
  if (this.required) {
98
99
  if (!this.value) {
99
- throw new Error(`${this.label}: field is required`);
100
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
100
101
  }
101
102
  }
102
103
  }
@@ -114,7 +115,7 @@ export class MapField extends Field {
114
115
  * Check if the value if well formatted as `lat,lng` string
115
116
  */
116
117
  if (!/^-?\d+(\.\d+)?,-?\d+(\.\d+)?$/.test(`${this.value?.lat},${this.value?.lng}`)) {
117
- throw new Error(`${this.label}: value is not well formatted, it should be of format: "number,number"`);
118
+ throw new Error(getString('invalidMapFormat', this.locale));
118
119
  }
119
120
  }
120
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../src/core/fields/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAgCxB,QAAA,MAAM,YAAY;;IA5Bd,oFAAoF;;;;;;;;;;;;;;;;;;;;;;IAoBpF;;;;OAIG;;wCAOL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,WAAY,SAAQ,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;IACpD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAgB;IAE7D,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,gBAAgB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;;;OAIG;;;;;;;wCA+ML,CAAA;AAEF,QAAA,MAAM,uBAAuB;;IAzOzB,oFAAoF;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoBpF;;;;OAIG;;;;;;;;;;mBAuNN,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,iBAAiB,CAmBnF"}
@@ -1,6 +1,7 @@
1
1
  import { Field, baseFieldConfigSchema } from './field.js';
2
2
  import { entityKind } from '../helpers/index.js';
3
3
  import * as z from 'zod';
4
+ import getString from '../../translations/index.js';
4
5
  const numberFieldAutoIncConfigSchema = z.strictObject({
5
6
  hasAutoIncrement: z.literal(true).describe('Enable auto-increment for this field'),
6
7
  /** Auto-increment is always integer. Allowing override to 'int' only (optional). */
@@ -75,10 +76,10 @@ export class NumberField extends Field {
75
76
  * Basic structural logic checks
76
77
  */
77
78
  if (this.minValue !== undefined && this.maxValue !== undefined && this.minValue > this.maxValue) {
78
- throw new Error(`Field ${this.label} has minValue > maxValue`);
79
+ throw new Error(getString('fieldMinMaxMismatch', this.locale, { field: this.getLocalizedLabel() }));
79
80
  }
80
81
  if (this.minLength !== undefined && this.maxLength !== undefined && this.minLength > this.maxLength) {
81
- throw new Error(`Field ${this.label} has minLength > maxLength`);
82
+ throw new Error(getString('fieldLengthMismatch', this.locale, { field: this.getLocalizedLabel() }));
82
83
  }
83
84
  /**
84
85
  * Attempt to coerce the value
@@ -142,7 +143,7 @@ export class NumberField extends Field {
142
143
  */
143
144
  if (this.required) {
144
145
  if (this.value === undefined || this.value === null || Number.isNaN(this.value)) {
145
- throw new Error(`Field ${this.label} is required`);
146
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
146
147
  }
147
148
  }
148
149
  }
@@ -163,7 +164,7 @@ export class NumberField extends Field {
163
164
  */
164
165
  if (this.minValue) {
165
166
  if (this.minValue > this.value) {
166
- throw new Error(`Field ${this.label} must be ${this.minValue} and above`);
167
+ throw new Error(getString('fieldMinValueError', this.locale, { field: this.getLocalizedLabel(), min: this.minValue }));
167
168
  }
168
169
  }
169
170
  /**
@@ -171,7 +172,7 @@ export class NumberField extends Field {
171
172
  */
172
173
  if (this.maxValue) {
173
174
  if (this.maxValue < this.value) {
174
- throw new Error(`Field ${this.label} must be ${this.maxValue} and below`);
175
+ throw new Error(getString('fieldMaxValueError', this.locale, { field: this.getLocalizedLabel(), max: this.maxValue }));
175
176
  }
176
177
  }
177
178
  /**
@@ -179,7 +180,7 @@ export class NumberField extends Field {
179
180
  */
180
181
  if (this.minLength) {
181
182
  if (this.minLength > this.value.toString().length) {
182
- throw new Error(`Field ${this.label} must be at least ${this.minLength} characters long`);
183
+ throw new Error(getString('numberMinLength', this.locale, { min: this.minLength }));
183
184
  }
184
185
  }
185
186
  /**
@@ -187,7 +188,7 @@ export class NumberField extends Field {
187
188
  */
188
189
  if (this.maxLength) {
189
190
  if (this.maxLength < this.value.toString().length) {
190
- throw new Error(`Field ${this.label} must be at most ${this.maxLength} characters long`);
191
+ throw new Error(getString('numberMaxLength', this.locale, { max: this.maxLength }));
191
192
  }
192
193
  }
193
194
  }
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../src/core/fields/password.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,4BAA4B;;;kBAGhC,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC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ACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,mBAAmB,CAmBvF"}
@@ -2,6 +2,7 @@ import { Field, baseFieldConfigSchema } from './field.js';
2
2
  import { entityKind } from '../helpers/index.js';
3
3
  import bcrypt from 'bcrypt';
4
4
  import * as z from 'zod';
5
+ import getString from '../../translations/index.js';
5
6
  const passwordValidationTypeSchema = z.strictObject({
6
7
  regex: z.custom().describe('The regex pattern for validation'),
7
8
  message: z.string().describe('The error message if validation fails'),
@@ -55,7 +56,7 @@ export class PasswordField extends Field {
55
56
  */
56
57
  if (this.adminGenerated && this.required) {
57
58
  if (!this.value || this.value.trim().length === 0) {
58
- throw new Error(`Field ${this.label} is required`);
59
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
59
60
  }
60
61
  }
61
62
  }
@@ -74,7 +75,7 @@ export class PasswordField extends Field {
74
75
  /**
75
76
  * Display the provided message
76
77
  */
77
- throw new Error(`Field ${this.label}: ${this.validation.message}`);
78
+ throw new Error(`${this.getLocalizedLabel()}: ${this.validation.message}`);
78
79
  }
79
80
  }
80
81
  /**
@@ -82,7 +83,7 @@ export class PasswordField extends Field {
82
83
  */
83
84
  if (this.minLength) {
84
85
  if (this.minLength > this.value.length) {
85
- throw new Error(`Field ${this.label} must be at least ${this.minLength} characters long`);
86
+ throw new Error(getString('minLength', this.locale, { min: this.minLength }));
86
87
  }
87
88
  }
88
89
  /**
@@ -90,7 +91,7 @@ export class PasswordField extends Field {
90
91
  */
91
92
  if (this.maxLength) {
92
93
  if (this.maxLength < this.value.length) {
93
- throw new Error(`Field ${this.label} must be at most ${this.maxLength} characters long`);
94
+ throw new Error(getString('maxLength', this.locale, { max: this.maxLength }));
94
95
  }
95
96
  }
96
97
  /**
@@ -74,10 +74,10 @@ declare const configSchema: z.ZodObject<{
74
74
  * @hint 'jpg' is an alias for 'jpeg'
75
75
  */
76
76
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
77
- jpeg: "jpeg";
77
+ webp: "webp";
78
78
  jpg: "jpg";
79
+ jpeg: "jpeg";
79
80
  png: "png";
80
- webp: "webp";
81
81
  }>>>;
82
82
  /**
83
83
  * Remove the extension from the file name
@@ -259,10 +259,10 @@ declare const optionsSchema: z.ZodObject<{
259
259
  * @hint 'jpg' is an alias for 'jpeg'
260
260
  */
261
261
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
262
- jpeg: "jpeg";
262
+ webp: "webp";
263
263
  jpg: "jpg";
264
+ jpeg: "jpeg";
264
265
  png: "png";
265
- webp: "webp";
266
266
  }>>>;
267
267
  /**
268
268
  * Remove the extension from the file name
@@ -351,10 +351,10 @@ declare const photoFieldConfigSchema: z.ZodObject<{
351
351
  * @hint 'jpg' is an alias for 'jpeg'
352
352
  */
353
353
  fileType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
354
- jpeg: "jpeg";
354
+ webp: "webp";
355
355
  jpg: "jpg";
356
+ jpeg: "jpeg";
356
357
  png: "png";
357
- webp: "webp";
358
358
  }>>>;
359
359
  /**
360
360
  * 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;AAsD1C,QAAA,MAAM,YAAY;IACd,yCAAyC;;;;;;QAvCzC;;;;;;;;;;;;WAYG;;QAEH;;;WAGG;;;;;;;;;;;;;QASH;;;WAGG;;;;;;;;IAeH;;;;;;;OAOG;;;;;;;;IAEH;;;;;;;OAOG;;;;;;;IAEH;;;OAGG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CA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
  import { FileField } from './fileField.js';
9
9
  import { humanReadableFileSize } from '../../utils/index.js';
10
10
  import { getCMSConfig } from '../config/index.js';
11
+ import getString from '../../translations/index.js';
11
12
  const backgroundSchema = z
12
13
  .strictObject({
13
14
  r: z.number().min(0).max(255).describe('Red channel (0-255)'),
@@ -130,7 +131,7 @@ export class PhotoField extends FileField {
130
131
  return 'image/png';
131
132
  if (e === 'webp')
132
133
  return 'image/webp';
133
- throw new Error(`Invalid image extension provided: ${e}`);
134
+ throw new Error(getString('invalidImageExtension', this.locale, { extensions: e }));
134
135
  });
135
136
  /**
136
137
  * Set the allowed extensions, add jpg if jpeg is present
@@ -165,7 +166,7 @@ export class PhotoField extends FileField {
165
166
  }
166
167
  exportForClient() {
167
168
  if (this._thumbnail === undefined) {
168
- throw new Error('PhotoField.build() must be called before exportForClient()');
169
+ throw new Error(getString('photoFieldBuildRequired', this.locale));
169
170
  }
170
171
  return {
171
172
  ...super.exportForClient(),
@@ -183,10 +184,10 @@ export class PhotoField extends FileField {
183
184
  */
184
185
  async writeToFile() {
185
186
  if (!this._folder) {
186
- throw new Error(`${this.label}: Folder is not set. Make sure to set the folder by calling postSubmit() before writing the file to disk`);
187
+ throw new Error(getString('folderNotSet', this.locale, { field: this.getLocalizedLabel() }));
187
188
  }
188
189
  if (!this._sharpImage) {
189
- throw new Error(`${this.label}: Image is not set. Make sure to call prepareForSubmission() before writing the file to disk`);
190
+ throw new Error(getString('imageNotSet', this.locale, { field: this.getLocalizedLabel() }));
190
191
  }
191
192
  try {
192
193
  /**
@@ -258,7 +259,7 @@ export class PhotoField extends FileField {
258
259
  .toFile(path.join(uploadsFolder, '.thumbs', this._folder, this.value));
259
260
  }
260
261
  catch (error) {
261
- throw new Error(`${this.label}: Error writing file to disk ${error.message}`);
262
+ throw new Error(getString('fileWriteError', this.locale, { field: this.getLocalizedLabel() }) + ` ${error.message}`);
262
263
  }
263
264
  }
264
265
  async postSubmit(folder) {
@@ -271,7 +272,7 @@ export class PhotoField extends FileField {
271
272
  if (!this._file)
272
273
  return;
273
274
  if (!this._folder) {
274
- throw new Error(`${this.label}: Folder is not set. Make sure to set the folder before writing the file to disk`);
275
+ throw new Error(getString('folderNotSet', this.locale, { field: this.getLocalizedLabel() }));
275
276
  }
276
277
  try {
277
278
  const uploadsFolder = (await getCMSConfig()).media.upload.path;
@@ -279,7 +280,7 @@ export class PhotoField extends FileField {
279
280
  await fs.promises.unlink(pathToFile);
280
281
  }
281
282
  catch (error) {
282
- throw new Error(`${this.label}: Error deleting file from disk`);
283
+ throw new Error(getString('fileDeleteError', this.locale, { field: this.getLocalizedLabel() }));
283
284
  }
284
285
  }
285
286
  async cleanupReplacedFile(previousValue, sectionName) {
@@ -318,7 +319,7 @@ export class PhotoField extends FileField {
318
319
  */
319
320
  if (this.required) {
320
321
  if (!this._file?.type || !this._file?.name || !this._file?.size) {
321
- throw new Error(`Field ${this.label} is required`);
322
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
322
323
  }
323
324
  }
324
325
  }
@@ -339,7 +340,7 @@ export class PhotoField extends FileField {
339
340
  if (ext === 'jpg')
340
341
  ext = 'jpeg';
341
342
  if (!ext || !this.extensions.includes(ext)) {
342
- throw new Error(`${this.label}: Invalid file type or extension. Allowed extensions: ${this.extensions.join(', ')}`);
343
+ throw new Error(getString('invalidFileTypeOrExtension', this.locale, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
343
344
  }
344
345
  /**
345
346
  * Construct the image
@@ -350,7 +351,7 @@ export class PhotoField extends FileField {
350
351
  * Check mime type
351
352
  */
352
353
  if (!this.mimeType.includes(this._file.type)) {
353
- throw new Error(`${this.label}: Invalid file type or extension. Allowed extensions: ${this.extensions.join(', ')}`);
354
+ throw new Error(getString('invalidFileTypeOrExtension', this.locale, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
354
355
  }
355
356
  /**
356
357
  * Check actual mime type
@@ -360,7 +361,7 @@ export class PhotoField extends FileField {
360
361
  if (!actualMimeType ||
361
362
  !this.extensions.includes(actualMimeType.ext) ||
362
363
  !this.mimeType.includes(actualMimeType.mime)) {
363
- throw new Error(`${this.label}: Invalid file type or extension. Allowed extensions: ${this.extensions.join(', ')}`);
364
+ throw new Error(getString('invalidFileTypeOrExtension', this.locale, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
364
365
  }
365
366
  /**
366
367
  * Disable caching for the image to avoid unlink issues
@@ -381,20 +382,20 @@ export class PhotoField extends FileField {
381
382
  */
382
383
  const fileSize = buffer.length;
383
384
  if (!fileSize || !metadata.size) {
384
- throw new Error(`Field ${this.label} is required`);
385
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
385
386
  }
386
387
  /**
387
388
  * Check the file size
388
389
  */
389
390
  if (fileSize > this.maxFileSize.size * (this.maxFileSize.unit === 'kb' ? 1024 : 1024 * 1024)) {
390
- throw new Error(`${this.label}: File size (${humanReadableFileSize(fileSize)}) exceeds the maximum allowed size of ${this.maxFileSize.size} ${this.maxFileSize.unit}`);
391
+ throw new Error(getString('fileSizeExceedsMax', this.locale, { field: this.getLocalizedLabel(), actual: humanReadableFileSize(fileSize), max: `${this.maxFileSize.size} ${this.maxFileSize.unit}` }));
391
392
  }
392
393
  /**
393
394
  * Don't just trust the file extension
394
395
  * Check the format
395
396
  */
396
397
  if (!metadata.format || !this.extensions.includes(metadata.format)) {
397
- throw new Error(`${this.label}: Invalid file type or extension. Allowed extensions: ${this.extensions.join(', ')}`);
398
+ throw new Error(getString('invalidFileTypeOrExtension', this.locale, { field: this.getLocalizedLabel(), extensions: this.extensions.join(', ') }));
398
399
  }
399
400
  /**
400
401
  * Check stat
@@ -403,7 +404,7 @@ export class PhotoField extends FileField {
403
404
  await image.stats();
404
405
  }
405
406
  catch (error) {
406
- throw new Error(`File is corrupted`);
407
+ throw new Error(getString('fileCorrupted', this.locale));
407
408
  }
408
409
  /**
409
410
  * Convert the image to webp
@@ -412,7 +413,7 @@ export class PhotoField extends FileField {
412
413
  image.toFormat('webp').withExif({});
413
414
  }
414
415
  catch (error) {
415
- throw new Error(`File is corrupted`);
416
+ throw new Error(getString('fileCorrupted', this.locale));
416
417
  }
417
418
  /**
418
419
  * Check the size
@@ -429,7 +430,7 @@ export class PhotoField extends FileField {
429
430
  * Check if the size matches the required size
430
431
  */
431
432
  if (metadata.width !== this.size.width || metadata.height !== this.size.height) {
432
- throw new Error(`${this.label}: Uploaded image size (${metadata.width}x${metadata.height} pixels) does not match the required size: ${this.size.width}x${this.size.height} pixels`);
433
+ throw new Error(getString('imageDimensionMismatchDetailed', this.locale, { field: this.getLocalizedLabel(), actual: `${metadata.width}x${metadata.height}`, required: `${this.size.width}x${this.size.height}` }));
433
434
  }
434
435
  }
435
436
  }
@@ -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
- jpeg: "jpeg";
34
+ webp: "webp";
35
35
  jpg: "jpg";
36
+ jpeg: "jpeg";
36
37
  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
- jpeg: "jpeg";
75
+ webp: "webp";
76
76
  jpg: "jpg";
77
+ jpeg: "jpeg";
77
78
  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?: "jpeg" | "jpg" | "png" | "webp" | undefined;
121
+ format?: "webp" | "jpg" | "jpeg" | "png" | 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
- jpeg: "jpeg";
189
+ webp: "webp";
190
190
  jpg: "jpg";
191
+ jpeg: "jpeg";
191
192
  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
- jpeg: "jpeg";
251
+ webp: "webp";
252
252
  jpg: "jpg";
253
+ jpeg: "jpeg";
253
254
  png: "png";
254
- webp: "webp";
255
255
  }>>;
256
256
  }, z.core.$strict>>;
257
257
  name: z.ZodString;
@@ -119,7 +119,7 @@ export class SelectField extends Field {
119
119
  };
120
120
  }
121
121
  else {
122
- throw new Error('Select field requires either db, section or an options array.');
122
+ throw new Error(`[SelectField: ${this.label}]: Select field requires either db, section or an options array.`);
123
123
  }
124
124
  }
125
125
  /**
@@ -402,7 +402,7 @@ export class SelectField extends Field {
402
402
  if (this.db.table.trim().length === 0 ||
403
403
  this.db.identifier.trim().length === 0 ||
404
404
  this.db.label.trim().length === 0) {
405
- throw new Error('Table, identifier and label are required');
405
+ throw new Error(`Field ${this.getLocalizedLabel()}: Table, identifier and label are required`);
406
406
  }
407
407
  }
408
408
  checkRequired() {
@@ -411,7 +411,7 @@ export class SelectField extends Field {
411
411
  */
412
412
  if (this.required) {
413
413
  if (!this.value || this.value.toString().trim().length === 0) {
414
- throw new Error(`Field ${this.label} is required`);
414
+ throw new Error(`Field ${this.getLocalizedLabel()} is required`);
415
415
  }
416
416
  }
417
417
  }
@@ -3,12 +3,6 @@ import { Field } from './field.js';
3
3
  import { entityKind } from '../helpers/index.js';
4
4
  import * as z from 'zod';
5
5
  import type { TextFieldConfig } from './text.js';
6
- /**
7
- * Context passed to SlugField.prepareForSubmission for duplicate checking.
8
- */
9
- export type SlugFieldSubmissionContext = {
10
- tableName: string;
11
- };
12
6
  declare const slugFieldConfigSchema: z.ZodObject<{
13
7
  placeholder: z.ZodOptional<z.ZodString>;
14
8
  minLength: z.ZodOptional<z.ZodNumber>;
@@ -94,22 +88,11 @@ export declare class SlugField extends Field<'slug', Config> {
94
88
  checkRequired(): void;
95
89
  hasSqlNameAndValue(): boolean;
96
90
  /**
97
- * Check if a slug already exists in the database table.
98
- * Uses dynamic import to avoid loading db client during module initialization.
99
- * @param tableName - The table to check for duplicates
100
- * @returns true if a duplicate exists, false otherwise
101
- */
102
- private checkDuplicateSlug;
103
- /**
104
- * Get a user-friendly label for the "for" field.
105
- * Falls back to the field name if no label is available.
106
- */
107
- private getForFieldLabel;
108
- /**
109
- * Prepare the field for submission
110
- * @param context - Optional context containing tableName for duplicate checking
91
+ * Prepare the field for submission.
92
+ * Normalizes the slug and validates length constraints.
93
+ * Uniqueness checking is handled centrally by the Submit class.
111
94
  */
112
- prepareForSubmission(context?: SlugFieldSubmissionContext): Promise<void>;
95
+ prepareForSubmission(): Promise<void>;
113
96
  }
114
97
  export type SlugFieldClientConfig = ReturnType<SlugField['exportForClient']>;
115
98
  declare const optionsSchema: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../../src/core/fields/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,C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tC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAA;IACxC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEtB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;IAW3C;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUpB,eAAe;;;;;;;;;;;;;;IAU/B;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,aAAa;IAQJ,kBAAkB,IAAI,OAAO;IAOtC;;;;OAIG;IACG,oBAAoB;CAwB7B;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE5E,QAAA,MAAM,aAAa;;;;IAvHf;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiHL,CAAA;AAEF,QAAA,MAAM,YAAY;;;;;;IA5Hd;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuHL,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,eAAe,CAkB/E"}
@@ -1,7 +1,7 @@
1
1
  import { Field, baseFieldConfigSchema } from './field.js';
2
2
  import { entityKind } from '../helpers/index.js';
3
3
  import * as z from 'zod';
4
- import { resolveLocalizedString } from '../../translations/localization.js';
4
+ import getString from '../../translations/index.js';
5
5
  const slugFieldConfigSchema = z.strictObject({
6
6
  placeholder: z.string().optional().describe('The placeholder text for the field'),
7
7
  minLength: z.number().optional().describe('The minimum length of the slug'),
@@ -72,7 +72,7 @@ export class SlugField extends Field {
72
72
  checkRequired() {
73
73
  if (this.required) {
74
74
  if (!this.value || this.value.trim().length === 0) {
75
- throw new Error(`Field ${this.label} is required`);
75
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
76
76
  }
77
77
  }
78
78
  }
@@ -83,41 +83,11 @@ export class SlugField extends Field {
83
83
  return this.adminGenerated === true || this._defaultValue !== undefined;
84
84
  }
85
85
  /**
86
- * Check if a slug already exists in the database table.
87
- * Uses dynamic import to avoid loading db client during module initialization.
88
- * @param tableName - The table to check for duplicates
89
- * @returns true if a duplicate exists, false otherwise
86
+ * Prepare the field for submission.
87
+ * Normalizes the slug and validates length constraints.
88
+ * Uniqueness checking is handled centrally by the Submit class.
90
89
  */
91
- async checkDuplicateSlug(tableName) {
92
- if (!this.value)
93
- return false;
94
- // Dynamic imports to avoid loading db client during module initialization
95
- const { sql } = await import('drizzle-orm');
96
- const { db } = await import('../../db/client.js');
97
- const [rows] = await db.execute(sql `SELECT COUNT(*) as count FROM ${sql.raw(tableName)} WHERE ${sql.raw(this.name)} = ${this.value}`);
98
- if (Array.isArray(rows) && rows.length > 0) {
99
- const count = Number(rows[0].count);
100
- return count > 0;
101
- }
102
- return false;
103
- }
104
- /**
105
- * Get a user-friendly label for the "for" field.
106
- * Falls back to the field name if no label is available.
107
- */
108
- getForFieldLabel() {
109
- const label = this.forFieldConfig.label;
110
- if (!label) {
111
- return Field.generateLabel(this.forFieldName);
112
- }
113
- // Resolve localized string with English as fallback
114
- return resolveLocalizedString(label, 'en', 'en');
115
- }
116
- /**
117
- * Prepare the field for submission
118
- * @param context - Optional context containing tableName for duplicate checking
119
- */
120
- async prepareForSubmission(context) {
90
+ async prepareForSubmission() {
121
91
  if (this.value) {
122
92
  // Ensure the value is a valid slug
123
93
  this.value = SlugField.toSlug(this.value);
@@ -126,7 +96,7 @@ export class SlugField extends Field {
126
96
  */
127
97
  if (this.minLength) {
128
98
  if (this.minLength > this.value.length) {
129
- throw new Error(`Field ${this.label} must be at least ${this.minLength} characters long`);
99
+ throw new Error(getString('minLength', this.locale, { min: this.minLength }));
130
100
  }
131
101
  }
132
102
  /**
@@ -134,19 +104,7 @@ export class SlugField extends Field {
134
104
  */
135
105
  if (this.maxLength) {
136
106
  if (this.maxLength < this.value.length) {
137
- throw new Error(`Field ${this.label} must be at most ${this.maxLength} characters long`);
138
- }
139
- }
140
- /**
141
- * Check for duplicate slugs in the database
142
- */
143
- if (context?.tableName) {
144
- const isDuplicate = await this.checkDuplicateSlug(context.tableName);
145
- if (isDuplicate) {
146
- const forFieldLabel = this.getForFieldLabel();
147
- throw new Error(`A record with the slug "${this.value}" already exists. ` +
148
- `Please change the "${forFieldLabel}" field to generate a different slug, ` +
149
- `or manually edit the slug value (not recommended).`);
107
+ throw new Error(getString('maxLength', this.locale, { max: this.maxLength }));
150
108
  }
151
109
  }
152
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/core/fields/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,KAAK,EAAyB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,QAAA,MAAM,YAAY;;;;IAId;;;;OAIG;;IAEH;;;;;OAKG;;kBAEL,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C,qBAAa,SAAU,SAAQ,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;IAChD,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAc;IAC3D,QAAQ,CAAC,SA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,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,eAAe,CAmB/E"}
@@ -2,6 +2,7 @@ import { Field, baseFieldConfigSchema } from './field.js';
2
2
  import { entityKind } from '../helpers/index.js';
3
3
  import * as z from 'zod';
4
4
  import { escapeHTML } from '../security/dom.js';
5
+ import getString from '../../translations/index.js';
5
6
  const configSchema = z.strictObject({
6
7
  placeholder: z.string().optional().describe('The placeholder text for the field'),
7
8
  minLength: z.number().optional().describe('The minimum length of the field value'),
@@ -75,7 +76,7 @@ export class TextField extends Field {
75
76
  */
76
77
  if (this.required) {
77
78
  if (!this.value || this.value.trim().length === 0) {
78
- throw new Error(`Field ${this.label} is required`);
79
+ throw new Error(getString('fieldIsRequired', this.locale, { field: this.getLocalizedLabel() }));
79
80
  }
80
81
  }
81
82
  }
@@ -99,7 +100,7 @@ export class TextField extends Field {
99
100
  */
100
101
  if (this.minLength) {
101
102
  if (this.minLength > this.value.length) {
102
- throw new Error(`Field ${this.label} must be at least ${this.minLength} characters long`);
103
+ throw new Error(getString('minLength', this.locale, { min: this.minLength }));
103
104
  }
104
105
  }
105
106
  /**
@@ -107,7 +108,7 @@ export class TextField extends Field {
107
108
  */
108
109
  if (this.maxLength) {
109
110
  if (this.maxLength < this.value.length) {
110
- throw new Error(`Field ${this.label} must be at most ${this.maxLength} characters long`);
111
+ throw new Error(getString('maxLength', this.locale, { max: this.maxLength }));
111
112
  }
112
113
  }
113
114
  }