@betterinternship/core 2.24.0 → 2.26.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/README.md CHANGED
@@ -1,26 +1,26 @@
1
- # Package.Core
2
-
3
- Contains dependencies shared between the different services of the site.
4
-
5
- ## How to update
6
-
7
- 1. Build the package:
8
-
9
- ```bash
10
- npm run build
11
- ```
12
-
13
- 2. Commit the build:
14
-
15
- ```bash
16
- git add .
17
- git commit -m "<follow conventional commits, k thanks>"
18
- git push
19
- ```
20
-
21
- 3. Update the version and publish the package to NPM:
22
-
23
- ```bash
24
- npm version <patch|minor|major>
25
- npm publish
26
- ```
1
+ # Package.Core
2
+
3
+ Contains dependencies shared between the different services of the site.
4
+
5
+ ## How to update
6
+
7
+ 1. Build the package:
8
+
9
+ ```bash
10
+ npm run build
11
+ ```
12
+
13
+ 2. Commit the build:
14
+
15
+ ```bash
16
+ git add .
17
+ git commit -m "<follow conventional commits, k thanks>"
18
+ git push
19
+ ```
20
+
21
+ 3. Update the version and publish the package to NPM:
22
+
23
+ ```bash
24
+ npm version <patch|minor|major>
25
+ npm publish
26
+ ```
@@ -1 +1,2 @@
1
1
  export * from './email.js';
2
+ export * from './shell.js';
@@ -1,2 +1,3 @@
1
1
  export * from './email.js';
2
+ export * from './shell.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface EmailShellOptions {
2
+ logoUrl: string;
3
+ heading: string;
4
+ bodyHtml: string;
5
+ footerHtml?: string;
6
+ }
7
+ export declare const renderEmailShell: ({ logoUrl, heading, bodyHtml, footerHtml, }: EmailShellOptions) => string;
@@ -0,0 +1,30 @@
1
+ const escapeHtml = (value) => value
2
+ .replaceAll('&', '&amp;')
3
+ .replaceAll('<', '&lt;')
4
+ .replaceAll('>', '&gt;')
5
+ .replaceAll('"', '&quot;')
6
+ .replaceAll("'", '&#39;');
7
+ export const renderEmailShell = ({ logoUrl, heading, bodyHtml, footerHtml = 'This is an automated message from BetterInternship.', }) => `<!doctype html>
8
+ <html lang="en">
9
+ <body style="margin:0;background:#ffffff;color:#17213d;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Arial,sans-serif">
10
+ <div style="padding:40px 16px">
11
+ <div style="margin:0 auto 20px;text-align:center">
12
+ <table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:0 auto">
13
+ <tr>
14
+ <td style="vertical-align:middle"><img src="${escapeHtml(logoUrl)}" alt="BetterInternship" width="30" height="30" style="width:30px;height:30px;display:block;object-fit:contain" /></td>
15
+ <td style="padding-left:9px;vertical-align:middle;font-size:19px;font-weight:700;color:#111827">${escapeHtml(heading)}</td>
16
+ </tr>
17
+ </table>
18
+ </div>
19
+
20
+ <div style="width:100%;max-width:520px;margin:0 auto;background:#ffffff;border:1px solid #e4e8f0;border-radius:14px;overflow:hidden">
21
+ <div style="padding:34px 32px 36px">
22
+ ${bodyHtml}
23
+ </div>
24
+
25
+ <div style="padding:16px 32px;background:#fafbfc;border-top:1px solid #edf0f5;color:#8a94a8;font-size:12px;line-height:1.5">${footerHtml}</div>
26
+ </div>
27
+ </div>
28
+ </body>
29
+ </html>`;
30
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../lib/email/shell.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,KAAK;KACF,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAM9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,OAAO,EACP,QAAQ,EACR,UAAU,GAAG,qDAAqD,GAChD,EAAU,EAAE,CAAC;;;;;;;0DAOyB,UAAU,CAAC,OAAO,CAAC;8GACiC,UAAU,CAAC,OAAO,CAAC;;;;;;;EAO/H,QAAQ;;;sIAG4H,UAAU;;;;QAIxI,CAAC"}
@@ -5,14 +5,14 @@ const LONG_TEXT_VALIDATOR = `${TEXT_PREPROCESS}z.string().describe("textarea"))`
5
5
  const NUMBER_VALIDATOR = 'z.number()';
