@serve.zone/platformclient 1.1.4 → 1.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serve.zone/platformclient",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "description": "a module that makes it really easy to use the serve.zone platform inside your app",
6
6
  "main": "dist_ts/index.js",
@@ -9,29 +9,30 @@
9
9
  "author": "Task Venture Capital GmbH",
10
10
  "license": "MIT",
11
11
  "devDependencies": {
12
- "@git.zone/tsbuild": "^4.4.0",
13
- "@git.zone/tsbundle": "^2.10.0",
14
- "@git.zone/tsrun": "^2.0.2",
15
- "@git.zone/tstest": "^3.6.3",
16
- "@types/node": "^25.6.0"
12
+ "@git.zone/tsbuild": "^4.4.2",
13
+ "@git.zone/tsbundle": "^2.11.0",
14
+ "@git.zone/tsrun": "^2.0.4",
15
+ "@git.zone/tstest": "^3.6.6",
16
+ "@types/node": "^25.9.1"
17
17
  },
18
18
  "dependencies": {
19
19
  "@api.global/typedrequest": "^3.3.0",
20
- "@api.global/typedserver": "^8.4.6",
20
+ "@api.global/typedserver": "^8.5.3",
21
21
  "@api.global/typedsocket": "^4.1.2",
22
- "@push.rocks/qenv": "^6.1.3",
22
+ "@push.rocks/qenv": "^6.1.4",
23
23
  "@push.rocks/smartlog": "^3.2.2",
24
- "@push.rocks/smartntml": "^2.0.8",
25
- "@serve.zone/interfaces": "^5.4.5"
24
+ "@push.rocks/smartntml": "^2.0.9",
25
+ "@push.rocks/smartsmtp": "^3.1.0",
26
+ "@serve.zone/interfaces": "^7.27.0"
26
27
  },
27
28
  "repository": {
28
29
  "type": "git",
29
- "url": "git+https://gitlab.com/serve.zone/platformclient.git"
30
+ "url": "git+https://code.foss.global/serve.zone/platformclient.git"
30
31
  },
31
32
  "bugs": {
32
- "url": "https://gitlab.com/serve.zone/platformclient/issues"
33
+ "url": "https://code.foss.global/serve.zone/platformclient/issues"
33
34
  },
34
- "homepage": "https://gitlab.com/serve.zone/platformclient#readme",
35
+ "homepage": "https://code.foss.global/serve.zone/platformclient#readme",
35
36
  "browserslist": [
36
37
  "last 1 chrome versions"
37
38
  ],
package/readme.md CHANGED
@@ -1,78 +1,85 @@
1
1
  # @serve.zone/platformclient
2
2
 
3
- `@serve.zone/platformclient` is the TypeScript SDK for talking to serve.zone platform services from application code. It wraps the serve.zone TypedSocket API and exposes focused connectors for transactional email, SMS, push notifications, and physical letters.
4
-
5
- Use it when your app should trigger serve.zone communication workflows without manually wiring TypedRequest methods or transport setup.
3
+ `@serve.zone/platformclient` is the application SDK for serve.zone platform services. It opens a TypedSocket connection to a platform endpoint and gives application code focused connectors for transactional email, SMS, push notifications, and physical letters without hand-writing TypedRequest setup.
6
4
 
7
5
  ## Issue Reporting and Security
8
6
 
9
7
  For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
10
8
 
11
- ## Installation
9
+ ## Install
12
10
 
13
11
  ```bash
14
12
  pnpm add @serve.zone/platformclient
15
13
  ```
16
14
 
17
- ## What It Does
18
-
19
- `SzPlatformClient` handles the shared serve.zone platform connection and gives you these connectors:
20
-
21
- | Connector | Purpose | TypedRequest method |
22
- | --- | --- | --- |
23
- | `emailConnector` | Send transactional email | `sendEmail` |
24
- | `smsConnector` | Send SMS messages and verification codes | `sendSms`, `sendVerificationCode` |
25
- | `pushNotificationConnector` | Send push notifications | `sendPushNotification` |
26
- | `letterConnector` | Send physical letters through the platform | `sendLetter` |
27
-
28
- Requests use the types from `@serve.zone/interfaces`, so payloads stay aligned with the serve.zone backend contracts.
29
-
30
15
  ## Quick Start
31
16
 
