@serve.zone/platformclient 1.1.2 → 1.1.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 (33) hide show
  1. package/{npmextra.json → .smartconfig.json} +10 -3
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/classes.platformclient.d.ts +27 -3
  4. package/dist_ts/classes.platformclient.js +152 -9
  5. package/dist_ts/email/classes.emailconnector.d.ts +1 -1
  6. package/dist_ts/email/classes.emailconnector.js +1 -1
  7. package/dist_ts/email/classes.letterconnector.d.ts +1 -1
  8. package/dist_ts/email/classes.letterconnector.js +1 -1
  9. package/dist_ts/email/classes.pushnotificationconnector.d.ts +1 -1
  10. package/dist_ts/email/classes.pushnotificationconnector.js +1 -1
  11. package/dist_ts/email/classes.smsconnector.d.ts +2 -2
  12. package/dist_ts/email/classes.smsconnector.js +1 -1
  13. package/dist_ts_infohtml/classes.infohtml.d.ts +1 -1
  14. package/dist_ts_infohtml/classes.infohtml.js +2 -2
  15. package/dist_ts_infohtml/plugins.js +2 -1
  16. package/license +21 -0
  17. package/package.json +14 -15
  18. package/readme.md +204 -30
  19. package/ts/00_commitinfo_data.ts +1 -1
  20. package/ts/classes.platformclient.ts +205 -14
  21. package/ts/email/classes.emailconnector.ts +2 -2
  22. package/ts/email/classes.letterconnector.ts +3 -3
  23. package/ts/email/classes.pushnotificationconnector.ts +3 -3
  24. package/ts/email/classes.smsconnector.ts +4 -4
  25. package/dist_ts/classes.serviceserver.d.ts +0 -18
  26. package/dist_ts/classes.serviceserver.js +0 -32
  27. package/dist_ts/infohtml/classes.infohtml.d.ts +0 -18
  28. package/dist_ts/infohtml/classes.infohtml.js +0 -27
  29. package/dist_ts/infohtml/index.d.ts +0 -1
  30. package/dist_ts/infohtml/index.js +0 -2
  31. package/dist_ts/infohtml/template.d.ts +0 -3
  32. package/dist_ts/infohtml/template.js +0 -156
  33. package/readme.hints.md +0 -0
package/readme.md CHANGED
@@ -1,31 +1,205 @@
1
1
  # @serve.zone/platformclient
