@rpcbase/db 0.148.0 → 0.150.0

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.
@@ -0,0 +1,3 @@
1
+ declare const _default: import('@rpcbase/migrations').MigrationDefinition<unknown>;
2
+ export default _default;
3
+ //# sourceMappingURL=20260826160000-normalize-rb-users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260826160000-normalize-rb-users.d.ts","sourceRoot":"","sources":["../../src/migrations/20260826160000-normalize-rb-users.ts"],"names":[],"mappings":";AASA,wBAkCE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAEhC,eAAO,MAAM,sBAAsB,+CAMjC,CAAA;AAEF,eAAe,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAEhC,eAAO,MAAM,sBAAsB,+CAMjC,CAAA;AAEF,eAAe,sBAAsB,CAAA"}
@@ -1,5 +1,33 @@
1
- import { t as rtsChangesTtlSeconds } from "../rtsChanges-xIGFCLGa.js";
2
- import { defineMigrationSource, defineMongoResources } from "@rpcbase/migrations";
1
+ import { t as rtsChangesTtlSeconds } from "../rtsChanges-269ntyVt.js";
2
+ import { defineMigration, defineMigrationSource, defineMongoResources } from "@rpcbase/migrations";
3
+ //#region src/migrations/20260826160000-normalize-rb-users.ts
4
+ var normalizeEmailExpression = { $toLower: { $trim: { input: "$email" } } };
5
+ var _20260826160000_normalize_rb_users_default = defineMigration({
6
+ __rpcbaseIntegrity: "ea8207f8fd8b932e5a56237a0d0aa1e1ce62980ff4722548ead4f134d0cb75b1",
7
+ id: "20260826160000-normalize-rb-users",
8
+ scope: "global",
9
+ phase: "expand",
10
+ async up({ db }) {
11
+ const users = db.collection("rbusers");
12
+ if ((await users.aggregate([
13
+ { $match: { email: { $type: "string" } } },
14
+ { $project: { normalizedEmail: normalizeEmailExpression } },
15
+ { $group: {
16
+ _id: "$normalizedEmail",
17
+ count: { $sum: 1 }
18
+ } },
19
+ { $match: { count: { $gt: 1 } } },
20
+ { $limit: 1 }
21
+ ], { allowDiskUse: true }).toArray()).length > 0) throw new Error("Cannot normalize rbusers emails because canonical duplicates exist");
22
+ await users.updateMany({ email: { $type: "string" } }, [{ $set: { email: normalizeEmailExpression } }]);
23
+ await users.updateMany({
24
+ registrationStatus: { $exists: false },
25
+ emailVerificationCode: { $type: "string" }
26
+ }, { $set: { registrationStatus: "pending_verification" } });
27
+ await users.updateMany({ registrationStatus: { $exists: false } }, { $set: { registrationStatus: "active" } });
28
+ }
29
+ });
30
+ //#endregion
3
31
  //#region src/migrations/resources.ts
4
32
  var global = "global";
5
33
  var tenant = "tenant";
