@_henriquewilson/gabirubi-domain 1.5.3 → 1.5.4
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/model/journey/chat.d.mts +9 -0
- package/dist/model/journey/chat.d.ts +9 -0
- package/dist/model/journey/chat.js +1 -0
- package/dist/model/journey/chat.js.map +1 -1
- package/dist/model/journey/chat.mjs +1 -0
- package/dist/model/journey/chat.mjs.map +1 -1
- package/dist/model/purchase.d.mts +8 -0
- package/dist/model/purchase.d.ts +8 -0
- package/dist/model/purchase.js +1 -0
- package/dist/model/purchase.js.map +1 -1
- package/dist/model/purchase.mjs +1 -0
- package/dist/model/purchase.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -520,6 +520,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
520
520
|
sentAt?: unknown;
|
|
521
521
|
}>>;
|
|
522
522
|
isOpen: z.ZodDefault<z.ZodBoolean>;
|
|
523
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
523
524
|
unreadCount: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
524
525
|
isMuted: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
525
526
|
isArchived: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -541,6 +542,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
541
542
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
542
543
|
}[];
|
|
543
544
|
isOpen: boolean;
|
|
545
|
+
enabled: boolean;
|
|
544
546
|
unreadCount: Record<string, number>;
|
|
545
547
|
isMuted: Record<string, boolean>;
|
|
546
548
|
isArchived: boolean;
|
|
@@ -596,6 +598,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
596
598
|
sentAt?: unknown;
|
|
597
599
|
} | undefined;
|
|
598
600
|
isOpen?: boolean | undefined;
|
|
601
|
+
enabled?: boolean | undefined;
|
|
599
602
|
unreadCount?: Record<string, number> | undefined;
|
|
600
603
|
isMuted?: Record<string, boolean> | undefined;
|
|
601
604
|
isArchived?: boolean | undefined;
|
|
@@ -684,6 +687,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
684
687
|
sentAt?: unknown;
|
|
685
688
|
}>>;
|
|
686
689
|
isOpen: z.ZodDefault<z.ZodBoolean>;
|
|
690
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
687
691
|
unreadCount: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
688
692
|
isMuted: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
689
693
|
isArchived: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -704,6 +708,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
704
708
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
705
709
|
}[];
|
|
706
710
|
isOpen: boolean;
|
|
711
|
+
enabled: boolean;
|
|
707
712
|
createdBy: string | number;
|
|
708
713
|
photoURL?: string | undefined;
|
|
709
714
|
name?: string | undefined;
|
|
@@ -727,6 +732,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
727
732
|
name?: string | undefined;
|
|
728
733
|
description?: string | undefined;
|
|
729
734
|
isOpen?: boolean | undefined;
|
|
735
|
+
enabled?: boolean | undefined;
|
|
730
736
|
createdBy?: unknown;
|
|
731
737
|
}>;
|
|
732
738
|
type CreateChat = z.infer<typeof CreateChatSchema>;
|
|
@@ -864,6 +870,7 @@ declare const safeParseChat: (data: unknown) => z.SafeParseReturnType<{
|
|
|
864
870
|
sentAt?: unknown;
|
|
865
871
|
} | undefined;
|
|
866
872
|
isOpen?: boolean | undefined;
|
|
873
|
+
enabled?: boolean | undefined;
|
|
867
874
|
unreadCount?: Record<string, number> | undefined;
|
|
868
875
|
isMuted?: Record<string, boolean> | undefined;
|
|
869
876
|
isArchived?: boolean | undefined;
|
|
@@ -885,6 +892,7 @@ declare const safeParseChat: (data: unknown) => z.SafeParseReturnType<{
|
|
|
885
892
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
886
893
|
}[];
|
|
887
894
|
isOpen: boolean;
|
|
895
|
+
enabled: boolean;
|
|
888
896
|
unreadCount: Record<string, number>;
|
|
889
897
|
isMuted: Record<string, boolean>;
|
|
890
898
|
isArchived: boolean;
|
|
@@ -961,6 +969,7 @@ declare const validateChat: (data: unknown) => {
|
|
|
961
969
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
962
970
|
}[];
|
|
963
971
|
isOpen: boolean;
|
|
972
|
+
enabled: boolean;
|
|
964
973
|
unreadCount: Record<string, number>;
|
|
965
974
|
isMuted: Record<string, boolean>;
|
|
966
975
|
isArchived: boolean;
|
|
@@ -520,6 +520,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
520
520
|
sentAt?: unknown;
|
|
521
521
|
}>>;
|
|
522
522
|
isOpen: z.ZodDefault<z.ZodBoolean>;
|
|
523
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
523
524
|
unreadCount: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
524
525
|
isMuted: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
525
526
|
isArchived: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -541,6 +542,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
541
542
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
542
543
|
}[];
|
|
543
544
|
isOpen: boolean;
|
|
545
|
+
enabled: boolean;
|
|
544
546
|
unreadCount: Record<string, number>;
|
|
545
547
|
isMuted: Record<string, boolean>;
|
|
546
548
|
isArchived: boolean;
|
|
@@ -596,6 +598,7 @@ declare const ChatSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
596
598
|
sentAt?: unknown;
|
|
597
599
|
} | undefined;
|
|
598
600
|
isOpen?: boolean | undefined;
|
|
601
|
+
enabled?: boolean | undefined;
|
|
599
602
|
unreadCount?: Record<string, number> | undefined;
|
|
600
603
|
isMuted?: Record<string, boolean> | undefined;
|
|
601
604
|
isArchived?: boolean | undefined;
|
|
@@ -684,6 +687,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
684
687
|
sentAt?: unknown;
|
|
685
688
|
}>>;
|
|
686
689
|
isOpen: z.ZodDefault<z.ZodBoolean>;
|
|
690
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
687
691
|
unreadCount: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
688
692
|
isMuted: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
689
693
|
isArchived: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -704,6 +708,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
704
708
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
705
709
|
}[];
|
|
706
710
|
isOpen: boolean;
|
|
711
|
+
enabled: boolean;
|
|
707
712
|
createdBy: string | number;
|
|
708
713
|
photoURL?: string | undefined;
|
|
709
714
|
name?: string | undefined;
|
|
@@ -727,6 +732,7 @@ declare const CreateChatSchema: z.ZodObject<Omit<z.objectUtil.extendShape<Omit<{
|
|
|
727
732
|
name?: string | undefined;
|
|
728
733
|
description?: string | undefined;
|
|
729
734
|
isOpen?: boolean | undefined;
|
|
735
|
+
enabled?: boolean | undefined;
|
|
730
736
|
createdBy?: unknown;
|
|
731
737
|
}>;
|
|
732
738
|
type CreateChat = z.infer<typeof CreateChatSchema>;
|
|
@@ -864,6 +870,7 @@ declare const safeParseChat: (data: unknown) => z.SafeParseReturnType<{
|
|
|
864
870
|
sentAt?: unknown;
|
|
865
871
|
} | undefined;
|
|
866
872
|
isOpen?: boolean | undefined;
|
|
873
|
+
enabled?: boolean | undefined;
|
|
867
874
|
unreadCount?: Record<string, number> | undefined;
|
|
868
875
|
isMuted?: Record<string, boolean> | undefined;
|
|
869
876
|
isArchived?: boolean | undefined;
|
|
@@ -885,6 +892,7 @@ declare const safeParseChat: (data: unknown) => z.SafeParseReturnType<{
|
|
|
885
892
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
886
893
|
}[];
|
|
887
894
|
isOpen: boolean;
|
|
895
|
+
enabled: boolean;
|
|
888
896
|
unreadCount: Record<string, number>;
|
|
889
897
|
isMuted: Record<string, boolean>;
|
|
890
898
|
isArchived: boolean;
|
|
@@ -961,6 +969,7 @@ declare const validateChat: (data: unknown) => {
|
|
|
961
969
|
lastSeenAt?: FirebaseFirestore.Timestamp | null | undefined;
|
|
962
970
|
}[];
|
|
963
971
|
isOpen: boolean;
|
|
972
|
+
enabled: boolean;
|
|
964
973
|
unreadCount: Record<string, number>;
|
|
965
974
|
isMuted: Record<string, boolean>;
|
|
966
975
|
isArchived: boolean;
|
|
@@ -240,6 +240,7 @@ var ChatSchema = ModelSchema.omit({
|
|
|
240
240
|
participants: import_zod3.z.array(ParticipantSchema),
|
|
241
241
|
lastMessage: LastMessageSchema.optional(),
|
|
242
242
|
isOpen: import_zod3.z.boolean().default(true),
|
|
243
|
+
enabled: import_zod3.z.boolean().default(true),
|
|
243
244
|
unreadCount: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).default({}),
|
|
244
245
|
// { [userId]: true } — chats silenciados por usuário
|
|
245
246
|
isMuted: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.boolean()).default({}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/journey/chat.js","../../../src/model/journey/chat.ts","../../../src/model/shared.ts","../../../src/model.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","chat_exports","AttachmentSchema","ChatSchema","ChatTypeSchema","CreateChatSchema","CreateMessageSchema","LastMessageSchema","MessageSchema","MessageStatusSchema","MessageTypeSchema","ParticipantSchema","ReplyToSchema","TypingIndicatorSchema","safeParseChat","safeParseMessage","validateChat","validateMessage","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","import_zod3","enum","userId","displayName","min","photoURL","url","nullable","role","default","joinedAt","lastSeenAt","size","positive","mimeType","thumbnailUrl","messageId","senderId","senderName","content","max","type","omit","chatId","senderPhotoURL","attachment","status","readBy","replyTo","editedAt","deletedAt","sentAt","participantIds","participants","lastMessage","isOpen","unreadCount","record","isMuted","isArchived","createdBy","startedAt","data","safeParse","parse"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfb,UAAUY,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAA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sF;WAAkB7F,cAAc8F,SAAA,CAAUD;;AACpE,IAAMvF,gBAAmB,SAACuF;WAAkBlG,WAAWmG,SAAA,CAAUD;;AACjE,IAAMpF,kBAAmB,SAACoF;WAAkB7F,cAAc+F,KAAA,CAAMF;;AAChE,IAAMrF,eAAmB,SAACqF;WAAkBlG,WAAWoG,KAAA,CAAMF;;ADWpE,6DAA6D;AAC7D,KAAMnF,CAAAA,OAAOC,OAAO,GAAG;IACrBjB,kBAAAA;IACAC,YAAAA;IACAC,gBAAAA;IACAC,kBAAAA;IACAC,qBAAAA;IACAC,mBAAAA;IACAC,eAAAA;IACAC,qBAAAA;IACAC,mBAAAA;IACAC,mBAAAA;IACAC,eAAAA;IACAC,uBAAAA;IACAC,eAAAA;IACAC,kBAAAA;IACAC,cAAAA;IACAC,iBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/model/journey/chat.ts\nvar chat_exports = {};\n__export(chat_exports, {\n AttachmentSchema: () => AttachmentSchema,\n ChatSchema: () => ChatSchema,\n ChatTypeSchema: () => ChatTypeSchema,\n CreateChatSchema: () => CreateChatSchema,\n CreateMessageSchema: () => CreateMessageSchema,\n LastMessageSchema: () => LastMessageSchema,\n MessageSchema: () => MessageSchema,\n MessageStatusSchema: () => MessageStatusSchema,\n MessageTypeSchema: () => MessageTypeSchema,\n ParticipantSchema: () => ParticipantSchema,\n ReplyToSchema: () => ReplyToSchema,\n TypingIndicatorSchema: () => TypingIndicatorSchema,\n safeParseChat: () => safeParseChat,\n safeParseMessage: () => safeParseMessage,\n validateChat: () => validateChat,\n validateMessage: () => validateMessage\n});\nmodule.exports = __toCommonJS(chat_exports);\nvar import_zod3 = require(\"zod\");\n\n// src/model/shared.ts\nvar import_firestore = require(\"@google-cloud/firestore\");\nvar import_zod = require(\"zod\");\nvar TimestampOrNow = import_zod.z.preprocess(\n (arg) => arg === void 0 ? import_firestore.Timestamp.now() : arg,\n import_zod.z.custom()\n).nullish().optional();\n\n// src/model.ts\nvar import_zod2 = require(\"zod\");\nvar import_cuid = __toESM(require(\"cuid\"));\nvar generateFirestoreId = () => {\n return (0, import_cuid.default)();\n};\nvar IdModelSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]);\nvar IdModelProcess = import_zod2.z.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = import_zod2.z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: import_zod2.z.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: import_zod2.z.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = import_zod2.z.object({\n enabled: import_zod2.z.boolean().optional()\n});\nvar DocumentHistorySchema = import_zod2.z.object({\n createdAt: TimestampOrNow,\n description: import_zod2.z.string().optional()\n});\n\n// src/model/journey/chat.ts\nvar MessageTypeSchema = import_zod3.z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nvar ChatTypeSchema = import_zod3.z.enum([\"direct\", \"group\"]);\nvar MessageStatusSchema = import_zod3.z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nvar ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: import_zod3.z.string().min(1),\n photoURL: import_zod3.z.string().url().nullable().optional(),\n role: import_zod3.z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow\n});\nvar AttachmentSchema = ModelSchema.extend({\n url: import_zod3.z.string().url(),\n name: import_zod3.z.string(),\n size: import_zod3.z.number().positive(),\n // bytes\n mimeType: import_zod3.z.string(),\n thumbnailUrl: import_zod3.z.string().url().optional()\n});\nvar ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: import_zod3.z.string(),\n content: import_zod3.z.string().max(200),\n type: MessageTypeSchema\n});\nvar MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: import_zod3.z.string().min(1),\n senderPhotoURL: import_zod3.z.string().url().nullable().optional(),\n type: MessageTypeSchema,\n content: import_zod3.z.string().min(1).max(4e3),\n attachment: AttachmentSchema.optional(),\n status: MessageStatusSchema.default(\"sending\"),\n readBy: import_zod3.z.array(import_zod3.z.string()).default([]),\n // array de userIds\n replyTo: ReplyToSchema.optional(),\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow\n});\nvar CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true\n});\nvar LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: import_zod3.z.string(),\n senderId: IdModelProcess,\n senderName: import_zod3.z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow\n});\nvar ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: import_zod3.z.string().min(1).optional(),\n description: import_zod3.z.string().max(500).optional(),\n photoURL: import_zod3.z.string().url().optional(),\n participantIds: import_zod3.z.array(IdModelProcess).min(2).max(100),\n participants: import_zod3.z.array(ParticipantSchema),\n lastMessage: LastMessageSchema.optional(),\n isOpen: import_zod3.z.boolean().default(true),\n unreadCount: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).default({}),\n // { [userId]: true } — chats silenciados por usuário\n isMuted: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.boolean()).default({}),\n isArchived: import_zod3.z.boolean().default(false),\n createdBy: IdModelProcess\n});\nvar CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true\n});\nvar TypingIndicatorSchema = ModelSchema.extend({\n userId: import_zod3.z.string(),\n displayName: import_zod3.z.string(),\n startedAt: import_zod3.z.number()\n // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nvar safeParseMessage = (data) => MessageSchema.safeParse(data);\nvar safeParseChat = (data) => ChatSchema.safeParse(data);\nvar validateMessage = (data) => MessageSchema.parse(data);\nvar validateChat = (data) => ChatSchema.parse(data);\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n AttachmentSchema,\n ChatSchema,\n ChatTypeSchema,\n CreateChatSchema,\n CreateMessageSchema,\n LastMessageSchema,\n MessageSchema,\n MessageStatusSchema,\n MessageTypeSchema,\n ParticipantSchema,\n ReplyToSchema,\n TypingIndicatorSchema,\n safeParseChat,\n safeParseMessage,\n validateChat,\n validateMessage\n});\n","import { z } from \"zod\";\nimport {TimestampOrNow} from \"../shared\";\nimport {IdModelProcess, ModelSchema} from \"../../model\";\n\n// ─────────────────────────────────────────────\n// Enums\n// ─────────────────────────────────────────────\n\nexport const MessageTypeSchema = z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nexport type MessageType = z.infer<typeof MessageTypeSchema>;\n\nexport const ChatTypeSchema = z.enum([\"direct\", \"group\"]);\nexport type ChatType = z.infer<typeof ChatTypeSchema>;\n\nexport const MessageStatusSchema = z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nexport type MessageStatus = z.infer<typeof MessageStatusSchema>;\n\n// ─────────────────────────────────────────────\n// Participant\n// Não estende ModelSchema pois é sub-documento (não tem coleção própria)\n// ─────────────────────────────────────────────\n\nexport const ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z.string().min(1),\n photoURL: z.string().url().nullable().optional(),\n role: z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow,\n});\nexport type Participant = z.infer<typeof ParticipantSchema>;\n\n// ─────────────────────────────────────────────\n// Attachment\n// Sub-documento, sem id próprio\n// ─────────────────────────────────────────────\n\nexport const AttachmentSchema = ModelSchema.extend({\n url: z.string().url(),\n name: z.string(),\n size: z.number().positive(), // bytes\n mimeType: z.string(),\n thumbnailUrl: z.string().url().optional(),\n});\nexport type Attachment = z.infer<typeof AttachmentSchema>;\n\n// ─────────────────────────────────────────────\n// ReplyTo\n// Snapshot da mensagem original (evita lookup extra)\n// ─────────────────────────────────────────────\n\nexport const ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string(),\n content: z.string().max(200),\n type: MessageTypeSchema,\n});\nexport type ReplyTo = z.infer<typeof ReplyToSchema>;\n\n// ─────────────────────────────────────────────\n// Message\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string().min(1),\n senderPhotoURL: z.string().url().nullable().optional(),\n\n type: MessageTypeSchema,\n content: z.string().min(1).max(4000),\n\n attachment: AttachmentSchema.optional(),\n\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z.array(z.string()).default([]), // array de userIds\n\n replyTo: ReplyToSchema.optional(),\n\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow,\n});\nexport type Message = z.infer<typeof MessageSchema>;\n\n// Para criar — omite campos gerados automaticamente pelo ModelSchema/servidor\nexport const CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true,\n});\nexport type CreateMessage = z.infer<typeof CreateMessageSchema>;\n\n// ─────────────────────────────────────────────\n// LastMessage\n// Snapshot da última mensagem para preview na lista de chats\n// ─────────────────────────────────────────────\n\nexport const LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z.string(),\n senderId: IdModelProcess,\n senderName: z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow,\n});\nexport type LastMessage = z.infer<typeof LastMessageSchema>;\n\n// ─────────────────────────────────────────────\n// Chat\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z.string().min(1).optional(),\n description: z.string().max(500).optional(),\n photoURL: z.string().url().optional(),\n\n participantIds: z.array(IdModelProcess).min(2).max(100),\n participants: z.array(ParticipantSchema),\n\n lastMessage: LastMessageSchema.optional(),\n\n isOpen: z.boolean().default(true),\n unreadCount: z.record(z.string(), z.number()).default({}),\n\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z.record(z.string(), z.boolean()).default({}),\n\n isArchived: z.boolean().default(false),\n\n createdBy: IdModelProcess,\n});\nexport type Chat = z.infer<typeof ChatSchema>;\n\nexport const CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true,\n});\nexport type CreateChat = z.infer<typeof CreateChatSchema>;\n\n// ─────────────────────────────────────────────\n// Typing Indicator\n// Persistido no Realtime Database (não no Firestore)\n// Não usa ModelSchema pois não é documento Firestore\n// ─────────────────────────────────────────────\n\nexport const TypingIndicatorSchema = ModelSchema.extend({\n userId: z.string(),\n displayName: z.string(),\n startedAt: z.number(), // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nexport type TypingIndicator = z.infer<typeof TypingIndicatorSchema>;\n\n// ─────────────────────────────────────────────\n// Helpers de validação\n// ─────────────────────────────────────────────\n\nexport const safeParseMessage = (data: unknown) => MessageSchema.safeParse(data);\nexport const safeParseChat = (data: unknown) => ChatSchema.safeParse(data);\nexport const validateMessage = (data: unknown) => MessageSchema.parse(data);\nexport const validateChat = (data: unknown) => ChatSchema.parse(data);\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/journey/chat.js","../../../src/model/journey/chat.ts","../../../src/model/shared.ts","../../../src/model.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","chat_exports","AttachmentSchema","ChatSchema","ChatTypeSchema","CreateChatSchema","CreateMessageSchema","LastMessageSchema","MessageSchema","MessageStatusSchema","MessageTypeSchema","ParticipantSchema","ReplyToSchema","TypingIndicatorSchema","safeParseChat","safeParseMessage","validateChat","validateMessage","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","import_zod3","enum","userId","displayName","min","photoURL","url","nullable","role","default","joinedAt","lastSeenAt","size","positive","mimeType","thumbnailUrl","messageId","senderId","senderName","content","max","type","omit","chatId","senderPhotoURL","attachment","status","readBy","replyTo","editedAt","deletedAt","sentAt","participantIds","participants","lastMessage","isOpen","unreadCount","record","isMuted","isArchived","createdBy","startedAt","data","safeParse","parse"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAA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E,SAAS;IACTC,YAAY;AACd;AASO,IAAMrF,wBAAwB6B,YAAYQ,MAAA,CAAO;IACtDW,QAAQF,YAAAnC,CAAA,CAAEc,MAAA;IACVwB,aAAaH,YAAAnC,CAAA,CAAEc,MAAA;IACf8D,WAAWzC,YAAAnC,CAAA,CAAEe,MAAA;AACf;AAOO,IAAMxB,mBAAmB,SAACsF;WAAkB7F,cAAc8F,SAAA,CAAUD;;AACpE,IAAMvF,gBAAmB,SAACuF;WAAkBlG,WAAWmG,SAAA,CAAUD;;AACjE,IAAMpF,kBAAmB,SAACoF;WAAkB7F,cAAc+F,KAAA,CAAMF;;AAChE,IAAMrF,eAAmB,SAACqF;WAAkBlG,WAAWoG,KAAA,CAAMF;;ADWpE,6DAA6D;AAC7D,KAAMnF,CAAAA,OAAOC,OAAO,GAAG;IACrBjB,kBAAAA;IACAC,YAAAA;IACAC,gBAAAA;IACAC,kBAAAA;IACAC,qBAAAA;IACAC,mBAAAA;IACAC,eAAAA;IACAC,qBAAAA;IACAC,mBAAAA;IACAC,mBAAAA;IACAC,eAAAA;IACAC,uBAAAA;IACAC,eAAAA;IACAC,kBAAAA;IACAC,cAAAA;IACAC,iBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/model/journey/chat.ts\nvar chat_exports = {};\n__export(chat_exports, {\n AttachmentSchema: () => AttachmentSchema,\n ChatSchema: () => ChatSchema,\n ChatTypeSchema: () => ChatTypeSchema,\n CreateChatSchema: () => CreateChatSchema,\n CreateMessageSchema: () => CreateMessageSchema,\n LastMessageSchema: () => LastMessageSchema,\n MessageSchema: () => MessageSchema,\n MessageStatusSchema: () => MessageStatusSchema,\n MessageTypeSchema: () => MessageTypeSchema,\n ParticipantSchema: () => ParticipantSchema,\n ReplyToSchema: () => ReplyToSchema,\n TypingIndicatorSchema: () => TypingIndicatorSchema,\n safeParseChat: () => safeParseChat,\n safeParseMessage: () => safeParseMessage,\n validateChat: () => validateChat,\n validateMessage: () => validateMessage\n});\nmodule.exports = __toCommonJS(chat_exports);\nvar import_zod3 = require(\"zod\");\n\n// src/model/shared.ts\nvar import_firestore = require(\"@google-cloud/firestore\");\nvar import_zod = require(\"zod\");\nvar TimestampOrNow = import_zod.z.preprocess(\n (arg) => arg === void 0 ? import_firestore.Timestamp.now() : arg,\n import_zod.z.custom()\n).nullish().optional();\n\n// src/model.ts\nvar import_zod2 = require(\"zod\");\nvar import_cuid = __toESM(require(\"cuid\"));\nvar generateFirestoreId = () => {\n return (0, import_cuid.default)();\n};\nvar IdModelSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]);\nvar IdModelProcess = import_zod2.z.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = import_zod2.z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: import_zod2.z.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: import_zod2.z.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = import_zod2.z.object({\n enabled: import_zod2.z.boolean().optional()\n});\nvar DocumentHistorySchema = import_zod2.z.object({\n createdAt: TimestampOrNow,\n description: import_zod2.z.string().optional()\n});\n\n// src/model/journey/chat.ts\nvar MessageTypeSchema = import_zod3.z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nvar ChatTypeSchema = import_zod3.z.enum([\"direct\", \"group\"]);\nvar MessageStatusSchema = import_zod3.z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nvar ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: import_zod3.z.string().min(1),\n photoURL: import_zod3.z.string().url().nullable().optional(),\n role: import_zod3.z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow\n});\nvar AttachmentSchema = ModelSchema.extend({\n url: import_zod3.z.string().url(),\n name: import_zod3.z.string(),\n size: import_zod3.z.number().positive(),\n // bytes\n mimeType: import_zod3.z.string(),\n thumbnailUrl: import_zod3.z.string().url().optional()\n});\nvar ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: import_zod3.z.string(),\n content: import_zod3.z.string().max(200),\n type: MessageTypeSchema\n});\nvar MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: import_zod3.z.string().min(1),\n senderPhotoURL: import_zod3.z.string().url().nullable().optional(),\n type: MessageTypeSchema,\n content: import_zod3.z.string().min(1).max(4e3),\n attachment: AttachmentSchema.optional(),\n status: MessageStatusSchema.default(\"sending\"),\n readBy: import_zod3.z.array(import_zod3.z.string()).default([]),\n // array de userIds\n replyTo: ReplyToSchema.optional(),\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow\n});\nvar CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true\n});\nvar LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: import_zod3.z.string(),\n senderId: IdModelProcess,\n senderName: import_zod3.z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow\n});\nvar ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: import_zod3.z.string().min(1).optional(),\n description: import_zod3.z.string().max(500).optional(),\n photoURL: import_zod3.z.string().url().optional(),\n participantIds: import_zod3.z.array(IdModelProcess).min(2).max(100),\n participants: import_zod3.z.array(ParticipantSchema),\n lastMessage: LastMessageSchema.optional(),\n isOpen: import_zod3.z.boolean().default(true),\n enabled: import_zod3.z.boolean().default(true),\n unreadCount: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.number()).default({}),\n // { [userId]: true } — chats silenciados por usuário\n isMuted: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.boolean()).default({}),\n isArchived: import_zod3.z.boolean().default(false),\n createdBy: IdModelProcess\n});\nvar CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true\n});\nvar TypingIndicatorSchema = ModelSchema.extend({\n userId: import_zod3.z.string(),\n displayName: import_zod3.z.string(),\n startedAt: import_zod3.z.number()\n // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nvar safeParseMessage = (data) => MessageSchema.safeParse(data);\nvar safeParseChat = (data) => ChatSchema.safeParse(data);\nvar validateMessage = (data) => MessageSchema.parse(data);\nvar validateChat = (data) => ChatSchema.parse(data);\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n AttachmentSchema,\n ChatSchema,\n ChatTypeSchema,\n CreateChatSchema,\n CreateMessageSchema,\n LastMessageSchema,\n MessageSchema,\n MessageStatusSchema,\n MessageTypeSchema,\n ParticipantSchema,\n ReplyToSchema,\n TypingIndicatorSchema,\n safeParseChat,\n safeParseMessage,\n validateChat,\n validateMessage\n});\n","import { z } from \"zod\";\nimport {TimestampOrNow} from \"../shared\";\nimport {IdModelProcess, ModelSchema} from \"../../model\";\n\n// ─────────────────────────────────────────────\n// Enums\n// ─────────────────────────────────────────────\n\nexport const MessageTypeSchema = z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nexport type MessageType = z.infer<typeof MessageTypeSchema>;\n\nexport const ChatTypeSchema = z.enum([\"direct\", \"group\"]);\nexport type ChatType = z.infer<typeof ChatTypeSchema>;\n\nexport const MessageStatusSchema = z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nexport type MessageStatus = z.infer<typeof MessageStatusSchema>;\n\n// ─────────────────────────────────────────────\n// Participant\n// Não estende ModelSchema pois é sub-documento (não tem coleção própria)\n// ─────────────────────────────────────────────\n\nexport const ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z.string().min(1),\n photoURL: z.string().url().nullable().optional(),\n role: z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow,\n});\nexport type Participant = z.infer<typeof ParticipantSchema>;\n\n// ─────────────────────────────────────────────\n// Attachment\n// Sub-documento, sem id próprio\n// ─────────────────────────────────────────────\n\nexport const AttachmentSchema = ModelSchema.extend({\n url: z.string().url(),\n name: z.string(),\n size: z.number().positive(), // bytes\n mimeType: z.string(),\n thumbnailUrl: z.string().url().optional(),\n});\nexport type Attachment = z.infer<typeof AttachmentSchema>;\n\n// ─────────────────────────────────────────────\n// ReplyTo\n// Snapshot da mensagem original (evita lookup extra)\n// ─────────────────────────────────────────────\n\nexport const ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string(),\n content: z.string().max(200),\n type: MessageTypeSchema,\n});\nexport type ReplyTo = z.infer<typeof ReplyToSchema>;\n\n// ─────────────────────────────────────────────\n// Message\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string().min(1),\n senderPhotoURL: z.string().url().nullable().optional(),\n\n type: MessageTypeSchema,\n content: z.string().min(1).max(4000),\n\n attachment: AttachmentSchema.optional(),\n\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z.array(z.string()).default([]), // array de userIds\n\n replyTo: ReplyToSchema.optional(),\n\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow,\n});\nexport type Message = z.infer<typeof MessageSchema>;\n\n// Para criar — omite campos gerados automaticamente pelo ModelSchema/servidor\nexport const CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true,\n});\nexport type CreateMessage = z.infer<typeof CreateMessageSchema>;\n\n// ─────────────────────────────────────────────\n// LastMessage\n// Snapshot da última mensagem para preview na lista de chats\n// ─────────────────────────────────────────────\n\nexport const LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z.string(),\n senderId: IdModelProcess,\n senderName: z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow,\n});\nexport type LastMessage = z.infer<typeof LastMessageSchema>;\n\n// ─────────────────────────────────────────────\n// Chat\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z.string().min(1).optional(),\n description: z.string().max(500).optional(),\n photoURL: z.string().url().optional(),\n\n participantIds: z.array(IdModelProcess).min(2).max(100),\n participants: z.array(ParticipantSchema),\n\n lastMessage: LastMessageSchema.optional(),\n\n isOpen: z.boolean().default(true),\n enabled: z.boolean().default(true),\n unreadCount: z.record(z.string(), z.number()).default({}),\n\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z.record(z.string(), z.boolean()).default({}),\n\n isArchived: z.boolean().default(false),\n\n createdBy: IdModelProcess,\n});\nexport type Chat = z.infer<typeof ChatSchema>;\n\nexport const CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true,\n});\nexport type CreateChat = z.infer<typeof CreateChatSchema>;\n\n// ─────────────────────────────────────────────\n// Typing Indicator\n// Persistido no Realtime Database (não no Firestore)\n// Não usa ModelSchema pois não é documento Firestore\n// ─────────────────────────────────────────────\n\nexport const TypingIndicatorSchema = ModelSchema.extend({\n userId: z.string(),\n displayName: z.string(),\n startedAt: z.number(), // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nexport type TypingIndicator = z.infer<typeof TypingIndicatorSchema>;\n\n// ─────────────────────────────────────────────\n// Helpers de validação\n// ─────────────────────────────────────────────\n\nexport const safeParseMessage = (data: unknown) => MessageSchema.safeParse(data);\nexport const safeParseChat = (data: unknown) => ChatSchema.safeParse(data);\nexport const validateMessage = (data: unknown) => MessageSchema.parse(data);\nexport const validateChat = (data: unknown) => ChatSchema.parse(data);\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n"]}
|
|
@@ -129,6 +129,7 @@ var ChatSchema = ModelSchema.omit({
|
|
|
129
129
|
participants: z3.array(ParticipantSchema),
|
|
130
130
|
lastMessage: LastMessageSchema.optional(),
|
|
131
131
|
isOpen: z3.boolean().default(true),
|
|
132
|
+
enabled: z3.boolean().default(true),
|
|
132
133
|
unreadCount: z3.record(z3.string(), z3.number()).default({}),
|
|
133
134
|
// { [userId]: true } — chats silenciados por usuário
|
|
134
135
|
isMuted: z3.record(z3.string(), z3.boolean()).default({}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/journey/chat.mjs","../../../src/model/journey/chat.ts","../../../src/model/shared.ts","../../../src/model.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","MessageTypeSchema","enum","ChatTypeSchema","MessageStatusSchema","ParticipantSchema","userId","displayName","min","photoURL","url","nullable","role","default","joinedAt","lastSeenAt","AttachmentSchema","name","size","positive","mimeType","thumbnailUrl","ReplyToSchema","messageId","senderId","senderName","content","max","type","MessageSchema","omit","chatId","senderPhotoURL","attachment","status","readBy","replyTo","editedAt","deletedAt","CreateMessageSchema","LastMessageSchema","sentAt","ChatSchema","participantIds","participants","lastMessage","isOpen","unreadCount","record","isMuted","isArchived","createdBy","CreateChatSchema","TypingIndicatorSchema","startedAt","safeParseMessage","data","safeParse","safeParseChat","validateMessage","parse","validateChat"],"mappings":"AAAA,4BAA4B;ACA5B,SAASA,KAAAA,EAAAA,QAAS,MAAA;ADGlB,sBAAsB;AEHtB,SAASC,SAAA,QAAiB,0BAAA;AAC1B,SAAQD,CAAA,QAAQ,MAAA;AAET,IAAME,iBAAiBF,EAC3BG,UAAA,CACC,SAACC;WAASA,QAAQ,KAAA,IAAYH,UAAUI,GAAA,KAAQD;GAChDJ,EAAEM,MAAA,IAEHC,OAAA,GAAUC,QAAA;AFGb,eAAe;AGXf,SAAQR,KAAAA,EAAAA,QAAQ,MAAA;AAEhB,OAAOS,UAAU,OAAA;AAEV,IAAMC,sBAAsB;IACjC,OAAOD;AACT;AAEO,IAAME,gBAAgBX,GAAEY,KAAA,CAAM;IAACZ,GAAEa,MAAA;IAAUb,GAAEc,MAAA;CAAS;AAEtD,IAAMC,iBAAiBf,GAAEG,UAAA,CAAW,SAACa;IAC1C,IAAIA,QAAQ,KAAA,KAAaA,QAAQ,MAAM;QACrC,OAAON;IACT;IACA,OAAOM;AACT,GAAGL;AAEI,IAAMM,cAAcjB,GAAEkB,MAAA,CAAO;IAClCC,IAAIJ;IACJK,WAAWlB;IACXmB,WAAWnB;IACXoB,OAAOtB,GAAEuB,MAAA,CAAOT,MAAA,GAASP,OAAA,GAAUC,QAAA;AACrC;AAEO,IAAMgB,iBAAiBP,YAAYQ,MAAA,CAAO;IAC/CC,UAAU1B,GAAE2B,IAAA,CAAK;eAAMV,YAAYW,KAAA,GAAQpB,QAAA;;AAC7C;AAEO,IAAMqB,gBAAgB7B,GAAEkB,MAAA,CAAO;IACpCY,SAAS9B,GAAE+B,OAAA,GAAUvB,QAAA;AACvB;AAEO,IAAMwB,wBAAwBhC,GAAEkB,MAAA,CAAO;IA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MAAA,IAAUb,GAAEc,MAAA,IAAUgC,OAAA,CAAQ,CAAC;IAAC,qDAAA;IAGxDoC,SAASlF,GAAEiF,MAAA,CAAOjF,GAAEa,MAAA,IAAUb,GAAE+B,OAAA,IAAWe,OAAA,CAAQ,CAAC;IAEpDqC,YAAYnF,GAAE+B,OAAA,GAAUe,OAAA,CAAQ;IAEhCsC,WAAWrE;AACb;AAGO,IAAMsE,mBAAmBV,WAAWZ,IAAA,CAAK;IAC9C5C,IAAI;IACJC,WAAW;IACXC,WAAW;IACXyD,aAAa;IACbE,aAAa;IACbE,SAAS;IACTC,YAAY;AACd;AASO,IAAMG,wBAAwBrE,YAAYQ,MAAA,CAAO;IACtDc,QAAQvC,GAAEa,MAAA;IACV2B,aAAaxC,GAAEa,MAAA;IACf0E,WAAWvF,GAAEc,MAAA;AACf;AAOO,IAAM0E,mBAAmB,SAACC;WAAkB3B,cAAc4B,SAAA,CAAUD;;AACpE,IAAME,gBAAmB,SAACF;WAAkBd,WAAWe,SAAA,CAAUD;;AACjE,IAAMG,kBAAmB,SAACH;WAAkB3B,cAAc+B,KAAA,CAAMJ;;AAChE,IAAMK,eAAmB,SAACL;WAAkBd,WAAWkB,KAAA,CAAMJ;;ADtCpE,SACExC,gBAAgB,EAChB0B,UAAU,EACVvC,cAAc,EACdiD,gBAAgB,EAChBb,mBAAmB,EACnBC,iBAAiB,EACjBX,aAAa,EACbzB,mBAAmB,EACnBH,iBAAiB,EACjBI,iBAAiB,EACjBiB,aAAa,EACb+B,qBAAqB,EACrBK,aAAa,EACbH,gBAAgB,EAChBM,YAAY,EACZF,eAAe,GACf","sourcesContent":["// src/model/journey/chat.ts\nimport { z as z3 } from \"zod\";\n\n// src/model/shared.ts\nimport { Timestamp } from \"@google-cloud/firestore\";\nimport { z } from \"zod\";\nvar TimestampOrNow = z.preprocess(\n (arg) => arg === void 0 ? Timestamp.now() : arg,\n z.custom()\n).nullish().optional();\n\n// src/model.ts\nimport { z as z2 } from \"zod\";\nimport cuid from \"cuid\";\nvar generateFirestoreId = () => {\n return cuid();\n};\nvar IdModelSchema = z2.union([z2.string(), z2.number()]);\nvar IdModelProcess = z2.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = z2.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z2.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: z2.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = z2.object({\n enabled: z2.boolean().optional()\n});\nvar DocumentHistorySchema = z2.object({\n createdAt: TimestampOrNow,\n description: z2.string().optional()\n});\n\n// src/model/journey/chat.ts\nvar MessageTypeSchema = z3.enum([\"text\", \"image\", \"file\", \"audio\"]);\nvar ChatTypeSchema = z3.enum([\"direct\", \"group\"]);\nvar MessageStatusSchema = z3.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nvar ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z3.string().min(1),\n photoURL: z3.string().url().nullable().optional(),\n role: z3.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow\n});\nvar AttachmentSchema = ModelSchema.extend({\n url: z3.string().url(),\n name: z3.string(),\n size: z3.number().positive(),\n // bytes\n mimeType: z3.string(),\n thumbnailUrl: z3.string().url().optional()\n});\nvar ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z3.string(),\n content: z3.string().max(200),\n type: MessageTypeSchema\n});\nvar MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z3.string().min(1),\n senderPhotoURL: z3.string().url().nullable().optional(),\n type: MessageTypeSchema,\n content: z3.string().min(1).max(4e3),\n attachment: AttachmentSchema.optional(),\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z3.array(z3.string()).default([]),\n // array de userIds\n replyTo: ReplyToSchema.optional(),\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow\n});\nvar CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true\n});\nvar LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z3.string(),\n senderId: IdModelProcess,\n senderName: z3.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow\n});\nvar ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z3.string().min(1).optional(),\n description: z3.string().max(500).optional(),\n photoURL: z3.string().url().optional(),\n participantIds: z3.array(IdModelProcess).min(2).max(100),\n participants: z3.array(ParticipantSchema),\n lastMessage: LastMessageSchema.optional(),\n isOpen: z3.boolean().default(true),\n unreadCount: z3.record(z3.string(), z3.number()).default({}),\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z3.record(z3.string(), z3.boolean()).default({}),\n isArchived: z3.boolean().default(false),\n createdBy: IdModelProcess\n});\nvar CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true\n});\nvar TypingIndicatorSchema = ModelSchema.extend({\n userId: z3.string(),\n displayName: z3.string(),\n startedAt: z3.number()\n // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nvar safeParseMessage = (data) => MessageSchema.safeParse(data);\nvar safeParseChat = (data) => ChatSchema.safeParse(data);\nvar validateMessage = (data) => MessageSchema.parse(data);\nvar validateChat = (data) => ChatSchema.parse(data);\nexport {\n AttachmentSchema,\n ChatSchema,\n ChatTypeSchema,\n CreateChatSchema,\n CreateMessageSchema,\n LastMessageSchema,\n MessageSchema,\n MessageStatusSchema,\n MessageTypeSchema,\n ParticipantSchema,\n ReplyToSchema,\n TypingIndicatorSchema,\n safeParseChat,\n safeParseMessage,\n validateChat,\n validateMessage\n};\n","import { z } from \"zod\";\nimport {TimestampOrNow} from \"../shared\";\nimport {IdModelProcess, ModelSchema} from \"../../model\";\n\n// ─────────────────────────────────────────────\n// Enums\n// ─────────────────────────────────────────────\n\nexport const MessageTypeSchema = z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nexport type MessageType = z.infer<typeof MessageTypeSchema>;\n\nexport const ChatTypeSchema = z.enum([\"direct\", \"group\"]);\nexport type ChatType = z.infer<typeof ChatTypeSchema>;\n\nexport const MessageStatusSchema = z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nexport type MessageStatus = z.infer<typeof MessageStatusSchema>;\n\n// ─────────────────────────────────────────────\n// Participant\n// Não estende ModelSchema pois é sub-documento (não tem coleção própria)\n// ─────────────────────────────────────────────\n\nexport const ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z.string().min(1),\n photoURL: z.string().url().nullable().optional(),\n role: z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow,\n});\nexport type Participant = z.infer<typeof ParticipantSchema>;\n\n// ─────────────────────────────────────────────\n// Attachment\n// Sub-documento, sem id próprio\n// ─────────────────────────────────────────────\n\nexport const AttachmentSchema = ModelSchema.extend({\n url: z.string().url(),\n name: z.string(),\n size: z.number().positive(), // bytes\n mimeType: z.string(),\n thumbnailUrl: z.string().url().optional(),\n});\nexport type Attachment = z.infer<typeof AttachmentSchema>;\n\n// ─────────────────────────────────────────────\n// ReplyTo\n// Snapshot da mensagem original (evita lookup extra)\n// ─────────────────────────────────────────────\n\nexport const ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string(),\n content: z.string().max(200),\n type: MessageTypeSchema,\n});\nexport type ReplyTo = z.infer<typeof ReplyToSchema>;\n\n// ─────────────────────────────────────────────\n// Message\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string().min(1),\n senderPhotoURL: z.string().url().nullable().optional(),\n\n type: MessageTypeSchema,\n content: z.string().min(1).max(4000),\n\n attachment: AttachmentSchema.optional(),\n\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z.array(z.string()).default([]), // array de userIds\n\n replyTo: ReplyToSchema.optional(),\n\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow,\n});\nexport type Message = z.infer<typeof MessageSchema>;\n\n// Para criar — omite campos gerados automaticamente pelo ModelSchema/servidor\nexport const CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true,\n});\nexport type CreateMessage = z.infer<typeof CreateMessageSchema>;\n\n// ─────────────────────────────────────────────\n// LastMessage\n// Snapshot da última mensagem para preview na lista de chats\n// ─────────────────────────────────────────────\n\nexport const LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z.string(),\n senderId: IdModelProcess,\n senderName: z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow,\n});\nexport type LastMessage = z.infer<typeof LastMessageSchema>;\n\n// ─────────────────────────────────────────────\n// Chat\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z.string().min(1).optional(),\n description: z.string().max(500).optional(),\n photoURL: z.string().url().optional(),\n\n participantIds: z.array(IdModelProcess).min(2).max(100),\n participants: z.array(ParticipantSchema),\n\n lastMessage: LastMessageSchema.optional(),\n\n isOpen: z.boolean().default(true),\n unreadCount: z.record(z.string(), z.number()).default({}),\n\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z.record(z.string(), z.boolean()).default({}),\n\n isArchived: z.boolean().default(false),\n\n createdBy: IdModelProcess,\n});\nexport type Chat = z.infer<typeof ChatSchema>;\n\nexport const CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true,\n});\nexport type CreateChat = z.infer<typeof CreateChatSchema>;\n\n// ─────────────────────────────────────────────\n// Typing Indicator\n// Persistido no Realtime Database (não no Firestore)\n// Não usa ModelSchema pois não é documento Firestore\n// ─────────────────────────────────────────────\n\nexport const TypingIndicatorSchema = ModelSchema.extend({\n userId: z.string(),\n displayName: z.string(),\n startedAt: z.number(), // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nexport type TypingIndicator = z.infer<typeof TypingIndicatorSchema>;\n\n// ─────────────────────────────────────────────\n// Helpers de validação\n// ─────────────────────────────────────────────\n\nexport const safeParseMessage = (data: unknown) => MessageSchema.safeParse(data);\nexport const safeParseChat = (data: unknown) => ChatSchema.safeParse(data);\nexport const validateMessage = (data: unknown) => MessageSchema.parse(data);\nexport const validateChat = (data: unknown) => ChatSchema.parse(data);\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/journey/chat.mjs","../../../src/model/journey/chat.ts","../../../src/model/shared.ts","../../../src/model.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","MessageTypeSchema","enum","ChatTypeSchema","MessageStatusSchema","ParticipantSchema","userId","displayName","min","photoURL","url","nullable","role","default","joinedAt","lastSeenAt","AttachmentSchema","name","size","positive","mimeType","thumbnailUrl","ReplyToSchema","messageId","senderId","senderName","content","max","type","MessageSchema","omit","chatId","senderPhotoURL","attachment","status","readBy","replyTo","editedAt","deletedAt","CreateMessageSchema","LastMessageSchema","sentAt","ChatSchema","participantIds","participants","lastMessage","isOpen","unreadCount","record","isMuted","isArchived","createdBy","CreateChatSchema","TypingIndicatorSchema","startedAt","safeParseMessage","data","safeParse","safeParseChat","validateMessage","parse","validateChat"],"mappings":"AAAA,4BAA4B;ACA5B,SAASA,KAAAA,EAAAA,QAAS,MAAA;ADGlB,sBAAsB;AEHtB,SAASC,SAAA,QAAiB,0BAAA;AAC1B,SAAQD,CAAA,QAAQ,MAAA;AAET,IAAME,iBAAiBF,EAC3BG,UAAA,CACC,SAACC;WAASA,QAAQ,KAAA,IAAYH,UAAUI,GAAA,KAAQD;GAChDJ,EAAEM,MAAA,IAEHC,OAAA,GAAUC,QAAA;AFGb,eAAe;AGXf,SAAQR,KAAAA,E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AQvC,GAAEa,MAAA;IACV2B,aAAaxC,GAAEa,MAAA;IACf0E,WAAWvF,GAAEc,MAAA;AACf;AAOO,IAAM0E,mBAAmB,SAACC;WAAkB3B,cAAc4B,SAAA,CAAUD;;AACpE,IAAME,gBAAmB,SAACF;WAAkBd,WAAWe,SAAA,CAAUD;;AACjE,IAAMG,kBAAmB,SAACH;WAAkB3B,cAAc+B,KAAA,CAAMJ;;AAChE,IAAMK,eAAmB,SAACL;WAAkBd,WAAWkB,KAAA,CAAMJ;;ADtCpE,SACExC,gBAAgB,EAChB0B,UAAU,EACVvC,cAAc,EACdiD,gBAAgB,EAChBb,mBAAmB,EACnBC,iBAAiB,EACjBX,aAAa,EACbzB,mBAAmB,EACnBH,iBAAiB,EACjBI,iBAAiB,EACjBiB,aAAa,EACb+B,qBAAqB,EACrBK,aAAa,EACbH,gBAAgB,EAChBM,YAAY,EACZF,eAAe,GACf","sourcesContent":["// src/model/journey/chat.ts\nimport { z as z3 } from \"zod\";\n\n// src/model/shared.ts\nimport { Timestamp } from \"@google-cloud/firestore\";\nimport { z } from \"zod\";\nvar TimestampOrNow = z.preprocess(\n (arg) => arg === void 0 ? Timestamp.now() : arg,\n z.custom()\n).nullish().optional();\n\n// src/model.ts\nimport { z as z2 } from \"zod\";\nimport cuid from \"cuid\";\nvar generateFirestoreId = () => {\n return cuid();\n};\nvar IdModelSchema = z2.union([z2.string(), z2.number()]);\nvar IdModelProcess = z2.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = z2.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z2.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: z2.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = z2.object({\n enabled: z2.boolean().optional()\n});\nvar DocumentHistorySchema = z2.object({\n createdAt: TimestampOrNow,\n description: z2.string().optional()\n});\n\n// src/model/journey/chat.ts\nvar MessageTypeSchema = z3.enum([\"text\", \"image\", \"file\", \"audio\"]);\nvar ChatTypeSchema = z3.enum([\"direct\", \"group\"]);\nvar MessageStatusSchema = z3.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nvar ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z3.string().min(1),\n photoURL: z3.string().url().nullable().optional(),\n role: z3.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow\n});\nvar AttachmentSchema = ModelSchema.extend({\n url: z3.string().url(),\n name: z3.string(),\n size: z3.number().positive(),\n // bytes\n mimeType: z3.string(),\n thumbnailUrl: z3.string().url().optional()\n});\nvar ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z3.string(),\n content: z3.string().max(200),\n type: MessageTypeSchema\n});\nvar MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z3.string().min(1),\n senderPhotoURL: z3.string().url().nullable().optional(),\n type: MessageTypeSchema,\n content: z3.string().min(1).max(4e3),\n attachment: AttachmentSchema.optional(),\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z3.array(z3.string()).default([]),\n // array de userIds\n replyTo: ReplyToSchema.optional(),\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow\n});\nvar CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true\n});\nvar LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z3.string(),\n senderId: IdModelProcess,\n senderName: z3.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow\n});\nvar ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z3.string().min(1).optional(),\n description: z3.string().max(500).optional(),\n photoURL: z3.string().url().optional(),\n participantIds: z3.array(IdModelProcess).min(2).max(100),\n participants: z3.array(ParticipantSchema),\n lastMessage: LastMessageSchema.optional(),\n isOpen: z3.boolean().default(true),\n enabled: z3.boolean().default(true),\n unreadCount: z3.record(z3.string(), z3.number()).default({}),\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z3.record(z3.string(), z3.boolean()).default({}),\n isArchived: z3.boolean().default(false),\n createdBy: IdModelProcess\n});\nvar CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true\n});\nvar TypingIndicatorSchema = ModelSchema.extend({\n userId: z3.string(),\n displayName: z3.string(),\n startedAt: z3.number()\n // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nvar safeParseMessage = (data) => MessageSchema.safeParse(data);\nvar safeParseChat = (data) => ChatSchema.safeParse(data);\nvar validateMessage = (data) => MessageSchema.parse(data);\nvar validateChat = (data) => ChatSchema.parse(data);\nexport {\n AttachmentSchema,\n ChatSchema,\n ChatTypeSchema,\n CreateChatSchema,\n CreateMessageSchema,\n LastMessageSchema,\n MessageSchema,\n MessageStatusSchema,\n MessageTypeSchema,\n ParticipantSchema,\n ReplyToSchema,\n TypingIndicatorSchema,\n safeParseChat,\n safeParseMessage,\n validateChat,\n validateMessage\n};\n","import { z } from \"zod\";\nimport {TimestampOrNow} from \"../shared\";\nimport {IdModelProcess, ModelSchema} from \"../../model\";\n\n// ─────────────────────────────────────────────\n// Enums\n// ─────────────────────────────────────────────\n\nexport const MessageTypeSchema = z.enum([\"text\", \"image\", \"file\", \"audio\"]);\nexport type MessageType = z.infer<typeof MessageTypeSchema>;\n\nexport const ChatTypeSchema = z.enum([\"direct\", \"group\"]);\nexport type ChatType = z.infer<typeof ChatTypeSchema>;\n\nexport const MessageStatusSchema = z.enum([\"sending\", \"sent\", \"delivered\", \"read\", \"failed\"]);\nexport type MessageStatus = z.infer<typeof MessageStatusSchema>;\n\n// ─────────────────────────────────────────────\n// Participant\n// Não estende ModelSchema pois é sub-documento (não tem coleção própria)\n// ─────────────────────────────────────────────\n\nexport const ParticipantSchema = ModelSchema.extend({\n userId: IdModelProcess,\n displayName: z.string().min(1),\n photoURL: z.string().url().nullable().optional(),\n role: z.enum([\"admin\", \"member\"]).default(\"member\"),\n joinedAt: TimestampOrNow,\n lastSeenAt: TimestampOrNow,\n});\nexport type Participant = z.infer<typeof ParticipantSchema>;\n\n// ─────────────────────────────────────────────\n// Attachment\n// Sub-documento, sem id próprio\n// ─────────────────────────────────────────────\n\nexport const AttachmentSchema = ModelSchema.extend({\n url: z.string().url(),\n name: z.string(),\n size: z.number().positive(), // bytes\n mimeType: z.string(),\n thumbnailUrl: z.string().url().optional(),\n});\nexport type Attachment = z.infer<typeof AttachmentSchema>;\n\n// ─────────────────────────────────────────────\n// ReplyTo\n// Snapshot da mensagem original (evita lookup extra)\n// ─────────────────────────────────────────────\n\nexport const ReplyToSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string(),\n content: z.string().max(200),\n type: MessageTypeSchema,\n});\nexport type ReplyTo = z.infer<typeof ReplyToSchema>;\n\n// ─────────────────────────────────────────────\n// Message\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const MessageSchema = ModelSchema.omit({ order: true }).extend({\n chatId: IdModelProcess,\n senderId: IdModelProcess,\n senderName: z.string().min(1),\n senderPhotoURL: z.string().url().nullable().optional(),\n\n type: MessageTypeSchema,\n content: z.string().min(1).max(4000),\n\n attachment: AttachmentSchema.optional(),\n\n status: MessageStatusSchema.default(\"sending\"),\n readBy: z.array(z.string()).default([]), // array de userIds\n\n replyTo: ReplyToSchema.optional(),\n\n editedAt: TimestampOrNow,\n deletedAt: TimestampOrNow,\n});\nexport type Message = z.infer<typeof MessageSchema>;\n\n// Para criar — omite campos gerados automaticamente pelo ModelSchema/servidor\nexport const CreateMessageSchema = MessageSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n status: true,\n readBy: true,\n editedAt: true,\n deletedAt: true,\n});\nexport type CreateMessage = z.infer<typeof CreateMessageSchema>;\n\n// ─────────────────────────────────────────────\n// LastMessage\n// Snapshot da última mensagem para preview na lista de chats\n// ─────────────────────────────────────────────\n\nexport const LastMessageSchema = ModelSchema.extend({\n messageId: IdModelProcess,\n content: z.string(),\n senderId: IdModelProcess,\n senderName: z.string(),\n type: MessageTypeSchema,\n sentAt: TimestampOrNow,\n});\nexport type LastMessage = z.infer<typeof LastMessageSchema>;\n\n// ─────────────────────────────────────────────\n// Chat\n// Estende ModelSchema — herda id, createdAt, updatedAt, order\n// ─────────────────────────────────────────────\n\nexport const ChatSchema = ModelSchema.omit({ order: true }).extend({\n type: ChatTypeSchema,\n name: z.string().min(1).optional(),\n description: z.string().max(500).optional(),\n photoURL: z.string().url().optional(),\n\n participantIds: z.array(IdModelProcess).min(2).max(100),\n participants: z.array(ParticipantSchema),\n\n lastMessage: LastMessageSchema.optional(),\n\n isOpen: z.boolean().default(true),\n enabled: z.boolean().default(true),\n unreadCount: z.record(z.string(), z.number()).default({}),\n\n // { [userId]: true } — chats silenciados por usuário\n isMuted: z.record(z.string(), z.boolean()).default({}),\n\n isArchived: z.boolean().default(false),\n\n createdBy: IdModelProcess,\n});\nexport type Chat = z.infer<typeof ChatSchema>;\n\nexport const CreateChatSchema = ChatSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n lastMessage: true,\n unreadCount: true,\n isMuted: true,\n isArchived: true,\n});\nexport type CreateChat = z.infer<typeof CreateChatSchema>;\n\n// ─────────────────────────────────────────────\n// Typing Indicator\n// Persistido no Realtime Database (não no Firestore)\n// Não usa ModelSchema pois não é documento Firestore\n// ─────────────────────────────────────────────\n\nexport const TypingIndicatorSchema = ModelSchema.extend({\n userId: z.string(),\n displayName: z.string(),\n startedAt: z.number(), // Unix timestamp — RTDB não usa Timestamp do Firestore\n});\nexport type TypingIndicator = z.infer<typeof TypingIndicatorSchema>;\n\n// ─────────────────────────────────────────────\n// Helpers de validação\n// ─────────────────────────────────────────────\n\nexport const safeParseMessage = (data: unknown) => MessageSchema.safeParse(data);\nexport const safeParseChat = (data: unknown) => ChatSchema.safeParse(data);\nexport const validateMessage = (data: unknown) => MessageSchema.parse(data);\nexport const validateChat = (data: unknown) => ChatSchema.parse(data);\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n"]}
|
|
@@ -8,6 +8,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
8
8
|
order: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
9
9
|
}, {
|
|
10
10
|
completionPercentage: z.ZodNumber;
|
|
11
|
+
startsWith: z.ZodOptional<z.ZodNumber>;
|
|
11
12
|
lastChange: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
12
13
|
}>, "strip", z.ZodTypeAny, {
|
|
13
14
|
id: string | number;
|
|
@@ -16,6 +17,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
16
17
|
createdAt?: Timestamp | null | undefined;
|
|
17
18
|
updatedAt?: Timestamp | null | undefined;
|
|
18
19
|
order?: number | null | undefined;
|
|
20
|
+
startsWith?: number | undefined;
|
|
19
21
|
}, {
|
|
20
22
|
lastChange: Timestamp;
|
|
21
23
|
completionPercentage: number;
|
|
@@ -23,6 +25,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
23
25
|
createdAt?: unknown;
|
|
24
26
|
updatedAt?: unknown;
|
|
25
27
|
order?: number | null | undefined;
|
|
28
|
+
startsWith?: number | undefined;
|
|
26
29
|
}>;
|
|
27
30
|
declare const ModuleProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
28
31
|
id: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string | number, unknown>;
|
|
@@ -59,6 +62,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
59
62
|
order: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
60
63
|
}, {
|
|
61
64
|
completionPercentage: z.ZodNumber;
|
|
65
|
+
startsWith: z.ZodOptional<z.ZodNumber>;
|
|
62
66
|
lastChange: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
63
67
|
}>, "strip", z.ZodTypeAny, {
|
|
64
68
|
id: string | number;
|
|
@@ -67,6 +71,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
67
71
|
createdAt?: Timestamp | null | undefined;
|
|
68
72
|
updatedAt?: Timestamp | null | undefined;
|
|
69
73
|
order?: number | null | undefined;
|
|
74
|
+
startsWith?: number | undefined;
|
|
70
75
|
}, {
|
|
71
76
|
lastChange: Timestamp;
|
|
72
77
|
completionPercentage: number;
|
|
@@ -74,6 +79,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
74
79
|
createdAt?: unknown;
|
|
75
80
|
updatedAt?: unknown;
|
|
76
81
|
order?: number | null | undefined;
|
|
82
|
+
startsWith?: number | undefined;
|
|
77
83
|
}>, "many">;
|
|
78
84
|
}>, "strip", z.ZodTypeAny, {
|
|
79
85
|
id: string | number;
|
|
@@ -84,6 +90,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
84
90
|
createdAt?: Timestamp | null | undefined;
|
|
85
91
|
updatedAt?: Timestamp | null | undefined;
|
|
86
92
|
order?: number | null | undefined;
|
|
93
|
+
startsWith?: number | undefined;
|
|
87
94
|
}[];
|
|
88
95
|
completionCounter: number;
|
|
89
96
|
createdAt?: Timestamp | null | undefined;
|
|
@@ -97,6 +104,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
97
104
|
createdAt?: unknown;
|
|
98
105
|
updatedAt?: unknown;
|
|
99
106
|
order?: number | null | undefined;
|
|
107
|
+
startsWith?: number | undefined;
|
|
100
108
|
}[];
|
|
101
109
|
completionCounter: number;
|
|
102
110
|
id?: unknown;
|
package/dist/model/purchase.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
8
8
|
order: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
9
9
|
}, {
|
|
10
10
|
completionPercentage: z.ZodNumber;
|
|
11
|
+
startsWith: z.ZodOptional<z.ZodNumber>;
|
|
11
12
|
lastChange: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
12
13
|
}>, "strip", z.ZodTypeAny, {
|
|
13
14
|
id: string | number;
|
|
@@ -16,6 +17,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
16
17
|
createdAt?: Timestamp | null | undefined;
|
|
17
18
|
updatedAt?: Timestamp | null | undefined;
|
|
18
19
|
order?: number | null | undefined;
|
|
20
|
+
startsWith?: number | undefined;
|
|
19
21
|
}, {
|
|
20
22
|
lastChange: Timestamp;
|
|
21
23
|
completionPercentage: number;
|
|
@@ -23,6 +25,7 @@ declare const ActivityProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
23
25
|
createdAt?: unknown;
|
|
24
26
|
updatedAt?: unknown;
|
|
25
27
|
order?: number | null | undefined;
|
|
28
|
+
startsWith?: number | undefined;
|
|
26
29
|
}>;
|
|
27
30
|
declare const ModuleProgressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
28
31
|
id: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string | number, unknown>;
|
|
@@ -59,6 +62,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
59
62
|
order: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodNumber>>>;
|
|
60
63
|
}, {
|
|
61
64
|
completionPercentage: z.ZodNumber;
|
|
65
|
+
startsWith: z.ZodOptional<z.ZodNumber>;
|
|
62
66
|
lastChange: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
63
67
|
}>, "strip", z.ZodTypeAny, {
|
|
64
68
|
id: string | number;
|
|
@@ -67,6 +71,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
67
71
|
createdAt?: Timestamp | null | undefined;
|
|
68
72
|
updatedAt?: Timestamp | null | undefined;
|
|
69
73
|
order?: number | null | undefined;
|
|
74
|
+
startsWith?: number | undefined;
|
|
70
75
|
}, {
|
|
71
76
|
lastChange: Timestamp;
|
|
72
77
|
completionPercentage: number;
|
|
@@ -74,6 +79,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
74
79
|
createdAt?: unknown;
|
|
75
80
|
updatedAt?: unknown;
|
|
76
81
|
order?: number | null | undefined;
|
|
82
|
+
startsWith?: number | undefined;
|
|
77
83
|
}>, "many">;
|
|
78
84
|
}>, "strip", z.ZodTypeAny, {
|
|
79
85
|
id: string | number;
|
|
@@ -84,6 +90,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
84
90
|
createdAt?: Timestamp | null | undefined;
|
|
85
91
|
updatedAt?: Timestamp | null | undefined;
|
|
86
92
|
order?: number | null | undefined;
|
|
93
|
+
startsWith?: number | undefined;
|
|
87
94
|
}[];
|
|
88
95
|
completionCounter: number;
|
|
89
96
|
createdAt?: Timestamp | null | undefined;
|
|
@@ -97,6 +104,7 @@ declare const ModuleProgressWithActivitiesSchema: z.ZodObject<z.objectUtil.exten
|
|
|
97
104
|
createdAt?: unknown;
|
|
98
105
|
updatedAt?: unknown;
|
|
99
106
|
order?: number | null | undefined;
|
|
107
|
+
startsWith?: number | undefined;
|
|
100
108
|
}[];
|
|
101
109
|
completionCounter: number;
|
|
102
110
|
id?: unknown;
|
package/dist/model/purchase.js
CHANGED
|
@@ -119,6 +119,7 @@ var DocumentHistorySchema = import_zod2.z.object({
|
|
|
119
119
|
var import_zod3 = require("zod");
|
|
120
120
|
var ActivityProgressSchema = ModelSchema.extend({
|
|
121
121
|
completionPercentage: import_zod3.z.coerce.number(),
|
|
122
|
+
startsWith: import_zod3.z.coerce.number().optional(),
|
|
122
123
|
lastChange: import_zod3.z.custom()
|
|
123
124
|
});
|
|
124
125
|
var ModuleProgressSchema = ModelSchema.extend({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/purchase.js","../../src/model/purchase.ts","../../src/model.ts","../../src/model/shared.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","purchase_exports","ActivityProgressSchema","ModuleProgressSchema","ModuleProgressWithActivitiesSchema","PurchaseSchema","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","completionPercentage","import_zod3","lastChange","completionCounter","activities","nextActivityId","nextModuleId","modulesAllowed"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfb,UAAUY,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,OAAOA,SAAS,YAAY,OAAOA,SAAS,YAAY;YAC7D,kCAAA,2BAAA;;;gBAAA,IAAIG,MAAJ;gBACH,IAAI,CAACd,aAAae,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCpB,UAAUkB,IAAII,KAAK;oBAAEP,KAAK;+BAAMI,IAAI,CAACG,IAAI;;oBAAEN,YAAY,CAAEK,CAAAA,OAAOnB,iB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;AAEO,IAAMpC,iBAAiByB,YAAYQ,MAAA,CAAO;IAC/Cc,gBAAgBJ,YAAApC,CAAA,CAAEc,MAAA,GAASP,QAAA;IAC3BkC,cAAcL,YAAApC,CAAA,CAAEc,MAAA,GAASP,QAAA;IACzBmC,gBAAgBN,YAAApC,CAAA,CAAEc,MAAA,GAASe,KAAA,GAAQtB,QAAA;AACrC;AD2EA,6DAA6D;AAC7D,KAAMb,CAAAA,OAAOC,OAAO,GAAG;IACrBL,wBAAAA;IACAC,sBAAAA;IACAC,oCAAAA;IACAC,gBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/model/purchase.ts\nvar purchase_exports = {};\n__export(purchase_exports, {\n ActivityProgressSchema: () => ActivityProgressSchema,\n ModuleProgressSchema: () => ModuleProgressSchema,\n ModuleProgressWithActivitiesSchema: () => ModuleProgressWithActivitiesSchema,\n PurchaseSchema: () => PurchaseSchema\n});\nmodule.exports = __toCommonJS(purchase_exports);\n\n// src/model.ts\nvar import_zod2 = require(\"zod\");\n\n// src/model/shared.ts\nvar import_firestore = require(\"@google-cloud/firestore\");\nvar import_zod = require(\"zod\");\nvar TimestampOrNow = import_zod.z.preprocess(\n (arg) => arg === void 0 ? import_firestore.Timestamp.now() : arg,\n import_zod.z.custom()\n).nullish().optional();\n\n// src/model.ts\nvar import_cuid = __toESM(require(\"cuid\"));\nvar generateFirestoreId = () => {\n return (0, import_cuid.default)();\n};\nvar IdModelSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]);\nvar IdModelProcess = import_zod2.z.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = import_zod2.z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: import_zod2.z.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: import_zod2.z.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = import_zod2.z.object({\n enabled: import_zod2.z.boolean().optional()\n});\nvar DocumentHistorySchema = import_zod2.z.object({\n createdAt: TimestampOrNow,\n description: import_zod2.z.string().optional()\n});\n\n// src/model/purchase.ts\nvar import_zod3 = require(\"zod\");\nvar ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: import_zod3.z.coerce.number(),\n lastChange: import_zod3.z.custom()\n});\nvar ModuleProgressSchema = ModelSchema.extend({\n completionCounter: import_zod3.z.coerce.number()\n});\nvar ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n});\nvar PurchaseSchema = ModelSchema.extend({\n nextActivityId: import_zod3.z.string().optional(),\n nextModuleId: import_zod3.z.string().optional(),\n modulesAllowed: import_zod3.z.string().array().optional()\n});\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n ActivityProgressSchema,\n ModuleProgressSchema,\n ModuleProgressWithActivitiesSchema,\n PurchaseSchema\n});\n","import {ModelSchema} from \"../model\";\nimport {z} from \"zod\";\nimport {Timestamp} from \"@google-cloud/firestore\";\n\nexport const ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: z.coerce.number(),\n lastChange: z.custom<Timestamp>()\n})\n\nexport const ModuleProgressSchema = ModelSchema.extend({\n completionCounter: z.coerce.number()\n})\n\nexport const ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n})\n\nexport const PurchaseSchema = ModelSchema.extend({\n nextActivityId: z.string().optional(),\n nextModuleId: z.string().optional(),\n modulesAllowed: z.string().array().optional()\n})\n\nexport type ActivityProgress = z.infer<typeof ActivityProgressSchema>\nexport type ModuleProgress = z.infer<typeof ModuleProgressSchema>\nexport type ModuleProgressWithActivities = z.infer<typeof ModuleProgressWithActivitiesSchema>\nexport type Purchase = z.infer<typeof PurchaseSchema>\n\n\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/purchase.js","../../src/model/purchase.ts","../../src/model.ts","../../src/model/shared.ts"],"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","purchase_exports","ActivityProgressSchema","ModuleProgressSchema","ModuleProgressWithActivitiesSchema","PurchaseSchema","module","exports","import_zod","require","import_firestore","TimestampOrNow","z","preprocess","arg","Timestamp","now","custom","nullish","optional","import_cuid","generateFirestoreId","cuid","IdModelSchema","import_zod2","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","completionPercentage","import_zod3","startsWith","lastChange","completionCounter","activities","nextActivityId","nextModuleId","modulesAllowed"],"mappings":"AAAA;AACA,IAAIA,WAAWC,OAAOC,MAAM;AAC5B,IAAIC,YAAYF,OAAOG,cAAc;AACrC,IAAIC,mBAAmBJ,OAAOK,wBAAwB;AACtD,IAAIC,oBAAoBN,OAAOO,mBAAmB;AAClD,IAAIC,eAAeR,OAAOS,cAAc;AACxC,IAAIC,eAAeV,OAAOW,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,I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;AAC1B;AF4CA,wBAAwB;AC9ExB,IAAAX,cAAgBC,QAAA;AAGT,IAAMP,yBAAyB4B,YAAYQ,MAAA,CAAO;IACvDS,sBAAsBC,YAAApC,CAAA,CAAEwB,MAAA,CAAOT,MAAA;IAC/BsB,YAAYD,YAAApC,CAAA,CAAEwB,MAAA,CAAOT,MAAA,GAASR,QAAA;IAC9B+B,YAAYF,YAAApC,CAAA,CAAEK,MAAA;AAChB;AAEO,IAAMd,uBAAuB2B,YAAYQ,MAAA,CAAO;IACrDa,mBAAmBH,YAAApC,CAAA,CAAEwB,MAAA,CAAOT,MAAA;AAC9B;AAEO,IAAMvB,qCAAqCD,qBAAqBmC,MAAA,CAAO;IAC5Ec,YAAYlD,uBAAuBuC,KAAA;AACrC;AAEO,IAAMpC,iBAAiByB,YAAYQ,MAAA,CAAO;IAC/Ce,gBAAgBL,YAAApC,CAAA,CAAEc,MAAA,GAASP,QAAA;IAC3BmC,cAAcN,YAAApC,CAAA,CAAEc,MAAA,GAASP,QAAA;IACzBoC,gBAAgBP,YAAApC,CAAA,CAAEc,MAAA,GAASe,KAAA,GAAQtB,QAAA;AACrC;AD2EA,6DAA6D;AAC7D,KAAMb,CAAAA,OAAOC,OAAO,GAAG;IACrBL,wBAAAA;IACAC,sBAAAA;IACAC,oCAAAA;IACAC,gBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/model/purchase.ts\nvar purchase_exports = {};\n__export(purchase_exports, {\n ActivityProgressSchema: () => ActivityProgressSchema,\n ModuleProgressSchema: () => ModuleProgressSchema,\n ModuleProgressWithActivitiesSchema: () => ModuleProgressWithActivitiesSchema,\n PurchaseSchema: () => PurchaseSchema\n});\nmodule.exports = __toCommonJS(purchase_exports);\n\n// src/model.ts\nvar import_zod2 = require(\"zod\");\n\n// src/model/shared.ts\nvar import_firestore = require(\"@google-cloud/firestore\");\nvar import_zod = require(\"zod\");\nvar TimestampOrNow = import_zod.z.preprocess(\n (arg) => arg === void 0 ? import_firestore.Timestamp.now() : arg,\n import_zod.z.custom()\n).nullish().optional();\n\n// src/model.ts\nvar import_cuid = __toESM(require(\"cuid\"));\nvar generateFirestoreId = () => {\n return (0, import_cuid.default)();\n};\nvar IdModelSchema = import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]);\nvar IdModelProcess = import_zod2.z.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = import_zod2.z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: import_zod2.z.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: import_zod2.z.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = import_zod2.z.object({\n enabled: import_zod2.z.boolean().optional()\n});\nvar DocumentHistorySchema = import_zod2.z.object({\n createdAt: TimestampOrNow,\n description: import_zod2.z.string().optional()\n});\n\n// src/model/purchase.ts\nvar import_zod3 = require(\"zod\");\nvar ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: import_zod3.z.coerce.number(),\n startsWith: import_zod3.z.coerce.number().optional(),\n lastChange: import_zod3.z.custom()\n});\nvar ModuleProgressSchema = ModelSchema.extend({\n completionCounter: import_zod3.z.coerce.number()\n});\nvar ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n});\nvar PurchaseSchema = ModelSchema.extend({\n nextActivityId: import_zod3.z.string().optional(),\n nextModuleId: import_zod3.z.string().optional(),\n modulesAllowed: import_zod3.z.string().array().optional()\n});\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n ActivityProgressSchema,\n ModuleProgressSchema,\n ModuleProgressWithActivitiesSchema,\n PurchaseSchema\n});\n","import {ModelSchema} from \"../model\";\nimport {z} from \"zod\";\nimport {Timestamp} from \"@google-cloud/firestore\";\n\nexport const ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: z.coerce.number(),\n startsWith: z.coerce.number().optional(),\n lastChange: z.custom<Timestamp>()\n})\n\nexport const ModuleProgressSchema = ModelSchema.extend({\n completionCounter: z.coerce.number()\n})\n\nexport const ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n})\n\nexport const PurchaseSchema = ModelSchema.extend({\n nextActivityId: z.string().optional(),\n nextModuleId: z.string().optional(),\n modulesAllowed: z.string().array().optional()\n})\n\nexport type ActivityProgress = z.infer<typeof ActivityProgressSchema>\nexport type ModuleProgress = z.infer<typeof ModuleProgressSchema>\nexport type ModuleProgressWithActivities = z.infer<typeof ModuleProgressWithActivitiesSchema>\nexport type Purchase = z.infer<typeof PurchaseSchema>\n\n\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n"]}
|
package/dist/model/purchase.mjs
CHANGED
|
@@ -43,6 +43,7 @@ var DocumentHistorySchema = z2.object({
|
|
|
43
43
|
import { z as z3 } from "zod";
|
|
44
44
|
var ActivityProgressSchema = ModelSchema.extend({
|
|
45
45
|
completionPercentage: z3.coerce.number(),
|
|
46
|
+
startsWith: z3.coerce.number().optional(),
|
|
46
47
|
lastChange: z3.custom()
|
|
47
48
|
});
|
|
48
49
|
var ModuleProgressSchema = ModelSchema.extend({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/purchase.mjs","../../src/model.ts","../../src/model/shared.ts","../../src/model/purchase.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","ActivityProgressSchema","completionPercentage","lastChange","ModuleProgressSchema","completionCounter","ModuleProgressWithActivitiesSchema","activities","PurchaseSchema","nextActivityId","nextModuleId","modulesAllowed"],"mappings":"AAAA,eAAe;ACAf,SAAQA,KAAAA,EAAAA,QAAQ,MAAA;ADGhB,sBAAsB;AEHtB,SAASC,SAAA,QAAiB,0BAAA;AAC1B,SAAQD,CAAA,QAAQ,MAAA;AAET,IAAME,iBAAiBF,EAC3BG,UAAA,CACC,SAACC;WAASA,QAAQ,KAAA,IAAYH,UAAUI,GAAA,KAAQD;GAChDJ,EAAEM,MAAA,IAEHC,OAAA,GAAUC,QAAA;AFGb,eAAe;ACTf,OAAOC,UAAU,OAAA;AAEV,IAAMC,sBAAsB;IACjC,OAAOD;AACT;AAEO,IAAME,gBAAgBX,GAAEY,KAAA,CAAM;IAACZ,GAAEa,MAAA;IAAUb,GAAEc,MAAA;CAAS;AAEtD,IAAMC,iBAAiBf,GAAEG,UAAA,CAAW,SAACa;IAC1C,IAAIA,QAAQ,KAAA,KAAaA,QAAQ,MAAM;QACrC,OAAON;IACT;IACA,OAAOM;AACT,GAAGL;AAEI,IAAMM,cAAcjB,GAAEkB,MAAA,CAAO;IAClCC,IAAIJ;IACJK,WAAWlB;IACXmB,WAAWnB;IACXoB,OAAOtB,GAAEuB,MAAA,CAAOT,MAAA,GAASP,OAAA,GAAUC,QAAA;AACrC;AAEO,IAAMgB,iBAAiBP,YAAYQ,MAAA,CAAO;IAC/CC,UAAU1B,GAAE2B,IAAA,CAAK;eAAMV,YAAYW,KAAA,GAAQpB,QAAA;;AAC7C;AAEO,IAAMqB,gBAAgB7B,GAAEkB,MAAA,CAAO;IACpCY,SAAS9B,GAAE+B,OAAA,GAAUvB,QAAA;AACvB;AAEO,IAAMwB,wBAAwBhC,GAAEkB,MAAA,CAAO;IAC5CE,WAAWlB;IACX+B,aAAajC,GAAEa,MAAA,GAASL,QAAA;AAC1B;ADKA,wBAAwB;AGvCxB,SAAQR,KAAAA,EAAAA,QAAQ,MAAA;AAGT,IAAMkC,yBAAyBjB,YAAYQ,MAAA,CAAO;IACvDU,sBAAsBnC,GAAEuB,MAAA,CAAOT,MAAA;IAC/BsB,YAAYpC,GAAEM,MAAA;AAChB;AAEO,
|
|
1
|
+
{"version":3,"sources":["/Users/henriquewilson/Developer/Projects/gabirubi-domain/dist/model/purchase.mjs","../../src/model.ts","../../src/model/shared.ts","../../src/model/purchase.ts"],"names":["z","Timestamp","TimestampOrNow","preprocess","arg","now","custom","nullish","optional","cuid","generateFirestoreId","IdModelSchema","union","string","number","IdModelProcess","val","ModelSchema","object","id","createdAt","updatedAt","order","coerce","PreviousSchema","extend","previous","lazy","array","EnabledSchema","enabled","boolean","DocumentHistorySchema","description","ActivityProgressSchema","completionPercentage","startsWith","lastChange","ModuleProgressSchema","completionCounter","ModuleProgressWithActivitiesSchema","activities","PurchaseSchema","nextActivityId","nextModuleId","modulesAllowed"],"mappings":"AAAA,eAAe;ACAf,SAAQA,KAAAA,EAAAA,QAAQ,MAAA;ADGhB,sBAAsB;AEHtB,SAASC,SAAA,QAAiB,0BAAA;AAC1B,SAAQD,CAAA,QAAQ,MAAA;AAET,IAAME,iBAAiBF,EAC3BG,UAAA,CACC,SAACC;WAASA,QAAQ,KAAA,IAAYH,UAAUI,GAAA,KAAQD;GAChDJ,EAAEM,MAAA,IAEHC,OAAA,GAAUC,QAAA;AFGb,eAAe;ACTf,OAAOC,UAAU,OAAA;AAEV,IAAMC,sBAAsB;IACjC,OAAOD;AACT;AAEO,IAAME,gBAAgBX,GAAEY,KAAA,CAAM;IAACZ,GAAEa,MAAA;IAAUb,GAAEc,MAAA;CAAS;AAEtD,IAAMC,iBAAiBf,GAAEG,UAAA,CAA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BAAsB,EACtBI,oBAAoB,EACpBE,kCAAkC,EAClCE,cAAc,GACd","sourcesContent":["// src/model.ts\nimport { z as z2 } from \"zod\";\n\n// src/model/shared.ts\nimport { Timestamp } from \"@google-cloud/firestore\";\nimport { z } from \"zod\";\nvar TimestampOrNow = z.preprocess(\n (arg) => arg === void 0 ? Timestamp.now() : arg,\n z.custom()\n).nullish().optional();\n\n// src/model.ts\nimport cuid from \"cuid\";\nvar generateFirestoreId = () => {\n return cuid();\n};\nvar IdModelSchema = z2.union([z2.string(), z2.number()]);\nvar IdModelProcess = z2.preprocess((val) => {\n if (val === void 0 || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\nvar ModelSchema = z2.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z2.coerce.number().nullish().optional()\n});\nvar PreviousSchema = ModelSchema.extend({\n previous: z2.lazy(() => ModelSchema.array().optional())\n});\nvar EnabledSchema = z2.object({\n enabled: z2.boolean().optional()\n});\nvar DocumentHistorySchema = z2.object({\n createdAt: TimestampOrNow,\n description: z2.string().optional()\n});\n\n// src/model/purchase.ts\nimport { z as z3 } from \"zod\";\nvar ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: z3.coerce.number(),\n startsWith: z3.coerce.number().optional(),\n lastChange: z3.custom()\n});\nvar ModuleProgressSchema = ModelSchema.extend({\n completionCounter: z3.coerce.number()\n});\nvar ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n});\nvar PurchaseSchema = ModelSchema.extend({\n nextActivityId: z3.string().optional(),\n nextModuleId: z3.string().optional(),\n modulesAllowed: z3.string().array().optional()\n});\nexport {\n ActivityProgressSchema,\n ModuleProgressSchema,\n ModuleProgressWithActivitiesSchema,\n PurchaseSchema\n};\n","import {z} from \"zod\";\nimport {TimestampOrNow} from \"./model/shared\";\nimport cuid from 'cuid';\n\nexport const generateFirestoreId = () => {\n return cuid();\n}\n\nexport const IdModelSchema = z.union([z.string(), z.number()])\n\nexport const IdModelProcess = z.preprocess((val) => {\n if (val === undefined || val === null) {\n return generateFirestoreId();\n }\n return val;\n}, IdModelSchema);\n\nexport const ModelSchema = z.object({\n id: IdModelProcess,\n createdAt: TimestampOrNow,\n updatedAt: TimestampOrNow,\n order: z.coerce.number().nullish().optional()\n});\n\nexport const PreviousSchema = ModelSchema.extend({\n previous: z.lazy(() => ModelSchema.array().optional())\n})\n\nexport const EnabledSchema = z.object({\n enabled: z.boolean().optional()\n})\n\nexport const DocumentHistorySchema = z.object({\n createdAt: TimestampOrNow,\n description: z.string().optional(),\n})\n\nexport type IdModel = z.infer<typeof IdModelSchema>;\nexport type Model = z.infer<typeof ModelSchema>;\nexport type Previous = z.infer<typeof PreviousSchema>;\nexport type Enabled = z.infer<typeof EnabledSchema>;\nexport type PartialWithId<T extends Model> = Partial<T> & {\n id: NonNullable<T['id']>\n}\n\n\n","import { Timestamp } from '@google-cloud/firestore';\nimport {z} from \"zod\";\n\nexport const TimestampOrNow = z\n .preprocess(\n (arg) => (arg === undefined ? Timestamp.now() : arg),\n z.custom<Timestamp>(),\n )\n .nullish().optional();\n","import {ModelSchema} from \"../model\";\nimport {z} from \"zod\";\nimport {Timestamp} from \"@google-cloud/firestore\";\n\nexport const ActivityProgressSchema = ModelSchema.extend({\n completionPercentage: z.coerce.number(),\n startsWith: z.coerce.number().optional(),\n lastChange: z.custom<Timestamp>()\n})\n\nexport const ModuleProgressSchema = ModelSchema.extend({\n completionCounter: z.coerce.number()\n})\n\nexport const ModuleProgressWithActivitiesSchema = ModuleProgressSchema.extend({\n activities: ActivityProgressSchema.array()\n})\n\nexport const PurchaseSchema = ModelSchema.extend({\n nextActivityId: z.string().optional(),\n nextModuleId: z.string().optional(),\n modulesAllowed: z.string().array().optional()\n})\n\nexport type ActivityProgress = z.infer<typeof ActivityProgressSchema>\nexport type ModuleProgress = z.infer<typeof ModuleProgressSchema>\nexport type ModuleProgressWithActivities = z.infer<typeof ModuleProgressWithActivitiesSchema>\nexport type Purchase = z.infer<typeof PurchaseSchema>\n\n\n"]}
|