better-zap 0.2.0 → 0.2.1

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.
@@ -0,0 +1,97 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/client.ts
3
+ /**
4
+ * Session/proxy transport: send same-origin credentials (cookies), no API key.
5
+ * The recommended browser default when the app proxies Better Zap behind its
6
+ * own authenticated routes.
7
+ */
8
+ function sessionTransport() {
9
+ return { credentials: "include" };
10
+ }
11
+ /** API-key transport: send `Authorization: Bearer <apiKey>` on every request. */
12
+ function apiKeyTransport(apiKey) {
13
+ return { headers: () => ({ Authorization: `Bearer ${apiKey}` }) };
14
+ }
15
+ var BetterZapClientError = class extends Error {
16
+ status;
17
+ code;
18
+ details;
19
+ body;
20
+ constructor(message, options) {
21
+ super(message);
22
+ this.name = "BetterZapClientError";
23
+ this.status = options.status;
24
+ this.code = options.code;
25
+ this.details = options.details;
26
+ this.body = options.body;
27
+ }
28
+ };
29
+ function createZapClient(options) {
30
+ const baseURL = options?.baseURL ?? (typeof window !== "undefined" ? window.location.origin : "");
31
+ const basePath = options?.basePath ?? "/api/whatsapp";
32
+ const fetchFn = options?.fetch ?? fetch;
33
+ const transport = options?.transport;
34
+ async function request(path, init) {
35
+ const url = `${baseURL}${basePath}${path}`;
36
+ const transportHeaders = transport?.headers ? await transport.headers() : void 0;
37
+ const response = await fetchFn(url, transportHeaders || transport?.credentials ? {
38
+ ...init,
39
+ ...transport?.credentials ? { credentials: transport.credentials } : {},
40
+ headers: {
41
+ ...init?.headers,
42
+ ...transportHeaders
43
+ }
44
+ } : init ?? {});
45
+ const payload = await response.json().catch(() => null);
46
+ if (!response.ok) {
47
+ const error = payload;
48
+ throw new BetterZapClientError(error?.error || `Request failed: ${response.status}`, {
49
+ status: response.status,
50
+ code: error?.code,
51
+ details: error?.details,
52
+ body: payload
53
+ });
54
+ }
55
+ return payload;
56
+ }
57
+ function post(path, body) {
58
+ return request(path, {
59
+ method: "POST",
60
+ headers: { "Content-Type": "application/json" },
61
+ body: JSON.stringify(body)
62
+ });
63
+ }
64
+ /** Strip non-digits to get the canonical 13-digit phone for URL paths. */
65
+ function normalizePhone(phone) {
66
+ return phone.replace(/\D/g, "");
67
+ }
68
+ return {
69
+ send: {
70
+ text: (params) => post("/send/text", params),
71
+ template: ((params) => post("/send/template", params)),
72
+ templateRaw: (params) => post("/send/template", params),
73
+ interactive: (params) => post("/send/interactive", params),
74
+ location: (params) => post("/send/location", params)
75
+ },
76
+ conversations: {
77
+ list: () => request("/conversations"),
78
+ get: (phone) => request(`/conversations/${normalizePhone(phone)}`).catch((err) => {
79
+ if (err instanceof BetterZapClientError && err.status === 404) return null;
80
+ if (err.message?.includes("Conversation not found")) return null;
81
+ throw err;
82
+ }),
83
+ messages: (phone, opts) => {
84
+ const params = new URLSearchParams();
85
+ if (opts?.cursor) params.set("cursor", opts.cursor);
86
+ if (opts?.limit) params.set("limit", String(opts.limit));
87
+ const qs = params.toString();
88
+ return request(`/conversations/${normalizePhone(phone)}/messages${qs ? `?${qs}` : ""}`);
89
+ }
90
+ }
91
+ };
92
+ }
93
+ //#endregion
94
+ exports.BetterZapClientError = BetterZapClientError;
95
+ exports.apiKeyTransport = apiKeyTransport;
96
+ exports.createZapClient = createZapClient;
97
+ exports.sessionTransport = sessionTransport;
@@ -0,0 +1,2 @@
1
+ import { a as createZapClient, i as apiKeyTransport, n as ZapClient, o as sessionTransport, r as ZapTransport, t as BetterZapClientError } from "./client-DNlBPLBd.cjs";
2
+ export { BetterZapClientError, ZapClient, ZapTransport, apiKeyTransport, createZapClient, sessionTransport };
@@ -0,0 +1,2 @@
1
+ import { a as createZapClient, i as apiKeyTransport, n as ZapClient, o as sessionTransport, r as ZapTransport, t as BetterZapClientError } from "./client-DiHHMG8t.mjs";
2
+ export { BetterZapClientError, ZapClient, ZapTransport, apiKeyTransport, createZapClient, sessionTransport };
@@ -0,0 +1,93 @@
1
+ //#region src/client.ts
2
+ /**
3
+ * Session/proxy transport: send same-origin credentials (cookies), no API key.
4
+ * The recommended browser default when the app proxies Better Zap behind its
5
+ * own authenticated routes.
6
+ */
7
+ function sessionTransport() {
8
+ return { credentials: "include" };
9
+ }
10
+ /** API-key transport: send `Authorization: Bearer <apiKey>` on every request. */
11
+ function apiKeyTransport(apiKey) {
12
+ return { headers: () => ({ Authorization: `Bearer ${apiKey}` }) };
13
+ }
14
+ var BetterZapClientError = class extends Error {
15
+ status;
16
+ code;
17
+ details;
18
+ body;
19
+ constructor(message, options) {
20
+ super(message);
21
+ this.name = "BetterZapClientError";
22
+ this.status = options.status;
23
+ this.code = options.code;
24
+ this.details = options.details;
25
+ this.body = options.body;
26
+ }
27
+ };
28
+ function createZapClient(options) {
29
+ const baseURL = options?.baseURL ?? (typeof window !== "undefined" ? window.location.origin : "");
30
+ const basePath = options?.basePath ?? "/api/whatsapp";
31
+ const fetchFn = options?.fetch ?? fetch;
32
+ const transport = options?.transport;
33
+ async function request(path, init) {
34
+ const url = `${baseURL}${basePath}${path}`;
35
+ const transportHeaders = transport?.headers ? await transport.headers() : void 0;
36
+ const response = await fetchFn(url, transportHeaders || transport?.credentials ? {
37
+ ...init,
38
+ ...transport?.credentials ? { credentials: transport.credentials } : {},
39
+ headers: {
40
+ ...init?.headers,
41
+ ...transportHeaders
42
+ }
43
+ } : init ?? {});
44
+ const payload = await response.json().catch(() => null);
45
+ if (!response.ok) {
46
+ const error = payload;
47
+ throw new BetterZapClientError(error?.error || `Request failed: ${response.status}`, {
48
+ status: response.status,
49
+ code: error?.code,
50
+ details: error?.details,
51
+ body: payload
52
+ });
53
+ }
54
+ return payload;
55
+ }
56
+ function post(path, body) {
57
+ return request(path, {
58
+ method: "POST",
59
+ headers: { "Content-Type": "application/json" },
60
+ body: JSON.stringify(body)
61
+ });
62
+ }
63
+ /** Strip non-digits to get the canonical 13-digit phone for URL paths. */
64
+ function normalizePhone(phone) {
65
+ return phone.replace(/\D/g, "");
66
+ }
67
+ return {
68
+ send: {
69
+ text: (params) => post("/send/text", params),
70
+ template: ((params) => post("/send/template", params)),
71
+ templateRaw: (params) => post("/send/template", params),
72
+ interactive: (params) => post("/send/interactive", params),
73
+ location: (params) => post("/send/location", params)
74
+ },
75
+ conversations: {
76
+ list: () => request("/conversations"),
77
+ get: (phone) => request(`/conversations/${normalizePhone(phone)}`).catch((err) => {
78
+ if (err instanceof BetterZapClientError && err.status === 404) return null;
79
+ if (err.message?.includes("Conversation not found")) return null;
80
+ throw err;
81
+ }),
82
+ messages: (phone, opts) => {
83
+ const params = new URLSearchParams();
84
+ if (opts?.cursor) params.set("cursor", opts.cursor);
85
+ if (opts?.limit) params.set("limit", String(opts.limit));
86
+ const qs = params.toString();
87
+ return request(`/conversations/${normalizePhone(phone)}/messages${qs ? `?${qs}` : ""}`);
88
+ }
89
+ }
90
+ };
91
+ }
92
+ //#endregion
93
+ export { BetterZapClientError, apiKeyTransport, createZapClient, sessionTransport };
package/dist/index.cjs CHANGED
@@ -1064,6 +1064,7 @@ exports.InMemoryCoexistenceStore = InMemoryCoexistenceStore;
1064
1064
  exports.MessageLoggerService = MessageLoggerService;
