@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 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
- email_verification_code: z.string().length(6).optional(),
13
- email_verification_expires_at: z.date().optional()
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
- email_verification_code: { type: String, required: false },
22
- email_verification_expires_at: { type: Date, required: false }
21
+ emailVerificationCode: { type: String, required: false },
22
+ emailVerificationExpiresAt: { type: Date, required: false }
23
23
  }, { collection: "users" });
24
24
  const ZRBTenant = z.object({
25
- tenant_id: z.string(),
26
- parent_tenant_id: z.string().optional(),
25
+ tenantId: z.string(),
26
+ parentTenantId: z.string().optional(),
27
27
  name: z.string().optional()
28
28
  });
29
29
  const RBTenantSchema = new Schema({
30
- tenant_id: { type: String, required: true, unique: true, index: true },
31
- parent_tenant_id: { type: String },
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?.current_tenant_id;
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?.current_tenant_id;
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
  };
@@ -3,7 +3,7 @@ type LoadModelCtx = {
3
3
  req: {
4
4
  session?: {
5
5
  user?: {
6
- current_tenant_id?: string;
6
+ currentTenantId?: string;
7
7
  };
8
8
  } | null;
9
9
  };
@@ -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,iBAAiB,CAAC,EAAE,MAAM,CAAC;aAC5B,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"}
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"}
@@ -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
- tenant_id: z.ZodString;
5
- parent_tenant_id: z.ZodOptional<z.ZodString>;
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>;
@@ -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
- email_verification_code: z.ZodOptional<z.ZodString>;
10
- email_verification_expires_at: z.ZodOptional<z.ZodDate>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/db",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"