@dotbots-boutique/server-sdk 0.5.1 → 0.5.3

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.
Files changed (2) hide show
  1. package/dist/client.js +32 -6
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -109,16 +109,42 @@ class DotBotsBackend {
109
109
  return (await response.json());
110
110
  }
111
111
  async sendNotification(request) {
112
- const response = await fetch(`${this.getProxyUrl()}/notifications/send`, {
112
+ const url = 'https://dotnotifications-dotbots-api.apps.dotbots.boutique/notifications/send';
113
+ const body = JSON.stringify(request);
114
+ console.log(JSON.stringify({
115
+ level: 'info',
116
+ message: `[DotBotsBackend] sendNotification → ${url}`,
117
+ code: request.code,
118
+ userExternalId: request.userExternalId,
119
+ userOrganisationExternalId: request.userOrganisationExternalId,
120
+ language: request.language,
121
+ important: request.important,
122
+ parameterKeys: request.parameters ? Object.keys(request.parameters) : [],
123
+ }));
124
+ const response = await fetch(url, {
113
125
  method: 'POST',
114
- headers: this.baseHeaders(),
115
- body: JSON.stringify(request),
126
+ headers: { 'Content-Type': 'application/json' },
127
+ body,
116
128
  });
117
129
  if (!response.ok) {
118
- const body = (await response.json().catch(() => ({})));
119
- throw new errors_1.DotBotsBackendError(body.error ?? 'NOTIFICATION_FAILED', response.status);
130
+ const responseBody = (await response.json().catch(() => ({})));
131
+ console.log(JSON.stringify({
132
+ level: 'error',
133
+ message: `[DotBotsBackend] sendNotification failed`,
134
+ status: response.status,
135
+ error: responseBody.error,
136
+ }));
137
+ throw new errors_1.DotBotsBackendError(responseBody.error ?? 'NOTIFICATION_FAILED', response.status);
120
138
  }
121
- return (await response.json());
139
+ const result = (await response.json());
140
+ console.log(JSON.stringify({
141
+ level: 'info',
142
+ message: `[DotBotsBackend] sendNotification OK`,
143
+ id: result.id,
144
+ type: result.type,
145
+ status: result.status,
146
+ }));
147
+ return result;
122
148
  }
123
149
  baseHeaders() {
124
150
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbots-boutique/server-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "DotBots Backend SDK — server-side AI calls, payments, and user lookups via the DotBots proxy",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",