gruber 0.9.1 → 0.9.2
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/CHANGELOG.md +10 -0
- package/config/structure.d.ts +18 -0
- package/config/structure.d.ts.map +1 -1
- package/config/structure.js +45 -0
- package/config/structure.test.js +38 -0
- package/config/structure.ts +51 -0
- package/core/terminator.d.ts.map +1 -1
- package/core/terminator.js +7 -1
- package/core/terminator.ts +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,16 @@ This file documents notable changes to the project
|
|
|
9
9
|
|
|
10
10
|
## next
|
|
11
11
|
|
|
12
|
+
**fixes**
|
|
13
|
+
|
|
14
|
+
- `Terminator#waitForSignals` no longer exits the process
|
|
15
|
+
|
|
16
|
+
**unstable**
|
|
17
|
+
|
|
18
|
+
- Add `Structure.record`
|
|
19
|
+
|
|
20
|
+
## 0.9.1
|
|
21
|
+
|
|
12
22
|
**features**
|
|
13
23
|
|
|
14
24
|
- Add `Structure.nullable`
|
package/config/structure.d.ts
CHANGED
|
@@ -178,6 +178,24 @@ export declare class Structure<T> {
|
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
180
|
static tuple<const T extends Structure<any>[]>(types: T): Structure<InferObject<T>>;
|
|
181
|
+
/**
|
|
182
|
+
* @unstable
|
|
183
|
+
*
|
|
184
|
+
* Creates a Structure for objects that map a key to a common type of value
|
|
185
|
+
*
|
|
186
|
+
* ```js
|
|
187
|
+
* Structure.record(Structure.string(), Structure.number())
|
|
188
|
+
* Structure.record(
|
|
189
|
+
* Structure.string(),
|
|
190
|
+
* Structure.object({ name: Structure.string() })
|
|
191
|
+
* )
|
|
192
|
+
* Structure.record(
|
|
193
|
+
* Structure.enum(["name", "address", "emailAddress"]),
|
|
194
|
+
* Structure.string()
|
|
195
|
+
* )
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
static record<K extends string, V>(keyStruct: Structure<K>, valueStruct: Structure<V>): Structure<Record<K, V>>;
|
|
181
199
|
/**
|
|
182
200
|
* Define a Structure to validate the value is `null`
|
|
183
201
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKjD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,KAAK,CAAC,CAAC;AAE1E,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEhE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE7D,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAI9B;AAED;;;;;;GAMG;AACH,qBAAa,SAAS,CAAC,CAAC;IACvB,MAAM,CAAC,KAAK,sBAAgB;IAE5B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAWtD;IAEF,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;gBACZ,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,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ItC;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;IAI9D;;;;;;OAMG;IACH,MAAM,CAAC,SAAS;IAOhB;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;CAGtC"}
|
package/config/structure.js
CHANGED
|
@@ -411,6 +411,51 @@ export class Structure {
|
|
|
411
411
|
return output;
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* @unstable
|
|
416
|
+
*
|
|
417
|
+
* Creates a Structure for objects that map a key to a common type of value
|
|
418
|
+
*
|
|
419
|
+
* ```js
|
|
420
|
+
* Structure.record(Structure.string(), Structure.number())
|
|
421
|
+
* Structure.record(
|
|
422
|
+
* Structure.string(),
|
|
423
|
+
* Structure.object({ name: Structure.string() })
|
|
424
|
+
* )
|
|
425
|
+
* Structure.record(
|
|
426
|
+
* Structure.enum(["name", "address", "emailAddress"]),
|
|
427
|
+
* Structure.string()
|
|
428
|
+
* )
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
static record(keyStruct, valueStruct) {
|
|
432
|
+
const schema = {
|
|
433
|
+
type: "object",
|
|
434
|
+
};
|
|
435
|
+
return new Structure(schema, (value, context) => {
|
|
436
|
+
if (typeof value !== "object")
|
|
437
|
+
throw new Error("Not an object");
|
|
438
|
+
const output = {};
|
|
439
|
+
const errors = [];
|
|
440
|
+
for (const entry of Object.entries(value)) {
|
|
441
|
+
try {
|
|
442
|
+
const ctx = _nestContext(context, entry[0]);
|
|
443
|
+
output[keyStruct.process(entry[0], ctx)] = valueStruct.process(entry[1], ctx);
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
errors.push(error);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (errors.length > 0) {
|
|
450
|
+
throw new Structure.Error("Invalid record", context.path, errors);
|
|
451
|
+
}
|
|
452
|
+
for (const key in output) {
|
|
453
|
+
if (output[key] === undefined)
|
|
454
|
+
delete output[key];
|
|
455
|
+
}
|
|
456
|
+
return output;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
414
459
|
/**
|
|
415
460
|
* Define a Structure to validate the value is `null`
|
|
416
461
|
*
|
package/config/structure.test.js
CHANGED
|
@@ -589,6 +589,44 @@ describe("Structure", () => {
|
|
|
589
589
|
});
|
|
590
590
|
});
|
|
591
591
|
|
|
592
|
+
describe("record", () => {
|
|
593
|
+
it("allows matching key-value pairs", () => {
|
|
594
|
+
const struct = Structure.record(Structure.string(), Structure.number());
|
|
595
|
+
const value = struct.process({ age: 42 });
|
|
596
|
+
assertEquals(value, { age: 42 });
|
|
597
|
+
});
|
|
598
|
+
it("allows enum keys", () => {
|
|
599
|
+
const struct = Structure.record(
|
|
600
|
+
Structure.enum(["name", "pet"]),
|
|
601
|
+
Structure.string(),
|
|
602
|
+
);
|
|
603
|
+
const value = struct.process({ name: "Geoff T" });
|
|
604
|
+
assertEquals(value, { name: "Geoff T" });
|
|
605
|
+
});
|
|
606
|
+
it("blocks invalid keys", () => {
|
|
607
|
+
const struct = Structure.record(
|
|
608
|
+
Structure.literal("name"),
|
|
609
|
+
Structure.string(),
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
assertThrows(
|
|
613
|
+
() => struct.process({ pet: "Hugo" }),
|
|
614
|
+
(error) => error instanceof Structure.Error,
|
|
615
|
+
);
|
|
616
|
+
});
|
|
617
|
+
it("blocks invalid values", () => {
|
|
618
|
+
const struct = Structure.record(
|
|
619
|
+
Structure.literal("name"),
|
|
620
|
+
Structure.string(),
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
assertThrows(
|
|
624
|
+
() => struct.process({ name: 119 }),
|
|
625
|
+
(error) => error instanceof Structure.Error,
|
|
626
|
+
);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
|
|
592
630
|
describe("null", () => {
|
|
593
631
|
const struct = Structure.null();
|
|
594
632
|
|
package/config/structure.ts
CHANGED
|
@@ -465,6 +465,57 @@ export class Structure<T> {
|
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @unstable
|
|
470
|
+
*
|
|
471
|
+
* Creates a Structure for objects that map a key to a common type of value
|
|
472
|
+
*
|
|
473
|
+
* ```js
|
|
474
|
+
* Structure.record(Structure.string(), Structure.number())
|
|
475
|
+
* Structure.record(
|
|
476
|
+
* Structure.string(),
|
|
477
|
+
* Structure.object({ name: Structure.string() })
|
|
478
|
+
* )
|
|
479
|
+
* Structure.record(
|
|
480
|
+
* Structure.enum(["name", "address", "emailAddress"]),
|
|
481
|
+
* Structure.string()
|
|
482
|
+
* )
|
|
483
|
+
* ```
|
|
484
|
+
*/
|
|
485
|
+
static record<K extends string, V>(
|
|
486
|
+
keyStruct: Structure<K>,
|
|
487
|
+
valueStruct: Structure<V>,
|
|
488
|
+
): Structure<Record<K, V>> {
|
|
489
|
+
const schema = {
|
|
490
|
+
type: "object",
|
|
491
|
+
};
|
|
492
|
+
return new Structure<Record<K, V>>(schema, (value, context) => {
|
|
493
|
+
if (typeof value !== "object") throw new Error("Not an object");
|
|
494
|
+
|
|
495
|
+
const output: any = {};
|
|
496
|
+
const errors: any[] = [];
|
|
497
|
+
for (const entry of Object.entries(value as any)) {
|
|
498
|
+
try {
|
|
499
|
+
const ctx = _nestContext(context, entry[0]);
|
|
500
|
+
output[keyStruct.process(entry[0], ctx)] = valueStruct.process(
|
|
501
|
+
entry[1],
|
|
502
|
+
ctx,
|
|
503
|
+
);
|
|
504
|
+
} catch (error) {
|
|
505
|
+
errors.push(error as Error);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (errors.length > 0) {
|
|
509
|
+
throw new Structure.Error("Invalid record", context.path, errors);
|
|
510
|
+
}
|
|
511
|
+
for (const key in output) {
|
|
512
|
+
if (output[key] === undefined) delete output[key];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
return output;
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
468
519
|
/**
|
|
469
520
|
* Define a Structure to validate the value is `null`
|
|
470
521
|
*
|
package/core/terminator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminator.d.ts","sourceRoot":"","sources":["terminator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IACjC,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC;IAEhB,qCAAqC;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,4DAA4D;IAC5D,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAErE,oEAAoE;IACpE,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC;AAK7C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAU;IACtB,KAAK,EAAE,eAAe,CAAa;IACnC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,YAAY,CAAC;gBAET,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY;IAK5D;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,gBAAgB;IAM7B;;;;;;;;;;OAUG;IACG,SAAS,CAAC,KAAK,EAAE,gBAAgB;IAevC;;;;;;;;;OASG;IACH,WAAW,IAAI,QAAQ;IAOvB;;;;;;;;;;;;;OAaG;IACG,cAAc;
|
|
1
|
+
{"version":3,"file":"terminator.d.ts","sourceRoot":"","sources":["terminator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IACjC,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC;IAEhB,qCAAqC;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,4DAA4D;IAC5D,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAErE,oEAAoE;IACpE,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC;AAK7C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAU;IACtB,KAAK,EAAE,eAAe,CAAa;IACnC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,YAAY,CAAC;gBAET,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY;IAK5D;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,gBAAgB;IAM7B;;;;;;;;;;OAUG;IACG,SAAS,CAAC,KAAK,EAAE,gBAAgB;IAevC;;;;;;;;;OASG;IACH,WAAW,IAAI,QAAQ;IAOvB;;;;;;;;;;;;;OAaG;IACG,cAAc;CAWpB"}
|
package/core/terminator.js
CHANGED
|
@@ -93,6 +93,12 @@ export class Terminator {
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
async waitForSignals() {
|
|
96
|
-
await new Promise((resolve) =>
|
|
96
|
+
await new Promise((resolve) => {
|
|
97
|
+
this.options.startListeners(this.options.signals, () => resolve());
|
|
98
|
+
});
|
|
99
|
+
this.state = "terminating";
|
|
100
|
+
await new Promise((resolve) => {
|
|
101
|
+
this.timers.setTimeout(resolve, this.options.timeout);
|
|
102
|
+
});
|
|
97
103
|
}
|
|
98
104
|
}
|
package/core/terminator.ts
CHANGED
|
@@ -135,6 +135,14 @@ export class Terminator {
|
|
|
135
135
|
* ```
|
|
136
136
|
*/
|
|
137
137
|
async waitForSignals() {
|
|
138
|
-
await new Promise<void>((resolve) =>
|
|
138
|
+
await new Promise<void>((resolve) => {
|
|
139
|
+
this.options.startListeners(this.options.signals, () => resolve());
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
this.state = "terminating";
|
|
143
|
+
|
|
144
|
+
await new Promise<void>((resolve) => {
|
|
145
|
+
this.timers.setTimeout(resolve, this.options.timeout);
|
|
146
|
+
});
|
|
139
147
|
}
|
|
140
148
|
}
|
package/package.json
CHANGED