@@ -420,7 +448,7 @@ var rpcbaseMongoResources = defineMongoResources({
420
448
  var rpcbaseMigrationSource = defineMigrationSource({
421
449
  name: "@rpcbase/db",
422
450
  baseline: rpcbaseMongoResources,
423
- migrations: [],
451
+ migrations: [_20260826160000_normalize_rb_users_default],
424
452
  resources: rpcbaseMongoResources,
425
453
  resourceSnapshots: [rpcbaseMongoResources]
426
454
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["defineMongoResources","rtsChangesTtlSeconds","global","const","tenant","owner","rpcbaseMongoResources","collections","scope","name","indexes","collection","key","expiresAt","options","expireAfterSeconds","providerId","tenantId","unique","email","sparse","phone","tenants","createdAt","deliveryId","userId","archivedAt","readAt","seenAt","topic","tag","partialFilterExpression","$exists","drawerActive","modelName","seq","ts","runtimeOptions","provider","providerEventId","$type","subscriptionId","idempotencyKey","effectiveAt","occurredAt","scopeId","uploadId","index","defineMigrationSource","rpcbaseMongoResources","rpcbaseMigrationSource","name","baseline","migrations","resources","resourceSnapshots"],"sources":["../../src/migrations/resources.ts","../../src/migrations/index.ts"],"sourcesContent":["import { defineMongoResources } from \"@rpcbase/migrations\"\n\nimport { rtsChangesTtlSeconds } from \"./rtsChanges\"\n\n\nconst global = \"global\" as const\nconst tenant = \"tenant\" as const\nconst owner = \"@rpcbase/db\"\n\nexport const rpcbaseMongoResources = defineMongoResources({\n collections: [\n { scope: global, name: \"rboauthrequests\", owner },\n { scope: global, name: \"rbtenants\", owner },\n { scope: global, name: \"rbusers\", owner },\n { scope: tenant, name: \"rbnotificationdeliveries\", owner },\n { scope: tenant, name: \"rbnotifications\", owner },\n { scope: tenant, name: \"rbnotificationsettings\", owner },\n { scope: tenant, name: \"rbrtschanges\", owner },\n { scope: tenant, name: \"rbrtscounters\", owner },\n { scope: tenant, name: \"rbtenantsubscriptionevents\", owner },\n { scope: tenant, name: \"rbtenantsubscriptionprojections\", owner },\n { scope: tenant, name: \"rbuploadchunks\", owner },\n { scope: tenant, name: \"rbuploadsessions\", owner },\n ],\n indexes: [\n {\n scope: global,\n collection: \"rboauthrequests\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: global,\n collection: \"rboauthrequests\",\n name: \"providerId_1\",\n key: { providerId: 1 },\n owner,\n },\n {\n scope: global,\n collection: \"rbtenants\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"email_1\",\n key: { email: 1 },\n options: { unique: true, sparse: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"phone_1\",\n key: { phone: 1 },\n options: { unique: true, sparse: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"tenants_1\",\n key: { tenants: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"createdAt_1\",\n key: { createdAt: 1 },\n options: { expireAfterSeconds: 7_776_000 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"deliveryId_1\",\n key: { deliveryId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"userId_1_createdAt_-1\",\n key: { userId: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"archivedAt_1\",\n key: { archivedAt: 1 },\n options: { expireAfterSeconds: 7_776_000 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"createdAt_1\",\n key: { createdAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"readAt_1\",\n key: { readAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"seenAt_1\",\n key: { seenAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"topic_1\",\n key: { topic: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_readAt_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, readAt: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_seenAt_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, seenAt: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_tag_1\",\n key: { userId: 1, tag: 1 },\n options: {\n unique: true,\n partialFilterExpression: { tag: { $exists: true }, drawerActive: true },\n },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationsettings\",\n name: \"userId_1\",\n key: { userId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationsettings\",\n name: \"userId_1_topicPreferences.topic_1\",\n key: { userId: 1, \"topicPreferences.topic\": 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"modelName_1\",\n key: { modelName: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"seq_1\",\n key: { seq: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"ts_1\",\n key: { ts: 1 },\n runtimeOptions: { expireAfterSeconds: rtsChangesTtlSeconds },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"provider_1_providerEventId_1\",\n key: { provider: 1, providerEventId: 1 },\n options: {\n unique: true,\n partialFilterExpression: {\n provider: { $type: \"string\" },\n providerEventId: { $type: \"string\" },\n },\n },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"subscriptionId_1\",\n key: { subscriptionId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1_idempotencyKey_1\",\n key: { tenantId: 1, idempotencyKey: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1_subscriptionId_1_effectiveAt_1_occurredAt_1\",\n key: { tenantId: 1, subscriptionId: 1, effectiveAt: 1, occurredAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1_scope_1_scopeId_1\",\n key: { tenantId: 1, scope: 1, scopeId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1_subscriptionId_1\",\n key: { tenantId: 1, subscriptionId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"uploadId_1\",\n key: { uploadId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"uploadId_1_index_1\",\n key: { uploadId: 1, index: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadsessions\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadsessions\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n ],\n})\n","import { defineMigrationSource } from \"@rpcbase/migrations\"\n\nimport { rpcbaseMongoResources } from \"./resources\"\n\n\nexport { rpcbaseMongoResources }\n\nexport const rpcbaseMigrationSource = defineMigrationSource({\n name: \"@rpcbase/db\",\n baseline: rpcbaseMongoResources,\n migrations: [],\n resources: rpcbaseMongoResources,\n resourceSnapshots: [rpcbaseMongoResources],\n})\n\nexport default rpcbaseMigrationSource\n"],"mappings":";;;AAKA,IAAME,SAAS;AACf,IAAME,SAAS;AACf,IAAMC,QAAQ;AAEd,IAAaC,wBAAwBN,qBAAqB;CACxDO,aAAa;EACX;GAAEC,OAAON;GAAQO,MAAM;GAAmBJ;EAAM;EAChD;GAAEG,OAAON;GAAQO,MAAM;GAAaJ;EAAM;EAC1C;GAAEG,OAAON;GAAQO,MAAM;GAAWJ;EA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1DG,MAAM;CACNC,UAAUH;CACVI,YAAY,CAAA;CACZC,WAAWL;CACXM,mBAAmB,CAACN,qBAAqB;AAC3C,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/migrations/20260826160000-normalize-rb-users.ts","../../src/migrations/resources.ts","../../src/migrations/index.ts"],"sourcesContent":["import { defineMigration } from \"@rpcbase/migrations\"\n\n\nconst normalizeEmailExpression = {\n $toLower: {\n $trim: { input: \"$email\" },\n },\n}\n\nexport default defineMigration({\n __rpcbaseIntegrity: \"ea8207f8fd8b932e5a56237a0d0aa1e1ce62980ff4722548ead4f134d0cb75b1\",\n id: \"20260826160000-normalize-rb-users\",\n scope: \"global\",\n phase: \"expand\",\n async up({ db }) {\n const users = db.collection(\"rbusers\")\n const duplicates = await users.aggregate([\n { $match: { email: { $type: \"string\" } } },\n { $project: { normalizedEmail: normalizeEmailExpression } },\n { $group: { _id: \"$normalizedEmail\", count: { $sum: 1 } } },\n { $match: { count: { $gt: 1 } } },\n { $limit: 1 },\n ], { allowDiskUse: true }).toArray()\n\n if (duplicates.length > 0) {\n throw new Error(\"Cannot normalize rbusers emails because canonical duplicates exist\")\n }\n\n await users.updateMany(\n { email: { $type: \"string\" } },\n [{ $set: { email: normalizeEmailExpression } }],\n )\n await users.updateMany(\n {\n registrationStatus: { $exists: false },\n emailVerificationCode: { $type: \"string\" },\n },\n { $set: { registrationStatus: \"pending_verification\" } },\n )\n await users.updateMany(\n { registrationStatus: { $exists: false } },\n { $set: { registrationStatus: \"active\" } },\n )\n },\n})\n","import { defineMongoResources } from \"@rpcbase/migrations\"\n\nimport { rtsChangesTtlSeconds } from \"./rtsChanges\"\n\n\nconst global = \"global\" as const\nconst tenant = \"tenant\" as const\nconst owner = \"@rpcbase/db\"\n\nexport const rpcbaseMongoResources = defineMongoResources({\n collections: [\n { scope: global, name: \"rboauthrequests\", owner },\n { scope: global, name: \"rbtenants\", owner },\n { scope: global, name: \"rbusers\", owner },\n { scope: tenant, name: \"rbnotificationdeliveries\", owner },\n { scope: tenant, name: \"rbnotifications\", owner },\n { scope: tenant, name: \"rbnotificationsettings\", owner },\n { scope: tenant, name: \"rbrtschanges\", owner },\n { scope: tenant, name: \"rbrtscounters\", owner },\n { scope: tenant, name: \"rbtenantsubscriptionevents\", owner },\n { scope: tenant, name: \"rbtenantsubscriptionprojections\", owner },\n { scope: tenant, name: \"rbuploadchunks\", owner },\n { scope: tenant, name: \"rbuploadsessions\", owner },\n ],\n indexes: [\n {\n scope: global,\n collection: \"rboauthrequests\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: global,\n collection: \"rboauthrequests\",\n name: \"providerId_1\",\n key: { providerId: 1 },\n owner,\n },\n {\n scope: global,\n collection: \"rbtenants\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"email_1\",\n key: { email: 1 },\n options: { unique: true, sparse: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"phone_1\",\n key: { phone: 1 },\n options: { unique: true, sparse: true },\n owner,\n },\n {\n scope: global,\n collection: \"rbusers\",\n name: \"tenants_1\",\n key: { tenants: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"createdAt_1\",\n key: { createdAt: 1 },\n options: { expireAfterSeconds: 7_776_000 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"deliveryId_1\",\n key: { deliveryId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationdeliveries\",\n name: \"userId_1_createdAt_-1\",\n key: { userId: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"archivedAt_1\",\n key: { archivedAt: 1 },\n options: { expireAfterSeconds: 7_776_000 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"createdAt_1\",\n key: { createdAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"readAt_1\",\n key: { readAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"seenAt_1\",\n key: { seenAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"topic_1\",\n key: { topic: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_readAt_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, readAt: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_seenAt_1_archivedAt_1_createdAt_-1\",\n key: { userId: 1, seenAt: 1, archivedAt: 1, createdAt: -1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotifications\",\n name: \"userId_1_tag_1\",\n key: { userId: 1, tag: 1 },\n options: {\n unique: true,\n partialFilterExpression: { tag: { $exists: true }, drawerActive: true },\n },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationsettings\",\n name: \"userId_1\",\n key: { userId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbnotificationsettings\",\n name: \"userId_1_topicPreferences.topic_1\",\n key: { userId: 1, \"topicPreferences.topic\": 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"modelName_1\",\n key: { modelName: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"seq_1\",\n key: { seq: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbrtschanges\",\n name: \"ts_1\",\n key: { ts: 1 },\n runtimeOptions: { expireAfterSeconds: rtsChangesTtlSeconds },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"provider_1_providerEventId_1\",\n key: { provider: 1, providerEventId: 1 },\n options: {\n unique: true,\n partialFilterExpression: {\n provider: { $type: \"string\" },\n providerEventId: { $type: \"string\" },\n },\n },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"subscriptionId_1\",\n key: { subscriptionId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1_idempotencyKey_1\",\n key: { tenantId: 1, idempotencyKey: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionevents\",\n name: \"tenantId_1_subscriptionId_1_effectiveAt_1_occurredAt_1\",\n key: { tenantId: 1, subscriptionId: 1, effectiveAt: 1, occurredAt: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1\",\n key: { tenantId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1_scope_1_scopeId_1\",\n key: { tenantId: 1, scope: 1, scopeId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbtenantsubscriptionprojections\",\n name: \"tenantId_1_subscriptionId_1\",\n key: { tenantId: 1, subscriptionId: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"uploadId_1\",\n key: { uploadId: 1 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadchunks\",\n name: \"uploadId_1_index_1\",\n key: { uploadId: 1, index: 1 },\n options: { unique: true },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadsessions\",\n name: \"expiresAt_1\",\n key: { expiresAt: 1 },\n options: { expireAfterSeconds: 0 },\n owner,\n },\n {\n scope: tenant,\n collection: \"rbuploadsessions\",\n name: \"userId_1\",\n key: { userId: 1 },\n owner,\n },\n ],\n})\n","import { defineMigrationSource } from \"@rpcbase/migrations\"\n\nimport normalizeRBUsers from \"./20260826160000-normalize-rb-users\"\nimport { rpcbaseMongoResources } from \"./resources\"\n\n\nexport { rpcbaseMongoResources }\n\nexport const rpcbaseMigrationSource = defineMigrationSource({\n name: \"@rpcbase/db\",\n baseline: rpcbaseMongoResources,\n migrations: [normalizeRBUsers],\n resources: rpcbaseMongoResources,\n resourceSnapshots: [rpcbaseMongoResources],\n})\n\nexport default rpcbaseMigrationSource\n"],"mappings":";;;AAGA,IAAM,2BAA2B,EAC/B,UAAU,EACR,OAAO,EAAE,OAAO,SAAS,EAC3B,EACF;AAEA,IAAA,6CAAe,gBAAgB;CAC7B,oBAAoB;CACpB,IAAI;CACJ,OAAO;CACP,OAAO;CACP,MAAM,GAAG,EAAE,MAAM;EACf,MAAM,QAAQ,GAAG,WAAW,SAAS;EASrC,KAAI,MARqB,MAAM,UAAU;GACvC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,SAAS,EAAE,EAAE;GACzC,EAAE,UAAU,EAAE,iBAAiB,yBAAyB,EAAE;GAC1D,EAAE,QAAQ;IAAE,KAAK;IAAoB,OAAO,EAAE,MAAM,EAAE;GAAE,EAAE;GAC1D,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;GAChC,EAAE,QAAQ,EAAE;EAAC,GACZ,EAAE,cAAc,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAA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GACpB,SAAS,EAAE,oBAAoB,EAAE;GACjC;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK,EAAE,QAAQ,EAAE;GACjB;EACF;CACF;AACF,CAAC;;;ACtTD,IAAa,yBAAyB,sBAAsB;CAC1D,MAAM;CACN,UAAU;CACV,YAAY,CAAC,0CAAgB;CAC7B,WAAW;CACX,mBAAmB,CAAC,qBAAqB;AAC3C,CAAC"}
@@ -5,8 +5,8 @@ export declare const ZRBTenant: z.ZodObject<{
5
5
  parentTenantId: z.ZodOptional<z.ZodString>;
6
6
  name: z.ZodOptional<z.ZodString>;
7
7
  provisioningStatus: z.ZodOptional<z.ZodEnum<{
8
- initializing: "initializing";
9
8
  active: "active";
9
+ initializing: "initializing";
10
10
  failed: "failed";
11
11
  }>>;
12
12
  provisioningError: z.ZodOptional<z.ZodString>;
@@ -21,8 +21,13 @@ export declare const ZRBUser: z.ZodObject<{
21
21
  createdAt: z.ZodOptional<z.ZodDate>;
22
22
  updatedAt: z.ZodOptional<z.ZodDate>;
23
23
  }, z.core.$strip>>>;
24
+ registrationStatus: z.ZodOptional<z.ZodEnum<{
25
+ pending_verification: "pending_verification";
26
+ active: "active";
27
+ }>>;
24
28
  emailVerificationCode: z.ZodOptional<z.ZodString>;
25
29
  emailVerificationExpiresAt: z.ZodOptional<z.ZodDate>;
30
+ emailVerificationSentAt: z.ZodOptional<z.ZodDate>;
26
31
  passwordResetCode: z.ZodOptional<z.ZodString>;
27
32
  passwordResetCodeExpiresAt: z.ZodOptional<z.ZodDate>;
28
33
  passwordResetToken: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"RBUser.d.ts","sourceRoot":"","sources":["../../src/models/RBUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,YAAY,EAAE,MAgCzB,CAAA"}
1
+ {"version":3,"file":"RBUser.d.ts","sourceRoot":"","sources":["../../src/models/RBUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,YAAY,EAAE,MAsCzB,CAAA"}
package/dist/mongo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mongo.js","names":["EnvRecord","key","MongoUrlOptions","dbName","parseMongoDirectConnectionOverride","env","process","rawValue","RB_MONGO_DIRECT_CONNECTION","MONGO_DIRECT_CONNECTION","value","trim","toLowerCase","includes","getMongoDirectConnection","DB_HOST","getMongoUrl","options","port","DB_PORT","Error","host","baseUrl"],"sources":["../src/getMongoUrl.ts"],"sourcesContent":["type EnvRecord = { [key: string]: string | undefined }\n\ntype MongoUrlOptions = {\n dbName?: string\n}\n\nconst parseMongoDirectConnectionOverride = (env: EnvRecord = process.env): boolean | null => {\n const rawValue = env.RB_MONGO_DIRECT_CONNECTION ?? env.MONGO_DIRECT_CONNECTION\n if (typeof rawValue !== \"string\") return null\n\n const value = rawValue.trim().toLowerCase()\n if ([\"1\", \"true\", \"yes\", \"on\"].includes(value)) return true\n if ([\"0\", \"false\", \"no\", \"off\"].includes(value)) return false\n return null\n}\n\nexport const getMongoDirectConnection = (env: EnvRecord = process.env): boolean =>\n parseMongoDirectConnectionOverride(env) ??\n [\"\", \"localhost\", \"127.0.0.1\", \"::1\"].includes((env.DB_HOST ?? \"\").trim().toLowerCase())\n\nexport const getMongoUrl = (env: EnvRecord = process.env, options: MongoUrlOptions = {}): string => {\n const port = env.DB_PORT?.trim()\n if (!port) {\n throw new Error(\"Missing DB_PORT (required to build MongoDB connection URL)\")\n }\n\n const host = env.DB_HOST?.trim() || \"localhost\"\n const baseUrl = `mongodb://${host}:${port}`\n const dbName = options.dbName?.trim()\n\n return dbName ? `${baseUrl}/${dbName}` : baseUrl\n}\n"],"mappings":";AAMA,IAAMI,sCAAsCC,MAAiBC,QAAQD,QAAwB;CAC3F,MAAME,WAAWF,IAAIG,8BAA8BH,IAAII;CACvD,IAAI,OAAOF,aAAa,UAAU,OAAO;CAEzC,MAAMG,QAAQH,SAASI,KAAK,CAAC,CAACC,YAAY;CAC1C,IAAI;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAACC,SAASH,KAAK,GAAG,OAAO;CACvD,IAAI;EAAC;EAAK;EAAS;EAAM;CAAK,CAAC,CAACG,SAASH,KAAK,GAAG,OAAO;CACxD,OAAO;AACT;AAEA,IAAaI,4BAA4BT,MAAiBC,QAAQD,QAChED,mCAAmCC,GAAG,KACtC;CAAC;CAAI;CAAa;CAAa;AAAK,CAAC,CAACQ,UAAUR,IAAIU,WAAW,GAAA,CAAIJ,KAAK,CAAC,CAACC,YAAY,CAAC;AAEzF,IAAaI,eAAeX,MAAiBC,QAAQD,KAAKY,UAA2B,CAAC,MAAc;CAClG,MAAMC,OAAOb,IAAIc,SAASR,KAAK;CAC/B,IAAI,CAACO,MACH,MAAM,IAAIE,MAAM,4DAA4D;CAI9E,MAAME,UAAU,aADHjB,IAAIU,SAASJ,KAAK,KAAK,YACH,GAAIO;CACrC,MAAMf,SAASc,QAAQd,QAAQQ,KAAK;CAEpC,OAAOR,SAAS,GAAGmB,QAAO,GAAInB,WAAWmB;AAC3C"}
1
+ {"version":3,"file":"mongo.js","names":[],"sources":["../src/getMongoUrl.ts"],"sourcesContent":["type EnvRecord = { [key: string]: string | undefined }\n\ntype MongoUrlOptions = {\n dbName?: string\n}\n\nconst parseMongoDirectConnectionOverride = (env: EnvRecord = process.env): boolean | null => {\n const rawValue = env.RB_MONGO_DIRECT_CONNECTION ?? env.MONGO_DIRECT_CONNECTION\n if (typeof rawValue !== \"string\") return null\n\n const value = rawValue.trim().toLowerCase()\n if ([\"1\", \"true\", \"yes\", \"on\"].includes(value)) return true\n if ([\"0\", \"false\", \"no\", \"off\"].includes(value)) return false\n return null\n}\n\nexport const getMongoDirectConnection = (env: EnvRecord = process.env): boolean =>\n parseMongoDirectConnectionOverride(env) ??\n [\"\", \"localhost\", \"127.0.0.1\", \"::1\"].includes((env.DB_HOST ?? \"\").trim().toLowerCase())\n\nexport const getMongoUrl = (env: EnvRecord = process.env, options: MongoUrlOptions = {}): string => {\n const port = env.DB_PORT?.trim()\n if (!port) {\n throw new Error(\"Missing DB_PORT (required to build MongoDB connection URL)\")\n }\n\n const host = env.DB_HOST?.trim() || \"localhost\"\n const baseUrl = `mongodb://${host}:${port}`\n const dbName = options.dbName?.trim()\n\n return dbName ? `${baseUrl}/${dbName}` : baseUrl\n}\n"],"mappings":";AAMA,IAAM,sCAAsC,MAAiB,QAAQ,QAAwB;CAC3F,MAAM,WAAW,IAAI,8BAA8B,IAAI;CACvD,IAAI,OAAO,aAAa,UAAU,OAAO;CAEzC,MAAM,QAAQ,SAAS,KAAK,CAAC,CAAC,YAAY;CAC1C,IAAI;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAAC,SAAS,KAAK,GAAG,OAAO;CACvD,IAAI;EAAC;EAAK;EAAS;EAAM;CAAK,CAAC,CAAC,SAAS,KAAK,GAAG,OAAO;CACxD,OAAO;AACT;AAEA,IAAa,4BAA4B,MAAiB,QAAQ,QAChE,mCAAmC,GAAG,KACtC;CAAC;CAAI;CAAa;CAAa;AAAK,CAAC,CAAC,UAAU,IAAI,WAAW,GAAA,CAAI,KAAK,CAAC,CAAC,YAAY,CAAC;AAEzF,IAAa,eAAe,MAAiB,QAAQ,KAAK,UAA2B,CAAC,MAAc;CAClG,MAAM,OAAO,IAAI,SAAS,KAAK;CAC/B,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,4DAA4D;CAI9E,MAAM,UAAU,aADH,IAAI,SAAS,KAAK,KAAK,YACH,GAAI;CACrC,MAAM,SAAS,QAAQ,QAAQ,KAAK;CAEpC,OAAO,SAAS,GAAG,QAAO,GAAI,WAAW;AAC3C"}
@@ -1,7 +1,7 @@
1
1
  //#region src/migrations/rtsChanges.ts
2
2
  var ttlSecondsRaw = process.env.RB_RTS_CHANGES_TTL_S ?? "";
3
- var rtsChangesTtlSeconds = Number.isFinite(Number(ttlSecondsRaw)) ? Math.max(60, Math.floor(Number(ttlSecondsRaw))) : 3600 * 24 * 30;
3
+ var rtsChangesTtlSeconds = Number.isFinite(Number(ttlSecondsRaw)) ? Math.max(60, Math.floor(Number(ttlSecondsRaw))) : 2592e3;
4
4
  //#endregion
5
5
  export { rtsChangesTtlSeconds as t };
6
6
 
7
- //# sourceMappingURL=rtsChanges-xIGFCLGa.js.map
7
+ //# sourceMappingURL=rtsChanges-269ntyVt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtsChanges-269ntyVt.js","names":[],"sources":["../src/migrations/rtsChanges.ts"],"sourcesContent":["const ttlSecondsRaw = process.env.RB_RTS_CHANGES_TTL_S ?? \"\"\n\nexport const rtsChangesTtlSeconds = Number.isFinite(Number(ttlSecondsRaw))\n ? Math.max(60, Math.floor(Number(ttlSecondsRaw)))\n : 60 * 60 * 24 * 30\n"],"mappings":";AAAA,IAAM,gBAAgB,QAAQ,IAAI,wBAAwB;AAE1D,IAAa,uBAAuB,OAAO,SAAS,OAAO,aAAa,CAAC,IACrE,KAAK,IAAI,IAAI,KAAK,MAAM,OAAO,aAAa,CAAC,CAAC,IAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"zod-DSnhyNso.js","names":["z","LanguageCode","LocalizedStringEntry","Record","value","updatedAt","Date","autoTranslated","TExtra","LocalizedString","I18nStringRecord","I18nString","LocalizedStringWithFallback","get","key","getExact","hasExact","LANGUAGE_CODE_REGEX","LOCALIZED_STRING_PROXY_CACHE","WeakMap","normalizeLocale","locale","trimmed","trim","getCanonicalLocales","Intl","locales","buildLocaleFallbackChain","fallbacks","base","canonical","extra","output","seen","Set","push","has","add","addChain","parts","split","filter","Boolean","length","join","pop","fallback","resolveLocalizedString","options","resolveLocalizedStringEntry","undefined","chain","record","Object","prototype","hasOwnProperty","call","withLocalizedStringFallback","T","Array","isArray","Map","cached","proxy","withFallbackRecord","set","Proxy","target","prop","Reflect","next","zLocalizedString","languageCodeSchema","string","regex","message","entrySchema","object","date","boolean","optional","passthrough","schema","zI18nString","z","E164_PHONE_REGEX","E164_PHONE_OR_EMPTY_REGEX","E164PhoneOptions","allowEmpty","makeZE164Phone","zod","options","string","trim","regex","message","zE164Phone","z","E164PhoneOptions","makeZE164Phone","RpcbaseZodExtension","e164Phone","options","ZodString","ExtendableZodPrototype","unique","this","arg","sparse","ZodNumber","ZodDate","zodPrototypesExtended","extendZod","zod","zodWithExtension","Object","isExtensible","supported","const","type","proto","prototype","_flag","z","baseZ","ZodError","ZodString","ZodType","extendZod","RpcbaseZod","e164Phone","options","E164PhoneOptions","Object","create","infer","T","input","output","TypeOf","Infer"],"sources":["../src/zod/localizedString.ts","../src/zod/e164Phone.ts","../src/zod/extension.ts","../src/zod/index.ts"],"sourcesContent":["import { z } from \"zod\"\n\n\nexport type LanguageCode = string\n\nexport type LocalizedStringEntry<TExtra extends Record<string, unknown> = Record<string, unknown>> = {\n value: string\n updatedAt: Date\n autoTranslated?: boolean\n} & TExtra\n\nexport type LocalizedString<TExtra extends Record<string, unknown> = Record<string, unknown>> = Record<\n LanguageCode,\n LocalizedStringEntry<TExtra>\n>\n\nexport type I18nStringRecord = LocalizedString\n\nexport type I18nString = LocalizedString\n\nexport type LocalizedStringWithFallback = LocalizedString & {\n get: (key: string) => LocalizedStringEntry | undefined\n getExact: (key: string) => LocalizedStringEntry | undefined\n hasExact: (key: string) => boolean\n}\n\nexport const LANGUAGE_CODE_REGEX = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/\n\nconst LOCALIZED_STRING_PROXY_CACHE = new WeakMap<object, unknown>()\n\nfunction normalizeLocale(locale: string): string {\n const trimmed = locale.trim()\n if (!trimmed) return \"\"\n const getCanonicalLocales = (Intl as typeof Intl & {\n getCanonicalLocales?: (locales: string | readonly string[]) => string[]\n }).getCanonicalLocales\n if (typeof getCanonicalLocales !== \"function\") return trimmed\n try {\n return getCanonicalLocales(trimmed)[0] ?? trimmed\n } catch {\n return trimmed\n }\n}\n\nexport function buildLocaleFallbackChain(locale: string, fallbacks?: string | string[]): string[] {\n const base = locale.trim()\n const canonical = normalizeLocale(base)\n const extra = typeof fallbacks === \"string\" ? [fallbacks] : (fallbacks ?? [])\n\n const output: string[] = []\n const seen = new Set<string>()\n\n const push = (value: string) => {\n if (!value) return\n if (seen.has(value)) return\n seen.add(value)\n output.push(value)\n }\n\n const addChain = (value: string) => {\n if (!value) return\n const parts = value.split(\"-\").filter(Boolean)\n while (parts.length > 0) {\n push(parts.join(\"-\"))\n parts.pop()\n }\n }\n\n addChain(base)\n addChain(canonical)\n for (const fallback of extra) addChain(normalizeLocale(fallback))\n\n return output\n}\n\nexport function resolveLocalizedString(\n value: LocalizedString | null | undefined,\n locale: string,\n options?: { fallbacks?: string | string[] }\n): string | undefined {\n return resolveLocalizedStringEntry(value, locale, options)?.value\n}\n\nfunction resolveLocalizedStringEntry(\n value: LocalizedString | null | undefined,\n locale: string,\n options?: { fallbacks?: string | string[] }\n): LocalizedStringEntry | undefined {\n if (!value) return undefined\n const chain = buildLocaleFallbackChain(locale, options?.fallbacks)\n if (chain.length === 0) return undefined\n\n const record = value\n for (const key of chain) {\n if (!Object.prototype.hasOwnProperty.call(record, key)) continue\n return record[key] as LocalizedStringEntry\n }\n return undefined\n}\n\nexport function withLocalizedStringFallback<T>(value: T): T {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return value\n if (value instanceof Map) return value\n const cached = LOCALIZED_STRING_PROXY_CACHE.get(value)\n if (cached) return cached as T\n\n const proxy = withFallbackRecord(value as Record<string, unknown>)\n LOCALIZED_STRING_PROXY_CACHE.set(value, proxy)\n return proxy as T\n}\n\nfunction withFallbackRecord(record: Record<string, unknown>): LocalizedStringWithFallback {\n const getExact = (key: string): LocalizedStringEntry | undefined => {\n if (!hasExact(key)) return undefined\n return record[key] as LocalizedStringEntry\n }\n const hasExact = (key: string) => Object.prototype.hasOwnProperty.call(record, key)\n\n return new Proxy(record, {\n get(target, prop) {\n if (prop === \"getExact\") return getExact\n if (prop === \"hasExact\") return hasExact\n if (prop === \"get\") return (key: string) => resolveLocalizedStringEntry(target as LocalizedString, key)\n if (typeof prop === \"string\" && !(prop in target)) {\n return resolveLocalizedStringEntry(target as LocalizedString, prop)\n }\n\n return Reflect.get(target, prop)\n },\n set(target, prop, next) {\n return Reflect.set(target, prop, next)\n },\n }) as LocalizedStringWithFallback\n}\n\nexport const zLocalizedString = () => {\n const languageCodeSchema = z\n .string()\n .regex(LANGUAGE_CODE_REGEX, { message: \"Expected a language code (BCP 47, e.g. en or fr-FR).\" })\n const entrySchema = z.object({\n value: z.string(),\n updatedAt: z.date(),\n autoTranslated: z.boolean().optional(),\n }).passthrough()\n const schema = z.record(\n languageCodeSchema,\n entrySchema,\n )\n\n return schema\n}\n\nexport const zI18nString = zLocalizedString\n","import { z } from \"zod\"\n\n\nexport const E164_PHONE_REGEX = /^\\+[1-9]\\d{1,14}$/\nexport const E164_PHONE_OR_EMPTY_REGEX = /^(?:\\+[1-9]\\d{1,14})?$/\n\nexport type E164PhoneOptions = {\n allowEmpty?: boolean\n}\n\nexport const makeZE164Phone = (zod: typeof z, options?: E164PhoneOptions) => {\n const allowEmpty = options?.allowEmpty ?? false\n return zod.string().trim().regex(allowEmpty ? E164_PHONE_OR_EMPTY_REGEX : E164_PHONE_REGEX, {\n message: allowEmpty\n ? \"Expected an empty string or a phone number in E.164 format (e.g. +33608707197).\"\n : \"Expected a phone number in E.164 format (e.g. +33608707197).\",\n })\n}\n\nexport const zE164Phone = (options?: E164PhoneOptions) => makeZE164Phone(z, options)\n","import { z } from \"zod\"\n\nimport { type E164PhoneOptions, makeZE164Phone } from \"./e164Phone\"\n\n\ntype RpcbaseZodExtension = typeof z & {\n e164Phone?: (options?: E164PhoneOptions) => z.ZodString\n}\n\ntype ExtendableZodPrototype = {\n unique?: (this: unknown, arg?: boolean) => unknown\n sparse?: (this: unknown, arg?: boolean) => unknown\n}\n\ndeclare module \"zod\" {\n interface ZodString {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n interface ZodNumber {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n interface ZodDate {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n}\n\nlet zodPrototypesExtended = false\n\nexport function extendZod(zod: typeof z) {\n const zodWithExtension = zod as RpcbaseZodExtension\n if (Object.isExtensible(zodWithExtension) && typeof zodWithExtension.e164Phone !== \"function\") {\n zodWithExtension.e164Phone = (options?: E164PhoneOptions) => makeZE164Phone(zod, options)\n }\n\n if (zodPrototypesExtended) return\n zodPrototypesExtended = true\n\n const supported = [zod.ZodString, zod.ZodNumber, zod.ZodDate] as const\n for (const type of supported) {\n const proto = type?.prototype as ExtendableZodPrototype | undefined\n if (!proto) continue\n\n proto.unique = function unique(this: unknown, _flag = true) {\n return this\n }\n\n proto.sparse = function sparse(this: unknown, _flag = true) {\n return this\n }\n }\n}\n","import { z as baseZ, type ZodError, type ZodString, type ZodType } from \"zod\"\n\nimport { extendZod } from \"./extension\"\n\n\nexport * from \"./e164Phone\"\nexport * from \"./localizedString\"\n\nexport type RpcbaseZod = typeof baseZ & {\n e164Phone: (options?: import(\"./e164Phone\").E164PhoneOptions) => ZodString\n}\n\nexport const z = Object.create(baseZ) as RpcbaseZod\nextendZod(z)\n\nexport namespace z {\n export type infer<T> = import(\"zod\").infer<T>\n export type input<T> = import(\"zod\").input<T>\n export type output<T> = import(\"zod\").output<T>\n export type TypeOf<T> = import(\"zod\").TypeOf<T>\n export type Infer<T> = import(\"zod\").Infer<T>\n}\n\nexport { extendZod, ZodError, ZodType }\n"],"mappings":";;AA0BA,IAAaiB,sBAAsB;AAEnC,IAAMC,+CAA+B,IAAIC,QAAyB;AAElE,SAASC,gBAAgBC,QAAwB;CAC/C,MAAMC,UAAUD,OAAOE,KAAK;CAC5B,IAAI,CAACD,SAAS,OAAO;CACrB,MAAME,sBAAuBC,KAE1BD;CACH,IAAI,OAAOA,wBAAwB,YAAY,OAAOF;CACtD,IAAI;EACF,OAAOE,oBAAoBF,OAAO,CAAC,CAAC,MAAMA;CAC5C,QAAQ;EACN,OAAOA;CACT;AACF;AAEA,SAAgBK,yBAAyBN,QAAgBO,WAAyC;CAChG,MAAMC,OAAOR,OAAOE,KAAK;CACzB,MAAMO,YAAYV,gBAAgBS,IAAI;CACtC,MAAME,QAAQ,OAAOH,cAAc,WAAW,CAACA,SAAS,IAAKA,aAAa,CAAA;CAE1E,MAAMI,SAAmB,CAAA;CACzB,MAAMC,uBAAO,IAAIC,IAAY;CAE7B,MAAMC,QAAQ/B,UAAkB;EAC9B,IAAI,CAACA,OAAO;EACZ,IAAI6B,KAAKG,IAAIhC,KAAK,GAAG;EACrB6B,KAAKI,IAAIjC,KAAK;EACd4B,OAAOG,KAAK/B,KAAK;CACnB;CAEA,MAAMkC,YAAYlC,UAAkB;EAClC,IAAI,CAACA,OAAO;EACZ,MAAMmC,QAAQnC,MAAMoC,MAAM,GAAG,CAAC,CAACC,OAAOC,OAAO;EAC7C,OAAOH,MAAMI,SAAS,GAAG;GACvBR,KAAKI,MAAMK,KAAK,GAAG,CAAC;GACpBL,MAAMM,IAAI;EACZ;CACF;CAEAP,SAAST,IAAI;CACbS,SAASR,SAAS;CAClB,KAAK,MAAMgB,YAAYf,OAAOO,SAASlB,gBAAgB0B,QAAQ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,WAAW;EAC5B,MAAMG,QAAQD,MAAME;EACpB,IAAI,CAACD,OAAO;EAEZA,MAAMf,SAAS,SAASA,OAAsBiB,QAAQ,MAAM;GAC1D,OAAO;EACT;EAEAF,MAAMZ,SAAS,SAASA,OAAsBc,QAAQ,MAAM;GAC1D,OAAO;EACT;CACF;AACF;;;AC5CA,IAAaC,MAAIU,OAAOC,OAAOV,CAAK;AACpCI,UAAUL,GAAC"}
1
+ {"version":3,"file":"zod-DSnhyNso.js","names":[],"sources":["../src/zod/localizedString.ts","../src/zod/e164Phone.ts","../src/zod/extension.ts","../src/zod/index.ts"],"sourcesContent":["import { z } from \"zod\"\n\n\nexport type LanguageCode = string\n\nexport type LocalizedStringEntry<TExtra extends Record<string, unknown> = Record<string, unknown>> = {\n value: string\n updatedAt: Date\n autoTranslated?: boolean\n} & TExtra\n\nexport type LocalizedString<TExtra extends Record<string, unknown> = Record<string, unknown>> = Record<\n LanguageCode,\n LocalizedStringEntry<TExtra>\n>\n\nexport type I18nStringRecord = LocalizedString\n\nexport type I18nString = LocalizedString\n\nexport type LocalizedStringWithFallback = LocalizedString & {\n get: (key: string) => LocalizedStringEntry | undefined\n getExact: (key: string) => LocalizedStringEntry | undefined\n hasExact: (key: string) => boolean\n}\n\nexport const LANGUAGE_CODE_REGEX = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/\n\nconst LOCALIZED_STRING_PROXY_CACHE = new WeakMap<object, unknown>()\n\nfunction normalizeLocale(locale: string): string {\n const trimmed = locale.trim()\n if (!trimmed) return \"\"\n const getCanonicalLocales = (Intl as typeof Intl & {\n getCanonicalLocales?: (locales: string | readonly string[]) => string[]\n }).getCanonicalLocales\n if (typeof getCanonicalLocales !== \"function\") return trimmed\n try {\n return getCanonicalLocales(trimmed)[0] ?? trimmed\n } catch {\n return trimmed\n }\n}\n\nexport function buildLocaleFallbackChain(locale: string, fallbacks?: string | string[]): string[] {\n const base = locale.trim()\n const canonical = normalizeLocale(base)\n const extra = typeof fallbacks === \"string\" ? [fallbacks] : (fallbacks ?? [])\n\n const output: string[] = []\n const seen = new Set<string>()\n\n const push = (value: string) => {\n if (!value) return\n if (seen.has(value)) return\n seen.add(value)\n output.push(value)\n }\n\n const addChain = (value: string) => {\n if (!value) return\n const parts = value.split(\"-\").filter(Boolean)\n while (parts.length > 0) {\n push(parts.join(\"-\"))\n parts.pop()\n }\n }\n\n addChain(base)\n addChain(canonical)\n for (const fallback of extra) addChain(normalizeLocale(fallback))\n\n return output\n}\n\nexport function resolveLocalizedString(\n value: LocalizedString | null | undefined,\n locale: string,\n options?: { fallbacks?: string | string[] }\n): string | undefined {\n return resolveLocalizedStringEntry(value, locale, options)?.value\n}\n\nfunction resolveLocalizedStringEntry(\n value: LocalizedString | null | undefined,\n locale: string,\n options?: { fallbacks?: string | string[] }\n): LocalizedStringEntry | undefined {\n if (!value) return undefined\n const chain = buildLocaleFallbackChain(locale, options?.fallbacks)\n if (chain.length === 0) return undefined\n\n const record = value\n for (const key of chain) {\n if (!Object.prototype.hasOwnProperty.call(record, key)) continue\n return record[key] as LocalizedStringEntry\n }\n return undefined\n}\n\nexport function withLocalizedStringFallback<T>(value: T): T {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return value\n if (value instanceof Map) return value\n const cached = LOCALIZED_STRING_PROXY_CACHE.get(value)\n if (cached) return cached as T\n\n const proxy = withFallbackRecord(value as Record<string, unknown>)\n LOCALIZED_STRING_PROXY_CACHE.set(value, proxy)\n return proxy as T\n}\n\nfunction withFallbackRecord(record: Record<string, unknown>): LocalizedStringWithFallback {\n const getExact = (key: string): LocalizedStringEntry | undefined => {\n if (!hasExact(key)) return undefined\n return record[key] as LocalizedStringEntry\n }\n const hasExact = (key: string) => Object.prototype.hasOwnProperty.call(record, key)\n\n return new Proxy(record, {\n get(target, prop) {\n if (prop === \"getExact\") return getExact\n if (prop === \"hasExact\") return hasExact\n if (prop === \"get\") return (key: string) => resolveLocalizedStringEntry(target as LocalizedString, key)\n if (typeof prop === \"string\" && !(prop in target)) {\n return resolveLocalizedStringEntry(target as LocalizedString, prop)\n }\n\n return Reflect.get(target, prop)\n },\n set(target, prop, next) {\n return Reflect.set(target, prop, next)\n },\n }) as LocalizedStringWithFallback\n}\n\nexport const zLocalizedString = () => {\n const languageCodeSchema = z\n .string()\n .regex(LANGUAGE_CODE_REGEX, { message: \"Expected a language code (BCP 47, e.g. en or fr-FR).\" })\n const entrySchema = z.object({\n value: z.string(),\n updatedAt: z.date(),\n autoTranslated: z.boolean().optional(),\n }).passthrough()\n const schema = z.record(\n languageCodeSchema,\n entrySchema,\n )\n\n return schema\n}\n\nexport const zI18nString = zLocalizedString\n","import { z } from \"zod\"\n\n\nexport const E164_PHONE_REGEX = /^\\+[1-9]\\d{1,14}$/\nexport const E164_PHONE_OR_EMPTY_REGEX = /^(?:\\+[1-9]\\d{1,14})?$/\n\nexport type E164PhoneOptions = {\n allowEmpty?: boolean\n}\n\nexport const makeZE164Phone = (zod: typeof z, options?: E164PhoneOptions) => {\n const allowEmpty = options?.allowEmpty ?? false\n return zod.string().trim().regex(allowEmpty ? E164_PHONE_OR_EMPTY_REGEX : E164_PHONE_REGEX, {\n message: allowEmpty\n ? \"Expected an empty string or a phone number in E.164 format (e.g. +33608707197).\"\n : \"Expected a phone number in E.164 format (e.g. +33608707197).\",\n })\n}\n\nexport const zE164Phone = (options?: E164PhoneOptions) => makeZE164Phone(z, options)\n","import { z } from \"zod\"\n\nimport { type E164PhoneOptions, makeZE164Phone } from \"./e164Phone\"\n\n\ntype RpcbaseZodExtension = typeof z & {\n e164Phone?: (options?: E164PhoneOptions) => z.ZodString\n}\n\ntype ExtendableZodPrototype = {\n unique?: (this: unknown, arg?: boolean) => unknown\n sparse?: (this: unknown, arg?: boolean) => unknown\n}\n\ndeclare module \"zod\" {\n interface ZodString {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n interface ZodNumber {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n interface ZodDate {\n unique(arg?: boolean): this\n sparse(arg?: boolean): this\n }\n\n}\n\nlet zodPrototypesExtended = false\n\nexport function extendZod(zod: typeof z) {\n const zodWithExtension = zod as RpcbaseZodExtension\n if (Object.isExtensible(zodWithExtension) && typeof zodWithExtension.e164Phone !== \"function\") {\n zodWithExtension.e164Phone = (options?: E164PhoneOptions) => makeZE164Phone(zod, options)\n }\n\n if (zodPrototypesExtended) return\n zodPrototypesExtended = true\n\n const supported = [zod.ZodString, zod.ZodNumber, zod.ZodDate] as const\n for (const type of supported) {\n const proto = type?.prototype as ExtendableZodPrototype | undefined\n if (!proto) continue\n\n proto.unique = function unique(this: unknown, _flag = true) {\n return this\n }\n\n proto.sparse = function sparse(this: unknown, _flag = true) {\n return this\n }\n }\n}\n","import { z as baseZ, type ZodError, type ZodString, type ZodType } from \"zod\"\n\nimport { extendZod } from \"./extension\"\n\n\nexport * from \"./e164Phone\"\nexport * from \"./localizedString\"\n\nexport type RpcbaseZod = typeof baseZ & {\n e164Phone: (options?: import(\"./e164Phone\").E164PhoneOptions) => ZodString\n}\n\nexport const z = Object.create(baseZ) as RpcbaseZod\nextendZod(z)\n\nexport namespace z {\n export type infer<T> = import(\"zod\").infer<T>\n export type input<T> = import(\"zod\").input<T>\n export type output<T> = import(\"zod\").output<T>\n export type TypeOf<T> = import(\"zod\").TypeOf<T>\n export type Infer<T> = import(\"zod\").Infer<T>\n}\n\nexport { extendZod, ZodError, ZodType }\n"],"mappings":";;AA0BA,IAAa,sBAAsB;AAEnC,IAAM,+CAA+B,IAAI,QAAyB;AAElE,SAAS,gBAAgB,QAAwB;CAC/C,MAAM,UAAU,OAAO,KAAK;CAC5B,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,sBAAuB,KAE1B;CACH,IAAI,OAAO,wBAAwB,YAAY,OAAO;CACtD,IAAI;EACF,OAAO,oBAAoB,OAAO,CAAC,CAAC,MAAM;CAC5C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,yBAAyB,QAAgB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C;AACH;AAEA,IAAa,cAAc,YAA+B,eAAe,GAAG,OAAO;;;ACanF,IAAI,wBAAwB;AAE5B,SAAgB,UAAU,KAAe;CACvC,MAAM,mBAAmB;CACzB,IAAI,OAAO,aAAa,gBAAgB,KAAK,OAAO,iBAAiB,cAAc,YACjF,iBAAiB,aAAa,YAA+B,eAAe,KAAK,OAAO;CAG1F,IAAI,uBAAuB;CAC3B,wBAAwB;CAExB,MAAM,YAAY;EAAC,IAAI;EAAW,IAAI;EAAW,IAAI;CAAO;CAC5D,KAAK,MAAM,QAAQ,WAAW;EAC5B,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,OAAO;EAEZ,MAAM,SAAS,SAAS,OAAsB,QAAQ,MAAM;GAC1D,OAAO;EACT;EAEA,MAAM,SAAS,SAAS,OAAsB,QAAQ,MAAM;GAC1D,OAAO;EACT;CACF;AACF;;;AC5CA,IAAa,MAAI,OAAO,OAAO,CAAK;AACpC,UAAU,GAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/db",
3
- "version": "0.148.0",
3
+ "version": "0.150.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -99,12 +99,12 @@
99
99
  "dependencies": {
100
100
  "@rpcbase/migrations": "*",
101
101
  "@rpcbase/billing": "*",
102
- "@casl/ability": "6.8.0",
103
- "@casl/mongoose": "8.0.5"
102
+ "@casl/ability": "7.0.1",
103
+ "@casl/mongoose": "9.0.2"
104
104
  },
105
105
  "devDependencies": {
106
- "@types/node": "25.5.2",
107
- "@vitest/coverage-v8": "4.1.2",
108
- "vitest": "4.1.2"
106
+ "@types/node": "26.3.0",
107
+ "@vitest/coverage-v8": "4.1.11",
108
+ "vitest": "4.1.11"
109
109
  }
110
110
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"rtsChanges-xIGFCLGa.js","names":["ttlSecondsRaw","process","env","RB_RTS_CHANGES_TTL_S","rtsChangesTtlSeconds","Number","isFinite","Math","max","floor"],"sources":["../src/migrations/rtsChanges.ts"],"sourcesContent":["const ttlSecondsRaw = process.env.RB_RTS_CHANGES_TTL_S ?? \"\"\n\nexport const rtsChangesTtlSeconds = Number.isFinite(Number(ttlSecondsRaw))\n ? Math.max(60, Math.floor(Number(ttlSecondsRaw)))\n : 60 * 60 * 24 * 30\n"],"mappings":";AAAA,IAAMA,gBAAgBC,QAAQC,IAAIC,wBAAwB;AAE1D,IAAaC,uBAAuBC,OAAOC,SAASD,OAAOL,aAAa,CAAC,IACrEO,KAAKC,IAAI,IAAID,KAAKE,MAAMJ,OAAOL,aAAa,CAAC,CAAC,IAC9C,OAAU,KAAK"}