1065
1065
  exports.WHATSAPP_MESSAGE_TYPES = WHATSAPP_MESSAGE_TYPES;
1066
1066
  exports.WhatsAppService = WhatsAppService;
1067
+ exports.apiKeyTransport = require_client.apiKeyTransport;
1067
1068
  exports.createCoexistenceEmbeddedSignupConfig = createCoexistenceEmbeddedSignupConfig;
1068
1069
  exports.createFreeformMessageWindow = createFreeformMessageWindow;
1069
1070
  exports.createLogger = createLogger;
@@ -1083,4 +1084,5 @@ exports.normalizeConversationRecords = normalizeConversationRecords;
1083
1084
  exports.resolveConversationFreeformMessageWindow = resolveConversationFreeformMessageWindow;
1084
1085
  exports.serializeError = serializeError;
1085
1086
  exports.serializeTemplateFromRegistry = serializeTemplateFromRegistry;
1087
+ exports.sessionTransport = require_client.sessionTransport;
1086
1088
  exports.toLegacyCoexistenceSessionEvent = toLegacyCoexistenceSessionEvent;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as UIMessage, A as createLogger, B as ConversationRecord, C as WhatsAppLogRecord, D as LogLevel, E as WhatsAppStatus, F as NewMessageEvent, G as MessageError, H as IncomingMessage, I as StatusUpdateEvent, J as SendMessageError, K as MessageStatus, L as SyncEvent, M as serializeError, N as ConversationSummary, O as Logger, P as ConversationUpdateEvent, Q as TemplateParameter, R as WhatsAppConfig, S as WhatsAppDirection, T as WhatsAppMessageType, U as InteractiveMediaCarouselCardInput, V as FreeformMessageWindow, W as MediaMessage, X as SendResult, Y as SendMessageResponse, Z as TemplateComponent, _ as OutgoingLoggingMetadata, a as SupportedTemplateParameterType, at as WebhookPayload, b as MessageLoggerService, c as TemplateName, ct as WhatsAppInteractiveButtonsMessage, d as TemplateParams, dt as WhatsAppLocationMessage, et as UIMessageStatus, f as TemplateRegistry, ft as WhatsAppTemplateMessage, g as serializeTemplateFromRegistry, h as hasConfiguredTemplates, i as EMPTY_TEMPLATE_REGISTRY, it as WebhookError, j as noopLogger, k as LoggerConfig, l as TemplateParameterDefinition, lt as WhatsAppInteractiveListMessage, m as getTemplateNames, mt as WhatsAppWebhookField, n as ZapClient, nt as WebhookContact, o as TemplateComponentDefinition, ot as WebhookValue, p as defineTemplates, pt as WhatsAppTextMessage, q as SendInteractiveMediaCarouselData, r as createZapClient, rt as WebhookEntry, s as TemplateDefinition, st as WhatsAppCarouselCard, t as BetterZapClientError, tt as WebhookChange, u as TemplateParameterInputMap, ut as WhatsAppInteractiveMediaCarouselMessage, v as WhatsAppService, w as WhatsAppLogStore, x as WHATSAPP_MESSAGE_TYPES, y as MessageLoggerNotifier, z as Conversation } from "./client-By0mftjF.cjs";
