@betterinternship/core 2.1.1 → 2.2.0

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.
@@ -1,16 +1,16 @@
1
- import PocketBase from 'pocketbase';
2
- import { ENV } from '../env.js';
3
- let _pb = {};
4
- if (!ENV.BICORE_IGNORE_POCKETBASE) {
5
- _pb = new PocketBase(ENV.PB_URL);
6
- _pb.autoCancellation(false);
7
- }
8
- export const pb = _pb;
9
- export const authenticatePocketbase = async () => {
10
- await _pb
11
- .collection('_superusers')
12
- .authWithPassword(ENV.PB_ADMIN_EMAIL, ENV.PB_ADMIN_PASSWORD, { autoRefreshThreshold: 30 * 60 });
13
- };
14
- if (!ENV.BICORE_IGNORE_POCKETBASE)
15
- authenticatePocketbase();
1
+ import PocketBase from 'pocketbase';
2
+ import { ENV } from '../env.js';
3
+ let _pb = {};
4
+ if (!ENV.BICORE_IGNORE_POCKETBASE) {
5
+ _pb = new PocketBase(ENV.PB_URL);
6
+ _pb.autoCancellation(false);
7
+ }
8
+ export const pb = _pb;
9
+ export const authenticatePocketbase = async () => {
10
+ await _pb
11
+ .collection('_superusers')
12
+ .authWithPassword(ENV.PB_ADMIN_EMAIL, ENV.PB_ADMIN_PASSWORD, { autoRefreshThreshold: 30 * 60 });
13
+ };
14
+ if (!ENV.BICORE_IGNORE_POCKETBASE)
15
+ authenticatePocketbase();
16
16
  //# sourceMappingURL=pb.js.map
