@open-apime/sdk 0.4.1 → 0.5.0
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/index.cjs +12 -0
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +12 -0
- package/docs/guia.md +14 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -490,6 +490,18 @@ var MessagesResource = class {
|
|
|
490
490
|
form.set("file", input.file, input.filename ?? fileName(input.file, "media"));
|
|
491
491
|
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
492
492
|
}
|
|
493
|
+
sendGif(input, options) {
|
|
494
|
+
const form = toForm(input, ["file", "filename"]);
|
|
495
|
+
form.set("type", "gif");
|
|
496
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, "animation.mp4"));
|
|
497
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
498
|
+
}
|
|
499
|
+
sendSticker(input, options) {
|
|
500
|
+
const form = toForm(input, ["file", "filename"]);
|
|
501
|
+
form.set("type", "sticker");
|
|
502
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, "sticker.webp"));
|
|
503
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
504
|
+
}
|
|
493
505
|
sendAudio(input, options) {
|
|
494
506
|
const form = toForm(input, ["file", "filename"]);
|
|
495
507
|
form.set("file", input.file, input.filename ?? fileName(input.file, "audio.ogg"));
|
package/dist/index.d.cts
CHANGED
|
@@ -230,6 +230,32 @@ interface SendMediaInput extends QuoteInput, MarkReadInput {
|
|
|
230
230
|
filename?: string;
|
|
231
231
|
caption?: string;
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A GIF on WhatsApp is an MP4 VIDEO carrying the gif-playback flag, which is what makes the client
|
|
235
|
+
* loop it with no controls. Sending a real `.gif` file arrives as a still image, so it gets a method
|
|
236
|
+
* of its own rather than a `type` on sendMedia: the name is what warns the caller at the call site.
|
|
237
|
+
*/
|
|
238
|
+
interface SendGifInput extends QuoteInput, MarkReadInput {
|
|
239
|
+
to: string;
|
|
240
|
+
/** MP4 bytes. A `.gif` file is NOT what WhatsApp expects here. */
|
|
241
|
+
file: Blob | File;
|
|
242
|
+
filename?: string;
|
|
243
|
+
caption?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* WhatsApp takes stickers as WebP 512x512, up to 500 KB, transparent background; animated ones are
|
|
247
|
+
* animated WebP. The server validates and refuses outside that, because a sticker off-spec is
|
|
248
|
+
* accepted by the wire and then fails to render, with nothing reporting it.
|
|
249
|
+
*
|
|
250
|
+
* There is no caption: the protocol has no such field on a sticker, so one would be dropped in
|
|
251
|
+
* silence. That is why this does not reuse `SendMediaInput`.
|
|
252
|
+
*/
|
|
253
|
+
interface SendStickerInput extends QuoteInput, MarkReadInput {
|
|
254
|
+
to: string;
|
|
255
|
+
/** WebP bytes, 512x512, up to 500 KB. */
|
|
256
|
+
file: Blob | File;
|
|
257
|
+
filename?: string;
|
|
258
|
+
}
|
|
233
259
|
interface SendAudioInput extends QuoteInput, MarkReadInput {
|
|
234
260
|
to: string;
|
|
235
261
|
file: Blob | File;
|
|
@@ -275,6 +301,8 @@ declare class MessagesResource {
|
|
|
275
301
|
private get base();
|
|
276
302
|
sendText(input: SendTextInput, options?: RequestOptions): Promise<SentMessage>;
|
|
277
303
|
sendMedia(input: SendMediaInput, options?: RequestOptions): Promise<SentMessage>;
|
|
304
|
+
sendGif(input: SendGifInput, options?: RequestOptions): Promise<SentMessage>;
|
|
305
|
+
sendSticker(input: SendStickerInput, options?: RequestOptions): Promise<SentMessage>;
|
|
278
306
|
sendAudio(input: SendAudioInput, options?: RequestOptions): Promise<SentMessage>;
|
|
279
307
|
sendDocument(input: SendDocumentInput, options?: RequestOptions): Promise<SentMessage>;
|
|
280
308
|
sendContact(input: SendContactInput, options?: RequestOptions): Promise<SentMessage>;
|
|
@@ -535,4 +563,4 @@ interface HealthResult {
|
|
|
535
563
|
declare const DEFAULT_HEALTH_TIMEOUT_MS = 10000;
|
|
536
564
|
declare function checkHealth(baseUrl: string, options?: HealthOptions): Promise<HealthResult>;
|
|
537
565
|
|
|
538
|
-
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendLocationInput, type SendMediaInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
|
566
|
+
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,32 @@ interface SendMediaInput extends QuoteInput, MarkReadInput {
|
|
|
230
230
|
filename?: string;
|
|
231
231
|
caption?: string;
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A GIF on WhatsApp is an MP4 VIDEO carrying the gif-playback flag, which is what makes the client
|
|
235
|
+
* loop it with no controls. Sending a real `.gif` file arrives as a still image, so it gets a method
|
|
236
|
+
* of its own rather than a `type` on sendMedia: the name is what warns the caller at the call site.
|
|
237
|
+
*/
|
|
238
|
+
interface SendGifInput extends QuoteInput, MarkReadInput {
|
|
239
|
+
to: string;
|
|
240
|
+
/** MP4 bytes. A `.gif` file is NOT what WhatsApp expects here. */
|
|
241
|
+
file: Blob | File;
|
|
242
|
+
filename?: string;
|
|
243
|
+
caption?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* WhatsApp takes stickers as WebP 512x512, up to 500 KB, transparent background; animated ones are
|
|
247
|
+
* animated WebP. The server validates and refuses outside that, because a sticker off-spec is
|
|
248
|
+
* accepted by the wire and then fails to render, with nothing reporting it.
|
|
249
|
+
*
|
|
250
|
+
* There is no caption: the protocol has no such field on a sticker, so one would be dropped in
|
|
251
|
+
* silence. That is why this does not reuse `SendMediaInput`.
|
|
252
|
+
*/
|
|
253
|
+
interface SendStickerInput extends QuoteInput, MarkReadInput {
|
|
254
|
+
to: string;
|
|
255
|
+
/** WebP bytes, 512x512, up to 500 KB. */
|
|
256
|
+
file: Blob | File;
|
|
257
|
+
filename?: string;
|
|
258
|
+
}
|
|
233
259
|
interface SendAudioInput extends QuoteInput, MarkReadInput {
|
|
234
260
|
to: string;
|
|
235
261
|
file: Blob | File;
|
|
@@ -275,6 +301,8 @@ declare class MessagesResource {
|
|
|
275
301
|
private get base();
|
|
276
302
|
sendText(input: SendTextInput, options?: RequestOptions): Promise<SentMessage>;
|
|
277
303
|
sendMedia(input: SendMediaInput, options?: RequestOptions): Promise<SentMessage>;
|
|
304
|
+
sendGif(input: SendGifInput, options?: RequestOptions): Promise<SentMessage>;
|
|
305
|
+
sendSticker(input: SendStickerInput, options?: RequestOptions): Promise<SentMessage>;
|
|
278
306
|
sendAudio(input: SendAudioInput, options?: RequestOptions): Promise<SentMessage>;
|
|
279
307
|
sendDocument(input: SendDocumentInput, options?: RequestOptions): Promise<SentMessage>;
|
|
280
308
|
sendContact(input: SendContactInput, options?: RequestOptions): Promise<SentMessage>;
|
|
@@ -535,4 +563,4 @@ interface HealthResult {
|
|
|
535
563
|
declare const DEFAULT_HEALTH_TIMEOUT_MS = 10000;
|
|
536
564
|
declare function checkHealth(baseUrl: string, options?: HealthOptions): Promise<HealthResult>;
|
|
537
565
|
|
|
538
|
-
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendLocationInput, type SendMediaInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
|
566
|
+
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
package/dist/index.js
CHANGED
|
@@ -419,6 +419,18 @@ var MessagesResource = class {
|
|
|
419
419
|
form.set("file", input.file, input.filename ?? fileName(input.file, "media"));
|
|
420
420
|
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
421
421
|
}
|
|
422
|
+
sendGif(input, options) {
|
|
423
|
+
const form = toForm(input, ["file", "filename"]);
|
|
424
|
+
form.set("type", "gif");
|
|
425
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, "animation.mp4"));
|
|
426
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
427
|
+
}
|
|
428
|
+
sendSticker(input, options) {
|
|
429
|
+
const form = toForm(input, ["file", "filename"]);
|
|
430
|
+
form.set("type", "sticker");
|
|
431
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, "sticker.webp"));
|
|
432
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
433
|
+
}
|
|
422
434
|
sendAudio(input, options) {
|
|
423
435
|
const form = toForm(input, ["file", "filename"]);
|
|
424
436
|
form.set("file", input.file, input.filename ?? fileName(input.file, "audio.ogg"));
|
package/docs/guia.md
CHANGED
|
@@ -48,6 +48,20 @@ await conexao.messages.sendMedia(
|
|
|
48
48
|
{ idempotencyKey: mensagem.id },
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
+
// GIF é MP4 com reprodução em laço, não arquivo .gif: mandar um .gif de verdade
|
|
52
|
+
// faz a mensagem chegar como imagem parada.
|
|
53
|
+
await conexao.messages.sendGif(
|
|
54
|
+
{ to: "5511999999999", file: mp4Blob },
|
|
55
|
+
{ idempotencyKey: mensagem.id },
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// Figurinha exige WebP 512x512 até 500 KB (animada ou não), e não tem legenda:
|
|
59
|
+
// o protocolo não traz esse campo. Fora da especificação, o apime recusa com 400.
|
|
60
|
+
await conexao.messages.sendSticker(
|
|
61
|
+
{ to: "5511999999999", file: webpBlob },
|
|
62
|
+
{ idempotencyKey: mensagem.id },
|
|
63
|
+
);
|
|
64
|
+
|
|
51
65
|
await conexao.whatsapp.groups.updateParticipants(grupoJid, {
|
|
52
66
|
action: "add",
|
|
53
67
|
participants: ["5511999999999@s.whatsapp.net"],
|