@rpcbase/db 0.23.0 → 0.24.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.
- package/dist/index.js +10 -10
- package/dist/loadModel.d.ts +1 -1
- package/dist/loadModel.d.ts.map +1 -1
- package/dist/models/Tenant.d.ts +2 -2
- package/dist/models/User.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ const ZRBUser = z.object({
|
|
|
9
9
|
name: z.string().optional(),
|
|
10
10
|
phone: z.string().optional(),
|
|
11
11
|
tenants: z.array(z.string()),
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
emailVerificationCode: z.string().length(6).optional(),
|
|
13
|
+
emailVerificationExpiresAt: z.date().optional()
|
|
14
14
|
});
|
|
15
15
|
const RBUserSchema = new Schema({
|
|
16
16
|
email: { type: String, unique: true, sparse: true },
|
|
@@ -18,17 +18,17 @@ const RBUserSchema = new Schema({
|
|
|
18
18
|
password: { type: String, required: true },
|
|
19
19
|
name: String,
|
|
20
20
|
tenants: { type: [String], index: true, required: true },
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
emailVerificationCode: { type: String, required: false },
|
|
22
|
+
emailVerificationExpiresAt: { type: Date, required: false }
|
|
23
23
|
}, { collection: "users" });
|
|
24
24
|
const ZRBTenant = z.object({
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
tenantId: z.string(),
|
|
26
|
+
parentTenantId: z.string().optional(),
|
|
27
27
|
name: z.string().optional()
|
|
28
28
|
});
|
|
29
29
|
const RBTenantSchema = new Schema({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
tenantId: { type: String, required: true, unique: true, index: true },
|
|
31
|
+
parentTenantId: { type: String },
|
|
32
32
|
name: { type: String }
|
|
33
33
|
}, { collection: "tenants" });
|
|
34
34
|
const ZRBRtsCounter = z.object({
|
|
@@ -1119,7 +1119,7 @@ const loadModelFromDb = async (modelName, dbName) => {
|
|
|
1119
1119
|
};
|
|
1120
1120
|
const loadModel = async (modelName, ctx) => {
|
|
1121
1121
|
assertTenantModelName(modelName);
|
|
1122
|
-
const tenantId = ctx.req.session?.user?.
|
|
1122
|
+
const tenantId = ctx.req.session?.user?.currentTenantId;
|
|
1123
1123
|
assert(typeof tenantId === "string" && tenantId.trim(), "Tenant ID is missing from session");
|
|
1124
1124
|
const dbName = `${APP_NAME}-${tenantId.trim()}-db`;
|
|
1125
1125
|
return loadModelFromDb(modelName, dbName);
|
|
@@ -1150,7 +1150,7 @@ const normalizeTenantId = (tenantId) => {
|
|
|
1150
1150
|
const getTenantFilesystemDbName = (tenantId) => `${getAppName()}-${normalizeTenantId(tenantId)}-filesystem-db`;
|
|
1151
1151
|
const getTenantFilesystemDb = async (tenantId) => ensureMongooseConnection(getTenantFilesystemDbName(tenantId));
|
|
1152
1152
|
const getTenantFilesystemDbFromCtx = async (ctx) => {
|
|
1153
|
-
const tenantId = ctx.req.session?.user?.
|
|
1153
|
+
const tenantId = ctx.req.session?.user?.currentTenantId;
|
|
1154
1154
|
assert(typeof tenantId === "string" && tenantId.trim(), "Tenant ID is missing from session");
|
|
1155
1155
|
return getTenantFilesystemDb(tenantId);
|
|
1156
1156
|
};
|
package/dist/loadModel.d.ts
CHANGED
package/dist/loadModel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadModel.d.ts","sourceRoot":"","sources":["../src/loadModel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAMpC,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE;QACH,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,EAAE;gBACL,
|
|
1
|
+
{"version":3,"file":"loadModel.d.ts","sourceRoot":"","sources":["../src/loadModel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAMpC,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE;QACH,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,EAAE;gBACL,eAAe,CAAC,EAAE,MAAM,CAAC;aAC1B,CAAA;SACF,GAAG,IAAI,CAAC;KACV,CAAC;CACH,CAAC;AAuCF,eAAO,MAAM,SAAS,GAAU,WAAW,MAAM,EAAE,KAAK,YAAY,4DAOnE,CAAA;AAED,eAAO,MAAM,WAAW,GAAU,WAAW,MAAM,EAAE,MAAM,YAAY,4DAItE,CAAA;AAED,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/models/Tenant.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
2
|
import { z } from '../../../vite/node_modules/zod';
|
|
3
3
|
export declare const ZRBTenant: z.ZodObject<{
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tenantId: z.ZodString;
|
|
5
|
+
parentTenantId: z.ZodOptional<z.ZodString>;
|
|
6
6
|
name: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
8
|
export type IRBTenant = z.infer<typeof ZRBTenant>;
|
package/dist/models/User.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const ZRBUser: z.ZodObject<{
|
|
|
6
6
|
name: z.ZodOptional<z.ZodString>;
|
|
7
7
|
phone: z.ZodOptional<z.ZodString>;
|
|
8
8
|
tenants: z.ZodArray<z.ZodString>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
emailVerificationCode: z.ZodOptional<z.ZodString>;
|
|
10
|
+
emailVerificationExpiresAt: z.ZodOptional<z.ZodDate>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
export type IRBUser = z.infer<typeof ZRBUser>;
|
|
13
13
|
export declare const RBUserSchema: Schema;
|