@lssm-tech/integration.builder-whatsapp 0.2.11 → 2.0.2

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # @contractspec/integration.builder-whatsapp
1
+ # @lssm-tech/integration.builder-whatsapp
2
2
 
3
3
  Meta and Twilio WhatsApp normalization for Builder control-channel workflows.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "license": "MIT",
2
3
  "name": "@lssm-tech/integration.builder-whatsapp",
3
- "version": "0.2.11",
4
+ "version": "2.0.2",
4
5
  "description": "WhatsApp Builder control-channel integration.",
5
6
  "keywords": [
6
7
  "contractspec",
@@ -11,13 +12,12 @@
11
12
  "type": "module",
12
13
  "types": "./dist/index.d.ts",
13
14
  "files": [
14
- "dist",
15
- "README.md"
15
+ "package.json"
16
16
  ],
17
17
  "scripts": {
18
18
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
19
19
  "publish:pkg:canary": "bun publish:pkg --tag canary",
20
- "build": "bun run build:bundle && bun run build:types",
20
+ "build": "contractspec-bun-build build",
21
21
  "build:bundle": "contractspec-bun-build transpile",
22
22
  "build:types": "contractspec-bun-build types",
23
23
  "dev": "contractspec-bun-build dev",
@@ -27,7 +27,7 @@
27
27
  "lint:check": "node ../../../scripts/biome.cjs check .",
28
28
  "test": "bun test",
29
29
  "prebuild": "contractspec-bun-build prebuild",
30
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsgo --noEmit"
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
@@ -35,26 +35,20 @@
35
35
  "directory": "packages/integrations/builder-whatsapp"
36
36
  },
37
37
  "dependencies": {
38
- "@contractspec/lib.builder-spec": "0.2.11",
39
- "@contractspec/lib.builder-runtime": "0.2.11",
40
- "@contractspec/lib.provider-spec": "0.2.9",
41
- "@contractspec/integration.runtime": "3.10.1",
42
- "@contractspec/lib.contracts-integrations": "3.10.0",
43
- "@contractspec/lib.schema": "3.7.14"
38
+ "@lssm-tech/lib.builder-spec": "workspace:^",
39
+ "@lssm-tech/lib.builder-runtime": "workspace:^",
40
+ "@lssm-tech/lib.provider-spec": "workspace:^",
41
+ "@lssm-tech/integration.runtime": "workspace:^",
42
+ "@lssm-tech/lib.contracts-integrations": "workspace:^",
43
+ "@lssm-tech/lib.schema": "workspace:^"
44
44
  },
45
45
  "devDependencies": {
46
- "@contractspec/tool.bun": "3.7.18",
47
- "@contractspec/tool.typescript": "3.7.13",
48
- "typescript": "^5.9.3"
46
+ "@lssm-tech/tool.bun": "workspace:*",
47
+ "@lssm-tech/tool.typescript": "workspace:*",
48
+ "typescript": "catalog:"
49
49
  },
50
50
  "exports": {
51
- ".": {
52
- "types": "./dist/index.d.ts",
53
- "browser": "./dist/browser/index.js",
54
- "bun": "./dist/index.js",
55
- "node": "./dist/node/index.js",
56
- "default": "./dist/index.js"
57
- }
51
+ ".": "./src/index.ts"
58
52
  },
59
53
  "publishConfig": {
60
54
  "access": "public",
@@ -68,5 +62,73 @@
68
62
  "default": "./dist/index.js"
69
63
  }
70
64
  }