1
+ import { $ as SendResult, A as LogLevel, B as SyncEvent, C as MessageLoggerService, D as WhatsAppLogStore, E as WhatsAppLogRecord, F as serializeError, G as IncomingMessage, H as Conversation, I as ConversationSummary, J as MessageError, K as InteractiveMediaCarouselCardInput, L as ConversationUpdateEvent, M as LoggerConfig, N as createLogger, O as WhatsAppMessageType, P as noopLogger, Q as SendMessageResponse, R as NewMessageEvent, S as MessageLoggerNotifier, T as WhatsAppDirection, U as ConversationRecord, V as WhatsAppConfig, W as FreeformMessageWindow, X as SendInteractiveMediaCarouselData, Y as MessageStatus, Z as SendMessageError, _ as getTemplateNames, _t as WhatsAppWebhookField, a as createZapClient, at as WebhookContact, b as OutgoingLoggingMetadata, c as SupportedTemplateParameterType, ct as WebhookPayload, d as TemplateName, dt as WhatsAppInteractiveButtonsMessage, et as TemplateComponent, f as TemplateParameterDefinition, ft as WhatsAppInteractiveListMessage, g as defineTemplates, gt as WhatsAppTextMessage, h as TemplateRegistry, ht as WhatsAppTemplateMessage, i as apiKeyTransport, it as WebhookChange, j as Logger, k as WhatsAppStatus, l as TemplateComponentDefinition, lt as WebhookValue, m as TemplateParams, mt as WhatsAppLocationMessage, n as ZapClient, nt as UIMessage, o as sessionTransport, ot as WebhookEntry, p as TemplateParameterInputMap, pt as WhatsAppInteractiveMediaCarouselMessage, q as MediaMessage, r as ZapTransport, rt as UIMessageStatus, s as EMPTY_TEMPLATE_REGISTRY, st as WebhookError, t as BetterZapClientError, tt as TemplateParameter, u as TemplateDefinition, ut as WhatsAppCarouselCard, v as hasConfiguredTemplates, w as WHATSAPP_MESSAGE_TYPES, x as WhatsAppService, y as serializeTemplateFromRegistry, z as StatusUpdateEvent } from "./client-DNlBPLBd.cjs";
2
2
 
3
3
  //#region src/events.d.ts
