@serve.zone/platformclient 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  2. package/dist_ts/00_commitinfo_data.js +9 -0
  3. package/dist_ts/classes.platformclient.d.ts +14 -0
  4. package/dist_ts/classes.platformclient.js +20 -0
  5. package/dist_ts/classes.serviceserver.d.ts +18 -0
  6. package/dist_ts/classes.serviceserver.js +32 -0
  7. package/dist_ts/email/classes.emailconnector.d.ts +17 -0
  8. package/dist_ts/email/classes.emailconnector.js +13 -0
  9. package/dist_ts/email/classes.letterconnector.d.ts +7 -0
  10. package/dist_ts/email/classes.letterconnector.js +11 -0
  11. package/dist_ts/email/classes.smsconnector.d.ts +8 -0
  12. package/dist_ts/email/classes.smsconnector.js +17 -0
  13. package/dist_ts/index.d.ts +4 -0
  14. package/dist_ts/index.js +6 -0
  15. package/dist_ts/infohtml/classes.infohtml.d.ts +18 -0
  16. package/dist_ts/infohtml/classes.infohtml.js +27 -0
  17. package/dist_ts/infohtml/index.d.ts +1 -0
  18. package/dist_ts/infohtml/index.js +2 -0
  19. package/dist_ts/infohtml/template.d.ts +3 -0
  20. package/dist_ts/infohtml/template.js +156 -0
  21. package/dist_ts/logger.d.ts +2 -0
  22. package/dist_ts/logger.js +9 -0
  23. package/dist_ts/plugins.d.ts +10 -0
  24. package/dist_ts/plugins.js +14 -0
  25. package/npmextra.json +18 -0
  26. package/package.json +56 -0
  27. package/readme.md +31 -0
  28. package/ts/00_commitinfo_data.ts +8 -0
  29. package/ts/classes.platformclient.ts +26 -0
  30. package/ts/classes.serviceserver.ts +51 -0
  31. package/ts/email/classes.emailconnector.ts +24 -0
  32. package/ts/email/classes.letterconnector.ts +20 -0
  33. package/ts/email/classes.smsconnector.ts +29 -0
  34. package/ts/index.ts +7 -0
  35. package/ts/infohtml/classes.infohtml.ts +44 -0
  36. package/ts/infohtml/index.ts +1 -0
  37. package/ts/infohtml/template.ts +162 -0
  38. package/ts/logger.ts +9 -0
  39. package/ts/plugins.ts +29 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export declare const commitinfo: {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@serve.zone/platformclient',
6
+ version: '1.0.2',
7
+ description: 'a module that makes it really easy to use the serve.zone platform inside your app'
8
+ };
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSw0QkFBNEI7SUFDbEMsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLG1GQUFtRjtDQUNqRyxDQUFBIn0=
@@ -0,0 +1,14 @@
1
+ import { SzEmailConnector } from './email/classes.emailconnector.js';
2
+ import { SzSmsConnector } from './email/classes.smsconnector.js';
3
+ import * as plugins from './plugins.js';
4
+ export declare class SzPlatformClient {
5
+ private authorizationString;
6
+ typedrouter: plugins.typedrequest.TypedRouter;
7
+ typedsocket: plugins.typedsocket.TypedSocket;
8
+ private qenvInstance;
9
+ emailConnector: SzEmailConnector;
10
+ smsConnector: SzSmsConnector;
11
+ constructor(authorizationStringArg: string);
12
+ init(): Promise<void>;
13
+ private getConnectionAddress;
14
+ }
@@ -0,0 +1,20 @@
1
+ import { SzEmailConnector } from './email/classes.emailconnector.js';
2
+ import { SzSmsConnector } from './email/classes.smsconnector.js';
3
+ import * as plugins from './plugins.js';
4
+ export class SzPlatformClient {
5
+ constructor(authorizationStringArg) {
6
+ this.typedrouter = new plugins.typedrequest.TypedRouter();
7
+ this.qenvInstance = new plugins.qenv.Qenv();
8
+ this.emailConnector = new SzEmailConnector(this);
9
+ this.smsConnector = new SzSmsConnector(this);
10
+ this.authorizationString = authorizationStringArg;
11
+ }
12
+ async init() {
13
+ this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(this.typedrouter, await this.getConnectionAddress());
14
+ }
15
+ async getConnectionAddress() {
16
+ const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
17
+ return connectionAddress;
18
+ }
19
+ }
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5wbGF0Zm9ybWNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2NsYXNzZXMucGxhdGZvcm1jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFDckUsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBRXhDLE1BQU0sT0FBTyxnQkFBZ0I7SUFTM0IsWUFBWSxzQkFBOEI7UUFQbkMsZ0JBQVcsR0FBRyxJQUFJLE9BQU8sQ0FBQyxZQUFZLENBQUMsV0FBVyxFQUFFLENBQUM7UUFFcEQsaUJBQVksR0FBRyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUM7UUFFeEMsbUJBQWMsR0FBRyxJQUFJLGdCQUFnQixDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzVDLGlCQUFZLEdBQUcsSUFBSSxjQUFjLENBQUMsSUFBSSxDQUFDLENBQUM7UUFHN0MsSUFBSSxDQUFDLG1CQUFtQixHQUFHLHNCQUFzQixDQUFDO0lBQ3BELENBQUM7SUFFTSxLQUFLLENBQUMsSUFBSTtRQUNmLElBQUksQ0FBQyxXQUFXLEdBQUcsTUFBTSxPQUFPLENBQUMsV0FBVyxDQUFDLFdBQVcsQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLFdBQVcsRUFBRSxNQUFNLElBQUksQ0FBQyxvQkFBb0IsRUFBRSxDQUFDLENBQUM7SUFDN0gsQ0FBQztJQUVPLEtBQUssQ0FBQyxvQkFBb0I7UUFDaEMsTUFBTSxpQkFBaUIsR0FBRyxNQUFNLElBQUksQ0FBQyxZQUFZLENBQUMsaUJBQWlCLENBQUMsc0JBQXNCLENBQUMsQ0FBQztRQUM1RixPQUFPLGlCQUFpQixDQUFDO0lBQzNCLENBQUM7Q0FDRiJ9
@@ -0,0 +1,18 @@
1
+ import * as plugins from './plugins.js';
2
+ export interface IServiceServerConstructorOptions {
3
+ addCustomRoutes?: (serverArg: plugins.typedserver.servertools.Server) => Promise<any>;
4
+ serviceName: string;
5
+ serviceVersion: string;
6
+ serviceDomain: string;
7
+ port?: number;
8
+ }
9
+ /**
10
+ * a server for serving your app to the outside world
11
+ */
12
+ export declare class ServiceServer {
13
+ options: IServiceServerConstructorOptions;
14
+ typedServer: plugins.typedserver.TypedServer;
15
+ constructor(optionsArg: IServiceServerConstructorOptions);
16
+ start(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ }
@@ -0,0 +1,32 @@
1
+ import * as plugins from './plugins.js';
2
+ import { InfoHtml } from './infohtml/index.js';
3
+ /**
4
+ * a server for serving your app to the outside world
5
+ */
6
+ export class ServiceServer {
7
+ constructor(optionsArg) {
8
+ this.options = optionsArg;
9
+ }
10
+ async start() {
11
+ console.log('starting lole-serviceserver...');
12
+ this.typedServer = new plugins.typedserver.TypedServer({
13
+ cors: true,
14
+ domain: this.options.serviceDomain,
15
+ forceSsl: false,
16
+ port: this.options.port || 3000,
17
+ robots: true,
18
+ defaultAnswer: async () => {
19
+ return (await InfoHtml.fromSimpleText(`${this.options.serviceName} (version ${this.options.serviceVersion})`)).htmlString;
20
+ },
21
+ });
22
+ // lets add any custom routes
23
+ if (this.options.addCustomRoutes) {
24
+ await this.options.addCustomRoutes(this.typedServer.server);
25
+ }
26
+ await this.typedServer.start();
27
+ }
28
+ async stop() {
29
+ await this.typedServer.stop();
30
+ }
31
+ }
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5zZXJ2aWNlc2VydmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2xhc3Nlcy5zZXJ2aWNlc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQVUvQzs7R0FFRztBQUNILE1BQU0sT0FBTyxhQUFhO0lBSXhCLFlBQVksVUFBNEM7UUFDdEQsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUM7SUFDNUIsQ0FBQztJQUVNLEtBQUssQ0FBQyxLQUFLO1FBQ2hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsZ0NBQWdDLENBQUMsQ0FBQTtRQUM3QyxJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxXQUFXLENBQUM7WUFDckQsSUFBSSxFQUFFLElBQUk7WUFDVixNQUFNLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxhQUFhO1lBQ2xDLFFBQVEsRUFBRSxLQUFLO1lBQ2YsSUFBSSxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxJQUFJLElBQUk7WUFDL0IsTUFBTSxFQUFFLElBQUk7WUFDWixhQUFhLEVBQUUsS0FBSyxJQUFJLEVBQUU7Z0JBQ3hCLE9BQU8sQ0FDTCxNQUFNLFFBQVEsQ0FBQyxjQUFjLENBQzNCLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxXQUFXLGFBQWEsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLEdBQUcsQ0FDdkUsQ0FDRixDQUFDLFVBQVUsQ0FBQztZQUNmLENBQUM7U0FDRixDQUFDLENBQUM7UUFFSCw2QkFBNkI7UUFDN0IsSUFBSSxJQUFJLENBQUMsT0FBTyxDQUFDLGVBQWUsRUFBRSxDQUFDO1lBQ2pDLE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQyxlQUFlLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM5RCxDQUFDO1FBRUQsTUFBTSxJQUFJLENBQUMsV0FBVyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQ2pDLENBQUM7SUFFTSxLQUFLLENBQUMsSUFBSTtRQUNmLE1BQU0sSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQyxDQUFDO0NBQ0YifQ==
@@ -0,0 +1,17 @@
1
+ import type { SzPlatformClient } from '../classes.platformclient.js';
2
+ import * as plugins from '../plugins.js';
3
+ export declare class SzEmailConnector {
4
+ platformClientRef: SzPlatformClient;
5
+ constructor(platformClientRefArg: SzPlatformClient);
6
+ sendEmail(optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']): Promise<void>;
7
+ sendNotification(optionsArg: {
8
+ toArg: string;
9
+ subject: string;
10
+ text: string;
11
+ }): Promise<void>;
12
+ sendActionLink(optionsArg: {
13
+ toArg: string;
14
+ subject: string;
15
+ text: string;
16
+ }): Promise<void>;
17
+ }
@@ -0,0 +1,13 @@
1
+ import * as plugins from '../plugins.js';
2
+ export class SzEmailConnector {
3
+ constructor(platformClientRefArg) {
4
+ this.platformClientRef = platformClientRefArg;
5
+ }
6
+ async sendEmail(optionsArg) {
7
+ const typedRequest = this.platformClientRef.typedsocket.createTypedRequest('sendEmail');
8
+ const response = await typedRequest.fire(optionsArg);
9
+ }
10
+ async sendNotification(optionsArg) { }
11
+ async sendActionLink(optionsArg) { }
12
+ }
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5lbWFpbGNvbm5lY3Rvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2VtYWlsL2NsYXNzZXMuZW1haWxjb25uZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLE9BQU8sTUFBTSxlQUFlLENBQUM7QUFFekMsTUFBTSxPQUFPLGdCQUFnQjtJQUczQixZQUFZLG9CQUFzQztRQUNoRCxJQUFJLENBQUMsaUJBQWlCLEdBQUcsb0JBQW9CLENBQUM7SUFDaEQsQ0FBQztJQUVNLEtBQUssQ0FBQyxTQUFTLENBQ3BCLFVBQXlGO1FBRXpGLE1BQU0sWUFBWSxHQUNoQixJQUFJLENBQUMsaUJBQWlCLENBQUMsV0FBVyxDQUFDLGtCQUFrQixDQUNuRCxXQUFXLENBQ1osQ0FBQztRQUNKLE1BQU0sUUFBUSxHQUFHLE1BQU0sWUFBWSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUN2RCxDQUFDO0lBRU0sS0FBSyxDQUFDLGdCQUFnQixDQUFDLFVBQTRELElBQUcsQ0FBQztJQUV2RixLQUFLLENBQUMsY0FBYyxDQUFDLFVBQTRELElBQUcsQ0FBQztDQUM3RiJ9
@@ -0,0 +1,7 @@
1
+ import * as plugins from '../plugins.js';
2
+ import type { SzPlatformClient } from '../classes.platformclient.js';
3
+ export declare class SzLetterConnector {
4
+ platformClientRef: SzPlatformClient;
5
+ constructor(platformClientRefArg: SzPlatformClient);
6
+ sendLetter(optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']): Promise<void>;
7
+ }
@@ -0,0 +1,11 @@
1
+ import * as plugins from '../plugins.js';
2
+ export class SzLetterConnector {
3
+ constructor(platformClientRefArg) {
4
+ this.platformClientRef = platformClientRefArg;
5
+ }
6
+ async sendLetter(optionsArg) {
7
+ const typedRequest = this.platformClientRef.typedsocket.createTypedRequest('sendLetter');
8
+ const response = await typedRequest.fire(optionsArg);
9
+ }
10
+ }
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5sZXR0ZXJjb25uZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9lbWFpbC9jbGFzc2VzLmxldHRlcmNvbm5lY3Rvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUd6QyxNQUFNLE9BQU8saUJBQWlCO0lBRzVCLFlBQVksb0JBQXNDO1FBQ2hELElBQUksQ0FBQyxpQkFBaUIsR0FBRyxvQkFBb0IsQ0FBQztJQUNoRCxDQUFDO0lBRU0sS0FBSyxDQUFDLFVBQVUsQ0FDckIsVUFBNkY7UUFFN0YsTUFBTSxZQUFZLEdBQ2hCLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxXQUFXLENBQUMsa0JBQWtCLENBQ25ELFlBQVksQ0FDYixDQUFDO1FBQ0osTUFBTSxRQUFRLEdBQUcsTUFBTSxZQUFZLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3ZELENBQUM7Q0FDRiJ9
@@ -0,0 +1,8 @@
1
+ import type { SzPlatformClient } from '../classes.platformclient.js';
2
+ import * as plugins from '../plugins.js';
3
+ export declare class SzSmsConnector {
4
+ platformClientRef: SzPlatformClient;
5
+ constructor(platformClientRefArg: SzPlatformClient);
6
+ sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']): Promise<"ok" | "not ok">;
7
+ sendSmsVerifcation(recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']): Promise<string>;
8
+ }
@@ -0,0 +1,17 @@
1
+ import * as plugins from '../plugins.js';
2
+ export class SzSmsConnector {
3
+ constructor(platformClientRefArg) {
4
+ this.platformClientRef = platformClientRefArg;
5
+ }
6
+ async sendSms(messageArg) {
7
+ const typedrequest = this.platformClientRef.typedsocket.createTypedRequest('sendSms');
8
+ const response = await typedrequest.fire(messageArg);
9
+ return response.status;
10
+ }
11
+ async sendSmsVerifcation(recipientArg) {
12
+ const typedrequest = this.platformClientRef.typedsocket.createTypedRequest('sendVerificationCode');
13
+ const response = await typedrequest.fire(recipientArg);
14
+ return response.verificationCode;
15
+ }
16
+ }
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5zbXNjb25uZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9lbWFpbC9jbGFzc2VzLnNtc2Nvbm5lY3Rvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUV6QyxNQUFNLE9BQU8sY0FBYztJQUd6QixZQUFZLG9CQUFzQztRQUNoRCxJQUFJLENBQUMsaUJBQWlCLEdBQUcsb0JBQW9CLENBQUM7SUFDaEQsQ0FBQztJQUVNLEtBQUssQ0FBQyxPQUFPLENBQUMsVUFBdUY7UUFDMUcsTUFBTSxZQUFZLEdBQUcsSUFBSSxDQUFDLGlCQUFpQixDQUFDLFdBQVcsQ0FBQyxrQkFBa0IsQ0FDeEUsU0FBUyxDQUNWLENBQUM7UUFDRixNQUFNLFFBQVEsR0FBRyxNQUFNLFlBQVksQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDckQsT0FBTyxRQUFRLENBQUMsTUFBTSxDQUFDO0lBQ3pCLENBQUM7SUFFTSxLQUFLLENBQUMsa0JBQWtCLENBQzdCLFlBQXNHO1FBRXRHLE1BQU0sWUFBWSxHQUNoQixJQUFJLENBQUMsaUJBQWlCLENBQUMsV0FBVyxDQUFDLGtCQUFrQixDQUNuRCxzQkFBc0IsQ0FDdkIsQ0FBQztRQUNKLE1BQU0sUUFBUSxHQUFHLE1BQU0sWUFBWSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQztRQUN2RCxPQUFPLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBQztJQUNuQyxDQUFDO0NBQ0YifQ==
@@ -0,0 +1,4 @@
1
+ export * from './classes.serviceserver.js';
2
+ import { servertools } from '@api.global/typedserver';
3
+ declare const Handler: typeof servertools.Handler, HandlerTypedRouter: typeof servertools.HandlerTypedRouter;
4
+ export { Handler, HandlerTypedRouter };
@@ -0,0 +1,6 @@
1
+ export * from './classes.serviceserver.js';
2
+ // Things for building a server
3
+ import { servertools } from '@api.global/typedserver';
4
+ const { Handler, HandlerTypedRouter } = servertools;
5
+ export { Handler, HandlerTypedRouter };
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDRCQUE0QixDQUFDO0FBRTNDLCtCQUErQjtBQUMvQixPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDdEQsTUFBTSxFQUFFLE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxHQUFHLFdBQVcsQ0FBQztBQUNwRCxPQUFPLEVBQUUsT0FBTyxFQUFFLGtCQUFrQixFQUFFLENBQUMifQ==
@@ -0,0 +1,18 @@
1
+ import * as plugins from '../plugins.js';
2
+ export interface IHtmlInfoOptions {
3
+ text: string;
4
+ heading?: string;
5
+ title?: string;
6
+ sentryMessage?: string;
7
+ sentryDsn?: string;
8
+ redirectTo?: string;
9
+ }
10
+ export declare class InfoHtml {
11
+ static fromSimpleText(textArg: string): Promise<InfoHtml>;
12
+ static fromOptions(optionsArg: IHtmlInfoOptions): Promise<InfoHtml>;
13
+ options: IHtmlInfoOptions;
14
+ smartntmlInstance: plugins.smartntml.Smartntml;
15
+ htmlString: string;
16
+ constructor(optionsArg: IHtmlInfoOptions);
17
+ init(): Promise<string>;
18
+ }
@@ -0,0 +1,27 @@
1
+ import * as plugins from '../plugins.js';
2
+ import { simpleInfo } from './template.js';
3
+ export class InfoHtml {
4
+ // STATIC
5
+ static async fromSimpleText(textArg) {
6
+ const infohtmlInstance = new InfoHtml({
7
+ text: textArg,
8
+ heading: null,
9
+ });
10
+ await infohtmlInstance.init();
11
+ return infohtmlInstance;
12
+ }
13
+ static async fromOptions(optionsArg) {
14
+ const infohtmlInstance = new InfoHtml(optionsArg);
15
+ await infohtmlInstance.init();
16
+ return infohtmlInstance;
17
+ }
18
+ constructor(optionsArg) {
19
+ this.options = optionsArg;
20
+ }
21
+ async init() {
22
+ this.smartntmlInstance = new plugins.smartntml.Smartntml();
23
+ this.htmlString = await simpleInfo(this.smartntmlInstance, this.options);
24
+ return this.htmlString;
25
+ }
26
+ }
27
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5pbmZvaHRtbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2luZm9odG1sL2NsYXNzZXMuaW5mb2h0bWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxlQUFlLENBQUM7QUFFekMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQVczQyxNQUFNLE9BQU8sUUFBUTtJQUNuQixTQUFTO0lBQ0YsTUFBTSxDQUFDLEtBQUssQ0FBQyxjQUFjLENBQUMsT0FBZTtRQUNoRCxNQUFNLGdCQUFnQixHQUFHLElBQUksUUFBUSxDQUFDO1lBQ3BDLElBQUksRUFBRSxPQUFPO1lBQ2IsT0FBTyxFQUFFLElBQUk7U0FDZCxDQUFDLENBQUM7UUFDSCxNQUFNLGdCQUFnQixDQUFDLElBQUksRUFBRSxDQUFDO1FBQzlCLE9BQU8sZ0JBQWdCLENBQUM7SUFDMUIsQ0FBQztJQUVNLE1BQU0sQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLFVBQTRCO1FBQzFELE1BQU0sZ0JBQWdCLEdBQUcsSUFBSSxRQUFRLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDbEQsTUFBTSxnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM5QixPQUFPLGdCQUFnQixDQUFDO0lBQzFCLENBQUM7SUFNRCxZQUFZLFVBQTRCO1FBQ3RDLElBQUksQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDO0lBQzVCLENBQUM7SUFFTSxLQUFLLENBQUMsSUFBSTtRQUNmLElBQUksQ0FBQyxpQkFBaUIsR0FBRyxJQUFJLE9BQU8sQ0FBQyxTQUFTLENBQUMsU0FBUyxFQUFFLENBQUM7UUFDM0QsSUFBSSxDQUFDLFVBQVUsR0FBRyxNQUFNLFVBQVUsQ0FBQyxJQUFJLENBQUMsaUJBQWlCLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3pFLE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQztJQUN6QixDQUFDO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ export { InfoHtml } from './classes.infohtml.js';
@@ -0,0 +1,2 @@
1
+ export { InfoHtml } from './classes.infohtml.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbmZvaHRtbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sdUJBQXVCLENBQUMifQ==
@@ -0,0 +1,3 @@
1
+ import * as plugins from '../plugins.js';
2
+ import { type IHtmlInfoOptions } from './classes.infohtml.js';
3
+ export declare const simpleInfo: (smartntmlInstanceArg: plugins.smartntml.Smartntml, optionsArg: IHtmlInfoOptions) => Promise<string>;
@@ -0,0 +1,156 @@
1
+ import * as plugins from '../plugins.js';
2
+ import {} from './classes.infohtml.js';
3
+ export const simpleInfo = async (smartntmlInstanceArg, optionsArg) => {
4
+ const html = plugins.smartntml.deesElement.html;
5
+ const htmlTemplate = await plugins.smartntml.deesElement.html `
6
+ <html lang="en">
7
+ <head>
8
+ <title>${optionsArg.title}</title>
9
+ <script>
10
+ setTimeout(() => {
11
+ const redirectUrl = '${optionsArg.redirectTo}';
12
+ if (redirectUrl) {
13
+ window.location = redirectUrl;
14
+ }
15
+ }, 5000);
16
+ </script>
17
+ <style>
18
+ body {
19
+ margin: 0px;
20
+ background: #000000;
21
+ font-family: 'Roboto Mono', monospace;
22
+ min-height: 100vh;
23
+ min-width: 100vw;
24
+ border: 1px solid #e4002b;
25
+ }
26
+
27
+ * {
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ .logo {
32
+ width: 150px;
33
+ padding-top: 70px;
34
+ margin: 0px auto 30px auto;
35
+ }
36
+
37
+ .content {
38
+ text-align: center;
39
+ max-width: 800px;
40
+ margin: auto;
41
+ }
42
+
43
+ .content .maintext {
44
+ margin: 10px;
45
+ color: #ffffff;
46
+ background: #333;
47
+ display: block;
48
+ border-radius: 3px;
49
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
50
+ padding: 20px;
51
+ }
52
+
53
+ .content .maintext h1 {
54
+ margin: 0px;
55
+ }
56
+
57
+ .content .addontext {
58
+ margin: 10px;
59
+ color: #ffffff;
60
+ background: #222;
61
+ display: block;
62
+ padding: 10px 15px;
63
+ border-radius: 3px;
64
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
65
+ padding: 10px;
66
+ }
67
+
68
+ .content .text h1 {
69
+ margin: 0px;
70
+ font-weight: 100;
71
+ font-size: 40px;
72
+ }
73
+
74
+ .content .text ul {
75
+ text-align: left;
76
+ }
77
+
78
+ a {
79
+ color: #ffffff;
80
+ }
81
+
82
+ .legal {
83
+ color: #fff;
84
+ position: fixed;
85
+ bottom: 0px;
86
+ width: 100vw;
87
+ text-align: center;
88
+ padding: 10px;
89
+ }
90
+ </style>
91
+ <meta
92
+ name="viewport"
93
+ content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
94
+ />
95
+ <script
96
+ src="https://browser.sentry-cdn.com/5.4.0/bundle.min.js"
97
+ crossorigin="anonymous"
98
+ ></script>
99
+ <script>
100
+ const sentryDsn = '${optionsArg.sentryDsn}';
101
+ const sentryMessage = '${optionsArg.sentryMessage}';
102
+ if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
103
+ Sentry.init({
104
+ dsn: '${optionsArg.sentryDsn}',
105
+ // ...
106
+ });
107
+ Sentry.setExtra('location', window.location.href);
108
+ Sentry.captureMessage('${optionsArg.sentryMessage} @ ' + window.location.host);
109
+ }
110
+ </script>
111
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
112
+ </head>
113
+ <body>
114
+ <div class="logo">
115
+ <img src="https://assetbroker.lossless.one/brandfiles/lossless/svg-minimal-bright.svg" />
116
+ </div>
117
+ <div class="content">
118
+ ${(() => {
119
+ const returnArray = [];
120
+ if (optionsArg.heading) {
121
+ returnArray.push(html `
122
+ <div class="maintext">
123
+ <h1>${optionsArg.heading}</h1>
124
+ ${optionsArg.text}
125
+ </div>
126
+ `);
127
+ }
128
+ else {
129
+ returnArray.push(html ` <div class="maintext">${optionsArg.text}</div> `);
130
+ }
131
+ if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
132
+ returnArray.push(html `<div class="addontext">
133
+ We recorded this event. Should you continue to see this page against your
134
+ expectations, feel free to mail us at
135
+ <a href="mailto:hello@lossless.com">hello@lossless.com</a>
136
+ </div>`);
137
+ }
138
+ if (optionsArg.redirectTo) {
139
+ returnArray.push(html `<div class="addontext">
140
+ We will redirect you to ${optionsArg.redirectTo} in a few seconds.
141
+ </div>`);
142
+ }
143
+ return returnArray;
144
+ })()}
145
+ </div>
146
+ <div class="legal">
147
+ <a href="https://lossless.com">Lossless GmbH</a> / &copy 2014-${new Date().getFullYear()}
148
+ / <a href="https://lossless.gmbh">Legal Info</a> /
149
+ <a href="https://lossless.gmbh">Privacy Policy</a>
150
+ </div>
151
+ </body>
152
+ </html>
153
+ `;
154
+ return smartntmlInstanceArg.renderTemplateResult(htmlTemplate);
155
+ };
156
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVtcGxhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbmZvaHRtbC90ZW1wbGF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUN6QyxPQUFPLEVBQXlCLE1BQU0sdUJBQXVCLENBQUM7QUFFOUQsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHLEtBQUssRUFDN0Isb0JBQWlELEVBQ2pELFVBQTRCLEVBQzVCLEVBQUU7SUFDRixNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUM7SUFDaEQsTUFBTSxZQUFZLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUE7OztpQkFHOUMsVUFBVSxDQUFDLEtBQUs7OzttQ0FHRSxVQUFVLENBQUMsVUFBVTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7K0JBeUZ6QixVQUFVLENBQUMsU0FBUzttQ0FDaEIsVUFBVSxDQUFDLGFBQWE7OztzQkFHckMsVUFBVSxDQUFDLFNBQVM7Ozs7cUNBSUwsVUFBVSxDQUFDLGFBQWE7Ozs7Ozs7Ozs7WUFVakQsQ0FBQyxHQUFHLEVBQUU7UUFDTixNQUFNLFdBQVcsR0FBbUQsRUFBRSxDQUFDO1FBQ3ZFLElBQUksVUFBVSxDQUFDLE9BQU8sRUFBRSxDQUFDO1lBQ3ZCLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFBOzt3QkFFWCxVQUFVLENBQUMsT0FBTztvQkFDdEIsVUFBVSxDQUFDLElBQUk7O2VBRXBCLENBQUMsQ0FBQztRQUNMLENBQUM7YUFBTSxDQUFDO1lBQ04sV0FBVyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUEsMEJBQTBCLFVBQVUsQ0FBQyxJQUFJLFNBQVMsQ0FBQyxDQUFDO1FBQzNFLENBQUM7UUFDRCxJQUFJLFVBQVUsQ0FBQyxTQUFTLElBQUksVUFBVSxDQUFDLGFBQWEsRUFBRSxDQUFDO1lBQ3JELFdBQVcsQ0FBQyxJQUFJLENBQ2QsSUFBSSxDQUFBOzs7O3VCQUlHLENBQ1IsQ0FBQztRQUNKLENBQUM7UUFDRCxJQUFJLFVBQVUsQ0FBQyxVQUFVLEVBQUUsQ0FBQztZQUMxQixXQUFXLENBQUMsSUFBSSxDQUNkLElBQUksQ0FBQTs0Q0FDd0IsVUFBVSxDQUFDLFVBQVU7dUJBQzFDLENBQ1IsQ0FBQztRQUNKLENBQUM7UUFDRCxPQUFPLFdBQVcsQ0FBQztJQUNyQixDQUFDLENBQUMsRUFBRTs7OzBFQUc0RCxJQUFJLElBQUksRUFBRSxDQUFDLFdBQVcsRUFBRTs7Ozs7O0dBTS9GLENBQUM7SUFDRixPQUFPLG9CQUFvQixDQUFDLG9CQUFvQixDQUFDLFlBQVksQ0FBQyxDQUFDO0FBQ2pFLENBQUMsQ0FBQyJ9
@@ -0,0 +1,2 @@
1
+ import * as plugins from './plugins.js';
2
+ export declare const logger: plugins.smartlog.Smartlog;
@@ -0,0 +1,9 @@
1
+ import * as plugins from './plugins.js';
2
+ export const logger = new plugins.smartlog.Smartlog({
3
+ logContext: {
4
+ environment: 'production',
5
+ runtime: 'node',
6
+ zone: 'serve.zone',
7
+ }
8
+ });
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbG9nZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBRXhDLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFDO0lBQ2xELFVBQVUsRUFBRTtRQUNWLFdBQVcsRUFBRSxZQUFZO1FBQ3pCLE9BQU8sRUFBRSxNQUFNO1FBQ2YsSUFBSSxFQUFFLFlBQVk7S0FDbkI7Q0FDRixDQUFDLENBQUMifQ==
@@ -0,0 +1,10 @@
1
+ import * as servezoneInterfaces from '@serve.zone/interfaces';
2
+ export { servezoneInterfaces, };
3
+ import * as qenv from '@push.rocks/qenv';
4
+ import * as smartlog from '@push.rocks/smartlog';
5
+ import * as smartntml from '@push.rocks/smartntml';
6
+ export { qenv, smartlog, smartntml, };
7
+ import * as typedrequest from '@api.global/typedrequest';
8
+ import * as typedserver from '@api.global/typedserver';
9
+ import * as typedsocket from '@api.global/typedsocket';
10
+ export { typedrequest, typedserver, typedsocket, };
@@ -0,0 +1,14 @@
1
+ // @serve.zone scope
2
+ import * as servezoneInterfaces from '@serve.zone/interfaces';
3
+ export { servezoneInterfaces, };
4
+ // @push.rocks scope
5
+ import * as qenv from '@push.rocks/qenv';
6
+ import * as smartlog from '@push.rocks/smartlog';
7
+ import * as smartntml from '@push.rocks/smartntml';
8
+ export { qenv, smartlog, smartntml, };
9
+ // @api.global scope
10
+ import * as typedrequest from '@api.global/typedrequest';
11
+ import * as typedserver from '@api.global/typedserver';
12
+ import * as typedsocket from '@api.global/typedsocket';
13
+ export { typedrequest, typedserver, typedsocket, };
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsb0JBQW9CO0FBQ3BCLE9BQU8sS0FBSyxtQkFBbUIsTUFBTSx3QkFBd0IsQ0FBQztBQUU5RCxPQUFPLEVBQ0wsbUJBQW1CLEdBQ3BCLENBQUE7QUFFRCxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLElBQUksTUFBTSxrQkFBa0IsQ0FBQztBQUN6QyxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFFbkQsT0FBTyxFQUNMLElBQUksRUFDSixRQUFRLEVBQ1IsU0FBUyxHQUNWLENBQUE7QUFHRCxvQkFBb0I7QUFDcEIsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssV0FBVyxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxXQUFXLE1BQU0seUJBQXlCLENBQUM7QUFFdkQsT0FBTyxFQUNMLFlBQVksRUFDWixXQUFXLEVBQ1gsV0FBVyxHQUNaLENBQUEifQ==
package/npmextra.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "gitzone": {
3
+ "projectType": "npm",
4
+ "module": {
5
+ "githost": "gitlab.com",
6
+ "gitscope": "serve.zone",
7
+ "gitrepo": "platformclient",
8
+ "description": "a module that makes it really easy to use the serve.zone platform inside your app",
9
+ "npmPackagename": "@serve.zone/platformclient",
10
+ "license": "MIT",
11
+ "projectDomain": "serve.zone"
12
+ }
13
+ },
14
+ "npmci": {
15
+ "npmGlobalTools": [],
16
+ "npmAccessLevel": "public"
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@serve.zone/platformclient",
3
+ "version": "1.0.2",
4
+ "private": false,
5
+ "description": "a module that makes it really easy to use the serve.zone platform inside your app",
6
+ "main": "dist_ts/index.js",
7
+ "typings": "dist_ts/index.d.ts",
8
+ "type": "module",
9
+ "author": "Task Venture Capital GmbH",
10
+ "license": "MIT",
11
+ "devDependencies": {
12
+ "@git.zone/tsbuild": "^2.1.25",
13
+ "@git.zone/tsbundle": "^2.0.5",
14
+ "@git.zone/tsrun": "^1.2.46",
15
+ "@git.zone/tstest": "^1.0.44",
16
+ "@push.rocks/tapbundle": "^5.0.15",
17
+ "@types/node": "^20.11.19"
18
+ },
19
+ "dependencies": {
20
+ "@api.global/typedrequest": "^3.0.4",
21
+ "@api.global/typedserver": "^3.0.20",
22
+ "@api.global/typedsocket": "^3.0.0",
23
+ "@push.rocks/qenv": "^6.0.5",
24
+ "@push.rocks/smartlog": "^3.0.3",
25
+ "@push.rocks/smartntml": "^2.0.4",
26
+ "@serve.zone/interfaces": "^1.0.35"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://gitlab.com/serve.zone/platformclient.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://gitlab.com/serve.zone/platformclient/issues"
34
+ },
35
+ "homepage": "https://gitlab.com/serve.zone/platformclient#readme",
36
+ "browserslist": [
37
+ "last 1 chrome versions"
38
+ ],
39
+ "files": [
40
+ "ts/**/*",
41
+ "ts_web/**/*",
42
+ "dist/**/*",
43
+ "dist_*/**/*",
44
+ "dist_ts/**/*",
45
+ "dist_ts_web/**/*",
46
+ "assets/**/*",
47
+ "cli.js",
48
+ "npmextra.json",
49
+ "readme.md"
50
+ ],
51
+ "scripts": {
52
+ "test": "(tstest test/ --web)",
53
+ "build": "(tsbuild --web --allowimplicitany)",
54
+ "localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
55
+ }
56
+ }
package/readme.md ADDED
@@ -0,0 +1,31 @@
1
+ # @serve.zone/platformclient
2
+ a module that makes it really easy to use the serve.zone platform inside your app
3
+
4
+ ## Availabililty and Links
5
+ * [npmjs.org (npm package)](https://www.npmjs.com/package/@serve.zone/platformclient)
6
+ * [gitlab.com (source)](https://gitlab.com/serve.zone/platformclient)
7
+ * [github.com (source mirror)](https://github.com/serve.zone/platformclient)
8
+ * [docs (typedoc)](https://serve.zone.gitlab.io/platformclient/)
9
+
10
+ ## Status for master
11
+
12
+ Status Category | Status Badge
13
+ -- | --
14
+ GitLab Pipelines | [![pipeline status](https://gitlab.com/serve.zone/platformclient/badges/master/pipeline.svg)](https://lossless.cloud)
15
+ GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/serve.zone/platformclient/badges/master/coverage.svg)](https://lossless.cloud)
16
+ npm | [![npm downloads per month](https://badgen.net/npm/dy/@serve.zone/platformclient)](https://lossless.cloud)
17
+ Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/serve.zone/platformclient)](https://lossless.cloud)
18
+ TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
+ node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
+ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
+ PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@serve.zone/platformclient)](https://lossless.cloud)
22
+ PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@serve.zone/platformclient)](https://lossless.cloud)
23
+ BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@serve.zone/platformclient)](https://lossless.cloud)
24
+
25
+ ## Usage
26
+ Use TypeScript for best in class intellisense
27
+ For further information read the linked docs at the top of this readme.
28
+
29
+ ## Legal
30
+ > MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
31
+ | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @pushrocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@serve.zone/platformclient',
6
+ version: '1.0.2',
7
+ description: 'a module that makes it really easy to use the serve.zone platform inside your app'
8
+ }
@@ -0,0 +1,26 @@
1
+ import { SzEmailConnector } from './email/classes.emailconnector.js';
2
+ import { SzSmsConnector } from './email/classes.smsconnector.js';
3
+ import * as plugins from './plugins.js';
4
+
5
+ export class SzPlatformClient {
6
+ private authorizationString: string;
7
+ public typedrouter = new plugins.typedrequest.TypedRouter();
8
+ public typedsocket: plugins.typedsocket.TypedSocket;
9
+ private qenvInstance = new plugins.qenv.Qenv();
10
+
11
+ public emailConnector = new SzEmailConnector(this);
12
+ public smsConnector = new SzSmsConnector(this);
13
+
14
+ constructor(authorizationStringArg: string) {
15
+ this.authorizationString = authorizationStringArg;
16
+ }
17
+
18
+ public async init() {
19
+ this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(this.typedrouter, await this.getConnectionAddress());
20
+ }
21
+
22
+ private async getConnectionAddress() {
23
+ const connectionAddress = await this.qenvInstance.getEnvVarOnDemand('SERVEZONE_API_DOMAIN');
24
+ return connectionAddress;
25
+ }
26
+ }
@@ -0,0 +1,51 @@
1
+ import * as plugins from './plugins.js';
2
+ import { InfoHtml } from './infohtml/index.js';
3
+
4
+ export interface IServiceServerConstructorOptions {
5
+ addCustomRoutes?: (serverArg: plugins.typedserver.servertools.Server) => Promise<any>;
6
+ serviceName: string;
7
+ serviceVersion: string;
8
+ serviceDomain: string;
9
+ port?: number;
10
+ }
11
+
12
+ /**
13
+ * a server for serving your app to the outside world
14
+ */
15
+ export class ServiceServer {
16
+ public options: IServiceServerConstructorOptions;
17
+ public typedServer: plugins.typedserver.TypedServer;
18
+
19
+ constructor(optionsArg: IServiceServerConstructorOptions) {
20
+ this.options = optionsArg;
21
+ }
22
+
23
+ public async start() {
24
+ console.log('starting lole-serviceserver...')
25
+ this.typedServer = new plugins.typedserver.TypedServer({
26
+ cors: true,
27
+ domain: this.options.serviceDomain,
28
+ forceSsl: false,
29
+ port: this.options.port || 3000,
30
+ robots: true,
31
+ defaultAnswer: async () => {
32
+ return (
33
+ await InfoHtml.fromSimpleText(
34
+ `${this.options.serviceName} (version ${this.options.serviceVersion})`
35
+ )
36
+ ).htmlString;
37
+ },
38
+ });
39
+
40
+ // lets add any custom routes
41
+ if (this.options.addCustomRoutes) {
42
+ await this.options.addCustomRoutes(this.typedServer.server);
43
+ }
44
+
45
+ await this.typedServer.start();
46
+ }
47
+
48
+ public async stop() {
49
+ await this.typedServer.stop();
50
+ }
51
+ }
@@ -0,0 +1,24 @@
1
+ import type { SzPlatformClient } from '../classes.platformclient.js';
2
+ import * as plugins from '../plugins.js';
3
+
4
+ export class SzEmailConnector {
5
+ public platformClientRef: SzPlatformClient;
6
+
7
+ constructor(platformClientRefArg: SzPlatformClient) {
8
+ this.platformClientRef = platformClientRefArg;
9
+ }
10
+
11
+ public async sendEmail(
12
+ optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
13
+ ) {
14
+ const typedRequest =
15
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
16
+ 'sendEmail'
17
+ );
18
+ const response = await typedRequest.fire(optionsArg);
19
+ }
20
+
21
+ public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
22
+
23
+ public async sendActionLink(optionsArg: { toArg: string; subject: string; text: string }) {}
24
+ }
@@ -0,0 +1,20 @@
1
+ import * as plugins from '../plugins.js';
2
+ import type { SzPlatformClient } from '../classes.platformclient.js';
3
+
4
+ export class SzLetterConnector {
5
+ public platformClientRef: SzPlatformClient;
6
+
7
+ constructor(platformClientRefArg: SzPlatformClient) {
8
+ this.platformClientRef = platformClientRefArg;
9
+ }
10
+
11
+ public async sendLetter(
12
+ optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
13
+ ) {
14
+ const typedRequest =
15
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter>(
16
+ 'sendLetter'
17
+ );
18
+ const response = await typedRequest.fire(optionsArg);
19
+ }
20
+ }
@@ -0,0 +1,29 @@
1
+ import type { SzPlatformClient } from '../classes.platformclient.js';
2
+ import * as plugins from '../plugins.js';
3
+
4
+ export class SzSmsConnector {
5
+ public platformClientRef: SzPlatformClient;
6
+
7
+ constructor(platformClientRefArg: SzPlatformClient) {
8
+ this.platformClientRef = platformClientRefArg;
9
+ }
10
+
11
+ public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
12
+ const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
13
+ 'sendSms'
14
+ );
15
+ const response = await typedrequest.fire(messageArg);
16
+ return response.status;
17
+ }
18
+
19
+ public async sendSmsVerifcation(
20
+ recipientArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode['request']
21
+ ) {
22
+ const typedrequest =
23
+ this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendVerificationCode>(
24
+ 'sendVerificationCode'
25
+ );
26
+ const response = await typedrequest.fire(recipientArg);
27
+ return response.verificationCode;
28
+ }
29
+ }
package/ts/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './classes.serviceserver.js';
2
+
3
+ // Things for building a server
4
+ import { servertools } from '@api.global/typedserver';
5
+ const { Handler, HandlerTypedRouter } = servertools;
6
+ export { Handler, HandlerTypedRouter };
7
+
@@ -0,0 +1,44 @@
1
+ import * as plugins from '../plugins.js';
2
+
3
+ import { simpleInfo } from './template.js';
4
+
5
+ export interface IHtmlInfoOptions {
6
+ text: string;
7
+ heading?: string;
8
+ title?: string;
9
+ sentryMessage?: string;
10
+ sentryDsn?: string;
11
+ redirectTo?: string;
12
+ }
13
+
14
+ export class InfoHtml {
15
+ // STATIC
16
+ public static async fromSimpleText(textArg: string) {
17
+ const infohtmlInstance = new InfoHtml({
18
+ text: textArg,
19
+ heading: null,
20
+ });
21
+ await infohtmlInstance.init();
22
+ return infohtmlInstance;
23
+ }
24
+
25
+ public static async fromOptions(optionsArg: IHtmlInfoOptions) {
26
+ const infohtmlInstance = new InfoHtml(optionsArg);
27
+ await infohtmlInstance.init();
28
+ return infohtmlInstance;
29
+ }
30
+
31
+ // INSTANCE
32
+ public options: IHtmlInfoOptions;
33
+ public smartntmlInstance: plugins.smartntml.Smartntml;
34
+ public htmlString: string;
35
+ constructor(optionsArg: IHtmlInfoOptions) {
36
+ this.options = optionsArg;
37
+ }
38
+
39
+ public async init() {
40
+ this.smartntmlInstance = new plugins.smartntml.Smartntml();
41
+ this.htmlString = await simpleInfo(this.smartntmlInstance, this.options);
42
+ return this.htmlString;
43
+ }
44
+ }
@@ -0,0 +1 @@
1
+ export { InfoHtml } from './classes.infohtml.js';
@@ -0,0 +1,162 @@
1
+ import * as plugins from '../plugins.js';
2
+ import { type IHtmlInfoOptions } from './classes.infohtml.js';
3
+
4
+ export const simpleInfo = async (
5
+ smartntmlInstanceArg: plugins.smartntml.Smartntml,
6
+ optionsArg: IHtmlInfoOptions
7
+ ) => {
8
+ const html = plugins.smartntml.deesElement.html;
9
+ const htmlTemplate = await plugins.smartntml.deesElement.html`
10
+ <html lang="en">
11
+ <head>
12
+ <title>${optionsArg.title}</title>
13
+ <script>
14
+ setTimeout(() => {
15
+ const redirectUrl = '${optionsArg.redirectTo}';
16
+ if (redirectUrl) {
17
+ window.location = redirectUrl;
18
+ }
19
+ }, 5000);
20
+ </script>
21
+ <style>
22
+ body {
23
+ margin: 0px;
24
+ background: #000000;
25
+ font-family: 'Roboto Mono', monospace;
26
+ min-height: 100vh;
27
+ min-width: 100vw;
28
+ border: 1px solid #e4002b;
29
+ }
30
+
31
+ * {
32
+ box-sizing: border-box;
33
+ }
34
+
35
+ .logo {
36
+ width: 150px;
37
+ padding-top: 70px;
38
+ margin: 0px auto 30px auto;
39
+ }
40
+
41
+ .content {
42
+ text-align: center;
43
+ max-width: 800px;
44
+ margin: auto;
45
+ }
46
+
47
+ .content .maintext {
48
+ margin: 10px;
49
+ color: #ffffff;
50
+ background: #333;
51
+ display: block;
52
+ border-radius: 3px;
53
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
54
+ padding: 20px;
55
+ }
56
+
57
+ .content .maintext h1 {
58
+ margin: 0px;
59
+ }
60
+
61
+ .content .addontext {
62
+ margin: 10px;
63
+ color: #ffffff;
64
+ background: #222;
65
+ display: block;
66
+ padding: 10px 15px;
67
+ border-radius: 3px;
68
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
69
+ padding: 10px;
70
+ }
71
+
72
+ .content .text h1 {
73
+ margin: 0px;
74
+ font-weight: 100;
75
+ font-size: 40px;
76
+ }
77
+
78
+ .content .text ul {
79
+ text-align: left;
80
+ }
81
+
82
+ a {
83
+ color: #ffffff;
84
+ }
85
+
86
+ .legal {
87
+ color: #fff;
88
+ position: fixed;
89
+ bottom: 0px;
90
+ width: 100vw;
91
+ text-align: center;
92
+ padding: 10px;
93
+ }
94
+ </style>
95
+ <meta
96
+ name="viewport"
97
+ content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
98
+ />
99
+ <script
100
+ src="https://browser.sentry-cdn.com/5.4.0/bundle.min.js"
101
+ crossorigin="anonymous"
102
+ ></script>
103
+ <script>
104
+ const sentryDsn = '${optionsArg.sentryDsn}';
105
+ const sentryMessage = '${optionsArg.sentryMessage}';
106
+ if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
107
+ Sentry.init({
108
+ dsn: '${optionsArg.sentryDsn}',
109
+ // ...
110
+ });
111
+ Sentry.setExtra('location', window.location.href);
112
+ Sentry.captureMessage('${optionsArg.sentryMessage} @ ' + window.location.host);
113
+ }
114
+ </script>
115
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
116
+ </head>
117
+ <body>
118
+ <div class="logo">
119
+ <img src="https://assetbroker.lossless.one/brandfiles/lossless/svg-minimal-bright.svg" />
120
+ </div>
121
+ <div class="content">
122
+ ${(() => {
123
+ const returnArray: plugins.smartntml.deesElement.TemplateResult[] = [];
124
+ if (optionsArg.heading) {
125
+ returnArray.push(html`
126
+ <div class="maintext">
127
+ <h1>${optionsArg.heading}</h1>
128
+ ${optionsArg.text}
129
+ </div>
130
+ `);
131
+ } else {
132
+ returnArray.push(html` <div class="maintext">${optionsArg.text}</div> `);
133
+ }
134
+ if (optionsArg.sentryDsn && optionsArg.sentryMessage) {
135
+ returnArray.push(
136
+ html`<div class="addontext">
137
+ We recorded this event. Should you continue to see this page against your
138
+ expectations, feel free to mail us at
139
+ <a href="mailto:hello@lossless.com">hello@lossless.com</a>
140
+ </div>`
141
+ );
142
+ }
143
+ if (optionsArg.redirectTo) {
144
+ returnArray.push(
145
+ html`<div class="addontext">
146
+ We will redirect you to ${optionsArg.redirectTo} in a few seconds.
147
+ </div>`
148
+ );
149
+ }
150
+ return returnArray;
151
+ })()}
152
+ </div>
153
+ <div class="legal">
154
+ <a href="https://lossless.com">Lossless GmbH</a> / &copy 2014-${new Date().getFullYear()}
155
+ / <a href="https://lossless.gmbh">Legal Info</a> /
156
+ <a href="https://lossless.gmbh">Privacy Policy</a>
157
+ </div>
158
+ </body>
159
+ </html>
160
+ `;
161
+ return smartntmlInstanceArg.renderTemplateResult(htmlTemplate);
162
+ };
package/ts/logger.ts ADDED
@@ -0,0 +1,9 @@
1
+ import * as plugins from './plugins.js';
2
+
3
+ export const logger = new plugins.smartlog.Smartlog({
4
+ logContext: {
5
+ environment: 'production',
6
+ runtime: 'node',
7
+ zone: 'serve.zone',
8
+ }
9
+ });
package/ts/plugins.ts ADDED
@@ -0,0 +1,29 @@
1
+ // @serve.zone scope
2
+ import * as servezoneInterfaces from '@serve.zone/interfaces';
3
+
4
+ export {
5
+ servezoneInterfaces,
6
+ }
7
+
8
+ // @push.rocks scope
9
+ import * as qenv from '@push.rocks/qenv';
10
+ import * as smartlog from '@push.rocks/smartlog';
11
+ import * as smartntml from '@push.rocks/smartntml';
12
+
13
+ export {
14
+ qenv,
15
+ smartlog,
16
+ smartntml,
17
+ }
18
+
19
+
20
+ // @api.global scope
21
+ import * as typedrequest from '@api.global/typedrequest';
22
+ import * as typedserver from '@api.global/typedserver';
23
+ import * as typedsocket from '@api.global/typedsocket';
24
+
25
+ export {
26
+ typedrequest,
27
+ typedserver,
28
+ typedsocket,
29
+ }