@bizmap/sdk 0.0.131 → 0.0.133

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/main.d.ts CHANGED
@@ -102,10 +102,6 @@ declare const CompanyDetails: z.ZodObject<{
102
102
  current: z.ZodNumber;
103
103
  lastModified: z.ZodOptional<z.ZodISODateTime>;
104
104
  }, z.core.$strip>;
105
- usedStorageInBytes: z.ZodObject<{
106
- current: z.ZodNumber;
107
- lastModified: z.ZodOptional<z.ZodISODateTime>;
108
- }, z.core.$strip>;
109
105
  tierId: z.ZodObject<{
110
106
  current: z.ZodString;
111
107
  lastModified: z.ZodOptional<z.ZodISODateTime>;
@@ -184,10 +180,14 @@ declare const CompanyDetails: z.ZodObject<{
184
180
  staff: z.ZodObject<{
185
181
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
186
182
  lastModified: z.ZodOptional<z.ZodISODateTime>;
183
+ ownerId: z.ZodUUID;
187
184
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
188
185
  invitedAt: z.ZodOptional<z.ZodISODateTime>;
189
186
  joinedAt: z.ZodISODateTime;
190
- lastActive: z.ZodISODateTime;
187
+ lastSession: z.ZodOptional<z.ZodObject<{
188
+ startedAt: z.ZodOptional<z.ZodISODateTime>;
189
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
190
+ }, z.core.$strip>>;
191
191
  roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
192
192
  doc: "doc";
193
193
  physAsst: "physAsst";
@@ -255,10 +255,6 @@ declare const _CompanyDetails: z.ZodObject<{
255
255
  current: z.ZodNumber;
256
256
  lastModified: z.ZodOptional<z.ZodISODateTime>;
257
257
  }, z.core.$strip>;
258
- usedStorageInBytes: z.ZodObject<{
259
- current: z.ZodNumber;
260
- lastModified: z.ZodOptional<z.ZodISODateTime>;
261
- }, z.core.$strip>;
262
258
  tierId: z.ZodObject<{
263
259
  current: z.ZodString;
264
260
  lastModified: z.ZodOptional<z.ZodISODateTime>;
@@ -340,10 +336,14 @@ declare const _CompanyDetails: z.ZodObject<{
340
336
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
341
337
  lastModified: z.ZodOptional<z.ZodISODateTime>;
342
338
  _id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
339
+ ownerId: z.ZodUUID;
343
340
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
344
341
  invitedAt: z.ZodOptional<z.ZodISODateTime>;
345
342
  joinedAt: z.ZodISODateTime;
346
- lastActive: z.ZodISODateTime;
343
+ lastSession: z.ZodOptional<z.ZodObject<{
344
+ startedAt: z.ZodOptional<z.ZodISODateTime>;
345
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
346
+ }, z.core.$strip>>;
347
347
  roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
348
348
  doc: "doc";
349
349
  physAsst: "physAsst";
@@ -683,10 +683,14 @@ declare const CompanyStaff: z.ZodObject<{
683
683
  createdAt: z.ZodReadonly<z.ZodISODateTime>;
684
684
  lastModified: z.ZodOptional<z.ZodISODateTime>;
685
685
  _id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
686
+ ownerId: z.ZodUUID;
686
687
  members: z.ZodRecord<z.ZodUUID, z.ZodObject<{
687
688
  invitedAt: z.ZodOptional<z.ZodISODateTime>;
688
689
  joinedAt: z.ZodISODateTime;
689
- lastActive: z.ZodISODateTime;
690
+ lastSession: z.ZodOptional<z.ZodObject<{
691
+ startedAt: z.ZodOptional<z.ZodISODateTime>;
692
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
693
+ }, z.core.$strip>>;
690
694
  roles: z.ZodPipe<z.ZodArray<z.ZodEnum<{
691
695
  doc: "doc";
692
696
  physAsst: "physAsst";
@@ -750,10 +754,6 @@ declare const CompanyState: z.ZodObject<{
750
754
  current: z.ZodNumber;
751
755
  lastModified: z.ZodOptional<z.ZodISODateTime>;
752
756
  }, z.core.$strip>;
753
- usedStorageInBytes: z.ZodObject<{
754
- current: z.ZodNumber;
755
- lastModified: z.ZodOptional<z.ZodISODateTime>;
756
- }, z.core.$strip>;
757
757
  tierId: z.ZodObject<{
758
758
  current: z.ZodString;
759
759
  lastModified: z.ZodOptional<z.ZodISODateTime>;
@@ -1062,7 +1062,11 @@ declare const UserDetails: z.ZodObject<{
1062
1062
  phoneNumber: z.ZodOptional<z.ZodString>;
1063
1063
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
1064
1064
  publicKey: z.ZodOptional<z.ZodString>;
1065
- availableStorageInBytes: z.ZodOptional<z.ZodNumber>;
1065
+ usedStorageInBytes: z.ZodReadonly<z.ZodRecord<z.ZodUnion<[z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodLiteral<"gp">]>, z.ZodObject<{
1066
+ createdAt: z.ZodReadonly<z.ZodISODateTime>;
1067
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
1068
+ current: z.ZodNumber;
1069
+ }, z.core.$strip>>>;
1066
1070
  lastSignedIn: z.ZodObject<{
1067
1071
  auto: z.ZodOptional<z.ZodISODateTime>;
1068
1072
  manual: z.ZodOptional<z.ZodISODateTime>;
package/dist/main.js CHANGED
@@ -137,10 +137,6 @@ var CompanyState = z6.object({
137
137
  current: z6.number(),
138
138
  lastModified: Timestamp.optional()
139
139
  }),
140
- usedStorageInBytes: z6.object({
141
- current: z6.number(),
142
- lastModified: Timestamp.optional()
143
- }),
144
140
  tierId: z6.object({
145
141
  current: z6.string(),
146
142
  lastModified: Timestamp.optional()
@@ -314,12 +310,21 @@ var UserDetails = z11.object({
314
310
  }),
315
311
  email: UserModel.shape.email,
316
312
  publicKey: z11.string().optional(),
317
- availableStorageInBytes: z11.number().optional(),
313
+ // Used to track the user's general purpose (gp) storage and the total storage used by
314
+ // their companies.
315
+ usedStorageInBytes: z11.record(
316
+ CompanyState.shape._id.or(z11.literal("gp")),
317
+ z11.object({
318
+ current: z11.number().positive(),
319
+ ...TimeLog.shape
320
+ })
321
+ ).readonly(),
318
322
  // notifications: z.array(Notification),
319
323
  lastSignedIn: z11.object({
320
324
  auto: Timestamp,
321
325
  manual: Timestamp
322
326
  }).partial(),
327
+ // This is useful for tracking the companies that a non-company owner belongs to.
323
328
  companyIds: z11.array(CompanyState.shape._id).min(1).optional(),
324
329
  // resumeToken: z.uuidv4().optional(),
325
330
  ...TimeLog.shape
@@ -416,12 +421,16 @@ var CompanyMemberRoles = z13.array(companyUserRoles).transform((roles) => distin
416
421
  }, "A user is not allowed to have conflicting roles.");
417
422
  var CompanyStaff = z13.object({
418
423
  _id: CompanyState.shape._id,
424
+ ownerId: UserDetails.shape._id,
419
425
  members: z13.record(
420
426
  UserDetails.shape._id,
421
427
  z13.object({
422
428
  invitedAt: Timestamp.optional(),
423
429
  joinedAt: Timestamp,
424
- lastActive: Timestamp,
430
+ lastSession: z13.object({
431
+ startedAt: Timestamp,
432
+ endedAt: Timestamp
433
+ }).partial().optional(),
425
434
  roles: CompanyMemberRoles,
426
435
  serviceCounter: z13.record(z13.literal(["undone", "done"]), z13.int().min(0)).optional()
427
436
  })
@@ -444,17 +453,20 @@ var CompanyStaff = z13.object({
444
453
  }).partial()
445
454
  ).optional(),
446
455
  ...TimeLog.shape
447
- }).superRefine((details, ctx) => {
448
- for (const [_id, user] of Object.entries(details.members)) {
449
- if (user.roles.includes("doc") && details.partnerMap && _id in details.partnerMap) {
450
- for (const asstUid of Object.keys(details.partnerMap[_id])) {
451
- if (!details.members[asstUid].roles.includes("physAsst")) {
456
+ }).superRefine((data, ctx) => {
457
+ if (!(data.ownerId in data.members)) {
458
+ ctx.addIssue('"ownerId" missing from "members" object.');
459
+ }
460
+ for (const [_id, user] of Object.entries(data.members)) {
461
+ if (user.roles.includes("doc") && data.partnerMap && _id in data.partnerMap) {
462
+ for (const asstUid of Object.keys(data.partnerMap[_id])) {
463
+ if (!data.members[asstUid].roles.includes("physAsst")) {
452
464
  ctx.addIssue(
453
465
  `A partner group member must have the "physAsst" role (${_id}) -> (${asstUid}).`
454
466
  );
455
467
  }
456
468
  }
457
- } else if (details.partnerMap && _id in details.partnerMap) {
469
+ } else if (data.partnerMap && _id in data.partnerMap) {
458
470
  ctx.addIssue(
459
471
  `A partner group leader must have the "doc" role. (${_id})`
460
472
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",