4
4
  type MessageContext = {
@@ -622,4 +622,4 @@ declare function formatPhone(phone: string): string;
622
622
  */
623
623
  declare function delay(ms: number): Promise<void>;
624
624
  //#endregion
625
- export { type Awaitable, type BetterZapApi, BetterZapClientError, type BetterZapContext, type BetterZapCoreConfig, type BetterZapCoreContext, type BetterZapCoreServices, type BetterZapDatabase, type BetterZapPlugin, type BetterZapPluginInitContext, type BetterZapPluginInitResult, type BetterZapServices, type CoexistenceAccountOffboardedValue, type CoexistenceAccountOffboardedWebhook, type CoexistenceAccountReconnectedValue, type CoexistenceAccountReconnectedWebhook, type CoexistenceAccountUpdateValue, type CoexistenceAccountUpdateWebhook, type CoexistenceBillingStatus, type CoexistenceConnectedAccountIdentifiers, type CoexistenceConnectedAccountRecord, type CoexistenceContactRecord, type CoexistenceCredentialProvider, type CoexistenceEligibilityStatus, type CoexistenceEmbeddedSignupCallbacks, type CoexistenceEmbeddedSignupConfig, type CoexistenceEmbeddedSignupConfigInput, type CoexistenceEmbeddedSignupController, type CoexistenceEmbeddedSignupMessageEvent, type CoexistenceEmbeddedSignupResult, type CoexistenceEmbeddedSignupSetup, type CoexistenceEmbeddedSignupWindow, type CoexistenceErrorValue, type CoexistenceErrorWebhook, type CoexistenceFacebookInitOptions, type CoexistenceFacebookLoginResponse, type CoexistenceFacebookSdk, type CoexistenceFeatureType, type CoexistenceGenericSessionEvent, type CoexistenceGraphResult, type CoexistenceHistoryValue, type CoexistenceHistoryWebhook, type CoexistenceLegacySessionEvent, type CoexistenceLifecycleEventRecord, type CoexistenceMessageEditValue, type CoexistenceMessageEditWebhook, type CoexistenceMessageRevokeValue, type CoexistenceMessageRevokeWebhook, type CoexistenceOnboardingSessionRecord, type CoexistencePhoneStatusResponse, type CoexistencePreflightFailureCode, type CoexistencePreflightStateRecord, type CoexistenceRawEventStatusRecord, CoexistenceService, type CoexistenceServiceConfig, type CoexistenceSessionEventPayload, type CoexistenceSessionInfoVersion, type CoexistenceSmbAppStateSyncValue, type CoexistenceSmbAppStateSyncWebhook, type CoexistenceSmbMessageEchoesValue, type CoexistenceSmbMessageEchoesWebhook, type CoexistenceStore, type CoexistenceSyncJobRecord, type CoexistenceSyncJobStatus, type CoexistenceSyncRequest, type CoexistenceSyncResponse, type CoexistenceSyncType, type CoexistenceTokenExchangeResult, type CoexistenceUnsupportedValue, type CoexistenceUnsupportedWebhook, type CoexistenceWebhookBase, type CoexistenceWebhookPayload, type CoexistenceWebhookValueBase, type Conversation, type ConversationRecord, type ConversationSummary, type ConversationUpdateEvent, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, type FreeformMessageWindow, InMemoryCoexistenceStore, type IncomingMessage, type InferBetterZapPluginContext, type InferBetterZapPluginServices, type InteractiveMediaCarouselCardInput, type LaunchCoexistenceEmbeddedSignupInput, type LogLevel, type Logger, type LoggerConfig, type MediaMessage, type MessageContext, type MessageError, type MessageLoggerNotifier, MessageLoggerService, type MessageStatus, type MetaAccessTokenProvider, type MetaGraphApiErrorBody, type NewMessageEvent, type NormalizedCoexistenceSessionEvent, type OutgoingLoggingMetadata, type SendInteractiveMediaCarouselData, type SendMessageError, type SendMessageResponse, type SendResult, type StatusContext, type StatusUpdateEvent, type SupportedTemplateParameterType, type SyncEvent, type TemplateComponent, type TemplateComponentDefinition, type TemplateDefinition, type TemplateName, type TemplateParameter, type TemplateParameterDefinition, type TemplateParameterInputMap, type TemplateParams, type TemplateRegistry, type UIMessage, type UIMessageStatus, WHATSAPP_MESSAGE_TYPES, type WebhookChange, type WebhookContact, type WebhookEntry, type WebhookError, type WebhookPayload, type WebhookValue, type WhatsAppCarouselCard, type WhatsAppConfig, type WhatsAppDirection, type WhatsAppInteractiveButtonsMessage, type WhatsAppInteractiveListMessage, type WhatsAppInteractiveMediaCarouselMessage, type WhatsAppLocationMessage, type WhatsAppLogRecord, type WhatsAppLogStore, type WhatsAppMessageType, WhatsAppService, type WhatsAppStatus, type WhatsAppTemplateMessage, type WhatsAppTextMessage, type WhatsAppWebhookField, type ZapClient, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, toLegacyCoexistenceSessionEvent };
625
+ export { type Awaitable, type BetterZapApi, BetterZapClientError, type BetterZapContext, type BetterZapCoreConfig, type BetterZapCoreContext, type BetterZapCoreServices, type BetterZapDatabase, type BetterZapPlugin, type BetterZapPluginInitContext, type BetterZapPluginInitResult, type BetterZapServices, type CoexistenceAccountOffboardedValue, type CoexistenceAccountOffboardedWebhook, type CoexistenceAccountReconnectedValue, type CoexistenceAccountReconnectedWebhook, type CoexistenceAccountUpdateValue, type CoexistenceAccountUpdateWebhook, type CoexistenceBillingStatus, type CoexistenceConnectedAccountIdentifiers, type CoexistenceConnectedAccountRecord, type CoexistenceContactRecord, type CoexistenceCredentialProvider, type CoexistenceEligibilityStatus, type CoexistenceEmbeddedSignupCallbacks, type CoexistenceEmbeddedSignupConfig, type CoexistenceEmbeddedSignupConfigInput, type CoexistenceEmbeddedSignupController, type CoexistenceEmbeddedSignupMessageEvent, type CoexistenceEmbeddedSignupResult, type CoexistenceEmbeddedSignupSetup, type CoexistenceEmbeddedSignupWindow, type CoexistenceErrorValue, type CoexistenceErrorWebhook, type CoexistenceFacebookInitOptions, type CoexistenceFacebookLoginResponse, type CoexistenceFacebookSdk, type CoexistenceFeatureType, type CoexistenceGenericSessionEvent, type CoexistenceGraphResult, type CoexistenceHistoryValue, type CoexistenceHistoryWebhook, type CoexistenceLegacySessionEvent, type CoexistenceLifecycleEventRecord, type CoexistenceMessageEditValue, type CoexistenceMessageEditWebhook, type CoexistenceMessageRevokeValue, type CoexistenceMessageRevokeWebhook, type CoexistenceOnboardingSessionRecord, type CoexistencePhoneStatusResponse, type CoexistencePreflightFailureCode, type CoexistencePreflightStateRecord, type CoexistenceRawEventStatusRecord, CoexistenceService, type CoexistenceServiceConfig, type CoexistenceSessionEventPayload, type CoexistenceSessionInfoVersion, type CoexistenceSmbAppStateSyncValue, type CoexistenceSmbAppStateSyncWebhook, type CoexistenceSmbMessageEchoesValue, type CoexistenceSmbMessageEchoesWebhook, type CoexistenceStore, type CoexistenceSyncJobRecord, type CoexistenceSyncJobStatus, type CoexistenceSyncRequest, type CoexistenceSyncResponse, type CoexistenceSyncType, type CoexistenceTokenExchangeResult, type CoexistenceUnsupportedValue, type CoexistenceUnsupportedWebhook, type CoexistenceWebhookBase, type CoexistenceWebhookPayload, type CoexistenceWebhookValueBase, type Conversation, type ConversationRecord, type ConversationSummary, type ConversationUpdateEvent, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, type FreeformMessageWindow, InMemoryCoexistenceStore, type IncomingMessage, type InferBetterZapPluginContext, type InferBetterZapPluginServices, type InteractiveMediaCarouselCardInput, type LaunchCoexistenceEmbeddedSignupInput, type LogLevel, type Logger, type LoggerConfig, type MediaMessage, type MessageContext, type MessageError, type MessageLoggerNotifier, MessageLoggerService, type MessageStatus, type MetaAccessTokenProvider, type MetaGraphApiErrorBody, type NewMessageEvent, type NormalizedCoexistenceSessionEvent, type OutgoingLoggingMetadata, type SendInteractiveMediaCarouselData, type SendMessageError, type SendMessageResponse, type SendResult, type StatusContext, type StatusUpdateEvent, type SupportedTemplateParameterType, type SyncEvent, type TemplateComponent, type TemplateComponentDefinition, type TemplateDefinition, type TemplateName, type TemplateParameter, type TemplateParameterDefinition, type TemplateParameterInputMap, type TemplateParams, type TemplateRegistry, type UIMessage, type UIMessageStatus, WHATSAPP_MESSAGE_TYPES, type WebhookChange, type WebhookContact, type WebhookEntry, type WebhookError, type WebhookPayload, type WebhookValue, type WhatsAppCarouselCard, type WhatsAppConfig, type WhatsAppDirection, type WhatsAppInteractiveButtonsMessage, type WhatsAppInteractiveListMessage, type WhatsAppInteractiveMediaCarouselMessage, type WhatsAppLocationMessage, type WhatsAppLogRecord, type WhatsAppLogStore, type WhatsAppMessageType, WhatsAppService, type WhatsAppStatus, type WhatsAppTemplateMessage, type WhatsAppTextMessage, type WhatsAppWebhookField, type ZapClient, type ZapTransport, apiKeyTransport, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, sessionTransport, toLegacyCoexistenceSessionEvent };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as UIMessage, A as createLogger, B as ConversationRecord, C as WhatsAppLogRecord, D as LogLevel, E as WhatsAppStatus, F as NewMessageEvent, G as MessageError, H as IncomingMessage, I as StatusUpdateEvent, J as SendMessageError, K as MessageStatus, L as SyncEvent, M as serializeError, N as ConversationSummary, O as Logger, P as ConversationUpdateEvent, Q as TemplateParameter, R as WhatsAppConfig, S as WhatsAppDirection, T as WhatsAppMessageType, U as InteractiveMediaCarouselCardInput, V as FreeformMessageWindow, W as MediaMessage, X as SendResult, Y as SendMessageResponse, Z as TemplateComponent, _ as OutgoingLoggingMetadata, a as SupportedTemplateParameterType, at as WebhookPayload, b as MessageLoggerService, c as TemplateName, ct as WhatsAppInteractiveButtonsMessage, d as TemplateParams, dt as WhatsAppLocationMessage, et as UIMessageStatus, f as TemplateRegistry, ft as WhatsAppTemplateMessage, g as serializeTemplateFromRegistry, h as hasConfiguredTemplates, i as EMPTY_TEMPLATE_REGISTRY, it as WebhookError, j as noopLogger, k as LoggerConfig, l as TemplateParameterDefinition, lt as WhatsAppInteractiveListMessage, m as getTemplateNames, mt as WhatsAppWebhookField, n as ZapClient, nt as WebhookContact, o as TemplateComponentDefinition, ot as WebhookValue, p as defineTemplates, pt as WhatsAppTextMessage, q as SendInteractiveMediaCarouselData, r as createZapClient, rt as WebhookEntry, s as TemplateDefinition, st as WhatsAppCarouselCard, t as BetterZapClientError, tt as WebhookChange, u as TemplateParameterInputMap, ut as WhatsAppInteractiveMediaCarouselMessage, v as WhatsAppService, w as WhatsAppLogStore, x as WHATSAPP_MESSAGE_TYPES, y as MessageLoggerNotifier, z as Conversation } from "./client-Cr53TTvf.mjs";
1
+ import { $ as SendResult, A as LogLevel, B as SyncEvent, C as MessageLoggerService, D as WhatsAppLogStore, E as WhatsAppLogRecord, F as serializeError, G as IncomingMessage, H as Conversation, I as ConversationSummary, J as MessageError, K as InteractiveMediaCarouselCardInput, L as ConversationUpdateEvent, M as LoggerConfig, N as createLogger, O as WhatsAppMessageType, P as noopLogger, Q as SendMessageResponse, R as NewMessageEvent, S as MessageLoggerNotifier, T as WhatsAppDirection, U as ConversationRecord, V as WhatsAppConfig, W as FreeformMessageWindow, X as SendInteractiveMediaCarouselData, Y as MessageStatus, Z as SendMessageError, _ as getTemplateNames, _t as WhatsAppWebhookField, a as createZapClient, at as WebhookContact, b as OutgoingLoggingMetadata, c as SupportedTemplateParameterType, ct as WebhookPayload, d as TemplateName, dt as WhatsAppInteractiveButtonsMessage, et as TemplateComponent, f as TemplateParameterDefinition, ft as WhatsAppInteractiveListMessage, g as defineTemplates, gt as WhatsAppTextMessage, h as TemplateRegistry, ht as WhatsAppTemplateMessage, i as apiKeyTransport, it as WebhookChange, j as Logger, k as WhatsAppStatus, l as TemplateComponentDefinition, lt as WebhookValue, m as TemplateParams, mt as WhatsAppLocationMessage, n as ZapClient, nt as UIMessage, o as sessionTransport, ot as WebhookEntry, p as TemplateParameterInputMap, pt as WhatsAppInteractiveMediaCarouselMessage, q as MediaMessage, r as ZapTransport, rt as UIMessageStatus, s as EMPTY_TEMPLATE_REGISTRY, st as WebhookError, t as BetterZapClientError, tt as TemplateParameter, u as TemplateDefinition, ut as WhatsAppCarouselCard, v as hasConfiguredTemplates, w as WHATSAPP_MESSAGE_TYPES, x as WhatsAppService, y as serializeTemplateFromRegistry, z as StatusUpdateEvent } from "./client-DiHHMG8t.mjs";
2
2
 
