You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

whatsapp-api-js

Package Overview
Dependencies
Maintainers
0
Versions
106
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

to
5.1.0

87

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 {
/**

@@ -603,24 +605,25 @@ * The name of the component

* The Flow parameters
*
* @remarks TSDoc is unable to document this type properly, so most of
* the documentation is in the subclasses constructors instead.
*/
readonly parameters: {
/**
* Unique ID of the Flow provided by WhatsApp
*/
flow_id?: string | never;
/**
* Flow name provided by the business as an alternative to flow_id
*/
flow_name?: string | never;
/**
* The Flow can be in either draft or published mode
*/
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,7 +633,7 @@ */

/**
* 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.
*/
flow_action: "navigate" | "data_exchange";
flow_action?: "navigate" | "data_exchange";
/**
* Required if flow_action is "navigate", should be omitted otherwise
* Required if flow_action is "navigate", must be omitted otherwise
*/

@@ -646,5 +649,5 @@ flow_action_payload?: {

data?: unknown;
};
} | never;
} & ({
flow_action: "navigate";
flow_action?: "navigate";
flow_action_payload: {

@@ -657,2 +660,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;
});

@@ -667,2 +682,4 @@ /**

*
* @note flow_message_version defaults to "3"
*
* @param parameters - The Flow parameters

@@ -677,2 +694,3 @@ * @throws If parameters.flow_cta is empty or over 20 characters

*
* @deprecated Use {@link ActionFlow} instead
* @group Interactive

@@ -700,2 +718,3 @@ */

*
* @deprecated Use {@link ActionFlow} instead
* @group Interactive

@@ -702,0 +721,0 @@ */

@@ -435,5 +435,2 @@ import {

* The Flow parameters
*
* @remarks TSDoc is unable to document this type properly, so most of
* the documentation is in the subclasses constructors instead.
*/

@@ -451,2 +448,4 @@ parameters;

*
* @note flow_message_version defaults to "3"
*
* @param parameters - The Flow parameters

@@ -457,2 +456,6 @@ * @throws If parameters.flow_cta is empty or over 20 characters

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

@@ -464,2 +467,7 @@ throw new Error("Flow CTA must be between 1 and 20 characters");

}
if (parameters.flow_action === "navigate" && parameters.flow_action_payload.data && !Object.keys(parameters.flow_action_payload.data).length) {
throw new Error(
"Flow data must be a non-empty object when flow_action is navigate"
);
}
this.parameters = parameters;

@@ -496,5 +504,2 @@ }

});
if (data && !Object.keys(data).length) {
throw new Error("Flow data must be a non-empty object if provided");
}
}

@@ -501,0 +506,0 @@ }

{
"name": "whatsapp-api-js",
"version": "5.0.0",
"version": "5.1.0",
"author": "Secreto31126",

@@ -20,11 +20,14 @@ "description": "A TypeScript server agnostic Whatsapp's Official API framework",

"types": "./lib/index.d.ts",
"import": "./lib/index.js"
"import": "./lib/index.js",
"require": "./lib/index.js"
},
"./messages": {
"types": "./lib/messages/index.d.ts",
"import": "./lib/messages/index.js"
"import": "./lib/messages/index.js",
"require": "./lib/messages/index.js"
},
"./messages/*": {
"types": "./lib/messages/*.d.ts",
"import": "./lib/messages/*.js"
"import": "./lib/messages/*.js",
"require": "./lib/messages/*.js"
},

@@ -35,3 +38,4 @@ "./setup": null,

"types": "./lib/setup/*.d.ts",
"import": "./lib/setup/*.js"
"import": "./lib/setup/*.js",
"require": "./lib/setup/*.js"
},

@@ -42,3 +46,4 @@ "./middleware": null,

"types": "./lib/middleware/*.d.ts",
"import": "./lib/middleware/*.js"
"import": "./lib/middleware/*.js",
"require": "./lib/middleware/*.js"
},

@@ -50,7 +55,9 @@ "./emitters": {

"types": "./lib/types.d.ts",
"import": "./lib/types.js"
"import": "./lib/types.js",
"require": "./lib/types.js"
},
"./errors": {
"types": "./lib/errors.d.ts",
"import": "./lib/errors.js"
"import": "./lib/errors.js",
"require": "./lib/errors.js"
}

@@ -99,3 +106,3 @@ },

"build:types": "tsc",
"build:types:dev": "npm run build:types",
"build:types:dev": "tsc --noCheck",
"build:standalone": "esbuild src/standalone.ts --outfile=lib/standalone.js --bundle --platform=neutral --target=node10 --minify-syntax",

@@ -142,3 +149,3 @@ "test": "node --test --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=spec --test-reporter-destination=stdout",

"@adonisjs/http-server": "7.4.0",
"@eslint/js": "9.17.0",
"@eslint/js": "9.21.0",
"@reporters/github": "1.7.2",

@@ -148,20 +155,20 @@ "@reporters/silent": "1.2.7",

"@types/express": "5.0.0",
"@types/node": "18.19.68",
"@vercel/node": "5.0.0",
"@types/node": "18.19.76",
"@vercel/node": "5.1.8",
"all-contributors-cli": "6.26.1",
"c8": "10.1.3",
"dotenv": "16.4.7",
"esbuild": "0.24.2",
"eslint": "9.17.0",
"eslint-config-prettier": "9.1.0",
"esbuild": "0.25.0",
"eslint": "9.21.0",
"eslint-config-prettier": "10.0.1",
"eslint-plugin-tsdoc": "0.4.0",
"glob": "11.0.0",
"globals": "15.14.0",
"prettier": "3.4.2",
"glob": "11.0.1",
"globals": "15.15.0",
"prettier": "3.5.1",
"sinon": "19.0.2",
"typedoc": "0.27.6",
"typescript": "5.7.2",
"typescript-eslint": "8.19.0",
"undici": "7.2.0"
"typedoc": "0.27.8",
"typescript": "5.7.3",
"typescript-eslint": "8.24.1",
"undici": "7.3.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet