@betterinternship/core 2.3.0 → 2.3.1
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.
- package/dist/index.js +5 -5
- package/dist/lib/broker/broker.d.ts +5 -1
- package/dist/lib/broker/broker.js +5 -5
- package/dist/lib/broker/broker.js.map +1 -1
- package/dist/lib/chat/chat.d.ts +51 -51
- package/dist/lib/chat/chat.js +183 -183
- package/dist/lib/chat/index.js +2 -2
- package/dist/lib/chat/pb.js +15 -15
- package/dist/lib/email/email.js +66 -66
- package/dist/lib/email/index.js +1 -1
- package/dist/lib/env.js +3 -3
- package/dist/lib/forms/fields.client.d.ts +30 -30
- package/dist/lib/forms/fields.client.js +20 -20
- package/dist/lib/forms/fields.server.js +1 -1
- package/dist/lib/forms/form-metadata.js +320 -320
- package/dist/lib/forms/index.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/lib/email/email.js
CHANGED
|
@@ -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
|
package/dist/lib/email/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './email.js';
|
|
1
|
+
export * from './email.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as dotenv from "dotenv";
|
|
2
|
-
dotenv.config();
|
|
3
|
-
export const ENV = process.env;
|
|
1
|
+
import * as dotenv from "dotenv";
|
|
2
|
+
dotenv.config();
|
|
3
|
+
export const ENV = process.env;
|
|
4
4
|
//# sourceMappingURL=env.js.map
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { BLOCK_TYPES, IFormField, IFormFieldPrefiller, IFormFieldValidator, IFormPhantomField, IFormSigningParty } from './form-metadata.js';
|
|
3
|
-
type EnumValue = string | number;
|
|
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
|
-
}
|
|
30
|
-
export {};
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
import { BLOCK_TYPES, IFormField, IFormFieldPrefiller, IFormFieldValidator, IFormPhantomField, IFormSigningParty } from './form-metadata.js';
|
|
3
|
+
type EnumValue = string | number;
|
|
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
|
+
}
|
|
30
|
+
export {};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
export const getSchemaClientType = (s) => {
|
|
3
|
-
const infer = s.type;
|
|
4
|
-
const desc = s.description;
|
|
5
|
-
if (infer === 'date' || desc === 'date')
|
|
6
|
-
return 'date';
|
|
7
|
-
if (infer === 'number' || desc === 'number')
|
|
8
|
-
return 'number';
|
|
9
|
-
if (infer === 'enum' || desc === 'dropdown')
|
|
10
|
-
return 'dropdown';
|
|
11
|
-
if (infer === 'boolean' || desc === 'checkbox')
|
|
12
|
-
return 'checkbox';
|
|
13
|
-
if (s instanceof z.ZodArray && desc === 'multiselect')
|
|
14
|
-
return 'multiselect';
|
|
15
|
-
if (desc === 'textarea')
|
|
16
|
-
return 'textarea';
|
|
17
|
-
if (desc === 'time')
|
|
18
|
-
return 'time';
|
|
19
|
-
return 'text';
|
|
20
|
-
};
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
export const getSchemaClientType = (s) => {
|
|
3
|
+
const infer = s.type;
|
|
4
|
+
const desc = s.description;
|
|
5
|
+
if (infer === 'date' || desc === 'date')
|
|
6
|
+
return 'date';
|
|
7
|
+
if (infer === 'number' || desc === 'number')
|
|
8
|
+
return 'number';
|
|
9
|
+
if (infer === 'enum' || desc === 'dropdown')
|
|
10
|
+
return 'dropdown';
|
|
11
|
+
if (infer === 'boolean' || desc === 'checkbox')
|
|
12
|
+
return 'checkbox';
|
|
13
|
+
if (s instanceof z.ZodArray && desc === 'multiselect')
|
|
14
|
+
return 'multiselect';
|
|
15
|
+
if (desc === 'textarea')
|
|
16
|
+
return 'textarea';
|
|
17
|
+
if (desc === 'time')
|
|
18
|
+
return 'time';
|
|
19
|
+
return 'text';
|
|
20
|
+
};
|
|
21
21
|
//# sourceMappingURL=fields.client.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=fields.server.js.map
|