Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e16c8876b8 | |||
1212ee9116 | |||
b610cba9ac | |||
854f1f73dc | |||
edc54f4fc1 | |||
7e721eb48e | |||
965dad9b15 | |||
4a75c109e3 | |||
7d0925ad33 | |||
63700c3754 |
31
changelog.md
31
changelog.md
@ -1,5 +1,36 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 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)
|
## 2024-10-02 - 1.0.9 - fix(infohtml)
|
||||||
Refactor infohtml module and fix import paths
|
Refactor infohtml module and fix import paths
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/platformclient",
|
"name": "@serve.zone/platformclient",
|
||||||
"version": "1.0.9",
|
"version": "1.1.2",
|
||||||
"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,7 +10,7 @@
|
|||||||
"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": {
|
||||||
@ -28,7 +28,7 @@
|
|||||||
"@push.rocks/qenv": "^6.0.5",
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
"@push.rocks/smartlog": "^3.0.7",
|
"@push.rocks/smartlog": "^3.0.7",
|
||||||
"@push.rocks/smartntml": "^2.0.4",
|
"@push.rocks/smartntml": "^2.0.4",
|
||||||
"@serve.zone/interfaces": "^1.0.81"
|
"@serve.zone/interfaces": "^1.1.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -27,8 +27,8 @@ importers:
|
|||||||
specifier: ^2.0.4
|
specifier: ^2.0.4
|
||||||
version: 2.0.4
|
version: 2.0.4
|
||||||
'@serve.zone/interfaces':
|
'@serve.zone/interfaces':
|
||||||
specifier: ^1.0.81
|
specifier: ^1.1.1
|
||||||
version: 1.0.81
|
version: 1.1.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@git.zone/tsbuild':
|
'@git.zone/tsbuild':
|
||||||
specifier: ^2.1.84
|
specifier: ^2.1.84
|
||||||
@ -599,8 +599,8 @@ packages:
|
|||||||
'@sec-ant/readable-stream@0.4.1':
|
'@sec-ant/readable-stream@0.4.1':
|
||||||
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
||||||
|
|
||||||
'@serve.zone/interfaces@1.0.81':
|
'@serve.zone/interfaces@1.1.1':
|
||||||
resolution: {integrity: sha512-ra0pALnvhYut2Ts55BHWKv8q1ysjf84AS0cG/Pi8FB53/OqCnaaETr2qJrAETa6OcuDDDm++R0KVZm+R5evbwQ==}
|
resolution: {integrity: sha512-Ir9xs06UYvsGoo67en7hitzMxZJ3kOBZWoQs5HIV+dTTd/5eMBjidFPJH+x6MSZsr3mb907s5Sfmb8FEtgMFYA==}
|
||||||
|
|
||||||
'@sindresorhus/is@5.6.0':
|
'@sindresorhus/is@5.6.0':
|
||||||
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
|
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
|
||||||
@ -3963,7 +3963,7 @@ snapshots:
|
|||||||
|
|
||||||
'@sec-ant/readable-stream@0.4.1': {}
|
'@sec-ant/readable-stream@0.4.1': {}
|
||||||
|
|
||||||
'@serve.zone/interfaces@1.0.81':
|
'@serve.zone/interfaces@1.1.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@api.global/typedrequest-interfaces': 3.0.19
|
'@api.global/typedrequest-interfaces': 3.0.19
|
||||||
'@push.rocks/smartlog-interfaces': 3.0.2
|
'@push.rocks/smartlog-interfaces': 3.0.2
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/platformclient',
|
name: '@serve.zone/platformclient',
|
||||||
version: '1.0.9',
|
version: '1.1.2',
|
||||||
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'
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
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 class SzPlatformClient {
|
export class SzPlatformClient {
|
||||||
|
public debugMode = false;
|
||||||
private authorizationString: string;
|
private authorizationString: string;
|
||||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||||
public typedsocket: plugins.typedsocket.TypedSocket;
|
public typedsocket: plugins.typedsocket.TypedSocket;
|
||||||
@ -10,16 +13,29 @@ export class SzPlatformClient {
|
|||||||
|
|
||||||
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) {
|
||||||
this.authorizationString = authorizationStringArg;
|
this.authorizationString = authorizationStringArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init(authorizationStringArg?: string) {
|
public async init(authorizationStringArg?: string) {
|
||||||
if (authorizationStringArg) this.authorizationString = authorizationStringArg;
|
if (authorizationStringArg) {
|
||||||
if (!this.authorizationString) this.authorizationString = process.env.SERVEZONE_PLATFROM_AUTHORIZATION;
|
this.authorizationString = authorizationStringArg;
|
||||||
|
}
|
||||||
|
if (!this.authorizationString)
|
||||||
|
this.authorizationString = process.env.SERVEZONE_PLATFROM_AUTHORIZATION;
|
||||||
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.debugMode = true;
|
||||||
|
console.log('debug mode activated.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(
|
||||||
|
this.typedrouter,
|
||||||
|
await this.getConnectionAddress()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getConnectionAddress() {
|
private async getConnectionAddress() {
|
||||||
|
@ -13,13 +13,7 @@ export class SzEmailConnector {
|
|||||||
public async sendEmail(
|
public async sendEmail(
|
||||||
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
|
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
|
||||||
) {
|
) {
|
||||||
const typedRequest =
|
if (this.platformClientRef.debugMode) {
|
||||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
|
|
||||||
'sendEmail'
|
|
||||||
);
|
|
||||||
const response = await typedRequest.fire(optionsArg);
|
|
||||||
|
|
||||||
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
|
||||||
logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
|
logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
|
||||||
body:
|
body:
|
||||||
${optionsArg.body.split('\n').map(line => ` ${line}`).join('\n')}
|
${optionsArg.body.split('\n').map(line => ` ${line}`).join('\n')}
|
||||||
@ -27,6 +21,16 @@ export class SzEmailConnector {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
|
||||||
|
@ -11,6 +11,15 @@ export class SzLetterConnector {
|
|||||||
public async sendLetter(
|
public async sendLetter(
|
||||||
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
|
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_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.platformservice.letter.IRequest_SendLetter>(
|
||||||
'sendLetter'
|
'sendLetter'
|
||||||
|
34
ts/email/classes.pushnotificationconnector.ts
Normal file
34
ts/email/classes.pushnotificationconnector.ts
Normal file
@ -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.platformservice.pushnotification.IRequest_SendPushNotification['request']
|
||||||
|
) {
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
console.log('sendPushNotification', optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const typedRequest =
|
||||||
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification>(
|
||||||
|
'sendPushNotification'
|
||||||
|
);
|
||||||
|
const response = await typedRequest.fire(optionsArg);
|
||||||
|
|
||||||
|
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
||||||
|
console.log('sendPushNotification response', response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.status;
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,7 @@ export class SzSmsConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
||||||
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
if (this.platformClientRef.debugMode) {
|
||||||
'sendSms'
|
|
||||||
);
|
|
||||||
const response = await typedrequest.fire(messageArg);
|
|
||||||
|
|
||||||
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
|
||||||
logger.log('info', `sent sms to ${messageArg.toNumber}}
|
logger.log('info', `sent sms to ${messageArg.toNumber}}
|
||||||
body:
|
body:
|
||||||
${messageArg.messageText.split('\n').map(line => ` ${line}`).join('\n')}
|
${messageArg.messageText.split('\n').map(line => ` ${line}`).join('\n')}
|
||||||
@ -23,6 +18,14 @@ export class SzSmsConnector {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.platformClientRef.debugMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
||||||
|
'sendSms'
|
||||||
|
);
|
||||||
|
const response = await typedrequest.fire(messageArg);
|
||||||
|
|
||||||
return response.status;
|
return response.status;
|
||||||
}
|
}
|
||||||
@ -30,6 +33,12 @@ export class SzSmsConnector {
|
|||||||
public async sendSmsVerifcation(
|
public async sendSmsVerifcation(
|
||||||
recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']
|
recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_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.platformservice.sms.IRequest_SendVerificationCode>(
|
||||||
'sendVerificationCode'
|
'sendVerificationCode'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from '../ts/plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
import { simpleInfo } from './template.js';
|
import { simpleInfo } from './template.js';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user