@nexpress/core 0.3.8 → 0.3.10

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 (61) hide show
  1. package/dist/auth.js +2 -2
  2. package/dist/{can-U5F4JBZ7.js → can-2CHRJ2FK.js} +3 -3
  3. package/dist/{chunk-6PFUXZJ6.js → chunk-2LNXTEBM.js} +9 -9
  4. package/dist/{chunk-XPD7EQML.js → chunk-5NCTIJEN.js} +3 -3
  5. package/dist/{chunk-EWVXP3GP.js → chunk-A3DPN2SP.js} +2 -2
  6. package/dist/{chunk-XU2GJJ6Z.js → chunk-BGEPMNVB.js} +2 -2
  7. package/dist/{chunk-VX3HM5TF.js → chunk-IT4JBQK4.js} +3 -3
  8. package/dist/{chunk-PPUHXOWZ.js → chunk-JMNDARCQ.js} +3 -3
  9. package/dist/{chunk-CD74WQK7.js → chunk-K4IYOAZJ.js} +15 -15
  10. package/dist/{chunk-CD74WQK7.js.map → chunk-K4IYOAZJ.js.map} +1 -1
  11. package/dist/{chunk-6MRTH734.js → chunk-KNSOZ2NN.js} +2 -2
  12. package/dist/{chunk-YEOQJ7WW.js → chunk-KS3S6TJS.js} +2 -2
  13. package/dist/{chunk-TIWJVQOO.js → chunk-LDY26JKB.js} +2 -2
  14. package/dist/{chunk-2X3GBJOT.js → chunk-MLQKHRW2.js} +2 -2
  15. package/dist/{chunk-U4QCCLAW.js → chunk-MYUCR3SE.js} +4 -3
  16. package/dist/{chunk-U4QCCLAW.js.map → chunk-MYUCR3SE.js.map} +1 -1
  17. package/dist/{chunk-EAYUAXW3.js → chunk-PXVCVEXV.js} +2 -2
  18. package/dist/{chunk-JKTU67A7.js → chunk-RCK73HJI.js} +2 -2
  19. package/dist/{chunk-2O2KMHLO.js → chunk-UVLDAY4U.js} +7 -7
  20. package/dist/{chunk-K4CJ3KXB.js → chunk-X43DI2QJ.js} +2 -2
  21. package/dist/community.js +11 -11
  22. package/dist/{config-2CV7KZ3D.js → config-WD2IMHKB.js} +5 -5
  23. package/dist/{digest-IWHMJPXI.js → digest-U4X45I74.js} +3 -3
  24. package/dist/{host-C5PGUXX7.js → host-6EAJQRCL.js} +4 -4
  25. package/dist/i18n.js +2 -2
  26. package/dist/index.js +99 -18
  27. package/dist/index.js.map +1 -1
  28. package/dist/jobs.js +1 -1
  29. package/dist/media.js +2 -2
  30. package/dist/{mentions-LQRZWAGO.js → mentions-FRPM6LOO.js} +3 -3
  31. package/dist/{mutes-PQA6U5X7.js → mutes-2JEKADIG.js} +3 -3
  32. package/dist/{registry-WZVL5HH6.js → registry-JMMSOTJI.js} +2 -2
  33. package/dist/{scheduled-PF2HECSF.js → scheduled-N34EKDIJ.js} +5 -5
  34. package/dist/seo.js +4 -4
  35. package/dist/{settings-NBAP7E5E.js → settings-5PH4SNIX.js} +2 -2
  36. package/dist/{strings-O2M7VSKV.js → strings-CKOSVH45.js} +3 -3
  37. package/package.json +1 -1
  38. /package/dist/{can-U5F4JBZ7.js.map → can-2CHRJ2FK.js.map} +0 -0
  39. /package/dist/{chunk-6PFUXZJ6.js.map → chunk-2LNXTEBM.js.map} +0 -0
  40. /package/dist/{chunk-XPD7EQML.js.map → chunk-5NCTIJEN.js.map} +0 -0
  41. /package/dist/{chunk-EWVXP3GP.js.map → chunk-A3DPN2SP.js.map} +0 -0
  42. /package/dist/{chunk-XU2GJJ6Z.js.map → chunk-BGEPMNVB.js.map} +0 -0
  43. /package/dist/{chunk-VX3HM5TF.js.map → chunk-IT4JBQK4.js.map} +0 -0
  44. /package/dist/{chunk-PPUHXOWZ.js.map → chunk-JMNDARCQ.js.map} +0 -0
  45. /package/dist/{chunk-6MRTH734.js.map → chunk-KNSOZ2NN.js.map} +0 -0
  46. /package/dist/{chunk-YEOQJ7WW.js.map → chunk-KS3S6TJS.js.map} +0 -0
  47. /package/dist/{chunk-TIWJVQOO.js.map → chunk-LDY26JKB.js.map} +0 -0
  48. /package/dist/{chunk-2X3GBJOT.js.map → chunk-MLQKHRW2.js.map} +0 -0
  49. /package/dist/{chunk-EAYUAXW3.js.map → chunk-PXVCVEXV.js.map} +0 -0
  50. /package/dist/{chunk-JKTU67A7.js.map → chunk-RCK73HJI.js.map} +0 -0
  51. /package/dist/{chunk-2O2KMHLO.js.map → chunk-UVLDAY4U.js.map} +0 -0
  52. /package/dist/{chunk-K4CJ3KXB.js.map → chunk-X43DI2QJ.js.map} +0 -0
  53. /package/dist/{config-2CV7KZ3D.js.map → config-WD2IMHKB.js.map} +0 -0
  54. /package/dist/{digest-IWHMJPXI.js.map → digest-U4X45I74.js.map} +0 -0
  55. /package/dist/{host-C5PGUXX7.js.map → host-6EAJQRCL.js.map} +0 -0
  56. /package/dist/{mentions-LQRZWAGO.js.map → mentions-FRPM6LOO.js.map} +0 -0
  57. /package/dist/{mutes-PQA6U5X7.js.map → mutes-2JEKADIG.js.map} +0 -0
  58. /package/dist/{registry-WZVL5HH6.js.map → registry-JMMSOTJI.js.map} +0 -0
  59. /package/dist/{scheduled-PF2HECSF.js.map → scheduled-N34EKDIJ.js.map} +0 -0
  60. /package/dist/{settings-NBAP7E5E.js.map → settings-5PH4SNIX.js.map} +0 -0
  61. /package/dist/{strings-O2M7VSKV.js.map → strings-CKOSVH45.js.map} +0 -0
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  introspectThemeSettingsSchema,
5
5
  pluginConfigCacheTag,
