@chatally/core
Advanced tools
| > @chatally/core@0.0.5 lint | ||
| > @chatally/core@0.0.6 lint | ||
| > eslint . | ||
@@ -8,1 +8,7 @@ | ||
| } | ||
| /home/runner/work/chatally/chatally/packages/core/lib/messages.d.ts | ||
| 46:20 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any | ||
| ✖ 1 problem (0 errors, 1 warning) | ||
| > @chatally/core@0.0.5 test | ||
| > @chatally/core@0.0.6 test | ||
| > vitest run | ||
@@ -8,8 +8,8 @@ | ||
| [32m✓[39m lib/application.test.js [2m ([22m[2m7 tests[22m[2m)[22m[90m 10[2mms[22m[39m | ||
| [32m✓[39m lib/application.test.js [2m ([22m[2m7 tests[22m[2m)[22m[90m 11[2mms[22m[39m | ||
| [2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m | ||
| [2m Tests [22m [1m[32m7 passed[39m[22m[90m (7)[39m | ||
| [2m Start at [22m 08:12:45 | ||
| [2m Duration [22m 609ms[2m (transform 121ms, setup 0ms, collect 135ms, tests 10ms, environment 0ms, prepare 123ms)[22m | ||
| [2m Start at [22m 14:32:46 | ||
| [2m Duration [22m 971ms[2m (transform 218ms, setup 0ms, collect 221ms, tests 11ms, environment 0ms, prepare 214ms)[22m | ||
+6
-0
| # @chatally/core | ||
| ## 0.0.6 | ||
| ### Patch Changes | ||
| - cd44088: WhatsApp Cloud server implementation | ||
| ## 0.0.5 | ||
@@ -4,0 +10,0 @@ |
+11
-6
@@ -46,10 +46,12 @@ import { BaseLogger, NoLogger } from "@chatally/logger"; | ||
| * | ||
| * @param {Object} [options={}] Optional options | ||
| * @param {Object} [options={}] | ||
| * @param {D} [options.data] | ||
| * Arbitrary data to put into the context for each request | ||
| * [Optional] Arbitrary data to put into the context for each request | ||
| * [`default=undefined`] | ||
| * @param {import("@chatally/logger").Logger | boolean} [options.log] | ||
| * Your logger or flag if you want to use a default logger, | ||
| * default is the BaseLogger | ||
| * [Optional] Custom logger or flag if you want to use a default logger | ||
| * [`default=new BaseLogger()`] | ||
| * @param {boolean} [options.dev] | ||
| * Run in development mode | ||
| * [Optional] Flag to run application in development mode | ||
| * [`default=false`] | ||
| */ | ||
@@ -72,3 +74,3 @@ constructor(options = {}) { | ||
| /** | ||
| * Register a middleware function | ||
| * Register a middleware function or a server | ||
| * | ||
@@ -89,2 +91,5 @@ * Middlewares are executed in order of registration, but can `await next()` | ||
| m.dispatch = this.dispatch; | ||
| if (m.log === undefined || m.log === true) { | ||
| m.log = this.#log.child({ name: m.name }); | ||
| } | ||
| this.#servers.push(m); | ||
@@ -91,0 +96,0 @@ this.#log.info("Registered server '%s'", name); |
+121
-9
@@ -1,9 +0,65 @@ | ||
| export type Message = Text | Image | Audio; | ||
| export type Message = | ||
| | Audio | ||
| | Buttons | ||
| | Custom | ||
| | Document | ||
| | Image | ||
| | Location | ||
| | Menu | ||
| | Reaction | ||
| | Select | ||
| | Text | ||
| | Video; | ||
| export type Text = { | ||
| readonly type: "text"; | ||
| export type Action = { | ||
| id: string; | ||
| title: string; | ||
| description?: string; | ||
| }; | ||
| export type Audio = { | ||
| readonly type: "audio"; | ||
| readonly audio: { | ||
| /** Location of audio data */ | ||
| url: string; | ||
| /** MIME type */ | ||
| mimeType: string; | ||
| /** [Optional] Caption */ | ||
| caption?: string; | ||
| /** [Optional] transcript of the audio */ | ||
| transcript?: string; | ||
| }; | ||
| }; | ||
| export type Buttons = { | ||
| readonly type: "buttons"; | ||
| /** The content of the message */ | ||
| readonly text: string; | ||
| readonly buttons: { | ||
| text: string; | ||
| actions: Action[]; | ||
| }; | ||
| }; | ||
| export type Custom = { | ||
| readonly type: "custom"; | ||
| readonly schema: string; | ||
| readonly custom: any; | ||
| }; | ||
| export type Document = { | ||
| readonly type: "document"; | ||
| readonly document: { | ||
| /** Location of document data */ | ||
| url: string; | ||
| /** MIME type */ | ||
| mimeType: string; | ||
| /** [Optional] Caption */ | ||
| caption?: string; | ||
| /** [Optional] Name for the file on the device. */ | ||
| filename?: string; | ||
| /** [Optional] description of the document */ | ||
| description?: string; | ||
| }; | ||
| }; | ||
| export type Image = { | ||
@@ -14,15 +70,71 @@ readonly type: "image"; | ||
| url: string; | ||
| /** MIME type */ | ||
| mimeType: string; | ||
| /** [Optional] Caption */ | ||
| caption?: string; | ||
| /** [Optional] Image description */ | ||
| description?: string; | ||
| }; | ||
| }; | ||
| export type Audio = { | ||
| readonly type: "audio"; | ||
| readonly audio: { | ||
| /** Location of audio data */ | ||
| export type Location = { | ||
| readonly type: "location"; | ||
| readonly location: { | ||
| /** Longitude of the location. */ | ||
| longitude: number; | ||
| /** Latitude of the location. */ | ||
| latitude: number; | ||
| /** Name of the location. */ | ||
| name?: string; | ||
| /** Address of the location. */ | ||
| address?: string; | ||
| }; | ||
| }; | ||
| export type Menu = { | ||
| readonly type: "menu"; | ||
| /** The content of the message */ | ||
| readonly menu: { | ||
| title: string; | ||
| text: string; | ||
| sections: Array<{ | ||
| title?: string; | ||
| actions: Action[]; | ||
| }>; | ||
| }; | ||
| }; | ||
| export type Reaction = { | ||
| readonly type: "reaction"; | ||
| readonly reaction: { | ||
| /** The ID of the message the customer reacted to. */ | ||
| replyTo: string; | ||
| /** The emoji the customer reacted with. */ | ||
| emoji: string; | ||
| }; | ||
| }; | ||
| export type Select = { | ||
| readonly type: "select"; | ||
| readonly select: Action; | ||
| }; | ||
| export type Text = { | ||
| readonly type: "text"; | ||
| /** The content of the message */ | ||
| readonly text: string; | ||
| }; | ||
| export type Video = { | ||
| readonly type: "video"; | ||
| readonly video: { | ||
| /** Location of video data */ | ||
| url: string; | ||
| /** [Optional] transcript of the audio */ | ||
| /** MIME type */ | ||
| mimeType: string; | ||
| /** [Optional] Caption */ | ||
| caption?: string; | ||
| /** [Optional] transcript of the video */ | ||
| transcript?: string; | ||
| }; | ||
| }; |
+4
-0
@@ -15,2 +15,6 @@ /** | ||
| * @property {Dispatch} dispatch Registers the application as dispatcher | ||
| * @property {import("@chatally/logger").Logger | boolean | undefined} log | ||
| * The logger to use during runtime. Set this explicitly to false or | ||
| * NoLogger, if the registered server shall not log, otherwise the | ||
| * application will register a child logger | ||
| * @property {() => void} listen Starts the server | ||
@@ -17,0 +21,0 @@ */ |
+45
-4
@@ -7,9 +7,50 @@ /** | ||
| switch (msg.type) { | ||
| case "audio": | ||
| return ( | ||
| msg.audio.transcript || | ||
| msg.audio.caption || | ||
| `audio: ${msg.audio.url} (${msg.audio.mimeType})` | ||
| ); | ||
| case "buttons": | ||
| return ( | ||
| msg.buttons.text || | ||
| msg.buttons.actions.map((a) => a.title).join(", ") || | ||
| "<buttons>" | ||
| ); | ||
| case "custom": | ||
| return "custom:" + JSON.stringify(msg.custom); | ||
| case "document": | ||
| return ( | ||
| msg.document.description || | ||
| msg.document.caption || | ||
| msg.document.filename || | ||
| "<document>" | ||
| ); | ||
| case "image": | ||
| return ( | ||
| msg.image.description || | ||
| msg.image.caption || | ||
| `image: ${msg.image.url} (${msg.image.mimeType}))` | ||
| ); | ||
| case "location": | ||
| return ( | ||
| msg.location.name || | ||
| msg.location.address || | ||
| `location: lon ${msg.location.longitude} lat ${msg.location.latitude}` | ||
| ); | ||
| case "menu": | ||
| return `${msg.menu.title}: ${msg.menu.text}`; | ||
| case "reaction": | ||
| return msg.reaction.emoji; | ||
| case "select": | ||
| return `${msg.select.id}: ${msg.select.title}`; | ||
| case "text": | ||
| return msg.text; | ||
| case "image": | ||
| return msg.image.caption || "<image>"; | ||
| case "audio": | ||
| return msg.audio.transcript || "<audio>"; | ||
| case "video": | ||
| return ( | ||
| msg.video.transcript || | ||
| msg.video.caption || | ||
| `video: ${msg.video.url} (${msg.video.mimeType})` | ||
| ); | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "@chatally/core", | ||
| "version": "0.0.5", | ||
| "version": "0.0.6", | ||
| "description": "ChatAlly Core Modules", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
23844
20.64%741
26.02%