3
3
  //#region src/events.d.ts
4
4
  type MessageContext = {
@@ -622,4 +622,4 @@ declare function formatPhone(phone: string): string;
622
622
  */
623
623
  declare function delay(ms: number): Promise<void>;
624
624
  //#endregion
625
- export { type Awaitable, type BetterZapApi, BetterZapClientError, type BetterZapContext, type BetterZapCoreConfig, type BetterZapCoreContext, type BetterZapCoreServices, type BetterZapDatabase, type BetterZapPlugin, type BetterZapPluginInitContext, type BetterZapPluginInitResult, type BetterZapServices, type CoexistenceAccountOffboardedValue, type CoexistenceAccountOffboardedWebhook, type CoexistenceAccountReconnectedValue, type CoexistenceAccountReconnectedWebhook, type CoexistenceAccountUpdateValue, type CoexistenceAccountUpdateWebhook, type CoexistenceBillingStatus, type CoexistenceConnectedAccountIdentifiers, type CoexistenceConnectedAccountRecord, type CoexistenceContactRecord, type CoexistenceCredentialProvider, type CoexistenceEligibilityStatus, type CoexistenceEmbeddedSignupCallbacks, type CoexistenceEmbeddedSignupConfig, type CoexistenceEmbeddedSignupConfigInput, type CoexistenceEmbeddedSignupController, type CoexistenceEmbeddedSignupMessageEvent, type CoexistenceEmbeddedSignupResult, type CoexistenceEmbeddedSignupSetup, type CoexistenceEmbeddedSignupWindow, type CoexistenceErrorValue, type CoexistenceErrorWebhook, type CoexistenceFacebookInitOptions, type CoexistenceFacebookLoginResponse, type CoexistenceFacebookSdk, type CoexistenceFeatureType, type CoexistenceGenericSessionEvent, type CoexistenceGraphResult, type CoexistenceHistoryValue, type CoexistenceHistoryWebhook, type CoexistenceLegacySessionEvent, type CoexistenceLifecycleEventRecord, type CoexistenceMessageEditValue, type CoexistenceMessageEditWebhook, type CoexistenceMessageRevokeValue, type CoexistenceMessageRevokeWebhook, type CoexistenceOnboardingSessionRecord, type CoexistencePhoneStatusResponse, type CoexistencePreflightFailureCode, type CoexistencePreflightStateRecord, type CoexistenceRawEventStatusRecord, CoexistenceService, type CoexistenceServiceConfig, type CoexistenceSessionEventPayload, type CoexistenceSessionInfoVersion, type CoexistenceSmbAppStateSyncValue, type CoexistenceSmbAppStateSyncWebhook, type CoexistenceSmbMessageEchoesValue, type CoexistenceSmbMessageEchoesWebhook, type CoexistenceStore, type CoexistenceSyncJobRecord, type CoexistenceSyncJobStatus, type CoexistenceSyncRequest, type CoexistenceSyncResponse, type CoexistenceSyncType, type CoexistenceTokenExchangeResult, type CoexistenceUnsupportedValue, type CoexistenceUnsupportedWebhook, type CoexistenceWebhookBase, type CoexistenceWebhookPayload, type CoexistenceWebhookValueBase, type Conversation, type ConversationRecord, type ConversationSummary, type ConversationUpdateEvent, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, type FreeformMessageWindow, InMemoryCoexistenceStore, type IncomingMessage, type InferBetterZapPluginContext, type InferBetterZapPluginServices, type InteractiveMediaCarouselCardInput, type LaunchCoexistenceEmbeddedSignupInput, type LogLevel, type Logger, type LoggerConfig, type MediaMessage, type MessageContext, type MessageError, type MessageLoggerNotifier, MessageLoggerService, type MessageStatus, type MetaAccessTokenProvider, type MetaGraphApiErrorBody, type NewMessageEvent, type NormalizedCoexistenceSessionEvent, type OutgoingLoggingMetadata, type SendInteractiveMediaCarouselData, type SendMessageError, type SendMessageResponse, type SendResult, type StatusContext, type StatusUpdateEvent, type SupportedTemplateParameterType, type SyncEvent, type TemplateComponent, type TemplateComponentDefinition, type TemplateDefinition, type TemplateName, type TemplateParameter, type TemplateParameterDefinition, type TemplateParameterInputMap, type TemplateParams, type TemplateRegistry, type UIMessage, type UIMessageStatus, WHATSAPP_MESSAGE_TYPES, type WebhookChange, type WebhookContact, type WebhookEntry, type WebhookError, type WebhookPayload, type WebhookValue, type WhatsAppCarouselCard, type WhatsAppConfig, type WhatsAppDirection, type WhatsAppInteractiveButtonsMessage, type WhatsAppInteractiveListMessage, type WhatsAppInteractiveMediaCarouselMessage, type WhatsAppLocationMessage, type WhatsAppLogRecord, type WhatsAppLogStore, type WhatsAppMessageType, WhatsAppService, type WhatsAppStatus, type WhatsAppTemplateMessage, type WhatsAppTextMessage, type WhatsAppWebhookField, type ZapClient, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, toLegacyCoexistenceSessionEvent };
625
+ export { type Awaitable, type BetterZapApi, BetterZapClientError, type BetterZapContext, type BetterZapCoreConfig, type BetterZapCoreContext, type BetterZapCoreServices, type BetterZapDatabase, type BetterZapPlugin, type BetterZapPluginInitContext, type BetterZapPluginInitResult, type BetterZapServices, type CoexistenceAccountOffboardedValue, type CoexistenceAccountOffboardedWebhook, type CoexistenceAccountReconnectedValue, type CoexistenceAccountReconnectedWebhook, type CoexistenceAccountUpdateValue, type CoexistenceAccountUpdateWebhook, type CoexistenceBillingStatus, type CoexistenceConnectedAccountIdentifiers, type CoexistenceConnectedAccountRecord, type CoexistenceContactRecord, type CoexistenceCredentialProvider, type CoexistenceEligibilityStatus, type CoexistenceEmbeddedSignupCallbacks, type CoexistenceEmbeddedSignupConfig, type CoexistenceEmbeddedSignupConfigInput, type CoexistenceEmbeddedSignupController, type CoexistenceEmbeddedSignupMessageEvent, type CoexistenceEmbeddedSignupResult, type CoexistenceEmbeddedSignupSetup, type CoexistenceEmbeddedSignupWindow, type CoexistenceErrorValue, type CoexistenceErrorWebhook, type CoexistenceFacebookInitOptions, type CoexistenceFacebookLoginResponse, type CoexistenceFacebookSdk, type CoexistenceFeatureType, type CoexistenceGenericSessionEvent, type CoexistenceGraphResult, type CoexistenceHistoryValue, type CoexistenceHistoryWebhook, type CoexistenceLegacySessionEvent, type CoexistenceLifecycleEventRecord, type CoexistenceMessageEditValue, type CoexistenceMessageEditWebhook, type CoexistenceMessageRevokeValue, type CoexistenceMessageRevokeWebhook, type CoexistenceOnboardingSessionRecord, type CoexistencePhoneStatusResponse, type CoexistencePreflightFailureCode, type CoexistencePreflightStateRecord, type CoexistenceRawEventStatusRecord, CoexistenceService, type CoexistenceServiceConfig, type CoexistenceSessionEventPayload, type CoexistenceSessionInfoVersion, type CoexistenceSmbAppStateSyncValue, type CoexistenceSmbAppStateSyncWebhook, type CoexistenceSmbMessageEchoesValue, type CoexistenceSmbMessageEchoesWebhook, type CoexistenceStore, type CoexistenceSyncJobRecord, type CoexistenceSyncJobStatus, type CoexistenceSyncRequest, type CoexistenceSyncResponse, type CoexistenceSyncType, type CoexistenceTokenExchangeResult, type CoexistenceUnsupportedValue, type CoexistenceUnsupportedWebhook, type CoexistenceWebhookBase, type CoexistenceWebhookPayload, type CoexistenceWebhookValueBase, type Conversation, type ConversationRecord, type ConversationSummary, type ConversationUpdateEvent, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, type FreeformMessageWindow, InMemoryCoexistenceStore, type IncomingMessage, type InferBetterZapPluginContext, type InferBetterZapPluginServices, type InteractiveMediaCarouselCardInput, type LaunchCoexistenceEmbeddedSignupInput, type LogLevel, type Logger, type LoggerConfig, type MediaMessage, type MessageContext, type MessageError, type MessageLoggerNotifier, MessageLoggerService, type MessageStatus, type MetaAccessTokenProvider, type MetaGraphApiErrorBody, type NewMessageEvent, type NormalizedCoexistenceSessionEvent, type OutgoingLoggingMetadata, type SendInteractiveMediaCarouselData, type SendMessageError, type SendMessageResponse, type SendResult, type StatusContext, type StatusUpdateEvent, type SupportedTemplateParameterType, type SyncEvent, type TemplateComponent, type TemplateComponentDefinition, type TemplateDefinition, type TemplateName, type TemplateParameter, type TemplateParameterDefinition, type TemplateParameterInputMap, type TemplateParams, type TemplateRegistry, type UIMessage, type UIMessageStatus, WHATSAPP_MESSAGE_TYPES, type WebhookChange, type WebhookContact, type WebhookEntry, type WebhookError, type WebhookPayload, type WebhookValue, type WhatsAppCarouselCard, type WhatsAppConfig, type WhatsAppDirection, type WhatsAppInteractiveButtonsMessage, type WhatsAppInteractiveListMessage, type WhatsAppInteractiveMediaCarouselMessage, type WhatsAppLocationMessage, type WhatsAppLogRecord, type WhatsAppLogStore, type WhatsAppMessageType, WhatsAppService, type WhatsAppStatus, type WhatsAppTemplateMessage, type WhatsAppTextMessage, type WhatsAppWebhookField, type ZapClient, type ZapTransport, apiKeyTransport, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, sessionTransport, toLegacyCoexistenceSessionEvent };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { BetterZapClientError, createZapClient } from "./client.mjs";
1
+ import { BetterZapClientError, apiKeyTransport, createZapClient, sessionTransport } from "./client.mjs";
2
2
  //#region src/freeform-message-window.ts
3
3
  const FREEFORM_MESSAGE_WINDOW_MS = 1440 * 60 * 1e3;
4
4
  function toTimestamp(value) {
@@ -1055,4 +1055,4 @@ function serializeTemplateParameter(parameter, value) {
1055
1055
  }
1056
1056
  }
1057
1057
  //#endregion
1058
- export { BetterZapClientError, CoexistenceService, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, InMemoryCoexistenceStore, MessageLoggerService, WHATSAPP_MESSAGE_TYPES, WhatsAppService, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, toLegacyCoexistenceSessionEvent };
1058
+ export { BetterZapClientError, CoexistenceService, EMPTY_TEMPLATE_REGISTRY, FREEFORM_MESSAGE_WINDOW_MS, InMemoryCoexistenceStore, MessageLoggerService, WHATSAPP_MESSAGE_TYPES, WhatsAppService, apiKeyTransport, createCoexistenceEmbeddedSignupConfig, createFreeformMessageWindow, createLogger, createZapClient, defineTemplates, delay, formatPhone, getLatestIncomingMessageAt, getTemplateNames, hasConfiguredTemplates, launchCoexistenceEmbeddedSignup, noopLogger, normalizeCoexistenceSessionEvent, normalizeCoexistenceSessionPayload, normalizeConversationRecord, normalizeConversationRecords, resolveConversationFreeformMessageWindow, serializeError, serializeTemplateFromRegistry, sessionTransport, toLegacyCoexistenceSessionEvent };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "better-zap",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Framework-agnostic Better Zap core for typed WhatsApp integrations.",
5
5
  "license": "ISC",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/Dosbodoke/better-zap",
8
+ "url": "git+https://github.com/Dosbodoke/better-zap.git",
9
9
  "directory": "packages/better-zap"
10
10
  },
