@rpcbase/db 0.149.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
1
  import { t as rtsChangesTtlSeconds } from "../rtsChanges-269ntyVt.js";
2
- import { defineMigrationSource, defineMongoResources } from "@rpcbase/migrations";
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":[],"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,IAAM,SAAS;AACf,IAAM,SAAS;AACf,IAAM,QAAQ;AAEd,IAAa,wBAAwB,qBAAqB;CACxD,aAAa;EACX;GAAE,OAAO;GAAQ,MAAM;GAAmB;EAAM;EAChD;GAAE,OAAO;GAAQ,MAAM;GAAa;EAAM;EAC1C;GAAE,OAAO;GAAQ,MAAM;GAAW;EAAM;EACxC;GAAE,OAAO;GAAQ,MAAM;GAA4B;EAAM;EACzD;GAAE,OAAO;GAAQ,MAAM;GAAmB;EAAM;EAChD;GAAE,OAAO;GAAQ,MAAM;GAA0B;EAAM;EACvD;GAAE,OAAO;GAAQ,MAAM;GAAgB;EAAM;EAC7C;GAAE,OAAO;GAAQ,MAAM;GAAiB;EAAM;EAC9C;GAAE,OAAO;GAAQ,MAAM;GAA8B;EAAM;EAC3D;GAAE,OAAO;GAAQ,MAAM;GAAmC;EAAM;EAChE;GAAE,OAAO;GAAQ,MAAM;GAAkB;EAAM;EAC/C;GAAE,OAAO;GAAQ,MAAM;GAAoB;EAAM;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AM;GACN,KAAK;IAAE,UAAU;IAAG,OAAO;GAAE;GAC7B,SAAS,EAAE,QAAQ,KAAK;GACxB;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK,EAAE,WAAW,EAAE;GACpB,SAAS,EAAE,oBAAoB,EAAE;GACjC;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK,EAAE,QAAQ,EAAE;GACjB;EACF;CACF;AACF,CAAC;;;ACvTD,IAAa,yBAAyB,sBAAsB;CAC1D,MAAM;CACN,UAAU;CACV,YAAY,CAAC;CACb,WAAW;CACX,mBAAmB,CAAC,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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AW,EAAE;GACpB,SAAS,EAAE,oBAAoB,EAAE;GACjC;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK,EAAE,UAAU,EAAE;GACnB;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK;IAAE,UAAU;IAAG,OAAO;GAAE;GAC7B,SAAS,EAAE,QAAQ,KAAK;GACxB;EACF;EACA;GACE,OAAO;GACP,YAAY;GACZ,MAAM;GACN,KAAK,EAAE,WAAW,EAAE;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/db",
3
- "version": "0.149.0",
3
+ "version": "0.150.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"