@nexpress/core 0.3.0 → 0.3.2

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 (76) hide show
  1. package/dist/auth.d.ts +26 -3
  2. package/dist/auth.js +5 -3
  3. package/dist/{can-FKIEV54H.js → can-UJ2NAOIR.js} +3 -3
  4. package/dist/{chunk-CHQJG4BB.js → chunk-2N53KKIL.js} +2 -2
  5. package/dist/{chunk-DWG3RZH2.js → chunk-2VZZ7M26.js} +2 -2
  6. package/dist/{chunk-4EPNN4XG.js → chunk-54KUQF3S.js} +2 -2
  7. package/dist/{chunk-QYP6E5FP.js → chunk-6UV2P5MW.js} +63 -50
  8. package/dist/chunk-6UV2P5MW.js.map +1 -0
  9. package/dist/{chunk-QSJIKNQJ.js → chunk-ANZBCOEH.js} +9 -9
  10. package/dist/{chunk-TD4KNSEP.js → chunk-C6HXDY46.js} +19 -19
  11. package/dist/{chunk-26RYBFTF.js → chunk-LMPYQLMH.js} +37 -5
  12. package/dist/chunk-LMPYQLMH.js.map +1 -0
  13. package/dist/{chunk-EVOBLRHW.js → chunk-M2FWG5OJ.js} +5 -5
  14. package/dist/chunk-P5WGQRSG.js +180 -0
  15. package/dist/chunk-P5WGQRSG.js.map +1 -0
  16. package/dist/{chunk-HM46WM45.js → chunk-RDTTK27V.js} +6 -6
  17. package/dist/{chunk-PQBJWZ7D.js → chunk-RJ76SKWQ.js} +4 -4
  18. package/dist/{chunk-74CGJJDY.js → chunk-RKM4GDWM.js} +1 -1
  19. package/dist/{chunk-CKT4QZDC.js → chunk-WJJ5MBH5.js} +5 -5
  20. package/dist/{chunk-DPRBHEHI.js → chunk-YOFCLTBR.js} +7 -4
  21. package/dist/chunk-YOFCLTBR.js.map +1 -0
  22. package/dist/{chunk-HTDDXBMY.js → chunk-ZA3IRJUQ.js} +81 -131
  23. package/dist/chunk-ZA3IRJUQ.js.map +1 -0
  24. package/dist/community.d.ts +1 -1
  25. package/dist/community.js +20 -19
  26. package/dist/{config-2Y2YGD25.js → config-O7QM2OQS.js} +8 -7
  27. package/dist/db-schema.d.ts +2 -2
  28. package/dist/db.d.ts +3 -3
  29. package/dist/db.js +1 -1
  30. package/dist/fields.d.ts +54 -0
  31. package/dist/fields.js +14 -0
  32. package/dist/{host-YSADWU7J.js → host-NI3LR774.js} +6 -5
  33. package/dist/i18n.d.ts +1 -1
  34. package/dist/i18n.js +1 -1
  35. package/dist/{index-9IhVtFfA.d.ts → index-CPp-zGgL.d.ts} +2 -2
  36. package/dist/{index-CXuqW_Gl.d.ts → index-DKoSaszT.d.ts} +1 -1
  37. package/dist/{index-ClcinJ29.d.ts → index-DymnczhP.d.ts} +1 -1
  38. package/dist/{index-7_PBSyOq.d.ts → index-UZn29S3i.d.ts} +1 -1
  39. package/dist/index.d.ts +102 -16
  40. package/dist/index.js +191 -79
  41. package/dist/index.js.map +1 -1
  42. package/dist/jobs.d.ts +2 -2
  43. package/dist/jobs.js +2 -2
  44. package/dist/media.d.ts +2 -2
  45. package/dist/media.js +2 -2
  46. package/dist/{mentions-NCQR4B72.js → mentions-U4JACYI6.js} +3 -3
  47. package/dist/{mutes-FJSSU2JP.js → mutes-MNQP6ACF.js} +3 -3
  48. package/dist/{scheduled-F77QCDOG.js → scheduled-BWJG35Z2.js} +7 -6
  49. package/dist/seo.d.ts +16 -3
  50. package/dist/seo.js +6 -5
  51. package/dist/{settings-JODDWMDB.js → settings-OZWM6L2K.js} +2 -2
  52. package/dist/settings-OZWM6L2K.js.map +1 -0
  53. package/dist/strings-4EWJYDOG.js +1 -1
  54. package/dist/{types-DI3gxsiY.d.ts → types-D31ppGJw.d.ts} +294 -2
  55. package/package.json +6 -1
  56. package/dist/chunk-26RYBFTF.js.map +0 -1
  57. package/dist/chunk-DPRBHEHI.js.map +0 -1
  58. package/dist/chunk-HTDDXBMY.js.map +0 -1
  59. package/dist/chunk-QYP6E5FP.js.map +0 -1
  60. /package/dist/{can-FKIEV54H.js.map → can-UJ2NAOIR.js.map} +0 -0
  61. /package/dist/{chunk-CHQJG4BB.js.map → chunk-2N53KKIL.js.map} +0 -0
  62. /package/dist/{chunk-DWG3RZH2.js.map → chunk-2VZZ7M26.js.map} +0 -0
  63. /package/dist/{chunk-4EPNN4XG.js.map → chunk-54KUQF3S.js.map} +0 -0
  64. /package/dist/{chunk-QSJIKNQJ.js.map → chunk-ANZBCOEH.js.map} +0 -0
  65. /package/dist/{chunk-TD4KNSEP.js.map → chunk-C6HXDY46.js.map} +0 -0
  66. /package/dist/{chunk-EVOBLRHW.js.map → chunk-M2FWG5OJ.js.map} +0 -0
  67. /package/dist/{chunk-HM46WM45.js.map → chunk-RDTTK27V.js.map} +0 -0
  68. /package/dist/{chunk-PQBJWZ7D.js.map → chunk-RJ76SKWQ.js.map} +0 -0
  69. /package/dist/{chunk-74CGJJDY.js.map → chunk-RKM4GDWM.js.map} +0 -0
  70. /package/dist/{chunk-CKT4QZDC.js.map → chunk-WJJ5MBH5.js.map} +0 -0
  71. /package/dist/{config-2Y2YGD25.js.map → config-O7QM2OQS.js.map} +0 -0
  72. /package/dist/{host-YSADWU7J.js.map → fields.js.map} +0 -0
  73. /package/dist/{mentions-NCQR4B72.js.map → host-NI3LR774.js.map} +0 -0
  74. /package/dist/{mutes-FJSSU2JP.js.map → mentions-U4JACYI6.js.map} +0 -0
  75. /package/dist/{scheduled-F77QCDOG.js.map → mutes-MNQP6ACF.js.map} +0 -0
  76. /package/dist/{settings-JODDWMDB.js.map → scheduled-BWJG35Z2.js.map} +0 -0