6
6
  setPluginConfig
7
- } from "./chunk-JKTU67A7.js";
7
+ } from "./chunk-RCK73HJI.js";
8
8
  import {
9
9
  getPluginTemplatesForCollection,
10
10
  registerPluginTemplates,
@@ -41,7 +41,7 @@ import {
41
41
  renderSitemapIndexXml,
42
42
  renderSitemapXml,
43
43
  validateSeoSettingsPatch
44
- } from "./chunk-VX3HM5TF.js";
44
+ } from "./chunk-IT4JBQK4.js";
45
45
  import {
46
46
  ARGON2_OPTIONS,
47
47
  authenticated,
@@ -82,7 +82,7 @@ import {
82
82
  verifyPassword,
83
83
  verifyToken,
84
84
  verifyTokenFull
85
- } from "./chunk-TIWJVQOO.js";
85
+ } from "./chunk-LDY26JKB.js";
86
86
  import {
87
87
  DEFAULT_REACTION_KINDS,
88
88
  addReaction,
@@ -130,14 +130,14 @@ import {
130
130
  unfollow,
131
131
  unresolvedReportCount,
132
132
  updateComment
133
- } from "./chunk-6PFUXZJ6.js";
133
+ } from "./chunk-2LNXTEBM.js";
134
134
  import {
135
135
  publishScheduledDocuments
136
- } from "./chunk-PPUHXOWZ.js";
136
+ } from "./chunk-JMNDARCQ.js";
137
137
  import {
138
138
  buildDigestEmail,
139
139
  runDigestSweep
140
- } from "./chunk-K4CJ3KXB.js";
140
+ } from "./chunk-X43DI2QJ.js";
141
141
  import {
142
142
  assertNotBanned,
143
143
  getCommunityRole,
@@ -146,14 +146,14 @@ import {
146
146
  registerCommunityRole,
147
147
  resetCommunityRoles,
148
148
  withMemberWrite
149
- } from "./chunk-XU2GJJ6Z.js";
149
+ } from "./chunk-BGEPMNVB.js";
150
150
  import {
151
151
  getMutedTargetIds,
152
152
  isMuted,
153
153
  listMutes,
154
154
  muteMember,
155
155
  unmuteMember
156
- } from "./chunk-YEOQJ7WW.js";
156
+ } from "./chunk-KS3S6TJS.js";
157
157
  import {
158
158
  getMemberNotificationPrefs,
159
159
  isNotificationKindEnabled,
@@ -175,7 +175,7 @@ import {
175
175
  markNotificationsRead,
176
176
  resolveMentionedMembers,
177
177
  unreadNotificationCount
178
- } from "./chunk-XPD7EQML.js";
178
+ } from "./chunk-5NCTIJEN.js";
179
179
  import {
180
180
  applyReputation,
181
181
  getReputationAdapter,
@@ -194,7 +194,7 @@ import {
194
194
  } from "./chunk-KU5M27ZC.js";
195
195
  import {
196
196
  getMediaUrl
197
- } from "./chunk-EWVXP3GP.js";
197
+ } from "./chunk-A3DPN2SP.js";
198
198
  import {
199
199
  autosaveRevision,
200
200
  buildSearchVector,
@@ -229,7 +229,7 @@ import {
229
229
  schedulePluginTask,
230
230
  updateMemberDocument,
231
231
  withDeferredPostCommit
232
- } from "./chunk-CD74WQK7.js";
232
+ } from "./chunk-K4IYOAZJ.js";
233
233
  import {
234
234
  DEFAULT_IMAGE_SIZES,
235
235
  cleanupDeletedMedia,
@@ -241,7 +241,7 @@ import {
241
241
  processMediaImage,
242
242
  setStorageAdapter,
243
243
  uploadMedia
244
- } from "./chunk-EAYUAXW3.js";
244
+ } from "./chunk-PXVCVEXV.js";
245
245
  import {
246
246
  can
247
247
  } from "./chunk-EQ2Z3KMD.js";