11
11
  "type": "module",
@@ -19,22 +19,35 @@
19
19
  ],
20
20
  "exports": {
21
21
  ".": {
22
- "types": "./dist/index.d.mts",
23
- "import": "./dist/index.mjs",
24
- "require": "./dist/index.cjs"
22
+ "import": {
23
+ "types": "./dist/index.d.mts",
24
+ "default": "./dist/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./dist/index.d.cts",
28
+ "default": "./dist/index.cjs"
29
+ }
25
30
  },
26
31
  "./client": {
27
- "types": "./dist/client.d.mts",
28
- "import": "./dist/client.mjs",
29
- "require": "./dist/client.cjs"
32
+ "import": {
33
+ "types": "./dist/client.d.mts",
34
+ "default": "./dist/client.mjs"
35
+ },
36
+ "require": {
37
+ "types": "./dist/client.d.cts",
38
+ "default": "./dist/client.cjs"
39
+ }
30
40
  },
31
41
  "./package.json": "./package.json"
32
42
  },
33
43
  "engines": {
34
44
  "node": ">=20"
35
45
  },
46
+ "sideEffects": false,
36
47
  "publishConfig": {
37
- "access": "public"
48
+ "access": "public",
49
+ "registry": "https://registry.npmjs.org/",
50
+ "provenance": true
38
51
  },
39
52
  "devDependencies": {
40
53
  "@types/node": "^25.4.0",
@@ -45,6 +58,7 @@
45
58
  "scripts": {
46
59
  "build": "tsdown",
47
60
  "typecheck": "tsc --noEmit",
48
- "test": "vitest run"
61
+ "test": "vitest run",
62
+ "package:check": "publint --strict && attw --pack --profile node16"
49
63
  }
50
64
  }