@betterinternship/core 1.3.4 → 1.4.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.
- package/dist/index.d.ts +5 -5
- package/dist/lib/email/email.d.ts +6 -6
- package/dist/lib/email/email.js +39 -39
- package/dist/lib/forms/fields.client.d.ts +14 -14
- package/dist/lib/forms/fields.client.js +24 -24
- package/dist/lib/forms/form-metadata.d.ts +57 -47
- package/dist/lib/forms/form-metadata.js +194 -72
- package/dist/lib/forms/form-metadata.js.map +1 -1
- package/dist/lib/forms/index.d.ts +2 -2
- package/dist/lib/forms/index.js +18 -18
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './lib/chat';
|
|
2
|
-
export * from './lib/env';
|
|
3
|
-
export * from './lib/notice';
|
|
4
|
-
export * from './lib/email';
|
|
5
|
-
export * from './lib/forms';
|
|
1
|
+
export * from './lib/chat';
|
|
2
|
+
export * from './lib/env';
|
|
3
|
+
export * from './lib/notice';
|
|
4
|
+
export * from './lib/email';
|
|
5
|
+
export * from './lib/forms';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const sendSingleEmail: ({ sender, subject, recipient, content, }: {
|
|
2
|
-
sender?: string;
|
|
3
|
-
subject: string;
|
|
4
|
-
recipient: string;
|
|
5
|
-
content: string;
|
|
6
|
-
}) => void;
|
|
1
|
+
export declare const sendSingleEmail: ({ sender, subject, recipient, content, }: {
|
|
2
|
+
sender?: string;
|
|
3
|
+
subject: string;
|
|
4
|
+
recipient: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}) => void;
|
package/dist/lib/email/email.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendSingleEmail = void 0;
|
|
4
|
-
const nodemailer = require("nodemailer");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
const env_1 = require("../env");
|
|
7
|
-
const SMTP_EMAIL = env_1.ENV.SMTP_EMAIL;
|
|
8
|
-
const SMTP_PASSWORD = env_1.ENV.SMTP_PASSWORD;
|
|
9
|
-
if (!SMTP_EMAIL || !SMTP_PASSWORD)
|
|
10
|
-
throw Error('[ERROR:ENV]: Missing SMTP setup.');
|
|
11
|
-
const transporter = nodemailer.createTransport({
|
|
12
|
-
service: 'Gmail',
|
|
13
|
-
host: 'smtp.gmail.com',
|
|
14
|
-
port: 465,
|
|
15
|
-
secure: true,
|
|
16
|
-
auth: {
|
|
17
|
-
user: SMTP_EMAIL,
|
|
18
|
-
pass: SMTP_PASSWORD,
|
|
19
|
-
},
|
|
20
|
-
messageId: `${(0, uuid_1.v4)()}${SMTP_EMAIL}`,
|
|
21
|
-
});
|
|
22
|
-
const sendSingleEmail = ({ sender, subject, recipient, content, }) => {
|
|
23
|
-
transporter.sendMail({
|
|
24
|
-
from: `"${sender ?? 'BetterInternship'}" <${SMTP_EMAIL}>`,
|
|
25
|
-
to: recipient,
|
|
26
|
-
subject,
|
|
27
|
-
html: content,
|
|
28
|
-
}, (error, info) => {
|
|
29
|
-
if (error) {
|
|
30
|
-
console.error('[ERROR] Could not send email.');
|
|
31
|
-
console.error('[-----] ' + error.message);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
console.warn('[LOG] Email sent to ' + recipient);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return;
|
|
38
|
-
};
|
|
39
|
-
exports.sendSingleEmail = sendSingleEmail;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendSingleEmail = void 0;
|
|
4
|
+
const nodemailer = require("nodemailer");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const env_1 = require("../env");
|
|
7
|
+
const SMTP_EMAIL = env_1.ENV.SMTP_EMAIL;
|
|
8
|
+
const SMTP_PASSWORD = env_1.ENV.SMTP_PASSWORD;
|
|
9
|
+
if (!SMTP_EMAIL || !SMTP_PASSWORD)
|
|
10
|
+
throw Error('[ERROR:ENV]: Missing SMTP setup.');
|
|
11
|
+
const transporter = nodemailer.createTransport({
|
|
12
|
+
service: 'Gmail',
|
|
13
|
+
host: 'smtp.gmail.com',
|
|
14
|
+
port: 465,
|
|
15
|
+
secure: true,
|
|
16
|
+
auth: {
|
|
17
|
+
user: SMTP_EMAIL,
|
|
18
|
+
pass: SMTP_PASSWORD,
|
|
19
|
+
},
|
|
20
|
+
messageId: `${(0, uuid_1.v4)()}${SMTP_EMAIL}`,
|
|
21
|
+
});
|
|
22
|
+
const sendSingleEmail = ({ sender, subject, recipient, content, }) => {
|
|
23
|
+
transporter.sendMail({
|
|
24
|
+
from: `"${sender ?? 'BetterInternship'}" <${SMTP_EMAIL}>`,
|
|
25
|
+
to: recipient,
|
|
26
|
+
subject,
|
|
27
|
+
html: content,
|
|
28
|
+
}, (error, info) => {
|
|
29
|
+
if (error) {
|
|
30
|
+
console.error('[ERROR] Could not send email.');
|
|
31
|
+
console.error('[-----] ' + error.message);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.warn('[LOG] Email sent to ' + recipient);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
};
|
|
39
|
+
exports.sendSingleEmail = sendSingleEmail;
|
|
40
40
|
//# sourceMappingURL=email.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { IFormField, IFormFieldPrefiller, IFormFieldValidator } from './form-metadata';
|
|
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 ClientFieldSection = 'student' | 'internship' | 'entity' | 'university' | 'report' | 'feedback';
|
|
7
|
-
export type ClientField<SourceDomains extends any[]> = Omit<IFormField, 'x' | 'y' | 'w' | 'h' | 'page' | 'type' | 'validator' | 'prefiller' | 'align_h' | 'align_v'> & {
|
|
8
|
-
type: ClientFieldType;
|
|
9
|
-
validator: IFormFieldValidator | null;
|
|
10
|
-
prefiller: IFormFieldPrefiller<SourceDomains> | null;
|
|
11
|
-
section: ClientFieldSection;
|
|
12
|
-
options?: EnumValue[];
|
|
13
|
-
coerce: (s: string) => string | number | boolean | Date | Array<string>;
|
|
14
|
-
};
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
import { IFormField, IFormFieldPrefiller, IFormFieldValidator } from './form-metadata';
|
|
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 ClientFieldSection = 'student' | 'internship' | 'entity' | 'university' | 'report' | 'feedback';
|
|
7
|
+
export type ClientField<SourceDomains extends any[]> = Omit<IFormField, 'x' | 'y' | 'w' | 'h' | 'page' | 'type' | 'validator' | 'prefiller' | 'align_h' | 'align_v'> & {
|
|
8
|
+
type: ClientFieldType;
|
|
9
|
+
validator: IFormFieldValidator | null;
|
|
10
|
+
prefiller: IFormFieldPrefiller<SourceDomains> | null;
|
|
11
|
+
section: ClientFieldSection;
|
|
12
|
+
options?: EnumValue[];
|
|
13
|
+
coerce: (s: string) => string | number | boolean | Date | Array<string>;
|
|
14
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSchemaClientType = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const getSchemaClientType = (s) => {
|
|
6
|
-
const infer = s.type;
|
|
7
|
-
const desc = s.description;
|
|
8
|
-
if (infer === 'date' || desc === 'date')
|
|
9
|
-
return 'date';
|
|
10
|
-
if (infer === 'number' || desc === 'number')
|
|
11
|
-
return 'number';
|
|
12
|
-
if (infer === 'enum' || desc === 'dropdown')
|
|
13
|
-
return 'dropdown';
|
|
14
|
-
if (infer === 'boolean' || desc === 'checkbox')
|
|
15
|
-
return 'checkbox';
|
|
16
|
-
if (s instanceof zod_1.default.ZodArray && desc === 'multiselect')
|
|
17
|
-
return 'multiselect';
|
|
18
|
-
if (desc === 'textarea')
|
|
19
|
-
return 'textarea';
|
|
20
|
-
if (desc === 'time')
|
|
21
|
-
return 'time';
|
|
22
|
-
return 'text';
|
|
23
|
-
};
|
|
24
|
-
exports.getSchemaClientType = getSchemaClientType;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSchemaClientType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const getSchemaClientType = (s) => {
|
|
6
|
+
const infer = s.type;
|
|
7
|
+
const desc = s.description;
|
|
8
|
+
if (infer === 'date' || desc === 'date')
|
|
9
|
+
return 'date';
|
|
10
|
+
if (infer === 'number' || desc === 'number')
|
|
11
|
+
return 'number';
|
|
12
|
+
if (infer === 'enum' || desc === 'dropdown')
|
|
13
|
+
return 'dropdown';
|
|
14
|
+
if (infer === 'boolean' || desc === 'checkbox')
|
|
15
|
+
return 'checkbox';
|
|
16
|
+
if (s instanceof zod_1.default.ZodArray && desc === 'multiselect')
|
|
17
|
+
return 'multiselect';
|
|
18
|
+
if (desc === 'textarea')
|
|
19
|
+
return 'textarea';
|
|
20
|
+
if (desc === 'time')
|
|
21
|
+
return 'time';
|
|
22
|
+
return 'text';
|
|
23
|
+
};
|
|
24
|
+
exports.getSchemaClientType = getSchemaClientType;
|
|
25
25
|
//# sourceMappingURL=fields.client.js.map
|
|
@@ -1,93 +1,103 @@
|
|
|
1
1
|
import { ZodType } from 'zod';
|
|
2
2
|
import { ClientField } from './fields.client';
|
|
3
3
|
import { ServerField } from './fields.server';
|
|
4
|
-
export declare const SCHEMA_VERSION =
|
|
5
|
-
export declare const PARTIES: string[];
|
|
4
|
+
export declare const SCHEMA_VERSION = 1;
|
|
6
5
|
export declare const SOURCES: string[];
|
|
7
6
|
export declare const FIELD_TYPES: string[];
|
|
7
|
+
export declare const BLOCK_TYPES: string[];
|
|
8
|
+
export declare const ALIGN_H: string[];
|
|
9
|
+
export declare const ALIGN_V: string[];
|
|
10
|
+
export declare const FORM_SOURCE: string[];
|
|
8
11
|
export interface IFormMetadata {
|
|
9
12
|
name: string;
|
|
10
13
|
label: string;
|
|
11
14
|
schema_version: number;
|
|
12
|
-
schema:
|
|
13
|
-
|
|
15
|
+
schema: IForm;
|
|
16
|
+
parties: IFormSigningParty[];
|
|
14
17
|
subscribers: IFormSubscriber[];
|
|
15
|
-
signatories: IFormSignatory[];
|
|
16
|
-
required_parties: IFormPendingParties[];
|
|
17
|
-
params?: IFormParams;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
interface IFormContact {
|
|
19
|
+
export interface IUserAccount {
|
|
20
|
+
account_id: string;
|
|
23
21
|
name: string;
|
|
24
|
-
honorific: string;
|
|
25
|
-
title: string;
|
|
26
22
|
email: string;
|
|
27
23
|
}
|
|
28
|
-
export type IFormSubscriber =
|
|
29
|
-
export interface IFormSignatory extends
|
|
30
|
-
|
|
24
|
+
export type IFormSubscriber = IFormSignatory;
|
|
25
|
+
export interface IFormSignatory extends IUserAccount {
|
|
26
|
+
title?: string;
|
|
27
|
+
honorific?: string;
|
|
31
28
|
}
|
|
32
|
-
export
|
|
33
|
-
|
|
29
|
+
export interface IFormSigningParty {
|
|
30
|
+
_id: string;
|
|
34
31
|
order: number;
|
|
35
|
-
|
|
32
|
+
signatory_account?: IFormSignatory;
|
|
33
|
+
signatory_source?: string;
|
|
34
|
+
signed?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface IForm {
|
|
37
|
+
blocks: IFormBlock[];
|
|
38
|
+
}
|
|
39
|
+
export interface IFormBlock {
|
|
40
|
+
block_type: (typeof BLOCK_TYPES)[number];
|
|
41
|
+
order: number;
|
|
42
|
+
content: string | IFormField | IFormPhantomField;
|
|
43
|
+
party_id: IFormSigningParty['_id'];
|
|
44
|
+
}
|
|
36
45
|
export interface IFormField {
|
|
37
46
|
field: string;
|
|
38
|
-
type: 'text' | 'signature';
|
|
47
|
+
type: 'text' | 'signature' | 'image';
|
|
39
48
|
x: number;
|
|
40
49
|
y: number;
|
|
41
50
|
w: number;
|
|
42
51
|
h: number;
|
|
43
52
|
page: number;
|
|
44
|
-
align_h?:
|
|
45
|
-
align_v?:
|
|
53
|
+
align_h?: (typeof ALIGN_H)[number];
|
|
54
|
+
align_v?: (typeof ALIGN_V)[number];
|
|
46
55
|
label: string;
|
|
47
|
-
source: 'auto' | 'prefill' | 'derived' | 'manual';
|
|
48
|
-
party: 'university' | 'entity' | 'student' | 'student-guardian';
|
|
49
|
-
shared: boolean;
|
|
50
|
-
descriptor?: boolean;
|
|
51
56
|
tooltip_label: string;
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
shared: boolean;
|
|
58
|
+
source: (typeof FORM_SOURCE)[number];
|
|
59
|
+
default_value?: string | IFormParameter;
|
|
60
|
+
validator?: string | IFormParameter;
|
|
54
61
|
}
|
|
55
62
|
export interface IFormPhantomField {
|
|
56
63
|
field: string;
|
|
64
|
+
type: 'text' | 'signature' | 'image';
|
|
57
65
|
label: string;
|
|
58
|
-
type: 'email' | 'param';
|
|
59
|
-
source: 'auto' | 'prefill' | 'derived' | 'manual';
|
|
60
|
-
party: 'university' | 'entity' | 'student' | 'student-guardian';
|
|
61
|
-
shared: boolean;
|
|
62
|
-
descriptor?: boolean;
|
|
63
66
|
tooltip_label: string;
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
shared: boolean;
|
|
68
|
+
source: (typeof FORM_SOURCE)[number];
|
|
69
|
+
default_value?: string | IFormParameter;
|
|
70
|
+
validator?: string | IFormParameter;
|
|
71
|
+
}
|
|
72
|
+
export interface IFormParameter {
|
|
73
|
+
[key: string]: string | ZodType;
|
|
66
74
|
}
|
|
67
75
|
export type IFormSourceDomains<SourceDomains extends any[]> = Record<string, SourceDomains[number]>;
|
|
68
76
|
export type IFormFieldValidator = ZodType;
|
|
69
77
|
export type IFormFieldPrefiller<SourceDomains extends any[]> = (sourceDomains: IFormSourceDomains<SourceDomains>) => string;
|
|
70
78
|
export declare class FormMetadata<SourceDomains extends any[]> {
|
|
71
79
|
private readonly formMetadata;
|
|
72
|
-
private readonly
|
|
80
|
+
private readonly blocks;
|
|
73
81
|
constructor(formMetadata: IFormMetadata);
|
|
82
|
+
getAllBlocks(): IFormBlock[];
|
|
83
|
+
getBlocksByType<T extends (typeof BLOCK_TYPES)[number]>(blockType: T): IFormBlock[];
|
|
84
|
+
getBlocksByPartyId(partyId: string): IFormBlock[];
|
|
85
|
+
getFields(): IFormField[];
|
|
86
|
+
getField(index: number): IFormField | undefined;
|
|
87
|
+
getPhantomFields(): IFormPhantomField[];
|
|
74
88
|
encodeAsJSON(): string;
|
|
75
89
|
static decodeFromJSON<SourceDomains extends any[]>(json: string): FormMetadata<SourceDomains>;
|
|
76
90
|
getLabel(): string;
|
|
77
|
-
getFieldForClient(index: number, sourceDomains?: IFormSourceDomains<SourceDomains>, derivationBase?:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
getPhantomFields(): IFormPhantomField[];
|
|
91
|
+
getFieldForClient(index: number, sourceDomains?: IFormSourceDomains<SourceDomains>, derivationBase?: IFormParameter): ClientField<SourceDomains>;
|
|
92
|
+
getFieldsForClientService(sourceDomains?: IFormSourceDomains<SourceDomains>, derivationBase?: IFormParameter): ClientField<SourceDomains>[];
|
|
93
|
+
getFieldsForSigningService(): ServerField[];
|
|
81
94
|
inferParams(): string[];
|
|
82
|
-
getParams(): IFormParams;
|
|
83
|
-
getDescriptors(): IFormField[];
|
|
84
|
-
getSignatoryAsValues(): Record<string, string>;
|
|
85
95
|
private parseValidator;
|
|
86
96
|
private parsePrefiller;
|
|
87
97
|
private enumerateParams;
|
|
88
98
|
private populateParams;
|
|
89
|
-
getSignatories():
|
|
90
|
-
getSubscribers():
|
|
91
|
-
getRequiredParties():
|
|
99
|
+
getSignatories(): IFormSignatory[];
|
|
100
|
+
getSubscribers(): IFormSignatory[];
|
|
101
|
+
getRequiredParties(): IFormSigningParty[];
|
|
92
102
|
}
|
|
93
|
-
export
|
|
103
|
+
export declare const DUMMY_FORM_METADATA: IFormMetadata;
|