@betterinternship/core 1.4.0 → 1.4.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.
|
@@ -1,346 +1,347 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DUMMY_FORM_METADATA = exports.FormMetadata = exports.FORM_SOURCE = exports.ALIGN_V = exports.ALIGN_H = exports.BLOCK_TYPES = exports.FIELD_TYPES = exports.SOURCES = exports.SCHEMA_VERSION = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const fields_client_1 = require("./fields.client");
|
|
6
|
-
exports.SCHEMA_VERSION = 1;
|
|
7
|
-
exports.SOURCES = ['auto', 'prefill', 'derived', 'manual'];
|
|
8
|
-
exports.FIELD_TYPES = ['text', 'signature'];
|
|
9
|
-
exports.BLOCK_TYPES = [
|
|
10
|
-
'header',
|
|
11
|
-
'paragraph',
|
|
12
|
-
'form_field',
|
|
13
|
-
'form_phantom_field',
|
|
14
|
-
'divider',
|
|
15
|
-
'image',
|
|
16
|
-
];
|
|
17
|
-
exports.ALIGN_H = ['left', 'center', 'right'];
|
|
18
|
-
exports.ALIGN_V = ['top', 'middle', 'bottom'];
|
|
19
|
-
exports.FORM_SOURCE = ['auto', 'prefill', 'derived', 'manual'];
|
|
20
|
-
class FormMetadata {
|
|
21
|
-
formMetadata;
|
|
22
|
-
blocks;
|
|
23
|
-
constructor(formMetadata) {
|
|
24
|
-
this.formMetadata = formMetadata;
|
|
25
|
-
this.blocks = formMetadata.schema.blocks;
|
|
26
|
-
}
|
|
27
|
-
getAllBlocks() {
|
|
28
|
-
return this.blocks;
|
|
29
|
-
}
|
|
30
|
-
getBlocksByType(blockType) {
|
|
31
|
-
return this.blocks.filter((block) => block.block_type === blockType);
|
|
32
|
-
}
|
|
33
|
-
getBlocksByPartyId(partyId) {
|
|
34
|
-
return this.blocks.filter((block) => block.party_id === partyId);
|
|
35
|
-
}
|
|
36
|
-
getFields() {
|
|
37
|
-
return this.blocks
|
|
38
|
-
.filter((block) => block.block_type === 'form_field')
|
|
39
|
-
.map((block) => block.content);
|
|
40
|
-
}
|
|
41
|
-
getField(index) {
|
|
42
|
-
const fields = this.getFields();
|
|
43
|
-
return fields[index];
|
|
44
|
-
}
|
|
45
|
-
getPhantomFields() {
|
|
46
|
-
return this.blocks
|
|
47
|
-
.filter((block) => block.block_type === 'form_phantom_field')
|
|
48
|
-
.map((block) => block.content);
|
|
49
|
-
}
|
|
50
|
-
encodeAsJSON() {
|
|
51
|
-
return JSON.stringify(this.formMetadata);
|
|
52
|
-
}
|
|
53
|
-
static decodeFromJSON(json) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
...
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.
|
|
128
|
-
field
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
.replaceAll('
|
|
192
|
-
.replaceAll('
|
|
193
|
-
.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
exports.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DUMMY_FORM_METADATA = exports.FormMetadata = exports.FORM_SOURCE = exports.ALIGN_V = exports.ALIGN_H = exports.BLOCK_TYPES = exports.FIELD_TYPES = exports.SOURCES = exports.SCHEMA_VERSION = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const fields_client_1 = require("./fields.client");
|
|
6
|
+
exports.SCHEMA_VERSION = 1;
|
|
7
|
+
exports.SOURCES = ['auto', 'prefill', 'derived', 'manual'];
|
|
8
|
+
exports.FIELD_TYPES = ['text', 'signature'];
|
|
9
|
+
exports.BLOCK_TYPES = [
|
|
10
|
+
'header',
|
|
11
|
+
'paragraph',
|
|
12
|
+
'form_field',
|
|
13
|
+
'form_phantom_field',
|
|
14
|
+
'divider',
|
|
15
|
+
'image',
|
|
16
|
+
];
|
|
17
|
+
exports.ALIGN_H = ['left', 'center', 'right'];
|
|
18
|
+
exports.ALIGN_V = ['top', 'middle', 'bottom'];
|
|
19
|
+
exports.FORM_SOURCE = ['auto', 'prefill', 'derived', 'manual'];
|
|
20
|
+
class FormMetadata {
|
|
21
|
+
formMetadata;
|
|
22
|
+
blocks;
|
|
23
|
+
constructor(formMetadata) {
|
|
24
|
+
this.formMetadata = formMetadata;
|
|
25
|
+
this.blocks = formMetadata.schema.blocks;
|
|
26
|
+
}
|
|
27
|
+
getAllBlocks() {
|
|
28
|
+
return this.blocks;
|
|
29
|
+
}
|
|
30
|
+
getBlocksByType(blockType) {
|
|
31
|
+
return this.blocks.filter((block) => block.block_type === blockType);
|
|
32
|
+
}
|
|
33
|
+
getBlocksByPartyId(partyId) {
|
|
34
|
+
return this.blocks.filter((block) => block.party_id === partyId);
|
|
35
|
+
}
|
|
36
|
+
getFields() {
|
|
37
|
+
return this.blocks
|
|
38
|
+
.filter((block) => block.block_type === 'form_field')
|
|
39
|
+
.map((block) => block.content);
|
|
40
|
+
}
|
|
41
|
+
getField(index) {
|
|
42
|
+
const fields = this.getFields();
|
|
43
|
+
return fields[index];
|
|
44
|
+
}
|
|
45
|
+
getPhantomFields() {
|
|
46
|
+
return this.blocks
|
|
47
|
+
.filter((block) => block.block_type === 'form_phantom_field')
|
|
48
|
+
.map((block) => block.content);
|
|
49
|
+
}
|
|
50
|
+
encodeAsJSON() {
|
|
51
|
+
return JSON.stringify(this.formMetadata);
|
|
52
|
+
}
|
|
53
|
+
static decodeFromJSON(json) {
|
|
54
|
+
const parsed = JSON.parse(json);
|
|
55
|
+
return new FormMetadata(parsed);
|
|
56
|
+
}
|
|
57
|
+
getLabel() {
|
|
58
|
+
return this.formMetadata.label;
|
|
59
|
+
}
|
|
60
|
+
getFieldForClient(index, sourceDomains, derivationBase) {
|
|
61
|
+
const field = this.getField(index);
|
|
62
|
+
if (!field)
|
|
63
|
+
throw new Error('Field does not exist');
|
|
64
|
+
const finalParams = {
|
|
65
|
+
...derivationBase,
|
|
66
|
+
...sourceDomains,
|
|
67
|
+
};
|
|
68
|
+
const validator = this.parseValidator(field.field, finalParams);
|
|
69
|
+
const prefiller = this.parsePrefiller(field.field, finalParams);
|
|
70
|
+
const section = field.field.split('.')[0];
|
|
71
|
+
let options = undefined;
|
|
72
|
+
if (validator?.type === 'enum')
|
|
73
|
+
options = validator.options;
|
|
74
|
+
if (validator?.type === 'array') {
|
|
75
|
+
const element = validator.element;
|
|
76
|
+
if (element?.options)
|
|
77
|
+
options = element.options;
|
|
78
|
+
}
|
|
79
|
+
const type = field.type === 'signature'
|
|
80
|
+
? 'signature'
|
|
81
|
+
: validator
|
|
82
|
+
? (0, fields_client_1.getSchemaClientType)(validator)
|
|
83
|
+
: 'text';
|
|
84
|
+
const coerce = (value) => {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'number': {
|
|
87
|
+
const n = parseInt(value);
|
|
88
|
+
return isNaN(n) ? 0 : n;
|
|
89
|
+
}
|
|
90
|
+
case 'date': {
|
|
91
|
+
const n = parseInt(value);
|
|
92
|
+
return isNaN(n) ? new Date() : new Date(n);
|
|
93
|
+
}
|
|
94
|
+
case 'checkbox': {
|
|
95
|
+
return !!value?.trim();
|
|
96
|
+
}
|
|
97
|
+
case 'multiselect': {
|
|
98
|
+
return value?.split('\n');
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
field: field.field,
|
|
106
|
+
shared: field.shared,
|
|
107
|
+
label: field.label,
|
|
108
|
+
source: field.source,
|
|
109
|
+
tooltip_label: field.tooltip_label,
|
|
110
|
+
coerce,
|
|
111
|
+
type,
|
|
112
|
+
section,
|
|
113
|
+
validator,
|
|
114
|
+
prefiller,
|
|
115
|
+
options,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
getFieldsForClientService(sourceDomains, derivationBase) {
|
|
119
|
+
const fields = this.getFields();
|
|
120
|
+
return fields
|
|
121
|
+
.map((field, i) => this.getFieldForClient(i, sourceDomains, derivationBase))
|
|
122
|
+
.filter((field) => field !== null);
|
|
123
|
+
}
|
|
124
|
+
getFieldsForSigningService() {
|
|
125
|
+
const fields = this.getFields();
|
|
126
|
+
return fields
|
|
127
|
+
.filter((field) => field.type !== 'image')
|
|
128
|
+
.map((field) => ({
|
|
129
|
+
field: field.field,
|
|
130
|
+
type: field.type,
|
|
131
|
+
x: field.x,
|
|
132
|
+
y: field.y,
|
|
133
|
+
w: field.w,
|
|
134
|
+
h: field.h,
|
|
135
|
+
align_h: (field.align_h ?? 'left'),
|
|
136
|
+
align_v: (field.align_v ?? 'top'),
|
|
137
|
+
page: field.page,
|
|
138
|
+
}))
|
|
139
|
+
.filter((field) => field !== null);
|
|
140
|
+
}
|
|
141
|
+
inferParams() {
|
|
142
|
+
const inferenceRegex = /params\[\s*(['"])(.*?)\1\s*\]/g;
|
|
143
|
+
const params = [];
|
|
144
|
+
let match;
|
|
145
|
+
for (const field of this.getFields()) {
|
|
146
|
+
const validatorStr = typeof field.validator === 'string' ? field.validator : '';
|
|
147
|
+
while ((match = inferenceRegex.exec(validatorStr)) !== null)
|
|
148
|
+
if (!params.includes(match[2]))
|
|
149
|
+
params.push(match[2]);
|
|
150
|
+
}
|
|
151
|
+
for (const field of this.getPhantomFields()) {
|
|
152
|
+
const validatorStr = typeof field.validator === 'string' ? field.validator : '';
|
|
153
|
+
while ((match = inferenceRegex.exec(validatorStr)) !== null)
|
|
154
|
+
if (!params.includes(match[2]))
|
|
155
|
+
params.push(match[2]);
|
|
156
|
+
}
|
|
157
|
+
return params;
|
|
158
|
+
}
|
|
159
|
+
parseValidator(fieldname, params = {}) {
|
|
160
|
+
const field = this.getFields().find((f) => f.field === fieldname);
|
|
161
|
+
if (!field)
|
|
162
|
+
return null;
|
|
163
|
+
const d = new Date();
|
|
164
|
+
const defaults = {
|
|
165
|
+
currentDate: d,
|
|
166
|
+
currentDateTimestamp: d.getTime(),
|
|
167
|
+
};
|
|
168
|
+
const validatorStr = typeof field.validator === 'string' ? field.validator : '';
|
|
169
|
+
const validator = this.populateParams(validatorStr, params);
|
|
170
|
+
const ret = `return ${validator}`;
|
|
171
|
+
const evaluator = new Function('z', 'params', ret);
|
|
172
|
+
return evaluator(zod_1.default, { ...params, ...defaults });
|
|
173
|
+
}
|
|
174
|
+
parsePrefiller(fieldname, _params = {}) {
|
|
175
|
+
const field = this.getFields().find((f) => f.field === fieldname);
|
|
176
|
+
if (!field || !field.default_value)
|
|
177
|
+
return null;
|
|
178
|
+
try {
|
|
179
|
+
const fn = eval(field.default_value);
|
|
180
|
+
return typeof fn === 'function' ? fn : null;
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
console.error(`Failed to parse prefiller for field ${fieldname}`, e);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
enumerateParams(s) {
|
|
188
|
+
const detectedParams = s.match(/#\{[^}]*\}/g) ?? [];
|
|
189
|
+
const params = detectedParams.map((dp) => {
|
|
190
|
+
const [fieldName, propertyTree] = dp
|
|
191
|
+
.replaceAll('#{', '')
|
|
192
|
+
.replaceAll('}', '')
|
|
193
|
+
.replaceAll(')', '')
|
|
194
|
+
.split('(');
|
|
195
|
+
const properties = propertyTree?.split('.') ?? [];
|
|
196
|
+
return [fieldName, ...properties];
|
|
197
|
+
});
|
|
198
|
+
return params?.reduce((acc, cur, i) => ((acc[detectedParams[i]] = cur), acc), {});
|
|
199
|
+
}
|
|
200
|
+
populateParams(s, params) {
|
|
201
|
+
const paramsReflection = this.enumerateParams(s);
|
|
202
|
+
const paramsValues = {};
|
|
203
|
+
for (const match in paramsReflection) {
|
|
204
|
+
const path = paramsReflection[match];
|
|
205
|
+
paramsValues[match] =
|
|
206
|
+
path.reduce((acc, cur) => acc?.[cur], params) ?? '';
|
|
207
|
+
}
|
|
208
|
+
let out = s;
|
|
209
|
+
for (const match in paramsValues) {
|
|
210
|
+
const replacement = JSON.stringify(paramsValues[match]);
|
|
211
|
+
out = out.replaceAll(match, replacement);
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
getSignatories() {
|
|
216
|
+
return this.formMetadata.subscribers;
|
|
217
|
+
}
|
|
218
|
+
getSubscribers() {
|
|
219
|
+
return this.formMetadata.subscribers;
|
|
220
|
+
}
|
|
221
|
+
getRequiredParties() {
|
|
222
|
+
return this.formMetadata.parties;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.FormMetadata = FormMetadata;
|
|
226
|
+
exports.DUMMY_FORM_METADATA = {
|
|
227
|
+
name: 'test-form',
|
|
228
|
+
label: 'Test Form',
|
|
229
|
+
schema_version: exports.SCHEMA_VERSION,
|
|
230
|
+
schema: {
|
|
231
|
+
blocks: [
|
|
232
|
+
{
|
|
233
|
+
block_type: 'header',
|
|
234
|
+
order: 0,
|
|
235
|
+
content: 'Student Information Form',
|
|
236
|
+
party_id: 'party-1',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
block_type: 'paragraph',
|
|
240
|
+
order: 1,
|
|
241
|
+
content: 'Please fill in your personal details below.',
|
|
242
|
+
party_id: 'party-1',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
block_type: 'form_field',
|
|
246
|
+
order: 2,
|
|
247
|
+
content: {
|
|
248
|
+
field: 'student.full_name',
|
|
249
|
+
type: 'text',
|
|
250
|
+
x: 100,
|
|
251
|
+
y: 100,
|
|
252
|
+
w: 200,
|
|
253
|
+
h: 20,
|
|
254
|
+
page: 1,
|
|
255
|
+
align_h: 'left',
|
|
256
|
+
align_v: 'top',
|
|
257
|
+
label: 'Full Name',
|
|
258
|
+
tooltip_label: 'Enter your full name',
|
|
259
|
+
shared: true,
|
|
260
|
+
source: 'manual',
|
|
261
|
+
default_value: '({ user }) => `${user?.first_name ?? ""} ${user?.last_name ?? ""}`',
|
|
262
|
+
validator: 'z.string().min(1, "Name is required")',
|
|
263
|
+
},
|
|
264
|
+
party_id: 'party-1',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
block_type: 'form_field',
|
|
268
|
+
order: 3,
|
|
269
|
+
content: {
|
|
270
|
+
field: 'student.email',
|
|
271
|
+
type: 'text',
|
|
272
|
+
x: 100,
|
|
273
|
+
y: 130,
|
|
274
|
+
w: 200,
|
|
275
|
+
h: 20,
|
|
276
|
+
page: 1,
|
|
277
|
+
align_h: 'left',
|
|
278
|
+
align_v: 'top',
|
|
279
|
+
label: 'Email',
|
|
280
|
+
tooltip_label: 'Enter your email address',
|
|
281
|
+
shared: true,
|
|
282
|
+
source: 'prefill',
|
|
283
|
+
default_value: '({ user }) => user?.email ?? ""',
|
|
284
|
+
validator: 'z.string().email("Invalid email")',
|
|
285
|
+
},
|
|
286
|
+
party_id: 'party-1',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
block_type: 'form_field',
|
|
290
|
+
order: 4,
|
|
291
|
+
content: {
|
|
292
|
+
field: 'student.signature',
|
|
293
|
+
type: 'signature',
|
|
294
|
+
x: 100,
|
|
295
|
+
y: 160,
|
|
296
|
+
w: 150,
|
|
297
|
+
h: 50,
|
|
298
|
+
page: 1,
|
|
299
|
+
align_h: 'left',
|
|
300
|
+
align_v: 'top',
|
|
301
|
+
label: 'Signature',
|
|
302
|
+
tooltip_label: 'Please sign here',
|
|
303
|
+
shared: true,
|
|
304
|
+
source: 'manual',
|
|
305
|
+
validator: 'z.string().min(1, "Signature is required")',
|
|
306
|
+
},
|
|
307
|
+
party_id: 'party-1',
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
block_type: 'form_phantom_field',
|
|
311
|
+
order: 5,
|
|
312
|
+
content: {
|
|
313
|
+
field: 'student.phone',
|
|
314
|
+
type: 'text',
|
|
315
|
+
label: 'Phone Number',
|
|
316
|
+
tooltip_label: 'Optional contact number',
|
|
317
|
+
shared: true,
|
|
318
|
+
source: 'manual',
|
|
319
|
+
validator: 'z.string().optional()',
|
|
320
|
+
},
|
|
321
|
+
party_id: 'party-1',
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
parties: [
|
|
326
|
+
{
|
|
327
|
+
_id: 'party-1',
|
|
328
|
+
order: 1,
|
|
329
|
+
signatory_account: {
|
|
330
|
+
account_id: 'user-1',
|
|
331
|
+
name: 'John Doe',
|
|
332
|
+
email: 'john@example.com',
|
|
333
|
+
title: 'Student',
|
|
334
|
+
},
|
|
335
|
+
signed: false,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
subscribers: [
|
|
339
|
+
{
|
|
340
|
+
account_id: 'user-2',
|
|
341
|
+
name: 'Jane Smith',
|
|
342
|
+
email: 'jane@example.com',
|
|
343
|
+
title: 'Administrator',
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
};
|
|
346
347
|
//# sourceMappingURL=form-metadata.js.map
|