chore(deps): modernize platformclient tooling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
@@ -9,10 +9,17 @@
|
||||
"npmPackagename": "@serve.zone/platformclient",
|
||||
"license": "MIT",
|
||||
"projectDomain": "serve.zone"
|
||||
},
|
||||
"release": {
|
||||
"registries": [
|
||||
"https://verdaccio.lossless.digital",
|
||||
"https://registry.npmjs.org"
|
||||
],
|
||||
"accessLevel": "public"
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"@ship.zone/szci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+5
-5
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"fileMatch": ["/.smartconfig.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"@ship.zone/szci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
"description": "settings for szci"
|
||||
},
|
||||
"gitzone": {
|
||||
"@git.zone/cli": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"description": "settings for git.zone CLI",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
|
||||
@@ -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.
|
||||
+14
-14
@@ -14,20 +14,19 @@
|
||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.84",
|
||||
"@git.zone/tsbundle": "^2.0.5",
|
||||
"@git.zone/tsrun": "^1.2.49",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.3.0",
|
||||
"@types/node": "^22.7.4"
|
||||
"@git.zone/tsbuild": "^4.4.0",
|
||||
"@git.zone/tsbundle": "^2.10.0",
|
||||
"@git.zone/tsrun": "^2.0.2",
|
||||
"@git.zone/tstest": "^3.6.3",
|
||||
"@types/node": "^25.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedrequest": "^3.0.32",
|
||||
"@api.global/typedserver": "^3.0.51",
|
||||
"@api.global/typedsocket": "^3.0.1",
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartntml": "^2.0.4",
|
||||
"@api.global/typedrequest": "^3.3.0",
|
||||
"@api.global/typedserver": "^8.4.6",
|
||||
"@api.global/typedsocket": "^4.1.2",
|
||||
"@push.rocks/qenv": "^6.1.3",
|
||||
"@push.rocks/smartlog": "^3.2.2",
|
||||
"@push.rocks/smartntml": "^2.0.8",
|
||||
"@serve.zone/interfaces": "^5.4.4"
|
||||
},
|
||||
"repository": {
|
||||
@@ -50,7 +49,8 @@
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
".smartconfig.json",
|
||||
"readme.md"
|
||||
]
|
||||
],
|
||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
|
||||
}
|
||||
|
||||
Generated
+6036
-3475
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,194 @@
|
||||
# @serve.zone/platformclient
|
||||
a module that makes it really easy to use the serve.zone platform inside your app
|
||||
|
||||
## Availabililty and Links
|
||||
* [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/)
|
||||
`@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.
|
||||
|
||||
## 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
|
||||
-- | --
|
||||
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)
|
||||
## Issue Reporting and Security
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class intellisense
|
||||
For further information read the linked docs at the top of this readme.
|
||||
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.
|
||||
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
## Installation
|
||||
|
||||
```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_API_DOMAIN`.
|
||||
|
||||
## Configuration
|
||||
|
||||
The client needs two values:
|
||||
|
||||
| Value | How to provide it | Notes |
|
||||
| --- | --- | --- |
|
||||
| Authorization token | Constructor argument, `init()` argument, or `SERVEZONE_PLATFROM_AUTHORIZATION` | The current environment variable name is intentionally documented as implemented. |
|
||||
| API domain | `SERVEZONE_API_DOMAIN` | Loaded on demand through `@push.rocks/qenv`. |
|
||||
|
||||
```typescript
|
||||
const client = new SzPlatformClient();
|
||||
await client.init('your-platform-authorization-token');
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
+2
-2
@@ -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';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(platformclient);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
|
||||
@@ -6,9 +6,9 @@ import * as plugins from './plugins.js';
|
||||
|
||||
export class SzPlatformClient {
|
||||
public debugMode = false;
|
||||
private authorizationString: string;
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
public typedsocket: plugins.typedsocket.TypedSocket;
|
||||
private authorizationString?: string;
|
||||
public typedrouter: plugins.typedrequest.TypedRouter = new plugins.typedrequest.TypedRouter();
|
||||
public typedsocket!: plugins.typedsocket.TypedSocket;
|
||||
private qenvInstance = new plugins.qenv.Qenv();
|
||||
|
||||
public emailConnector = new SzEmailConnector(this);
|
||||
@@ -40,6 +40,7 @@ export class SzPlatformClient {
|
||||
|
||||
private async getConnectionAddress() {
|
||||
const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
|
||||
if (!connectionAddress) throw new Error('SERVEZONE_API_DOMAIN is required');
|
||||
return connectionAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ export class InfoHtml {
|
||||
public static async fromSimpleText(textArg: string) {
|
||||
const infohtmlInstance = new InfoHtml({
|
||||
text: textArg,
|
||||
heading: null,
|
||||
});
|
||||
await infohtmlInstance.init();
|
||||
return infohtmlInstance;
|
||||
@@ -30,8 +29,8 @@ export class InfoHtml {
|
||||
|
||||
// INSTANCE
|
||||
public options: IHtmlInfoOptions;
|
||||
public smartntmlInstance: plugins.smartntml.Smartntml;
|
||||
public htmlString: string;
|
||||
public smartntmlInstance?: plugins.smartntml.Smartntml;
|
||||
public htmlString = '';
|
||||
constructor(optionsArg: IHtmlInfoOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as smartntml from '@push.rocks/smartntml';
|
||||
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user