hububb-saas-shared 1.0.70 → 1.0.71

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.
@@ -1,9 +1,13 @@
1
1
  import { z } from "zod";
2
- import * as admin from "firebase-admin";
2
+ interface Timestamp {
3
+ seconds: number;
4
+ nanoseconds: number;
5
+ toDate: () => Date;
6
+ }
3
7
  export declare const ChatMessageTypeSchema: z.ZodUnion<[z.ZodLiteral<"message">, z.ZodLiteral<"note">, z.ZodLiteral<"whatsapp-message">]>;
4
8
  export declare const ChatMessageSchema: z.ZodObject<{
5
9
  id: z.ZodString;
6
- createdAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
10
+ createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
7
11
  threadId: z.ZodString;
8
12
  authorId: z.ZodString;
9
13
  author: z.ZodOptional<z.ZodObject<{
@@ -57,8 +61,8 @@ export declare const ChatMessageSchema: z.ZodObject<{
57
61
  }>>;
58
62
  contentType: z.ZodString;
59
63
  body: z.ZodString;
60
- seen: z.ZodRecord<z.ZodString, z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
61
- lastSeen: z.ZodOptional<z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
64
+ seen: z.ZodRecord<z.ZodString, z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
65
+ lastSeen: z.ZodOptional<z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
62
66
  source: z.ZodOptional<z.ZodString>;
63
67
  externalMessageId: z.ZodOptional<z.ZodString>;
64
68
  attachments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -66,11 +70,11 @@ export declare const ChatMessageSchema: z.ZodObject<{
66
70
  }, "strip", z.ZodTypeAny, {
67
71
  id: string;
68
72
  body: string;
69
- createdAt: admin.firestore.Timestamp;
73
+ createdAt: Timestamp;
70
74
  threadId: string;
71
- contentType: string;
72
75
  authorId: string;
73
- seen: Record<string, admin.firestore.Timestamp>;
76
+ contentType: string;
77
+ seen: Record<string, Timestamp>;
74
78
  type?: "message" | "note" | "whatsapp-message" | undefined;
75
79
  source?: string | undefined;
76
80
  attachments?: string[] | undefined;
@@ -91,16 +95,16 @@ export declare const ChatMessageSchema: z.ZodObject<{
91
95
  photoUrl?: string | undefined;
92
96
  stripeCustomerId?: string | undefined;
93
97
  } | undefined;
94
- lastSeen?: admin.firestore.Timestamp | undefined;
98
+ lastSeen?: Timestamp | undefined;
95
99
  externalMessageId?: string | undefined;
96
100
  }, {
97
101
  id: string;
98
102
  body: string;
99
- createdAt: admin.firestore.Timestamp;
103
+ createdAt: Timestamp;
100
104
  threadId: string;
101
- contentType: string;
102
105
  authorId: string;
103
- seen: Record<string, admin.firestore.Timestamp>;
106
+ contentType: string;
107
+ seen: Record<string, Timestamp>;
104
108
  type?: "message" | "note" | "whatsapp-message" | undefined;
105
109
  source?: string | undefined;
106
110
  attachments?: string[] | undefined;
@@ -121,16 +125,16 @@ export declare const ChatMessageSchema: z.ZodObject<{
121
125
  photoUrl?: string | undefined;
122
126
  stripeCustomerId?: string | undefined;
123
127
  } | undefined;
124
- lastSeen?: admin.firestore.Timestamp | undefined;
128
+ lastSeen?: Timestamp | undefined;
125
129
  externalMessageId?: string | undefined;
126
130
  }>;
127
131
  export declare const ChatThreadSchema: z.ZodObject<{
128
132
  id: z.ZodOptional<z.ZodString>;
129
- createdAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
130
- updatedAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
133
+ createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
134
+ updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
131
135
  lastMessage: z.ZodOptional<z.ZodObject<{
132
136
  id: z.ZodString;
133
- createdAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
137
+ createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
134
138
  threadId: z.ZodString;
135
139
  authorId: z.ZodString;
136
140
  author: z.ZodOptional<z.ZodObject<{
@@ -184,8 +188,8 @@ export declare const ChatThreadSchema: z.ZodObject<{
184
188
  }>>;
185
189
  contentType: z.ZodString;
186
190
  body: z.ZodString;
187
- seen: z.ZodRecord<z.ZodString, z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
188
- lastSeen: z.ZodOptional<z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
191
+ seen: z.ZodRecord<z.ZodString, z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
192
+ lastSeen: z.ZodOptional<z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
189
193
  source: z.ZodOptional<z.ZodString>;
190
194
  externalMessageId: z.ZodOptional<z.ZodString>;
191
195
  attachments: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -193,11 +197,11 @@ export declare const ChatThreadSchema: z.ZodObject<{
193
197
  }, "strip", z.ZodTypeAny, {
194
198
  id: string;
195
199
  body: string;
196
- createdAt: admin.firestore.Timestamp;
200
+ createdAt: Timestamp;
197
201
  threadId: string;
198
- contentType: string;
199
202
  authorId: string;
200
- seen: Record<string, admin.firestore.Timestamp>;
203
+ contentType: string;
204
+ seen: Record<string, Timestamp>;
201
205
  type?: "message" | "note" | "whatsapp-message" | undefined;
202
206
  source?: string | undefined;
203
207
  attachments?: string[] | undefined;
@@ -218,16 +222,16 @@ export declare const ChatThreadSchema: z.ZodObject<{
218
222
  photoUrl?: string | undefined;
219
223
  stripeCustomerId?: string | undefined;
220
224
  } | undefined;
221
- lastSeen?: admin.firestore.Timestamp | undefined;
225
+ lastSeen?: Timestamp | undefined;
222
226
  externalMessageId?: string | undefined;
223
227
  }, {
224
228
  id: string;
225
229
  body: string;
226
- createdAt: admin.firestore.Timestamp;
230
+ createdAt: Timestamp;
227
231
  threadId: string;
228
- contentType: string;
229
232
  authorId: string;
230
- seen: Record<string, admin.firestore.Timestamp>;
233
+ contentType: string;
234
+ seen: Record<string, Timestamp>;
231
235
  type?: "message" | "note" | "whatsapp-message" | undefined;
232
236
  source?: string | undefined;
233
237
  attachments?: string[] | undefined;
@@ -248,7 +252,7 @@ export declare const ChatThreadSchema: z.ZodObject<{
248
252
  photoUrl?: string | undefined;
249
253
  stripeCustomerId?: string | undefined;
250
254
  } | undefined;
251
- lastSeen?: admin.firestore.Timestamp | undefined;
255
+ lastSeen?: Timestamp | undefined;
252
256
  externalMessageId?: string | undefined;
253
257
  }>>;
254
258
  participantIds: z.ZodArray<z.ZodString, "many">;
@@ -306,7 +310,7 @@ export declare const ChatThreadSchema: z.ZodObject<{
306
310
  externalThreadId: z.ZodOptional<z.ZodString>;
307
311
  externalSource: z.ZodOptional<z.ZodString>;
308
312
  title: z.ZodOptional<z.ZodString>;
309
- seenBy: z.ZodRecord<z.ZodString, z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
313
+ seenBy: z.ZodRecord<z.ZodString, z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
310
314
  isImportant: z.ZodOptional<z.ZodBoolean>;
311
315
  needsAttention: z.ZodArray<z.ZodString, "many">;
312
316
  needsAttentionMap: z.ZodRecord<z.ZodString, z.ZodBoolean>;
@@ -481,13 +485,13 @@ export declare const ChatThreadSchema: z.ZodObject<{
481
485
  isInquiryThread: z.ZodOptional<z.ZodBoolean>;
482
486
  whatsappTemplateSent: z.ZodOptional<z.ZodBoolean>;
483
487
  whatsappUserReplied: z.ZodOptional<z.ZodBoolean>;
484
- lastWhatsappMessageSentAt: z.ZodOptional<z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>>;
488
+ lastWhatsappMessageSentAt: z.ZodOptional<z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>>;
485
489
  }, "strip", z.ZodTypeAny, {
486
490
  type: "ONE_TO_ONE" | "GROUP";
487
- createdAt: admin.firestore.Timestamp;
488
- updatedAt: admin.firestore.Timestamp;
491
+ createdAt: Timestamp;
492
+ updatedAt: Timestamp;
489
493
  participantIds: string[];
490
- seenBy: Record<string, admin.firestore.Timestamp>;
494
+ seenBy: Record<string, Timestamp>;
491
495
  needsAttention: string[];
492
496
  needsAttentionMap: Record<string, boolean>;
493
497
  id?: string | undefined;
@@ -497,11 +501,11 @@ export declare const ChatThreadSchema: z.ZodObject<{
497
501
  lastMessage?: {
498
502
  id: string;
499
503
  body: string;
500
- createdAt: admin.firestore.Timestamp;
504
+ createdAt: Timestamp;
501
505
  threadId: string;
502
- contentType: string;
503
506
  authorId: string;
504
- seen: Record<string, admin.firestore.Timestamp>;
507
+ contentType: string;
508
+ seen: Record<string, Timestamp>;
505
509
  type?: "message" | "note" | "whatsapp-message" | undefined;
506
510
  source?: string | undefined;
507
511
  attachments?: string[] | undefined;
@@ -522,7 +526,7 @@ export declare const ChatThreadSchema: z.ZodObject<{
522
526
  photoUrl?: string | undefined;
523
527
  stripeCustomerId?: string | undefined;
524
528
  } | undefined;
525
- lastSeen?: admin.firestore.Timestamp | undefined;
529
+ lastSeen?: Timestamp | undefined;
526
530
  externalMessageId?: string | undefined;
527
531
  } | undefined;
528
532
  participants?: {
@@ -583,13 +587,13 @@ export declare const ChatThreadSchema: z.ZodObject<{
583
587
  isInquiryThread?: boolean | undefined;
584
588
  whatsappTemplateSent?: boolean | undefined;
585
589
  whatsappUserReplied?: boolean | undefined;
586
- lastWhatsappMessageSentAt?: admin.firestore.Timestamp | undefined;
590
+ lastWhatsappMessageSentAt?: Timestamp | undefined;
587
591
  }, {
588
592
  type: "ONE_TO_ONE" | "GROUP";
589
- createdAt: admin.firestore.Timestamp;
590
- updatedAt: admin.firestore.Timestamp;
593
+ createdAt: Timestamp;
594
+ updatedAt: Timestamp;
591
595
  participantIds: string[];
592
- seenBy: Record<string, admin.firestore.Timestamp>;
596
+ seenBy: Record<string, Timestamp>;
593
597
  needsAttention: string[];
594
598
  needsAttentionMap: Record<string, boolean>;
595
599
  id?: string | undefined;
@@ -599,11 +603,11 @@ export declare const ChatThreadSchema: z.ZodObject<{
599
603
  lastMessage?: {
600
604
  id: string;
601
605
  body: string;
602
- createdAt: admin.firestore.Timestamp;
606
+ createdAt: Timestamp;
603
607
  threadId: string;
604
- contentType: string;
605
608
  authorId: string;
606
- seen: Record<string, admin.firestore.Timestamp>;
609
+ contentType: string;
610
+ seen: Record<string, Timestamp>;
607
611
  type?: "message" | "note" | "whatsapp-message" | undefined;
608
612
  source?: string | undefined;
609
613
  attachments?: string[] | undefined;
@@ -624,7 +628,7 @@ export declare const ChatThreadSchema: z.ZodObject<{
624
628
  photoUrl?: string | undefined;
625
629
  stripeCustomerId?: string | undefined;
626
630
  } | undefined;
627
- lastSeen?: admin.firestore.Timestamp | undefined;
631
+ lastSeen?: Timestamp | undefined;
628
632
  externalMessageId?: string | undefined;
629
633
  } | undefined;
630
634
  participants?: {
@@ -685,12 +689,12 @@ export declare const ChatThreadSchema: z.ZodObject<{
685
689
  isInquiryThread?: boolean | undefined;
686
690
  whatsappTemplateSent?: boolean | undefined;
687
691
  whatsappUserReplied?: boolean | undefined;
688
- lastWhatsappMessageSentAt?: admin.firestore.Timestamp | undefined;
692
+ lastWhatsappMessageSentAt?: Timestamp | undefined;
689
693
  }>;
690
694
  export declare const MessageAutomationTemplateSchema: z.ZodObject<{
691
695
  id: z.ZodOptional<z.ZodString>;
692
696
  name: z.ZodString;
693
- createdAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
697
+ createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
694
698
  message: z.ZodString;
695
699
  action: z.ZodUnion<[z.ZodLiteral<"booking-confirmed">, z.ZodLiteral<"check-in">, z.ZodLiteral<"check-out">]>;
696
700
  minutesAfterBookingConfirmed: z.ZodOptional<z.ZodNumber>;
@@ -700,7 +704,7 @@ export declare const MessageAutomationTemplateSchema: z.ZodObject<{
700
704
  name: string;
701
705
  message: string;
702
706
  action: "booking-confirmed" | "check-in" | "check-out";
703
- createdAt: admin.firestore.Timestamp;
707
+ createdAt: Timestamp;
704
708
  id?: string | undefined;
705
709
  minutesAfterBookingConfirmed?: number | undefined;
706
710
  daysAfterAction?: number | undefined;
@@ -709,7 +713,7 @@ export declare const MessageAutomationTemplateSchema: z.ZodObject<{
709
713
  name: string;
710
714
  message: string;
711
715
  action: "booking-confirmed" | "check-in" | "check-out";
712
- createdAt: admin.firestore.Timestamp;
716
+ createdAt: Timestamp;
713
717
  id?: string | undefined;
714
718
  minutesAfterBookingConfirmed?: number | undefined;
715
719
  daysAfterAction?: number | undefined;
@@ -718,16 +722,17 @@ export declare const MessageAutomationTemplateSchema: z.ZodObject<{
718
722
  export declare const SavedReplySchema: z.ZodObject<{
719
723
  id: z.ZodOptional<z.ZodString>;
720
724
  name: z.ZodString;
721
- createdAt: z.ZodType<admin.firestore.Timestamp, z.ZodTypeDef, admin.firestore.Timestamp>;
725
+ createdAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
722
726
  message: z.ZodString;
723
727
  }, "strip", z.ZodTypeAny, {
724
728
  name: string;
725
729
  message: string;
726
- createdAt: admin.firestore.Timestamp;
730
+ createdAt: Timestamp;
727
731
  id?: string | undefined;
728
732
  }, {
729
733
  name: string;
730
734
  message: string;
731
- createdAt: admin.firestore.Timestamp;
735
+ createdAt: Timestamp;
732
736
  id?: string | undefined;
733
737
  }>;
738
+ export {};
@@ -1,46 +1,19 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.SavedReplySchema = exports.MessageAutomationTemplateSchema = exports.ChatThreadSchema = exports.ChatMessageSchema = exports.ChatMessageTypeSchema = void 0;
37
4
  const zod_1 = require("zod");
38
5
  const user_1 = require("../user");
39
6
  const reservation_1 = require("../reservation");
40
7
  const property_1 = require("../property");
41
- // import { Timestamp } from "@firebase/firestore-types";
42
- const admin = __importStar(require("firebase-admin"));
43
- const SeenBySchema = (0, zod_1.record)((0, zod_1.string)(), zod_1.z.instanceof(admin.firestore.Timestamp));
8
+ // Create a type-safe timestamp schema
9
+ const TimestampSchema = zod_1.z
10
+ .object({
11
+ seconds: zod_1.z.number(),
12
+ nanoseconds: zod_1.z.number(),
13
+ toDate: zod_1.z.function().returns(zod_1.z.date()),
14
+ })
15
+ .refine((val) => val && typeof val.toDate === "function", "Must be a valid Timestamp");
16
+ const SeenBySchema = (0, zod_1.record)((0, zod_1.string)(), TimestampSchema);
44
17
  exports.ChatMessageTypeSchema = (0, zod_1.union)([
45
18
  (0, zod_1.literal)("message"),
46
19
  (0, zod_1.literal)("note"),
@@ -48,14 +21,14 @@ exports.ChatMessageTypeSchema = (0, zod_1.union)([
48
21
  ]);
49
22
  exports.ChatMessageSchema = (0, zod_1.object)({
50
23
  id: (0, zod_1.string)(),
51
- createdAt: zod_1.z.instanceof(admin.firestore.Timestamp),
24
+ createdAt: TimestampSchema,
52
25
  threadId: (0, zod_1.string)(),
53
26
  authorId: (0, zod_1.string)(),
54
27
  author: (0, zod_1.optional)(user_1.userSchema),
55
28
  contentType: (0, zod_1.string)(),
56
29
  body: (0, zod_1.string)(),
57
30
  seen: SeenBySchema,
58
- lastSeen: (0, zod_1.optional)(zod_1.z.instanceof(admin.firestore.Timestamp)),
31
+ lastSeen: (0, zod_1.optional)(TimestampSchema),
59
32
  source: (0, zod_1.optional)((0, zod_1.string)()),
60
33
  externalMessageId: (0, zod_1.optional)((0, zod_1.string)()),
61
34
  attachments: (0, zod_1.optional)((0, zod_1.array)((0, zod_1.string)())),
@@ -63,8 +36,8 @@ exports.ChatMessageSchema = (0, zod_1.object)({
63
36
  });
64
37
  exports.ChatThreadSchema = (0, zod_1.object)({
65
38
  id: (0, zod_1.optional)((0, zod_1.string)()),
66
- createdAt: zod_1.z.instanceof(admin.firestore.Timestamp),
67
- updatedAt: zod_1.z.instanceof(admin.firestore.Timestamp),
39
+ createdAt: TimestampSchema,
40
+ updatedAt: TimestampSchema,
68
41
  lastMessage: (0, zod_1.optional)(exports.ChatMessageSchema),
69
42
  participantIds: (0, zod_1.array)((0, zod_1.string)()),
70
43
  participants: (0, zod_1.optional)((0, zod_1.array)(user_1.userSchema)),
@@ -73,7 +46,7 @@ exports.ChatThreadSchema = (0, zod_1.object)({
73
46
  externalThreadId: (0, zod_1.optional)((0, zod_1.string)()),
74
47
  externalSource: (0, zod_1.optional)((0, zod_1.string)()),
75
48
  title: (0, zod_1.optional)((0, zod_1.string)()),
76
- seenBy: (0, zod_1.record)((0, zod_1.string)(), zod_1.z.instanceof(admin.firestore.Timestamp)),
49
+ seenBy: (0, zod_1.record)((0, zod_1.string)(), TimestampSchema),
77
50
  isImportant: (0, zod_1.optional)((0, zod_1.boolean)()),
78
51
  needsAttention: (0, zod_1.array)((0, zod_1.string)()),
79
52
  needsAttentionMap: (0, zod_1.record)((0, zod_1.string)(), (0, zod_1.boolean)()),
@@ -93,12 +66,12 @@ exports.ChatThreadSchema = (0, zod_1.object)({
93
66
  isInquiryThread: (0, zod_1.optional)((0, zod_1.boolean)()),
94
67
  whatsappTemplateSent: (0, zod_1.optional)((0, zod_1.boolean)()),
95
68
  whatsappUserReplied: (0, zod_1.optional)((0, zod_1.boolean)()),
96
- lastWhatsappMessageSentAt: (0, zod_1.optional)(zod_1.z.instanceof(admin.firestore.Timestamp)),
69
+ lastWhatsappMessageSentAt: (0, zod_1.optional)(TimestampSchema),
97
70
  });
98
71
  exports.MessageAutomationTemplateSchema = (0, zod_1.object)({
99
72
  id: (0, zod_1.optional)((0, zod_1.string)()),
100
73
  name: (0, zod_1.string)(),
101
- createdAt: zod_1.z.instanceof(admin.firestore.Timestamp),
74
+ createdAt: TimestampSchema,
102
75
  message: (0, zod_1.string)(),
103
76
  action: (0, zod_1.union)([
104
77
  (0, zod_1.literal)("booking-confirmed"),
@@ -112,6 +85,6 @@ exports.MessageAutomationTemplateSchema = (0, zod_1.object)({
112
85
  exports.SavedReplySchema = (0, zod_1.object)({
113
86
  id: (0, zod_1.optional)((0, zod_1.string)()),
114
87
  name: (0, zod_1.string)(),
115
- createdAt: zod_1.z.instanceof(admin.firestore.Timestamp),
88
+ createdAt: TimestampSchema,
116
89
  message: (0, zod_1.string)(),
117
90
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "hububb-saas-shared",
4
- "version": "1.0.70",
4
+ "version": "1.0.71",
5
5
  "description": "This is a shared package for the hububb saas project",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.js",