nextjs-cms 0.9.37 → 0.9.38

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 (115) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +279 -279
  3. package/dist/api/actions/files.d.ts.map +1 -1
  4. package/dist/api/actions/pages.d.ts +1 -0
  5. package/dist/api/actions/pages.d.ts.map +1 -1
  6. package/dist/api/actions/pages.js +1 -0
  7. package/dist/api/axios/axiosInstance.d.ts +2 -0
  8. package/dist/api/axios/axiosInstance.d.ts.map +1 -0
  9. package/dist/api/axios/axiosInstance.js +8 -0
  10. package/dist/api/index.d.ts +975 -0
  11. package/dist/api/index.d.ts.map +1 -0
  12. package/dist/api/index.js +13 -0
  13. package/dist/api/lib/serverActions.d.ts +374 -0
  14. package/dist/api/lib/serverActions.d.ts.map +1 -0
  15. package/dist/api/lib/serverActions.js +1445 -0
  16. package/dist/api/root.d.ts +1917 -0
  17. package/dist/api/root.d.ts.map +1 -0
  18. package/dist/api/root.js +115 -0
  19. package/dist/api/routers/accountSettings.d.ts +66 -0
  20. package/dist/api/routers/accountSettings.d.ts.map +1 -0
  21. package/dist/api/routers/accountSettings.js +202 -0
  22. package/dist/api/routers/admins.d.ts +112 -0
  23. package/dist/api/routers/admins.d.ts.map +1 -0
  24. package/dist/api/routers/admins.js +323 -0
  25. package/dist/api/routers/auth.d.ts +54 -0
  26. package/dist/api/routers/auth.d.ts.map +1 -0
  27. package/dist/api/routers/auth.js +50 -0
  28. package/dist/api/routers/categorySection.d.ts +105 -0
  29. package/dist/api/routers/categorySection.d.ts.map +1 -0
  30. package/dist/api/routers/categorySection.js +49 -0
  31. package/dist/api/routers/config.d.ts +48 -0
  32. package/dist/api/routers/config.d.ts.map +1 -0
  33. package/dist/api/routers/config.js +18 -0
  34. package/dist/api/routers/cpanel.d.ts +82 -0
  35. package/dist/api/routers/cpanel.d.ts.map +1 -0
  36. package/dist/api/routers/cpanel.js +216 -0
  37. package/dist/api/routers/fields.d.ts +35 -0
  38. package/dist/api/routers/fields.d.ts.map +1 -0
  39. package/dist/api/routers/fields.js +81 -0
  40. package/dist/api/routers/files.d.ts +34 -0
  41. package/dist/api/routers/files.d.ts.map +1 -0
  42. package/dist/api/routers/files.js +14 -0
  43. package/dist/api/routers/gallery.d.ts +34 -0
  44. package/dist/api/routers/gallery.d.ts.map +1 -0
  45. package/dist/api/routers/gallery.js +64 -0
  46. package/dist/api/routers/hasItemsSection.d.ts +219 -0
  47. package/dist/api/routers/hasItemsSection.d.ts.map +1 -0
  48. package/dist/api/routers/hasItemsSection.js +86 -0
  49. package/dist/api/routers/logs.d.ts +59 -0
  50. package/dist/api/routers/logs.d.ts.map +1 -0
  51. package/dist/api/routers/logs.js +76 -0
  52. package/dist/api/routers/navigation.d.ts +50 -0
  53. package/dist/api/routers/navigation.d.ts.map +1 -0
  54. package/dist/api/routers/navigation.js +11 -0
  55. package/dist/api/routers/simpleSection.d.ts +105 -0
  56. package/dist/api/routers/simpleSection.d.ts.map +1 -0
  57. package/dist/api/routers/simpleSection.js +54 -0
  58. package/dist/api/trpc/root.d.ts +41 -7
  59. package/dist/api/trpc/root.d.ts.map +1 -1
  60. package/dist/api/trpc/routers/config.d.ts.map +1 -1
  61. package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -1
  62. package/dist/api/trpc/routers/logs.d.ts +37 -4
  63. package/dist/api/trpc/routers/logs.d.ts.map +1 -1
  64. package/dist/api/trpc/routers/logs.js +92 -43
  65. package/dist/api/trpc/routers/navigation.d.ts +1 -0
  66. package/dist/api/trpc/routers/navigation.d.ts.map +1 -1
  67. package/dist/api/trpc/routers/simpleSection.d.ts.map +1 -1
  68. package/dist/api/trpc/server.d.ts +123 -21
  69. package/dist/api/trpc/server.d.ts.map +1 -1
  70. package/dist/api/trpc.d.ts +111 -0
  71. package/dist/api/trpc.d.ts.map +1 -0
  72. package/dist/api/trpc.js +99 -0
  73. package/dist/auth/axios/axiosInstance.d.ts +2 -0
  74. package/dist/auth/axios/axiosInstance.d.ts.map +1 -0
  75. package/dist/auth/axios/axiosInstance.js +8 -0
  76. package/dist/auth/hooks/useAxiosPrivate.d.ts +5 -0
  77. package/dist/auth/hooks/useAxiosPrivate.d.ts.map +1 -0
  78. package/dist/auth/hooks/useAxiosPrivate.js +74 -0
  79. package/dist/auth/trpc.d.ts +6 -0
  80. package/dist/auth/trpc.d.ts.map +1 -0
  81. package/dist/auth/trpc.js +82 -0
  82. package/dist/cli/lib/db-config.js +10 -10
  83. package/dist/cli/lib/update-sections.js +24 -24
  84. package/dist/core/config/config-loader.d.ts +2 -2
  85. package/dist/core/db/table-checker/MysqlTable.js +10 -10
  86. package/dist/core/factories/section-factory-with-esbuild.js +9 -9
  87. package/dist/core/factories/section-factory-with-jiti.js +9 -9
  88. package/dist/core/fields/dateRange.d.ts +115 -0
  89. package/dist/core/fields/dateRange.d.ts.map +1 -0
  90. package/dist/core/fields/dateRange.js +149 -0
  91. package/dist/logging/event-labels.d.ts +11 -0
  92. package/dist/logging/event-labels.d.ts.map +1 -0
  93. package/dist/logging/event-labels.js +14 -0
  94. package/dist/logging/log.d.ts +1 -1
  95. package/dist/logging/log.d.ts.map +1 -1
  96. package/dist/translations/base/en.d.ts +33 -0
  97. package/dist/translations/base/en.d.ts.map +1 -1
  98. package/dist/translations/base/en.js +33 -0
  99. package/dist/translations/client.d.ts +400 -4
  100. package/dist/translations/client.d.ts.map +1 -1
  101. package/dist/translations/locale-cookie.d.ts +24 -0
  102. package/dist/translations/locale-cookie.d.ts.map +1 -0
  103. package/dist/translations/locale-cookie.js +44 -0
  104. package/dist/translations/locale-utils.d.ts +8 -0
  105. package/dist/translations/locale-utils.d.ts.map +1 -0
  106. package/dist/translations/locale-utils.js +11 -0
  107. package/dist/translations/localization.d.ts +40 -0
  108. package/dist/translations/localization.d.ts.map +1 -0
  109. package/dist/translations/localization.js +48 -0
  110. package/dist/translations/server.d.ts +400 -4
  111. package/dist/translations/server.d.ts.map +1 -1
  112. package/dist/validators/dateRange.d.ts +11 -0
  113. package/dist/validators/dateRange.d.ts.map +1 -0
  114. package/dist/validators/dateRange.js +16 -0
  115. package/package.json +6 -2
