nextjs-cms 0.5.74 → 0.5.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +2 -2
- package/dist/api/lib/serverActions.d.ts +2 -2
- package/dist/api/lib/serverActions.d.ts.map +1 -1
- package/dist/api/lib/serverActions.js +21 -0
- package/dist/api/root.d.ts +4 -4
- package/dist/api/routers/hasItemsSection.d.ts +2 -2
- package/dist/core/sections/category.d.ts +4 -4
- package/dist/core/sections/hasItems.d.ts +20 -4
- package/dist/core/sections/hasItems.d.ts.map +1 -1
- package/dist/core/sections/hasItems.js +17 -0
- package/dist/core/sections/section.d.ts +16 -2
- package/dist/core/sections/section.d.ts.map +1 -1
- package/dist/core/sections/simple.d.ts +4 -4
- package/dist/core/submit/submit.d.ts +10 -0
- package/dist/core/submit/submit.d.ts.map +1 -1
- package/dist/core/submit/submit.js +53 -0
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -233,14 +233,14 @@ declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
233
233
|
name: string;
|
|
234
234
|
title: string;
|
|
235
235
|
};
|
|
236
|
-
items: {
|
|
236
|
+
items: (Record<string, any> | {
|
|
237
237
|
id: string | number;
|
|
238
238
|
headingTitle: string;
|
|
239
239
|
coverPhoto: string | null;
|
|
240
240
|
createdAt: string;
|
|
241
241
|
createdBy: string;
|
|
242
242
|
permission: number;
|
|
243
|
-
}[];
|
|
243
|
+
})[];
|
|
244
244
|
totalCount: any;
|
|
245
245
|
error?: undefined;
|
|
246
246
|
};
|
|
@@ -270,14 +270,14 @@ export declare const getBrowsePage: (session: Session, sectionName: string, page
|
|
|
270
270
|
name: string;
|
|
271
271
|
title: string;
|
|
272
272
|
};
|
|
273
|
-
items: {
|
|
273
|
+
items: (Record<string, any> | {
|
|
274
274
|
id: string | number;
|
|
275
275
|
headingTitle: string;
|
|
276
276
|
coverPhoto: string | null;
|
|
277
277
|
createdAt: string;
|
|
278
278
|
createdBy: string;
|
|
279
279
|
permission: number;
|
|
280
|
-
}[];
|
|
280
|
+
})[];
|
|
281
281
|
totalCount: any;
|
|
282
282
|
error?: undefined;
|
|
283
283
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverActions.d.ts","sourceRoot":"","sources":["../../../src/api/lib/serverActions.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AASlD,eAAO,MAAM,eAAe,GAAU,gCAInC;IACC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACjB,qBAmBA,CAAA;AACD,eAAO,MAAM,WAAW,GACpB,SAAS,OAAO,EAChB,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;EAqGlE,CAAA;AA8BD,eAAO,MAAM,QAAQ,GAAU,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,oBAgDxF,CAAA;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,wDAyB3F;AAED,eAAO,MAAM,QAAQ,GAAU,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,mBAE7F,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,SAAS,MAAM,yBAOvD,CAAA;AAED,eAAO,MAAM,gBAAgB;WAKd,MAAM;WACN,MAAM;iBACA,MAAM;iBACN,MA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AAO,EAAE,aAAa,MAAM,EAAE,OAAM,MAAU,EAAE,IAAI,MAAM;;;;;;;;;;;;;;YAqGnF,MAAM,GAAG,MAAM;sBACL,MAAM;oBACR,MAAM,GAAG,IAAI;mBACd,MAAM;mBACN,MAAM;oBACL,MAAM;;;;EAKjC,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;EA+DhD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACnB,MAAM,MAAM,EACZ,UAAU;IACN,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,KACF,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAcpC,CAAA"}
|
|
@@ -823,6 +823,27 @@ export const getBrowsePage = async (session, sectionName, page = 1, q) => {
|
|
|
823
823
|
title: section.title.section,
|
|
824
824
|
},
|
|
825
825
|
items: rows.map((row) => {
|
|
826
|
+
// Custom browse page implementation: if browse.fields is configured,
|
|
827
|
+
// return the specified fields plus default fields (id, headingTitle, coverPhoto, createdAt, createdBy, permission).
|
|
828
|
+
// NOTE: This is for custom browse page implementations only.
|
|
829
|
+
// The default CMS browse page component uses the fallback fields below.
|
|
830
|
+
if (section.browse?.fields && section.browse.fields.length > 0) {
|
|
831
|
+
const item = {
|
|
832
|
+
// Always include default fields
|
|
833
|
+
id: row[section.db.identifier.name],
|
|
834
|
+
headingTitle: row[section.headingField.name],
|
|
835
|
+
coverPhoto: section.coverPhotoField ? row[section.coverPhotoField?.name] : null,
|
|
836
|
+
createdAt: row['created_at'],
|
|
837
|
+
createdBy: row['created_by'],
|
|
838
|
+
permission: row.permission,
|
|
839
|
+
};
|
|
840
|
+
// Add configured browse fields
|
|
841
|
+
for (const field of section.browse.fields) {
|
|
842
|
+
item[field.name] = row[field.name] ?? null;
|
|
843
|
+
}
|
|
844
|
+
return item;
|
|
845
|
+
}
|
|
846
|
+
// Default browse page fields (used by the standard CMS browse page)
|
|
826
847
|
return {
|
|
827
848
|
id: row[section.db.identifier.name],
|
|
828
849
|
headingTitle: row[section.headingField.name],
|
package/dist/api/root.d.ts
CHANGED
|
@@ -224,14 +224,14 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
224
224
|
name: string;
|
|
225
225
|
title: string;
|
|
226
226
|
};
|
|
227
|
-
items: {
|
|
227
|
+
items: (Record<string, any> | {
|
|
228
228
|
id: string | number;
|
|
229
229
|
headingTitle: string;
|
|
230
230
|
coverPhoto: string | null;
|
|
231
231
|
createdAt: string;
|
|
232
232
|
createdBy: string;
|
|
233
233
|
permission: number;
|
|
234
|
-
}[];
|
|
234
|
+
})[];
|
|
235
235
|
totalCount: any;
|
|
236
236
|
error?: undefined;
|
|
237
237
|
};
|
|
@@ -1002,14 +1002,14 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
|
|
|
1002
1002
|
name: string;
|
|
1003
1003
|
title: string;
|
|
1004
1004
|
};
|
|
1005
|
-
items: {
|
|
1005
|
+
items: (Record<string, any> | {
|
|
1006
1006
|
id: string | number;
|
|
1007
1007
|
headingTitle: string;
|
|
1008
1008
|
coverPhoto: string | null;
|
|
1009
1009
|
createdAt: string;
|
|
1010
1010
|
createdBy: string;
|
|
1011
1011
|
permission: number;
|
|
1012
|
-
}[];
|
|
1012
|
+
})[];
|
|
1013
1013
|
totalCount: any;
|
|
1014
1014
|
error?: undefined;
|
|
1015
1015
|
};
|
|
@@ -40,14 +40,14 @@ export declare const hasItemsSectionRouter: import("@trpc/server").TRPCBuiltRout
|
|
|
40
40
|
name: string;
|
|
41
41
|
title: string;
|
|
42
42
|
};
|
|
43
|
-
items: {
|
|
43
|
+
items: (Record<string, any> | {
|
|
44
44
|
id: string | number;
|
|
45
45
|
headingTitle: string;
|
|
46
46
|
coverPhoto: string | null;
|
|
47
47
|
createdAt: string;
|
|
48
48
|
createdBy: string;
|
|
49
49
|
permission: number;
|
|
50
|
-
}[];
|
|
50
|
+
})[];
|
|
51
51
|
totalCount: any;
|
|
52
52
|
error?: undefined;
|
|
53
53
|
};
|
|
@@ -117,10 +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>>;
|
|
121
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
122
120
|
name: z.ZodString;
|
|
123
121
|
order: z.ZodNumber;
|
|
122
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
124
123
|
db: z.ZodObject<{
|
|
125
124
|
table: z.ZodString;
|
|
126
125
|
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
@@ -160,6 +159,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
160
159
|
quality: z.ZodNumber;
|
|
161
160
|
}, z.core.$strict>>;
|
|
162
161
|
}, 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,10 +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>>;
|
|
218
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
219
217
|
name: z.ZodString;
|
|
220
218
|
order: z.ZodNumber;
|
|
219
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
221
220
|
db: z.ZodObject<{
|
|
222
221
|
table: z.ZodString;
|
|
223
222
|
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
@@ -257,6 +256,7 @@ export declare const categorySectionConfigSchema: z.ZodObject<{
|
|
|
257
256
|
quality: z.ZodNumber;
|
|
258
257
|
}, z.core.$strict>>;
|
|
259
258
|
}, 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>;
|
|
@@ -110,6 +110,9 @@ declare const configSchema: z.ZodObject<{
|
|
|
110
110
|
search: z.ZodOptional<z.ZodObject<{
|
|
111
111
|
searchFields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
112
112
|
}, z.core.$strict>>;
|
|
113
|
+
browse: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
fields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
115
|
+
}, z.core.$strict>>;
|
|
113
116
|
coverPhotoField: z.ZodOptional<z.ZodCustom<{
|
|
114
117
|
type: "photo";
|
|
115
118
|
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").PhotoField, import("../index.js").PhotoField>>;
|
|
@@ -185,6 +188,13 @@ export declare class HasItemsSection extends Section<Config> {
|
|
|
185
188
|
search?: {
|
|
186
189
|
readonly searchFields: readonly FieldConfig[];
|
|
187
190
|
} | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Browse configuration - for custom browse page implementations only.
|
|
193
|
+
* The default CMS browse page ignores this and uses its standard fields.
|
|
194
|
+
*/
|
|
195
|
+
browse?: {
|
|
196
|
+
readonly fields: readonly FieldConfig[];
|
|
197
|
+
} | undefined;
|
|
188
198
|
coverPhotoField?: PhotoFieldConfigType;
|
|
189
199
|
generateQR?: boolean | undefined;
|
|
190
200
|
constructor(config: BaseSectionOptions<Config>);
|
|
@@ -294,6 +304,9 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
294
304
|
search: z.ZodOptional<z.ZodObject<{
|
|
295
305
|
searchFields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
296
306
|
}, z.core.$strict>>;
|
|
307
|
+
browse: z.ZodOptional<z.ZodObject<{
|
|
308
|
+
fields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
309
|
+
}, z.core.$strict>>;
|
|
297
310
|
coverPhotoField: z.ZodOptional<z.ZodCustom<{
|
|
298
311
|
type: "photo";
|
|
299
312
|
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").PhotoField, import("../index.js").PhotoField>>;
|
|
@@ -355,10 +368,9 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
355
368
|
}>>;
|
|
356
369
|
generateQR: z.ZodOptional<z.ZodBoolean>;
|
|
357
370
|
fields: z.ZodUnion<[z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>, z.ZodArray<z.ZodCustom<FieldGroupConfig, FieldGroupConfig>>]>;
|
|
358
|
-
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
359
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
360
371
|
name: z.ZodString;
|
|
361
372
|
order: z.ZodNumber;
|
|
373
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
362
374
|
db: z.ZodObject<{
|
|
363
375
|
table: z.ZodString;
|
|
364
376
|
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
@@ -398,6 +410,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
398
410
|
quality: z.ZodNumber;
|
|
399
411
|
}, z.core.$strict>>;
|
|
400
412
|
}, z.core.$strict>>;
|
|
413
|
+
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
401
414
|
hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
|
|
402
415
|
}, z.core.$strict>;
|
|
403
416
|
declare const hasItemsSectionConfigSchema: z.ZodObject<{
|
|
@@ -509,6 +522,9 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
|
|
|
509
522
|
search: z.ZodOptional<z.ZodObject<{
|
|
510
523
|
searchFields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
511
524
|
}, z.core.$strict>>;
|
|
525
|
+
browse: z.ZodOptional<z.ZodObject<{
|
|
526
|
+
fields: z.ZodReadonly<z.ZodArray<z.ZodCustom<FieldConfig, FieldConfig>>>;
|
|
527
|
+
}, z.core.$strict>>;
|
|
512
528
|
coverPhotoField: z.ZodOptional<z.ZodCustom<{
|
|
513
529
|
type: "photo";
|
|
514
530
|
build: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodCustom<import("../index.js").PhotoField, import("../index.js").PhotoField>>;
|
|
@@ -569,10 +585,9 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
|
|
|
569
585
|
adminGenerated?: boolean | "readonly" | undefined;
|
|
570
586
|
}>>;
|
|
571
587
|
generateQR: z.ZodOptional<z.ZodBoolean>;
|
|
572
|
-
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
573
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
574
588
|
name: z.ZodString;
|
|
575
589
|
order: z.ZodNumber;
|
|
590
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
576
591
|
db: z.ZodObject<{
|
|
577
592
|
table: z.ZodString;
|
|
578
593
|
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
@@ -612,6 +627,7 @@ declare const hasItemsSectionConfigSchema: z.ZodObject<{
|
|
|
612
627
|
quality: z.ZodNumber;
|
|
613
628
|
}, z.core.$strict>>;
|
|
614
629
|
}, z.core.$strict>>;
|
|
630
|
+
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
615
631
|
hooks: z.ZodOptional<z.ZodCustom<import("./section.js").Hooks, import("./section.js").Hooks>>;
|
|
616
632
|
}, z.core.$strict>;
|
|
617
633
|
export type HasItemsSectionOptions = z.infer<typeof optionsSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasItems.d.ts","sourceRoot":"","sources":["../../../src/core/sections/hasItems.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,OAAO,EAA8E,MAAM,cAAc,CAAA;AAClH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"hasItems.d.ts","sourceRoot":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
30
|
+
.array(z.custom())
|
|
31
|
+
.readonly()
|
|
32
|
+
.describe('Custom browse fields - only use when creating a custom browse page implementation. ' +
|
|
33
|
+
'Fields must be configs - will be resolved during instantiation. '),
|
|
34
|
+
})
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Browse configuration - for custom browse page implementations only. ' +
|
|
37
|
+
'The default CMS browse page ignores this and uses its standard fields.'),
|
|
27
38
|
coverPhotoField: z
|
|
28
39
|
.custom()
|
|
29
40
|
.optional()
|
|
@@ -37,6 +48,11 @@ export class HasItemsSection extends Section {
|
|
|
37
48
|
title;
|
|
38
49
|
requirePublishPermission;
|
|
39
50
|
search;
|
|
51
|
+
/**
|
|
52
|
+
* Browse configuration - for custom browse page implementations only.
|
|
53
|
+
* The default CMS browse page ignores this and uses its standard fields.
|
|
54
|
+
*/
|
|
55
|
+
browse;
|
|
40
56
|
coverPhotoField;
|
|
41
57
|
generateQR;
|
|
42
58
|
// override variants?: Variant[] | undefined
|
|
@@ -46,6 +62,7 @@ export class HasItemsSection extends Section {
|
|
|
46
62
|
this.title = config.title;
|
|
47
63
|
this.requirePublishPermission = config.requirePublishPermission ?? false;
|
|
48
64
|
this.search = config.search;
|
|
65
|
+
this.browse = config.browse;
|
|
49
66
|
this.coverPhotoField = config.coverPhotoField;
|
|
50
67
|
this.generateQR = config.generateQR;
|
|
51
68
|
}
|
|
@@ -62,10 +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>>;
|
|
66
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<Variant, Variant>>>;
|
|
67
65
|
name: z.ZodString;
|
|
68
66
|
order: z.ZodNumber;
|
|
67
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
69
68
|
db: z.ZodObject<{
|
|
70
69
|
table: z.ZodString;
|
|
71
70
|
identifier: z.ZodOptional<z.ZodCustom<FieldConfig, FieldConfig>>;
|
|
@@ -105,16 +104,31 @@ export declare const baseHelperFunctionOptionsSchema: z.ZodObject<{
|
|
|
105
104
|
quality: z.ZodNumber;
|
|
106
105
|
}, z.core.$strict>>;
|
|
107
106
|
}, 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;
|
|
111
|
+
export type BeforeUpdateContext = {
|
|
112
|
+
itemId?: string | number;
|
|
113
|
+
values: Record<string, unknown>;
|
|
114
|
+
section: Section;
|
|
115
|
+
};
|
|
111
116
|
export type AfterUpdateContext = {
|
|
112
117
|
itemId?: string | number;
|
|
113
118
|
values: Record<string, unknown>;
|
|
114
119
|
section: Section;
|
|
115
120
|
};
|
|
121
|
+
export type OnErrorContext = {
|
|
122
|
+
itemId?: string | number;
|
|
123
|
+
values: Record<string, unknown>;
|
|
124
|
+
section: Section;
|
|
125
|
+
errorMessage: string;
|
|
126
|
+
error?: unknown;
|
|
127
|
+
};
|
|
116
128
|
export type Hooks = {
|
|
129
|
+
beforeUpdate?: (ctx: BeforeUpdateContext) => Promise<void> | void;
|
|
117
130
|
afterUpdate?: (ctx: AfterUpdateContext) => Promise<void> | void;
|
|
131
|
+
onError?: (ctx: OnErrorContext) => Promise<void> | void;
|
|
118
132
|
};
|
|
119
133
|
export declare abstract class Section<TExtraSectionConfig extends object = object> {
|
|
120
134
|
static readonly [entityKind]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../../../src/core/sections/section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE5E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,eAAO,MAAM,iBAAiB,uCAA0B,CAAA;AACxD,eAAO,MAAM,sBAAsB,iDAA+B,CAAA;AAIlE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmEnC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAa1C,CAAA;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAKtE;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAChB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../../../src/core/sections/section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,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A;YACd,IAAI,EAAE,OAAO,CAAA;YACb,OAAO,EAAE,MAAM,CAAA;SAClB,CAAA;KACJ,GACD,SAAS,CACd;IAwBD,OAAO,CAAC,gBAAgB;IAwBjB,WAAW,IAAI,IAAI;IAyB1B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;CAUvB;AAED,MAAM,MAAM,kBAAkB,CAAC,mBAAmB,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GAClH,mBAAmB,CAAA;AAEvB;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,kBAAkB,EAClE,OAAO,EAAE,CAAC,GACX,CAAC,GAAG;IAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG;QAAE,UAAU,EAAE,WAAW,CAAA;KAAE,CAAA;CAAE,CAwBnD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,kBAAkB,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAmBhF;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAAG;IAC7G,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAClC,CAYA"}
|
|
@@ -22,10 +22,9 @@ 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>>;
|
|
26
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
27
25
|
name: z.ZodString;
|
|
28
26
|
order: z.ZodNumber;
|
|
27
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
29
28
|
icon: z.ZodOptional<z.ZodString>;
|
|
30
29
|
gallery: z.ZodOptional<z.ZodObject<{
|
|
31
30
|
db: z.ZodObject<{
|
|
@@ -42,6 +41,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
42
41
|
quality: z.ZodNumber;
|
|
43
42
|
}, z.core.$strict>>;
|
|
44
43
|
}, 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,10 +53,9 @@ 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>>;
|
|
57
|
-
variants: z.ZodOptional<z.ZodArray<z.ZodCustom<import("../types/index.js").Variant, import("../types/index.js").Variant>>>;
|
|
58
56
|
name: z.ZodString;
|
|
59
57
|
order: z.ZodNumber;
|
|
58
|
+
readonly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
60
59
|
icon: z.ZodOptional<z.ZodString>;
|
|
61
60
|
gallery: z.ZodOptional<z.ZodObject<{
|
|
62
61
|
db: z.ZodObject<{
|
|
@@ -73,6 +72,7 @@ declare const simpleSectionConfigSchema: z.ZodObject<{
|
|
|
73
72
|
quality: z.ZodNumber;
|
|
74
73
|
}, z.core.$strict>>;
|
|
75
74
|
}, 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>;
|
|
@@ -26,11 +26,21 @@ export declare abstract class Submit {
|
|
|
26
26
|
* Constructor
|
|
27
27
|
*/
|
|
28
28
|
constructor({ preSubmit, sectionName, user, postData }: ConstructorType);
|
|
29
|
+
/**
|
|
30
|
+
* Run custom hooks before the item is updated
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
protected runPreSubmitHooks(): Promise<void>;
|
|
29
34
|
/**
|
|
30
35
|
* Run custom hooks after the item is updated
|
|
31
36
|
* @protected
|
|
32
37
|
*/
|
|
33
38
|
protected runPostSubmitHooks(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Run custom hooks when an error occurs
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
43
|
+
protected runErrorHooks(error?: unknown): Promise<void>;
|
|
34
44
|
/**
|
|
35
45
|
* Log operation to the database
|
|
36
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.d.ts","sourceRoot":"","sources":["../../../src/core/submit/submit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAM,MAAM,YAAY,CAAA;AAG3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,KAAK,eAAe,GAAG;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,CAAC,EAAE,OA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FL,aAAa;IAkF3B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,IAAI,OAAO,IAAI,MAAM,EAAE,GAAG,IAAI,CAE7B;IAED,OAAO,CAAC,SAAS;CAMpB"}
|
|
@@ -26,6 +26,23 @@ export class Submit {
|
|
|
26
26
|
this._postData = postData;
|
|
27
27
|
this.preSubmit = preSubmit ?? false;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Run custom hooks before the item is updated
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
33
|
+
async runPreSubmitHooks() {
|
|
34
|
+
try {
|
|
35
|
+
await this._sectionInfo.hooks?.beforeUpdate?.({
|
|
36
|
+
itemId: this._itemId,
|
|
37
|
+
values: this.sqlNamesAndValues,
|
|
38
|
+
section: this._sectionInfo,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
// Do not break the submit flow if a hook throws
|
|
43
|
+
console.error('beforeUpdate hook failed:', e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
29
46
|
/**
|
|
30
47
|
* Run custom hooks after the item is updated
|
|
31
48
|
* @protected
|
|
@@ -43,6 +60,28 @@ export class Submit {
|
|
|
43
60
|
console.error('afterUpdate hook failed:', e);
|
|
44
61
|
}
|
|
45
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Run custom hooks when an error occurs
|
|
65
|
+
* @protected
|
|
66
|
+
*/
|
|
67
|
+
async runErrorHooks(error) {
|
|
68
|
+
// Only run if sectionInfo is available
|
|
69
|
+
if (!this._sectionInfo)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
await this._sectionInfo.hooks?.onError?.({
|
|
73
|
+
itemId: this._itemId,
|
|
74
|
+
values: this.sqlNamesAndValues,
|
|
75
|
+
section: this._sectionInfo,
|
|
76
|
+
errorMessage: this._errorMessage,
|
|
77
|
+
error: error,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
// Do not break the submit flow if a hook throws
|
|
82
|
+
console.error('onError hook failed:', e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
46
85
|
/**
|
|
47
86
|
* Log operation to the database
|
|
48
87
|
*/
|
|
@@ -335,6 +374,10 @@ export class Submit {
|
|
|
335
374
|
if (this.preSubmit) {
|
|
336
375
|
return;
|
|
337
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Run pre-submit hooks (beforeUpdate)
|
|
379
|
+
*/
|
|
380
|
+
await this.runPreSubmitHooks();
|
|
338
381
|
/**
|
|
339
382
|
* Build the sql query
|
|
340
383
|
*/
|
|
@@ -368,6 +411,16 @@ export class Submit {
|
|
|
368
411
|
* Rollback the post submit operations for each field (if any)
|
|
369
412
|
*/
|
|
370
413
|
await this.postSubmitRollback();
|
|
414
|
+
/**
|
|
415
|
+
* Run error hooks
|
|
416
|
+
*/
|
|
417
|
+
await this.runErrorHooks({
|
|
418
|
+
itemId: this._itemId,
|
|
419
|
+
values: this.sqlNamesAndValues,
|
|
420
|
+
section: this._sectionInfo,
|
|
421
|
+
errorMessage: this._errorMessage,
|
|
422
|
+
error: this._error,
|
|
423
|
+
});
|
|
371
424
|
}
|
|
372
425
|
catch (e) {
|
|
373
426
|
/**
|