fix(core): update
This commit is contained in:
commit
450e4e023d
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
18
npmextra.json
Normal file
18
npmextra.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "serve.zone",
|
||||||
|
"gitrepo": "platformclient",
|
||||||
|
"description": "a module that makes it really easy to use the serve.zone platform inside your app",
|
||||||
|
"npmPackagename": "@serve.zone/platformclient",
|
||||||
|
"license": "MIT",
|
||||||
|
"projectDomain": "serve.zone"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
}
|
||||||
|
}
|
56
package.json
Normal file
56
package.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "@serve.zone/platformclient",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"private": false,
|
||||||
|
"description": "a module that makes it really easy to use the serve.zone platform inside your app",
|
||||||
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
|
"author": "Task Venture Capital GmbH",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"test": "(tstest test/ --web)",
|
||||||
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@git.zone/tsbuild": "^2.1.25",
|
||||||
|
"@git.zone/tsbundle": "^2.0.5",
|
||||||
|
"@git.zone/tsrun": "^1.2.46",
|
||||||
|
"@git.zone/tstest": "^1.0.44",
|
||||||
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
|
"@types/node": "^20.11.19"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@api.global/typedrequest": "^3.0.4",
|
||||||
|
"@api.global/typedserver": "^3.0.20",
|
||||||
|
"@api.global/typedsocket": "^3.0.0",
|
||||||
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
|
"@push.rocks/smartlog": "^3.0.3",
|
||||||
|
"@push.rocks/smartntml": "^2.0.4",
|
||||||
|
"@serve.zone/interfaces": "^1.0.35"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://gitlab.com/serve.zone/platformclient.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://gitlab.com/serve.zone/platformclient/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitlab.com/serve.zone/platformclient#readme",
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
|
}
|
6432
pnpm-lock.yaml
generated
Normal file
6432
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
readme.md
Normal file
31
readme.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# @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/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [![pipeline status](https://gitlab.com/serve.zone/platformclient/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/serve.zone/platformclient/badges/master/coverage.svg)](https://lossless.cloud)
|
||||||
|
npm | [![npm downloads per month](https://badgen.net/npm/dy/@serve.zone/platformclient)](https://lossless.cloud)
|
||||||
|
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/serve.zone/platformclient)](https://lossless.cloud)
|
||||||
|
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||||
|
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@serve.zone/platformclient)](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@serve.zone/platformclient)](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@serve.zone/platformclient)](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use TypeScript for best in class intellisense
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
## 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)
|
8
test/test.ts
Normal file
8
test/test.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||||
|
import * as platformclient from '../ts/index.js'
|
||||||
|
|
||||||
|
tap.test('first test', async () => {
|
||||||
|
console.log(platformclient)
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.start()
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@serve.zone/platformclient',
|
||||||
|
version: '1.0.2',
|
||||||
|
description: 'a module that makes it really easy to use the serve.zone platform inside your app'
|
||||||
|
}
|
26
ts/classes.platformclient.ts
Normal file
26
ts/classes.platformclient.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { SzEmailConnector } from './email/classes.emailconnector.js';
|
||||||
|
import { SzSmsConnector } from './email/classes.smsconnector.js';
|
||||||
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
|
export class SzPlatformClient {
|
||||||
|
private authorizationString: string;
|
||||||
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
|
public typedsocket: plugins.typedsocket.TypedSocket;
|
||||||
|
private qenvInstance = new plugins.qenv.Qenv();
|
||||||
|
|
||||||
|
public emailConnector = new SzEmailConnector(this);
|
||||||
|
public smsConnector = new SzSmsConnector(this);
|
||||||
|
|
||||||
|
constructor(authorizationStringArg: string) {
|
||||||
|
this.authorizationString = authorizationStringArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async init() {
|
||||||
|
this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(this.typedrouter, await this.getConnectionAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getConnectionAddress() {
|
||||||
|
const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
|
||||||
|
return connectionAddress;
|
||||||
|
}
|
||||||
|
}
|
51
ts/classes.serviceserver.ts
Normal file
51
ts/classes.serviceserver.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
24
ts/email/classes.emailconnector.ts
Normal file
24
ts/email/classes.emailconnector.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
export class SzEmailConnector {
|
||||||
|
public platformClientRef: SzPlatformClient;
|
||||||
|
|
||||||
|
constructor(platformClientRefArg: SzPlatformClient) {
|
||||||
|
this.platformClientRef = platformClientRefArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendEmail(
|
||||||
|
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
|
||||||
|
) {
|
||||||
|
const typedRequest =
|
||||||
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
|
||||||
|
'sendEmail'
|
||||||
|
);
|
||||||
|
const response = await typedRequest.fire(optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
|
||||||
|
|
||||||
|
public async sendActionLink(optionsArg: { toArg: string; subject: string; text: string }) {}
|
||||||
|
}
|
20
ts/email/classes.letterconnector.ts
Normal file
20
ts/email/classes.letterconnector.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
|
|
||||||
|
export class SzLetterConnector {
|
||||||
|
public platformClientRef: SzPlatformClient;
|
||||||
|
|
||||||
|
constructor(platformClientRefArg: SzPlatformClient) {
|
||||||
|
this.platformClientRef = platformClientRefArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendLetter(
|
||||||
|
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
|
||||||
|
) {
|
||||||
|
const typedRequest =
|
||||||
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter>(
|
||||||
|
'sendLetter'
|
||||||
|
);
|
||||||
|
const response = await typedRequest.fire(optionsArg);
|
||||||
|
}
|
||||||
|
}
|
29
ts/email/classes.smsconnector.ts
Normal file
29
ts/email/classes.smsconnector.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
export class SzSmsConnector {
|
||||||
|
public platformClientRef: SzPlatformClient;
|
||||||
|
|
||||||
|
constructor(platformClientRefArg: SzPlatformClient) {
|
||||||
|
this.platformClientRef = platformClientRefArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
||||||
|
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
||||||
|
'sendSms'
|
||||||
|
);
|
||||||
|
const response = await typedrequest.fire(messageArg);
|
||||||
|
return response.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendSmsVerifcation(
|
||||||
|
recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']
|
||||||
|
) {
|
||||||
|
const typedrequest =
|
||||||
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode>(
|
||||||
|
'sendVerificationCode'
|
||||||
|
);
|
||||||
|
const response = await typedrequest.fire(recipientArg);
|
||||||
|
return response.verificationCode;
|
||||||
|
}
|
||||||
|
}
|
7
ts/index.ts
Normal file
7
ts/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export * from './classes.serviceserver.js';
|
||||||
|
|
||||||
|
// Things for building a server
|
||||||
|
import { servertools } from '@api.global/typedserver';
|
||||||
|
const { Handler, HandlerTypedRouter } = servertools;
|
||||||
|
export { Handler, HandlerTypedRouter };
|
||||||
|
|
44
ts/infohtml/classes.infohtml.ts
Normal file
44
ts/infohtml/classes.infohtml.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
|
||||||
|
import { simpleInfo } from './template.js';
|
||||||
|
|
||||||
|
export interface IHtmlInfoOptions {
|
||||||
|
text: string;
|
||||||
|
heading?: string;
|
||||||
|
title?: string;
|
||||||
|
sentryMessage?: string;
|
||||||
|
sentryDsn?: string;
|
||||||
|
redirectTo?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class InfoHtml {
|
||||||
|
// STATIC
|
||||||
|
public static async fromSimpleText(textArg: string) {
|
||||||
|
const infohtmlInstance = new InfoHtml({
|
||||||
|
text: textArg,
|
||||||
|
heading: null,
|
||||||
|
});
|
||||||
|
await infohtmlInstance.init();
|
||||||
|
return infohtmlInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async fromOptions(optionsArg: IHtmlInfoOptions) {
|
||||||
|
const infohtmlInstance = new InfoHtml(optionsArg);
|
||||||
|
await infohtmlInstance.init();
|
||||||
|
return infohtmlInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public options: IHtmlInfoOptions;
|
||||||
|
public smartntmlInstance: plugins.smartntml.Smartntml;
|
||||||
|
public htmlString: string;
|
||||||
|
constructor(optionsArg: IHtmlInfoOptions) {
|
||||||
|
this.options = optionsArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async init() {
|
||||||
|
this.smartntmlInstance = new plugins.smartntml.Smartntml();
|
||||||
|
this.htmlString = await simpleInfo(this.smartntmlInstance, this.options);
|
||||||
|
return this.htmlString;
|
||||||
|
}
|
||||||
|
}
|
1
ts/infohtml/index.ts
Normal file
1
ts/infohtml/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { InfoHtml } from './classes.infohtml.js';
|
162
ts/infohtml/template.ts
Normal file
162
ts/infohtml/template.ts
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
import { type IHtmlInfoOptions } from './classes.infohtml.js';
|
||||||
|
|
||||||
|
export const simpleInfo = async (
|
||||||
|
smartntmlInstanceArg: plugins.smartntml.Smartntml,
|
||||||
|
optionsArg: IHtmlInfoOptions
|
||||||
|
) => {
|
||||||
|
const html = plugins.smartntml.deesElement.html;
|
||||||
|
const htmlTemplate = await plugins.smartntml.deesElement.html`
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>${optionsArg.title}</title>
|
||||||
|
<script>
|
||||||
|
setTimeout(() => {
|
||||||
|
const redirectUrl = '${optionsArg.redirectTo}';
|
||||||
|
if (redirectUrl) {
|
||||||
|
window.location = redirectUrl;
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0px;
|
||||||
|
background: #000000;
|
||||||
|
font-family: 'Roboto Mono', monospace;
|
||||||
|
min-height: 100vh;
|
||||||
|
min-width: 100vw;
|
||||||
|
border: 1px solid #e4002b;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
width: 150px;
|
||||||
|
padding-top: 70px;
|
||||||
|
margin: 0px auto 30px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
text-align: center;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .maintext {
|
||||||
|
margin: 10px;
|
||||||
|
color: #ffffff;
|
||||||
|
background: #333;
|
||||||
|
display: block;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .maintext h1 {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .addontext {
|
||||||
|
margin: 10px;
|
||||||
|
color: #ffffff;
|
||||||
|
background: #222;
|
||||||
|
display: block;
|
||||||
|
padding: 10px 15px;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .text h1 {
|
||||||
|
margin: 0px;
|
||||||
|
font-weight: 100;
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .text ul {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legal {
|
||||||
|
color: #fff;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0px;
|
||||||
|
width: 100vw;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
|
||||||
|
/>
|
||||||
|
<script
|
||||||
|
src="https://browser.sentry-cdn.com/5.4.0/bundle.min.js"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
></script>
|
||||||
|
<script>
|
||||||
|
const sentryDsn = '${optionsArg.sentryDsn}';
|
||||||
|
const sentryMessage = '${optionsArg.sentryMessage}';
|
||||||
|
if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
|
||||||
|
Sentry.init({
|
||||||
|
dsn: '${optionsArg.sentryDsn}',
|
||||||
|
// ...
|
||||||
|
});
|
||||||
|
Sentry.setExtra('location', window.location.href);
|
||||||
|
Sentry.captureMessage('${optionsArg.sentryMessage} @ ' + window.location.host);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="logo">
|
||||||
|
<img src="https://assetbroker.lossless.one/brandfiles/lossless/svg-minimal-bright.svg" />
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
${(() => {
|
||||||
|
const returnArray: plugins.smartntml.deesElement.TemplateResult[] = [];
|
||||||
|
if (optionsArg.heading) {
|
||||||
|
returnArray.push(html`
|
||||||
|
<div class="maintext">
|
||||||
|
<h1>${optionsArg.heading}</h1>
|
||||||
|
${optionsArg.text}
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
returnArray.push(html` <div class="maintext">${optionsArg.text}</div> `);
|
||||||
|
}
|
||||||
|
if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
|
||||||
|
returnArray.push(
|
||||||
|
html`<div class="addontext">
|
||||||
|
We recorded this event. Should you continue to see this page against your
|
||||||
|
expectations, feel free to mail us at
|
||||||
|
<a href="mailto:hello@lossless.com">hello@lossless.com</a>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (optionsArg.redirectTo) {
|
||||||
|
returnArray.push(
|
||||||
|
html`<div class="addontext">
|
||||||
|
We will redirect you to ${optionsArg.redirectTo} in a few seconds.
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return returnArray;
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
<div class="legal">
|
||||||
|
<a href="https://lossless.com">Lossless GmbH</a> / © 2014-${new Date().getFullYear()}
|
||||||
|
/ <a href="https://lossless.gmbh">Legal Info</a> /
|
||||||
|
<a href="https://lossless.gmbh">Privacy Policy</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
return smartntmlInstanceArg.renderTemplateResult(htmlTemplate);
|
||||||
|
};
|
9
ts/logger.ts
Normal file
9
ts/logger.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
|
logContext: {
|
||||||
|
environment: 'production',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'serve.zone',
|
||||||
|
}
|
||||||
|
});
|
29
ts/plugins.ts
Normal file
29
ts/plugins.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// @serve.zone scope
|
||||||
|
import * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||||
|
|
||||||
|
export {
|
||||||
|
servezoneInterfaces,
|
||||||
|
}
|
||||||
|
|
||||||
|
// @push.rocks scope
|
||||||
|
import * as qenv from '@push.rocks/qenv';
|
||||||
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
|
import * as smartntml from '@push.rocks/smartntml';
|
||||||
|
|
||||||
|
export {
|
||||||
|
qenv,
|
||||||
|
smartlog,
|
||||||
|
smartntml,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @api.global scope
|
||||||
|
import * as typedrequest from '@api.global/typedrequest';
|
||||||
|
import * as typedserver from '@api.global/typedserver';
|
||||||
|
import * as typedsocket from '@api.global/typedsocket';
|
||||||
|
|
||||||
|
export {
|
||||||
|
typedrequest,
|
||||||
|
typedserver,
|
||||||
|
typedsocket,
|
||||||
|
}
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user