65
+ },
66
+ "contractspec": {
67
+ "catalog": {
68
+ "family": "ui",
69
+ "kind": "integration",
70
+ "status": "active",
71
+ "adoptionMode": "adoptable",
72
+ "stability": "experimental",
73
+ "platforms": [
74
+ "server"
75
+ ],
76
+ "runtimes": [
77
+ "node"
78
+ ],
79
+ "entrypoints": [
80
+ "."
81
+ ],
82
+ "documentation": [
83
+ {
84
+ "title": "Integration Builder Whatsapp documentation",
85
+ "url": "https://www.npmjs.com/package/%40lssm-tech%2Fintegration.builder-whatsapp",
86
+ "kind": "readme"
87
+ }
88
+ ],
89
+ "examples": [],
90
+ "replacements": [],
91
+ "capabilities": [
92
+ {
93
+ "id": "package.lssm.tech.integration.builder.whatsapp",
94
+ "title": "Integration Builder Whatsapp",
95
+ "description": "WhatsApp Builder control-channel integration.",
96
+ "status": "active",
97
+ "useCases": [
98
+ "Adopt whatsapp builder control-channel integration"
99
+ ],
100
+ "aliases": [
101
+ "contractspec",
102
+ "builder",
103
+ "whatsapp",
104
+ "integration"
105
+ ],
106
+ "pythonEquivalents": [],
107
+ "canonicalImports": [
108
+ {
109
+ "from": "@lssm-tech/integration.builder-whatsapp",
110
+ "symbols": []
111
+ }
112
+ ],
113
+ "constraints": {
114
+ "platforms": [
115
+ "server"
116
+ ],
117
+ "runtimes": [
118
+ "node"
119
+ ],
120
+ "avoidWhen": [
121
+ "The @lssm-tech/integration.builder-whatsapp package constraints do not match the target runtime or platform."
122
+ ],
123
+ "requires": [
124
+ "TypeScript"
125
+ ]
126
+ },
127
+ "alternatives": [],
128
+ "relationships": [],
129
+ "resolutionPriority": 50
130
+ }
131
+ ]
132
+ }
71
133
  }
72
134
  }