@@ -22,12 +22,12 @@ export class MysqlTableChecker extends DbTableChecker {
22
22
  return _tables;
23
23
  }
24
24
  static async getColumns(tableName) {
25
- const statement = sql `
26
- SELECT COLUMN_NAME
27
- FROM information_schema.COLUMNS c
28
- inner join information_schema.TABLES t ON t.TABLE_NAME = c.TABLE_NAME
29
- WHERE t.TABLE_SCHEMA = DATABASE()
30
- AND c.TABLE_SCHEMA = DATABASE()
25
+ const statement = sql `
26
+ SELECT COLUMN_NAME
27
+ FROM information_schema.COLUMNS c
28
+ inner join information_schema.TABLES t ON t.TABLE_NAME = c.TABLE_NAME
29
+ WHERE t.TABLE_SCHEMA = DATABASE()
30
+ AND c.TABLE_SCHEMA = DATABASE()
31
31
  AND t.TABLE_NAME = ${tableName}`;
32
32
  const _cols = [];
33
33
  const _res = await db.execute(statement);
@@ -84,10 +84,10 @@ export class MysqlTableChecker extends DbTableChecker {
84
84
  fullTextKeys.push({ name: key, columns: _fullTextKeyMap[key] });
85
85
  }
86
86
  // Foreign keys should be retrieved from information_schema
87
- const [foreignKeys] = await db.execute(sql `
88
- SELECT COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
89
- FROM information_schema.KEY_COLUMN_USAGE
90
- WHERE TABLE_NAME = ${table} AND CONSTRAINT_NAME != 'PRIMARY' AND REFERENCED_TABLE_NAME IS NOT NULL;
87
+ const [foreignKeys] = await db.execute(sql `
88
+ SELECT COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
89
+ FROM information_schema.KEY_COLUMN_USAGE
90
+ WHERE TABLE_NAME = ${table} AND CONSTRAINT_NAME != 'PRIMARY' AND REFERENCED_TABLE_NAME IS NOT NULL;
91
91
  `);
92
92
  return { primaryKeys, uniqueKeys, indexKeys, foreignKeys, fullTextKeys };
93
93
  }