@@ -254,7 +254,7 @@ import {
254
254
  getCommunitySettings,
255
255
  updateCommunitySettings,
256
256
  validateCommunitySettingsPatch
257
- } from "./chunk-6MRTH734.js";
257
+ } from "./chunk-KNSOZ2NN.js";
258
258
  import {
259
259
  createDbConnection,
260
260
  generateDocumentsModule,
@@ -303,7 +303,7 @@ import {
303
303
  setStrings,
304
304
  t,
305
305
  tSync
306
- } from "./chunk-2X3GBJOT.js";
306
+ } from "./chunk-MLQKHRW2.js";
307
307
  import {
308
308
  getI18nConfig,
309
309
  resetI18nConfig,
@@ -326,7 +326,7 @@ import {
326
326
  registerCollection,
327
327
  resolveSiteForHostname,
328
328
  updateSite
329
- } from "./chunk-U4QCCLAW.js";
329
+ } from "./chunk-MYUCR3SE.js";
330
330
  import {
331
331
  getCurrentSiteId,
332
332
  resetCurrentSiteResolver,
@@ -366,7 +366,7 @@ import {
366
366
  startWorker,
367
367
  stopProducer,
368
368
  stopWorker
369
- } from "./chunk-2O2KMHLO.js";
369
+ } from "./chunk-UVLDAY4U.js";
370
370
  import {
371
371
  DEFAULT_JOB_LOG_RETENTION_MS,
372
372
  countJobLogs,
@@ -1058,7 +1058,7 @@ function defineCollection(config) {
1058
1058
  }
1059
1059
 
1060
1060
  // src/content/helpers.ts
1061
- import { and as and2, desc, eq as eq2 } from "drizzle-orm";
1061
+ import { and as and2, desc, eq as eq2, getTableColumns, inArray } from "drizzle-orm";
1062
1062
 
1063
1063
  // src/theme/defaults.ts
1064
1064
  var DEFAULT_THEME = {
@@ -1327,7 +1327,88 @@ async function getPostBySlug(slug, options) {
1327
1327
  return result.docs[0] ?? null;
1328
1328
  }
1329
1329
  async function findPosts(options, user) {
1330
- return findDocuments("posts", options, user);
1330
+ const resolved = await resolveHasManyRelationshipWhere("posts", options);
1331
+ if (resolved.empty) {
1332
+ return emptyFindResult(options);
1333
+ }
1334
+ return findDocuments("posts", { ...options, where: resolved.where }, user);
1335
+ }
1336
+ function emptyFindResult(options) {
1337
+ const limit = options.limit ?? 20;
1338
+ return {
1339
+ docs: [],
1340
+ totalDocs: 0,
1341
+ totalPages: 0,
1342
+ page: options.page ?? 1,
1343
+ limit,
1344
+ hasNextPage: false,
1345
+ hasPrevPage: false
1346
+ };
1347
+ }
1348
+ async function resolveHasManyRelationshipWhere(collectionSlug, options) {
1349
+ const where = options.where ? { ...options.where } : {};
1350
+ const registration = getCollectionRegistration(collectionSlug);
1351
+ const joinTables = registration.joinTables ?? {};
1352
+ const matchedIds = [];
1353
+ for (const field of registration.config.fields) {
1354
+ if (field.type !== "relationship" || !field.hasMany) continue;
1355
+ const value = where[field.name];
1356
+ if (value === void 0) continue;
1357
+ const table = joinTables[field.name];
1358
+ if (!table) {
1359
+ throw new Error(
1360
+ `Collection "${collectionSlug}" relationship field "${field.name}" has no registered join table.`
1361
+ );
1362
+ }
1363
+ delete where[field.name];
1364
+ const targetIds = (Array.isArray(value) ? value : [value]).filter(
1365
+ (item) => typeof item === "string" && item.length > 0
1366
+ );
1367
+ if (targetIds.length === 0) {
1368
+ matchedIds.push([]);
1369
+ continue;
1370
+ }
1371
+ const pgTable = table;
1372
+ const rows = await getDb().select({ id: parentColumn(pgTable) }).from(pgTable).where(inArray(column(pgTable, "targetId"), targetIds));
1373
+ matchedIds.push(rows.map((row) => String(row.id)));
1374
+ }
1375
+ if (matchedIds.length === 0) {
1376
+ return { where, empty: false };
1377
+ }
1378
+ let ids = matchedIds[0] ?? [];
1379
+ for (let i = 1; i < matchedIds.length; i++) {
1380
+ const allowed = new Set(matchedIds[i]);
1381
+ ids = ids.filter((id) => allowed.has(id));
1382
+ }
1383
+ const existingId = where.id;
1384
+ if (typeof existingId === "string") {
1385
+ ids = ids.includes(existingId) ? [existingId] : [];
1386
+ } else if (Array.isArray(existingId)) {
1387
+ const allowed = new Set(existingId.filter((item) => typeof item === "string"));
1388
+ ids = ids.filter((id) => allowed.has(id));
1389
+ }
1390
+ if (ids.length === 0) {
1391
+ return { where, empty: true };
1392
+ }
1393
+ where.id = ids;
1394
+ return { where, empty: false };
1395
+ }
1396
+ function column(table, key) {
1397
+ const selected = getTableColumns(table)[key];
1398
+ if (!selected) {
1399
+ throw new Error(`Column '${key}' not found on relationship join table.`);
1400
+ }
1401
+ return selected;
1402
+ }
1403
+ function parentColumn(table) {
1404
+ const columns = getTableColumns(table);
1405
+ const key = Object.keys(columns).find(
1406
+ (candidate) => candidate !== "id" && candidate !== "targetId" && candidate !== "order" && candidate.endsWith("Id")
1407
+ );
1408
+ if (!key) {
1409
+ throw new Error("Parent column not found on relationship join table.");
1410
+ }
1411
+ return columns[key];
1331
1412
  }
1332
1413
  async function getAllPageSlugs() {
1333
1414
  const result = await findDocuments("pages", {