package/dist/index.js CHANGED
@@ -4,12 +4,15 @@ import {
4
4
  introspectThemeSettingsSchema,
5
5
  pluginConfigCacheTag,
6
6
  setPluginConfig
7
- } from "./chunk-EVOBLRHW.js";
7
+ } from "./chunk-M2FWG5OJ.js";
8
8
  import {
9
9
  getPluginTemplatesForCollection,
10
10
  registerPluginTemplates,
11
11
  resetPluginTemplates
12
12
  } from "./chunk-CRUQBZUF.js";
13
+ import {
14
+ extractMediaIds
15
+ } from "./chunk-TETTWT56.js";
13
16
  import {
14
17
  verifyStartupSafety
15
18
  } from "./chunk-B7DTNT4O.js";
@@ -38,7 +41,7 @@ import {
38
41
  renderSitemapIndexXml,
39
42
  renderSitemapXml,
40
43
  validateSeoSettingsPatch
41
- } from "./chunk-DPRBHEHI.js";
44
+ } from "./chunk-YOFCLTBR.js";
42
45
  import {
43
46
  ARGON2_OPTIONS,
44
47
  authenticated,
@@ -50,6 +53,7 @@ import {
50
53
  fromArctic,
51
54
  getMemberFromTokenPayload,
52
55
  getOAuthProvider,
56
+ getUserById,
53
57
  hashPassword,
54
58
  invalidateAllMemberSessions,
55
59
  invalidateAllSessions,
@@ -78,7 +82,7 @@ import {
78
82
  verifyPassword,
79
83
  verifyToken,
80
84
  verifyTokenFull
81
- } from "./chunk-QYP6E5FP.js";
85
+ } from "./chunk-6UV2P5MW.js";
82
86
  import {
83
87
  DEFAULT_REACTION_KINDS,
84
88
  addReaction,
@@ -126,18 +130,30 @@ import {
126
130
  unfollow,
127
131
  unresolvedReportCount,
128
132
  updateComment
129
- } from "./chunk-TD4KNSEP.js";
133
+ } from "./chunk-C6HXDY46.js";
134
+ import {
135
+ publishScheduledDocuments
136
+ } from "./chunk-54KUQF3S.js";
130
137
  import {
131
138
  buildDigestEmail,
132
139
  runDigestSweep
133
140
  } from "./chunk-LN6NTH6E.js";
141
+ import {
142
+ assertNotBanned,
143
+ getCommunityRole,
144
+ listCommunityRoles,
145
+ memberCan,
146
+ registerCommunityRole,
147
+ resetCommunityRoles,
148
+ withMemberWrite
149
+ } from "./chunk-RJ76SKWQ.js";
134
150
  import {
135
151
  getMutedTargetIds,
136
152
  isMuted,
137
153
  listMutes,
138
154
  muteMember,
139
155
  unmuteMember
140
- } from "./chunk-CKT4QZDC.js";
156
+ } from "./chunk-WJJ5MBH5.js";
141
157
  import {
142
158
  getMemberNotificationPrefs,
143
159
  isNotificationKindEnabled,
@@ -159,7 +175,7 @@ import {
159
175
  markNotificationsRead,
160
176
  resolveMentionedMembers,
161
177
  unreadNotificationCount
162
- } from "./chunk-HM46WM45.js";
178
+ } from "./chunk-RDTTK27V.js";
163
179
  import {
164
180
  applyReputation,
165
181
  getReputationAdapter,
@@ -177,23 +193,13 @@ import {
177
193
  setProfanityAdapter
178
194
  } from "./chunk-KU5M27ZC.js";
179
195
  import {
180
- publishScheduledDocuments
181
- } from "./chunk-4EPNN4XG.js";
182
- import {
183
- assertNotBanned,
184
- getCommunityRole,
185
- listCommunityRoles,
186
- memberCan,
187
- registerCommunityRole,
188
- resetCommunityRoles,
189
- withMemberWrite
190
- } from "./chunk-PQBJWZ7D.js";
196
+ getMediaUrl
197
+ } from "./chunk-2N53KKIL.js";
191
198
  import {
192
199
  autosaveRevision,
193
200
  buildSearchVector,
194
201
  buildSearchVectorParts,
195
202
  buildWeightedSearchVectorSql,
196
- buildZodSchema,
197
203
  checkNexpressCompat,
198
204
  compareSemver,
199
205
  createMemberDocument,
@@ -203,7 +209,6 @@ import {
203
209
  findDocuments,
204
210
  getAllPluginIds,
205
211
  getCollectionTabsForSlug,
206
- getCollectionZodSchema,
207
212
  getDashboardWidgetsFromPlugins,
208
213
  getDocumentById,
209
214
  getFrameworkVersion,
@@ -222,8 +227,21 @@ import {
222
227
  runPluginScheduledTask,
223
228
  saveDocument,
224
229
  schedulePluginTask,
225
- updateMemberDocument
226
- } from "./chunk-HTDDXBMY.js";
230
+ updateMemberDocument,
231
+ withDeferredPostCommit
232
+ } from "./chunk-ZA3IRJUQ.js";
233
+ import {
234
+ DEFAULT_IMAGE_SIZES,
235
+ cleanupDeletedMedia,
236
+ deleteMedia,
237
+ getMediaById,
238
+ getStorageAdapter,
239
+ listMedia,
240
+ processImage,
241
+ processMediaImage,
242
+ setStorageAdapter,
243
+ uploadMedia
244
+ } from "./chunk-2VZZ7M26.js";
227
245
  import {
228
246
  can
229
247
  } from "./chunk-EQ2Z3KMD.js";
@@ -236,13 +254,13 @@ import {
236
254
  getCommunitySettings,
237
255
  updateCommunitySettings,
238
256
  validateCommunitySettingsPatch
239
- } from "./chunk-74CGJJDY.js";
257
+ } from "./chunk-RKM4GDWM.js";
240
258
  import {
241
259
  createDbConnection,
242
260
  generateDocumentsModule,
243
261
  generateDrizzleSchema,
244
262
  generateTypeScript
245
- } from "./chunk-26RYBFTF.js";
263
+ } from "./chunk-LMPYQLMH.js";
246
264
  import {
247
265
  npMediaFoldersRelations,
248
266
  npMediaRefsRelations,
@@ -253,6 +271,12 @@ import {
253
271
  npSettingsRelations,
254
272
  npUsersRelations
255
273
  } from "./chunk-2KNG5KMM.js";
274
+ import {
275
+ buildZodSchema,
276
+ collectHiddenFieldNames,
277
+ evaluateFieldCondition,
278
+ getCollectionZodSchema
279
+ } from "./chunk-P5WGQRSG.js";
256
280
  import {
257
281
  formatDate,
258
282
  formatNumber,
@@ -303,6 +327,12 @@ import {
303
327
  resolveSiteForHostname,
304
328
  updateSite
305
329
  } from "./chunk-U4QCCLAW.js";
330
+ import {
331
+ getCurrentSiteId,
332
+ resetCurrentSiteResolver,
333
+ setCurrentSiteResolver,
334
+ withCurrentSite
335
+ } from "./chunk-SBCVAC2Z.js";
306
336
  import {
307
337
  NpAuthError,
308
338
  NpConflictError,
@@ -313,12 +343,6 @@ import {
313
343
  NpSiteContextMissingError,
314
344
  NpValidationError
315
345
  } from "./chunk-ZCINJSS4.js";
316
- import {
317
- getCurrentSiteId,
318
- resetCurrentSiteResolver,
319
- setCurrentSiteResolver,
320
- withCurrentSite
321
- } from "./chunk-SBCVAC2Z.js";
322
346
  import {
323
347
  PAUSE_SYNC_INTERVAL_MS,
324
348
  PgBossAdapter,
@@ -342,7 +366,7 @@ import {
342
366
  startWorker,
343
367
  stopProducer,
344
368
  stopWorker
345
- } from "./chunk-QSJIKNQJ.js";
369
+ } from "./chunk-ANZBCOEH.js";
346
370
  import {
347
371
  DEFAULT_JOB_LOG_RETENTION_MS,
348
372
  countJobLogs,
@@ -358,6 +382,12 @@ import {
358
382
  resetEmailAdapter,
359
383
  setEmailAdapter
360
384
  } from "./chunk-LSHHRDVR.js";
385
+ import {
386
+ enqueueJob,
387
+ getJobQueue,
388
+ getOptionalJobQueue,
389
+ setJobQueue
390
+ } from "./chunk-V2UNHGAP.js";
361
391
  import {
362
392
  getErrorReporter,
363
393
  noopErrorReporter,
@@ -365,30 +395,6 @@ import {
365
395
  resetErrorReporter,
366
396
  setErrorReporter
367
397
  } from "./chunk-WV272MPW.js";
368
- import {
369
- extractMediaIds
370
- } from "./chunk-TETTWT56.js";
371
- import {
372
- getMediaUrl
373
- } from "./chunk-CHQJG4BB.js";
374
- import {
375
- DEFAULT_IMAGE_SIZES,
376
- cleanupDeletedMedia,
377
- deleteMedia,
378
- getMediaById,
379
- getStorageAdapter,
380
- listMedia,
381
- processImage,
382
- processMediaImage,
383
- setStorageAdapter,
384
- uploadMedia
385
- } from "./chunk-DWG3RZH2.js";
386
- import {
387
- enqueueJob,
388
- getJobQueue,
389
- getOptionalJobQueue,
390
- setJobQueue
391
- } from "./chunk-V2UNHGAP.js";
392
398
  import "./chunk-OROPGO65.js";
393
399
  import {
394
400
  consoleLogger,
@@ -471,7 +477,15 @@ var SUPPORTED_REQUIREMENT_TYPES = /* @__PURE__ */ new Set([
471
477
  "relationship",
472
478
  "blocks"
473
479
  ]);
474
- function requirementToField(name, req) {
480
+ function buildAdminSlot(req, themeId) {
481
+ const out = { _themeOrigin: themeId };
482
+ if (req.admin?.group !== void 0) out.group = req.admin.group;
483
+ if (req.admin?.condition !== void 0) out.condition = req.admin.condition;
484
+ if (req.admin?.position !== void 0) out.position = req.admin.position;
485
+ return out;
486
+ }
487
+ function requirementToField(name, req, themeId) {
488
+ const admin = buildAdminSlot(req, themeId);
475
489
  switch (req.type) {
476
490
  case "text":
477
491
  case "textarea":
@@ -480,7 +494,7 @@ function requirementToField(name, req) {
480
494
  case "checkbox":
481
495
  case "date":
482
496
  case "blocks":
483
- return { type: req.type, name };
497
+ return admin ? { type: req.type, name, admin } : { type: req.type, name };
484
498
  case "upload": {
485
499
  if (!req.relationTo || Array.isArray(req.relationTo)) {
486
500
  log().warn(
@@ -489,11 +503,12 @@ function requirementToField(name, req) {
489
503
  );
490
504
  return null;
491
505
  }
492
- return {
506
+ const base = {
493
507
  type: "upload",
494
508
  name,
495
509
  relationTo: req.relationTo
496
510
  };
511
+ return admin ? { ...base, admin } : base;
497
512
  }
498
513
  case "relationship": {
499
514
  if (!req.relationTo) {
@@ -508,14 +523,24 @@ function requirementToField(name, req) {
508
523
  name,
509
524
  relationTo: req.relationTo
510
525
  };
511
- return req.hasMany ? { ...baseField, hasMany: true } : baseField;
526
+ const withMany = req.hasMany ? { ...baseField, hasMany: true } : baseField;
527
+ return admin ? { ...withMany, admin } : withMany;
528
+ }
529
+ case "select": {
530
+ if (!req.options || req.options.length === 0) {
531
+ log().warn(
532
+ "Skipping theme-required select field: requirement is missing an `options` list.",
533
+ { field: name }
534
+ );
535
+ return null;
536
+ }
537
+ const base = {
538
+ type: "select",
539
+ name,
540
+ options: [...req.options]
541
+ };
542
+ return admin ? { ...base, admin } : base;
512
543
  }
513
- case "select":
514
- log().warn(
515
- "Skipping theme-required select field: cannot synthesise without an options list.",
516
- { field: name }
517
- );
518
- return null;
519
544
  default: {
520
545
  const _exhaustive = req.type;
521
546
  void _exhaustive;
@@ -527,6 +552,23 @@ function requirementToField(name, req) {
527
552
  }
528
553
  }
529
554
  }
555
+ function mergeSelectOptions(base, contribution) {
556
+ if (contribution.length === 0) return base;
557
+ const byValue = new Map(base.map((o) => [o.value, o]));
558
+ let changed = false;
559
+ for (const opt of contribution) {
560
+ const existing = byValue.get(opt.value);
561
+ if (!existing) {
562
+ byValue.set(opt.value, opt);
563
+ changed = true;
564
+ } else if (existing.label !== opt.label) {
565
+ byValue.set(opt.value, opt);
566
+ changed = true;
567
+ }
568
+ }
569
+ if (!changed) return base;
570
+ return Array.from(byValue.values());
571
+ }
530
572
  function collectExistingFieldNames(fields) {
531
573
  const names = /* @__PURE__ */ new Set();
532
574
  for (const f of fields) {
@@ -549,11 +591,11 @@ function synthesiseCollection(slug, requirement, injectedNames, themeId) {
549
591
  const fields = [];
550
592
  for (const [fieldName, fieldReq] of Object.entries(requirement.fields ?? {})) {
551
593
  if (!SUPPORTED_REQUIREMENT_TYPES.has(fieldReq.type)) {
552
- const synth2 = requirementToField(fieldName, fieldReq);
594
+ const synth2 = requirementToField(fieldName, fieldReq, themeId);
553
595
  if (synth2) fields.push(synth2);
554
596
  continue;
555
597
  }
556
- const synth = requirementToField(fieldName, fieldReq);
598
+ const synth = requirementToField(fieldName, fieldReq, themeId);
557
599
  if (synth) {
558
600
  fields.push(synth);
559
601
  injectedNames.add(fieldName);
@@ -606,11 +648,36 @@ function mergeThemeRequirements(collections, themes) {
606
648
  continue;
607
649
  }
608
650
  const reqFields = req.fields;
609
- if (!reqFields) continue;
651
+ const reqKinds = req.kinds;
652
+ if (!reqFields && !reqKinds) continue;
610
653
  const alreadyDeclared = existingFieldsBySlug.get(slug) ?? /* @__PURE__ */ new Set();
611
- const toAdd = [];
612
- for (const [fieldName, fieldReq] of Object.entries(reqFields)) {
654
+ const target = merged[existingIndex];
655
+ if (!target) continue;
656
+ let nextFields = target.fields;
657
+ let fieldsCloned = false;
658
+ const ensureCloned = () => {
659
+ if (!fieldsCloned) {
660
+ nextFields = [...nextFields];
661
+ fieldsCloned = true;
662
+ }
663
+ return nextFields;
664
+ };
665
+ for (const [fieldName, fieldReq] of Object.entries(reqFields ?? {})) {
613
666
  if (alreadyDeclared.has(fieldName)) {
667
+ if (fieldReq.type === "select" && fieldReq.options && fieldReq.options.length > 0) {
668
+ const idx = nextFields.findIndex(
669
+ (f) => "name" in f && f.name === fieldName
670
+ );
671
+ const existing = idx >= 0 ? nextFields[idx] : void 0;
672
+ if (existing && existing.type === "select") {
673
+ const merged2 = mergeSelectOptions(existing.options, fieldReq.options);
674
+ if (merged2 !== existing.options) {
675
+ const list = ensureCloned();
676
+ list[idx] = { ...existing, options: [...merged2] };
677
+ }
678
+ continue;
679
+ }
680
+ }
614
681
  const injectedHere2 = stats.injected.get(slug);
615
682
  if (injectedHere2?.has(fieldName)) {
616
683
  log().warn(
@@ -620,9 +687,9 @@ function mergeThemeRequirements(collections, themes) {
620
687
  }
621
688
  continue;
622
689
  }
623
- const synth = requirementToField(fieldName, fieldReq);
690
+ const synth = requirementToField(fieldName, fieldReq, theme.manifest.id);
624
691
  if (!synth) continue;
625
- toAdd.push(synth);
692
+ ensureCloned().push(synth);
626
693
  alreadyDeclared.add(fieldName);
627
694
  let injectedHere = stats.injected.get(slug);
628
695
  if (!injectedHere) {
@@ -631,12 +698,39 @@ function mergeThemeRequirements(collections, themes) {
631
698
  }
632
699
  injectedHere.add(fieldName);
633
700
  }
634
- if (toAdd.length === 0) continue;
635
- const target = merged[existingIndex];
636
- if (!target) continue;
701
+ let nextAdmin = target.admin;
702
+ let adminCloned = false;
703
+ if (reqKinds && Object.keys(reqKinds).length > 0) {
704
+ const existingKinds = target.admin?.kinds ?? {};
705
+ const mergedKinds = { ...existingKinds };
706
+ for (const [kindValue, kindMeta] of Object.entries(reqKinds)) {
707
+ mergedKinds[kindValue] = {
708
+ ...mergedKinds[kindValue] ?? {},
709
+ ...kindMeta,
710
+ _themeOrigin: theme.manifest.id
711
+ };
712
+ }
713
+ nextAdmin = { ...target.admin ?? {}, kinds: mergedKinds };
714
+ adminCloned = true;
715
+ }
716
+ const reqGroupMeta = req.groupMeta;
717
+ if (reqGroupMeta && Object.keys(reqGroupMeta).length > 0) {
718
+ const existingMeta = nextAdmin?.groupMeta ?? target.admin?.groupMeta ?? {};
719
+ const mergedMeta = { ...existingMeta };
720
+ for (const [groupName, meta] of Object.entries(reqGroupMeta)) {
721
+ mergedMeta[groupName] = {
722
+ ...mergedMeta[groupName] ?? {},
723
+ ...meta
724
+ };
725
+ }
726
+ nextAdmin = { ...nextAdmin ?? target.admin ?? {}, groupMeta: mergedMeta };
727
+ adminCloned = true;
728
+ }
729
+ if (!fieldsCloned && !adminCloned) continue;
637
730
  merged[existingIndex] = {
638
731
  ...target,
639
- fields: [...target.fields, ...toAdd]
732
+ ...fieldsCloned ? { fields: nextFields } : {},
733
+ ...adminCloned ? { admin: nextAdmin } : {}
640
734
  };
641
735
  existingFieldsBySlug.set(slug, alreadyDeclared);
642
736
  }
@@ -649,6 +743,17 @@ import { z } from "zod";
649
743
  var functionSchema = z.custom(
650
744
  (value) => typeof value === "function"
651
745
  );
746
+ var conditionExprSchema = z.lazy(
747
+ () => z.union([
748
+ z.object({ when: z.string().min(1), equals: z.unknown() }),
749
+ z.object({ when: z.string().min(1), notEquals: z.unknown() }),
750
+ z.object({ when: z.string().min(1), in: z.array(z.unknown()) }),
751
+ z.object({ when: z.string().min(1), notIn: z.array(z.unknown()) }),
752
+ z.object({ when: z.string().min(1), exists: z.boolean() }),
753
+ z.object({ all: z.array(conditionExprSchema) }),
754
+ z.object({ any: z.array(conditionExprSchema) })
755
+ ])
756
+ );
652
757
  var fieldBaseSchema = z.object({
653
758
  name: z.string().min(1),
654
759
  label: z.string().min(1).optional(),
@@ -659,7 +764,10 @@ var fieldBaseSchema = z.object({
659
764
  description: z.string().min(1).optional(),
660
765
  placeholder: z.string().optional(),
661
766
  readOnly: z.boolean().optional(),
662
- condition: functionSchema.optional(),
767
+ // Accepts either the legacy function form (server-only, stripped
768
+ // at the RSC boundary) or the serializable expression form
769
+ // (#764). The runtime evaluator handles both.
770
+ condition: z.union([functionSchema, conditionExprSchema]).optional(),
663
771
  width: z.string().optional()
664
772
  }).optional(),
665
773
  validate: functionSchema.optional()
@@ -1038,7 +1146,7 @@ async function getActiveTheme() {
1038
1146
  const first = registry.values().next();
1039
1147
  return first.done ? null : first.value;
1040
1148
  }
1041
- async function setActiveThemeId(id, updatedBy = null) {
1149
+ async function setActiveThemeId(id, updatedBy = null, options = {}) {
1042
1150
  if (!registry.has(id)) {
1043
1151
  throw new NpValidationError("Invalid input", [
1044
1152
  {
@@ -1047,10 +1155,10 @@ async function setActiveThemeId(id, updatedBy = null) {
1047
1155
  }
1048
1156
  ]);
1049
1157
  }
1050
- const db = getDb();
1158
+ const dbHandle = options.tx ?? getDb();
1051
1159
  const now = /* @__PURE__ */ new Date();
1052
1160
  const siteId = await getCurrentSiteId() ?? NP_DEFAULT_SITE_ID;
1053
- await db.insert(npSettings).values({ siteId, key: "activeTheme", value: id, updatedAt: now, updatedBy }).onConflictDoUpdate({
1161
+ await dbHandle.insert(npSettings).values({ siteId, key: "activeTheme", value: id, updatedAt: now, updatedBy }).onConflictDoUpdate({
1054
1162
  target: [npSettings.siteId, npSettings.key],
1055
1163
  set: { value: id, updatedAt: now, updatedBy }
1056
1164
  });
@@ -2032,6 +2140,7 @@ export {
2032
2140
  cleanupDeletedMedia,
2033
2141
  clearCustomRoutes,
2034
2142
  clearStringOverrideCacheForSite,
2143
+ collectHiddenFieldNames,
2035
2144
  collectionConfigSchema,
2036
2145
  compareSemver,
2037
2146
  configureBuiltinJobContext,
@@ -2062,6 +2171,7 @@ export {
2062
2171
  dispatchPluginAction,
2063
2172
  enqueueJob,
2064
2173
  ensureDefaultSite,
2174
+ evaluateFieldCondition,
2065
2175
  extractErrorComponent,
2066
2176
  extractMediaIds,
2067
2177
  extractMembersNotFoundComponent,
@@ -2166,6 +2276,7 @@ export {
2166
2276
  getThemeSettingsWithStatus,
2167
2277
  getThemeTemplateSummaries,
2168
2278
  getTranslationProgress,
2279
+ getUserById,
2169
2280
  grantMemberRole,
2170
2281
  grantSiteMembership,
2171
2282
  hasRoleOnSite,
@@ -2393,6 +2504,7 @@ export {
2393
2504
  verifyToken,
2394
2505
  verifyTokenFull,
2395
2506
  withCurrentSite,
2507
+ withDeferredPostCommit,
2396
2508
  withMemberWrite
2397
2509
  };
2398
2510
  //# sourceMappingURL=index.js.map