@@ -1,67 +1,67 @@
1
- import { TransactionalEmailsApi } from '@getbrevo/brevo';
2
- import * as nodemailer from 'nodemailer';
3
- import { v4 } from 'uuid';
4
- import { ENV } from '../env.js';
5
- const SMTP_EMAIL = ENV.SMTP_EMAIL;
6
- const SMTP_PASSWORD = ENV.SMTP_PASSWORD;
7
- if (!SMTP_EMAIL || !SMTP_PASSWORD)
8
- throw Error('[ERROR:ENV]: Missing SMTP setup.');
9
- let transacApi = null;
10
- if (process.env.NODE_ENV !== 'development') {
11
- const BREVO_API_KEY = process.env.BREVO_API_KEY;
12
- if (!BREVO_API_KEY)
13
- throw Error('[ERROR:ENV]: Missing Brevo setup.');
14
- transacApi = new TransactionalEmailsApi();
15
- transacApi.setApiKey(0, BREVO_API_KEY);
16
- }
17
- const transporter = nodemailer.createTransport({
18
- service: 'Gmail',
19
- host: 'smtp.gmail.com',
20
- port: 465,
21
- secure: true,
22
- auth: {
23
- user: SMTP_EMAIL,
24
- pass: SMTP_PASSWORD,
25
- },
26
- messageId: `${v4()}${SMTP_EMAIL}`,
27
- });
28
- export const sendSingleEmail = async ({ sender, subject, recipient, content, alias = 'hello', }) => {
29
- if (process.env.NODE_ENV === 'development' || true) {
30
- return new Promise((resolve, reject) => {
31
- transporter.sendMail({
32
- from: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
33
- to: recipient,
34
- subject,
35
- html: content,
36
- }, (error, info) => {
37
- if (error) {
38
- console.error('[ERROR] Could not send email.');
39
- console.error('[-----] ' + error.message);
40
- }
41
- else {
42
- resolve({
43
- messageId: info.messageId,
44
- response: info.response,
45
- });
46
- console.warn('[LOG] Email sent to ' + recipient);
47
- }
48
- });
49
- });
50
- }
51
- else {
52
- const response = await transacApi?.sendTransacEmail({
53
- sender: {
54
- email: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
55
- },
56
- to: [{ email: recipient }],
57
- subject,
58
- htmlContent: content,
59
- });
60
- console.warn('[LOG] Email sent to ' + recipient);
61
- return {
62
- messageId: response?.body?.messageId,
63
- response: response?.response,
64
- };
65
- }
66
- };
1
+ import { TransactionalEmailsApi } from '@getbrevo/brevo';
2
+ import * as nodemailer from 'nodemailer';
3
+ import { v4 } from 'uuid';
4
+ import { ENV } from '../env.js';
5
+ const SMTP_EMAIL = ENV.SMTP_EMAIL;
6
+ const SMTP_PASSWORD = ENV.SMTP_PASSWORD;
7
+ if (!SMTP_EMAIL || !SMTP_PASSWORD)
8
+ throw Error('[ERROR:ENV]: Missing SMTP setup.');
9
+ let transacApi = null;
10
+ if (process.env.NODE_ENV !== 'development') {
11
+ const BREVO_API_KEY = process.env.BREVO_API_KEY;
12
+ if (!BREVO_API_KEY)
13
+ throw Error('[ERROR:ENV]: Missing Brevo setup.');
14
+ transacApi = new TransactionalEmailsApi();
15
+ transacApi.setApiKey(0, BREVO_API_KEY);
16
+ }
17
+ const transporter = nodemailer.createTransport({
18
+ service: 'Gmail',
19
+ host: 'smtp.gmail.com',
20
+ port: 465,
21
+ secure: true,
22
+ auth: {
23
+ user: SMTP_EMAIL,
24
+ pass: SMTP_PASSWORD,
25
+ },
26
+ messageId: `${v4()}${SMTP_EMAIL}`,
27
+ });
28
+ export const sendSingleEmail = async ({ sender, subject, recipient, content, alias = 'hello', }) => {
29
+ if (process.env.NODE_ENV === 'development' || true) {
30
+ return new Promise((resolve, reject) => {
31
+ transporter.sendMail({
32
+ from: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
33
+ to: recipient,
34
+ subject,
35
+ html: content,
36
+ }, (error, info) => {
37
+ if (error) {
38
+ console.error('[ERROR] Could not send email.');
39
+ console.error('[-----] ' + error.message);
40
+ }
41
+ else {
42
+ resolve({
43
+ messageId: info.messageId,
44
+ response: info.response,
45
+ });
46
+ console.warn('[LOG] Email sent to ' + recipient);
47
+ }
48
+ });
49
+ });
50
+ }
51
+ else {
52
+ const response = await transacApi?.sendTransacEmail({
53
+ sender: {
54
+ email: `"${sender ?? 'BetterInternship'}" <${alias}@betterinternship.com>`,
55
+ },
56
+ to: [{ email: recipient }],
57
+ subject,
58
+ htmlContent: content,
59
+ });
60
+ console.warn('[LOG] Email sent to ' + recipient);
61
+ return {
62
+ messageId: response?.body?.messageId,
63
+ response: response?.response,
64
+ };
65
+ }
66
+ };
67
67
  //# sourceMappingURL=email.js.map
