Compare commits

..

No commits in common. "master" and "v1.0.6" have entirely different histories.

17 changed files with 513 additions and 589 deletions

View File

@ -1,56 +1,5 @@
# 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)
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) ## 2024-07-26 - 1.0.6 - fix(core)
Update @types/node dependency version Update @types/node dependency version

View File

@ -1,6 +1,6 @@
{ {
"name": "@serve.zone/platformclient", "name": "@serve.zone/platformclient",
"version": "1.1.2", "version": "1.0.6",
"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 tsfolders --web --allowimplicitany)", "build": "(tsbuild --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": {
@ -18,17 +18,17 @@
"@git.zone/tsbundle": "^2.0.5", "@git.zone/tsbundle": "^2.0.5",
"@git.zone/tsrun": "^1.2.49", "@git.zone/tsrun": "^1.2.49",
"@git.zone/tstest": "^1.0.90", "@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.3.0", "@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^22.7.4" "@types/node": "^20.14.12"
}, },
"dependencies": { "dependencies": {
"@api.global/typedrequest": "^3.0.32", "@api.global/typedrequest": "^3.0.30",
"@api.global/typedserver": "^3.0.51", "@api.global/typedserver": "^3.0.50",
"@api.global/typedsocket": "^3.0.1", "@api.global/typedsocket": "^3.0.1",
"@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.1.1" "@serve.zone/interfaces": "^1.0.74"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

905
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
import { expect, expectAsync, tap } from '@push.rocks/tapbundle'; import { expect, expectAsync, tap } from '@push.rocks/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(); tap.start()

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@serve.zone/platformclient', name: '@serve.zone/platformclient',
version: '1.1.2', version: '1.0.6',
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'
} }

View File

@ -1,11 +1,8 @@
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;
@ -13,29 +10,16 @@ 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) { if (authorizationStringArg) this.authorizationString = authorizationStringArg;
this.authorizationString = authorizationStringArg; if (!this.authorizationString) this.authorizationString = process.env.SERVEZONE_PLATFROM_AUTHORIZATION;
}
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');
if (this.authorizationString === 'test') { this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(this.typedrouter, await this.getConnectionAddress());
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() {

View File

@ -1,8 +1,6 @@
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;
@ -13,24 +11,11 @@ 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']
) { ) {
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.platformservice.mta.IRequest_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 }) {}

View File

@ -11,15 +11,6 @@ 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'

View File

@ -1,34 +0,0 @@
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;
}
}

View File

@ -1,5 +1,4 @@
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 {
@ -10,35 +9,16 @@ 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']) {
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.platformservice.sms.IRequest_SendSms>( const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_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.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'

View File

@ -1 +1,6 @@
export * from './classes.platformclient.js'; export * from './classes.platformclient.js';
// Things for building a server
import { servertools, utilityservers } from '@api.global/typedserver';

View File

@ -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';

View File

@ -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 (

View File

@ -7,5 +7,3 @@ export const logger = new plugins.smartlog.Smartlog({
zone: 'serve.zone', zone: 'serve.zone',
} }
}); });
logger.enableConsole();

View File

@ -8,10 +8,12 @@ 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,
} }

View File

@ -1,5 +0,0 @@
import * as smartntml from '@push.rocks/smartntml';
export {
smartntml,
}