32
17
  ```typescript
33
18
  import { SzPlatformClient } from '@serve.zone/platformclient';
34
19
 
35
- const platformClient = new SzPlatformClient(process.env.SERVEZONE_PLATFORM_AUTHORIZATION);
20
+ const platformClient = new SzPlatformClient({
21
+ token: process.env.SERVEZONE_PLATFORM_TOKEN,
22
+ platformUrl: process.env.SERVEZONE_PLATFORM_URL,
23
+ });
24
+
36
25
  await platformClient.init();
37
26
 
38
27
  await platformClient.emailConnector.sendEmail({
39
28
  to: 'user@example.com',
40
- from: 'hello@serve.zone',
41
- title: 'Welcome to the platform',
42
- body: 'Your workspace is ready.',
29
+ from: 'hello@example.com',
30
+ title: 'Workspace ready',
31
+ body: 'Your serve.zone workspace is ready.',
43
32
  });
44
33
  ```
45
34
 
46
- The client connects to the platform endpoint configured through `SERVEZONE_PLATFORM_URL` or a runtime platform binding.
35
+ ## Connectors
36
+
37
+ `SzPlatformClient` owns the shared connection and exposes connector instances:
38
+
39
+ | Connector | Main methods | Platform capability |
40
+ | --- | --- | --- |
41
+ | `emailConnector` | `getServiceMailStatus()`, `getServiceMailCredentials()`, `sendMail()`, `sendText()`, `sendHtml()`, `normalizeInboundMessage()`, `handleInboundPayload()`, `createInboundHandler()`, `sendEmail()` | `email` |
42
+ | `smsConnector` | `sendSms()`, `sendSmsVerifcation()` | `sms` |
43
+ | `pushNotificationConnector` | `sendPushNotification()` | `pushnotification` |
44
+ | `letterConnector` | `sendLetter()` | `letter` |
45
+
46
+ The request and response payloads come from `@serve.zone/interfaces`, so TypeScript stays aligned with the serve.zone platform contracts.
47
47
 
48
48
  ## Configuration
49
49
 
50
- The client needs two values:
50
+ The client needs an authorization string and a platform endpoint. You can provide both directly, through environment variables, or through platform bindings.
51
51
 
52
- | Value | How to provide it | Notes |
53
- | --- | --- | --- |
54
- | Authorization token | Constructor argument, `init()` argument, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, or binding credential env | Loaded on demand through `@push.rocks/qenv`. |
55
- | Platform URL | Constructor options, `SERVEZONE_PLATFORM_URL`, or binding endpoint | Loaded on demand through `@push.rocks/qenv`. |
56
- | Runtime bindings | Constructor options, `SERVEZONE_PLATFORM_BINDING`, or `SERVEZONE_PLATFORM_BINDINGS` | Values are JSON-encoded `IPlatformBinding` objects from `@serve.zone/interfaces`. |
52
+ | Value | Sources |
53
+ | --- | --- |
54
+ | Authorization | Constructor string, `authorizationString`, `authorization`, `token`, `init()` argument, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, or binding credentials. |
55
+ | Platform URL | `url`, `platformUrl`, `SERVEZONE_PLATFORM_URL`, or the first active binding endpoint using `typedrequest` or `http`. |
56
+ | Platform bindings | Constructor `binding` or `bindings`, `SERVEZONE_PLATFORM_BINDING`, or `SERVEZONE_PLATFORM_BINDINGS`. |
57
+
58
+ Binding environment variables must contain JSON encoded `IPlatformBinding` objects from `@serve.zone/interfaces`.
59
+
60
+ Service mail credentials can be provided directly as environment variables or through `email` platform binding credentials. The default sender uses `MAIL_FROM`, `SMTP_HOST`, `SMTP_PORT`, `SMTP_TLS_MODE`, `SMTP_USERNAME`, and `SMTP_PASSWORD`. Additional configured sender addresses use scoped variables such as `MAIL_TEST_SERVICE_GATED_ONE_FROM` and `MAIL_TEST_SERVICE_GATED_ONE_SMTP_USERNAME`.
57
61
 
58
62
  ```typescript
59
- const client = new SzPlatformClient();
60
- await client.init('your-platform-authorization-token');
61
- ```
63
+ import { SzPlatformClient } from '@serve.zone/platformclient';
62
64
 
63
- Constructor and `init()` also accept options:
65
+ const client = new SzPlatformClient(process.env.SERVEZONE_PLATFORM_AUTHORIZATION);
66
+ await client.init();
67
+ ```
64
68
 
65
69
  ```typescript
