New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

whatsapp-api-js

Package Overview
Dependencies
Maintainers
0
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatsapp-api-js - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0-beta.0

107

lib/messages/interactive.d.ts

@@ -192,3 +192,3 @@ import { ClientMessage, ClientLimitedMessageComponent, Section, type InteractiveAction } from "../types.js";

* Interactive,
* ActionNavigateFlow,
* ActionFlow,
* Body

@@ -198,12 +198,13 @@ * } from "whatsapp-api-js/messages";

* const interactive_navigate_flow_message = new Interactive(
* new ActionNavigateFlow(
* "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* "Hello World",
* "form_screen",
* {
* name: "John Doe",
* age: 42
* new ActionFlow({
* flow_token: "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* flow_name: "my_welcome_flow", // Can also use flow_id instead
* flow_cta: "Start the Flow!",
* mode: "published",
* flow_action: "navigate", // Default
* flow_action_payload: {
* screen: "FIRST_SCREEN",
* data: { name: "John" }
* }
* ),
* }),
* new Body("How was your experience today?")

@@ -217,3 +218,3 @@ * );

* Interactive,
* ActionDataExchangeFlow,
* ActionFlow,
* Body

@@ -223,11 +224,12 @@ * } from "whatsapp-api-js/messages";

* const interactive_data_exchange_flow_message = new Interactive(
* new ActionDataExchangeFlow(
* "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* "Hello World"
* ),
* new Body("Hello World")
* new ActionFlow({
* flow_token: "5f9b3b4f-2b7a-4f4f-8f4f-4f4f4f4f4f4f",
* flow_name: "my_welcome_flow", // Can also use flow_id instead
* flow_cta: "Start the Flow!",
* mode: "published",
* flow_action: "data_exchange",
* }),
* new Body("Hello World") ```
* );
* ```
*
* @param action - The action for the interactive message

@@ -595,3 +597,3 @@ * @param body - The body for the interactive message

*/
export declare abstract class ActionFlow implements InteractiveAction {
export declare class ActionFlow implements InteractiveAction {
/**

@@ -611,16 +613,12 @@ * The name of the component

*/
mode: "published" | "draft";
mode?: "published" | "draft";
/**
* The Flow version, must be 3
*/
flow_message_version: "3";
flow_message_version?: "3";
/**
* Flow token that is generated by the business to serve as an identifier
*/
flow_token: string;
flow_token?: string;
/**
* Unique ID of the Flow provided by WhatsApp
*/
flow_id: string;
/**
* Text on the CTA button, character limit - 20 characters (no emoji)

@@ -630,5 +628,5 @@ */

/**
* The Flow type, if set to "navigate", flow_action_payload must be provided
* The Flow type, if set to "navigate", flow_action_payload must be provided default to "navigate"
*/
flow_action: "navigate" | "data_exchange";
flow_action?: "navigate" | "data_exchange";
/**

@@ -648,3 +646,3 @@ * Required if flow_action is "navigate", should be omitted otherwise

} & ({
flow_action: "navigate";
flow_action?: "navigate";
flow_action_payload: {

@@ -657,2 +655,14 @@ screen: string;

flow_action_payload?: never;
}) & ({
/**
* Unique ID of the Flow provided by WhatsApp
*/
flow_id: string;
flow_name?: never;
} | {
/**
* Flow name provided by the business as an alternative to flow_id
*/
flow_name: string;
flow_id?: never;
});

@@ -678,41 +688,2 @@ /**

*/
export declare class ActionNavigateFlow extends ActionFlow {
/**
* Builds a navigate flow component for an Interactive message
*
* @param flow_token - Flow token that is generated by the business to serve as an identifier
* @param flow_id - ID of the Flow provided by WhatsApp
* @param flow_cta - Text on the CTA button, character limit - 20 characters (no emoji)
* @param screen - The ID of the first Screen
* @param data - Optional input data for the first Screen of the Flow. If provided, this must be a non-empty object.
* @param mode - The Flow can be in either "draft" or "published" mode
* @param flow_message_version - The Flow version, must be "3"
* @throws If flow_cta is empty or over 20 characters
* @throws If flow_cta contains emojis
* @throws If data is provided and is an empty object
*/
constructor(flow_token: string, flow_id: string, flow_cta: string, screen: string, data?: unknown, mode?: "published" | "draft", flow_message_version?: "3");
}
/**
* Action API object
*
* @group Interactive
*/
export declare class ActionDataExchangeFlow extends ActionFlow {
/**
* Builds a data exchange flow component for an Interactive message
*
* @param flow_token - Flow token that is generated by the business to serve as an identifier
* @param flow_id - ID of the Flow provided by WhatsApp
* @param flow_cta - Text on the CTA button, character limit - 20 characters (no emoji)
* @param mode - Must be "published" or "draft"
* @param flow_message_version - Must be "3"
*/
constructor(flow_token: string, flow_id: string, flow_cta: string, mode?: "published" | "draft", flow_message_version?: "3");
}
/**
* Action API object
*
* @group Interactive
*/
export declare class ActionLocation implements InteractiveAction {

@@ -719,0 +690,0 @@ /**

@@ -455,2 +455,7 @@ import {

constructor(parameters) {
parameters = {
flow_message_version: "3",
flow_action: "navigate",
...parameters
};
if (!parameters.flow_cta.length || parameters.flow_cta.length > 20) {

@@ -462,59 +467,10 @@ throw new Error("Flow CTA must be between 1 and 20 characters");

}
if (parameters.flow_action === "navigate" && !Object.keys(parameters.flow_action_payload).length) {
throw new Error(
"Flow data must be a non-empty object when flow_action is navigate"
);
}
this.parameters = parameters;
}
}
class ActionNavigateFlow extends ActionFlow {
/**
* Builds a navigate flow component for an Interactive message
*
* @param flow_token - Flow token that is generated by the business to serve as an identifier
* @param flow_id - ID of the Flow provided by WhatsApp
* @param flow_cta - Text on the CTA button, character limit - 20 characters (no emoji)
* @param screen - The ID of the first Screen
* @param data - Optional input data for the first Screen of the Flow. If provided, this must be a non-empty object.
* @param mode - The Flow can be in either "draft" or "published" mode
* @param flow_message_version - The Flow version, must be "3"
* @throws If flow_cta is empty or over 20 characters
* @throws If flow_cta contains emojis
* @throws If data is provided and is an empty object
*/
constructor(flow_token, flow_id, flow_cta, screen, data, mode = "published", flow_message_version = "3") {
super({
mode,
flow_message_version,
flow_token,
flow_id,
flow_cta,
flow_action: "navigate",
flow_action_payload: {
screen,
data
}
});
if (data && !Object.keys(data).length) {
throw new Error("Flow data must be a non-empty object if provided");
}
}
}
class ActionDataExchangeFlow extends ActionFlow {
/**
* Builds a data exchange flow component for an Interactive message
*
* @param flow_token - Flow token that is generated by the business to serve as an identifier
* @param flow_id - ID of the Flow provided by WhatsApp
* @param flow_cta - Text on the CTA button, character limit - 20 characters (no emoji)
* @param mode - Must be "published" or "draft"
* @param flow_message_version - Must be "3"
*/
constructor(flow_token, flow_id, flow_cta, mode = "published", flow_message_version = "3") {
super({
mode,
flow_message_version,
flow_token,
flow_id,
flow_cta,
flow_action: "data_exchange"
});
}
}
class ActionLocation {

@@ -537,7 +493,5 @@ /**

ActionCatalog,
ActionDataExchangeFlow,
ActionFlow,
ActionList,
ActionLocation,
ActionNavigateFlow,
ActionProduct,

@@ -544,0 +498,0 @@ ActionProductList,

{
"name": "whatsapp-api-js",
"version": "5.0.0",
"version": "6.0.0-beta.0",
"author": "Secreto31126",

@@ -5,0 +5,0 @@ "description": "A TypeScript server agnostic Whatsapp's Official API framework",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc