From 7728d011268c5ae896040ad0499a1b330d6d8900 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 16 Apr 2021 07:33:46 +0200 Subject: [PATCH 1/2] Typescript declarations --- lib/classes/cliam.class.d.ts | 37 +++++++++ lib/classes/client-configuration.class.d.ts | 35 +++++++++ lib/classes/consumer.class.d.ts | 63 +++++++++++++++ lib/classes/provider.class.d.ts | 34 +++++++++ lib/classes/sending-error.class.d.ts | 19 +++++ lib/classes/sending-response.class.d.ts | 57 ++++++++++++++ lib/classes/smtp.class.d.ts | 26 +++++++ lib/index.d.ts | 2 + lib/services/compiler.service.d.ts | 76 +++++++++++++++++++ lib/services/container.service.d.ts | 48 ++++++++++++ lib/services/emitter.service.d.ts | 58 ++++++++++++++ lib/services/mailer.service.d.ts | 65 ++++++++++++++++ lib/services/subscriber.service.d.ts | 17 +++++ lib/transporters/ITransporter.interface.d.ts | 16 ++++ .../amazon-ses/amazon-ses.transporter.d.ts | 1 + .../mailersend/mailersend.transporter.d.ts | 2 + .../mailgun/IMailgunError.interface.d.ts | 6 ++ lib/transporters/mailgun/mailgun.class.d.ts | 59 ++++++++++++++ .../mailjet/IMailjetError.interface.d.ts | 9 +++ .../IMailjetErrorMessage.interface.d.ts | 5 ++ .../mailjet/IMailjetResponse.interface.d.ts | 19 +++++ lib/transporters/mailjet/mailjet.class.d.ts | 59 ++++++++++++++ .../mandrill/IMandrillResponse.interface.d.ts | 10 +++ lib/transporters/mandrill/mandrill.class.d.ts | 63 +++++++++++++++ .../postmark/IPostmarkBody.interface.d.ts | 14 ++++ .../postmark/IPostmarkError.interface.d.ts | 11 +++ lib/transporters/postmark/postmark.class.d.ts | 59 ++++++++++++++ .../sendgrid/ISendgridError.interface.d.ts | 11 +++ .../sendgrid/ISendgridResponse.interface.d.ts | 10 +++ lib/transporters/sendgrid/sendgrid.class.d.ts | 63 +++++++++++++++ .../ISendinblueResponse.interface.d.ts | 9 +++ .../sendinblue/sendinblue.class.d.ts | 62 +++++++++++++++ .../smtp/IGmailError.interface.d.ts | 5 ++ .../smtp/IInformaniakError.interface.d.ts | 3 + .../smtp/ISMTPError.interface.d.ts | 5 ++ .../smtp/ISMTPResponse.interface.d.ts | 16 ++++ lib/transporters/smtp/smtp.class.d.ts | 58 ++++++++++++++ .../sparkpost/ISparkpostBody.interface.d.ts | 20 +++++ .../sparkpost/ISparkpostError.interface.d.ts | 7 ++ .../sparkpost/sparkpost.class.d.ts | 62 +++++++++++++++ lib/transporters/transporter.class.d.ts | 38 ++++++++++ lib/transporters/transporter.factory.d.ts | 30 ++++++++ lib/types/decorators/debug.decorator.d.ts | 7 ++ .../enums/attachment-disposition.enum.d.ts | 7 ++ .../enums/attachment-mime-type.enum.d.ts | 38 ++++++++++ lib/types/enums/buffer-mime-type.enum.d.ts | 7 ++ lib/types/enums/compiler.enum.d.ts | 8 ++ lib/types/enums/event.enum.d.ts | 13 ++++ lib/types/enums/http-method.enum.d.ts | 10 +++ lib/types/enums/social-network.enum.d.ts | 8 ++ lib/types/enums/theme.enum.d.ts | 8 ++ lib/types/enums/transporter.enum.d.ts | 13 ++++ .../interfaces/IAttachment.interface.d.ts | 23 ++++++ lib/types/interfaces/IBuffer.interface.d.ts | 14 ++++ .../interfaces/IBuildable.interface.d.ts | 13 ++++ lib/types/interfaces/IError.interface.d.ts | 17 +++++ lib/types/interfaces/IPayload.interface.d.ts | 63 +++++++++++++++ lib/types/interfaces/ISendMail.interface.d.ts | 7 ++ lib/types/interfaces/ISending.interface.d.ts | 34 +++++++++ .../addresses/IAddressA.interface.d.ts | 8 ++ .../addresses/IAddressB.interface.d.ts | 8 ++ .../addresses/IAddressC.interface.d.ts | 7 ++ .../addresses/IAddressD.interface.d.ts | 6 ++ .../addresses/IAddressable.interface.d.ts | 13 ++++ lib/types/schemas/email.schema.d.ts | 3 + lib/types/schemas/filename.schema.d.ts | 3 + lib/types/schemas/host.schema.d.ts | 3 + lib/types/schemas/id.schema.d.ts | 3 + lib/types/schemas/index.d.ts | 12 +++ lib/types/schemas/mimetype.schema.d.ts | 3 + lib/types/schemas/name.schema.d.ts | 3 + lib/types/schemas/password.schema.d.ts | 3 + lib/types/schemas/path.schema.d.ts | 3 + lib/types/schemas/port.schema.d.ts | 3 + lib/types/schemas/recipient.schema.d.ts | 3 + lib/types/schemas/smtp.schema.d.ts | 3 + lib/types/schemas/username.schema.d.ts | 3 + lib/types/types/buffer-mime-type.type.d.ts | 1 + lib/types/types/compiler.type.d.ts | 1 + lib/types/types/event.type.d.ts | 4 + lib/types/types/social-network.type.d.ts | 1 + lib/types/types/transporter.type.d.ts | 1 + lib/utils/enum.util.d.ts | 6 ++ lib/utils/error.util.d.ts | 8 ++ lib/utils/string.util.d.ts | 48 ++++++++++++ lib/validations/configuration.validation.d.ts | 3 + lib/validations/mail.validation.d.ts | 3 + tsconfig.json | 1 + 88 files changed, 1726 insertions(+) create mode 100644 lib/classes/cliam.class.d.ts create mode 100644 lib/classes/client-configuration.class.d.ts create mode 100644 lib/classes/consumer.class.d.ts create mode 100644 lib/classes/provider.class.d.ts create mode 100644 lib/classes/sending-error.class.d.ts create mode 100644 lib/classes/sending-response.class.d.ts create mode 100644 lib/classes/smtp.class.d.ts create mode 100644 lib/index.d.ts create mode 100644 lib/services/compiler.service.d.ts create mode 100644 lib/services/container.service.d.ts create mode 100644 lib/services/emitter.service.d.ts create mode 100644 lib/services/mailer.service.d.ts create mode 100644 lib/services/subscriber.service.d.ts create mode 100644 lib/transporters/ITransporter.interface.d.ts create mode 100644 lib/transporters/amazon-ses/amazon-ses.transporter.d.ts create mode 100644 lib/transporters/mailersend/mailersend.transporter.d.ts create mode 100644 lib/transporters/mailgun/IMailgunError.interface.d.ts create mode 100644 lib/transporters/mailgun/mailgun.class.d.ts create mode 100644 lib/transporters/mailjet/IMailjetError.interface.d.ts create mode 100644 lib/transporters/mailjet/IMailjetErrorMessage.interface.d.ts create mode 100644 lib/transporters/mailjet/IMailjetResponse.interface.d.ts create mode 100644 lib/transporters/mailjet/mailjet.class.d.ts create mode 100644 lib/transporters/mandrill/IMandrillResponse.interface.d.ts create mode 100644 lib/transporters/mandrill/mandrill.class.d.ts create mode 100644 lib/transporters/postmark/IPostmarkBody.interface.d.ts create mode 100644 lib/transporters/postmark/IPostmarkError.interface.d.ts create mode 100644 lib/transporters/postmark/postmark.class.d.ts create mode 100644 lib/transporters/sendgrid/ISendgridError.interface.d.ts create mode 100644 lib/transporters/sendgrid/ISendgridResponse.interface.d.ts create mode 100644 lib/transporters/sendgrid/sendgrid.class.d.ts create mode 100644 lib/transporters/sendinblue/ISendinblueResponse.interface.d.ts create mode 100644 lib/transporters/sendinblue/sendinblue.class.d.ts create mode 100644 lib/transporters/smtp/IGmailError.interface.d.ts create mode 100644 lib/transporters/smtp/IInformaniakError.interface.d.ts create mode 100644 lib/transporters/smtp/ISMTPError.interface.d.ts create mode 100644 lib/transporters/smtp/ISMTPResponse.interface.d.ts create mode 100644 lib/transporters/smtp/smtp.class.d.ts create mode 100644 lib/transporters/sparkpost/ISparkpostBody.interface.d.ts create mode 100644 lib/transporters/sparkpost/ISparkpostError.interface.d.ts create mode 100644 lib/transporters/sparkpost/sparkpost.class.d.ts create mode 100644 lib/transporters/transporter.class.d.ts create mode 100644 lib/transporters/transporter.factory.d.ts create mode 100644 lib/types/decorators/debug.decorator.d.ts create mode 100644 lib/types/enums/attachment-disposition.enum.d.ts create mode 100644 lib/types/enums/attachment-mime-type.enum.d.ts create mode 100644 lib/types/enums/buffer-mime-type.enum.d.ts create mode 100644 lib/types/enums/compiler.enum.d.ts create mode 100644 lib/types/enums/event.enum.d.ts create mode 100644 lib/types/enums/http-method.enum.d.ts create mode 100644 lib/types/enums/social-network.enum.d.ts create mode 100644 lib/types/enums/theme.enum.d.ts create mode 100644 lib/types/enums/transporter.enum.d.ts create mode 100644 lib/types/interfaces/IAttachment.interface.d.ts create mode 100644 lib/types/interfaces/IBuffer.interface.d.ts create mode 100644 lib/types/interfaces/IBuildable.interface.d.ts create mode 100644 lib/types/interfaces/IError.interface.d.ts create mode 100644 lib/types/interfaces/IPayload.interface.d.ts create mode 100644 lib/types/interfaces/ISendMail.interface.d.ts create mode 100644 lib/types/interfaces/ISending.interface.d.ts create mode 100644 lib/types/interfaces/addresses/IAddressA.interface.d.ts create mode 100644 lib/types/interfaces/addresses/IAddressB.interface.d.ts create mode 100644 lib/types/interfaces/addresses/IAddressC.interface.d.ts create mode 100644 lib/types/interfaces/addresses/IAddressD.interface.d.ts create mode 100644 lib/types/interfaces/addresses/IAddressable.interface.d.ts create mode 100644 lib/types/schemas/email.schema.d.ts create mode 100644 lib/types/schemas/filename.schema.d.ts create mode 100644 lib/types/schemas/host.schema.d.ts create mode 100644 lib/types/schemas/id.schema.d.ts create mode 100644 lib/types/schemas/index.d.ts create mode 100644 lib/types/schemas/mimetype.schema.d.ts create mode 100644 lib/types/schemas/name.schema.d.ts create mode 100644 lib/types/schemas/password.schema.d.ts create mode 100644 lib/types/schemas/path.schema.d.ts create mode 100644 lib/types/schemas/port.schema.d.ts create mode 100644 lib/types/schemas/recipient.schema.d.ts create mode 100644 lib/types/schemas/smtp.schema.d.ts create mode 100644 lib/types/schemas/username.schema.d.ts create mode 100644 lib/types/types/buffer-mime-type.type.d.ts create mode 100644 lib/types/types/compiler.type.d.ts create mode 100644 lib/types/types/event.type.d.ts create mode 100644 lib/types/types/social-network.type.d.ts create mode 100644 lib/types/types/transporter.type.d.ts create mode 100644 lib/utils/enum.util.d.ts create mode 100644 lib/utils/error.util.d.ts create mode 100644 lib/utils/string.util.d.ts create mode 100644 lib/validations/configuration.validation.d.ts create mode 100644 lib/validations/mail.validation.d.ts diff --git a/lib/classes/cliam.class.d.ts b/lib/classes/cliam.class.d.ts new file mode 100644 index 0000000..96c5e65 --- /dev/null +++ b/lib/classes/cliam.class.d.ts @@ -0,0 +1,37 @@ +import { Event } from './../types/types/event.type'; +import { IPayload } from './../types/interfaces/IPayload.interface'; +import { SendingResponse } from './sending-response.class'; +import { SendingError } from './sending-error.class'; +/** + * @summary Main class of cliam project. The Cliam class act as entry point and open wrapped methods such subscribe and emit. + * + * @public + */ +declare class Cliam { + /** + * @description + */ + private static instance; + /** + * @description + */ + private emitter; + private constructor(); + /** + * + * @param emitter + */ + static get(emitter: any): Cliam; + /** + * @description + * + * @param event + */ + subscribe(event: Event | string): void; + /** + * @description + */ + emit(event: Event, payload: IPayload): Promise; +} +declare const cliam: Cliam; +export { cliam as Cliam }; diff --git a/lib/classes/client-configuration.class.d.ts b/lib/classes/client-configuration.class.d.ts new file mode 100644 index 0000000..b1e2b8a --- /dev/null +++ b/lib/classes/client-configuration.class.d.ts @@ -0,0 +1,35 @@ +import { Smtp } from './smtp.class'; +import { Consumer } from './consumer.class'; +import { Transporter } from './../types/types/transporter.type'; +/** + * @description + */ +declare class ClientConfiguration { + sandbox?: { + active: boolean; + from: { + name: string; + email: string; + }; + to: { + name: string; + email: string; + }; + }; + consumer: Consumer; + mode: { + api?: { + credentials: { + apiKey: string; + token?: string; + }; + name: Transporter; + templates: Array<{ + [event: string]: string; + }>; + }; + smtp?: Smtp; + }; + constructor(payload: Record); +} +export { ClientConfiguration }; diff --git a/lib/classes/consumer.class.d.ts b/lib/classes/consumer.class.d.ts new file mode 100644 index 0000000..60ab88d --- /dev/null +++ b/lib/classes/consumer.class.d.ts @@ -0,0 +1,63 @@ +/** + * @description + */ +export declare class Consumer { + /** + * + */ + domain: string; + /** + * + */ + company?: string; + /** + * @description + */ + addresses?: { + from?: { + name: string; + email: string; + }; + replyTo?: { + name: string; + email: string; + }; + }; + /** + * + */ + location?: { + street: string; + num: string; + city: string; + zip: string; + country: string; + }; + /** + * + */ + email?: string; + /** + * + */ + phone?: string; + /** + * @description + */ + socials?: Array<{ + name: string; + url: string; + icon: string; + }>; + /** + * + */ + theme?: { + logo: string; + primaryColor: string; + secondaryColor: string; + tertiaryColor: string; + quaternaryColor: string; + }; + constructor(); +} diff --git a/lib/classes/provider.class.d.ts b/lib/classes/provider.class.d.ts new file mode 100644 index 0000000..53bb8b1 --- /dev/null +++ b/lib/classes/provider.class.d.ts @@ -0,0 +1,34 @@ +import { Transporter } from './../types/types/transporter.type'; +/** + * @description + * + * @todo LOW :: Rename as WebApiProvider + */ +export declare class Provider { + /** + * @description + */ + name: Transporter; + /** + * @description + */ + credentials: { + /** + * @description + */ + key: string; + /** + * @description + */ + token: string; + }; + /** + * @description + */ + templates: any; + /** + * @description + */ + domains: string[]; + constructor(payload: Record); +} diff --git a/lib/classes/sending-error.class.d.ts b/lib/classes/sending-error.class.d.ts new file mode 100644 index 0000000..bc2db4f --- /dev/null +++ b/lib/classes/sending-error.class.d.ts @@ -0,0 +1,19 @@ +import { IError } from './../types/interfaces/IError.interface'; +/** + * Type sending error + */ +export declare class SendingError implements IError { + /** + * @description HTTP response status code + */ + statusCode: number; + /** + * @description HTTP response status message + */ + statusText: string; + /** + * @description HTTP response errors + */ + errors: string[]; + constructor(status: number, message: string, errors: string[]); +} diff --git a/lib/classes/sending-response.class.d.ts b/lib/classes/sending-response.class.d.ts new file mode 100644 index 0000000..3a2576e --- /dev/null +++ b/lib/classes/sending-response.class.d.ts @@ -0,0 +1,57 @@ +import { ISending } from './../types/interfaces/ISending.interface'; +import { HTTP_METHOD } from './../types/enums/http-method.enum'; +/** + * Sending response wrapper + */ +export declare class SendingResponse implements ISending { + /** + * @description + */ + accepted?: string | string[]; + /** + * @description Request uri + */ + uri: string; + /** + * @description HTTP protocol version + */ + httpVersion: string; + /** + * @description + */ + messageId?: string; + /** + * @description Request method + */ + method: HTTP_METHOD; + /** + * @description Request headers + */ + headers: object; + /** + * @description Response body + */ + body: Record; + /** + * @description HTTP status code + */ + statusCode: number; + /** + * @description HTTP status message + */ + statusMessage: string; + constructor(); + /** + * @description Property setter + * + * @param property + * @param value + */ + set(property: string, value: number | string | string[] | Record | HTTP_METHOD): SendingResponse; + /** + * @description Property getter + * + * @param property + */ + get(property: string): number | string | string[] | Record | HTTP_METHOD; +} diff --git a/lib/classes/smtp.class.d.ts b/lib/classes/smtp.class.d.ts new file mode 100644 index 0000000..857183d --- /dev/null +++ b/lib/classes/smtp.class.d.ts @@ -0,0 +1,26 @@ +/** + * @description + */ +export declare class Smtp { + /** + * @description + */ + host: string; + /** + * @description + */ + port: number; + /** + * @description + */ + secure: boolean; + /** + * @description + */ + username: string; + /** + * @description + */ + password: string; + constructor(payload: Record); +} diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..c416a94 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,2 @@ +import { Cliam } from './classes/cliam.class'; +export { Cliam }; diff --git a/lib/services/compiler.service.d.ts b/lib/services/compiler.service.d.ts new file mode 100644 index 0000000..757191a --- /dev/null +++ b/lib/services/compiler.service.d.ts @@ -0,0 +1,76 @@ +/** + * On the fly hbs compilation middleware + */ +declare class Compiler { + /** + * @description + */ + private static instance; + /** + * @description + */ + private readonly LAYOUT; + /** + * @description + */ + private readonly PARTIALS; + /** + * @description + */ + private readonly BLOCKS; + /** + * @description + */ + private readonly TEMPLATES; + /** + * @description + */ + private readonly SOCIALS; + /** + * @description + */ + private readonly COLORS; + constructor(); + /** + * @description + */ + static get(): Compiler; + /** + * @description + * + * @param event + * @param data + * + * @todo LOW :: do better about socials and banner + */ + compile(event: string, data: Record): { + text: string; + html: string; + }; + /** + * @description + * + * @param html + */ + textify(html: string): string; + /** + * @description + * + * @param event + */ + private getBanner; + /** + * @description + * + * @param event + */ + private getSegment; + /** + * @description + * + * @param html + */ + private customize; +} +declare const service: Compiler; +export { service as Compiler }; diff --git a/lib/services/container.service.d.ts b/lib/services/container.service.d.ts new file mode 100644 index 0000000..8dbcf41 --- /dev/null +++ b/lib/services/container.service.d.ts @@ -0,0 +1,48 @@ +import { Transporter } from './../transporters/transporter.class'; +import { ClientConfiguration } from './../classes/client-configuration.class'; +/** + * @description + * + * @todo LOW :: Refactoring : should be simplified / cleaned : reading should not be here, this.transporter & this.configuration should be in a slot + */ +declare class Container { + /** + * @description + */ + private static instance; + /** + * @description + */ + configuration: ClientConfiguration; + /** + * @description + */ + transporter: Transporter; + /** + * @description + */ + private readonly PATH; + private constructor(); + /** + * @description + */ + static get(): Container; + /** + * @description + */ + private set; + /** + * @description + * + * @param path + */ + private read; + /** + * @description + * + * @param configuration + */ + private validates; +} +declare const service: Container; +export { service as Container }; diff --git a/lib/services/emitter.service.d.ts b/lib/services/emitter.service.d.ts new file mode 100644 index 0000000..f8b72c7 --- /dev/null +++ b/lib/services/emitter.service.d.ts @@ -0,0 +1,58 @@ +import { ClientConfiguration } from './../classes/client-configuration.class'; +import { IPayload } from './../types/interfaces/IPayload.interface'; +import { SendingResponse } from './../classes/sending-response.class'; +import { SendingError } from './../classes/sending-error.class'; +import { Event } from './../types/types/event.type'; +/** + * @summary + */ +declare class Emitter { + /** + * @description + */ + private static instance; + /** + * @description + */ + private subscribers; + /** + * @description + */ + private configuration; + private constructor(); + /** + * @description + * + * @param emitter + */ + static get(configuration: ClientConfiguration): Emitter; + /** + * @description + * + * @param event + */ + subscribe(event: Event | string): void; + /** + * @description + * + * @param event + */ + unsubscribe(event: Event | string): void; + /** + * @description + * + * @param event + */ + list(event?: Event | string): any[]; + /** + * @description + */ + count(): number; + /** + * @description + * + * @param event + */ + emit(event: Event | string, payload: IPayload): Promise; +} +export { Emitter }; diff --git a/lib/services/mailer.service.d.ts b/lib/services/mailer.service.d.ts new file mode 100644 index 0000000..a09d491 --- /dev/null +++ b/lib/services/mailer.service.d.ts @@ -0,0 +1,65 @@ +import { SendingResponse } from './../classes/sending-response.class'; +import { SendingError } from './../classes/sending-error.class'; +import { IPayload } from './../types/interfaces/IPayload.interface'; +import { Transporter } from './../transporters/transporter.class'; +/** + * @description Manage incoming mail requests + */ +declare class Mailer { + /** + * @description + */ + private static instance; + /** + * @description + */ + private transporter; + constructor(transporter: Transporter); + /** + * @description + */ + static get(transporter: Transporter): Mailer; + /** + * @description Send email + */ + send: (event: string, payload: IPayload) => Promise; + /** + * @description + * + * @param event + * @param payload + */ + private setAddresses; + /** + * @description + * + * @param event + * @param payload + */ + private setCompiler; + /** + * @description + * + * @param event + * @param payload + */ + private getBuildable; + /** + * @description + */ + private getOrigin; + /** + * @description + */ + private getTemplateId; + /** + * @description + */ + private hasPlainText; + /** + * @description + */ + private getCompilated; +} +declare const service: Mailer; +export { service as Mailer }; diff --git a/lib/services/subscriber.service.d.ts b/lib/services/subscriber.service.d.ts new file mode 100644 index 0000000..339a0be --- /dev/null +++ b/lib/services/subscriber.service.d.ts @@ -0,0 +1,17 @@ +import { IPayload } from './../types/interfaces/IPayload.interface'; +import { SendingResponse } from './../classes/sending-response.class'; +import { SendingError } from './../classes/sending-error.class'; +/** + * @description + */ +export declare class Subscriber { + /** + * @description + */ + event: string; + constructor(event: string); + /** + * @description + */ + handler(event: string, payload: IPayload, origin?: string): Promise; +} diff --git a/lib/transporters/ITransporter.interface.d.ts b/lib/transporters/ITransporter.interface.d.ts new file mode 100644 index 0000000..3624769 --- /dev/null +++ b/lib/transporters/ITransporter.interface.d.ts @@ -0,0 +1,16 @@ +import { SendingResponse } from '../classes/sending-response.class'; +import { SendingError } from '../classes/sending-error.class'; +import { ISendMail } from '../types/interfaces/ISendMail.interface'; +import { IBuildable } from '../types/interfaces/IBuildable.interface'; +/** + * Define and grant (mandatory) members of a Transporter instance. + */ +export interface ITransporter { + transporter: ISendMail; + address: (recipient: any, type?: string) => any; + addresses: (recipients: any, type?: string) => any; + build: ({ ...args }: IBuildable) => any; + error: (error: any) => SendingError; + response: (payload: any) => SendingResponse; + sendMail?: (body: any, callback: (err: any, result: any) => void) => void; +} diff --git a/lib/transporters/amazon-ses/amazon-ses.transporter.d.ts b/lib/transporters/amazon-ses/amazon-ses.transporter.d.ts new file mode 100644 index 0000000..c73cd80 --- /dev/null +++ b/lib/transporters/amazon-ses/amazon-ses.transporter.d.ts @@ -0,0 +1 @@ +/** https://www.npmjs.com/package/nodemailer-ses-transport */ diff --git a/lib/transporters/mailersend/mailersend.transporter.d.ts b/lib/transporters/mailersend/mailersend.transporter.d.ts new file mode 100644 index 0000000..3baa0ac --- /dev/null +++ b/lib/transporters/mailersend/mailersend.transporter.d.ts @@ -0,0 +1,2 @@ +/** https://www.mailersend.com/ */ +/** No nodemailer transporter available */ diff --git a/lib/transporters/mailgun/IMailgunError.interface.d.ts b/lib/transporters/mailgun/IMailgunError.interface.d.ts new file mode 100644 index 0000000..eafc3fc --- /dev/null +++ b/lib/transporters/mailgun/IMailgunError.interface.d.ts @@ -0,0 +1,6 @@ +export interface IMailgunError extends Error { + name: string; + statusCode: number; + statusText: string; + message: string; +} diff --git a/lib/transporters/mailgun/mailgun.class.d.ts b/lib/transporters/mailgun/mailgun.class.d.ts new file mode 100644 index 0000000..a9824f0 --- /dev/null +++ b/lib/transporters/mailgun/mailgun.class.d.ts @@ -0,0 +1,59 @@ +import { Transporter } from './../transporter.class'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IMailgunError } from './IMailgunError.interface'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { ITransporter } from './../ITransporter.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingError } from './../../classes/sending-error.class'; +import { SendingResponse } from './../../classes/sending-response.class'; +/** + * This class set a Mailgun transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-mailgun-transport + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-mailgun-transport + * @see https://documentation.mailgun.com/en/latest/index.html + */ +export declare class MailgunTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Format email address according to Mailgun requirements + * + * @param recipient + */ + address(recipient: string | IAddressable): string; + /** + * @description Format email addresses according to Mailgun requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): Array; + /** + * @description Build body request according to Mailgun requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format API response + * + * @param response Response from Mailgun API + */ + response(response: Record): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Mailgun API + */ + error(error: IMailgunError): SendingError; +} diff --git a/lib/transporters/mailjet/IMailjetError.interface.d.ts b/lib/transporters/mailjet/IMailjetError.interface.d.ts new file mode 100644 index 0000000..0274b03 --- /dev/null +++ b/lib/transporters/mailjet/IMailjetError.interface.d.ts @@ -0,0 +1,9 @@ +export interface IMailjetError { + response: { + res: { + text: string; + }; + }; + statusCode: number; + ErrorMessage: string; +} diff --git a/lib/transporters/mailjet/IMailjetErrorMessage.interface.d.ts b/lib/transporters/mailjet/IMailjetErrorMessage.interface.d.ts new file mode 100644 index 0000000..5003603 --- /dev/null +++ b/lib/transporters/mailjet/IMailjetErrorMessage.interface.d.ts @@ -0,0 +1,5 @@ +export interface IMailjetErrorMessage { + Errors: { + ErrorMessage: string; + }[]; +} diff --git a/lib/transporters/mailjet/IMailjetResponse.interface.d.ts b/lib/transporters/mailjet/IMailjetResponse.interface.d.ts new file mode 100644 index 0000000..e38da40 --- /dev/null +++ b/lib/transporters/mailjet/IMailjetResponse.interface.d.ts @@ -0,0 +1,19 @@ +export interface IMailjetResponse { + response: { + body: Record; + res: { + connection: { + servername: string; + }; + headers: Record; + httpVersion: string; + statusMessage: string; + req: { + path: string; + }; + }; + req: { + method: string; + }; + }; +} diff --git a/lib/transporters/mailjet/mailjet.class.d.ts b/lib/transporters/mailjet/mailjet.class.d.ts new file mode 100644 index 0000000..1bbb153 --- /dev/null +++ b/lib/transporters/mailjet/mailjet.class.d.ts @@ -0,0 +1,59 @@ +import { Transporter } from './../transporter.class'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { IAddressA } from './../../types/interfaces/addresses/IAddressA.interface'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IMailjetResponse } from './IMailjetResponse.interface'; +import { IMailjetError } from './IMailjetError.interface'; +import { ITransporter } from './../ITransporter.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingError } from './../../classes/sending-error.class'; +import { SendingResponse } from './../../classes/sending-response.class'; +/** + * Set a Mailjet transporter for mail sending. + * + * @dependency node-mailjet + * + * @see https://fr.mailjet.com/ + * @see https://github.com/mailjet/mailjet-apiv3-nodejs + * @see https://dev.mailjet.com/guides/ + */ +export declare class MailjetTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailjet requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format email address according to Mailjet requirements + * + * @param recipient + */ + address(recipient: string | IAddressable): IAddressA; + /** + * @description Format email addresses according to Mailjet requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): IAddressA[]; + /** + * @description Format API response + * + * @param response Response from Mailjet API + */ + response(response: IMailjetResponse): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Mailgun API + */ + error(error: IMailjetError): SendingError; +} diff --git a/lib/transporters/mandrill/IMandrillResponse.interface.d.ts b/lib/transporters/mandrill/IMandrillResponse.interface.d.ts new file mode 100644 index 0000000..cddee98 --- /dev/null +++ b/lib/transporters/mandrill/IMandrillResponse.interface.d.ts @@ -0,0 +1,10 @@ +export interface IMandrillResponse { + request: { + uri: string; + method: string; + body: Record; + }; + httpVersion: string; + headers: Record; + statusMessage: string; +} diff --git a/lib/transporters/mandrill/mandrill.class.d.ts b/lib/transporters/mandrill/mandrill.class.d.ts new file mode 100644 index 0000000..4d9e041 --- /dev/null +++ b/lib/transporters/mandrill/mandrill.class.d.ts @@ -0,0 +1,63 @@ +import { Transporter } from './../transporter.class'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { IAddressB } from './../../types/interfaces/addresses/IAddressB.interface'; +import { IMandrillResponse } from 'transporters/mandrill/IMandrillResponse.interface'; +import { ITransporter } from './../ITransporter.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingError } from './../../classes/sending-error.class'; +import { SendingResponse } from './../../classes/sending-response.class'; +/** + * Set a Mandrill transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-mandrill-transport + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-mandrill-transport + * @see https://mandrillapp.com/api/docs/ + * @see https://bitbucket.org/mailchimp/mandrill-api-node/src + */ +export declare class MandrillTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailgun requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format email address according to Mandrill requirements + * + * @param recipient Entry to format as email address + * @param type type Discriminator for body property settings + */ + address(recipient: string | IAddressable, type?: string): string | IAddressB; + /** + * @description Format email addresses according to Mandrill requirements + * + * @param recipients Entries to format as email address + * @param type Discriminator for body property settings + */ + addresses(recipients: Array, type?: string): Array; + /** + * @description Format API response + * + * @param response Response from Mandrill API + */ + response(response: IMandrillResponse[]): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Mandrill API + */ + error(error: Error): SendingError; +} diff --git a/lib/transporters/postmark/IPostmarkBody.interface.d.ts b/lib/transporters/postmark/IPostmarkBody.interface.d.ts new file mode 100644 index 0000000..1b22669 --- /dev/null +++ b/lib/transporters/postmark/IPostmarkBody.interface.d.ts @@ -0,0 +1,14 @@ +import { IAttachment } from '../../types/interfaces/IAttachment.interface'; +export interface IPostmarkBody { + from: string; + to: Array; + replyTo: string; + subject: string; + templateModel?: Record; + templateId?: string; + text?: string; + html?: string; + cc?: Array; + bcc?: Array; + attachments?: Array; +} diff --git a/lib/transporters/postmark/IPostmarkError.interface.d.ts b/lib/transporters/postmark/IPostmarkError.interface.d.ts new file mode 100644 index 0000000..56c467f --- /dev/null +++ b/lib/transporters/postmark/IPostmarkError.interface.d.ts @@ -0,0 +1,11 @@ +export interface IPostmarkError { + statusCode?: number; + code?: number; + name?: string; + message?: string; + response?: { + body: { + errors: string[]; + }; + }; +} diff --git a/lib/transporters/postmark/postmark.class.d.ts b/lib/transporters/postmark/postmark.class.d.ts new file mode 100644 index 0000000..979620f --- /dev/null +++ b/lib/transporters/postmark/postmark.class.d.ts @@ -0,0 +1,59 @@ +import { Transporter } from './../transporter.class'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IPostmarkError } from 'transporters/postmark/IPostmarkError.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingResponse } from './../../classes/sending-response.class'; +import { SendingError } from './../../classes/sending-error.class'; +import { IPostmarkBody } from './IPostmarkBody.interface'; +/** + * Set a Postmark transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-postmark-transport + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-postmark-transport + * @see https://postmarkapp.com/developer + */ +export declare class PostmarkTransporter extends Transporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailjet requirements + */ + build({ ...args }: IBuildable): IPostmarkBody; + /** + * @description Format email address according to Postmark requirements + * + * @param recipient + */ + address(recipient: string | IAddressable): string; + /** + * @description Format email addresses according to Postmark requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): Array; + /** + * @description Format API response + * + * @param response Response from Postmark API + */ + response(response: Record): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Postmark API + */ + error(error: IPostmarkError): SendingError; +} diff --git a/lib/transporters/sendgrid/ISendgridError.interface.d.ts b/lib/transporters/sendgrid/ISendgridError.interface.d.ts new file mode 100644 index 0000000..5b9b6ff --- /dev/null +++ b/lib/transporters/sendgrid/ISendgridError.interface.d.ts @@ -0,0 +1,11 @@ +export interface ISendgridError { + statusCode?: number; + code?: number; + name?: string; + message?: string; + response?: { + body: { + errors: string[]; + }; + }; +} diff --git a/lib/transporters/sendgrid/ISendgridResponse.interface.d.ts b/lib/transporters/sendgrid/ISendgridResponse.interface.d.ts new file mode 100644 index 0000000..e7e5707 --- /dev/null +++ b/lib/transporters/sendgrid/ISendgridResponse.interface.d.ts @@ -0,0 +1,10 @@ +export interface ISendgridResponse { + request: { + uri: string; + method: string; + body: Record; + }; + httpVersion: string; + headers: Record; + statusMessage: string; +} diff --git a/lib/transporters/sendgrid/sendgrid.class.d.ts b/lib/transporters/sendgrid/sendgrid.class.d.ts new file mode 100644 index 0000000..ebf656e --- /dev/null +++ b/lib/transporters/sendgrid/sendgrid.class.d.ts @@ -0,0 +1,63 @@ +import { Transporter } from './../transporter.class'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { ISendgridResponse } from './ISendgridResponse.interface'; +import { ITransporter } from './../ITransporter.interface'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { IAddressB } from './../../types/interfaces/addresses/IAddressB.interface'; +import { ISendgridError } from './ISendgridError.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingResponse } from './../../classes/sending-response.class'; +import { SendingError } from './../../classes/sending-error.class'; +/** + * Set a Sendgrid transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-sendgrid + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-sendgrid + * @see https://sendgrid.com/ + * @see https://sendgrid.com/docs/API_Reference/api_v3.html + */ +export declare class SendgridTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailjet requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format email address according to Sendgrid requirements + * + * @param recipient Entry to format as email address + * @param type Discriminator + */ + address(recipient: string | IAddressable, type?: string): string | IAddressB; + /** + * @description Format email addresses according to Sendgrid requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): Array; + /** + * @description Format API response + * + * @param response Response from Sendgrid API + */ + response(response: ISendgridResponse[]): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Sendgrid API + */ + error(error: ISendgridError): SendingError; +} diff --git a/lib/transporters/sendinblue/ISendinblueResponse.interface.d.ts b/lib/transporters/sendinblue/ISendinblueResponse.interface.d.ts new file mode 100644 index 0000000..9389a3f --- /dev/null +++ b/lib/transporters/sendinblue/ISendinblueResponse.interface.d.ts @@ -0,0 +1,9 @@ +export interface ISendinblueResponse { + res: { + httpVersion: string; + headers: Record; + method: string; + statusMessage: string; + }; + body: Record; +} diff --git a/lib/transporters/sendinblue/sendinblue.class.d.ts b/lib/transporters/sendinblue/sendinblue.class.d.ts new file mode 100644 index 0000000..ddf404d --- /dev/null +++ b/lib/transporters/sendinblue/sendinblue.class.d.ts @@ -0,0 +1,62 @@ +import { Transporter } from './../transporter.class'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { ISendinblueResponse } from './ISendinblueResponse.interface'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IAddressB } from './../../types/interfaces/addresses/IAddressB.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingError } from './../../classes/sending-error.class'; +import { SendingResponse } from './../../classes/sending-response.class'; +/** + * Set a Sendinblue transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-sendinblue-transport + * @dependency Fork of nodemailer-sendinblue-transport https://github.com/konfer-be/nodemailer-sendinblue-transport.git + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-sendinblue-transport + * @see https://fr.sendinblue.com/ + * @see https://apidocs.sendinblue.com/tutorial-sending-transactional-email/ + * + */ +export declare class SendinblueTransporter extends Transporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailjet requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format email address according to Sendinblue requirements + * + * @param recipient Entry to format as email address + */ + address(recipient: string | IAddressable): IAddressB; + /** + * @description Format email addresses according to Sendinblue requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): Array; + /** + * @description Format API response + * + * @param response Response from Sendinblue API + */ + response(response: ISendinblueResponse): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Sendgrid API + */ + error(error: Error): SendingError; +} diff --git a/lib/transporters/smtp/IGmailError.interface.d.ts b/lib/transporters/smtp/IGmailError.interface.d.ts new file mode 100644 index 0000000..923be18 --- /dev/null +++ b/lib/transporters/smtp/IGmailError.interface.d.ts @@ -0,0 +1,5 @@ +export interface IGmailError { + response: string; + responseCode: number; + code: number; +} diff --git a/lib/transporters/smtp/IInformaniakError.interface.d.ts b/lib/transporters/smtp/IInformaniakError.interface.d.ts new file mode 100644 index 0000000..42a6980 --- /dev/null +++ b/lib/transporters/smtp/IInformaniakError.interface.d.ts @@ -0,0 +1,3 @@ +export interface IInfomaniakError { + errno: number; +} diff --git a/lib/transporters/smtp/ISMTPError.interface.d.ts b/lib/transporters/smtp/ISMTPError.interface.d.ts new file mode 100644 index 0000000..5aaecda --- /dev/null +++ b/lib/transporters/smtp/ISMTPError.interface.d.ts @@ -0,0 +1,5 @@ +export interface ISMTPError { + response: string; + responseCode: number; + code: number; +} diff --git a/lib/transporters/smtp/ISMTPResponse.interface.d.ts b/lib/transporters/smtp/ISMTPResponse.interface.d.ts new file mode 100644 index 0000000..270de19 --- /dev/null +++ b/lib/transporters/smtp/ISMTPResponse.interface.d.ts @@ -0,0 +1,16 @@ +/** + * @description + */ +export interface ISMTPResponse { + accepted?: string | string[]; + rejected?: string | string[]; + envelopeTime?: number; + messageTime?: number; + messageSize?: number; + response?: string; + envelope?: { + from: string; + to: string[]; + }; + messageId?: string; +} diff --git a/lib/transporters/smtp/smtp.class.d.ts b/lib/transporters/smtp/smtp.class.d.ts new file mode 100644 index 0000000..d54d099 --- /dev/null +++ b/lib/transporters/smtp/smtp.class.d.ts @@ -0,0 +1,58 @@ +import { Transporter } from './../transporter.class'; +import { IAddressable } from './../../types/interfaces/addresses/IAddressable.interface'; +import { ISMTPResponse } from './ISMTPResponse.interface'; +import { IBuildable } from './../../types/interfaces/IBuildable.interface'; +import { IGmailError } from './IGmailError.interface'; +import { IInfomaniakError } from './IInformaniakError.interface'; +import { ISMTPError } from './ISMTPError.interface'; +import { ITransporter } from './../ITransporter.interface'; +import { ISendMail } from './../../types/interfaces/ISendMail.interface'; +import { SendingError } from './../../classes/sending-error.class'; +import { SendingResponse } from './../../classes/sending-response.class'; +/** + * Set a Nodemailer SMTP transporter for mail sending. + * + * @dependency nodemailer + * + * @see https://nodemailer.com/smtp/ + */ +export declare class SmtpTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Mailjet requirements + */ + build({ ...args }: IBuildable): Record; + /** + * @description Format email address according to SMTP requirements + * + * @param recipient + */ + address(recipient: string | IAddressable): string; + /** + * @description Format email addresses according to SMTP requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): Array; + /** + * @description Format API response + * + * @param response Response from Nodemailer SMTP API + */ + response(response: ISMTPResponse): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Nodemailer SMTP API + * + * @fixme Non managed error with smtp.gmail.com and secure true : error have a different pattern and this regError.exec(error.response)[0] not working + */ + error(error: Error | IGmailError | IInfomaniakError | ISMTPError): SendingError; +} diff --git a/lib/transporters/sparkpost/ISparkpostBody.interface.d.ts b/lib/transporters/sparkpost/ISparkpostBody.interface.d.ts new file mode 100644 index 0000000..fae86dd --- /dev/null +++ b/lib/transporters/sparkpost/ISparkpostBody.interface.d.ts @@ -0,0 +1,20 @@ +import { IAddressB } from '../../types/interfaces/addresses/IAddressB.interface'; +import { IAddressD } from '../../types/interfaces/addresses/IAddressD.interface'; +import { IAttachment } from '../../types/interfaces/IAttachment.interface'; +export interface ISparkpostBody { + content: { + attachments?: IAttachment[]; + headers?: { + CC?: string[]; + }; + from: IAddressB; + html?: string; + reply_to: string; + subject: string; + template_id?: string; + text?: string; + use_draft_template?: boolean; + }; + recipients: IAddressD[]; + substitution_data?: Record; +} diff --git a/lib/transporters/sparkpost/ISparkpostError.interface.d.ts b/lib/transporters/sparkpost/ISparkpostError.interface.d.ts new file mode 100644 index 0000000..2600744 --- /dev/null +++ b/lib/transporters/sparkpost/ISparkpostError.interface.d.ts @@ -0,0 +1,7 @@ +export interface ISparkpostError { + statusCode: number; + errors: { + message: string; + description: string; + }[]; +} diff --git a/lib/transporters/sparkpost/sparkpost.class.d.ts b/lib/transporters/sparkpost/sparkpost.class.d.ts new file mode 100644 index 0000000..657dd5a --- /dev/null +++ b/lib/transporters/sparkpost/sparkpost.class.d.ts @@ -0,0 +1,62 @@ +import { Transporter } from '../transporter.class'; +import { ITransporter } from '../ITransporter.interface'; +import { ISparkpostError } from './ISparkpostError.interface'; +import { IBuildable } from '../../types/interfaces/IBuildable.interface'; +import { IAddressable } from '../../types/interfaces/addresses/IAddressable.interface'; +import { ISparkpostBody } from './ISparkpostBody.interface'; +import { IAddressD } from '../../types/interfaces/addresses/IAddressD.interface'; +import { ISendMail } from '../../types/interfaces/ISendMail.interface'; +import { SendingError } from '../../classes/sending-error.class'; +import { SendingResponse } from '../../classes/sending-response.class'; +/** + * Set a Sparkpost transporter for mail sending. + * + * @dependency nodemailer + * @dependency nodemailer-sparkpost-transport + * + * @see https://nodemailer.com/smtp/ + * @see https://www.npmjs.com/package/nodemailer-sparkpost-transport + * @see https://app.sparkpost.com + * @see https://developers.sparkpost.com/api/ + */ +export declare class SparkpostTransporter extends Transporter implements ITransporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + /** + * @description + * + * @param transporterEngine + * @param domain Domain which do the request + */ + constructor(transporterEngine: ISendMail); + /** + * @description Build body request according to Sparkpost requirements + */ + build({ ...args }: IBuildable): ISparkpostBody; + /** + * @description Format email address according to Sparkpost requirements + * + * @param recipient + */ + address(recipient: string | IAddressable): IAddressD; + /** + * @description Format email addresses according to Sparkpost requirements + * + * @param recipients Entries to format as email address + */ + addresses(recipients: Array): IAddressD[]; + /** + * @description Format API response + * + * @param response Response from Sparkpost API + */ + response(response: Record): SendingResponse; + /** + * @description Format error output + * + * @param error Error from Sparkpost API + */ + error(error: ISparkpostError): SendingError; +} diff --git a/lib/transporters/transporter.class.d.ts b/lib/transporters/transporter.class.d.ts new file mode 100644 index 0000000..27b2767 --- /dev/null +++ b/lib/transporters/transporter.class.d.ts @@ -0,0 +1,38 @@ +import { SendingResponse } from './../classes/sending-response.class'; +import { SendingError } from './../classes/sending-error.class'; +import { ISendMail } from './../types/interfaces/ISendMail.interface'; +import { IBuildable } from './../types/interfaces/IBuildable.interface'; +/** + * Main Transporter class + */ +export declare abstract class Transporter { + /** + * @description Wrapped concrete transporter instance + */ + transporter: ISendMail; + constructor(); + /** + * @description + * + * @param err + */ + error(err: any): any; + /** + * @description + * + * @param err + */ + response(res: any): any; + /** + * @description + * + * @param err + */ + build({ ...args }: IBuildable): any; + /** + * @description Send email + * + * @returns + */ + send(body: Record): Promise; +} diff --git a/lib/transporters/transporter.factory.d.ts b/lib/transporters/transporter.factory.d.ts new file mode 100644 index 0000000..7d636fb --- /dev/null +++ b/lib/transporters/transporter.factory.d.ts @@ -0,0 +1,30 @@ +import { Transporter as TransporterType } from '../types/types/transporter.type'; +import { Smtp } from '../classes/smtp.class'; +import { Transporter } from './transporter.class'; +/** + * @description + */ +export declare class TransporterFactory { + private static engine; + constructor(); + /** + * @description Get a concrete transporter instance + * + * @param key + */ + static get(key: TransporterType, { ...args }: { + apiKey?: string; + token?: string; + smtp?: Smtp; + domain?: string; + }): Transporter; +} +/** + * après création, pour le smtp ? OU ailleurs en fait + * this.transporter.verify( (err, res) => { + if (err) { + reject(this.error(err)); + } + resolve(this.transporter); + }); + */ diff --git a/lib/types/decorators/debug.decorator.d.ts b/lib/types/decorators/debug.decorator.d.ts new file mode 100644 index 0000000..1e18eb1 --- /dev/null +++ b/lib/types/decorators/debug.decorator.d.ts @@ -0,0 +1,7 @@ +/** + * @description + * + * @param transporter + */ +declare const Debug: (transporter: string) => any; +export { Debug }; diff --git a/lib/types/enums/attachment-disposition.enum.d.ts b/lib/types/enums/attachment-disposition.enum.d.ts new file mode 100644 index 0000000..78d007c --- /dev/null +++ b/lib/types/enums/attachment-disposition.enum.d.ts @@ -0,0 +1,7 @@ +/** + * @description Define email attachment disposition property allowed values + */ +export declare enum ATTACHMENT_DISPOSITION { + inline = "inline", + attachment = "attachment" +} diff --git a/lib/types/enums/attachment-mime-type.enum.d.ts b/lib/types/enums/attachment-mime-type.enum.d.ts new file mode 100644 index 0000000..b502b5b --- /dev/null +++ b/lib/types/enums/attachment-mime-type.enum.d.ts @@ -0,0 +1,38 @@ +/** + * @description Define supported attachment mime-types + */ +declare enum ATTACHMENT_MIME_TYPE { + 'application/vnd.ms-excel' = "application/vnd.ms-excel", + 'application/vnd.ms-powerpoint' = "application/vnd.ms-powerpoint", + 'application/msword' = "application/msword", + 'application/pdf' = "application/pdf", + 'application/vnd.oasis.opendocument.presentation' = "application/vnd.oasis.opendocument.presentation", + 'application/vnd.oasis.opendocument.spreadsheet' = "application/vnd.oasis.opendocument.spreadsheet", + 'application/vnd.oasis.opendocument.text' = "application/vnd.oasis.opendocument.text", + 'application/x-7z-compressed' = "application/x-7z-compressed", + 'application/x-mpegURL' = "application/x-mpegURL", + 'application/x-rar-compressed' = "application/x-rar-compressed", + 'application/x-tar' = "application/x-tar", + 'application/zip' = "application/zip", + 'audio/mpeg' = "audio/mpeg", + 'audio/mp3' = "audio/mp3", + 'audio/mid' = "audio/mid", + 'audio/mp4' = "audio/mp4", + 'audio/x-aiff' = "audio/x-aiff", + 'audio/ogg' = "audio/ogg", + 'audio/vorbis' = "audio/vorbis", + 'audio/vnd.wav' = "audio/vnd.wav", + 'image/bmp' = "image/bmp", + 'image/gif' = "image/gif", + 'image/jpg' = "image/jpg", + 'image/jpeg' = "image/jpeg", + 'image/png' = "image/png", + 'text/calendar' = "text/calendar", + 'text/csv' = "text/csv", + 'video/mp4' = "video/mp4", + 'video/3gpp' = "video/3gpp", + 'video/quicktime' = "video/quicktime", + 'video/x-msvideo' = "video/x-msvideo", + 'video/x-ms-wmv' = "video/x-ms-wmv" +} +export { ATTACHMENT_MIME_TYPE }; diff --git a/lib/types/enums/buffer-mime-type.enum.d.ts b/lib/types/enums/buffer-mime-type.enum.d.ts new file mode 100644 index 0000000..da35838 --- /dev/null +++ b/lib/types/enums/buffer-mime-type.enum.d.ts @@ -0,0 +1,7 @@ +/** + * @description Define email buffer supported mimes + */ +export declare enum BUFFER_MIME_TYPE { + 'text/plain' = "text/plain", + 'text/html' = "text/html" +} diff --git a/lib/types/enums/compiler.enum.d.ts b/lib/types/enums/compiler.enum.d.ts new file mode 100644 index 0000000..5a6f18f --- /dev/null +++ b/lib/types/enums/compiler.enum.d.ts @@ -0,0 +1,8 @@ +/** + * @description Define supported rendering modes + */ +export declare enum COMPILER { + provider = "provider", + default = "default", + self = "self" +} diff --git a/lib/types/enums/event.enum.d.ts b/lib/types/enums/event.enum.d.ts new file mode 100644 index 0000000..313c705 --- /dev/null +++ b/lib/types/enums/event.enum.d.ts @@ -0,0 +1,13 @@ +/** + * @description Define supported email events + * + * @deprecated + */ +export declare enum EVENT { + confirm = "confirm", + welcome = "welcome", + alert = "alert", + password = "password", + contact = "contact", + invoice = "invoice" +} diff --git a/lib/types/enums/http-method.enum.d.ts b/lib/types/enums/http-method.enum.d.ts new file mode 100644 index 0000000..ffe2540 --- /dev/null +++ b/lib/types/enums/http-method.enum.d.ts @@ -0,0 +1,10 @@ +/** + * @description Define supported HTTP methods + */ +export declare enum HTTP_METHOD { + GET = "GET", + POST = "POST", + PUT = "PUT", + PATCH = "PATCH", + DELETE = "DELETE" +} diff --git a/lib/types/enums/social-network.enum.d.ts b/lib/types/enums/social-network.enum.d.ts new file mode 100644 index 0000000..92e9cb3 --- /dev/null +++ b/lib/types/enums/social-network.enum.d.ts @@ -0,0 +1,8 @@ +export declare enum SOCIAL_NETWORK { + 'facebook' = "facebook", + 'twitter' = "twitter", + 'youtube' = "youtube", + 'google' = "google", + 'github' = "github", + 'linkedin' = "linkedin" +} diff --git a/lib/types/enums/theme.enum.d.ts b/lib/types/enums/theme.enum.d.ts new file mode 100644 index 0000000..9be9e60 --- /dev/null +++ b/lib/types/enums/theme.enum.d.ts @@ -0,0 +1,8 @@ +/** + * @description + */ +export declare enum THEME { + 'caracas' = "caracas", + 'oxygen' = "oxygen", + 'neopolitan' = "neopolitan" +} diff --git a/lib/types/enums/transporter.enum.d.ts b/lib/types/enums/transporter.enum.d.ts new file mode 100644 index 0000000..f764498 --- /dev/null +++ b/lib/types/enums/transporter.enum.d.ts @@ -0,0 +1,13 @@ +/** + * @description Define supported email transporters + */ +export declare enum TRANSPORTER { + sparkpost = "sparkpost", + sendgrid = "sendgrid", + sendinblue = "sendinblue", + mandrill = "mandrill", + mailgun = "mailgun", + mailjet = "mailjet", + postmark = "postmark", + smtp = "smtp" +} diff --git a/lib/types/interfaces/IAttachment.interface.d.ts b/lib/types/interfaces/IAttachment.interface.d.ts new file mode 100644 index 0000000..b384ab9 --- /dev/null +++ b/lib/types/interfaces/IAttachment.interface.d.ts @@ -0,0 +1,23 @@ +import { ATTACHMENT_DISPOSITION } from '../enums/attachment-disposition.enum'; +import { ATTACHMENT_MIME_TYPE } from '../enums/attachment-mime-type.enum'; +/** + * Describe fields of an email attachment + */ +export interface IAttachment { + /** + * @description Base64 encoded content + */ + content: string; + /** + * @description Mime-Type of the attachment + */ + type?: ATTACHMENT_MIME_TYPE; + /** + * @description File name of the attachment + */ + filename: string; + /** + * @description Attachment disposition + */ + disposition?: ATTACHMENT_DISPOSITION; +} diff --git a/lib/types/interfaces/IBuffer.interface.d.ts b/lib/types/interfaces/IBuffer.interface.d.ts new file mode 100644 index 0000000..563c461 --- /dev/null +++ b/lib/types/interfaces/IBuffer.interface.d.ts @@ -0,0 +1,14 @@ +import { BufferMimeType } from '../types/buffer-mime-type.type'; +/** + * Describe fields of an email buffer + */ +export interface IBuffer { + /** + * @description Mime-type of the buffer + */ + type: BufferMimeType; + /** + * @description Text content of the buffer + */ + value: string; +} diff --git a/lib/types/interfaces/IBuildable.interface.d.ts b/lib/types/interfaces/IBuildable.interface.d.ts new file mode 100644 index 0000000..a0223c2 --- /dev/null +++ b/lib/types/interfaces/IBuildable.interface.d.ts @@ -0,0 +1,13 @@ +import { IPayload } from '../interfaces/IPayload.interface'; +/** + * @description + */ +export interface IBuildable { + payload: IPayload; + templateId: string; + body: { + text: string; + html: string; + }; + origin: string; +} diff --git a/lib/types/interfaces/IError.interface.d.ts b/lib/types/interfaces/IError.interface.d.ts new file mode 100644 index 0000000..a3d4706 --- /dev/null +++ b/lib/types/interfaces/IError.interface.d.ts @@ -0,0 +1,17 @@ +/** + * Define error output format + */ +export interface IError { + /** + * @description HTTP response status code + */ + statusCode: number; + /** + * @description HTTP response status message + */ + statusText: string; + /** + * @description HTTP response errors + */ + errors: string[]; +} diff --git a/lib/types/interfaces/IPayload.interface.d.ts b/lib/types/interfaces/IPayload.interface.d.ts new file mode 100644 index 0000000..f43c35d --- /dev/null +++ b/lib/types/interfaces/IPayload.interface.d.ts @@ -0,0 +1,63 @@ +import { IAttachment } from './IAttachment.interface'; +import { IAddressable } from './addresses/IAddressable.interface'; +import { IBuffer } from './IBuffer.interface'; +import { Compiler } from '../types/compiler.type'; +/** + * Define a payload schema type + */ +export interface IPayload { + /** + * @description + */ + compiler?: Compiler; + /** + * @description Meta data for email sending + */ + meta: { + /** + * @description Template id to use + * @deprecated le template est récupéré en fonction de l'action, et du type d'email (compilé en external) + */ + templateId?: string; + /** + * @description From address object + */ + from: IAddressable; + /** + * @description Recipients addresses objects + */ + to: Array | Array; + /** + * @description Reply-to address object + */ + replyTo: IAddressable; + /** + * @description Subject of email + */ + subject: string; + /** + * @description CC recipients addresses objects + */ + cc?: Array; + /** + * @description BCC recipients addresses objects + */ + bcc?: Array; + /** + * @description Attachments objects to join to email + */ + attachments?: Array; + /** + * @description Images objects to include to email + */ + inlineImages?: Array; + }; + /** + * @description Variables to use when template is compilated + */ + data?: Record; + /** + * @description Email stream contents to send + */ + content?: IBuffer[]; +} diff --git a/lib/types/interfaces/ISendMail.interface.d.ts b/lib/types/interfaces/ISendMail.interface.d.ts new file mode 100644 index 0000000..c9de172 --- /dev/null +++ b/lib/types/interfaces/ISendMail.interface.d.ts @@ -0,0 +1,7 @@ +/** + * @description + */ +export interface ISendMail { + options?: any; + sendMail: (body: any, callback: (err: any, result: any) => void) => void; +} diff --git a/lib/types/interfaces/ISending.interface.d.ts b/lib/types/interfaces/ISending.interface.d.ts new file mode 100644 index 0000000..2ea4c81 --- /dev/null +++ b/lib/types/interfaces/ISending.interface.d.ts @@ -0,0 +1,34 @@ +import { HTTP_METHOD } from '../enums/http-method.enum'; +/** + * Define mail sending uniform response properties. + */ +export interface ISending { + /** + * @description URI of the request + */ + uri: string; + /** + * @description HTTP protocol version used by the requested server + */ + httpVersion: string; + /** + * @description HTTP method of the request + */ + method: HTTP_METHOD; + /** + * @description HTTP headers of the response + */ + headers: Object; + /** + * @description Content returned by the requested API + */ + body: Object; + /** + * @description HTTP status code + */ + statusCode: number; + /** + * @description HTTP status message + */ + statusMessage: string; +} diff --git a/lib/types/interfaces/addresses/IAddressA.interface.d.ts b/lib/types/interfaces/addresses/IAddressA.interface.d.ts new file mode 100644 index 0000000..a431045 --- /dev/null +++ b/lib/types/interfaces/addresses/IAddressA.interface.d.ts @@ -0,0 +1,8 @@ +/** + * @description + */ +export interface IAddressA { + Email: string; + Name?: string; + Type?: string; +} diff --git a/lib/types/interfaces/addresses/IAddressB.interface.d.ts b/lib/types/interfaces/addresses/IAddressB.interface.d.ts new file mode 100644 index 0000000..0822f2b --- /dev/null +++ b/lib/types/interfaces/addresses/IAddressB.interface.d.ts @@ -0,0 +1,8 @@ +/** + * @description + */ +export interface IAddressB { + email: string; + name?: string; + type?: string; +} diff --git a/lib/types/interfaces/addresses/IAddressC.interface.d.ts b/lib/types/interfaces/addresses/IAddressC.interface.d.ts new file mode 100644 index 0000000..1fae37a --- /dev/null +++ b/lib/types/interfaces/addresses/IAddressC.interface.d.ts @@ -0,0 +1,7 @@ +import { IAddressA } from './IAddressA.interface'; +import { IAddressB } from './IAddressB.interface'; +/** + * @description + */ +export interface IAddressC extends IAddressA, IAddressB { +} diff --git a/lib/types/interfaces/addresses/IAddressD.interface.d.ts b/lib/types/interfaces/addresses/IAddressD.interface.d.ts new file mode 100644 index 0000000..f04d98b --- /dev/null +++ b/lib/types/interfaces/addresses/IAddressD.interface.d.ts @@ -0,0 +1,6 @@ +import { IAddressB } from './IAddressB.interface'; +export interface IAddressD { + address: string | IAddressB; + header_to?: string; + email?: string; +} diff --git a/lib/types/interfaces/addresses/IAddressable.interface.d.ts b/lib/types/interfaces/addresses/IAddressable.interface.d.ts new file mode 100644 index 0000000..6b03e19 --- /dev/null +++ b/lib/types/interfaces/addresses/IAddressable.interface.d.ts @@ -0,0 +1,13 @@ +/** + * Define fields of an email address object + */ +export interface IAddressable { + /** + * @description Name used as address name + */ + name?: string; + /** + * @description Email address + */ + email: string; +} diff --git a/lib/types/schemas/email.schema.d.ts b/lib/types/schemas/email.schema.d.ts new file mode 100644 index 0000000..fe4e32b --- /dev/null +++ b/lib/types/schemas/email.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const email: () => AnySchema; +export { email }; diff --git a/lib/types/schemas/filename.schema.d.ts b/lib/types/schemas/filename.schema.d.ts new file mode 100644 index 0000000..9cd6939 --- /dev/null +++ b/lib/types/schemas/filename.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const filename: (extension?: boolean) => AnySchema; +export { filename }; diff --git a/lib/types/schemas/host.schema.d.ts b/lib/types/schemas/host.schema.d.ts new file mode 100644 index 0000000..46c27cb --- /dev/null +++ b/lib/types/schemas/host.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const host: (type: string) => AnySchema; +export { host }; diff --git a/lib/types/schemas/id.schema.d.ts b/lib/types/schemas/id.schema.d.ts new file mode 100644 index 0000000..26c61b5 --- /dev/null +++ b/lib/types/schemas/id.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const id: () => AnySchema; +export { id }; diff --git a/lib/types/schemas/index.d.ts b/lib/types/schemas/index.d.ts new file mode 100644 index 0000000..fae5884 --- /dev/null +++ b/lib/types/schemas/index.d.ts @@ -0,0 +1,12 @@ +import { email } from './email.schema'; +import { filename } from './filename.schema'; +import { host } from './host.schema'; +import { id } from './id.schema'; +import { mimetype } from './mimetype.schema'; +import { name } from './name.schema'; +import { password } from './password.schema'; +import { port } from './port.schema'; +import { path } from './path.schema'; +import { recipient } from './recipient.schema'; +import { username } from './username.schema'; +export { email, filename, host, id, mimetype, name, password, port, path, recipient, username }; diff --git a/lib/types/schemas/mimetype.schema.d.ts b/lib/types/schemas/mimetype.schema.d.ts new file mode 100644 index 0000000..314932b --- /dev/null +++ b/lib/types/schemas/mimetype.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const mimetype: (mimetypes: string[]) => AnySchema; +export { mimetype }; diff --git a/lib/types/schemas/name.schema.d.ts b/lib/types/schemas/name.schema.d.ts new file mode 100644 index 0000000..4c0ace2 --- /dev/null +++ b/lib/types/schemas/name.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const name: () => AnySchema; +export { name }; diff --git a/lib/types/schemas/password.schema.d.ts b/lib/types/schemas/password.schema.d.ts new file mode 100644 index 0000000..85a9416 --- /dev/null +++ b/lib/types/schemas/password.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const password: (type: string) => AnySchema; +export { password }; diff --git a/lib/types/schemas/path.schema.d.ts b/lib/types/schemas/path.schema.d.ts new file mode 100644 index 0000000..df7f69a --- /dev/null +++ b/lib/types/schemas/path.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const path: () => AnySchema; +export { path }; diff --git a/lib/types/schemas/port.schema.d.ts b/lib/types/schemas/port.schema.d.ts new file mode 100644 index 0000000..37d1e97 --- /dev/null +++ b/lib/types/schemas/port.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const port: () => AnySchema; +export { port }; diff --git a/lib/types/schemas/recipient.schema.d.ts b/lib/types/schemas/recipient.schema.d.ts new file mode 100644 index 0000000..a238aec --- /dev/null +++ b/lib/types/schemas/recipient.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const recipient: () => AnySchema; +export { recipient }; diff --git a/lib/types/schemas/smtp.schema.d.ts b/lib/types/schemas/smtp.schema.d.ts new file mode 100644 index 0000000..71905bd --- /dev/null +++ b/lib/types/schemas/smtp.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const smtp: () => AnySchema; +export { smtp }; diff --git a/lib/types/schemas/username.schema.d.ts b/lib/types/schemas/username.schema.d.ts new file mode 100644 index 0000000..17b9b3a --- /dev/null +++ b/lib/types/schemas/username.schema.d.ts @@ -0,0 +1,3 @@ +import { AnySchema } from 'joi'; +declare const username: () => AnySchema; +export { username }; diff --git a/lib/types/types/buffer-mime-type.type.d.ts b/lib/types/types/buffer-mime-type.type.d.ts new file mode 100644 index 0000000..bbff710 --- /dev/null +++ b/lib/types/types/buffer-mime-type.type.d.ts @@ -0,0 +1 @@ +export declare type BufferMimeType = 'text/plain' | 'text/html'; diff --git a/lib/types/types/compiler.type.d.ts b/lib/types/types/compiler.type.d.ts new file mode 100644 index 0000000..4c93051 --- /dev/null +++ b/lib/types/types/compiler.type.d.ts @@ -0,0 +1 @@ +export declare type Compiler = 'provider' | 'default' | 'self'; diff --git a/lib/types/types/event.type.d.ts b/lib/types/types/event.type.d.ts new file mode 100644 index 0000000..450fb85 --- /dev/null +++ b/lib/types/types/event.type.d.ts @@ -0,0 +1,4 @@ +/** + * @description + */ +export declare type Event = 'default' | 'event.subscribe' | 'event.unsubscribe' | 'event.updated' | 'user.progress' | 'user.survey' | 'user.welcome' | 'user.bye' | 'user.confirm' | 'user.contact' | 'user.invite' | 'order.invoice' | 'order.shipped' | 'order.progress' | 'password.request' | 'password.updated'; diff --git a/lib/types/types/social-network.type.d.ts b/lib/types/types/social-network.type.d.ts new file mode 100644 index 0000000..ef3c3b6 --- /dev/null +++ b/lib/types/types/social-network.type.d.ts @@ -0,0 +1 @@ +export declare type SocialNetwork = 'facebook' | 'twitter' | 'youtube' | 'google' | 'github' | 'linkedin'; diff --git a/lib/types/types/transporter.type.d.ts b/lib/types/types/transporter.type.d.ts new file mode 100644 index 0000000..7ab218b --- /dev/null +++ b/lib/types/types/transporter.type.d.ts @@ -0,0 +1 @@ +export declare type Transporter = 'sparkpost' | 'sendgrid' | 'sendinblue' | 'mandrill' | 'mailgun' | 'mailjet' | 'postmark' | 'smtp'; diff --git a/lib/utils/enum.util.d.ts b/lib/utils/enum.util.d.ts new file mode 100644 index 0000000..96c727b --- /dev/null +++ b/lib/utils/enum.util.d.ts @@ -0,0 +1,6 @@ +/** + * @description List enum values + * @param enm Enum to list + */ +declare const list: (enm: Record) => string[]; +export { list }; diff --git a/lib/utils/error.util.d.ts b/lib/utils/error.util.d.ts new file mode 100644 index 0000000..6e278fb --- /dev/null +++ b/lib/utils/error.util.d.ts @@ -0,0 +1,8 @@ +import { IMailjetErrorMessage } from './../transporters/mailjet/IMailjetErrorMessage.interface'; +/** + * @description + * + * @param input + */ +declare const getMailjetErrorMessages: (input: IMailjetErrorMessage[]) => string[]; +export { getMailjetErrorMessages }; diff --git a/lib/utils/string.util.d.ts b/lib/utils/string.util.d.ts new file mode 100644 index 0000000..632e2e5 --- /dev/null +++ b/lib/utils/string.util.d.ts @@ -0,0 +1,48 @@ +/// +/** + * @decription Shuffle an array | string as array of chars + * + * @param a + */ +declare const shuffle: (a: any[]) => string; +/** + * @description Hash a string + * + * @param str Base string to hash + * @param length Number of chars to return + */ +declare const hash: (str: string, length: number) => string; +/** + * @description Encode binary file in base64 + * @param path + */ +declare const base64Encode: (path: string) => string; +/** + * @description Decode base64 encoded stream and write binary file + * @param path + */ +declare const base64Decode: (stream: Buffer, path: string) => void; +/** + * @description Decrypt text + * + * @param cipherText + */ +declare const decrypt: (cipherText: string) => string; +/** + * @description Encrypt text + * + * @param text + */ +declare const encrypt: (text: string) => string; +/** + * @description Get filename without extension + * @param name Filename to parse + */ +declare const filename: (name: string) => string; +/** + * @description Get file extension with or without . + * @param name Filename to parse + * @param include Get extension with . if true, without . else + */ +declare const extension: (name: string, include?: boolean) => string; +export { base64Encode, base64Decode, decrypt, encrypt, extension, filename, hash, shuffle }; diff --git a/lib/validations/configuration.validation.d.ts b/lib/validations/configuration.validation.d.ts new file mode 100644 index 0000000..7a52cc7 --- /dev/null +++ b/lib/validations/configuration.validation.d.ts @@ -0,0 +1,3 @@ +import * as Joi from 'joi'; +declare const configurationSchema: Joi.ObjectSchema; +export { configurationSchema }; diff --git a/lib/validations/mail.validation.d.ts b/lib/validations/mail.validation.d.ts new file mode 100644 index 0000000..be961c9 --- /dev/null +++ b/lib/validations/mail.validation.d.ts @@ -0,0 +1,3 @@ +import * as Joi from 'joi'; +declare const mailSchema: Joi.ObjectSchema; +export { mailSchema }; diff --git a/tsconfig.json b/tsconfig.json index 94c0548..a6da53a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "baseUrl": "./src", "lib": ["dom", "esNext"], "target": "esNext", + "declaration": false, "module": "commonjs", "allowSyntheticDefaultImports": true, "emitDecoratorMetadata": true, From 75d98e8bef3bb466ed824e424051b371e451fc3e Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 16 Apr 2021 07:34:39 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 9 ++++++++- package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59e08ea..c07a7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -## [v1.0.3](https://github.com/konfer-be/cliam/compare/v1.0.2...v1.0.3) +## [v1.0.4](https://github.com/konfer-be/cliam/compare/v1.0.3...v1.0.4) ### Commits +- Typescript declarations [`7728d01`](https://github.com/konfer-be/cliam/commit/7728d011268c5ae896040ad0499a1b330d6d8900) + +## [v1.0.3](https://github.com/konfer-be/cliam/compare/v1.0.2...v1.0.3) - 2021-04-15 + +### Commits + +- Update changelog [`9999b16`](https://github.com/konfer-be/cliam/commit/9999b163ecf0de85520d22936e92a091af41589b) - Fix merge replyTo property [`f633e07`](https://github.com/konfer-be/cliam/commit/f633e07264bca9e03951adb9d6face9dc2e182c3) ## [v1.0.2](https://github.com/konfer-be/cliam/compare/v1.0.1...v1.0.2) - 2021-04-15 diff --git a/package.json b/package.json index b12e4f4..6d84045 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cliam", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=14.16" },