@@ -1 +0,0 @@
1
- import{parseMetaWebhookPayload as B,parseTwilioFormPayload as N,verifyMetaSignature as x,verifyTwilioSignature as S}from"@contractspec/integration.runtime/channel";import{defineIntegration as $}from"@contractspec/lib.contracts-integrations";import{defineSchemaModel as Z}from"@contractspec/lib.schema";var z=Z({name:"BuilderWhatsappIntegrationConfig",description:"Managed configuration for @contractspec/integration.builder-whatsapp.",fields:{}}),F=Z({name:"BuilderWhatsappIntegrationSecret",description:"Secret material for @contractspec/integration.builder-whatsapp.",fields:{}}),P=$({meta:{...{key:"integrations.builder-whatsapp",version:"1.0.0",title:"Builder Whatsapp",description:"WhatsApp Builder control-channel integration.",domain:"builder-whatsapp",owners:["@contractspec-core"],tags:["package","integrations","builder-whatsapp"],stability:"experimental"},category:"custom"},supportedModes:["managed"],capabilities:{provides:[]},configSchema:{schema:z,example:{}},secretSchema:{schema:F,example:{}},healthCheck:{method:"ping",timeoutMs:5000}});function O(j){return j&&typeof j==="object"?j:null}function K(j,E,G,D,A){let C=typeof A.from==="string"?A.from:void 0,q=typeof A.id==="string"?A.id:void 0;if(!C||!q)return null;let L=O(A.text)?.body,Q=O(A.interactive),V=typeof Q?.type==="string"?Q.type:void 0,H=O(Q?.button_reply),J=O(Q?.list_reply),U=O(A.audio),X=O(A.document),Y=O(A.image),_=U?"voice":H?"button":J?"list_selection":"text";return{workspaceId:j,conversationId:E,channelType:"whatsapp",eventType:`whatsapp.meta.${typeof A.type==="string"?A.type:"message"}`,externalEventId:q,externalConversationId:C,externalChannelId:D,externalMessageId:q,participantBindingId:G,externalIdentityRef:C,externalUserId:C,messageKind:_,text:typeof L==="string"?L:typeof H?.title==="string"?H.title:typeof J?.title==="string"?J.title:void 0,interactiveSelection:H&&typeof H.id==="string"?{selectionType:"button",selectionId:H.id,label:typeof H.title==="string"?H.title:void 0,payload:{interactiveType:V}}:J&&typeof J.id==="string"?{selectionType:"list_selection",selectionId:J.id,label:typeof J.title==="string"?J.title:void 0,payload:{interactiveType:V}}:void 0,metadata:{phoneNumberId:D??"",audioId:typeof U?.id==="string"?U.id:"",documentId:typeof X?.id==="string"?X.id:"",imageId:typeof Y?.id==="string"?Y.id:""}}}function f(j){let E=[];for(let G of j.payload.entry??[])for(let D of G.changes??[]){let A=D.value;if(!A)continue;let C=A.metadata?.phone_number_id;for(let q of A.messages??[]){let L=K(j.workspaceId,j.conversationId,j.participantBindingId,C,q);if(L)E.push(L)}for(let q of A.statuses??[]){if(!q.id)continue;E.push({workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.meta.status",externalEventId:q.id,externalConversationId:q.recipient_id??q.id,externalChannelId:C,externalMessageId:q.id,participantBindingId:j.participantBindingId,externalIdentityRef:q.recipient_id??void 0,externalUserId:q.recipient_id??void 0,messageKind:"system",statusEvent:{status:q.status??"unknown",providerMessageId:q.id},text:`status ${q.status??"unknown"}`})}}return E}function h(j){let E=j.formBody.get("MessageSid"),G=j.formBody.get("From");if(!E||!G)return null;let D=j.formBody.get("ButtonText"),A=j.formBody.get("ButtonPayload"),C=j.formBody.get("ListTitle")??j.formBody.get("ListSelection"),q=j.formBody.get("MediaContentType0"),L=D?"button":C?"list_selection":q?.startsWith("audio/")?"voice":"text";return{workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.twilio.message",externalEventId:E,externalConversationId:G,externalChannelId:j.formBody.get("To")??void 0,externalMessageId:E,participantBindingId:j.participantBindingId,externalIdentityRef:G,externalUserId:G,messageKind:L,text:D??C??j.formBody.get("Body")??(q?`media ${q}`:void 0)??"",interactiveSelection:D?{selectionType:"button",selectionId:A??D,label:D}:C?{selectionType:"list_selection",selectionId:C,label:C}:void 0,metadata:{accountSid:j.formBody.get("AccountSid")??"",profileName:j.formBody.get("ProfileName")??"",mediaContentType0:q??"",mediaUrl0:j.formBody.get("MediaUrl0")??""}}}export{S as verifyTwilioSignature,x as verifyMetaSignature,N as parseTwilioFormPayload,B as parseMetaWebhookPayload,h as normalizeBuilderTwilioWhatsappEnvelope,f as normalizeBuilderMetaWhatsappEnvelopes,P as BuilderWhatsappIntegrationSpec};
package/dist/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { type MetaWhatsappWebhookPayload, parseMetaWebhookPayload, parseTwilioFormPayload, verifyMetaSignature, verifyTwilioSignature } from '@contractspec/integration.runtime/channel';
2
- import type { BuilderChannelInboundEnvelope } from '@contractspec/lib.builder-runtime';
3
- export { type MetaWhatsappWebhookPayload, parseMetaWebhookPayload, parseTwilioFormPayload, verifyMetaSignature, verifyTwilioSignature, };
4
- export declare function normalizeBuilderMetaWhatsappEnvelopes(input: {
5
- workspaceId: string;
6
- conversationId: string;
7
- payload: MetaWhatsappWebhookPayload;
8
- rawBody?: string;
9
- traceId?: string;
10
- participantBindingId?: string;
11
- }): BuilderChannelInboundEnvelope[];
12
- export declare function normalizeBuilderTwilioWhatsappEnvelope(input: {
13
- workspaceId: string;
14
- conversationId: string;
15
- formBody: URLSearchParams;
16
- rawBody?: string;
17
- traceId?: string;
18
- participantBindingId?: string;
19
- }): BuilderChannelInboundEnvelope | null;
20
- export * from './integration';
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{parseMetaWebhookPayload as B,parseTwilioFormPayload as N,verifyMetaSignature as x,verifyTwilioSignature as S}from"@contractspec/integration.runtime/channel";import{defineIntegration as $}from"@contractspec/lib.contracts-integrations";import{defineSchemaModel as Z}from"@contractspec/lib.schema";var z=Z({name:"BuilderWhatsappIntegrationConfig",description:"Managed configuration for @contractspec/integration.builder-whatsapp.",fields:{}}),F=Z({name:"BuilderWhatsappIntegrationSecret",description:"Secret material for @contractspec/integration.builder-whatsapp.",fields:{}}),P=$({meta:{...{key:"integrations.builder-whatsapp",version:"1.0.0",title:"Builder Whatsapp",description:"WhatsApp Builder control-channel integration.",domain:"builder-whatsapp",owners:["@contractspec-core"],tags:["package","integrations","builder-whatsapp"],stability:"experimental"},category:"custom"},supportedModes:["managed"],capabilities:{provides:[]},configSchema:{schema:z,example:{}},secretSchema:{schema:F,example:{}},healthCheck:{method:"ping",timeoutMs:5000}});function O(j){return j&&typeof j==="object"?j:null}function K(j,E,G,D,A){let C=typeof A.from==="string"?A.from:void 0,q=typeof A.id==="string"?A.id:void 0;if(!C||!q)return null;let L=O(A.text)?.body,Q=O(A.interactive),V=typeof Q?.type==="string"?Q.type:void 0,H=O(Q?.button_reply),J=O(Q?.list_reply),U=O(A.audio),X=O(A.document),Y=O(A.image),_=U?"voice":H?"button":J?"list_selection":"text";return{workspaceId:j,conversationId:E,channelType:"whatsapp",eventType:`whatsapp.meta.${typeof A.type==="string"?A.type:"message"}`,externalEventId:q,externalConversationId:C,externalChannelId:D,externalMessageId:q,participantBindingId:G,externalIdentityRef:C,externalUserId:C,messageKind:_,text:typeof L==="string"?L:typeof H?.title==="string"?H.title:typeof J?.title==="string"?J.title:void 0,interactiveSelection:H&&typeof H.id==="string"?{selectionType:"button",selectionId:H.id,label:typeof H.title==="string"?H.title:void 0,payload:{interactiveType:V}}:J&&typeof J.id==="string"?{selectionType:"list_selection",selectionId:J.id,label:typeof J.title==="string"?J.title:void 0,payload:{interactiveType:V}}:void 0,metadata:{phoneNumberId:D??"",audioId:typeof U?.id==="string"?U.id:"",documentId:typeof X?.id==="string"?X.id:"",imageId:typeof Y?.id==="string"?Y.id:""}}}function f(j){let E=[];for(let G of j.payload.entry??[])for(let D of G.changes??[]){let A=D.value;if(!A)continue;let C=A.metadata?.phone_number_id;for(let q of A.messages??[]){let L=K(j.workspaceId,j.conversationId,j.participantBindingId,C,q);if(L)E.push(L)}for(let q of A.statuses??[]){if(!q.id)continue;E.push({workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.meta.status",externalEventId:q.id,externalConversationId:q.recipient_id??q.id,externalChannelId:C,externalMessageId:q.id,participantBindingId:j.participantBindingId,externalIdentityRef:q.recipient_id??void 0,externalUserId:q.recipient_id??void 0,messageKind:"system",statusEvent:{status:q.status??"unknown",providerMessageId:q.id},text:`status ${q.status??"unknown"}`})}}return E}function h(j){let E=j.formBody.get("MessageSid"),G=j.formBody.get("From");if(!E||!G)return null;let D=j.formBody.get("ButtonText"),A=j.formBody.get("ButtonPayload"),C=j.formBody.get("ListTitle")??j.formBody.get("ListSelection"),q=j.formBody.get("MediaContentType0"),L=D?"button":C?"list_selection":q?.startsWith("audio/")?"voice":"text";return{workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.twilio.message",externalEventId:E,externalConversationId:G,externalChannelId:j.formBody.get("To")??void 0,externalMessageId:E,participantBindingId:j.participantBindingId,externalIdentityRef:G,externalUserId:G,messageKind:L,text:D??C??j.formBody.get("Body")??(q?`media ${q}`:void 0)??"",interactiveSelection:D?{selectionType:"button",selectionId:A??D,label:D}:C?{selectionType:"list_selection",selectionId:C,label:C}:void 0,metadata:{accountSid:j.formBody.get("AccountSid")??"",profileName:j.formBody.get("ProfileName")??"",mediaContentType0:q??"",mediaUrl0:j.formBody.get("MediaUrl0")??""}}}export{S as verifyTwilioSignature,x as verifyMetaSignature,N as parseTwilioFormPayload,B as parseMetaWebhookPayload,h as normalizeBuilderTwilioWhatsappEnvelope,f as normalizeBuilderMetaWhatsappEnvelopes,P as BuilderWhatsappIntegrationSpec};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const BuilderWhatsappIntegrationSpec: import("@contractspec/lib.contracts-integrations").IntegrationSpec;
@@ -1 +0,0 @@
1
- import{parseMetaWebhookPayload as B,parseTwilioFormPayload as N,verifyMetaSignature as x,verifyTwilioSignature as S}from"@contractspec/integration.runtime/channel";import{defineIntegration as $}from"@contractspec/lib.contracts-integrations";import{defineSchemaModel as Z}from"@contractspec/lib.schema";var z=Z({name:"BuilderWhatsappIntegrationConfig",description:"Managed configuration for @contractspec/integration.builder-whatsapp.",fields:{}}),F=Z({name:"BuilderWhatsappIntegrationSecret",description:"Secret material for @contractspec/integration.builder-whatsapp.",fields:{}}),P=$({meta:{...{key:"integrations.builder-whatsapp",version:"1.0.0",title:"Builder Whatsapp",description:"WhatsApp Builder control-channel integration.",domain:"builder-whatsapp",owners:["@contractspec-core"],tags:["package","integrations","builder-whatsapp"],stability:"experimental"},category:"custom"},supportedModes:["managed"],capabilities:{provides:[]},configSchema:{schema:z,example:{}},secretSchema:{schema:F,example:{}},healthCheck:{method:"ping",timeoutMs:5000}});function O(j){return j&&typeof j==="object"?j:null}function K(j,E,G,D,A){let C=typeof A.from==="string"?A.from:void 0,q=typeof A.id==="string"?A.id:void 0;if(!C||!q)return null;let L=O(A.text)?.body,Q=O(A.interactive),V=typeof Q?.type==="string"?Q.type:void 0,H=O(Q?.button_reply),J=O(Q?.list_reply),U=O(A.audio),X=O(A.document),Y=O(A.image),_=U?"voice":H?"button":J?"list_selection":"text";return{workspaceId:j,conversationId:E,channelType:"whatsapp",eventType:`whatsapp.meta.${typeof A.type==="string"?A.type:"message"}`,externalEventId:q,externalConversationId:C,externalChannelId:D,externalMessageId:q,participantBindingId:G,externalIdentityRef:C,externalUserId:C,messageKind:_,text:typeof L==="string"?L:typeof H?.title==="string"?H.title:typeof J?.title==="string"?J.title:void 0,interactiveSelection:H&&typeof H.id==="string"?{selectionType:"button",selectionId:H.id,label:typeof H.title==="string"?H.title:void 0,payload:{interactiveType:V}}:J&&typeof J.id==="string"?{selectionType:"list_selection",selectionId:J.id,label:typeof J.title==="string"?J.title:void 0,payload:{interactiveType:V}}:void 0,metadata:{phoneNumberId:D??"",audioId:typeof U?.id==="string"?U.id:"",documentId:typeof X?.id==="string"?X.id:"",imageId:typeof Y?.id==="string"?Y.id:""}}}function f(j){let E=[];for(let G of j.payload.entry??[])for(let D of G.changes??[]){let A=D.value;if(!A)continue;let C=A.metadata?.phone_number_id;for(let q of A.messages??[]){let L=K(j.workspaceId,j.conversationId,j.participantBindingId,C,q);if(L)E.push(L)}for(let q of A.statuses??[]){if(!q.id)continue;E.push({workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.meta.status",externalEventId:q.id,externalConversationId:q.recipient_id??q.id,externalChannelId:C,externalMessageId:q.id,participantBindingId:j.participantBindingId,externalIdentityRef:q.recipient_id??void 0,externalUserId:q.recipient_id??void 0,messageKind:"system",statusEvent:{status:q.status??"unknown",providerMessageId:q.id},text:`status ${q.status??"unknown"}`})}}return E}function h(j){let E=j.formBody.get("MessageSid"),G=j.formBody.get("From");if(!E||!G)return null;let D=j.formBody.get("ButtonText"),A=j.formBody.get("ButtonPayload"),C=j.formBody.get("ListTitle")??j.formBody.get("ListSelection"),q=j.formBody.get("MediaContentType0"),L=D?"button":C?"list_selection":q?.startsWith("audio/")?"voice":"text";return{workspaceId:j.workspaceId,conversationId:j.conversationId,channelType:"whatsapp",eventType:"whatsapp.twilio.message",externalEventId:E,externalConversationId:G,externalChannelId:j.formBody.get("To")??void 0,externalMessageId:E,participantBindingId:j.participantBindingId,externalIdentityRef:G,externalUserId:G,messageKind:L,text:D??C??j.formBody.get("Body")??(q?`media ${q}`:void 0)??"",interactiveSelection:D?{selectionType:"button",selectionId:A??D,label:D}:C?{selectionType:"list_selection",selectionId:C,label:C}:void 0,metadata:{accountSid:j.formBody.get("AccountSid")??"",profileName:j.formBody.get("ProfileName")??"",mediaContentType0:q??"",mediaUrl0:j.formBody.get("MediaUrl0")??""}}}export{S as verifyTwilioSignature,x as verifyMetaSignature,N as parseTwilioFormPayload,B as parseMetaWebhookPayload,h as normalizeBuilderTwilioWhatsappEnvelope,f as normalizeBuilderMetaWhatsappEnvelopes,P as BuilderWhatsappIntegrationSpec};