@zthun/helpful-internet 9.11.9 → 9.11.11

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 CHANGED
@@ -1,705 +1,620 @@
1
+ //#region src/cookie/cookie.mts
1
2
  /**
2
- * Represents a generic cookie.
3
- */ function _define_property$5(obj, key, value) {
4
- if (key in obj) {
5
- Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- } else {
12
- obj[key] = value;
13
- }
14
- return obj;
15
- }
3
+ * Represents a generic cookie.
4
+ */ /**
5
+ * Represents a builder for an IZCookie object.
6
+ */ var ZCookieBuilder = class ZCookieBuilder {
7
+ static MillisecondsOneDay = 864e5;
8
+ _cookie;
9
+ /**
10
+ * Initializes a new instance of this object.
11
+ */ constructor() {
12
+ this._cookie = {
13
+ name: "",
14
+ value: ""
15
+ };
16
+ }
17
+ /**
18
+ * Sets the cookie name.
19
+ *
20
+ * @param val -
21
+ * The value to set.
22
+ *
23
+ * @returns
24
+ * This object.
25
+ */ name(val) {
26
+ this._cookie.name = val;
27
+ return this;
28
+ }
29
+ /**
30
+ * Sets the cookie value.
31
+ *
32
+ * @param val -
33
+ * The value to set.
34
+ *
35
+ * @returns
36
+ * This object.
37
+ */ value(val) {
38
+ this._cookie.value = val;
39
+ return this;
40
+ }
41
+ /**
42
+ * Sets the cookie domain.
43
+ *
44
+ * @param val -
45
+ * The value to set.
46
+ *
47
+ * @returns
48
+ * This object.
49
+ */ domain(val) {
50
+ this._cookie.domain = val;
51
+ return this;
52
+ }
53
+ /**
54
+ * Sets the cookie expiration date.
55
+ *
56
+ * @param val -
57
+ * The value to set.
58
+ *
59
+ * @returns
60
+ * This object.
61
+ */ expires(val) {
62
+ if (val == null) {
63
+ delete this._cookie.expires;
64
+ return this;
65
+ }
66
+ this._cookie.expires = typeof val === "string" ? val : val.toJSON();
67
+ return this;
68
+ }
69
+ /**
70
+ * Sets the cookie expiration date to one day from the moment this is invoked.
71
+ *
72
+ * @returns
73
+ * This object.
74
+ */ expiresTomorrow() {
75
+ return this.expires(new Date(Date.now() + ZCookieBuilder.MillisecondsOneDay));
76
+ }
77
+ /**
78
+ * Removes the cookie expiration.
79
+ *
80
+ * @returns
81
+ * This object.
82
+ */ immortal = this.expires.bind(this, void 0);
83
+ /**
84
+ * Sets the cookie secure flag.
85
+ *
86
+ * @param val -
87
+ * The value to set.
88
+ *
89
+ * @returns
90
+ * This object.
91
+ */ secure(val = true) {
92
+ this._cookie.secure = val;
93
+ return this;
94
+ }
95
+ /**
96
+ * Sets the cookie same site policy.
97
+ *
98
+ * @param val -
99
+ * The value to set.
100
+ *
101
+ * @returns
102
+ * This object.
103
+ */ sameSite(val) {
104
+ this._cookie.sameSite = val;
105
+ return this;
106
+ }
107
+ /**
108
+ * Sets the same site policy to 'lax'
109
+ *
110
+ * @returns
111
+ * This object.
112
+ */ lax = this.sameSite.bind(this, "lax");
113
+ /**
114
+ * Sets the same site polity to 'strict'
115
+ *
116
+ * @returns
117
+ * This object.
118
+ */ strict = this.sameSite.bind(this, "strict");
119
+ /**
120
+ * Sets the same site policy to 'none' and turns on the secure flag.
121
+ *
122
+ * @returns
123
+ * This object.
124
+ */ allowCrossSite() {
125
+ return this.secure().sameSite("none");
126
+ }
127
+ /**
128
+ * Sets the cookie http only flag.
129
+ *
130
+ * @param val -
131
+ * The value to set.
132
+ *
133
+ * @returns
134
+ * This object.
135
+ */ httpOnly(val = true) {
136
+ this._cookie.httpOnly = val;
137
+ return this;
138
+ }
139
+ /**
140
+ * Creates a token based authentication cookie.
141
+ *
142
+ * @param token -
143
+ * The token value for the cookie. You
144
+ * can leave this as undefined to set it
145
+ * later.
146
+ *
147
+ * @returns
148
+ * This object.
149
+ */ authentication(token) {
150
+ const builder = this.name("Authentication").expiresTomorrow().secure().httpOnly();
151
+ return token == null ? builder : builder.value(token);
152
+ }
153
+ /**
154
+ * Returns a copy of the built instance of the cookie.
155
+ *
156
+ * @returns
157
+ * A shallow copy of the current cookie object.
158
+ */ build() {
159
+ return { ...this._cookie };
160
+ }
161
+ };
162
+ //#endregion
163
+ //#region src/email/email-envelope.mts
16
164
  /**
17
- * Represents a builder for an IZCookie object.
18
- */ class ZCookieBuilder {
19
- /**
20
- * Sets the cookie name.
21
- *
22
- * @param val -
23
- * The value to set.
24
- *
25
- * @returns
26
- * This object.
27
- */ name(val) {
28
- this._cookie.name = val;
29
- return this;
30
- }
31
- /**
32
- * Sets the cookie value.
33
- *
34
- * @param val -
35
- * The value to set.
36
- *
37
- * @returns
38
- * This object.
39
- */ value(val) {
40
- this._cookie.value = val;
41
- return this;
42
- }
43
- /**
44
- * Sets the cookie domain.
45
- *
46
- * @param val -
47
- * The value to set.
48
- *
49
- * @returns
50
- * This object.
51
- */ domain(val) {
52
- this._cookie.domain = val;
53
- return this;
54
- }
55
- /**
56
- * Sets the cookie expiration date.
57
- *
58
- * @param val -
59
- * The value to set.
60
- *
61
- * @returns
62
- * This object.
63
- */ expires(val) {
64
- if (val == null) {
65
- delete this._cookie.expires;
66
- return this;
67
- }
68
- this._cookie.expires = typeof val === "string" ? val : val.toJSON();
69
- return this;
70
- }
71
- /**
72
- * Sets the cookie expiration date to one day from the moment this is invoked.
73
- *
74
- * @returns
75
- * This object.
76
- */ expiresTomorrow() {
77
- return this.expires(new Date(Date.now() + ZCookieBuilder.MillisecondsOneDay));
78
- }
79
- /**
80
- * Sets the cookie secure flag.
81
- *
82
- * @param val -
83
- * The value to set.
84
- *
85
- * @returns
86
- * This object.
87
- */ secure(val = true) {
88
- this._cookie.secure = val;
89
- return this;
90
- }
91
- /**
92
- * Sets the cookie same site policy.
93
- *
94
- * @param val -
95
- * The value to set.
96
- *
97
- * @returns
98
- * This object.
99
- */ sameSite(val) {
100
- this._cookie.sameSite = val;
101
- return this;
102
- }
103
- /**
104
- * Sets the same site policy to 'none' and turns on the secure flag.
105
- *
106
- * @returns
107
- * This object.
108
- */ allowCrossSite() {
109
- return this.secure().sameSite("none");
110
- }
111
- /**
112
- * Sets the cookie http only flag.
113
- *
114
- * @param val -
115
- * The value to set.
116
- *
117
- * @returns
118
- * This object.
119
- */ httpOnly(val = true) {
120
- this._cookie.httpOnly = val;
121
- return this;
122
- }
123
- /**
124
- * Creates a token based authentication cookie.
125
- *
126
- * @param token -
127
- * The token value for the cookie. You
128
- * can leave this as undefined to set it
129
- * later.
130
- *
131
- * @returns
132
- * This object.
133
- */ authentication(token) {
134
- const builder = this.name("Authentication").expiresTomorrow().secure().httpOnly();
135
- return token == null ? builder : builder.value(token);
136
- }
137
- /**
138
- * Returns a copy of the built instance of the cookie.
139
- *
140
- * @returns
141
- * A shallow copy of the current cookie object.
142
- */ build() {
143
- return {
144
- ...this._cookie
145
- };
146
- }
147
- /**
148
- * Initializes a new instance of this object.
149
- */ constructor(){
150
- _define_property$5(this, "_cookie", void 0);
151
- /**
152
- * Removes the cookie expiration.
153
- *
154
- * @returns
155
- * This object.
156
- */ _define_property$5(this, "immortal", this.expires.bind(this, undefined));
157
- /**
158
- * Sets the same site policy to 'lax'
159
- *
160
- * @returns
161
- * This object.
162
- */ _define_property$5(this, "lax", this.sameSite.bind(this, "lax"));
163
- /**
164
- * Sets the same site polity to 'strict'
165
- *
166
- * @returns
167
- * This object.
168
- */ _define_property$5(this, "strict", this.sameSite.bind(this, "strict"));
169
- this._cookie = {
170
- name: "",
171
- value: ""
172
- };
173
- }
174
- }
175
- _define_property$5(ZCookieBuilder, "MillisecondsOneDay", 86400000);
176
-
177
- function _define_property$4(obj, key, value) {
178
- if (key in obj) {
179
- Object.defineProperty(obj, key, {
180
- value: value,
181
- enumerable: true,
182
- configurable: true,
183
- writable: true
184
- });
185
- } else {
186
- obj[key] = value;
187
- }
188
- return obj;
189
- }
190
- /**
191
- * Represents a builder that will build a comma separated
192
- * list of addresses for an email message.
193
- */ class ZEmailContactAddressBuilder {
194
- /**
195
- * Adds an address to the list to builder.
196
- *
197
- * @param val -
198
- * The address to add. This can be the empty string,
199
- * null, or undefined.
200
- *
201
- * @returns
202
- * This object.
203
- */ address(val) {
204
- this._addresses.push(val);
205
- return this;
206
- }
207
- /**
208
- * Sets the addresses to build from.
209
- *
210
- * @param val -
211
- * The address to set.
212
- *
213
- * @returns
214
- * This object.
215
- */ addresses(val) {
216
- this._addresses = val.slice();
217
- return this;
218
- }
219
- /**
220
- * Sets the delimiter to split the addresses with.
221
- *
222
- * The default is a comma with a space.
223
- *
224
- * @param val -
225
- * The delimiter to set.
226
- *
227
- * @returns
228
- * This object.
229
- */ delimiter(val) {
230
- this._delimiter = val;
231
- return this;
232
- }
233
- /**
234
- * Builds the delimiters separated list of addresses.
235
- *
236
- * @returns
237
- * The delimited separated list of addresses.
238
- */ build() {
239
- const addr = (ct)=>{
240
- if (!ct) {
241
- return undefined;
242
- }
243
- return typeof ct === "string" ? ct : ct.address;
244
- };
245
- const truthy = (ct)=>{
246
- return !!ct;
247
- };
248
- return this._addresses.map(addr).filter(truthy).join(this._delimiter);
249
- }
250
- constructor(){
251
- _define_property$4(this, "_addresses", []);
252
- _define_property$4(this, "_delimiter", ", ");
253
- }
254
- }
255
-
256
- /**
257
- * Represents an email contact.
258
- */ function _define_property$3(obj, key, value) {
259
- if (key in obj) {
260
- Object.defineProperty(obj, key, {
261
- value: value,
262
- enumerable: true,
263
- configurable: true,
264
- writable: true
265
- });
266
- } else {
267
- obj[key] = value;
268
- }
269
- return obj;
270
- }
271
- /**
272
- * Represents a builder for an email contact.
273
- */ class ZEmailContactBuilder {
274
- /**
275
- * Sets the address of the contact.
276
- *
277
- * @param val -
278
- * The value to set.
279
- *
280
- * @returns
281
- * This object.
282
- */ address(val) {
283
- this._contact.address = val;
284
- return this;
285
- }
286
- /**
287
- * Sets the type of the contact.
288
- *
289
- * @param val -
290
- * The value to set.
291
- *
292
- * @returns
293
- * This object.
294
- */ type(val) {
295
- this._contact.type = val;
296
- return this;
297
- }
298
- /**
299
- * Sets the display of the contact.
300
- *
301
- * @param val -
302
- * The value to set.
303
- *
304
- * @returns
305
- * This object.
306
- */ display(val) {
307
- this._contact.display = val;
308
- return this;
309
- }
310
- /**
311
- * Assigns the values in other to this object.
312
- *
313
- * @param other -
314
- * The value to partial copy.
315
- *
316
- * @returns
317
- * This object.
318
- */ assign(other) {
319
- this._contact = Object.assign({}, this._contact, other);
320
- this._contact = JSON.parse(JSON.stringify(this._contact));
321
- return this;
322
- }
323
- /**
324
- * Copies another object.
325
- *
326
- * @param other -
327
- * The value to copy.
328
- *
329
- * @returns
330
- * This object.
331
- */ copy(other) {
332
- this._contact = JSON.parse(JSON.stringify(other));
333
- return this;
334
- }
335
- /**
336
- * Returns a copy of the built object.
337
- *
338
- * @returns
339
- * A copy of the built email contact.
340
- */ build() {
341
- return JSON.parse(JSON.stringify(this._contact));
342
- }
343
- /**
344
- * Initializes a new instance of this object.
345
- */ constructor(){
346
- _define_property$3(this, "_contact", void 0);
347
- this._contact = {
348
- address: ""
349
- };
350
- }
351
- }
352
-
353
- function _define_property$2(obj, key, value) {
354
- if (key in obj) {
355
- Object.defineProperty(obj, key, {
356
- value: value,
357
- enumerable: true,
358
- configurable: true,
359
- writable: true
360
- });
361
- } else {
362
- obj[key] = value;
363
- }
364
- return obj;
365
- }
165
+ * Represents a builder for an email envelope.
166
+ */ var ZEmailEnvelopeBuilder = class {
167
+ _envelope;
168
+ /**
169
+ * Initializes a new instance of this object.
170
+ */ constructor() {
171
+ this._envelope = { from: "" };
172
+ }
173
+ /**
174
+ * Sets the from field.
175
+ *
176
+ * @param val -
177
+ * The value to set.
178
+ *
179
+ * @returns
180
+ * This object.
181
+ */ from(val) {
182
+ this._envelope.from = val;
183
+ return this;
184
+ }
185
+ /**
186
+ * Adds a value to the 'to' field.
187
+ *
188
+ * @param val -
189
+ * The value to add.
190
+ *
191
+ * @returns
192
+ * This object.
193
+ */ to(val) {
194
+ this._envelope.to = this._envelope.to || [];
195
+ this._envelope.to.push(val);
196
+ return this;
197
+ }
198
+ /**
199
+ * Sets the to field.
200
+ *
201
+ * @param val -
202
+ * The value to set.
203
+ *
204
+ * @returns
205
+ * This object.
206
+ */ tos(val) {
207
+ this._envelope.to = val;
208
+ return this;
209
+ }
210
+ /**
211
+ * Adds a value to the cc field.
212
+ *
213
+ * @param val -
214
+ * The value to add.
215
+ *
216
+ * @returns
217
+ * This object.
218
+ */ cc(val) {
219
+ this._envelope.cc = this._envelope.cc || [];
220
+ this._envelope.cc.push(val);
221
+ return this;
222
+ }
223
+ /**
224
+ * Sets the cc field.
225
+ *
226
+ * @param val -
227
+ * The value to set.
228
+ *
229
+ * @returns
230
+ * This object.
231
+ */ ccs(val) {
232
+ this._envelope.cc = val;
233
+ return this;
234
+ }
235
+ /**
236
+ * Adds a value to the bcc field.
237
+ *
238
+ * @param val -
239
+ * The value to add.
240
+ *
241
+ * @returns
242
+ * This object.
243
+ */ bcc(val) {
244
+ this._envelope.bcc = this._envelope.bcc || [];
245
+ this._envelope.bcc.push(val);
246
+ return this;
247
+ }
248
+ /**
249
+ * Sets the bcc field.
250
+ *
251
+ * @param val -
252
+ * The value to set.
253
+ *
254
+ * @returns
255
+ * This object.
256
+ */ bccs(val) {
257
+ this._envelope.bcc = val;
258
+ return this;
259
+ }
260
+ /**
261
+ * Assigns another partial email envelope to this object.
262
+ *
263
+ * @param other -
264
+ * The value to partial copy.
265
+ *
266
+ * @returns
267
+ * This object.
268
+ */ assign(other) {
269
+ this._envelope = Object.assign({}, this._envelope, other);
270
+ this._envelope = JSON.parse(JSON.stringify(this._envelope));
271
+ return this;
272
+ }
273
+ /**
274
+ * Copies another email envelope to this object.
275
+ *
276
+ * @param other -
277
+ * The value to copy.
278
+ *
279
+ * @returns
280
+ * This object.
281
+ */ copy(other) {
282
+ this._envelope = JSON.parse(JSON.stringify(other));
283
+ return this;
284
+ }
285
+ /**
286
+ * Returns a copy of the built envelope.
287
+ *
288
+ * @returns
289
+ * A copy of the currently built up envelope object.
290
+ */ build() {
291
+ return JSON.parse(JSON.stringify(this._envelope));
292
+ }
293
+ };
294
+ //#endregion
295
+ //#region src/email/email.mts
366
296
  /**
367
- * Represents a builder for an email envelope.
368
- */ class ZEmailEnvelopeBuilder {
369
- /**
370
- * Sets the from field.
371
- *
372
- * @param val -
373
- * The value to set.
374
- *
375
- * @returns
376
- * This object.
377
- */ from(val) {
378
- this._envelope.from = val;
379
- return this;
380
- }
381
- /**
382
- * Adds a value to the 'to' field.
383
- *
384
- * @param val -
385
- * The value to add.
386
- *
387
- * @returns
388
- * This object.
389
- */ to(val) {
390
- this._envelope.to = this._envelope.to || [];
391
- this._envelope.to.push(val);
392
- return this;
393
- }
394
- /**
395
- * Sets the to field.
396
- *
397
- * @param val -
398
- * The value to set.
399
- *
400
- * @returns
401
- * This object.
402
- */ tos(val) {
403
- this._envelope.to = val;
404
- return this;
405
- }
406
- /**
407
- * Adds a value to the cc field.
408
- *
409
- * @param val -
410
- * The value to add.
411
- *
412
- * @returns
413
- * This object.
414
- */ cc(val) {
415
- this._envelope.cc = this._envelope.cc || [];
416
- this._envelope.cc.push(val);
417
- return this;
418
- }
419
- /**
420
- * Sets the cc field.
421
- *
422
- * @param val -
423
- * The value to set.
424
- *
425
- * @returns
426
- * This object.
427
- */ ccs(val) {
428
- this._envelope.cc = val;
429
- return this;
430
- }
431
- /**
432
- * Adds a value to the bcc field.
433
- *
434
- * @param val -
435
- * The value to add.
436
- *
437
- * @returns
438
- * This object.
439
- */ bcc(val) {
440
- this._envelope.bcc = this._envelope.bcc || [];
441
- this._envelope.bcc.push(val);
442
- return this;
443
- }
444
- /**
445
- * Sets the bcc field.
446
- *
447
- * @param val -
448
- * The value to set.
449
- *
450
- * @returns
451
- * This object.
452
- */ bccs(val) {
453
- this._envelope.bcc = val;
454
- return this;
455
- }
456
- /**
457
- * Assigns another partial email envelope to this object.
458
- *
459
- * @param other -
460
- * The value to partial copy.
461
- *
462
- * @returns
463
- * This object.
464
- */ assign(other) {
465
- this._envelope = Object.assign({}, this._envelope, other);
466
- this._envelope = JSON.parse(JSON.stringify(this._envelope));
467
- return this;
468
- }
469
- /**
470
- * Copies another email envelope to this object.
471
- *
472
- * @param other -
473
- * The value to copy.
474
- *
475
- * @returns
476
- * This object.
477
- */ copy(other) {
478
- this._envelope = JSON.parse(JSON.stringify(other));
479
- return this;
480
- }
481
- /**
482
- * Returns a copy of the built envelope.
483
- *
484
- * @returns
485
- * A copy of the currently built up envelope object.
486
- */ build() {
487
- return JSON.parse(JSON.stringify(this._envelope));
488
- }
489
- /**
490
- * Initializes a new instance of this object.
491
- */ constructor(){
492
- _define_property$2(this, "_envelope", void 0);
493
- this._envelope = {
494
- from: ""
495
- };
496
- }
497
- }
498
-
499
- function _define_property$1(obj, key, value) {
500
- if (key in obj) {
501
- Object.defineProperty(obj, key, {
502
- value: value,
503
- enumerable: true,
504
- configurable: true,
505
- writable: true
506
- });
507
- } else {
508
- obj[key] = value;
509
- }
510
- return obj;
511
- }
297
+ * Represents a builder for an email.
298
+ */ var ZEmailBuilder = class {
299
+ _email;
300
+ /**
301
+ * Initializes a new instance of this object.
302
+ */ constructor() {
303
+ this._email = { envelope: new ZEmailEnvelopeBuilder().build() };
304
+ }
305
+ /**
306
+ * Sets the envelope of where the email is going.
307
+ *
308
+ * @param val -
309
+ * The value to set.
310
+ *
311
+ * @returns
312
+ * This object.
313
+ */ envelope(val) {
314
+ this._email.envelope = val;
315
+ return this;
316
+ }
317
+ /**
318
+ * Sets the subject line of the email.
319
+ *
320
+ * @param val -
321
+ * The value to set.
322
+ *
323
+ * @returns
324
+ * This object.
325
+ */ subject(val) {
326
+ this._email.subject = val;
327
+ return this;
328
+ }
329
+ /**
330
+ * Sets the message of the email.
331
+ *
332
+ * The message can be raw text or html.
333
+ *
334
+ * @param val -
335
+ * A html enabled formatted message to set.
336
+ *
337
+ * @returns
338
+ * This object.
339
+ */ message(val) {
340
+ this._email.message = val;
341
+ return this;
342
+ }
343
+ /**
344
+ * Assigns the other object to the current email object.
345
+ *
346
+ * @param other -
347
+ * The object to copy.
348
+ *
349
+ * @returns
350
+ * This object.
351
+ */ assign(other) {
352
+ this._email = Object.assign(this._email, other);
353
+ this._email = JSON.parse(JSON.stringify(this._email));
354
+ return this;
355
+ }
356
+ /**
357
+ * Copies another email into the builder.
358
+ *
359
+ * @param other -
360
+ * The object to copy.
361
+ *
362
+ * @returns
363
+ * This object.
364
+ */ copy(other) {
365
+ this._email = JSON.parse(JSON.stringify(other));
366
+ return this;
367
+ }
368
+ /**
369
+ * Returns a copy of the built object.
370
+ *
371
+ * @returns
372
+ * A copy of the built object.
373
+ */ build() {
374
+ return JSON.parse(JSON.stringify(this._email));
375
+ }
376
+ };
377
+ //#endregion
378
+ //#region src/email/email-contact.mts
512
379
  /**
513
- * Represents a builder for an email.
514
- */ class ZEmailBuilder {
515
- /**
516
- * Sets the envelope of where the email is going.
517
- *
518
- * @param val -
519
- * The value to set.
520
- *
521
- * @returns
522
- * This object.
523
- */ envelope(val) {
524
- this._email.envelope = val;
525
- return this;
526
- }
527
- /**
528
- * Sets the subject line of the email.
529
- *
530
- * @param val -
531
- * The value to set.
532
- *
533
- * @returns
534
- * This object.
535
- */ subject(val) {
536
- this._email.subject = val;
537
- return this;
538
- }
539
- /**
540
- * Sets the message of the email.
541
- *
542
- * The message can be raw text or html.
543
- *
544
- * @param val -
545
- * A html enabled formatted message to set.
546
- *
547
- * @returns
548
- * This object.
549
- */ message(val) {
550
- this._email.message = val;
551
- return this;
552
- }
553
- /**
554
- * Assigns the other object to the current email object.
555
- *
556
- * @param other -
557
- * The object to copy.
558
- *
559
- * @returns
560
- * This object.
561
- */ assign(other) {
562
- this._email = Object.assign(this._email, other);
563
- this._email = JSON.parse(JSON.stringify(this._email));
564
- return this;
565
- }
566
- /**
567
- * Copies another email into the builder.
568
- *
569
- * @param other -
570
- * The object to copy.
571
- *
572
- * @returns
573
- * This object.
574
- */ copy(other) {
575
- this._email = JSON.parse(JSON.stringify(other));
576
- return this;
577
- }
578
- /**
579
- * Returns a copy of the built object.
580
- *
581
- * @returns
582
- * A copy of the built object.
583
- */ build() {
584
- return JSON.parse(JSON.stringify(this._email));
585
- }
586
- /**
587
- * Initializes a new instance of this object.
588
- */ constructor(){
589
- _define_property$1(this, "_email", void 0);
590
- this._email = {
591
- envelope: new ZEmailEnvelopeBuilder().build()
592
- };
593
- }
594
- }
595
-
380
+ * Represents an email contact.
381
+ */ /**
382
+ * Represents a builder for an email contact.
383
+ */ var ZEmailContactBuilder = class {
384
+ _contact;
385
+ /**
386
+ * Initializes a new instance of this object.
387
+ */ constructor() {
388
+ this._contact = { address: "" };
389
+ }
390
+ /**
391
+ * Sets the address of the contact.
392
+ *
393
+ * @param val -
394
+ * The value to set.
395
+ *
396
+ * @returns
397
+ * This object.
398
+ */ address(val) {
399
+ this._contact.address = val;
400
+ return this;
401
+ }
402
+ /**
403
+ * Sets the type of the contact.
404
+ *
405
+ * @param val -
406
+ * The value to set.
407
+ *
408
+ * @returns
409
+ * This object.
410
+ */ type(val) {
411
+ this._contact.type = val;
412
+ return this;
413
+ }
414
+ /**
415
+ * Sets the display of the contact.
416
+ *
417
+ * @param val -
418
+ * The value to set.
419
+ *
420
+ * @returns
421
+ * This object.
422
+ */ display(val) {
423
+ this._contact.display = val;
424
+ return this;
425
+ }
426
+ /**
427
+ * Assigns the values in other to this object.
428
+ *
429
+ * @param other -
430
+ * The value to partial copy.
431
+ *
432
+ * @returns
433
+ * This object.
434
+ */ assign(other) {
435
+ this._contact = Object.assign({}, this._contact, other);
436
+ this._contact = JSON.parse(JSON.stringify(this._contact));
437
+ return this;
438
+ }
439
+ /**
440
+ * Copies another object.
441
+ *
442
+ * @param other -
443
+ * The value to copy.
444
+ *
445
+ * @returns
446
+ * This object.
447
+ */ copy(other) {
448
+ this._contact = JSON.parse(JSON.stringify(other));
449
+ return this;
450
+ }
451
+ /**
452
+ * Returns a copy of the built object.
453
+ *
454
+ * @returns
455
+ * A copy of the built email contact.
456
+ */ build() {
457
+ return JSON.parse(JSON.stringify(this._contact));
458
+ }
459
+ };
460
+ //#endregion
461
+ //#region src/email/email-contact-address.mts
596
462
  /**
597
- * Represents an abstract server connection.
598
- */ function _define_property(obj, key, value) {
599
- if (key in obj) {
600
- Object.defineProperty(obj, key, {
601
- value: value,
602
- enumerable: true,
603
- configurable: true,
604
- writable: true
605
- });
606
- } else {
607
- obj[key] = value;
608
- }
609
- return obj;
610
- }
463
+ * Represents a builder that will build a comma separated
464
+ * list of addresses for an email message.
465
+ */ var ZEmailContactAddressBuilder = class {
466
+ _addresses = [];
467
+ _delimiter = ", ";
468
+ /**
469
+ * Adds an address to the list to builder.
470
+ *
471
+ * @param val -
472
+ * The address to add. This can be the empty string,
473
+ * null, or undefined.
474
+ *
475
+ * @returns
476
+ * This object.
477
+ */ address(val) {
478
+ this._addresses.push(val);
479
+ return this;
480
+ }
481
+ /**
482
+ * Sets the addresses to build from.
483
+ *
484
+ * @param val -
485
+ * The address to set.
486
+ *
487
+ * @returns
488
+ * This object.
489
+ */ addresses(val) {
490
+ this._addresses = val.slice();
491
+ return this;
492
+ }
493
+ /**
494
+ * Sets the delimiter to split the addresses with.
495
+ *
496
+ * The default is a comma with a space.
497
+ *
498
+ * @param val -
499
+ * The delimiter to set.
500
+ *
501
+ * @returns
502
+ * This object.
503
+ */ delimiter(val) {
504
+ this._delimiter = val;
505
+ return this;
506
+ }
507
+ /**
508
+ * Builds the delimiters separated list of addresses.
509
+ *
510
+ * @returns
511
+ * The delimited separated list of addresses.
512
+ */ build() {
513
+ const addr = (ct) => {
514
+ if (!ct) return;
515
+ return typeof ct === "string" ? ct : ct.address;
516
+ };
517
+ const truthy = (ct) => {
518
+ return !!ct;
519
+ };
520
+ return this._addresses.map(addr).filter(truthy).join(this._delimiter);
521
+ }
522
+ };
523
+ //#endregion
524
+ //#region src/server/server.mts
611
525
  /**
612
- * Represents a builder for a server object.
613
- */ class ZServerBuilder {
614
- /**
615
- * The server ip address or hostname.
616
- *
617
- * @param val -
618
- * The value to set.
619
- *
620
- * @returns
621
- * This object.
622
- */ address(val) {
623
- this._server.address = val;
624
- return this;
625
- }
626
- /**
627
- * Sets the optional port to connect on.
628
- *
629
- * @param val -
630
- * The value to set.
631
- *
632
- * @returns
633
- * This object.
634
- */ port(val) {
635
- this._server.port = val;
636
- return this;
637
- }
638
- /**
639
- * Sets the optional username to connect on.
640
- *
641
- * @param val -
642
- * The value to set.
643
- *
644
- * @returns
645
- * This object.
646
- */ username(val) {
647
- this._server.username = val;
648
- return this;
649
- }
650
- /**
651
- * Sets the password to connect on.
652
- *
653
- * @param val -
654
- * The value to set.
655
- *
656
- * @returns
657
- * This object.
658
- */ password(val) {
659
- this._server.password = val;
660
- return this;
661
- }
662
- /**
663
- * Assigns all truthy properties in other to this object.
664
- *
665
- * @param other -
666
- * The server object to copy.
667
- *
668
- * @returns
669
- * This object.
670
- */ assign(other) {
671
- this._server = Object.assign({}, this._server, other);
672
- return this;
673
- }
674
- /**
675
- * Copies all properties in other to this object.
676
- *
677
- * @param other -
678
- * The server object to copy.
679
- *
680
- * @returns
681
- * This object.
682
- */ copy(other) {
683
- this._server = JSON.parse(JSON.stringify(other));
684
- return this;
685
- }
686
- /**
687
- * Returns a copy of the built object.
688
- *
689
- * @returns
690
- * A copy of the built object.
691
- */ build() {
692
- return JSON.parse(JSON.stringify(this._server));
693
- }
694
- /**
695
- * Initializes a new instance of this object.
696
- */ constructor(){
697
- _define_property(this, "_server", void 0);
698
- this._server = {
699
- address: ""
700
- };
701
- }
702
- }
703
-
526
+ * Represents an abstract server connection.
527
+ */ /**
528
+ * Represents a builder for a server object.
529
+ */ var ZServerBuilder = class {
530
+ _server;
531
+ /**
532
+ * Initializes a new instance of this object.
533
+ */ constructor() {
534
+ this._server = { address: "" };
535
+ }
536
+ /**
537
+ * The server ip address or hostname.
538
+ *
539
+ * @param val -
540
+ * The value to set.
541
+ *
542
+ * @returns
543
+ * This object.
544
+ */ address(val) {
545
+ this._server.address = val;
546
+ return this;
547
+ }
548
+ /**
549
+ * Sets the optional port to connect on.
550
+ *
551
+ * @param val -
552
+ * The value to set.
553
+ *
554
+ * @returns
555
+ * This object.
556
+ */ port(val) {
557
+ this._server.port = val;
558
+ return this;
559
+ }
560
+ /**
561
+ * Sets the optional username to connect on.
562
+ *
563
+ * @param val -
564
+ * The value to set.
565
+ *
566
+ * @returns
567
+ * This object.
568
+ */ username(val) {
569
+ this._server.username = val;
570
+ return this;
571
+ }
572
+ /**
573
+ * Sets the password to connect on.
574
+ *
575
+ * @param val -
576
+ * The value to set.
577
+ *
578
+ * @returns
579
+ * This object.
580
+ */ password(val) {
581
+ this._server.password = val;
582
+ return this;
583
+ }
584
+ /**
585
+ * Assigns all truthy properties in other to this object.
586
+ *
587
+ * @param other -
588
+ * The server object to copy.
589
+ *
590
+ * @returns
591
+ * This object.
592
+ */ assign(other) {
593
+ this._server = Object.assign({}, this._server, other);
594
+ return this;
595
+ }
596
+ /**
597
+ * Copies all properties in other to this object.
598
+ *
599
+ * @param other -
600
+ * The server object to copy.
601
+ *
602
+ * @returns
603
+ * This object.
604
+ */ copy(other) {
605
+ this._server = JSON.parse(JSON.stringify(other));
606
+ return this;
607
+ }
608
+ /**
609
+ * Returns a copy of the built object.
610
+ *
611
+ * @returns
612
+ * A copy of the built object.
613
+ */ build() {
614
+ return JSON.parse(JSON.stringify(this._server));
615
+ }
616
+ };
617
+ //#endregion
704
618
  export { ZCookieBuilder, ZEmailBuilder, ZEmailContactAddressBuilder, ZEmailContactBuilder, ZEmailEnvelopeBuilder, ZServerBuilder };
705
- //# sourceMappingURL=index.js.map
619
+
620
+ //# sourceMappingURL=index.js.map