@rpcbase/db 0.24.0 → 0.26.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/createModels.d.ts +3 -2
- package/dist/createModels.d.ts.map +1 -1
- package/dist/index.js +251 -1
- package/dist/loadModel.d.ts.map +1 -1
- package/dist/models/RBNotification.d.ts +17 -0
- package/dist/models/RBNotification.d.ts.map +1 -0
- package/dist/models/RBNotificationSettings.d.ts +31 -0
- package/dist/models/RBNotificationSettings.d.ts.map +1 -0
- package/dist/models/RBTenantSubscription.d.ts +70 -0
- package/dist/models/RBTenantSubscription.d.ts.map +1 -0
- package/dist/models/RBTenantSubscriptionEvent.d.ts +72 -0
- package/dist/models/RBTenantSubscriptionEvent.d.ts.map +1 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/createModels.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ type ExtractModelNamesFromSchemas<TModules> = {
|
|
|
6
6
|
}[keyof TModules] & string;
|
|
7
7
|
type FrameworkModelName = ExtractModelNamesFromSchemas<typeof frameworkSchemas>;
|
|
8
8
|
type WithoutRbPrefix<TName extends string> = TName extends `RB${string}` ? never : TName;
|
|
9
|
-
|
|
10
|
-
export type
|
|
9
|
+
type TenantInternalRbModelName = "RBUploadSession" | "RBUploadChunk" | "RBNotification" | "RBNotificationSettings";
|
|
10
|
+
export type TenantModelName<TModules extends ModelModules> = WithoutRbPrefix<ExtractModelNamesFromSchemas<TModules>> | WithoutRbPrefix<FrameworkModelName> | TenantInternalRbModelName;
|
|
11
|
+
export type RbModelName = ExtractModelNamesFromSchemas<typeof frameworkSchemas> extends infer Name ? Name extends string ? Name extends `RB${string}` ? Name extends "RBRtsChange" | "RBRtsCounter" | "RBUploadSession" | "RBUploadChunk" | "RBNotification" | "RBNotificationSettings" ? never : Name : never : never : never;
|
|
11
12
|
export type ModelsClient<TModules extends ModelModules> = {
|
|
12
13
|
register: (modules: TModules) => void;
|
|
13
14
|
get: (modelName: TenantModelName<TModules>, ctx: LoadModelCtx) => ReturnType<typeof loadModel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModels.d.ts","sourceRoot":"","sources":["../src/createModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,KAAK,gBAAgB,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAIpD,KAAK,4BAA4B,CAAC,QAAQ,IAAI;KAC3C,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,IAAI,QAAQ,GAAG,IAAI,GAAG,KAAK;CACxE,CAAC,MAAM,QAAQ,CAAC,GAAG,MAAM,CAAA;AAE1B,KAAK,kBAAkB,GAAG,4BAA4B,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/E,KAAK,eAAe,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,SAAS,KAAK,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK,CAAA;AAExF,MAAM,MAAM,eAAe,CAAC,QAAQ,SAAS,YAAY,IACrD,eAAe,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,GACvD,eAAe,CAAC,kBAAkB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"createModels.d.ts","sourceRoot":"","sources":["../src/createModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,KAAK,gBAAgB,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAIpD,KAAK,4BAA4B,CAAC,QAAQ,IAAI;KAC3C,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,IAAI,QAAQ,GAAG,IAAI,GAAG,KAAK;CACxE,CAAC,MAAM,QAAQ,CAAC,GAAG,MAAM,CAAA;AAE1B,KAAK,kBAAkB,GAAG,4BAA4B,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/E,KAAK,eAAe,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,SAAS,KAAK,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK,CAAA;AAExF,KAAK,yBAAyB,GAC1B,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,wBAAwB,CAAA;AAE5B,MAAM,MAAM,eAAe,CAAC,QAAQ,SAAS,YAAY,IACrD,eAAe,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,GACvD,eAAe,CAAC,kBAAkB,CAAC,GACnC,yBAAyB,CAAA;AAE7B,MAAM,MAAM,WAAW,GAAG,4BAA4B,CAAC,OAAO,gBAAgB,CAAC,SAAS,MAAM,IAAI,GAC9F,IAAI,SAAS,MAAM,GACjB,IAAI,SAAS,KAAK,MAAM,EAAE,GACxB,IAAI,SACF,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,wBAAwB,GACxB,KAAK,GACL,IAAI,GACN,KAAK,GACP,KAAK,GACP,KAAK,CAAA;AAET,MAAM,MAAM,YAAY,CAAC,QAAQ,SAAS,YAAY,IAAI;IACxD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAA;IACrC,GAAG,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,YAAY,KAAK,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;IAC9F,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,KAAK,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;CACrF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,YAAY,EAAE,SAAS,QAAQ,KAAG,YAAY,CAAC,QAAQ,CAQpG,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,142 @@ const RBTenantSchema = new Schema({
|
|
|
31
31
|
parentTenantId: { type: String },
|
|
32
32
|
name: { type: String }
|
|
33
33
|
}, { collection: "tenants" });
|
|
34
|
+
const ZRBTenantSubscriptionStatus = z.enum([
|
|
35
|
+
"trialing",
|
|
36
|
+
"active",
|
|
37
|
+
"past_due",
|
|
38
|
+
"paused",
|
|
39
|
+
"canceled",
|
|
40
|
+
"expired"
|
|
41
|
+
]);
|
|
42
|
+
const ZRBTenantSubscriptionIntervalUnit = z.enum(["day", "month", "year"]);
|
|
43
|
+
const ZRBTenantSubscriptionType = z.enum(["primary", "addon"]);
|
|
44
|
+
const ZRBTenantSubscriptionScope = z.enum(["tenant", "shop", "custom"]);
|
|
45
|
+
const ZRBTenantSubscription = z.object({
|
|
46
|
+
tenantId: z.string(),
|
|
47
|
+
subscriptionId: z.string(),
|
|
48
|
+
type: ZRBTenantSubscriptionType.optional(),
|
|
49
|
+
parentSubscriptionId: z.string().optional(),
|
|
50
|
+
scope: ZRBTenantSubscriptionScope.optional(),
|
|
51
|
+
scopeId: z.string().optional(),
|
|
52
|
+
planKey: z.string(),
|
|
53
|
+
status: ZRBTenantSubscriptionStatus,
|
|
54
|
+
intervalUnit: ZRBTenantSubscriptionIntervalUnit,
|
|
55
|
+
intervalCount: z.number().int().min(1).optional(),
|
|
56
|
+
modules: z.array(z.string()).optional(),
|
|
57
|
+
currentPeriodStart: z.date().optional(),
|
|
58
|
+
currentPeriodEnd: z.date().optional(),
|
|
59
|
+
trialEndsAt: z.date().optional(),
|
|
60
|
+
cancelAt: z.date().optional(),
|
|
61
|
+
cancelAtPeriodEnd: z.boolean().optional(),
|
|
62
|
+
canceledAt: z.date().optional(),
|
|
63
|
+
provider: z.string().optional(),
|
|
64
|
+
providerCustomerId: z.string().optional(),
|
|
65
|
+
providerSubscriptionId: z.string().optional(),
|
|
66
|
+
latestEventId: z.string().optional(),
|
|
67
|
+
latestEventAt: z.date().optional(),
|
|
68
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
69
|
+
});
|
|
70
|
+
const RBTenantSubscriptionSchema = new Schema(
|
|
71
|
+
{
|
|
72
|
+
tenantId: { type: String, required: true, index: true },
|
|
73
|
+
subscriptionId: { type: String, required: true },
|
|
74
|
+
type: { type: String, required: true, enum: ZRBTenantSubscriptionType.options, default: "primary" },
|
|
75
|
+
parentSubscriptionId: { type: String },
|
|
76
|
+
scope: { type: String, enum: ZRBTenantSubscriptionScope.options, default: "tenant" },
|
|
77
|
+
scopeId: { type: String },
|
|
78
|
+
planKey: { type: String, required: true },
|
|
79
|
+
status: { type: String, required: true, enum: ZRBTenantSubscriptionStatus.options },
|
|
80
|
+
intervalUnit: { type: String, required: true, enum: ZRBTenantSubscriptionIntervalUnit.options },
|
|
81
|
+
intervalCount: { type: Number, min: 1, default: 1 },
|
|
82
|
+
modules: { type: [String], default: [] },
|
|
83
|
+
currentPeriodStart: { type: Date },
|
|
84
|
+
currentPeriodEnd: { type: Date },
|
|
85
|
+
trialEndsAt: { type: Date },
|
|
86
|
+
cancelAt: { type: Date },
|
|
87
|
+
cancelAtPeriodEnd: { type: Boolean, default: false },
|
|
88
|
+
canceledAt: { type: Date },
|
|
89
|
+
provider: { type: String },
|
|
90
|
+
providerCustomerId: { type: String },
|
|
91
|
+
providerSubscriptionId: { type: String },
|
|
92
|
+
latestEventId: { type: String },
|
|
93
|
+
latestEventAt: { type: Date },
|
|
94
|
+
metadata: { type: Schema.Types.Mixed }
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
collection: "tenantSubscriptions"
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
RBTenantSubscriptionSchema.index({ tenantId: 1, subscriptionId: 1 }, { unique: true });
|
|
101
|
+
RBTenantSubscriptionSchema.index({ tenantId: 1, scope: 1, scopeId: 1 });
|
|
102
|
+
const ZRBTenantSubscriptionEventSource = z.enum([
|
|
103
|
+
"admin",
|
|
104
|
+
"system",
|
|
105
|
+
"webhook",
|
|
106
|
+
"user"
|
|
107
|
+
]);
|
|
108
|
+
const ZRBTenantSubscriptionChangeDirection = z.enum([
|
|
109
|
+
"upgrade",
|
|
110
|
+
"downgrade",
|
|
111
|
+
"lateral"
|
|
112
|
+
]);
|
|
113
|
+
const ZRBTenantSubscriptionEvent = z.object({
|
|
114
|
+
tenantId: z.string(),
|
|
115
|
+
subscriptionId: z.string(),
|
|
116
|
+
type: z.string(),
|
|
117
|
+
occurredAt: z.date(),
|
|
118
|
+
effectiveAt: z.date().optional(),
|
|
119
|
+
fromPlanKey: z.string().optional(),
|
|
120
|
+
toPlanKey: z.string().optional(),
|
|
121
|
+
fromStatus: ZRBTenantSubscriptionStatus.optional(),
|
|
122
|
+
toStatus: ZRBTenantSubscriptionStatus.optional(),
|
|
123
|
+
fromModules: z.array(z.string()).optional(),
|
|
124
|
+
toModules: z.array(z.string()).optional(),
|
|
125
|
+
fromIntervalUnit: ZRBTenantSubscriptionIntervalUnit.optional(),
|
|
126
|
+
toIntervalUnit: ZRBTenantSubscriptionIntervalUnit.optional(),
|
|
127
|
+
fromIntervalCount: z.number().int().min(1).optional(),
|
|
128
|
+
toIntervalCount: z.number().int().min(1).optional(),
|
|
129
|
+
direction: ZRBTenantSubscriptionChangeDirection.optional(),
|
|
130
|
+
actorUserId: z.string().optional(),
|
|
131
|
+
source: ZRBTenantSubscriptionEventSource.optional(),
|
|
132
|
+
reason: z.string().optional(),
|
|
133
|
+
provider: z.string().optional(),
|
|
134
|
+
providerEventId: z.string().optional(),
|
|
135
|
+
providerPayload: z.unknown().optional(),
|
|
136
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
137
|
+
});
|
|
138
|
+
const RBTenantSubscriptionEventSchema = new Schema(
|
|
139
|
+
{
|
|
140
|
+
tenantId: { type: String, required: true, index: true },
|
|
141
|
+
subscriptionId: { type: String, required: true, index: true },
|
|
142
|
+
type: { type: String, required: true },
|
|
143
|
+
occurredAt: { type: Date, required: true, default: Date.now },
|
|
144
|
+
effectiveAt: { type: Date },
|
|
145
|
+
fromPlanKey: { type: String },
|
|
146
|
+
toPlanKey: { type: String },
|
|
147
|
+
fromStatus: { type: String, enum: ZRBTenantSubscriptionStatus.options },
|
|
148
|
+
toStatus: { type: String, enum: ZRBTenantSubscriptionStatus.options },
|
|
149
|
+
fromModules: { type: [String], default: void 0 },
|
|
150
|
+
toModules: { type: [String], default: void 0 },
|
|
151
|
+
fromIntervalUnit: { type: String, enum: ZRBTenantSubscriptionIntervalUnit.options },
|
|
152
|
+
toIntervalUnit: { type: String, enum: ZRBTenantSubscriptionIntervalUnit.options },
|
|
153
|
+
fromIntervalCount: { type: Number, min: 1 },
|
|
154
|
+
toIntervalCount: { type: Number, min: 1 },
|
|
155
|
+
direction: { type: String, enum: ZRBTenantSubscriptionChangeDirection.options },
|
|
156
|
+
actorUserId: { type: String },
|
|
157
|
+
source: { type: String, enum: ZRBTenantSubscriptionEventSource.options },
|
|
158
|
+
reason: { type: String },
|
|
159
|
+
provider: { type: String },
|
|
160
|
+
providerEventId: { type: String },
|
|
161
|
+
providerPayload: { type: Schema.Types.Mixed },
|
|
162
|
+
metadata: { type: Schema.Types.Mixed }
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
collection: "tenantSubscriptionEvents"
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
RBTenantSubscriptionEventSchema.index({ tenantId: 1, subscriptionId: 1, occurredAt: 1 });
|
|
169
|
+
RBTenantSubscriptionEventSchema.index({ provider: 1, providerEventId: 1 }, { unique: true, sparse: true });
|
|
34
170
|
const ZRBRtsCounter = z.object({
|
|
35
171
|
_id: z.string(),
|
|
36
172
|
seq: z.number().int().min(0)
|
|
@@ -134,18 +270,114 @@ const RBUploadChunkSchema = new Schema(
|
|
|
134
270
|
);
|
|
135
271
|
RBUploadChunkSchema.index({ uploadId: 1, index: 1 }, { unique: true });
|
|
136
272
|
RBUploadChunkSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
273
|
+
const ZRBNotification = z.object({
|
|
274
|
+
userId: z.string(),
|
|
275
|
+
topic: z.string().optional(),
|
|
276
|
+
title: z.string(),
|
|
277
|
+
body: z.string().optional(),
|
|
278
|
+
url: z.string().optional(),
|
|
279
|
+
createdAt: z.date(),
|
|
280
|
+
seenAt: z.date().optional(),
|
|
281
|
+
readAt: z.date().optional(),
|
|
282
|
+
archivedAt: z.date().optional(),
|
|
283
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
284
|
+
});
|
|
285
|
+
const TTL_90_DAYS_S = 60 * 60 * 24 * 90;
|
|
286
|
+
const RBNotificationSchema = new Schema(
|
|
287
|
+
{
|
|
288
|
+
userId: { type: String, required: true, index: true },
|
|
289
|
+
topic: { type: String, required: false, index: true },
|
|
290
|
+
title: { type: String, required: true },
|
|
291
|
+
body: { type: String, required: false },
|
|
292
|
+
url: { type: String, required: false },
|
|
293
|
+
createdAt: { type: Date, required: true, default: Date.now, index: true },
|
|
294
|
+
seenAt: { type: Date, required: false, index: true },
|
|
295
|
+
readAt: { type: Date, required: false, index: true },
|
|
296
|
+
archivedAt: { type: Date, required: false },
|
|
297
|
+
metadata: { type: Schema.Types.Mixed, required: false }
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
versionKey: false,
|
|
301
|
+
collection: "notifications"
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
RBNotificationSchema.index({ userId: 1, archivedAt: 1, createdAt: -1 });
|
|
305
|
+
RBNotificationSchema.index({ userId: 1, seenAt: 1, archivedAt: 1, createdAt: -1 });
|
|
306
|
+
RBNotificationSchema.index({ userId: 1, readAt: 1, archivedAt: 1, createdAt: -1 });
|
|
307
|
+
RBNotificationSchema.index({ archivedAt: 1 }, { expireAfterSeconds: TTL_90_DAYS_S });
|
|
308
|
+
const ZRBNotificationDigestFrequency = z.enum(["off", "daily", "weekly"]);
|
|
309
|
+
const ZRBNotificationTopicPreference = z.object({
|
|
310
|
+
topic: z.string(),
|
|
311
|
+
inApp: z.boolean(),
|
|
312
|
+
emailDigest: z.boolean(),
|
|
313
|
+
push: z.boolean()
|
|
314
|
+
});
|
|
315
|
+
const ZRBNotificationSettings = z.object({
|
|
316
|
+
userId: z.string(),
|
|
317
|
+
digestFrequency: ZRBNotificationDigestFrequency,
|
|
318
|
+
topicPreferences: z.array(ZRBNotificationTopicPreference).optional(),
|
|
319
|
+
lastDigestSentAt: z.date().optional()
|
|
320
|
+
});
|
|
321
|
+
const TopicPreferenceSchema = new Schema(
|
|
322
|
+
{
|
|
323
|
+
topic: { type: String, required: true },
|
|
324
|
+
inApp: { type: Boolean, required: true, default: true },
|
|
325
|
+
emailDigest: { type: Boolean, required: true, default: true },
|
|
326
|
+
push: { type: Boolean, required: true, default: false }
|
|
327
|
+
},
|
|
328
|
+
{ _id: false }
|
|
329
|
+
);
|
|
330
|
+
const RBNotificationSettingsSchema = new Schema(
|
|
331
|
+
{
|
|
332
|
+
userId: { type: String, required: true },
|
|
333
|
+
digestFrequency: {
|
|
334
|
+
type: String,
|
|
335
|
+
required: true,
|
|
336
|
+
enum: ZRBNotificationDigestFrequency.options,
|
|
337
|
+
default: "weekly"
|
|
338
|
+
},
|
|
339
|
+
topicPreferences: {
|
|
340
|
+
type: [TopicPreferenceSchema],
|
|
341
|
+
default: []
|
|
342
|
+
},
|
|
343
|
+
lastDigestSentAt: { type: Date, required: false }
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
versionKey: false,
|
|
347
|
+
collection: "notificationSettings",
|
|
348
|
+
timestamps: true
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
RBNotificationSettingsSchema.index({ userId: 1 }, { unique: true });
|
|
352
|
+
RBNotificationSettingsSchema.index({ userId: 1, "topicPreferences.topic": 1 });
|
|
137
353
|
const frameworkSchemas = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
138
354
|
__proto__: null,
|
|
355
|
+
RBNotificationSchema,
|
|
356
|
+
RBNotificationSettingsSchema,
|
|
139
357
|
RBRtsChangeSchema,
|
|
140
358
|
RBRtsCounterSchema,
|
|
141
359
|
RBTenantSchema,
|
|
360
|
+
RBTenantSubscriptionEventSchema,
|
|
361
|
+
RBTenantSubscriptionSchema,
|
|
142
362
|
RBUploadChunkSchema,
|
|
143
363
|
RBUploadSessionSchema,
|
|
144
364
|
RBUserSchema,
|
|
365
|
+
ZRBNotification,
|
|
366
|
+
ZRBNotificationDigestFrequency,
|
|
367
|
+
ZRBNotificationSettings,
|
|
368
|
+
ZRBNotificationTopicPreference,
|
|
145
369
|
ZRBRtsChange,
|
|
146
370
|
ZRBRtsChangeOp,
|
|
147
371
|
ZRBRtsCounter,
|
|
148
372
|
ZRBTenant,
|
|
373
|
+
ZRBTenantSubscription,
|
|
374
|
+
ZRBTenantSubscriptionChangeDirection,
|
|
375
|
+
ZRBTenantSubscriptionEvent,
|
|
376
|
+
ZRBTenantSubscriptionEventSource,
|
|
377
|
+
ZRBTenantSubscriptionIntervalUnit,
|
|
378
|
+
ZRBTenantSubscriptionScope,
|
|
379
|
+
ZRBTenantSubscriptionStatus,
|
|
380
|
+
ZRBTenantSubscriptionType,
|
|
149
381
|
ZRBUploadChunk,
|
|
150
382
|
ZRBUploadSession,
|
|
151
383
|
ZRBUploadSessionStatus,
|
|
@@ -1094,7 +1326,9 @@ const TENANT_INTERNAL_MODEL_NAMES = /* @__PURE__ */ new Set([
|
|
|
1094
1326
|
"RBRtsChange",
|
|
1095
1327
|
"RBRtsCounter",
|
|
1096
1328
|
"RBUploadSession",
|
|
1097
|
-
"RBUploadChunk"
|
|
1329
|
+
"RBUploadChunk",
|
|
1330
|
+
"RBNotification",
|
|
1331
|
+
"RBNotificationSettings"
|
|
1098
1332
|
]);
|
|
1099
1333
|
const assertTenantModelName = (modelName) => {
|
|
1100
1334
|
if (TENANT_INTERNAL_MODEL_NAMES.has(modelName)) return;
|
|
@@ -1156,16 +1390,32 @@ const getTenantFilesystemDbFromCtx = async (ctx) => {
|
|
|
1156
1390
|
};
|
|
1157
1391
|
export {
|
|
1158
1392
|
LANGUAGE_CODE_REGEX,
|
|
1393
|
+
RBNotificationSchema,
|
|
1394
|
+
RBNotificationSettingsSchema,
|
|
1159
1395
|
RBRtsChangeSchema,
|
|
1160
1396
|
RBRtsCounterSchema,
|
|
1161
1397
|
RBTenantSchema,
|
|
1398
|
+
RBTenantSubscriptionEventSchema,
|
|
1399
|
+
RBTenantSubscriptionSchema,
|
|
1162
1400
|
RBUploadChunkSchema,
|
|
1163
1401
|
RBUploadSessionSchema,
|
|
1164
1402
|
RBUserSchema,
|
|
1403
|
+
ZRBNotification,
|
|
1404
|
+
ZRBNotificationDigestFrequency,
|
|
1405
|
+
ZRBNotificationSettings,
|
|
1406
|
+
ZRBNotificationTopicPreference,
|
|
1165
1407
|
ZRBRtsChange,
|
|
1166
1408
|
ZRBRtsChangeOp,
|
|
1167
1409
|
ZRBRtsCounter,
|
|
1168
1410
|
ZRBTenant,
|
|
1411
|
+
ZRBTenantSubscription,
|
|
1412
|
+
ZRBTenantSubscriptionChangeDirection,
|
|
1413
|
+
ZRBTenantSubscriptionEvent,
|
|
1414
|
+
ZRBTenantSubscriptionEventSource,
|
|
1415
|
+
ZRBTenantSubscriptionIntervalUnit,
|
|
1416
|
+
ZRBTenantSubscriptionScope,
|
|
1417
|
+
ZRBTenantSubscriptionStatus,
|
|
1418
|
+
ZRBTenantSubscriptionType,
|
|
1169
1419
|
ZRBUploadChunk,
|
|
1170
1420
|
ZRBUploadSession,
|
|
1171
1421
|
ZRBUploadSessionStatus,
|
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,eAAe,CAAC,EAAE,MAAM,CAAC;aAC1B,CAAA;SACF,GAAG,IAAI,CAAC;KACV,CAAC;CACH,CAAC;
|
|
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;AAyCF,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZRBNotification: z.ZodObject<{
|
|
4
|
+
userId: z.ZodString;
|
|
5
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodString;
|
|
7
|
+
body: z.ZodOptional<z.ZodString>;
|
|
8
|
+
url: z.ZodOptional<z.ZodString>;
|
|
9
|
+
createdAt: z.ZodDate;
|
|
10
|
+
seenAt: z.ZodOptional<z.ZodDate>;
|
|
11
|
+
readAt: z.ZodOptional<z.ZodDate>;
|
|
12
|
+
archivedAt: z.ZodOptional<z.ZodDate>;
|
|
13
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type IRBNotification = z.infer<typeof ZRBNotification>;
|
|
16
|
+
export declare const RBNotificationSchema: Schema;
|
|
17
|
+
//# sourceMappingURL=RBNotification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RBNotification.d.ts","sourceRoot":"","sources":["../../src/models/RBNotification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,eAAe;;;;;;;;;;;iBAW1B,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAI7D,eAAO,MAAM,oBAAoB,EAAE,MAiBlC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZRBNotificationDigestFrequency: z.ZodEnum<{
|
|
4
|
+
off: "off";
|
|
5
|
+
daily: "daily";
|
|
6
|
+
weekly: "weekly";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const ZRBNotificationTopicPreference: z.ZodObject<{
|
|
9
|
+
topic: z.ZodString;
|
|
10
|
+
inApp: z.ZodBoolean;
|
|
11
|
+
emailDigest: z.ZodBoolean;
|
|
12
|
+
push: z.ZodBoolean;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const ZRBNotificationSettings: z.ZodObject<{
|
|
15
|
+
userId: z.ZodString;
|
|
16
|
+
digestFrequency: z.ZodEnum<{
|
|
17
|
+
off: "off";
|
|
18
|
+
daily: "daily";
|
|
19
|
+
weekly: "weekly";
|
|
20
|
+
}>;
|
|
21
|
+
topicPreferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
|
+
topic: z.ZodString;
|
|
23
|
+
inApp: z.ZodBoolean;
|
|
24
|
+
emailDigest: z.ZodBoolean;
|
|
25
|
+
push: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>>>;
|
|
27
|
+
lastDigestSentAt: z.ZodOptional<z.ZodDate>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type IRBNotificationSettings = z.infer<typeof ZRBNotificationSettings>;
|
|
30
|
+
export declare const RBNotificationSettingsSchema: Schema;
|
|
31
|
+
//# sourceMappingURL=RBNotificationSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RBNotificationSettings.d.ts","sourceRoot":"","sources":["../../src/models/RBNotificationSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,8BAA8B;;;;EAAqC,CAAA;AAEhF,eAAO,MAAM,8BAA8B;;;;;iBAKzC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAKlC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAY7E,eAAO,MAAM,4BAA4B,EAAE,MAoB1C,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZRBTenantSubscriptionStatus: z.ZodEnum<{
|
|
4
|
+
trialing: "trialing";
|
|
5
|
+
active: "active";
|
|
6
|
+
past_due: "past_due";
|
|
7
|
+
paused: "paused";
|
|
8
|
+
canceled: "canceled";
|
|
9
|
+
expired: "expired";
|
|
10
|
+
}>;
|
|
11
|
+
export declare const ZRBTenantSubscriptionIntervalUnit: z.ZodEnum<{
|
|
12
|
+
day: "day";
|
|
13
|
+
month: "month";
|
|
14
|
+
year: "year";
|
|
15
|
+
}>;
|
|
16
|
+
export declare const ZRBTenantSubscriptionType: z.ZodEnum<{
|
|
17
|
+
primary: "primary";
|
|
18
|
+
addon: "addon";
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ZRBTenantSubscriptionScope: z.ZodEnum<{
|
|
21
|
+
custom: "custom";
|
|
22
|
+
tenant: "tenant";
|
|
23
|
+
shop: "shop";
|
|
24
|
+
}>;
|
|
25
|
+
export declare const ZRBTenantSubscription: z.ZodObject<{
|
|
26
|
+
tenantId: z.ZodString;
|
|
27
|
+
subscriptionId: z.ZodString;
|
|
28
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
primary: "primary";
|
|
30
|
+
addon: "addon";
|
|
31
|
+
}>>;
|
|
32
|
+
parentSubscriptionId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
custom: "custom";
|
|
35
|
+
tenant: "tenant";
|
|
36
|
+
shop: "shop";
|
|
37
|
+
}>>;
|
|
38
|
+
scopeId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
planKey: z.ZodString;
|
|
40
|
+
status: z.ZodEnum<{
|
|
41
|
+
trialing: "trialing";
|
|
42
|
+
active: "active";
|
|
43
|
+
past_due: "past_due";
|
|
44
|
+
paused: "paused";
|
|
45
|
+
canceled: "canceled";
|
|
46
|
+
expired: "expired";
|
|
47
|
+
}>;
|
|
48
|
+
intervalUnit: z.ZodEnum<{
|
|
49
|
+
day: "day";
|
|
50
|
+
month: "month";
|
|
51
|
+
year: "year";
|
|
52
|
+
}>;
|
|
53
|
+
intervalCount: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
modules: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
currentPeriodStart: z.ZodOptional<z.ZodDate>;
|
|
56
|
+
currentPeriodEnd: z.ZodOptional<z.ZodDate>;
|
|
57
|
+
trialEndsAt: z.ZodOptional<z.ZodDate>;
|
|
58
|
+
cancelAt: z.ZodOptional<z.ZodDate>;
|
|
59
|
+
cancelAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
canceledAt: z.ZodOptional<z.ZodDate>;
|
|
61
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
62
|
+
providerCustomerId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
providerSubscriptionId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
latestEventId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
latestEventAt: z.ZodOptional<z.ZodDate>;
|
|
66
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type IRBTenantSubscription = z.infer<typeof ZRBTenantSubscription>;
|
|
69
|
+
export declare const RBTenantSubscriptionSchema: Schema;
|
|
70
|
+
//# sourceMappingURL=RBTenantSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RBTenantSubscription.d.ts","sourceRoot":"","sources":["../../src/models/RBTenantSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,2BAA2B;;;;;;;EAOtC,CAAA;AAEF,eAAO,MAAM,iCAAiC;;;;EAAmC,CAAA;AAEjF,eAAO,MAAM,yBAAyB;;;EAA+B,CAAA;AAErE,eAAO,MAAM,0BAA0B;;;;EAAuC,CAAA;AAE9E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwBhC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE,eAAO,MAAM,0BAA0B,EAAE,MA6BxC,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZRBTenantSubscriptionEventSource: z.ZodEnum<{
|
|
4
|
+
admin: "admin";
|
|
5
|
+
system: "system";
|
|
6
|
+
webhook: "webhook";
|
|
7
|
+
user: "user";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const ZRBTenantSubscriptionChangeDirection: z.ZodEnum<{
|
|
10
|
+
upgrade: "upgrade";
|
|
11
|
+
downgrade: "downgrade";
|
|
12
|
+
lateral: "lateral";
|
|
13
|
+
}>;
|
|
14
|
+
export declare const ZRBTenantSubscriptionEvent: z.ZodObject<{
|
|
15
|
+
tenantId: z.ZodString;
|
|
16
|
+
subscriptionId: z.ZodString;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
occurredAt: z.ZodDate;
|
|
19
|
+
effectiveAt: z.ZodOptional<z.ZodDate>;
|
|
20
|
+
fromPlanKey: z.ZodOptional<z.ZodString>;
|
|
21
|
+
toPlanKey: z.ZodOptional<z.ZodString>;
|
|
22
|
+
fromStatus: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
trialing: "trialing";
|
|
24
|
+
active: "active";
|
|
25
|
+
past_due: "past_due";
|
|
26
|
+
paused: "paused";
|
|
27
|
+
canceled: "canceled";
|
|
28
|
+
expired: "expired";
|
|
29
|
+
}>>;
|
|
30
|
+
toStatus: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
trialing: "trialing";
|
|
32
|
+
active: "active";
|
|
33
|
+
past_due: "past_due";
|
|
34
|
+
paused: "paused";
|
|
35
|
+
canceled: "canceled";
|
|
36
|
+
expired: "expired";
|
|
37
|
+
}>>;
|
|
38
|
+
fromModules: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
toModules: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
fromIntervalUnit: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
day: "day";
|
|
42
|
+
month: "month";
|
|
43
|
+
year: "year";
|
|
44
|
+
}>>;
|
|
45
|
+
toIntervalUnit: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
day: "day";
|
|
47
|
+
month: "month";
|
|
48
|
+
year: "year";
|
|
49
|
+
}>>;
|
|
50
|
+
fromIntervalCount: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
toIntervalCount: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
upgrade: "upgrade";
|
|
54
|
+
downgrade: "downgrade";
|
|
55
|
+
lateral: "lateral";
|
|
56
|
+
}>>;
|
|
57
|
+
actorUserId: z.ZodOptional<z.ZodString>;
|
|
58
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
admin: "admin";
|
|
60
|
+
system: "system";
|
|
61
|
+
webhook: "webhook";
|
|
62
|
+
user: "user";
|
|
63
|
+
}>>;
|
|
64
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
65
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
66
|
+
providerEventId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
providerPayload: z.ZodOptional<z.ZodUnknown>;
|
|
68
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type IRBTenantSubscriptionEvent = z.infer<typeof ZRBTenantSubscriptionEvent>;
|
|
71
|
+
export declare const RBTenantSubscriptionEventSchema: Schema;
|
|
72
|
+
//# sourceMappingURL=RBTenantSubscriptionEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RBTenantSubscriptionEvent.d.ts","sourceRoot":"","sources":["../../src/models/RBTenantSubscriptionEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB,eAAO,MAAM,gCAAgC;;;;;EAK3C,CAAA;AAEF,eAAO,MAAM,oCAAoC;;;;EAI/C,CAAA;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwBrC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEnF,eAAO,MAAM,+BAA+B,EAAE,MA6B7C,CAAA"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from './User';
|
|
2
2
|
export * from './Tenant';
|
|
3
|
+
export * from './RBTenantSubscription';
|
|
4
|
+
export * from './RBTenantSubscriptionEvent';
|
|
3
5
|
export * from './RBRtsCounter';
|
|
4
6
|
export * from './RBRtsChange';
|
|
5
7
|
export * from './RBUploadSession';
|
|
6
8
|
export * from './RBUploadChunk';
|
|
9
|
+
export * from './RBNotification';
|
|
10
|
+
export * from './RBNotificationSettings';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA"}
|