fix(platformclient): Refactor debug mode checks in SzPlatformClient connectors
This commit is contained in:
parent
edc54f4fc1
commit
854f1f73dc
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 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
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
"@push.rocks/qenv": "^6.0.5",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartntml": "^2.0.4",
|
||||
"@serve.zone/interfaces": "^1.0.81"
|
||||
"@serve.zone/interfaces": "^1.1.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -27,8 +27,8 @@ importers:
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
'@serve.zone/interfaces':
|
||||
specifier: ^1.0.81
|
||||
version: 1.0.81
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
devDependencies:
|
||||
'@git.zone/tsbuild':
|
||||
specifier: ^2.1.84
|
||||
@ -599,8 +599,8 @@ packages:
|
||||
'@sec-ant/readable-stream@0.4.1':
|
||||
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
||||
|
||||
'@serve.zone/interfaces@1.0.81':
|
||||
resolution: {integrity: sha512-ra0pALnvhYut2Ts55BHWKv8q1ysjf84AS0cG/Pi8FB53/OqCnaaETr2qJrAETa6OcuDDDm++R0KVZm+R5evbwQ==}
|
||||
'@serve.zone/interfaces@1.1.1':
|
||||
resolution: {integrity: sha512-Ir9xs06UYvsGoo67en7hitzMxZJ3kOBZWoQs5HIV+dTTd/5eMBjidFPJH+x6MSZsr3mb907s5Sfmb8FEtgMFYA==}
|
||||
|
||||
'@sindresorhus/is@5.6.0':
|
||||
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
|
||||
@ -3963,7 +3963,7 @@ snapshots:
|
||||
|
||||
'@sec-ant/readable-stream@0.4.1': {}
|
||||
|
||||
'@serve.zone/interfaces@1.0.81':
|
||||
'@serve.zone/interfaces@1.1.1':
|
||||
dependencies:
|
||||
'@api.global/typedrequest-interfaces': 3.0.19
|
||||
'@push.rocks/smartlog-interfaces': 3.0.2
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/platformclient',
|
||||
version: '1.1.0',
|
||||
version: '1.1.1',
|
||||
description: 'a module that makes it really easy to use the serve.zone platform inside your app'
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { SzEmailConnector } from './email/classes.emailconnector.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';
|
||||
|
||||
export class SzPlatformClient {
|
||||
@ -11,6 +13,8 @@ export class SzPlatformClient {
|
||||
|
||||
public emailConnector = new SzEmailConnector(this);
|
||||
public smsConnector = new SzSmsConnector(this);
|
||||
public pushNotificationConnector = new SzPushNotificationConnector(this);
|
||||
public letterConnector = new SzLetterConnector(this);
|
||||
|
||||
constructor(authorizationStringArg?: string) {
|
||||
this.authorizationString = authorizationStringArg;
|
||||
|
@ -11,6 +11,15 @@ export class SzLetterConnector {
|
||||
public async sendLetter(
|
||||
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
|
||||
) {
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
console.log('sendLetter', optionsArg);
|
||||
}
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typedRequest =
|
||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_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,7 +10,7 @@ export class SzSmsConnector {
|
||||
}
|
||||
|
||||
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
||||
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
||||
if (this.platformClientRef.debugMode) {
|
||||
logger.log('info', `sent sms to ${messageArg.toNumber}}
|
||||
body:
|
||||
${messageArg.messageText.split('\n').map(line => ` ${line}`).join('\n')}
|
||||
@ -18,6 +18,10 @@ export class SzSmsConnector {
|
||||
`);
|
||||
}
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
||||
'sendSms'
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user