UNPKG

@solufy/evolution-sdk

Version:

Unofficial SDK for the Evolution Whatsapp API v2

108 lines (102 loc) 3.84 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/modules/groups/schemas/find-by-invite-code.ts var find_by_invite_code_exports = {}; __export(find_by_invite_code_exports, { FindGroupByInviteCodeResponseSchema: () => FindGroupByInviteCodeResponseSchema, ResponseSchema: () => FindGroupByInviteCodeResponseSchema }); module.exports = __toCommonJS(find_by_invite_code_exports); var import_zod2 = require("zod"); // src/modules/groups/schemas/common.ts var import_zod = require("zod"); // src/types/tags.ts var Jid = (jid) => jid; var GroupJid = (jid) => jid; // src/utils/phone-numer-from-jid.ts var import_libphonenumber_js = require("libphonenumber-js"); function phoneNumberFromJid(jid) { return (0, import_libphonenumber_js.parsePhoneNumber)(`+${jid.split("@")[0]}`).number; } // src/modules/groups/schemas/common.ts var GroupResponseSchema = import_zod.z.object({ id: import_zod.z.string(), subject: import_zod.z.string(), subjectOwner: import_zod.z.string(), subjectTime: import_zod.z.coerce.date(), pictureUrl: import_zod.z.string().url().nullish(), size: import_zod.z.number(), creation: import_zod.z.coerce.date(), owner: import_zod.z.string(), restrict: import_zod.z.boolean(), announce: import_zod.z.boolean() }); var ParticipantResponseSchema = import_zod.z.object({ id: import_zod.z.string(), admin: import_zod.z.enum(["admin", "superadmin"]).nullish() }); var GroupWithParticipantsResponseSchema = GroupResponseSchema.extend({ participants: import_zod.z.array(ParticipantResponseSchema) }); var GroupResponseSchemaTransform = (group) => ({ jid: GroupJid(group.id), name: group.subject, pictureUrl: group.pictureUrl || void 0, size: group.size, subject: { owner: Jid(group.subjectOwner), time: group.subjectTime }, owner: { jid: Jid(group.owner), phoneNumber: phoneNumberFromJid(group.owner) }, createdAt: group.creation, restrict: group.restrict, announce: group.announce }); var ParticipantResponseSchemaTransform = (participant) => ({ id: participant.id, role: participant.admin || "member" }); var GroupWithParticipantsResponseSchemaTransform = (group) => ({ ...GroupResponseSchemaTransform(group), participants: group.participants.map(ParticipantResponseSchemaTransform) }); // src/modules/groups/schemas/find-by-invite-code.ts var FindGroupByInviteCodeResponseSchema = GroupWithParticipantsResponseSchema.extend({ isCommunity: import_zod2.z.boolean(), isCommunityAnnounce: import_zod2.z.boolean(), joinApprovalMode: import_zod2.z.boolean(), memberAddMode: import_zod2.z.boolean() }).omit({ pictureUrl: true }).transform((group) => ({ ...GroupWithParticipantsResponseSchemaTransform({ ...group, pictureUrl: null }), isCommunity: group.isCommunity, isCommunityAnnounce: group.isCommunityAnnounce, joinApprovalMode: group.joinApprovalMode, memberAddMode: group.memberAddMode })); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { FindGroupByInviteCodeResponseSchema, ResponseSchema }); //# sourceMappingURL=find-by-invite-code.js.map