ziphjs 0.0.0-stage → 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Spikenard
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # ziphjs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Lightweight server-side JavaScript and TypeScript client for sending WhatsApp and
4
+ SMS messages with [Ziph](https://ziph.dev). Requires Node.js 20 or later. ESM only;
5
+ TypeScript declarations are included. No runtime dependencies.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install ziphjs
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ Keep your API key on the server, outside source control. Set `ZIPH_API_KEY` in your
16
+ environment, then send a message:
17
+
18
+ ```js
19
+ import { ZiphClient } from "ziphjs";
20
+
21
+ const client = new ZiphClient({ apiKey: process.env.ZIPH_API_KEY });
22
+
23
+ const { data: message } = await client.sendText({
24
+ channel_type: "sms",
25
+ to: "+23276123456",
26
+ text: "Your order is ready.",
27
+ idempotencyKey: "order-123-ready",
28
+ });
29
+
30
+ console.log(message.id, message.status);
31
+ ```
32
+
33
+ Use `channel_type: "whatsapp"` to send WhatsApp text. An optional `channel_id`
34
+ selects a WhatsApp channel; omitting it uses the default channel.
35
+
36
+ The client also exposes `sendImage`, `sendList`, and `sendMessage`. Public request
37
+ and response types are exported from `ziphjs`.
38
+
39
+ Every send requires an `idempotencyKey` of 1–255 bytes. Use a new key per logical
40
+ message, and reuse that key with the unchanged request when retrying an uncertain
41
+ outcome. The client sends once, without automatic retries. An accepted message is
42
+ not confirmation of delivery.
43
+
44
+ ## Errors
45
+
46
+ Unsuccessful HTTP responses throw `ZiphError`, with `status`, `code`, `details`,
47
+ and `meta` properties. Network errors are not wrapped. Invalid client options or
48
+ idempotency keys throw `TypeError`.
49
+
50
+ ## Development and releases
51
+
52
+ Run `npm ci`, `npm run format:check`, `npm run typecheck`, `npm test`, and
53
+ `npm run build` before releasing. The test command currently discovers no tests.
54
+ Use `npm pack --dry-run` to inspect the package contents without publishing.
55
+
56
+ The Release workflow runs only on pushed `v*` tags. The tag must match the version
57
+ in `package.json`, for example `v0.0.1`. It checks the package, builds it, publishes
58
+ to npm using OIDC, then creates a GitHub Release with generated release notes.
59
+ Pushing a release tag publishes the package; it is not a preview.
60
+
61
+ Before using the workflow, configure npm trusted publishing for the package:
62
+
63
+ - Organization: `spikenardco`
64
+ - Repository: `ziphjs`
65
+ - Workflow filename: `release.yml`
66
+ - Allow direct `npm publish`
67
+
68
+ If the package does not yet exist on npm, first publish it manually with a
69
+ maintainer account so its package settings are available, then configure trusted
70
+ publishing for subsequent versions. Do not tag that already-published version for
71
+ the publish workflow. No long-lived npm token is needed in GitHub Actions.
72
+
73
+ ## License
74
+
75
+ Apache-2.0. See [LICENSE](./LICENSE).
@@ -0,0 +1,90 @@
1
+ export * from "./types.js";
2
+ export type ZiphOptions = {
3
+ /**
4
+ * Server-side API key. Never expose it in browser code.
5
+ */
6
+ apiKey: string;
7
+ /**
8
+ * API root without /v1. Defaults to https://api.ziph.dev.
9
+ */
10
+ baseUrl?: string;
11
+ };
12
+ export type SendMessageInput = import('./types.js').SendMessageRequest & {
13
+ idempotencyKey: string;
14
+ };
15
+ export type SendTextInput = (Pick<import('./types.js').SmsMessage, 'channel_type' | 'to' | 'text'> | Pick<import('./types.js').WhatsAppTextMessage, 'channel_type' | 'to' | 'text' | 'channel_id' | 'buttons'>) & {
16
+ idempotencyKey: string;
17
+ };
18
+ export type SendImageInput = Pick<import('./types.js').WhatsAppImageMessage, 'to' | 'channel_id' | 'image' | 'buttons'> & {
19
+ idempotencyKey: string;
20
+ };
21
+ export type SendListInput = Pick<import('./types.js').WhatsAppListMessage, 'to' | 'channel_id' | 'text' | 'list'> & {
22
+ idempotencyKey: string;
23
+ };
24
+ /**
25
+ * @typedef {object} ZiphOptions
26
+ * @property {string} apiKey Server-side API key. Never expose it in browser code.
27
+ * @property {string} [baseUrl] API root without /v1. Defaults to https://api.ziph.dev.
28
+ */
29
+ /**
30
+ * @typedef {import('./types.js').SendMessageRequest & { idempotencyKey: string }} SendMessageInput
31
+ * The key must be 1–255 bytes. Reuse it with the unchanged request when retrying.
32
+ */
33
+ /**
34
+ * @typedef {(Pick<import('./types.js').SmsMessage, 'channel_type' | 'to' | 'text'> | Pick<import('./types.js').WhatsAppTextMessage, 'channel_type' | 'to' | 'text' | 'channel_id' | 'buttons'>) & { idempotencyKey: string }} SendTextInput
35
+ */
36
+ /**
37
+ * @typedef {Pick<import('./types.js').WhatsAppImageMessage, 'to' | 'channel_id' | 'image' | 'buttons'> & { idempotencyKey: string }} SendImageInput
38
+ */
39
+ /**
40
+ * @typedef {Pick<import('./types.js').WhatsAppListMessage, 'to' | 'channel_id' | 'text' | 'list'> & { idempotencyKey: string }} SendListInput
41
+ */
42
+ /** An unsuccessful HTTP response from Ziph. Network errors are not wrapped. */
43
+ export declare class ZiphError extends Error {
44
+ /** @readonly */
45
+ status: number;
46
+ /** @readonly */
47
+ code: import("./types.js").ErrorCode | null;
48
+ /** @readonly */
49
+ details: import("./types.js").FieldError[];
50
+ /** @readonly */
51
+ meta: import("./types.js").Meta | null;
52
+ /**
53
+ * @param {number} status
54
+ * @param {import('./types.js').ApiError | null} [error]
55
+ * @param {import('./types.js').Meta | null} [meta]
56
+ */
57
+ constructor(status: number, error?: import('./types.js').ApiError | null, meta?: import('./types.js').Meta | null);
58
+ }
59
+ /** Server-side client for sending WhatsApp and SMS messages. */
60
+ export declare class ZiphClient {
61
+ #private;
62
+ /** @param {ZiphOptions} options */
63
+ constructor({ apiKey, baseUrl }: ZiphOptions);
64
+ /**
65
+ * Sends a WhatsApp or SMS text message. text is required.
66
+ * @param {SendTextInput} input
67
+ * @returns {Promise<import('./types.js').MessageEnvelope>}
68
+ */
69
+ sendText(input: SendTextInput): Promise<import('./types.js').MessageEnvelope>;
70
+ /**
71
+ * Sends a WhatsApp image. Use image.caption for accompanying text.
72
+ * @param {SendImageInput} input
73
+ * @returns {Promise<import('./types.js').MessageEnvelope>}
74
+ */
75
+ sendImage(input: SendImageInput): Promise<import('./types.js').MessageEnvelope>;
76
+ /**
77
+ * Sends a WhatsApp list menu. Both text and list are required.
78
+ * @param {SendListInput} input
79
+ * @returns {Promise<import('./types.js').MessageEnvelope>}
80
+ */
81
+ sendList(input: SendListInput): Promise<import('./types.js').MessageEnvelope>;
82
+ /**
83
+ * Sends once, without automatic retries. Reuse the same key and unchanged
84
+ * request if retrying after a network error or an uncertain outcome.
85
+ * Acceptance does not confirm delivery. idempotencyKey is sent only as a header.
86
+ * @param {SendMessageInput} input
87
+ * @returns {Promise<import('./types.js').MessageEnvelope>}
88
+ */
89
+ sendMessage({ idempotencyKey, ...request }: SendMessageInput): Promise<import('./types.js').MessageEnvelope>;
90
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var r=class extends Error{constructor(e,t=null,s=null){super(t?.message??`Ziph request failed with HTTP ${e}.`),this.name="ZiphError",this.status=e,this.code=t?.code??null,this.details=t?.details??[],this.meta=s}},a=class{#t;#e;constructor({apiKey:e,baseUrl:t="https://api.ziph.dev"}){if(typeof e!="string"||!e.trim())throw new TypeError("apiKey is required.");if(this.#t=e,this.#e=new URL(`${t.replace(/\/+$/,"")}/v1/messages`),!["http:","https:"].includes(this.#e.protocol))throw new TypeError("baseUrl must use HTTP or HTTPS.")}sendText(e){return this.sendMessage(e)}sendImage(e){return this.sendMessage({...e,channel_type:"whatsapp"})}sendList(e){return this.sendMessage({...e,channel_type:"whatsapp"})}async sendMessage({idempotencyKey:e,...t}){if(typeof e!="string"||!e.trim()||Buffer.byteLength(e)>255)throw new TypeError("idempotencyKey must be between 1 and 255 bytes.");let s=await fetch(this.#e,{method:"POST",redirect:"error",headers:{Authorization:`Bearer ${this.#t}`,"Content-Type":"application/json","Idempotency-Key":e},body:JSON.stringify(t)});if(!s.ok){let n=await s.json().catch(()=>null);throw new r(s.status,n?.error,n?.meta)}return s.json()}};export{a as ZiphClient,r as ZiphError};
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Public types for the Ziph API,
3
+ *
4
+ * Wire fields keep the API's snake_case names.
5
+ */
6
+ export type ChannelType = "whatsapp" | "sms";
7
+ export type MessageStatus = "processing" | "accepted" | "delivered" | "read" | "failed" | "unknown";
8
+ /** Buttons: 1–3 per message, WhatsApp only. */
9
+ export interface QuickReplyButton {
10
+ /** Defaults to quick_reply when omitted. */
11
+ type?: "" | "quick_reply";
12
+ /** Unique per message, 1–128 bytes. */
13
+ id: string;
14
+ /** 1–25 characters. */
15
+ title: string;
16
+ url?: never;
17
+ copy_code?: never;
18
+ phone_number?: never;
19
+ }
20
+ export interface UrlButton {
21
+ type: "url";
22
+ title: string;
23
+ /** Absolute http(s) URL. */
24
+ url: string;
25
+ id?: never;
26
+ copy_code?: never;
27
+ phone_number?: never;
28
+ }
29
+ export interface CopyButton {
30
+ type: "copy";
31
+ title: string;
32
+ copy_code: string;
33
+ id?: never;
34
+ url?: never;
35
+ phone_number?: never;
36
+ }
37
+ export interface CallButton {
38
+ type: "call";
39
+ title: string;
40
+ /** International format, e.g. +23276123456. */
41
+ phone_number: string;
42
+ id?: never;
43
+ url?: never;
44
+ copy_code?: never;
45
+ }
46
+ export type MessageButton = QuickReplyButton | UrlButton | CopyButton | CallButton;
47
+ export type MessageButtons = [MessageButton] | [MessageButton, MessageButton] | [MessageButton, MessageButton, MessageButton];
48
+ /** WhatsApp image: JPEG or PNG, up to 5 MiB, publicly accessible without redirects. */
49
+ export interface MessageImage {
50
+ url: string;
51
+ /** Up to 4096 bytes. Use this instead of text when sending an image. */
52
+ caption?: string;
53
+ }
54
+ /** Single-select WhatsApp list menu. Cannot be combined with buttons or an image. */
55
+ export interface ListRow {
56
+ /** Unique per message, 1–128 bytes. */
57
+ id: string;
58
+ /** 1–24 characters. */
59
+ title: string;
60
+ /** Up to 72 characters. */
61
+ description?: string;
62
+ }
63
+ export interface ListSection {
64
+ /** 1–24 characters. */
65
+ title: string;
66
+ rows: [ListRow, ...ListRow[]];
67
+ }
68
+ export interface MessageListMenu {
69
+ /** Caption of the menu button, 1–20 characters. */
70
+ button_text: string;
71
+ /** 1–10 sections, at most 10 rows in total. */
72
+ sections: [ListSection, ...ListSection[]];
73
+ }
74
+ /** SMS is text only. */
75
+ export interface SmsMessage {
76
+ channel_type: "sms";
77
+ /** Recipient in international format, e.g. +23276123456. */
78
+ to: string;
79
+ channel_id?: never;
80
+ /** 1–4096 bytes. */
81
+ text: string;
82
+ buttons?: never;
83
+ image?: never;
84
+ list?: never;
85
+ }
86
+ export interface WhatsAppTextMessage {
87
+ channel_type: "whatsapp";
88
+ /** Recipient in international format, e.g. +23276123456. */
89
+ to: string;
90
+ /** Uses the default channel when omitted or null. */
91
+ channel_id?: string | null;
92
+ /** 1–4096 bytes. Must include non-whitespace text when adding buttons. */
93
+ text: string;
94
+ buttons?: MessageButtons;
95
+ image?: never;
96
+ list?: never;
97
+ }
98
+ export interface WhatsAppImageMessage {
99
+ channel_type: "whatsapp";
100
+ /** Recipient in international format, e.g. +23276123456. */
101
+ to: string;
102
+ /** Uses the default channel when omitted or null. */
103
+ channel_id?: string | null;
104
+ /** Omit, or pass an empty string, and use image.caption instead. */
105
+ text?: "";
106
+ buttons?: MessageButtons;
107
+ image: MessageImage;
108
+ list?: never;
109
+ }
110
+ export interface WhatsAppListMessage {
111
+ channel_type: "whatsapp";
112
+ /** Recipient in international format, e.g. +23276123456. */
113
+ to: string;
114
+ /** Uses the default channel when omitted or null. */
115
+ channel_id?: string | null;
116
+ /** 1–4096 bytes. */
117
+ text: string;
118
+ buttons?: never;
119
+ image?: never;
120
+ list: MessageListMenu;
121
+ }
122
+ export type SendMessageRequest = SmsMessage | WhatsAppTextMessage | WhatsAppImageMessage | WhatsAppListMessage;
123
+ /** Selection returned when a recipient answers a quick-reply or list message. */
124
+ export interface InteractiveReply {
125
+ id: string;
126
+ title: string;
127
+ quoted_provider_message_id?: string;
128
+ }
129
+ export interface ReceivedMessage {
130
+ provider_message_id: string;
131
+ sender: string;
132
+ conversation: string;
133
+ text: string;
134
+ button_reply?: InteractiveReply;
135
+ list_reply?: InteractiveReply;
136
+ }
137
+ export interface MessageReceivedEvent {
138
+ version: 1;
139
+ id: string;
140
+ event: "message.received";
141
+ channel_id: string;
142
+ timestamp: string;
143
+ message: ReceivedMessage;
144
+ }
145
+ export interface MessageStatusEvent {
146
+ id: string;
147
+ status: MessageStatus;
148
+ failure_code: string | null;
149
+ occurred_at: string;
150
+ }
151
+ export interface Message {
152
+ id: string;
153
+ channel_id: string | null;
154
+ channel_type: ChannelType;
155
+ recipient_masked: string;
156
+ status: MessageStatus;
157
+ provider_message_id: string | null;
158
+ failure_code: string | null;
159
+ created_at: string;
160
+ updated_at: string;
161
+ events?: MessageStatusEvent[];
162
+ }
163
+ export interface MessageDetail extends Message {
164
+ events: MessageStatusEvent[];
165
+ }
166
+ export interface MessageList {
167
+ messages: Message[];
168
+ /** Pass as `before` when listing; null on the last page. */
169
+ next_cursor: string | null;
170
+ }
171
+ export interface Meta {
172
+ request_id?: string;
173
+ timestamp: string;
174
+ }
175
+ export interface ResponseEnvelope<T> {
176
+ data: T;
177
+ meta: Meta;
178
+ }
179
+ export type MessageEnvelope = ResponseEnvelope<Message>;
180
+ export type MessageDetailEnvelope = ResponseEnvelope<MessageDetail>;
181
+ export type MessageListEnvelope = ResponseEnvelope<MessageList>;
182
+ export type ErrorCode = "AUTH_REQUIRED" | "MESSAGE_QUOTA_EXCEEDED" | "PLAN_EXPIRED" | "VALIDATION_ERROR" | "NOT_FOUND" | "CHANNEL_DISCONNECTED" | "PROVIDER_UNAVAILABLE" | "PROVIDER_TIMEOUT" | "PROVIDER_REJECTED" | "IDEMPOTENCY_CONFLICT" | "CHANNEL_TYPE_UNAVAILABLE" | "CHANNEL_TYPE_MISMATCH" | "MESSAGE_TYPE_UNAVAILABLE" | "INTERNAL_SERVER_ERROR";
183
+ export interface FieldError {
184
+ field: string;
185
+ message: string;
186
+ }
187
+ export interface ApiError {
188
+ code: ErrorCode;
189
+ message: string;
190
+ details: FieldError[];
191
+ }
192
+ export interface ErrorEnvelope {
193
+ data: null;
194
+ error: ApiError;
195
+ meta: Meta;
196
+ }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
- "name": "ziphjs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "ziphjs",
3
+ "version": "0.0.1",
4
+ "description": "Lightweight server-side JavaScript and TypeScript client for sending WhatsApp and SMS messages with Ziph.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=20.0.0"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "format": "biome check --write .",
22
+ "format:check": "biome check .",
23
+ "test": "node --test",
24
+ "typecheck": "tsc --noEmit",
25
+ "build": "rm -rf dist && esbuild src/index.js --bundle --platform=node --format=esm --outfile=dist/index.js --target=node20 --minify && tsc --emitDeclarationOnly --rootDir src",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/spikenardco/ziphjs.git"
31
+ },
32
+ "keywords": [
33
+ "ziph",
34
+ "whatsapp",
35
+ "sms",
36
+ "messaging",
37
+ "sdk",
38
+ "nodejs",
39
+ "typescript"
40
+ ],
41
+ "license": "Apache-2.0",
42
+ "contributors": [
43
+ {
44
+ "name": "Ben",
45
+ "email": "bnjox@users.noreply.github.com",
46
+ "url": "https://github.com/bnjox"
47
+ }
48
+ ],
49
+ "bugs": {
50
+ "url": "https://github.com/spikenardco/ziphjs/issues"
51
+ },
52
+ "homepage": "https://github.com/spikenardco/ziphjs#readme",
53
+ "devDependencies": {
54
+ "@biomejs/biome": "^2.5.12",
55
+ "@types/node": "^26.4.1",
56
+ "esbuild": "^0.28.2",
57
+ "typescript": "^7.0.2"
58
+ }
59
+ }