@@ -460,15 +460,15 @@ export class SectionFactory {
460
460
  importErr.message.includes('Cannot find module') &&
461
461
  importErr.message.includes('.section')) {
462
462
  this.sectionProcessingErrors[file] ??= [];
463
- this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
464
-
465
- Sections MUST use extensionless relative imports:
466
-
467
- ✅ import exampleSection from './example.section'
468
- ❌ import exampleSection from './example.section.ts'
469
- ❌ import exampleSection from './example.section.js'
470
-
471
- This file is bundled with esbuild, so Node never resolves the import directly.
463
+ this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
464
+
465
+ Sections MUST use extensionless relative imports:
466
+
467
+ ✅ import exampleSection from './example.section'
468
+ ❌ import exampleSection from './example.section.ts'
469
+ ❌ import exampleSection from './example.section.js'
470
+
471
+ This file is bundled with esbuild, so Node never resolves the import directly.
472
472
  If you added an extension manually, remove it.`);
473
473
  this.errorCount++;
474
474
  continue;
@@ -417,15 +417,15 @@ export class SectionFactory {
417
417
  importErr.message.includes('Cannot find module') &&
418
418
  importErr.message.includes('.section')) {
419
419
  this.sectionProcessingErrors[file] ??= [];
420
- this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
421
-
422
- Sections MUST use extensionless relative imports:
423
-
424
- ✅ import exampleSection from './example.section'
425
- ❌ import exampleSection from './example.section.ts'
426
- ❌ import exampleSection from './example.section.js'
427
-
428
- This file is bundled with jiti, so Node never resolves the import directly.
420
+ this.sectionProcessingErrors[file].push(`❌ Invalid section import detected.
421
+
422
+ Sections MUST use extensionless relative imports:
423
+
424
+ ✅ import exampleSection from './example.section'
425
+ ❌ import exampleSection from './example.section.ts'
426
+ ❌ import exampleSection from './example.section.js'
427
+
428
+ This file is bundled with jiti, so Node never resolves the import directly.
429
429
  If you added an extension manually, remove it.`);
430
430
  this.errorCount++;
431
431
  continue;
@@ -0,0 +1,115 @@
1
+ import type { BaseFieldConfig } from './field.js';
2
+ import { Field } from './field.js';
3
+ import { entityKind } from '../helpers/index.js';
4
+ import * as z from 'zod';
5
+ declare const configSchema: z.ZodObject<{
6
+ startName: z.ZodString;
7
+ endName: z.ZodString;
8
+ format: z.ZodOptional<z.ZodEnum<{
9
+ date: "date";
10
+ datetime: "datetime";
11
+ }>>;
12
+ defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
13
+ defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
14
+ }, z.core.$strict>;
15
+ type Config = z.infer<typeof configSchema>;
16
+ /**
17
+ * DateRangeField stores two DB columns: startName and endName.
18
+ *
19
+ * Because Field expects a single `name`, we pass `startName` as `name` to the
20
+ * super constructor (used for label generation / identity only).
21
+ * The field opts out of the normal single-column SQL path via hasSqlNameAndValue()=false
22
+ * and instead exposes setValues() / getSqlNamesAndValues() which submit.ts calls
23
+ * via an is(field, DateRangeField) guard — the same pattern used for SelectField.
24
+ */
25
+ export declare class DateRangeField extends Field<'date_range', Config> {
26
+ static readonly [entityKind]: string;
27
+ readonly startName: string;
28
+ readonly endName: string;
29
+ readonly format: 'date' | 'datetime';
30
+ private startValue;
31
+ private endValue;
32
+ constructor(config: Omit<BaseFieldConfig<Config>, 'name'> & Config);
33
+ hasSqlNameAndValue(): boolean;
34
+ setValues(postData: FormData): void;
35
+ getSqlNamesAndValues(): Record<string, string | null>;
36
+ getValue(): {
37
+ from: string | null;
38
+ to: string | null;
39
+ };
40
+ exportForClient(): {
41
+ startName: string;
42
+ endName: string;
43
+ format: "date" | "datetime";
44
+ startValue: any;
45
+ endValue: any;
46
+ type: "date_range";
47
+ name: string;
48
+ label: string;
49
+ required: boolean;
50
+ localized?: boolean;
51
+ conditionalFields: import("../types/index.js").ConditionalField[];
52
+ readonly: boolean;
53
+ defaultValue: any;
54
+ value: any;
55
+ };
56
+ checkRequired(): void;
57
+ prepareForSubmission(): Promise<void>;
58
+ private parseDate;
59
+ private formatDate;
60
+ }
61
+ export type DateRangeFieldClientConfig = ReturnType<DateRangeField['exportForClient']>;
62
+ declare const optionsSchema: z.ZodObject<{
63
+ startName: z.ZodString;
64
+ endName: z.ZodString;
65
+ format: z.ZodOptional<z.ZodEnum<{
66
+ date: "date";
67
+ datetime: "datetime";
68
+ }>>;
69
+ defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
70
+ defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
71
+ label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
72
+ required: z.ZodOptional<z.ZodBoolean>;
73
+ defaultValue: z.ZodOptional<z.ZodAny>;
74
+ order: z.ZodOptional<z.ZodNumber>;
75
+ conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
76
+ adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
77
+ localized: z.ZodOptional<z.ZodBoolean>;
78
+ }, z.core.$strict>;
79
+ declare const dateRangeFieldConfigSchema: z.ZodObject<{
80
+ /**
81
+ * Auto-computed as `${startName}|${endName}`.
82
+ * Satisfies the `FieldConfig` union constraint that every config has a `name` property.
83
+ * Never set manually — use `startName` and `endName` instead.
84
+ */
85
+ name: z.ZodString;
86
+ type: z.ZodLiteral<"date_range">;
87
+ build: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodCustom<DateRangeField, DateRangeField>>;
88
+ startName: z.ZodString;
89
+ endName: z.ZodString;
90
+ format: z.ZodOptional<z.ZodEnum<{
91
+ date: "date";
92
+ datetime: "datetime";
93
+ }>>;
94
+ defaultStartValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
95
+ defaultEndValue: z.ZodOptional<z.ZodCustom<Date, Date>>;
96
+ label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
97
+ required: z.ZodOptional<z.ZodBoolean>;
98
+ defaultValue: z.ZodOptional<z.ZodAny>;
99
+ order: z.ZodOptional<z.ZodNumber>;
100
+ conditionalRules: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").ConditionalRule, import("../types/index.js").ConditionalRule>>>;
101
+ adminGenerated: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodLiteral<false>, z.ZodLiteral<"readonly">]>>;
102
+ localized: z.ZodOptional<z.ZodBoolean>;
103
+ }, z.core.$strict>;
104
+ export type DateRangeFieldConfig = z.infer<typeof dateRangeFieldConfigSchema>;
105
+ /**
106
+ * Helper to create a date range field configuration.
107
+ * Uses `startName` and `endName` instead of the usual `name`.
108
+ * The `name` property is auto-computed as `${startName}|${endName}`.
109
+ *
110
+ * @example
111
+ * dateRangeField({ startName: 'event_start', endName: 'event_end', label: 'Event Dates' })
112
+ */
113
+ export declare function dateRangeField(field: z.infer<typeof optionsSchema>): DateRangeFieldConfig;
114
+ export {};
115
+ //# sourceMappingURL=dateRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateRange.d.ts","sourceRoot":"","sources":["../../../src/core/fields/dateRange.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;AAIxB,QAAA,MAAM,YAAY;;;;;;;;;kBAMhB,CAAA;AAEF,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAE1C;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;IAC3D,gBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAmB;IAEhE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAEpC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAK;gBAET,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM;IAYzD,kBAAkB,IAAI,OAAO;IAMtC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IASnC,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IASrD,QAAQ,IAAI;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;IAO7C,eAAe;;;;;;;;;;;;;;;;IAWxB,aAAa,IAAI,IAAI;IASf,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3C,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;CAOrB;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAItF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;kBAGjB,CAAA;AAEF,QAAA,MAAM,0BAA0B;IAE5B;;;;OAIG;;;;;;;;;;;;;;;;;;;kBAOL,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG,oBAAoB,CAczF"}
@@ -0,0 +1,149 @@
1
+ import { Field, baseFieldConfigSchema } from './field.js';
2
+ import { entityKind } from '../helpers/index.js';
3
+ import * as z from 'zod';
4
+ import dayjs from 'dayjs';
5
+ import getString from '../../translations/index.js';
6
+ const configSchema = z.strictObject({
7
+ startName: z.string().describe('The DB column name for the start date'),
8
+ endName: z.string().describe('The DB column name for the end date'),
9
+ format: z.enum(['date', 'datetime']).optional().describe('The format of the date columns'),
10
+ defaultStartValue: z.custom().optional().describe('Default value for the start date'),
11
+ defaultEndValue: z.custom().optional().describe('Default value for the end date'),
12
+ });
13
+ /**
14
+ * DateRangeField stores two DB columns: startName and endName.
15
+ *
16
+ * Because Field expects a single `name`, we pass `startName` as `name` to the
17
+ * super constructor (used for label generation / identity only).
18
+ * The field opts out of the normal single-column SQL path via hasSqlNameAndValue()=false
19
+ * and instead exposes setValues() / getSqlNamesAndValues() which submit.ts calls
20
+ * via an is(field, DateRangeField) guard — the same pattern used for SelectField.
21
+ */
22
+ export class DateRangeField extends Field {
23
+ static [entityKind] = 'DateRangeField';
24
+ startName;
25
+ endName;
26
+ format;
27
+ startValue;
28
+ endValue;
29
+ constructor(config) {
30
+ // Pass startName as `name` so the base class label-generation / identity works
31
+ super({ ...config, name: config.startName }, 'date_range');
32
+ this.startName = config.startName;
33
+ this.endName = config.endName;
34
+ this.format = config.format ?? 'date';
35
+ this.startValue = config.defaultStartValue ?? undefined;
36
+ this.endValue = config.defaultEndValue ?? undefined;
37
+ }
38
+ // ─── Opt out of single-column SQL path ────────────────────────────────────
39
+ hasSqlNameAndValue() {
40
+ return false;
41
+ }
42
+ // ─── Dual-column FormData reading (called by submit.ts) ───────────────────
43
+ setValues(postData) {
44
+ const start = postData.get(this.startName);
45
+ const end = postData.get(this.endName);
46
+ if (start)
47
+ this.startValue = start;
48
+ if (end)
49
+ this.endValue = end;
50
+ }
51
+ // ─── Dual-column SQL output (called by submit.ts) ─────────────────────────
52
+ getSqlNamesAndValues() {
53
+ return {
54
+ [this.startName]: this.formatDate(this.startValue),
55
+ [this.endName]: this.formatDate(this.endValue),
56
+ };
57
+ }
58
+ // ─── Standard Field interface ─────────────────────────────────────────────
59
+ getValue() {
60
+ return {
61
+ from: this.formatDate(this.startValue),
62
+ to: this.formatDate(this.endValue),
63
+ };
64
+ }
65
+ exportForClient() {
66
+ return {
67
+ ...super.exportForClient(),
68
+ startName: this.startName,
69
+ endName: this.endName,
70
+ format: this.format,
71
+ startValue: this.startValue ?? null,
72
+ endValue: this.endValue ?? null,
73
+ };
74
+ }
75
+ checkRequired() {
76
+ if (!this.required)
77
+ return;
78
+ if (!this.parseDate(this.startValue) || !this.parseDate(this.endValue)) {
79
+ throw new Error(getString('fieldIsRequired', this.language, { field: this.getLocalizedLabel() }));
80
+ }
81
+ }
82
+ async prepareForSubmission() {
83
+ const start = this.parseDate(this.startValue);
84
+ const end = this.parseDate(this.endValue);
85
+ if (this.required && (!start || !end)) {
86
+ throw new Error(getString('invalidDatePleaseProvideValid', this.language, { field: this.getLocalizedLabel() }));
87
+ }
88
+ if (start)
89
+ this.startValue = start.toISOString();
90
+ if (end)
91
+ this.endValue = end.toISOString();
92
+ }
93
+ // ─── Helpers ──────────────────────────────────────────────────────────────
94
+ parseDate(value) {
95
+ if (value === undefined || value === null || value === '')
96
+ return null;
97
+ const date = new Date(value);
98
+ return isNaN(date.getTime()) ? null : date;
99
+ }
100
+ formatDate(value) {
101
+ const date = this.parseDate(value);
102
+ if (!date)
103
+ return null;
104
+ return this.format === 'datetime'
105
+ ? dayjs(date).format('YYYY-MM-DD HH:mm:ss')
106
+ : dayjs(date).format('YYYY-MM-DD');
107
+ }
108
+ }
109
+ // ─── Config schema & factory ──────────────────────────────────────────────────
110
+ const optionsSchema = z.strictObject({
111
+ ...baseFieldConfigSchema.omit({ name: true }).shape,
112
+ ...configSchema.shape,
113
+ });
114
+ const dateRangeFieldConfigSchema = z.strictObject({
115
+ ...optionsSchema.shape,
116
+ /**
117
+ * Auto-computed as `${startName}|${endName}`.
118
+ * Satisfies the `FieldConfig` union constraint that every config has a `name` property.
119
+ * Never set manually — use `startName` and `endName` instead.
120
+ */
121
+ name: z.string(),
122
+ type: z.literal('date_range').describe('The type of the field'),
123
+ build: z
124
+ .function()
125
+ .output(z.instanceof(DateRangeField))
126
+ .describe('Build a DateRangeField instance from this config'),
127
+ });
128
+ /**
129
+ * Helper to create a date range field configuration.
130
+ * Uses `startName` and `endName` instead of the usual `name`.
131
+ * The `name` property is auto-computed as `${startName}|${endName}`.
132
+ *
133
+ * @example
134
+ * dateRangeField({ startName: 'event_start', endName: 'event_end', label: 'Event Dates' })
135
+ */
136
+ export function dateRangeField(field) {
137
+ const result = optionsSchema.safeParse(field);
138
+ if (!result.success) {
139
+ throw new Error(`[DateRangeField: ${field.startName}/${field.endName}]: ${z.prettifyError(result.error)}`);
140
+ }
141
+ return {
142
+ ...field,
143
+ name: `${field.startName}|${field.endName}`,
144
+ type: 'date_range',
145
+ build() {
146
+ return new DateRangeField(field);
147
+ },
148
+ };
149
+ }
@@ -0,0 +1,11 @@
1
+ import type { LogEventType } from './log.js';
2
+ export type EventCategory = 'auth' | 'content' | 'admin';
3
+ type EventLabel = {
4
+ labelKey: string;
5
+ category: EventCategory;
6
+ };
7
+ export declare const EVENT_LABELS: Record<LogEventType, EventLabel>;
8
+ export declare const getEventLabelKey: (eventType: string) => string;
9
+ export declare const getEventCategory: (eventType: string) => EventCategory;
10
+ export {};
11
+ //# sourceMappingURL=event-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-labels.d.ts","sourceRoot":"","sources":["../../src/logging/event-labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;AAExD,KAAK,UAAU,GAAG;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,UAAU,CAWzD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,KAAG,MAC6B,CAAA;AAElF,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,KAAG,aAC6B,CAAA"}
@@ -0,0 +1,14 @@
1
+ export const EVENT_LABELS = {
2
+ 'auth.login': { labelKey: 'eventAuthLogin', category: 'auth' },
3
+ 'auth.logout': { labelKey: 'eventAuthLogout', category: 'auth' },
4
+ 'section.item.create': { labelKey: 'eventItemCreate', category: 'content' },
5
+ 'section.item.update': { labelKey: 'eventItemUpdate', category: 'content' },
6
+ 'section.item.delete': { labelKey: 'eventItemDelete', category: 'content' },
7
+ 'section.item.locale.delete': { labelKey: 'eventItemLocaleDelete', category: 'content' },
8
+ 'admin.section.create': { labelKey: 'eventAdminSectionCreate', category: 'admin' },
9
+ 'admin.section.update': { labelKey: 'eventAdminSectionUpdate', category: 'admin' },
10
+ 'admin.section.delete': { labelKey: 'eventAdminSectionDelete', category: 'admin' },
11
+ 'admin.settings.change': { labelKey: 'eventAdminSettingsChange', category: 'admin' },
12
+ };
13
+ export const getEventLabelKey = (eventType) => EVENT_LABELS[eventType]?.labelKey ?? eventType;
14
+ export const getEventCategory = (eventType) => EVENT_LABELS[eventType]?.category ?? 'content';
@@ -1,4 +1,4 @@
1
- export type LogEventType = 'auth.login' | 'auth.logout' | 'section.item.create' | 'section.item.update' | 'section.item.delete' | 'section.item.locale.delete' | 'admin.section.create' | 'admin.section.update' | 'admin.section.delete' | 'admin.username.change' | 'admin.settings.change';
1
+ export type LogEventType = 'auth.login' | 'auth.logout' | 'section.item.create' | 'section.item.update' | 'section.item.delete' | 'section.item.locale.delete' | 'admin.section.create' | 'admin.section.update' | 'admin.section.delete' | 'admin.settings.change';
2
2
  export type RequestMetadata = {
3
3
  ipAddress?: string | null;
4
4
  userAgent?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/logging/log.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAClB,YAAY,GACZ,aAAa,GACb,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,4BAA4B,GAC5B,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAA;AAE7B,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACnB,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAChC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;CACpC,CAAA;AAcD,eAAO,MAAM,6BAA6B,GAAI,UAAU,OAAO,GAAG,IAAI,KAAG,eAaxE,CAAA;AAED,eAAO,MAAM,SAAS,GAAU,OAAO,QAAQ,KAAG,OAAO,CAAC,IAAI,CAqB7D,CAAA"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/logging/log.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAClB,YAAY,GACZ,aAAa,GACb,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,4BAA4B,GAC5B,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,uBAAuB,CAAA;AAE7B,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACnB,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAChC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;CACpC,CAAA;AAcD,eAAO,MAAM,6BAA6B,GAAI,UAAU,OAAO,GAAG,IAAI,KAAG,eAaxE,CAAA;AAED,eAAO,MAAM,SAAS,GAAU,OAAO,QAAQ,KAAG,OAAO,CAAC,IAAI,CAqB7D,CAAA"}
@@ -262,6 +262,39 @@ declare const _default: {
262
262
  readonly emailAddress: "Email Address";
263
263
  readonly log: "Log";
264
264
  readonly logs: "Logs";
265
+ readonly logsDescription: "Audit trail of actions performed in the CMS";
266
+ readonly time: "Time";
267
+ readonly event: "Event";
268
+ readonly actor: "Actor";
269
+ readonly target: "Target";
270
+ readonly type: "Type";
271
+ readonly deletedAccount: "deleted account";
272
+ readonly filterByEvent: "Event type";
273
+ readonly filterBySection: "Section";
274
+ readonly filterByActor: "Actor";
275
+ readonly dateRange: "Date range";
276
+ readonly from: "From";
277
+ readonly to: "To";
278
+ readonly allEvents: "All events";
279
+ readonly allSections: "All sections";
280
+ readonly allActors: "All actors";
281
+ readonly reset: "Reset";
282
+ readonly loadMore: "Load more";
283
+ readonly showingCount: "Showing {count}";
284
+ readonly ipAddress: "IP address";
285
+ readonly userAgent: "User agent";
286
+ readonly requestInfo: "Request info";
287
+ readonly metadata: "Metadata";
288
+ readonly eventAuthLogin: "Signed in";
289
+ readonly eventAuthLogout: "Signed out";
290
+ readonly eventItemCreate: "Created item";
291
+ readonly eventItemUpdate: "Updated item";
292
+ readonly eventItemDelete: "Deleted item";
293
+ readonly eventItemLocaleDelete: "Deleted translation";
294
+ readonly eventAdminSectionCreate: "Created section";
295
+ readonly eventAdminSectionUpdate: "Updated permissions";
296
+ readonly eventAdminSectionDelete: "Deleted section";
297
+ readonly eventAdminSettingsChange: "Changed settings";
265
298
  readonly select: "Select";
266
299
  readonly selectOptions: "Select options";
267
300
  readonly settings: "Settings";
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/translations/base/en.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAghBU"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/translations/base/en.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAijBU"}
@@ -262,6 +262,39 @@ export default {
262
262
  emailAddress: 'Email Address',
263
263
  log: 'Log',
264
264
  logs: 'Logs',
265
+ logsDescription: 'Audit trail of actions performed in the CMS',
266
+ time: 'Time',
267
+ event: 'Event',
268
+ actor: 'Actor',
269
+ target: 'Target',
270
+ type: 'Type',
271
+ deletedAccount: 'deleted account',
272
+ filterByEvent: 'Event type',
273
+ filterBySection: 'Section',
274
+ filterByActor: 'Actor',
275
+ dateRange: 'Date range',
276
+ from: 'From',
277
+ to: 'To',
278
+ allEvents: 'All events',
279
+ allSections: 'All sections',
280
+ allActors: 'All actors',
281
+ reset: 'Reset',
282
+ loadMore: 'Load more',
283
+ showingCount: 'Showing {count}',
284
+ ipAddress: 'IP address',
285
+ userAgent: 'User agent',
286
+ requestInfo: 'Request info',
287
+ metadata: 'Metadata',
288
+ eventAuthLogin: 'Signed in',
289
+ eventAuthLogout: 'Signed out',
290
+ eventItemCreate: 'Created item',
291
+ eventItemUpdate: 'Updated item',
292
+ eventItemDelete: 'Deleted item',
293
+ eventItemLocaleDelete: 'Deleted translation',
294
+ eventAdminSectionCreate: 'Created section',
295
+ eventAdminSectionUpdate: 'Updated permissions',
296
+ eventAdminSectionDelete: 'Deleted section',
297
+ eventAdminSettingsChange: 'Changed settings',
265
298
  select: 'Select',
266
299
  selectOptions: 'Select options',
267
300
  settings: 'Settings',