70
+ import { SzPlatformClient } from '@serve.zone/platformclient';
71
+
66
72
  const client = new SzPlatformClient({
67
- token: process.env.SERVEZONE_PLATFORM_TOKEN,
68
- platformUrl: process.env.SERVEZONE_PLATFORM_URL,
73
+ authorization: process.env.SERVEZONE_PLATFORM_AUTHORIZATION,
74
+ url: process.env.SERVEZONE_PLATFORM_URL,
69
75
  });
76
+
70
77
  await client.init();
71
78
  ```
72
79
 
73
80
  ## Debug Mode
74
81
 
75
- Pass `test` as the authorization string to enable debug mode. In debug mode, the client does not open a TypedSocket connection and connector methods log or return deterministic test values instead of sending real platform requests.
82
+ Pass `test` as the authorization string to activate debug mode. In debug mode, the client does not open a TypedSocket connection. Connector methods log or return deterministic test values instead of sending real platform requests.
76
83
 
77
84
  ```typescript
78
85
  const client = new SzPlatformClient('test');
@@ -80,7 +87,7 @@ await client.init();
80
87
 
81
88
  await client.emailConnector.sendEmail({
82
89
  to: 'developer@example.com',
83
- from: 'hello@serve.zone',
90
+ from: 'hello@example.com',
84
91
  title: 'Preview only',
85
92
  body: 'This message is logged, not sent.',
86
93
  });
@@ -89,42 +96,70 @@ const verificationCode = await client.smsConnector.sendSmsVerifcation({
89
96
  toNumber: 491234567890,
90
97
  fromName: 'ServeZone',
91
98
  });
92
- // verificationCode === '123456'
99
+
100
+ console.log(verificationCode); // 123456
93
101
  ```
94
102
 
103
+ The current SMS verification method is spelled `sendSmsVerifcation()` in code. Use that exact method name until the public API changes.
104
+
95
105
  ## Connector Examples
96
106
 
97
- ### Email
107
+ Service mail over managed SMTP credentials:
98
108
 
99
109
  ```typescript
