Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df542ec67a | |||
| f0b924ba9d | |||
| b4b2ed9571 | |||
| 4b3a2b2e75 | |||
| 19344b2535 | |||
| e16c8876b8 | |||
| 1212ee9116 | |||
| b610cba9ac | |||
| 854f1f73dc | |||
| edc54f4fc1 | |||
| 7e721eb48e | |||
| 965dad9b15 | |||
| 4a75c109e3 | |||
| 7d0925ad33 | |||
| 63700c3754 | |||
| 274bffb318 | |||
| 1ed33efec1 | |||
| 8300532de4 | |||
| 606d46acf8 | |||
| 9c84205633 | |||
| a71d5f1bde | |||
| e19a5b6195 | |||
| 02d204e606 | |||
| 7d9d023d6b | |||
| 07a3df944a | |||
| 0c0a35bc90 | |||
| d346ca5237 |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"gitzone": {
|
"@git.zone/cli": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
@@ -9,10 +9,17 @@
|
|||||||
"npmPackagename": "@serve.zone/platformclient",
|
"npmPackagename": "@serve.zone/platformclient",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "serve.zone"
|
"projectDomain": "serve.zone"
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+5
-5
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"json.schemas": [
|
"json.schemas": [
|
||||||
{
|
{
|
||||||
"fileMatch": ["/npmextra.json"],
|
"fileMatch": ["/.smartconfig.json"],
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "settings for npmci"
|
"description": "settings for szci"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"@git.zone/cli": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "settings for gitzone",
|
"description": "settings for git.zone CLI",
|
||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-04-28 - 1.1.4 - fix(platformclient)
|
||||||
|
Keep platform environment configuration clean.
|
||||||
|
|
||||||
|
- Kept only `SERVEZONE_PLATFORM_URL`, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, and platform binding discovery.
|
||||||
|
|
||||||
|
## 2026-04-28 - 1.1.3 - feat(platformclient)
|
||||||
|
Add runtime platform binding configuration.
|
||||||
|
|
||||||
|
- Added `SERVEZONE_PLATFORM_URL`, `SERVEZONE_PLATFORM_AUTHORIZATION`, and `SERVEZONE_PLATFORM_TOKEN` support.
|
||||||
|
- Added environment binding discovery through `SERVEZONE_PLATFORM_BINDING` and `SERVEZONE_PLATFORM_BINDINGS`.
|
||||||
|
|
||||||
|
## 2024-10-05 - 1.1.2 - fix(core)
|
||||||
|
Fix authorization handling and format code.
|
||||||
|
|
||||||
|
- Resolved the incorrect condition check for 'authorizationStringArg' within the 'init' function.
|
||||||
|
- Corrected the condition to activate 'debugMode' within the 'init' function.
|
||||||
|
- Improved code formatting for better readability.
|
||||||
|
|
||||||
|
## 2024-10-05 - 1.1.1 - fix(platformclient)
|
||||||
|
Refactor debug mode checks in SzPlatformClient connectors
|
||||||
|
|
||||||
|
- Unified debug mode checks across email, SMS, and letter connectors
|
||||||
|
- Added new SzPushNotificationConnector class with debug mode functionality
|
||||||
|
|
||||||
|
## 2024-10-04 - 1.1.0 - feat(SzPlatformClient)
|
||||||
|
Add debug mode functionality to SzPlatformClient and SzEmailConnector
|
||||||
|
|
||||||
|
- Introduced a debug mode in SzPlatformClient to handle authorization in test scenarios.
|
||||||
|
- Updated SzEmailConnector to log emails and early return in debug mode for testing purposes.
|
||||||
|
|
||||||
|
## 2024-10-02 - 1.0.11 - fix(email,sms)
|
||||||
|
Reorder debug logging to avoid confusion in email and sms connectors
|
||||||
|
|
||||||
|
- Reordered the logging after request creation in `sendEmail` method of `SzEmailConnector`
|
||||||
|
- Reordered the logging after request creation in `sendSms` method of `SzSmsConnector`
|
||||||
|
|
||||||
|
## 2024-10-02 - 1.0.10 - fix(build)
|
||||||
|
Fix build script configuration and plugins import path
|
||||||
|
|
||||||
|
- Corrected the build script in package.json to include tsfolders parameter
|
||||||
|
- Fixed the import path for plugins in classes.infohtml.ts
|
||||||
|
|
||||||
|
## 2024-10-02 - 1.0.9 - fix(infohtml)
|
||||||
|
Refactor infohtml module and fix import paths
|
||||||
|
|
||||||
|
- Refactored ts_infohtml module.
|
||||||
|
- Fixed incorrect import paths in ts_infohtml module.
|
||||||
|
- Ensured that the InfoHtml class and related templates are properly imported and used.
|
||||||
|
|
||||||
|
## 2024-10-02 - 1.0.8 - fix(core)
|
||||||
|
Maintain dependencies, update metadata
|
||||||
|
|
||||||
|
- No changes detected
|
||||||
|
|
||||||
|
## 2024-10-02 - 1.0.7 - fix(core)
|
||||||
|
Update dependencies and add logging for email and SMS functions
|
||||||
|
|
||||||
|
- Updated devDependencies and dependencies in package.json
|
||||||
|
- Added logger import and logging statements in classes.emailconnector.ts and classes.smsconnector.ts
|
||||||
|
- Fixed formatting issues in test/test.ts
|
||||||
|
- Cleaned up and removed unused imports in index.ts and plugins.ts
|
||||||
|
|
||||||
|
## 2024-07-26 - 1.0.6 - fix(core)
|
||||||
|
Update @types/node dependency version
|
||||||
|
|
||||||
|
- Dependencies updated: @types/node updated from ^20.14.11 to ^20.14.12
|
||||||
|
|
||||||
|
## 2024-07-23 - 1.0.5 - fix(dependencies)
|
||||||
|
Updated dependencies to latest versions and removed unused service server class
|
||||||
|
|
||||||
|
- Updated devDependencies and dependencies to their latest versions in package.json
|
||||||
|
- Removed the unused ServiceServer class
|
||||||
|
- Updated index.ts to reflect changes in imports
|
||||||
|
|
||||||
|
## 2024-05-11 - 1.0.3 to 1.0.4 - General Updates
|
||||||
|
Maintenance updates
|
||||||
|
|
||||||
|
- Fix(core): update
|
||||||
|
|
||||||
|
## 2024-02-17 - 1.0.1 to 1.0.3 - General Updates
|
||||||
|
Maintenance updates
|
||||||
|
|
||||||
|
- Fix(core): update
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Task Venture Capital GmbH
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
+17
-17
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/platformclient",
|
"name": "@serve.zone/platformclient",
|
||||||
"version": "1.0.3",
|
"version": "1.1.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a module that makes it really easy to use the serve.zone platform inside your app",
|
"description": "a module that makes it really easy to use the serve.zone platform inside your app",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -10,25 +10,24 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "(tsbuild tsfolders --web --allowimplicitany)",
|
||||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.25",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@git.zone/tsbundle": "^2.0.5",
|
"@git.zone/tsbundle": "^2.10.0",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@git.zone/tsrun": "^2.0.2",
|
||||||
"@git.zone/tstest": "^1.0.44",
|
"@git.zone/tstest": "^3.6.3",
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@types/node": "^25.6.0"
|
||||||
"@types/node": "^20.11.19"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@api.global/typedrequest": "^3.0.4",
|
"@api.global/typedrequest": "^3.3.0",
|
||||||
"@api.global/typedserver": "^3.0.20",
|
"@api.global/typedserver": "^8.4.6",
|
||||||
"@api.global/typedsocket": "^3.0.0",
|
"@api.global/typedsocket": "^4.1.2",
|
||||||
"@push.rocks/qenv": "^6.0.5",
|
"@push.rocks/qenv": "^6.1.3",
|
||||||
"@push.rocks/smartlog": "^3.0.3",
|
"@push.rocks/smartlog": "^3.2.2",
|
||||||
"@push.rocks/smartntml": "^2.0.4",
|
"@push.rocks/smartntml": "^2.0.8",
|
||||||
"@serve.zone/interfaces": "^1.0.35"
|
"@serve.zone/interfaces": "^5.4.5"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -50,7 +49,8 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
".smartconfig.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
],
|
||||||
|
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+7940
-5111
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,205 @@
|
|||||||
# @serve.zone/platformclient
|
# @serve.zone/platformclient
|
||||||
a module that makes it really easy to use the serve.zone platform inside your app
|
|
||||||
|
|
||||||
## Availabililty and Links
|
`@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.
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@serve.zone/platformclient)
|
|
||||||
* [gitlab.com (source)](https://gitlab.com/serve.zone/platformclient)
|
|
||||||
* [github.com (source mirror)](https://github.com/serve.zone/platformclient)
|
|
||||||
* [docs (typedoc)](https://serve.zone.gitlab.io/platformclient/)
|
|
||||||
|
|
||||||
## Status for master
|
Use it when your app should trigger serve.zone communication workflows without manually wiring TypedRequest methods or transport setup.
|
||||||
|
|
||||||
Status Category | Status Badge
|
## Issue Reporting and Security
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
||||||
npm | [](https://lossless.cloud)
|
|
||||||
Snyk | [](https://lossless.cloud)
|
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
Code Style | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
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.
|
||||||
Use TypeScript for best in class intellisense
|
|
||||||
For further information read the linked docs at the top of this readme.
|
|
||||||
|
|
||||||
## Legal
|
## Installation
|
||||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
```bash
|
||||||
|
pnpm add @serve.zone/platformclient
|
||||||
|
```
|
||||||
|
|
||||||
|
## What It Does
|
||||||
|
|
||||||
|
`SzPlatformClient` handles the shared serve.zone platform connection and gives you these connectors:
|
||||||
|
|
||||||
|
| Connector | Purpose | TypedRequest method |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `emailConnector` | Send transactional email | `sendEmail` |
|
||||||
|
| `smsConnector` | Send SMS messages and verification codes | `sendSms`, `sendVerificationCode` |
|
||||||
|
| `pushNotificationConnector` | Send push notifications | `sendPushNotification` |
|
||||||
|
| `letterConnector` | Send physical letters through the platform | `sendLetter` |
|
||||||
|
|
||||||
|
Requests use the types from `@serve.zone/interfaces`, so payloads stay aligned with the serve.zone backend contracts.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { SzPlatformClient } from '@serve.zone/platformclient';
|
||||||
|
|
||||||
|
const platformClient = new SzPlatformClient(process.env.SERVEZONE_PLATFORM_AUTHORIZATION);
|
||||||
|
await platformClient.init();
|
||||||
|
|
||||||
|
await platformClient.emailConnector.sendEmail({
|
||||||
|
to: 'user@example.com',
|
||||||
|
from: 'hello@serve.zone',
|
||||||
|
title: 'Welcome to the platform',
|
||||||
|
body: 'Your workspace is ready.',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
The client connects to the platform endpoint configured through `SERVEZONE_PLATFORM_URL` or a runtime platform binding.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The client needs two values:
|
||||||
|
|
||||||
|
| Value | How to provide it | Notes |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Authorization token | Constructor argument, `init()` argument, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, or binding credential env | Loaded on demand through `@push.rocks/qenv`. |
|
||||||
|
| Platform URL | Constructor options, `SERVEZONE_PLATFORM_URL`, or binding endpoint | Loaded on demand through `@push.rocks/qenv`. |
|
||||||
|
| Runtime bindings | Constructor options, `SERVEZONE_PLATFORM_BINDING`, or `SERVEZONE_PLATFORM_BINDINGS` | Values are JSON-encoded `IPlatformBinding` objects from `@serve.zone/interfaces`. |
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const client = new SzPlatformClient();
|
||||||
|
await client.init('your-platform-authorization-token');
|
||||||
|
```
|
||||||
|
|
||||||
|
Constructor and `init()` also accept options:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const client = new SzPlatformClient({
|
||||||
|
token: process.env.SERVEZONE_PLATFORM_TOKEN,
|
||||||
|
platformUrl: process.env.SERVEZONE_PLATFORM_URL,
|
||||||
|
});
|
||||||
|
await client.init();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debug Mode
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const client = new SzPlatformClient('test');
|
||||||
|
await client.init();
|
||||||
|
|
||||||
|
await client.emailConnector.sendEmail({
|
||||||
|
to: 'developer@example.com',
|
||||||
|
from: 'hello@serve.zone',
|
||||||
|
title: 'Preview only',
|
||||||
|
body: 'This message is logged, not sent.',
|
||||||
|
});
|
||||||
|
|
||||||
|
const verificationCode = await client.smsConnector.sendSmsVerifcation({
|
||||||
|
toNumber: 491234567890,
|
||||||
|
fromName: 'ServeZone',
|
||||||
|
});
|
||||||
|
// verificationCode === '123456'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Connector Examples
|
||||||
|
|
||||||
|
### Email
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
await client.emailConnector.sendEmail({
|
||||||
|
to: 'user@example.com',
|
||||||
|
from: 'hello@serve.zone',
|
||||||
|
title: 'Invoice ready',
|
||||||
|
body: 'Your invoice is available in the dashboard.',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### SMS
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const status = await client.smsConnector.sendSms({
|
||||||
|
toNumber: 491234567890,
|
||||||
|
fromName: 'ServeZone',
|
||||||
|
messageText: 'Your code is 123456.',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### SMS Verification
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const code = await client.smsConnector.sendSmsVerifcation({
|
||||||
|
toNumber: 491234567890,
|
||||||
|
fromName: 'ServeZone',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Push Notifications
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const status = await client.pushNotificationConnector.sendPushNotification({
|
||||||
|
deviceToken: 'device-token-from-your-app',
|
||||||
|
message: 'Deployment complete: your service is live.',
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Letters
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
await client.letterConnector.sendLetter({
|
||||||
|
description: 'Important account information',
|
||||||
|
needsCover: true,
|
||||||
|
title: 'Account update',
|
||||||
|
coverBody: 'This letter was generated through serve.zone.',
|
||||||
|
service: ['Einschreiben'],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Exact request fields are defined by `@serve.zone/interfaces` and may evolve with the platform API.
|
||||||
|
|
||||||
|
## InfoHtml Helper
|
||||||
|
|
||||||
|
The repository also contains an `InfoHtml` helper in `ts_infohtml/` for rendering simple branded informational HTML pages from text or option objects.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { InfoHtml } from './ts_infohtml/index.js';
|
||||||
|
|
||||||
|
const infoPage = await InfoHtml.fromOptions({
|
||||||
|
title: 'Service unavailable',
|
||||||
|
heading: 'Maintenance in progress',
|
||||||
|
text: 'Please try again in a few minutes.',
|
||||||
|
redirectTo: 'https://serve.zone',
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(infoPage.htmlString);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install
|
||||||
|
pnpm test
|
||||||
|
pnpm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
The package is authored in TypeScript and builds the source folders through `tsbuild tsfolders --web --allowimplicitany`.
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
| Resource | URL |
|
||||||
|
| --- | --- |
|
||||||
|
| npm package | <https://www.npmjs.com/package/@serve.zone/platformclient> |
|
||||||
|
| Source | <https://gitlab.com/serve.zone/platformclient> |
|
||||||
|
| Source mirror | <https://github.com/serve.zone/platformclient> |
|
||||||
|
| Typedoc | <https://serve.zone.gitlab.io/platformclient/> |
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
import { tap } from '@git.zone/tstest/tapbundle';
|
||||||
import * as platformclient from '../ts/index.js'
|
import * as platformclient from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(platformclient)
|
console.log(platformclient);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
export default tap.start();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/platformclient',
|
name: '@serve.zone/platformclient',
|
||||||
version: '1.0.3',
|
version: '1.1.4',
|
||||||
description: 'a module that makes it really easy to use the serve.zone platform inside your app'
|
description: 'a module that makes it really easy to use the serve.zone platform inside your app'
|
||||||
}
|
}
|
||||||
|
|||||||
+216
-11
@@ -1,29 +1,234 @@
|
|||||||
import { SzEmailConnector } from './email/classes.emailconnector.js';
|
import { SzEmailConnector } from './email/classes.emailconnector.js';
|
||||||
import { SzSmsConnector } from './email/classes.smsconnector.js';
|
import { SzSmsConnector } from './email/classes.smsconnector.js';
|
||||||
|
import { SzPushNotificationConnector } from './email/classes.pushnotificationconnector.js';
|
||||||
|
import { SzLetterConnector } from './email/classes.letterconnector.js';
|
||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
|
export interface ISzPlatformClientOptions {
|
||||||
|
authorizationString?: string;
|
||||||
|
authorization?: string;
|
||||||
|
token?: string;
|
||||||
|
url?: string;
|
||||||
|
platformUrl?: string;
|
||||||
|
binding?: plugins.servezoneInterfaces.platform.IPlatformBinding;
|
||||||
|
bindings?: plugins.servezoneInterfaces.platform.IPlatformBinding[];
|
||||||
|
}
|
||||||
|
|
||||||
export class SzPlatformClient {
|
export class SzPlatformClient {
|
||||||
private authorizationString: string;
|
public debugMode = false;
|
||||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
private authorizationString?: string;
|
||||||
public typedsocket: plugins.typedsocket.TypedSocket;
|
private connectionAddress?: string;
|
||||||
|
public platformBindings: plugins.servezoneInterfaces.platform.IPlatformBinding[] = [];
|
||||||
|
public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
public typedsocket!: plugins.typedsocket.TypedSocket;
|
||||||
private qenvInstance = new plugins.qenv.Qenv();
|
private qenvInstance = new plugins.qenv.Qenv();
|
||||||
|
|
||||||
public emailConnector = new SzEmailConnector(this);
|
public emailConnector = new SzEmailConnector(this);
|
||||||
public smsConnector = new SzSmsConnector(this);
|
public smsConnector = new SzSmsConnector(this);
|
||||||
|
public pushNotificationConnector = new SzPushNotificationConnector(this);
|
||||||
|
public letterConnector = new SzLetterConnector(this);
|
||||||
|
|
||||||
constructor(authorizationStringArg?: string) {
|
constructor(authorizationStringArg?: string | ISzPlatformClientOptions) {
|
||||||
this.authorizationString = authorizationStringArg;
|
this.applyOptions(authorizationStringArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init(authorizationStringArg?: string) {
|
public async init(authorizationStringArg?: string | ISzPlatformClientOptions) {
|
||||||
if (authorizationStringArg) this.authorizationString = authorizationStringArg;
|
this.applyOptions(authorizationStringArg);
|
||||||
if (!this.authorizationString) this.authorizationString = process.env.SERVEZONE_PLATFROM_AUTHORIZATION;
|
if (!this.authorizationString) {
|
||||||
|
this.authorizationString = await this.getConfiguredAuthorizationString();
|
||||||
|
}
|
||||||
|
if (this.authorizationString === 'test') {
|
||||||
|
this.activateDebugMode();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.platformBindings = this.mergePlatformBindings(
|
||||||
|
this.platformBindings,
|
||||||
|
await this.discoverPlatformBindings()
|
||||||
|
);
|
||||||
|
if (!this.authorizationString) {
|
||||||
|
this.authorizationString = this.getAuthorizationStringFromBindings();
|
||||||
|
}
|
||||||
if (!this.authorizationString) throw new Error('authorizationString is required');
|
if (!this.authorizationString) throw new Error('authorizationString is required');
|
||||||
this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(this.typedrouter, await this.getConnectionAddress());
|
if (this.authorizationString === 'test') {
|
||||||
|
this.activateDebugMode();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(
|
||||||
|
this.typedrouter as any,
|
||||||
|
await this.getConnectionAddress()
|
||||||
|
);
|
||||||
|
await this.setAuthorizationTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
private activateDebugMode() {
|
||||||
|
this.debugMode = true;
|
||||||
|
console.log('debug mode activated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public getPlatformBinding(
|
||||||
|
capabilityArg?: plugins.servezoneInterfaces.platform.TPlatformCapability
|
||||||
|
) {
|
||||||
|
return this.platformBindings.find((bindingArg) => {
|
||||||
|
return (
|
||||||
|
bindingArg.desiredState !== 'disabled' &&
|
||||||
|
bindingArg.status !== 'failed' &&
|
||||||
|
(!capabilityArg || bindingArg.capability === capabilityArg)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private applyOptions(optionsArg?: string | ISzPlatformClientOptions) {
|
||||||
|
if (!optionsArg) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof optionsArg === 'string') {
|
||||||
|
this.authorizationString = optionsArg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.authorizationString =
|
||||||
|
optionsArg.authorizationString ||
|
||||||
|
optionsArg.authorization ||
|
||||||
|
optionsArg.token ||
|
||||||
|
this.authorizationString;
|
||||||
|
this.connectionAddress = optionsArg.url || optionsArg.platformUrl || this.connectionAddress;
|
||||||
|
this.platformBindings = this.mergePlatformBindings(
|
||||||
|
this.platformBindings,
|
||||||
|
[optionsArg.binding, ...(optionsArg.bindings || [])].filter(
|
||||||
|
Boolean
|
||||||
|
) as plugins.servezoneInterfaces.platform.IPlatformBinding[]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getConnectionAddress() {
|
private async getConnectionAddress() {
|
||||||
const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
|
const connectionAddress =
|
||||||
|
this.connectionAddress ||
|
||||||
|
(await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_URL')) ||
|
||||||
|
this.getConnectionAddressFromBindings();
|
||||||
|
if (!connectionAddress) throw new Error('SERVEZONE_PLATFORM_URL or platform binding endpoint is required');
|
||||||
return connectionAddress;
|
return connectionAddress;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private getConnectionAddressFromBindings() {
|
||||||
|
for (const binding of this.platformBindings) {
|
||||||
|
if (binding.desiredState === 'disabled' || binding.status === 'failed') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!this.isSupportedConnectorCapability(binding.capability)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const endpoint = binding.endpoints?.find((endpointArg) => {
|
||||||
|
return endpointArg.protocol === 'typedrequest' || endpointArg.protocol === 'http';
|
||||||
|
});
|
||||||
|
const endpointUrl = endpoint?.internalUrl || endpoint?.externalUrl;
|
||||||
|
if (endpointUrl) {
|
||||||
|
return endpointUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private isSupportedConnectorCapability(
|
||||||
|
capabilityArg: plugins.servezoneInterfaces.platform.TPlatformCapability
|
||||||
|
) {
|
||||||
|
return ['email', 'sms', 'pushnotification', 'letter'].includes(capabilityArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getConfiguredAuthorizationString() {
|
||||||
|
return (
|
||||||
|
(await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_AUTHORIZATION')) ||
|
||||||
|
(await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_TOKEN'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getAuthorizationStringFromBindings() {
|
||||||
|
const authEnvNames = [
|
||||||
|
'SERVEZONE_PLATFORM_AUTHORIZATION',
|
||||||
|
'SERVEZONE_PLATFORM_TOKEN',
|
||||||
|
'SERVEZONE_API_TOKEN',
|
||||||
|
'AUTHORIZATION',
|
||||||
|
'TOKEN',
|
||||||
|
];
|
||||||
|
for (const binding of this.platformBindings) {
|
||||||
|
for (const credential of binding.credentials || []) {
|
||||||
|
for (const envName of authEnvNames) {
|
||||||
|
const value = credential.env?.[envName];
|
||||||
|
if (value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async setAuthorizationTag() {
|
||||||
|
if (!this.authorizationString) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await this.typedsocket.setTag('authorization' as any, this.authorizationString);
|
||||||
|
} catch (error) {
|
||||||
|
if (await this.getConfiguredEnvVar('SERVEZONE_PLATFORMCLIENT_DEBUG')) {
|
||||||
|
console.warn('Could not set platform authorization tag:', (error as Error).message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async discoverPlatformBindings() {
|
||||||
|
const bindings: plugins.servezoneInterfaces.platform.IPlatformBinding[] = [];
|
||||||
|
const envBindings = await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_BINDINGS');
|
||||||
|
const envBinding = await this.getConfiguredEnvVar('SERVEZONE_PLATFORM_BINDING');
|
||||||
|
|
||||||
|
if (envBindings) {
|
||||||
|
bindings.push(...this.parsePlatformBindingsEnv('SERVEZONE_PLATFORM_BINDINGS', envBindings));
|
||||||
|
}
|
||||||
|
if (envBinding) {
|
||||||
|
bindings.push(...this.parsePlatformBindingsEnv('SERVEZONE_PLATFORM_BINDING', envBinding));
|
||||||
|
}
|
||||||
|
|
||||||
|
return bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private parsePlatformBindingsEnv(envNameArg: string, envValueArg: string) {
|
||||||
|
let parsedValue: unknown;
|
||||||
|
try {
|
||||||
|
parsedValue = JSON.parse(envValueArg);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`${envNameArg} must contain valid JSON`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(parsedValue)) {
|
||||||
|
return parsedValue as plugins.servezoneInterfaces.platform.IPlatformBinding[];
|
||||||
|
}
|
||||||
|
if (parsedValue && typeof parsedValue === 'object') {
|
||||||
|
return [parsedValue as plugins.servezoneInterfaces.platform.IPlatformBinding];
|
||||||
|
}
|
||||||
|
throw new Error(`${envNameArg} must contain a platform binding object or array`);
|
||||||
|
}
|
||||||
|
|
||||||
|
private mergePlatformBindings(
|
||||||
|
existingBindingsArg: plugins.servezoneInterfaces.platform.IPlatformBinding[],
|
||||||
|
newBindingsArg: plugins.servezoneInterfaces.platform.IPlatformBinding[]
|
||||||
|
) {
|
||||||
|
const bindingMap = new Map<string, plugins.servezoneInterfaces.platform.IPlatformBinding>();
|
||||||
|
for (const binding of [...existingBindingsArg, ...newBindingsArg]) {
|
||||||
|
bindingMap.set(binding.id, binding);
|
||||||
|
}
|
||||||
|
return Array.from(bindingMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getConfiguredEnvVar(envNameArg: string) {
|
||||||
|
const processValue = this.getProcessEnvVar(envNameArg);
|
||||||
|
if (processValue) {
|
||||||
|
return processValue;
|
||||||
|
}
|
||||||
|
return this.qenvInstance.getEnvVarOnDemand(envNameArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getProcessEnvVar(envNameArg: string) {
|
||||||
|
const processEnv = (globalThis as typeof globalThis & {
|
||||||
|
process?: { env?: Record<string, string | undefined> };
|
||||||
|
}).process?.env;
|
||||||
|
return processEnv?.[envNameArg];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import * as plugins from './plugins.js';
|
|
||||||
import { InfoHtml } from './infohtml/index.js';
|
|
||||||
|
|
||||||
export interface IServiceServerConstructorOptions {
|
|
||||||
addCustomRoutes?: (serverArg: plugins.typedserver.servertools.Server) => Promise<any>;
|
|
||||||
serviceName: string;
|
|
||||||
serviceVersion: string;
|
|
||||||
serviceDomain: string;
|
|
||||||
port?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* a server for serving your app to the outside world
|
|
||||||
*/
|
|
||||||
export class ServiceServer {
|
|
||||||
public options: IServiceServerConstructorOptions;
|
|
||||||
public typedServer: plugins.typedserver.TypedServer;
|
|
||||||
|
|
||||||
constructor(optionsArg: IServiceServerConstructorOptions) {
|
|
||||||
this.options = optionsArg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async start() {
|
|
||||||
console.log('starting lole-serviceserver...')
|
|
||||||
this.typedServer = new plugins.typedserver.TypedServer({
|
|
||||||
cors: true,
|
|
||||||
domain: this.options.serviceDomain,
|
|
||||||
forceSsl: false,
|
|
||||||
port: this.options.port || 3000,
|
|
||||||
robots: true,
|
|
||||||
defaultAnswer: async () => {
|
|
||||||
return (
|
|
||||||
await InfoHtml.fromSimpleText(
|
|
||||||
`${this.options.serviceName} (version ${this.options.serviceVersion})`
|
|
||||||
)
|
|
||||||
).htmlString;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// lets add any custom routes
|
|
||||||
if (this.options.addCustomRoutes) {
|
|
||||||
await this.options.addCustomRoutes(this.typedServer.server);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.typedServer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async stop() {
|
|
||||||
await this.typedServer.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { SzPlatformClient } from '../classes.platformclient.js';
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
import { logger } from '../logger.js';
|
||||||
|
|
||||||
export class SzEmailConnector {
|
export class SzEmailConnector {
|
||||||
public platformClientRef: SzPlatformClient;
|
public platformClientRef: SzPlatformClient;
|
||||||
|
|
||||||
@@ -9,13 +11,26 @@ export class SzEmailConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async sendEmail(
|
public async sendEmail(
|
||||||
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
|
optionsArg: plugins.servezoneInterfaces.platform.email.IReq_SendEmail['request']
|
||||||
) {
|
) {
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
|
||||||
|
body:
|
||||||
|
${optionsArg.body.split('\n').map(line => ` ${line}`).join('\n')}
|
||||||
|
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const typedRequest =
|
const typedRequest =
|
||||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.email.IReq_SendEmail>(
|
||||||
'sendEmail'
|
'sendEmail'
|
||||||
);
|
);
|
||||||
const response = await typedRequest.fire(optionsArg);
|
const response = await typedRequest.fire(optionsArg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
|
public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
|
||||||
|
|||||||
@@ -9,12 +9,21 @@ export class SzLetterConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async sendLetter(
|
public async sendLetter(
|
||||||
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
|
optionsArg: plugins.servezoneInterfaces.platform.letter.IReq_SendLetter['request']
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
console.log('sendLetter', optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const typedRequest =
|
const typedRequest =
|
||||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter>(
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.letter.IReq_SendLetter>(
|
||||||
'sendLetter'
|
'sendLetter'
|
||||||
);
|
);
|
||||||
const response = await typedRequest.fire(optionsArg);
|
const response = await typedRequest.fire(optionsArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
export class SzPushNotificationConnector {
|
||||||
|
public platformClientRef: SzPlatformClient;
|
||||||
|
|
||||||
|
constructor(platformClientRefArg: SzPlatformClient) {
|
||||||
|
this.platformClientRef = platformClientRefArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendPushNotification(
|
||||||
|
optionsArg: plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification['request']
|
||||||
|
) {
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
console.log('sendPushNotification', optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const typedRequest =
|
||||||
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.pushnotification.IReq_SendPushNotification>(
|
||||||
|
'sendPushNotification'
|
||||||
|
);
|
||||||
|
const response = await typedRequest.fire(optionsArg);
|
||||||
|
|
||||||
|
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
||||||
|
console.log('sendPushNotification response', response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { SzPlatformClient } from '../classes.platformclient.js';
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
|
import { logger } from '../logger.js';
|
||||||
import * as plugins from '../plugins.js';
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
export class SzSmsConnector {
|
export class SzSmsConnector {
|
||||||
@@ -8,19 +9,38 @@ export class SzSmsConnector {
|
|||||||
this.platformClientRef = platformClientRefArg;
|
this.platformClientRef = platformClientRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
public async sendSms(messageArg: plugins.servezoneInterfaces.platform.sms.IReq_SendSms['request']) {
|
||||||
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
if (this.platformClientRef.debugMode) {
|
||||||
|
logger.log('info', `sent sms to ${messageArg.toNumber}}
|
||||||
|
body:
|
||||||
|
${messageArg.messageText.split('\n').map(line => ` ${line}`).join('\n')}
|
||||||
|
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendSms>(
|
||||||
'sendSms'
|
'sendSms'
|
||||||
);
|
);
|
||||||
const response = await typedrequest.fire(messageArg);
|
const response = await typedrequest.fire(messageArg);
|
||||||
|
|
||||||
return response.status;
|
return response.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendSmsVerifcation(
|
public async sendSmsVerifcation(
|
||||||
recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']
|
recipientArg: plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode['request']
|
||||||
) {
|
) {
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
console.log('sendSmsVerifcation', recipientArg, '123456');
|
||||||
|
return '123456';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const typedrequest =
|
const typedrequest =
|
||||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode>(
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platform.sms.IReq_SendVerificationCode>(
|
||||||
'sendVerificationCode'
|
'sendVerificationCode'
|
||||||
);
|
);
|
||||||
const response = await typedrequest.fire(recipientArg);
|
const response = await typedrequest.fire(recipientArg);
|
||||||
|
|||||||
+1
-7
@@ -1,7 +1 @@
|
|||||||
export * from './classes.serviceserver.js';
|
export * from './classes.platformclient.js';
|
||||||
|
|
||||||
// Things for building a server
|
|
||||||
import { servertools } from '@api.global/typedserver';
|
|
||||||
const { Handler, HandlerTypedRouter } = servertools;
|
|
||||||
export { Handler, HandlerTypedRouter };
|
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -6,4 +6,6 @@ export const logger = new plugins.smartlog.Smartlog({
|
|||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'serve.zone',
|
zone: 'serve.zone',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.enableConsole();
|
||||||
@@ -8,12 +8,10 @@ export {
|
|||||||
// @push.rocks scope
|
// @push.rocks scope
|
||||||
import * as qenv from '@push.rocks/qenv';
|
import * as qenv from '@push.rocks/qenv';
|
||||||
import * as smartlog from '@push.rocks/smartlog';
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
import * as smartntml from '@push.rocks/smartntml';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
qenv,
|
qenv,
|
||||||
smartlog,
|
smartlog,
|
||||||
smartntml,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
import { simpleInfo } from './template.js';
|
import { simpleInfo } from './template.js';
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ export class InfoHtml {
|
|||||||
public static async fromSimpleText(textArg: string) {
|
public static async fromSimpleText(textArg: string) {
|
||||||
const infohtmlInstance = new InfoHtml({
|
const infohtmlInstance = new InfoHtml({
|
||||||
text: textArg,
|
text: textArg,
|
||||||
heading: null,
|
|
||||||
});
|
});
|
||||||
await infohtmlInstance.init();
|
await infohtmlInstance.init();
|
||||||
return infohtmlInstance;
|
return infohtmlInstance;
|
||||||
@@ -30,8 +29,8 @@ export class InfoHtml {
|
|||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public options: IHtmlInfoOptions;
|
public options: IHtmlInfoOptions;
|
||||||
public smartntmlInstance: plugins.smartntml.Smartntml;
|
public smartntmlInstance?: plugins.smartntml.Smartntml;
|
||||||
public htmlString: string;
|
public htmlString = '';
|
||||||
constructor(optionsArg: IHtmlInfoOptions) {
|
constructor(optionsArg: IHtmlInfoOptions) {
|
||||||
this.options = optionsArg;
|
this.options = optionsArg;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import * as smartntml from '@push.rocks/smartntml';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartntml,
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { type IHtmlInfoOptions } from './classes.infohtml.js';
|
import { type IHtmlInfoOptions } from './classes.infohtml.js';
|
||||||
|
|
||||||
export const simpleInfo = async (
|
export const simpleInfo = async (
|
||||||
Reference in New Issue
Block a user