6
6
  const SIGNATURE_VALIDATOR = `${TEXT_PREPROCESS}z.string().nonempty({ message: "This field is required." }))`;
7
7
  const DROPDOWN_VALIDATOR = `z.enum(["Option 1", "Option 2"], {message:"This field is required."})`;
8
- const MULTISELECT_VALIDATOR = `z.array(
9
- z.enum(
10
- [
11
- "Option 1",
12
- "Option 2"
13
- ],
14
- { message: "This field is required." }
15
- )
8
+ const MULTISELECT_VALIDATOR = `z.array(
9
+ z.enum(
10
+ [
11
+ "Option 1",
12
+ "Option 2"
13
+ ],
14
+ { message: "This field is required." }
15
+ )
16
16
  ).describe("multiselect")`;
17
17
  const DATE_VALIDATOR = 'z.coerce.date()';
18
18
  const TIME_VALIDATOR = 'z.string().describe("time")';
@@ -1,141 +1,141 @@
1
- import { ZodType } from 'zod';
2
- import { ClientBlock, ClientField, ClientPhantomField } from './fields.client.js';
3
- import { ServerField } from './fields.server.js';
4
- import { FontName } from './constants/fonts.js';
5
- import type { ValidatorIRv0 } from './validator-ir.js';
6
- export type FormValues = Record<string, string>;
7
- export type FormErrors = Record<string, string>;
8
- export declare const SCHEMA_VERSION = 1;
9
- export declare const FIELD_TYPES: string[];
10
- export declare const BLOCK_TYPES: string[];
11
- export declare const ALIGN_H: string[];
12
- export declare const ALIGN_V: string[];
13
- export declare const SOURCES: string[];
14
- export type { ValidatorIRv0, ValidatorBaseType } from './validator-ir.js';
15
- export interface IFormMetadata {
16
- name: string;
17
- label: string;
18
- schema_version: number;
19
- schema: IForm;
20
- signing_parties: IFormSigningParty[];
21
- subscribers?: IFormSubscriber[];
22
- }
23
- export type IFormSubscriber = {
24
- email: string;
25
- };
26
- export interface IFormSignatory {
27
- name?: string;
28
- email: string;
29
- title?: string;
30
- honorific?: string;
31
- }
32
- export interface IFormSigningParty {
33
- _id: string;
34
- order: number;
35
- signatory_title: string;
36
- signatory_account?: IFormSignatory;
37
- signatory_source?: {
38
- _id: string;
39
- label: string;
40
- tooltip_label: string;
41
- };
42
- signed?: boolean;
43
- signed_ip_address?: string;
44
- }
45
- export interface IFormSignee {
46
- name: string;
47
- sourceEmail: string;
48
- title?: string;
49
- honorific?: string;
50
- signedDate?: number;
51
- }
52
- export interface IForm {
53
- blocks: IFormBlock[];
54
- }
55
- export interface IFormBlock {
56
- _id: string;
57
- block_type: (typeof BLOCK_TYPES)[number];
58
- order: number;
59
- signing_party_id: IFormSigningParty['_id'];
60
- text_content?: string;
61
- field_schema?: IFormField;
62
- phantom_field_schema?: IFormPhantomField;
63
- }
64
- export interface IFormField {
65
- field: string;
66
- type: 'text' | 'signature' | 'image';
67
- x: number;
68
- y: number;
69
- w: number;
70
- h: number;
71
- page: number;
72
- align_h?: (typeof ALIGN_H)[number];
73
- align_v?: (typeof ALIGN_V)[number];
74
- label: string;
75
- tooltip_label: string;
76
- shared: boolean;
77
- source: (typeof SOURCES)[number];
78
- prefiller?: string;
79
- validator?: string;
80
- validator_ir?: ValidatorIRv0 | null;
81
- size?: number;
82
- wrap?: boolean;
83
- font?: FontName;
84
- radio_group_id?: string;
85
- radio_option_label?: string;
86
- }
87
- export interface IFormPhantomField {
88
- field: string;
89
- type: 'text' | 'signature' | 'image';
90
- label: string;
91
- tooltip_label: string;
92
- shared: boolean;
93
- source: (typeof SOURCES)[number];
94
- prefiller?: string;
95
- validator?: string;
96
- validator_ir?: ValidatorIRv0 | null;
97
- radio_group_id?: string;
98
- radio_option_label?: string;
99
- }
100
- export interface IFormParameters {
101
- [key: string]: string | ZodType;
102
- }
103
- export type IFormSourceDomains<SourceDomains extends any[]> = Record<string, SourceDomains[number]>;
104
- export type IFormFieldValidator = ZodType;
105
- export type IFormFieldPrefiller<SourceDomains extends any[]> = (sourceDomains: IFormSourceDomains<SourceDomains>) => string;
106
- export declare class FormMetadata<SourceDomains extends any[]> {
107
- private readonly formMetadata;
108
- private readonly blocks;
109
- constructor(formMetadata: IFormMetadata);
110
- getBlocksForClientService(signingPartyId?: string): ClientBlock<SourceDomains>[];
111
- getSigningPartyFieldName(signingPartyId: string): string;
112
- getSigningPartyTitleFromFieldName(signingPartyFieldName: string): string | undefined;
113
- getSigningPartyBlocks(sourceSigningPartyId: string): ClientBlock<SourceDomains>[];
114
- getSigningPartyFields(signingPartyId: string): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
115
- static getSigningPartyValues(signingParties: IFormSigningParty[], values: FormValues): Record<string, IFormSignatory>;
116
- private getFields;
117
- private getField;
118
- private getPhantomFields;
119
- private getPhantomField;
120
- encodeAsJSON(): string;
121
- static decodeFromJSON<SourceDomains extends any[]>(json: string): FormMetadata<SourceDomains>;
122
- getLabel(): string;
123
- private getFieldForClientService;
124
- getFieldsForClientService(signingPartyId?: string, sourceDomains?: IFormSourceDomains<SourceDomains>, derivationBase?: IFormParameters): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
125
- getSignatureFieldsForClientService(signingPartyId: string): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
126
- getSignatureValueForSigningParty(values: FormValues, signingPartyId: string): string;
127
- setSignatureValueForSigningParty(values: FormValues, signatureString: string, signingPartyId: string): FormValues;
128
- getFieldsForEditorService(): IFormField[];
129
- getPhantomFieldsForEditorService(): IFormPhantomField[];
130
- getBlocksForEditorService(): IFormBlock[];
131
- getFieldsForSigningService(): ServerField[];
132
- inferParams(): string[];
133
- private parseValidator;
134
- private parsePrefiller;
135
- private enumerateParams;
136
- private populateParams;
137
- getSchemaVersion(): number;
138
- getSubscribers(): IFormSubscriber[];
139
- getSigningParties(): IFormSigningParty[];
140
- mayInvolveEsign(): boolean;
141
- }
1
+ import { ZodType } from 'zod';
2
+ import { ClientBlock, ClientField, ClientPhantomField } from './fields.client.js';
3
+ import { ServerField } from './fields.server.js';
4
+ import { FontName } from './constants/fonts.js';
5
+ import type { ValidatorIRv0 } from './validator-ir.js';
6
+ export type FormValues = Record<string, string>;
7
+ export type FormErrors = Record<string, string>;
8
+ export declare const SCHEMA_VERSION = 1;
9
+ export declare const FIELD_TYPES: string[];
10
+ export declare const BLOCK_TYPES: string[];
11
+ export declare const ALIGN_H: string[];
12
+ export declare const ALIGN_V: string[];
13
+ export declare const SOURCES: string[];
14
+ export type { ValidatorIRv0, ValidatorBaseType } from './validator-ir.js';
15
+ export interface IFormMetadata {
16
+ name: string;
17
+ label: string;
18
+ schema_version: number;
19
+ schema: IForm;
20
+ signing_parties: IFormSigningParty[];
21
+ subscribers?: IFormSubscriber[];
22
+ }
23
+ export type IFormSubscriber = {
24
+ email: string;
25
+ };
26
+ export interface IFormSignatory {
27
+ name?: string;
28
+ email: string;
29
+ title?: string;
30
+ honorific?: string;
31
+ }
32
+ export interface IFormSigningParty {
33
+ _id: string;
34
+ order: number;
35
+ signatory_title: string;
36
+ signatory_account?: IFormSignatory;
37
+ signatory_source?: {
38
+ _id: string;
39
+ label: string;
40
+ tooltip_label: string;
41
+ };
42
+ signed?: boolean;
43
+ signed_ip_address?: string;
44
+ }
45
+ export interface IFormSignee {
46
+ name: string;
47
+ sourceEmail: string;
48
+ title?: string;
49
+ honorific?: string;
50
+ signedDate?: number;
51
+ }
52
+ export interface IForm {
53
+ blocks: IFormBlock[];
54
+ }
55
+ export interface IFormBlock {
56
+ _id: string;
57
+ block_type: (typeof BLOCK_TYPES)[number];
58
+ order: number;
59
+ signing_party_id: IFormSigningParty['_id'];
60
+ text_content?: string;
61
+ field_schema?: IFormField;
62
+ phantom_field_schema?: IFormPhantomField;
63
+ }
64
+ export interface IFormField {
65
+ field: string;
66
+ type: 'text' | 'signature' | 'image';
67
+ x: number;
68
+ y: number;
69
+ w: number;
70
+ h: number;
71
+ page: number;
72
+ align_h?: (typeof ALIGN_H)[number];
73
+ align_v?: (typeof ALIGN_V)[number];
74
+ label: string;
75
+ tooltip_label: string;
76
+ shared: boolean;
77
+ source: (typeof SOURCES)[number];
78
+ prefiller?: string;
79
+ validator?: string;
80
+ validator_ir?: ValidatorIRv0 | null;
81
+ size?: number;
82
+ wrap?: boolean;
83
+ font?: FontName;
84
+ radio_group_id?: string;
85
+ radio_option_label?: string;
86
+ }
87
+ export interface IFormPhantomField {
88
+ field: string;
89
+ type: 'text' | 'signature' | 'image';
90
+ label: string;
91
+ tooltip_label: string;
92
+ shared: boolean;
93
+ source: (typeof SOURCES)[number];
94
+ prefiller?: string;
95
+ validator?: string;
96
+ validator_ir?: ValidatorIRv0 | null;
97
+ radio_group_id?: string;
98
+ radio_option_label?: string;
99
+ }
100
+ export interface IFormParameters {
101
+ [key: string]: string | ZodType;
102
+ }
103
+ export type IFormSourceDomains<SourceDomains extends any[]> = Record<string, SourceDomains[number]>;
104
+ export type IFormFieldValidator = ZodType;
105
+ export type IFormFieldPrefiller<SourceDomains extends any[]> = (sourceDomains: IFormSourceDomains<SourceDomains>) => string;
106
+ export declare class FormMetadata<SourceDomains extends any[]> {
107
+ private readonly formMetadata;
108
+ private readonly blocks;
109
+ constructor(formMetadata: IFormMetadata);
110
+ getBlocksForClientService(signingPartyId?: string): ClientBlock<SourceDomains>[];
111
+ getSigningPartyFieldName(signingPartyId: string): string;
112
+ getSigningPartyTitleFromFieldName(signingPartyFieldName: string): string | undefined;
113
+ getSigningPartyBlocks(sourceSigningPartyId: string): ClientBlock<SourceDomains>[];
114
+ getSigningPartyFields(signingPartyId: string): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
115
+ static getSigningPartyValues(signingParties: IFormSigningParty[], values: FormValues): Record<string, IFormSignatory>;
116
+ private getFields;
117
+ private getField;
118
+ private getPhantomFields;
119
+ private getPhantomField;
120
+ encodeAsJSON(): string;
121
+ static decodeFromJSON<SourceDomains extends any[]>(json: string): FormMetadata<SourceDomains>;
122
+ getLabel(): string;
123
+ private getFieldForClientService;
124
+ getFieldsForClientService(signingPartyId?: string, sourceDomains?: IFormSourceDomains<SourceDomains>, derivationBase?: IFormParameters): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
125
+ getSignatureFieldsForClientService(signingPartyId: string): (ClientField<SourceDomains> | ClientPhantomField<SourceDomains>)[];
126
+ getSignatureValueForSigningParty(values: FormValues, signingPartyId: string): string;
127
+ setSignatureValueForSigningParty(values: FormValues, signatureString: string, signingPartyId: string): FormValues;
128
+ getFieldsForEditorService(): IFormField[];
129
+ getPhantomFieldsForEditorService(): IFormPhantomField[];
130
+ getBlocksForEditorService(): IFormBlock[];
131
+ getFieldsForSigningService(): ServerField[];
132
+ inferParams(): string[];
133
+ private parseValidator;
134
+ private parsePrefiller;
135
+ private enumerateParams;
136
+ private populateParams;
137
+ getSchemaVersion(): number;
138
+ getSubscribers(): IFormSubscriber[];
139
+ getSigningParties(): IFormSigningParty[];
140
+ mayInvolveEsign(): boolean;
141
+ }
@@ -1,5 +1,5 @@
1
- import { type IFormBlock, type IFormSigningParty } from "@betterinternship/core/forms";
2
- export type PreviewFieldType = "text" | "signature" | "image";
1
+ import { type IFormBlock, type IFormSigningParty } from '@betterinternship/core/forms';
2
+ export type PreviewFieldType = 'text' | 'signature' | 'image';
3
3
  type ValidatorRuleLike = {
4
4
  kind?: string;
5
5
  };
@@ -17,8 +17,8 @@ export interface PreviewField {
17
17
  h: number;
18
18
  size?: number;
19
19
  wrap?: boolean;
20
- align_h?: "left" | "center" | "right";
21
- align_v?: "top" | "middle" | "bottom";
20
+ align_h?: 'left' | 'center' | 'right';
21
+ align_v?: 'top' | 'middle' | 'bottom';
22
22
  font?: string;
23
23
  type?: PreviewFieldType;
24
24
  signing_party_id?: string;
@@ -29,7 +29,7 @@ export interface PreviewField {
29
29
  }
30
30
  export interface OwnerMeta {
31
31
  ownerRoleId: string;
32
- ownerGroupId: "company" | "university" | "student" | "witness" | "other";
32
+ ownerGroupId: 'company' | 'university' | 'student' | 'witness' | 'other';
33
33
  ownerLabel: string;
34
34
  ownerColorHex: string;
35
35
  isMine: boolean;
@@ -41,7 +41,7 @@ export declare function groupFieldsByPage(fields: PreviewField[]): Map<number, P
41
41
  export declare const normalizePreviewFieldKey: (fieldKey: string) => string;
42
42
  export declare const resolveAutoPreviewValue: (fieldKey: string, now?: Date) => string;
43
43
  export declare const DEFAULT_PREVIEW_DUMMY_STUDENT_USER: Record<string, string>;
44
- type PreviewPrefillMode = "live" | "dummy" | "none";
44
+ type PreviewPrefillMode = 'live' | 'dummy' | 'none';
45
45
  export declare const createPreviewDisplayValueResolver: ({ user, prefillMode, nowFactory, }: {
46
46
  user?: Record<string, unknown> | null;
47
47
  prefillMode?: PreviewPrefillMode;