2
- a module that makes it really easy to use the serve.zone platform inside your app
3
-
4
- ## Availabililty and Links
5
- * [npmjs.org (npm package)](https://www.npmjs.com/package/@serve.zone/platformclient)
6
- * [gitlab.com (source)](https://gitlab.com/serve.zone/platformclient)
7
- * [github.com (source mirror)](https://github.com/serve.zone/platformclient)
8
- * [docs (typedoc)](https://serve.zone.gitlab.io/platformclient/)
9
-
10
- ## Status for master
11
-
12
- Status Category | Status Badge
13
- -- | --
14
- GitLab Pipelines | [![pipeline status](https://gitlab.com/serve.zone/platformclient/badges/master/pipeline.svg)](https://lossless.cloud)
15
- GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/serve.zone/platformclient/badges/master/coverage.svg)](https://lossless.cloud)
16
- npm | [![npm downloads per month](https://badgen.net/npm/dy/@serve.zone/platformclient)](https://lossless.cloud)
17
- Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/serve.zone/platformclient)](https://lossless.cloud)
18
- TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
- node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
- Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
- PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@serve.zone/platformclient)](https://lossless.cloud)
22
- PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@serve.zone/platformclient)](https://lossless.cloud)
23
- BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@serve.zone/platformclient)](https://lossless.cloud)
24
-
25
- ## Usage
26
- Use TypeScript for best in class intellisense
27
- For further information read the linked docs at the top of this readme.
28
-
29
- ## Legal
30
- > MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
31
- | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
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.
6
+
7
+ ## Issue Reporting and Security
8
+
9
+ 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
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @serve.zone/platformclient
15
+ ```
16
+
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
+ ## Quick Start
31
+
32
+ ```typescript
33
+ import { SzPlatformClient } from '@serve.zone/platformclient';
34
+
35
+ const platformClient = new SzPlatformClient(process.env.SERVEZONE_PLATFORM_AUTHORIZATION);
36
+ await platformClient.init();
37
+
38
+ await platformClient.emailConnector.sendEmail({
39
+ to: 'user@example.com',
40
+ from: 'hello@serve.zone',
41
+ title: 'Welcome to the platform',
42
+ body: 'Your workspace is ready.',
43
+ });
44
+ ```
45
+
46
+ The client connects to the platform endpoint configured through `SERVEZONE_PLATFORM_URL`, a runtime platform binding, or the legacy `SERVEZONE_API_DOMAIN` fallback.
47
+
48
+ ## Configuration
49
+
50
+ The client needs two values:
51
+
52
+ | Value | How to provide it | Notes |
53
+ | --- | --- | --- |
54
+ | Authorization token | Constructor argument, `init()` argument, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, binding credential env, or `SERVEZONE_PLATFROM_AUTHORIZATION` | The misspelled legacy env name remains supported for compatibility. |
55
+ | Platform URL | Constructor options, `SERVEZONE_PLATFORM_URL`, binding endpoint, or `SERVEZONE_API_DOMAIN` | 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`. |
57
+
58
+ ```typescript
59
+ const client = new SzPlatformClient();
60
+ await client.init('your-platform-authorization-token');
61
+ ```
62
+
63
+ Constructor and `init()` also accept options:
64
+
65
+ ```typescript
66
+ const client = new SzPlatformClient({
67
+ token: process.env.SERVEZONE_PLATFORM_TOKEN,
68
+ platformUrl: process.env.SERVEZONE_PLATFORM_URL,
69
+ });
70
+ await client.init();
71
+ ```
72
+
73
+ ## Debug Mode
74
+
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.
76
+
77
+ ```typescript
78
+ const client = new SzPlatformClient('test');
79
+ await client.init();
80
+
81
+ await client.emailConnector.sendEmail({
82
+ to: 'developer@example.com',
83
+ from: 'hello@serve.zone',
84
+ title: 'Preview only',
85
+ body: 'This message is logged, not sent.',
86
+ });
87
+
88
+ const verificationCode = await client.smsConnector.sendSmsVerifcation({
89
+ toNumber: 491234567890,
90
+ fromName: 'ServeZone',
91
+ });
92
+ // verificationCode === '123456'
93
+ ```
94
+
95
+ ## Connector Examples
96
+
97
+ ### Email
98
+
99
+ ```typescript
100
+ await client.emailConnector.sendEmail({
101
+ to: 'user@example.com',
102
+ from: 'hello@serve.zone',
103
+ title: 'Invoice ready',
104
+ body: 'Your invoice is available in the dashboard.',
105
+ });
106
+ ```
107
+
108
+ ### SMS
109
+
110
+ ```typescript
111
+ const status = await client.smsConnector.sendSms({
112
+ toNumber: 491234567890,
113
+ fromName: 'ServeZone',
114
+ messageText: 'Your code is 123456.',
115
+ });
116
+ ```
117
+
118
+ ### SMS Verification
119
+
120
+ ```typescript
121
+ const code = await client.smsConnector.sendSmsVerifcation({
122
+ toNumber: 491234567890,
123
+ fromName: 'ServeZone',
124
+ });
125
+ ```
126
+
127
+ ### Push Notifications
128
+
129
+ ```typescript
130
+ const status = await client.pushNotificationConnector.sendPushNotification({
131
+ deviceToken: 'device-token-from-your-app',
132
+ message: 'Deployment complete: your service is live.',
133
+ });
134
+ ```
135
+
136
+ ### Letters
137
+
138
+ ```typescript
139
+ await client.letterConnector.sendLetter({
140
+ description: 'Important account information',
141
+ needsCover: true,
142
+ title: 'Account update',
143
+ coverBody: 'This letter was generated through serve.zone.',
144
+ service: ['Einschreiben'],
145
+ });
146
+ ```
147
+
148
+ Exact request fields are defined by `@serve.zone/interfaces` and may evolve with the platform API.
149
+
150
+ ## InfoHtml Helper
151
+
152
+ The repository also contains an `InfoHtml` helper in `ts_infohtml/` for rendering simple branded informational HTML pages from text or option objects.
153
+
154
+ ```typescript
155
+ import { InfoHtml } from './ts_infohtml/index.js';
156
+
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
+ });
163
+
164
+ console.log(infoPage.htmlString);
165
+ ```
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ pnpm install
171
+ pnpm test
172
+ pnpm run build
173
+ ```
174
+
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/> |
185
+
186
+ ## License and Legal Information
187
+
188
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
189
+
190
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
191
+
192
+ ### Trademarks
193
+
194
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
195
+
196
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
197
+
198
+ ### Company Information
199
+
200
+ Task Venture Capital GmbH
201
+ Registered at District Court Bremen HRB 35230 HB, Germany
202
+
203
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
204
+
205
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/platformclient',
6
- version: '1.1.2',
6
+ version: '1.1.3',
7
7
  description: 'a module that makes it really easy to use the serve.zone platform inside your app'
8
8
  }
@@ -4,11 +4,23 @@ import { SzPushNotificationConnector } from './email/classes.pushnotificationcon
4
4
  import { SzLetterConnector } from './email/classes.letterconnector.js';
5
5
  import * as plugins from './plugins.js';
6
6
 
7
+ export interface ISzPlatformClientOptions {
8
+ authorizationString?: string;
9
+ authorization?: string;
10
+ token?: string;
11
+ url?: string;
12
+ platformUrl?: string;
13
+ binding?: plugins.servezoneInterfaces.platform.IPlatformBinding;
14
+ bindings?: plugins.servezoneInterfaces.platform.IPlatformBinding[];
15
+ }
16
+
7
17
  export class SzPlatformClient {
8
18
  public debugMode = false;
9
- private authorizationString: string;
10
- public typedrouter = new plugins.typedrequest.TypedRouter();
11
- public typedsocket: plugins.typedsocket.TypedSocket;
19
+ private authorizationString?: string;
20
+ private connectionAddress?: string;
21
+ public platformBindings: plugins.servezoneInterfaces.platform.IPlatformBinding[] = [];
22
+ public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter();
23
+ public typedsocket!: plugins.typedsocket.TypedSocket;
12
24
  private qenvInstance = new plugins.qenv.Qenv();
13
25
 
14
26
  public emailConnector = new SzEmailConnector(this);
@@ -16,30 +28,209 @@ export class SzPlatformClient {
16
28
  public pushNotificationConnector = new SzPushNotificationConnector(this);
17
29
  public letterConnector = new SzLetterConnector(this);
18
30
 
19
- constructor(authorizationStringArg?: string) {
20
- this.authorizationString = authorizationStringArg;
31
+ constructor(authorizationStringArg?: string | ISzPlatformClientOptions) {
32
+ this.applyOptions(authorizationStringArg);
21
33
  }
22
34
 
23
- public async init(authorizationStringArg?: string) {
24
- if (authorizationStringArg) {
25
- this.authorizationString = authorizationStringArg;
35
+ public async init(authorizationStringArg?: string | ISzPlatformClientOptions) {
36
+ this.applyOptions(authorizationStringArg);
37
+ if (!this.authorizationString) {
38
+ this.authorizationString = await this.getConfiguredAuthorizationString();
39
+ }
40
+ if (this.authorizationString === 'test') {
41
+ this.activateDebugMode();
42
+ return;
43
+ }
44
+
45
+ this.platformBindings = this.mergePlatformBindings(
46
+ this.platformBindings,
47
+ await this.discoverPlatformBindings()
48
+ );
49
+ if (!this.authorizationString) {
50
+ this.authorizationString = this.getAuthorizationStringFromBindings();
26
51
  }
27
- if (!this.authorizationString)
28
- this.authorizationString = process.env.SERVEZONE_PLATFROM_AUTHORIZATION;
29
52
  if (!this.authorizationString) throw new Error('authorizationString is required');
30
53
  if (this.authorizationString === 'test') {
31
- this.debugMode = true;
32
- console.log('debug mode activated.');
54
+ this.activateDebugMode();
33
55
  return;
34
56
  }
35
57
  this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(
36
- this.typedrouter,
58
+ this.typedrouter as any,
37
59
  await this.getConnectionAddress()
38
60
  );
61
+ await this.setAuthorizationTag();
62
+ }
63
+
64
+ private activateDebugMode() {
65
+ this.debugMode = true;
66
+ console.log('debug mode activated.');
67
+ }
68
+
69
+ public getPlatformBinding(
70
+ capabilityArg?: plugins.servezoneInterfaces.platform.TPlatformCapability
71
+ ) {
72
+ return this.platformBindings.find((bindingArg) => {
73
+ return (
74
+ bindingArg.desiredState !== 'disabled' &&
75
+ bindingArg.status !== 'failed' &&
76
+ (!capabilityArg || bindingArg.capability === capabilityArg)
77
+ );
78
+ });
79
+ }
80
+
81
+ private applyOptions(optionsArg?: string | ISzPlatformClientOptions) {
82
+ if (!optionsArg) {
83
+ return;
84
+ }
85
+ if (typeof optionsArg === 'string') {
86
+ this.authorizationString = optionsArg;
87
+ return;
88
+ }
89
+
90
+ this.authorizationString =
91
+ optionsArg.authorizationString ||
92
+ optionsArg.authorization ||
93
+ optionsArg.token ||
94
+ this.authorizationString;
95
+ this.connectionAddress = optionsArg.url || optionsArg.platformUrl || this.connectionAddress;
96
+ this.platformBindings = this.mergePlatformBindings(
97
+ this.platformBindings,
98
+ [optionsArg.binding, ...(optionsArg.bindings || [])].filter(
99
+ Boolean
100
+ ) as plugins.servezoneInterfaces.platform.IPlatformBinding[]
101
+ );
39
102
  }
40
103
 
41
104
  private async getConnectionAddress() {
42
- const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
105
+ const connectionAddress =
106
+ this.connectionAddress ||
107
+ (await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_URL')) ||
108
+ this.getConnectionAddressFromBindings() ||
109
+ (await this.getConfiguredEnvVar('SERVEZONE_API_DOMAIN'));
110
+ if (!connectionAddress) throw new Error('SERVEZONE_PLATFORM_URL or SERVEZONE_API_DOMAIN is required');
43
111
  return connectionAddress;
44
112
  }
113
+
114
+ private getConnectionAddressFromBindings() {
115
+ for (const binding of this.platformBindings) {
116
+ if (binding.desiredState === 'disabled' || binding.status === 'failed') {
117
+ continue;
118
+ }
119
+ if (!this.isSupportedConnectorCapability(binding.capability)) {
120
+ continue;
121
+ }
122
+ const endpoint = binding.endpoints?.find((endpointArg) => {
123
+ return endpointArg.protocol === 'typedrequest' || endpointArg.protocol === 'http';
124
+ });
125
+ const endpointUrl = endpoint?.internalUrl || endpoint?.externalUrl;
126
+ if (endpointUrl) {
127
+ return endpointUrl;
128
+ }
129
+ }
130
+ }
131
+
132
+ private isSupportedConnectorCapability(
133
+ capabilityArg: plugins.servezoneInterfaces.platform.TPlatformCapability
134
+ ) {
135
+ return ['email', 'sms', 'pushnotification', 'letter'].includes(capabilityArg);
136
+ }
137
+
138
+ private async getConfiguredAuthorizationString() {
139
+ return (
140
+ (await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_AUTHORIZATION')) ||
141
+ (await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_TOKEN')) ||
142
+ (await this.getConfiguredEnvVar('SERVEZONE_PLATFROM_AUTHORIZATION'))
143
+ );
144
+ }
145
+
146
+ private getAuthorizationStringFromBindings() {
147
+ const authEnvNames = [
148
+ 'SERVEZONE_PLATFORM_AUTHORIZATION',
149
+ 'SERVEZONE_PLATFORM_TOKEN',
150
+ 'SERVEZONE_API_TOKEN',
151
+ 'AUTHORIZATION',
152
+ 'TOKEN',
153
+ ];
154
+ for (const binding of this.platformBindings) {
155
+ for (const credential of binding.credentials || []) {
156
+ for (const envName of authEnvNames) {
157
+ const value = credential.env?.[envName];
158
+ if (value) {
159
+ return value;
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ private async setAuthorizationTag() {
167
+ if (!this.authorizationString) {
168
+ return;
169
+ }
170
+ try {
171
+ await this.typedsocket.setTag('authorization' as any, this.authorizationString);
172
+ } catch (error) {
173
+ if (await this.getConfiguredEnvVar('SERVEZONE_PLATFORMCLIENT_DEBUG')) {
174
+ console.warn('Could not set platform authorization tag:', (error as Error).message);
175
+ }
176
+ }
177
+ }
178
+
179
+ private async discoverPlatformBindings() {
180
+ const bindings: plugins.servezoneInterfaces.platform.IPlatformBinding[] = [];
181
+ const envBindings = await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_BINDINGS');
182
+ const envBinding = await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_BINDING');
183
+
184
+ if (envBindings) {
185
+ bindings.push(...this.parsePlatformBindingsEnv('SERVEZONE_PLATFORM_BINDINGS', envBindings));
186
+ }
187
+ if (envBinding) {
188
+ bindings.push(...this.parsePlatformBindingsEnv('SERVEZONE_PLATFORM_BINDING', envBinding));
189
+ }
190
+
191
+ return bindings;
192
+ }
193
+
194
+ private parsePlatformBindingsEnv(envNameArg: string, envValueArg: string) {
195
+ let parsedValue: unknown;
196
+ try {
197
+ parsedValue = JSON.parse(envValueArg);
198
+ } catch (error) {
199
+ throw new Error(`${envNameArg} must contain valid JSON`);
200
+ }
201
+
202
+ if (Array.isArray(parsedValue)) {
203
+ return parsedValue as plugins.servezoneInterfaces.platform.IPlatformBinding[];
204
+ }
205
+ if (parsedValue && typeof parsedValue === 'object') {
206
+ return [parsedValue as plugins.servezoneInterfaces.platform.IPlatformBinding];
207
+ }
208
+ throw new Error(`${envNameArg} must contain a platform binding object or array`);
209
+ }
210
+
211
+ private mergePlatformBindings(
212
+ existingBindingsArg: plugins.servezoneInterfaces.platform.IPlatformBinding[],
213
+ newBindingsArg: plugins.servezoneInterfaces.platform.IPlatformBinding[]
214
+ ) {
215
+ const bindingMap = new Map<string, plugins.servezoneInterfaces.platform.IPlatformBinding>();
216
+ for (const binding of [...existingBindingsArg, ...newBindingsArg]) {
217
+ bindingMap.set(binding.id, binding);
218
+ }
219
+ return Array.from(bindingMap.values());
220
+ }
221
+
222
+ private async getConfiguredEnvVar(envNameArg: string) {
223
+ const processValue = this.getProcessEnvVar(envNameArg);
224
+ if (processValue) {
225
+ return processValue;
226
+ }
227
+ return this.qenvInstance.getEnvVarOnDemand(envNameArg);
228
+ }
229
+
230
+ private getProcessEnvVar(envNameArg: string) {
231
+ const processEnv = (globalThis as typeof globalThis & {
232
+ process?: { env?: Record<string, string | undefined> };
233
+ }).process?.env;
234
+ return processEnv?.[envNameArg];
235
+ }
45
236
  }
@@ -11,7 +11,7 @@ export class SzEmailConnector {
11
11
  }
12
12
 
13
13
  public async sendEmail(
14
- optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
14
+ optionsArg: plugins.servezoneInterfaces.platform.email.IReq_SendEmail['request']
15
15
  ) {
16
16
  if (this.platformClientRef.debugMode) {
17
17
  logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
@@ -26,7 +26,7 @@ export class SzEmailConnector {
26
26
  }
27
27
 
28
28
  const typedRequest =
29
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
29
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.email.IReq_SendEmail>(
30
30
  'sendEmail'
31
31
  );
32
32
  const response = await typedRequest.fire(optionsArg);
@@ -9,7 +9,7 @@ export class SzLetterConnector {
9
9
  }
10
10
 
11
11
  public async sendLetter(
12
- optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
12
+ optionsArg: plugins.servezoneInterfaces.platform.letter.IReq_SendLetter['request']
13
13
  ) {
14
14
 
15
15
  if (this.platformClientRef.debugMode) {
@@ -21,9 +21,9 @@ export class SzLetterConnector {
21
21
  }
22
22
 
23
23
  const typedRequest =
24
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter>(
24
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.letter.IReq_SendLetter>(
25
25
  'sendLetter'
26
26
  );
27
27
  const response = await typedRequest.fire(optionsArg);
28
28
  }
29
- }
29
+ }
@@ -9,7 +9,7 @@ export class SzPushNotificationConnector {
9
9
  }
10
10
 
11
11
  public async sendPushNotification(
12
- optionsArg: plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification['request']
12
+ optionsArg: plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification['request']
13
13
  ) {
14
14
  if (this.platformClientRef.debugMode) {
15
15
  console.log('sendPushNotification', optionsArg);
@@ -20,7 +20,7 @@ export class SzPushNotificationConnector {
20
20
  }
21
21
 
22
22
  const typedRequest =
23
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification>(
23
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification>(
24
24
  'sendPushNotification'
25
25
  );
26
26
  const response = await typedRequest.fire(optionsArg);
@@ -31,4 +31,4 @@ export class SzPushNotificationConnector {
31
31
 
32
32
  return response.status;
33
33
  }
34
- }
34
+ }
@@ -9,7 +9,7 @@ export class SzSmsConnector {
9
9
  this.platformClientRef = platformClientRefArg;
10
10
  }
11
11
 
12
- public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
12
+ public async sendSms(messageArg: plugins.servezoneInterfaces.platform.sms.IReq_SendSms['request']) {
13
13
  if (this.platformClientRef.debugMode) {
14
14
  logger.log('info', `sent sms to ${messageArg.toNumber}}
15
15
  body:
@@ -22,7 +22,7 @@ export class SzSmsConnector {
22
22
  return;
23
23
  }
24
24
 
25
- const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
25
+ const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendSms>(
26
26
  'sendSms'
27
27
  );
28
28
  const response = await typedrequest.fire(messageArg);
@@ -31,7 +31,7 @@ export class SzSmsConnector {
31
31
  }
32
32
 
33
33
  public async sendSmsVerifcation(
34
- recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']
34
+ recipientArg: plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode['request']
35
35
  ) {
36
36
  if (this.platformClientRef.debugMode) {
37
37
  console.log('sendSmsVerifcation', recipientArg, '123456');
@@ -40,7 +40,7 @@ export class SzSmsConnector {
40
40
 
41
41
 
42
42
  const typedrequest =
43
- this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode>(
43
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode>(
44
44
  'sendVerificationCode'
45
45
  );
46
46
  const response = await typedrequest.fire(recipientArg);
@@ -1,18 +0,0 @@
1
- import * as plugins from './plugins.js';
2
- export interface IServiceServerConstructorOptions {
3
- addCustomRoutes?: (serverArg: plugins.typedserver.servertools.Server) => Promise<any>;
4
- serviceName: string;
5
- serviceVersion: string;
6
- serviceDomain: string;
7
- port?: number;
8
- }
9
- /**
10
- * a server for serving your app to the outside world
11
- */
12
- export declare class ServiceServer {
13
- options: IServiceServerConstructorOptions;
14
- typedServer: plugins.typedserver.TypedServer;
15
- constructor(optionsArg: IServiceServerConstructorOptions);
16
- start(): Promise<void>;
17
- stop(): Promise<void>;
18
- }
@@ -1,32 +0,0 @@
1
- import * as plugins from './plugins.js';
2
- import { InfoHtml } from './infohtml/index.js';
3
- /**
4
- * a server for serving your app to the outside world
5
- */
6
- export class ServiceServer {
7
- constructor(optionsArg) {
8
- this.options = optionsArg;
9
- }
10
- async start() {
11
- console.log('starting lole-serviceserver...');
12
- this.typedServer = new plugins.typedserver.TypedServer({
13
- cors: true,
14
- domain: this.options.serviceDomain,
15
- forceSsl: false,
16
- port: this.options.port || 3000,
17
- robots: true,
18
- defaultAnswer: async () => {
19
- return (await InfoHtml.fromSimpleText(`${this.options.serviceName} (version ${this.options.serviceVersion})`)).htmlString;
20
- },
21
- });
22
- // lets add any custom routes
23
- if (this.options.addCustomRoutes) {
24
- await this.options.addCustomRoutes(this.typedServer.server);
25
- }
26
- await this.typedServer.start();
27
- }
28
- async stop() {
29
- await this.typedServer.stop();
30
- }
31
- }
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5zZXJ2aWNlc2VydmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2xhc3Nlcy5zZXJ2aWNlc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQVUvQzs7R0FFRztBQUNILE1BQU0sT0FBTyxhQUFhO0lBSXhCLFlBQVksVUFBNEM7UUFDdEQsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUM7SUFDNUIsQ0FBQztJQUVNLEtBQUssQ0FBQyxLQUFLO1FBQ2hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsZ0NBQWdDLENBQUMsQ0FBQTtRQUM3QyxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxXQUFXLENBQUM7WUFDckQsSUFBSSxFQUFFLElBQUk7WUFDVixNQUFNLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxhQUFhO1lBQ2xDLFFBQVEsRUFBRSxLQUFLO1lBQ2YsSUFBSSxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxJQUFJLElBQUk7WUFDL0IsTUFBTSxFQUFFLElBQUk7WUFDWixhQUFhLEVBQUUsS0FBSyxJQUFJLEVBQUU7Z0JBQ3hCLE9BQU8sQ0FDTCxNQUFNLFFBQVEsQ0FBQyxjQUFjLENBQzNCLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxXQUFXLGFBQWEsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLEdBQUcsQ0FDdkUsQ0FDRixDQUFDLFVBQVUsQ0FBQztZQUNmLENBQUM7U0FDRixDQUFDLENBQUM7UUFFSCw2QkFBNkI7UUFDN0IsSUFBSSxJQUFJLENBQUMsT0FBTyxDQUFDLGVBQWUsRUFBRSxDQUFDO1lBQ2pDLE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQyxlQUFlLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM5RCxDQUFDO1FBRUQsTUFBTSxJQUFJLENBQUMsV0FBVyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQ2pDLENBQUM7SUFFTSxLQUFLLENBQUMsSUFBSTtRQUNmLE1BQU0sSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQyxDQUFDO0NBQ0YifQ==
@@ -1,18 +0,0 @@
1
- import * as plugins from '../plugins.js';
2
- export interface IHtmlInfoOptions {
3
- text: string;
4
- heading?: string;
5
- title?: string;
6
- sentryMessage?: string;
7
- sentryDsn?: string;
8
- redirectTo?: string;
9
- }
10
- export declare class InfoHtml {
11
- static fromSimpleText(textArg: string): Promise<InfoHtml>;
12
- static fromOptions(optionsArg: IHtmlInfoOptions): Promise<InfoHtml>;
13
- options: IHtmlInfoOptions;
14
- smartntmlInstance: plugins.smartntml.Smartntml;
15
- htmlString: string;
16
- constructor(optionsArg: IHtmlInfoOptions);
17
- init(): Promise<string>;
18
- }