@@ -1 +1 @@
1
- export * from './email.js';
1
+ export * from './email.js';
@@ -1,2 +1,2 @@
1
- export * from './email.js';
1
+ export * from './email.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,29 +1,29 @@
1
- import { ZodType } from 'zod';
2
- import { BLOCK_TYPES, IFormField, IFormFieldPrefiller, IFormFieldValidator, IFormPhantomField, IFormSigningParty } from './form-metadata.js';
3
- import { EnumValue } from 'zod/v4/core/util.cjs';
4
- export declare const getSchemaClientType: (s: ZodType) => ClientFieldType;
5
- export type ClientFieldType = 'text' | 'number' | 'date' | 'dropdown' | 'checkbox' | 'textarea' | 'multiselect' | 'time' | 'signature';
6
- export type ClientField<SourceDomains extends any[]> = Omit<IFormField, 'x' | 'y' | 'w' | 'h' | 'page' | 'type' | 'validator' | 'prefiller' | 'align_h' | 'align_v'> & {
7
- type: ClientFieldType;
8
- signing_party_id?: string;
9
- validator: IFormFieldValidator | null;
10
- prefiller: IFormFieldPrefiller<SourceDomains> | null;
11
- options?: EnumValue[];
12
- coerce: (s: string) => string | number | boolean | Date | Array<string>;
13
- };
14
- export type ClientPhantomField<SourceDomains extends any[]> = Omit<IFormPhantomField, 'type' | 'validator' | 'prefiller'> & {
15
- type: ClientFieldType;
16
- signing_party_id?: string;
17
- validator: IFormFieldValidator | null;
18
- prefiller: IFormFieldPrefiller<SourceDomains> | null;
19
- options?: EnumValue[];
20
- coerce: (s: string) => string | number | boolean | Date | Array<string>;
21
- };
22
- export interface ClientBlock<SourceDomains extends any[]> {
23
- block_type: (typeof BLOCK_TYPES)[number];
24
- order: number;
25
- signing_party_id: IFormSigningParty['_id'];
26
- text_content?: string;
27
- field_schema?: ClientField<SourceDomains>;
28
- phantom_field_schema?: ClientPhantomField<SourceDomains>;
29
- }
1
+ import { ZodType } from 'zod';
2
+ import { BLOCK_TYPES, IFormField, IFormFieldPrefiller, IFormFieldValidator, IFormPhantomField, IFormSigningParty } from './form-metadata.js';
3
+ import { EnumValue } from 'zod/v4/core/util.cjs';
4
+ export declare const getSchemaClientType: (s: ZodType) => ClientFieldType;
5
+ export type ClientFieldType = 'text' | 'number' | 'date' | 'dropdown' | 'checkbox' | 'textarea' | 'multiselect' | 'time' | 'signature';
6
+ export type ClientField<SourceDomains extends any[]> = Omit<IFormField, 'x' | 'y' | 'w' | 'h' | 'page' | 'type' | 'validator' | 'prefiller' | 'align_h' | 'align_v'> & {
7
+ type: ClientFieldType;
8
+ signing_party_id?: string;
9
+ validator: IFormFieldValidator | null;
10
+ prefiller: IFormFieldPrefiller<SourceDomains> | null;
11
+ options?: EnumValue[];
12
+ coerce: (s: string) => string | number | boolean | Date | Array<string>;
13
+ };
14
+ export type ClientPhantomField<SourceDomains extends any[]> = Omit<IFormPhantomField, 'type' | 'validator' | 'prefiller'> & {
15
+ type: ClientFieldType;
16
+ signing_party_id?: string;
17
+ validator: IFormFieldValidator | null;
18
+ prefiller: IFormFieldPrefiller<SourceDomains> | null;
19
+ options?: EnumValue[];
20
+ coerce: (s: string) => string | number | boolean | Date | Array<string>;
21
+ };
22
+ export interface ClientBlock<SourceDomains extends any[]> {
23
+ block_type: (typeof BLOCK_TYPES)[number];
24
+ order: number;
25
+ signing_party_id: IFormSigningParty['_id'];
26
+ text_content?: string;
27
+ field_schema?: ClientField<SourceDomains>;
28
+ phantom_field_schema?: ClientPhantomField<SourceDomains>;
29
+ }
@@ -1,3 +1,3 @@
1
- export * from './form-metadata.js';
2
- export * from './fields.client.js';
3
- export * from './fields.server.js';
1
+ export * from './form-metadata.js';
2
+ export * from './fields.client.js';
3
+ export * from './fields.server.js';
@@ -1,4 +1,4 @@
1
- export * from './form-metadata.js';
2
- export * from './fields.client.js';
3
- export * from './fields.server.js';
1
+ export * from './form-metadata.js';
2
+ export * from './fields.client.js';
3
+ export * from './fields.server.js';
4
4
  //# sourceMappingURL=index.js.map