100
- await client.emailConnector.sendEmail({
110
+ const status = await client.emailConnector.getServiceMailStatus();
111
+
112
+ if (status.ready) {
113
+ await client.emailConnector.sendText({
114
+ to: 'user@example.com',
115
+ subject: 'Service mail ready',
116
+ text: 'This message was sent through the managed service mail identity.',
117
+ });
118
+ }
119
+ ```
120
+
121
+ Specific sender address:
122
+
123
+ ```typescript
124
+ await client.emailConnector.sendHtml({
125
+ from: 'test-service@gated.one',
101
126
  to: 'user@example.com',
102
- from: 'hello@serve.zone',
103
- title: 'Invoice ready',
104
- body: 'Your invoice is available in the dashboard.',
127
+ subject: 'Platform capability test',
128
+ html: '<p>The service mail identity is working.</p>',
105
129
  });
106
130
  ```
107
131
 
108
- ### SMS
132
+ Inbound message normalization for webhook or TypedRequest-style delivery:
109
133
 
110
134
  ```typescript
111
- const status = await client.smsConnector.sendSms({
112
- toNumber: 491234567890,
113
- fromName: 'ServeZone',
114
- messageText: 'Your code is 123456.',
135
+ const inboundHandler = client.emailConnector.createInboundHandler(async (message) => {
136
+ console.log(message.from, message.to, message.subject);
137
+ return { accepted: true };
115
138
  });
116
139
  ```
117
140
 
118
- ### SMS Verification
141
+ Legacy platform-service email request:
119
142
 
120
143
  ```typescript
121
- const code = await client.smsConnector.sendSmsVerifcation({
144
+ await client.emailConnector.sendEmail({
145
+ to: 'user@example.com',
146
+ from: 'hello@example.com',
147
+ title: 'Invoice ready',
148
+ body: 'Your invoice is available in the dashboard.',
149
+ });
150
+ ```
151
+
152
+ SMS:
153
+
154
+ ```typescript
155
+ const status = await client.smsConnector.sendSms({
122
156
  toNumber: 491234567890,
123
157
  fromName: 'ServeZone',
158
+ messageText: 'Your code is 123456.',
124
159
  });
125
160
  ```
126
161
 
127
- ### Push Notifications
162
+ Push notification:
128
163
 
129
164
  ```typescript
130
165
  const status = await client.pushNotificationConnector.sendPushNotification({
@@ -133,7 +168,7 @@ const status = await client.pushNotificationConnector.sendPushNotification({
133
168
  });
134
169
  ```
135
170
 
136
- ### Letters
171
+ Letter:
137
172
 
138
173
  ```typescript
139
174
  await client.letterConnector.sendLetter({
@@ -145,25 +180,32 @@ await client.letterConnector.sendLetter({
145
180
  });
146
181
  ```
147
182
 
148
- Exact request fields are defined by `@serve.zone/interfaces` and may evolve with the platform API.
183
+ Service-mail helper option and result types are exported from `@serve.zone/platformclient`. The legacy platform-service request fields are defined in `@serve.zone/interfaces` under `platform.email`, `platform.sms`, `platform.pushnotification`, and `platform.letter`.
149
184
 
150
- ## InfoHtml Helper
185
+ ## Platform Bindings
151
186
 
152
- The repository also contains an `InfoHtml` helper in `ts_infohtml/` for rendering simple branded informational HTML pages from text or option objects.
187
+ Platform bindings allow a workload to discover endpoint URLs and credentials from its runtime environment.
153
188
 
154
189
  ```typescript
155
- import { InfoHtml } from './ts_infohtml/index.js';
190
+ import { SzPlatformClient } from '@serve.zone/platformclient';
191
+ import { platform } from '@serve.zone/interfaces';
156
192
 
157
- const infoPage = await InfoHtml.fromOptions({
158
- title: 'Service unavailable',
159
- heading: 'Maintenance in progress',
160
- text: 'Please try again in a few minutes.',
161
- redirectTo: 'https://serve.zone',
162
- });
193
+ const binding: platform.IPlatformBinding = JSON.parse(
194
+ process.env.SERVEZONE_PLATFORM_BINDING!
195
+ );
196
+
197
+ const client = new SzPlatformClient({ binding });
198
+ await client.init();
163
199
 
164
- console.log(infoPage.htmlString);
200
+ const emailBinding = client.getPlatformBinding('email');
165
201
  ```
166
202
 
203
+ Bindings with `desiredState: 'disabled'` or `status: 'failed'` are ignored when the client auto-selects an endpoint.
204
+
205
+ ## InfoHtml Helper
206
+
207
+ The repository also contains a small `ts_infohtml` source folder for rendering simple informational HTML pages from text or options. It is not exported from the package root, so treat it as a source-level helper rather than the main SDK API.
208
+
167
209
  ## Development
168
210
 
169
211
  ```bash
@@ -172,16 +214,7 @@ pnpm test
172
214
  pnpm run build
173
215
  ```
174
216
 
175
- The package is authored in TypeScript and builds the source folders through `tsbuild tsfolders --web --allowimplicitany`.
176
-
177
- ## Links
178
-
179
- | Resource | URL |
180
- | --- | --- |
181
- | npm package | <https://www.npmjs.com/package/@serve.zone/platformclient> |
182
- | Source | <https://gitlab.com/serve.zone/platformclient> |
183
- | Source mirror | <https://github.com/serve.zone/platformclient> |
184
- | Typedoc | <https://serve.zone.gitlab.io/platformclient/> |
217
+ The package is authored as ESM TypeScript and builds source folders with `tsbuild tsfolders --web --allowimplicitany`.
185
218
 
186
219
  ## License and Legal Information
187
220
 
@@ -197,7 +230,7 @@ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark G
197
230
 
198
231
  ### Company Information
199
232
 
200
- Task Venture Capital GmbH
233
+ Task Venture Capital GmbH
201
234
  Registered at District Court Bremen HRB 35230 HB, Germany
202
235
 
203
236
  For any legal inquiries or further information, please contact us via email at hello@task.vc.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/platformclient',
6
- version: '1.1.4',
6
+ version: '1.2.0',
7
7
  description: 'a module that makes it really easy to use the serve.zone platform inside your app'
8
8
  }
@@ -217,7 +217,7 @@ export class SzPlatformClient {
217
217
  return Array.from(bindingMap.values());
218
218
  }
219
219
 
220
- private async getConfiguredEnvVar(envNameArg: string) {
220
+ public async getConfiguredEnvVar(envNameArg: string) {
221
221
  const processValue = this.getProcessEnvVar(envNameArg);
222
222
  if (processValue) {
223
223
  return processValue;