@xylabs/creatable 5.0.79 → 5.0.81
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 +929 -128
- package/dist/neutral/AbstractCreatable.d.ts +83 -0
- package/dist/neutral/AbstractCreatable.d.ts.map +1 -1
- package/dist/neutral/Creatable.d.ts +17 -0
- package/dist/neutral/Creatable.d.ts.map +1 -1
- package/dist/neutral/Factory.d.ts +17 -0
- package/dist/neutral/Factory.d.ts.map +1 -1
- package/dist/neutral/index.mjs +86 -0
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/lib/getFunctionName.d.ts +5 -0
- package/dist/neutral/lib/getFunctionName.d.ts.map +1 -1
- package/dist/neutral/lib/getRootFunction.d.ts +6 -0
- package/dist/neutral/lib/getRootFunction.d.ts.map +1 -1
- package/dist/neutral/model/CreatableInstance.d.ts +6 -0
- package/dist/neutral/model/CreatableInstance.d.ts.map +1 -1
- package/dist/neutral/model/CreatableParams.d.ts +5 -0
- package/dist/neutral/model/CreatableParams.d.ts.map +1 -1
- package/dist/neutral/model/CreatableStatusReporter.d.ts +6 -0
- package/dist/neutral/model/CreatableStatusReporter.d.ts.map +1 -1
- package/package.json +11 -14
- package/src/AbstractCreatable.ts +0 -269
- package/src/Creatable.ts +0 -69
- package/src/Factory.ts +0 -38
- package/src/index.ts +0 -4
- package/src/lib/getFunctionName.ts +0 -18
- package/src/lib/getRootFunction.ts +0 -8
- package/src/lib/index.ts +0 -2
- package/src/model/CreatableInstance.ts +0 -12
- package/src/model/CreatableParams.ts +0 -13
- package/src/model/CreatableStatusReporter.ts +0 -11
- package/src/model/Labels.ts +0 -33
- package/src/model/index.ts +0 -4
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
33
33
|
- [Creatable](#interfaces/Creatable)
|
|
34
34
|
- [CreatableWithFactory](#interfaces/CreatableWithFactory)
|
|
35
35
|
- [CreatableInstance](#interfaces/CreatableInstance)
|
|
36
|
+
- [RequiredCreatableParams](#interfaces/RequiredCreatableParams)
|
|
36
37
|
- [CreatableParams](#interfaces/CreatableParams)
|
|
37
38
|
- [CreatableStatusReporter](#interfaces/CreatableStatusReporter)
|
|
38
39
|
- [Labels](#interfaces/Labels)
|
|
@@ -42,6 +43,7 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
42
43
|
## Type Aliases
|
|
43
44
|
|
|
44
45
|
- [CreatableName](#type-aliases/CreatableName)
|
|
46
|
+
- [StandardCreatableStatus](#type-aliases/StandardCreatableStatus)
|
|
45
47
|
- [CreatableStatus](#type-aliases/CreatableStatus)
|
|
46
48
|
|
|
47
49
|
## Functions
|
|
@@ -58,9 +60,13 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
58
60
|
|
|
59
61
|
***
|
|
60
62
|
|
|
63
|
+
Base class for objects that follow an asynchronous creation and lifecycle pattern.
|
|
64
|
+
Instances must be created via the static `create` method rather than direct construction.
|
|
65
|
+
Provides start/stop lifecycle management with status tracking and telemetry support.
|
|
66
|
+
|
|
61
67
|
## Extends
|
|
62
68
|
|
|
63
|
-
- `BaseEmitter`\<`Partial`\<`TParams
|
|
69
|
+
- `BaseEmitter`\<`Partial`\<`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\>, `TEventData`\>
|
|
64
70
|
|
|
65
71
|
## Extended by
|
|
66
72
|
|
|
@@ -92,7 +98,7 @@ new AbstractCreatable<TParams, TEventData>(key, params): AbstractCreatable<TPara
|
|
|
92
98
|
|
|
93
99
|
#### params
|
|
94
100
|
|
|
95
|
-
`Partial`\<`TParams
|
|
101
|
+
`Partial`\<`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\>
|
|
96
102
|
|
|
97
103
|
### Returns
|
|
98
104
|
|
|
@@ -101,7 +107,7 @@ new AbstractCreatable<TParams, TEventData>(key, params): AbstractCreatable<TPara
|
|
|
101
107
|
### Overrides
|
|
102
108
|
|
|
103
109
|
```ts
|
|
104
|
-
BaseEmitter<Partial<TParams>, TEventData>.constructor
|
|
110
|
+
BaseEmitter<Partial<TParams & RequiredCreatableParams>, TEventData>.constructor
|
|
105
111
|
```
|
|
106
112
|
|
|
107
113
|
## Properties
|
|
@@ -148,24 +154,20 @@ BaseEmitter.globalInstancesCountHistory
|
|
|
148
154
|
|
|
149
155
|
***
|
|
150
156
|
|
|
151
|
-
###
|
|
157
|
+
### defaultLogger?
|
|
152
158
|
|
|
153
159
|
```ts
|
|
154
|
-
|
|
160
|
+
optional defaultLogger: Logger;
|
|
155
161
|
```
|
|
156
162
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```ts
|
|
160
|
-
BaseEmitter.uniqueName
|
|
161
|
-
```
|
|
163
|
+
Optional default logger for this instance.
|
|
162
164
|
|
|
163
165
|
***
|
|
164
166
|
|
|
165
|
-
###
|
|
167
|
+
### \_startPromise
|
|
166
168
|
|
|
167
169
|
```ts
|
|
168
|
-
|
|
170
|
+
protected _startPromise: Promisable<boolean> | undefined;
|
|
169
171
|
```
|
|
170
172
|
|
|
171
173
|
***
|
|
@@ -317,12 +319,12 @@ BaseEmitter.maxHistoryDepth
|
|
|
317
319
|
### Get Signature
|
|
318
320
|
|
|
319
321
|
```ts
|
|
320
|
-
get logger():
|
|
322
|
+
get logger(): Logger | undefined;
|
|
321
323
|
```
|
|
322
324
|
|
|
323
325
|
#### Returns
|
|
324
326
|
|
|
325
|
-
`
|
|
327
|
+
`Logger` \| `undefined`
|
|
326
328
|
|
|
327
329
|
### Inherited from
|
|
328
330
|
|
|
@@ -337,12 +339,12 @@ BaseEmitter.logger
|
|
|
337
339
|
### Get Signature
|
|
338
340
|
|
|
339
341
|
```ts
|
|
340
|
-
get meter():
|
|
342
|
+
get meter(): Meter | undefined;
|
|
341
343
|
```
|
|
342
344
|
|
|
343
345
|
#### Returns
|
|
344
346
|
|
|
345
|
-
`
|
|
347
|
+
`Meter` \| `undefined`
|
|
346
348
|
|
|
347
349
|
### Inherited from
|
|
348
350
|
|
|
@@ -357,12 +359,12 @@ BaseEmitter.meter
|
|
|
357
359
|
### Get Signature
|
|
358
360
|
|
|
359
361
|
```ts
|
|
360
|
-
get tracer():
|
|
362
|
+
get tracer(): Tracer | undefined;
|
|
361
363
|
```
|
|
362
364
|
|
|
363
365
|
#### Returns
|
|
364
366
|
|
|
365
|
-
`
|
|
367
|
+
`Tracer` \| `undefined`
|
|
366
368
|
|
|
367
369
|
### Inherited from
|
|
368
370
|
|
|
@@ -377,12 +379,14 @@ BaseEmitter.tracer
|
|
|
377
379
|
### Get Signature
|
|
378
380
|
|
|
379
381
|
```ts
|
|
380
|
-
get name():
|
|
382
|
+
get name(): CreatableName;
|
|
381
383
|
```
|
|
382
384
|
|
|
385
|
+
The name identifier for this creatable instance.
|
|
386
|
+
|
|
383
387
|
#### Returns
|
|
384
388
|
|
|
385
|
-
`
|
|
389
|
+
[`CreatableName`](#../type-aliases/CreatableName)
|
|
386
390
|
|
|
387
391
|
***
|
|
388
392
|
|
|
@@ -391,12 +395,14 @@ get name(): string;
|
|
|
391
395
|
### Get Signature
|
|
392
396
|
|
|
393
397
|
```ts
|
|
394
|
-
get params(): TParams
|
|
398
|
+
get params(): TParams & RequiredCreatableParams<void>;
|
|
395
399
|
```
|
|
396
400
|
|
|
401
|
+
The validated and merged parameters for this instance.
|
|
402
|
+
|
|
397
403
|
#### Returns
|
|
398
404
|
|
|
399
|
-
`TParams`
|
|
405
|
+
`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\<`void`\>
|
|
400
406
|
|
|
401
407
|
### Overrides
|
|
402
408
|
|
|
@@ -406,20 +412,54 @@ BaseEmitter.params
|
|
|
406
412
|
|
|
407
413
|
***
|
|
408
414
|
|
|
415
|
+
### startable
|
|
416
|
+
|
|
417
|
+
### Get Signature
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
get startable(): boolean;
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Whether this instance can be started (must be in 'created' or 'stopped' status).
|
|
424
|
+
|
|
425
|
+
#### Returns
|
|
426
|
+
|
|
427
|
+
`boolean`
|
|
428
|
+
|
|
429
|
+
***
|
|
430
|
+
|
|
431
|
+
### status
|
|
432
|
+
|
|
433
|
+
### Get Signature
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
get status(): CreatableStatus | null;
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
The current lifecycle status of this instance, or null if not yet initialized.
|
|
440
|
+
|
|
441
|
+
#### Returns
|
|
442
|
+
|
|
443
|
+
[`CreatableStatus`](#../type-aliases/CreatableStatus) \| `null`
|
|
444
|
+
|
|
445
|
+
***
|
|
446
|
+
|
|
409
447
|
### statusReporter
|
|
410
448
|
|
|
411
449
|
### Get Signature
|
|
412
450
|
|
|
413
451
|
```ts
|
|
414
452
|
get statusReporter():
|
|
415
|
-
|
|
|
416
|
-
|
|
|
453
|
+
| CreatableStatusReporter<void>
|
|
454
|
+
| undefined;
|
|
417
455
|
```
|
|
418
456
|
|
|
457
|
+
The status reporter used to broadcast lifecycle changes.
|
|
458
|
+
|
|
419
459
|
#### Returns
|
|
420
460
|
|
|
421
|
-
\| `undefined`
|
|
422
461
|
\| [`CreatableStatusReporter`](#../interfaces/CreatableStatusReporter)\<`void`\>
|
|
462
|
+
\| `undefined`
|
|
423
463
|
|
|
424
464
|
## Methods
|
|
425
465
|
|
|
@@ -457,7 +497,7 @@ static gc(className): void;
|
|
|
457
497
|
|
|
458
498
|
##### className
|
|
459
499
|
|
|
460
|
-
`
|
|
500
|
+
`BaseClassName`
|
|
461
501
|
|
|
462
502
|
#### Returns
|
|
463
503
|
|
|
@@ -481,7 +521,7 @@ static instanceCount(className): number;
|
|
|
481
521
|
|
|
482
522
|
#### className
|
|
483
523
|
|
|
484
|
-
`
|
|
524
|
+
`BaseClassName`
|
|
485
525
|
|
|
486
526
|
### Returns
|
|
487
527
|
|
|
@@ -552,9 +592,12 @@ BaseEmitter.stopHistory
|
|
|
552
592
|
### create()
|
|
553
593
|
|
|
554
594
|
```ts
|
|
555
|
-
static create<T>(this, inParams): Promise<T>;
|
|
595
|
+
static create<T>(this, inParams?): Promise<T>;
|
|
556
596
|
```
|
|
557
597
|
|
|
598
|
+
Asynchronously creates a new instance by processing params, constructing,
|
|
599
|
+
and running both static and instance createHandlers.
|
|
600
|
+
|
|
558
601
|
### Type Parameters
|
|
559
602
|
|
|
560
603
|
#### T
|
|
@@ -567,14 +610,18 @@ static create<T>(this, inParams): Promise<T>;
|
|
|
567
610
|
|
|
568
611
|
[`Creatable`](#../interfaces/Creatable)\<`T`\>
|
|
569
612
|
|
|
570
|
-
#### inParams
|
|
613
|
+
#### inParams?
|
|
571
614
|
|
|
572
615
|
`Partial`\<`T`\[`"params"`\]\> = `{}`
|
|
573
616
|
|
|
617
|
+
Optional partial parameters to configure the instance
|
|
618
|
+
|
|
574
619
|
### Returns
|
|
575
620
|
|
|
576
621
|
`Promise`\<`T`\>
|
|
577
622
|
|
|
623
|
+
The fully initialized instance
|
|
624
|
+
|
|
578
625
|
***
|
|
579
626
|
|
|
580
627
|
### createHandler()
|
|
@@ -583,6 +630,9 @@ static create<T>(this, inParams): Promise<T>;
|
|
|
583
630
|
static createHandler<T>(this, instance): Promisable<T>;
|
|
584
631
|
```
|
|
585
632
|
|
|
633
|
+
Static hook called during creation to perform additional initialization.
|
|
634
|
+
Override in subclasses to customize post-construction setup.
|
|
635
|
+
|
|
586
636
|
### Type Parameters
|
|
587
637
|
|
|
588
638
|
#### T
|
|
@@ -599,18 +649,25 @@ static createHandler<T>(this, instance): Promisable<T>;
|
|
|
599
649
|
|
|
600
650
|
`T`
|
|
601
651
|
|
|
652
|
+
The newly constructed instance
|
|
653
|
+
|
|
602
654
|
### Returns
|
|
603
655
|
|
|
604
656
|
`Promisable`\<`T`\>
|
|
605
657
|
|
|
658
|
+
The instance, potentially modified
|
|
659
|
+
|
|
606
660
|
***
|
|
607
661
|
|
|
608
662
|
### paramsHandler()
|
|
609
663
|
|
|
610
664
|
```ts
|
|
611
|
-
static paramsHandler<T>(this, params): Promisable<T["params"]>;
|
|
665
|
+
static paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
612
666
|
```
|
|
613
667
|
|
|
668
|
+
Static hook called during creation to validate and transform params.
|
|
669
|
+
Override in subclasses to add default values or validation.
|
|
670
|
+
|
|
614
671
|
### Type Parameters
|
|
615
672
|
|
|
616
673
|
#### T
|
|
@@ -623,14 +680,18 @@ static paramsHandler<T>(this, params): Promisable<T["params"]>;
|
|
|
623
680
|
|
|
624
681
|
[`Creatable`](#../interfaces/Creatable)\<`T`\>
|
|
625
682
|
|
|
626
|
-
#### params
|
|
683
|
+
#### params?
|
|
627
684
|
|
|
628
685
|
`Partial`\<`T`\[`"params"`\]\> = `{}`
|
|
629
686
|
|
|
687
|
+
The raw partial params provided to `create`
|
|
688
|
+
|
|
630
689
|
### Returns
|
|
631
690
|
|
|
632
691
|
`Promisable`\<`T`\[`"params"`\]\>
|
|
633
692
|
|
|
693
|
+
The processed params ready for construction
|
|
694
|
+
|
|
634
695
|
***
|
|
635
696
|
|
|
636
697
|
### createHandler()
|
|
@@ -639,6 +700,8 @@ static paramsHandler<T>(this, params): Promisable<T["params"]>;
|
|
|
639
700
|
createHandler(): Promisable<void>;
|
|
640
701
|
```
|
|
641
702
|
|
|
703
|
+
Instance-level creation hook. Override in subclasses to perform setup after construction.
|
|
704
|
+
|
|
642
705
|
### Returns
|
|
643
706
|
|
|
644
707
|
`Promisable`\<`void`\>
|
|
@@ -648,18 +711,102 @@ createHandler(): Promisable<void>;
|
|
|
648
711
|
### paramsValidator()
|
|
649
712
|
|
|
650
713
|
```ts
|
|
651
|
-
paramsValidator(params): TParams
|
|
714
|
+
paramsValidator(params): TParams & RequiredCreatableParams<void>;
|
|
652
715
|
```
|
|
653
716
|
|
|
717
|
+
Validates and returns the merged params, ensuring required fields are present.
|
|
718
|
+
Override in subclasses to add custom validation logic.
|
|
719
|
+
|
|
654
720
|
### Parameters
|
|
655
721
|
|
|
656
722
|
#### params
|
|
657
723
|
|
|
658
|
-
`Partial`\<`TParams
|
|
724
|
+
`Partial`\<`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\>
|
|
725
|
+
|
|
726
|
+
The raw partial params to validate
|
|
727
|
+
|
|
728
|
+
### Returns
|
|
729
|
+
|
|
730
|
+
`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\<`void`\>
|
|
731
|
+
|
|
732
|
+
The validated params
|
|
733
|
+
|
|
734
|
+
***
|
|
735
|
+
|
|
736
|
+
### span()
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
span<T>(name, fn): T;
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
Executes a function within a telemetry span.
|
|
743
|
+
|
|
744
|
+
### Type Parameters
|
|
745
|
+
|
|
746
|
+
#### T
|
|
747
|
+
|
|
748
|
+
`T`
|
|
749
|
+
|
|
750
|
+
### Parameters
|
|
751
|
+
|
|
752
|
+
#### name
|
|
753
|
+
|
|
754
|
+
`string`
|
|
755
|
+
|
|
756
|
+
The span name
|
|
757
|
+
|
|
758
|
+
#### fn
|
|
759
|
+
|
|
760
|
+
() => `T`
|
|
761
|
+
|
|
762
|
+
The function to execute within the span
|
|
763
|
+
|
|
764
|
+
### Returns
|
|
765
|
+
|
|
766
|
+
`T`
|
|
767
|
+
|
|
768
|
+
***
|
|
769
|
+
|
|
770
|
+
### spanAsync()
|
|
771
|
+
|
|
772
|
+
```ts
|
|
773
|
+
spanAsync<T>(
|
|
774
|
+
name,
|
|
775
|
+
fn,
|
|
776
|
+
config?): Promise<T>;
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
Executes an async function within a telemetry span.
|
|
780
|
+
|
|
781
|
+
### Type Parameters
|
|
782
|
+
|
|
783
|
+
#### T
|
|
784
|
+
|
|
785
|
+
`T`
|
|
786
|
+
|
|
787
|
+
### Parameters
|
|
788
|
+
|
|
789
|
+
#### name
|
|
790
|
+
|
|
791
|
+
`string`
|
|
792
|
+
|
|
793
|
+
The span name
|
|
794
|
+
|
|
795
|
+
#### fn
|
|
796
|
+
|
|
797
|
+
() => `Promise`\<`T`\>
|
|
798
|
+
|
|
799
|
+
The async function to execute within the span
|
|
800
|
+
|
|
801
|
+
#### config?
|
|
802
|
+
|
|
803
|
+
`SpanConfig` = `{}`
|
|
804
|
+
|
|
805
|
+
Optional span configuration
|
|
659
806
|
|
|
660
807
|
### Returns
|
|
661
808
|
|
|
662
|
-
`
|
|
809
|
+
`Promise`\<`T`\>
|
|
663
810
|
|
|
664
811
|
***
|
|
665
812
|
|
|
@@ -669,10 +816,68 @@ paramsValidator(params): TParams;
|
|
|
669
816
|
start(): Promise<boolean>;
|
|
670
817
|
```
|
|
671
818
|
|
|
819
|
+
Starts the instance, transitioning through 'starting' to 'started' status.
|
|
820
|
+
Thread-safe via mutex. Returns true if already started or started successfully.
|
|
821
|
+
|
|
822
|
+
### Returns
|
|
823
|
+
|
|
824
|
+
`Promise`\<`boolean`\>
|
|
825
|
+
|
|
826
|
+
***
|
|
827
|
+
|
|
828
|
+
### started()
|
|
829
|
+
|
|
830
|
+
```ts
|
|
831
|
+
started(notStartedAction?): boolean;
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
Checks whether this instance is currently started.
|
|
835
|
+
Takes an action if not started, based on the notStartedAction parameter.
|
|
836
|
+
|
|
837
|
+
### Parameters
|
|
838
|
+
|
|
839
|
+
#### notStartedAction?
|
|
840
|
+
|
|
841
|
+
What to do if not started: 'error'/'throw' throws, 'warn'/'log' logs, 'none' is silent
|
|
842
|
+
|
|
843
|
+
`"error"` | `"throw"` | `"warn"` | `"log"` | `"none"`
|
|
844
|
+
|
|
845
|
+
### Returns
|
|
846
|
+
|
|
847
|
+
`boolean`
|
|
848
|
+
|
|
849
|
+
True if started, false otherwise
|
|
850
|
+
|
|
851
|
+
***
|
|
852
|
+
|
|
853
|
+
### startedAsync()
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
startedAsync(notStartedAction?, tryStart?): Promise<boolean>;
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Async version of `started` that can optionally auto-start the instance.
|
|
860
|
+
|
|
861
|
+
### Parameters
|
|
862
|
+
|
|
863
|
+
#### notStartedAction?
|
|
864
|
+
|
|
865
|
+
What to do if not started and auto-start is disabled
|
|
866
|
+
|
|
867
|
+
`"error"` | `"throw"` | `"warn"` | `"log"` | `"none"`
|
|
868
|
+
|
|
869
|
+
#### tryStart?
|
|
870
|
+
|
|
871
|
+
`boolean` = `true`
|
|
872
|
+
|
|
873
|
+
If true, attempts to start the instance automatically
|
|
874
|
+
|
|
672
875
|
### Returns
|
|
673
876
|
|
|
674
877
|
`Promise`\<`boolean`\>
|
|
675
878
|
|
|
879
|
+
True if the instance is or becomes started
|
|
880
|
+
|
|
676
881
|
***
|
|
677
882
|
|
|
678
883
|
### stop()
|
|
@@ -681,6 +886,9 @@ start(): Promise<boolean>;
|
|
|
681
886
|
stop(): Promise<boolean>;
|
|
682
887
|
```
|
|
683
888
|
|
|
889
|
+
Stops the instance, transitioning through 'stopping' to 'stopped' status.
|
|
890
|
+
Thread-safe via mutex. Returns true if already stopped or stopped successfully.
|
|
891
|
+
|
|
684
892
|
### Returns
|
|
685
893
|
|
|
686
894
|
`Promise`\<`boolean`\>
|
|
@@ -690,12 +898,15 @@ stop(): Promise<boolean>;
|
|
|
690
898
|
### \_noOverride()
|
|
691
899
|
|
|
692
900
|
```ts
|
|
693
|
-
protected _noOverride(functionName): void;
|
|
901
|
+
protected _noOverride(functionName?): void;
|
|
694
902
|
```
|
|
695
903
|
|
|
904
|
+
Asserts that the given function has not been overridden in a subclass.
|
|
905
|
+
Used to enforce the handler pattern (override `startHandler` not `start`).
|
|
906
|
+
|
|
696
907
|
### Parameters
|
|
697
908
|
|
|
698
|
-
#### functionName
|
|
909
|
+
#### functionName?
|
|
699
910
|
|
|
700
911
|
`string` = `...`
|
|
701
912
|
|
|
@@ -705,12 +916,62 @@ protected _noOverride(functionName): void;
|
|
|
705
916
|
|
|
706
917
|
***
|
|
707
918
|
|
|
919
|
+
### setStatus()
|
|
920
|
+
|
|
921
|
+
### Call Signature
|
|
922
|
+
|
|
923
|
+
```ts
|
|
924
|
+
protected setStatus(value, progress?): void;
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
Sets the lifecycle status and reports it via the status reporter.
|
|
928
|
+
|
|
929
|
+
#### Parameters
|
|
930
|
+
|
|
931
|
+
##### value
|
|
932
|
+
|
|
933
|
+
`"creating"` | `"created"` | `"starting"` | `"started"` | `"stopping"` | `"stopped"`
|
|
934
|
+
|
|
935
|
+
##### progress?
|
|
936
|
+
|
|
937
|
+
`number`
|
|
938
|
+
|
|
939
|
+
#### Returns
|
|
940
|
+
|
|
941
|
+
`void`
|
|
942
|
+
|
|
943
|
+
### Call Signature
|
|
944
|
+
|
|
945
|
+
```ts
|
|
946
|
+
protected setStatus(value, error?): void;
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
Sets the lifecycle status and reports it via the status reporter.
|
|
950
|
+
|
|
951
|
+
#### Parameters
|
|
952
|
+
|
|
953
|
+
##### value
|
|
954
|
+
|
|
955
|
+
`"error"`
|
|
956
|
+
|
|
957
|
+
##### error?
|
|
958
|
+
|
|
959
|
+
`Error`
|
|
960
|
+
|
|
961
|
+
#### Returns
|
|
962
|
+
|
|
963
|
+
`void`
|
|
964
|
+
|
|
965
|
+
***
|
|
966
|
+
|
|
708
967
|
### startHandler()
|
|
709
968
|
|
|
710
969
|
```ts
|
|
711
970
|
protected startHandler(): Promisable<void>;
|
|
712
971
|
```
|
|
713
972
|
|
|
973
|
+
Override in subclasses to define start behavior. Throw an error on failure.
|
|
974
|
+
|
|
714
975
|
### Returns
|
|
715
976
|
|
|
716
977
|
`Promisable`\<`void`\>
|
|
@@ -723,6 +984,8 @@ protected startHandler(): Promisable<void>;
|
|
|
723
984
|
protected stopHandler(): Promisable<void>;
|
|
724
985
|
```
|
|
725
986
|
|
|
987
|
+
Override in subclasses to define stop behavior. Throw an error on failure.
|
|
988
|
+
|
|
726
989
|
### Returns
|
|
727
990
|
|
|
728
991
|
`Promisable`\<`void`\>
|
|
@@ -1025,6 +1288,9 @@ BaseEmitter.once
|
|
|
1025
1288
|
|
|
1026
1289
|
***
|
|
1027
1290
|
|
|
1291
|
+
Extends AbstractCreatable with a static `factory` method for creating
|
|
1292
|
+
pre-configured CreatableFactory instances.
|
|
1293
|
+
|
|
1028
1294
|
## Extends
|
|
1029
1295
|
|
|
1030
1296
|
- [`AbstractCreatable`](#AbstractCreatable)\<`TParams`, `TEventData`\>
|
|
@@ -1055,7 +1321,7 @@ new AbstractCreatableWithFactory<TParams, TEventData>(key, params): AbstractCrea
|
|
|
1055
1321
|
|
|
1056
1322
|
#### params
|
|
1057
1323
|
|
|
1058
|
-
`Partial`\<`TParams
|
|
1324
|
+
`Partial`\<`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\>
|
|
1059
1325
|
|
|
1060
1326
|
### Returns
|
|
1061
1327
|
|
|
@@ -1103,27 +1369,29 @@ readonly static globalInstancesCountHistory: Record<BaseClassName, number[]>;
|
|
|
1103
1369
|
|
|
1104
1370
|
***
|
|
1105
1371
|
|
|
1106
|
-
###
|
|
1372
|
+
### defaultLogger?
|
|
1107
1373
|
|
|
1108
1374
|
```ts
|
|
1109
|
-
|
|
1375
|
+
optional defaultLogger: Logger;
|
|
1110
1376
|
```
|
|
1111
1377
|
|
|
1378
|
+
Optional default logger for this instance.
|
|
1379
|
+
|
|
1112
1380
|
### Inherited from
|
|
1113
1381
|
|
|
1114
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
1382
|
+
[`AbstractCreatable`](#AbstractCreatable).[`defaultLogger`](AbstractCreatable.md#defaultlogger-1)
|
|
1115
1383
|
|
|
1116
1384
|
***
|
|
1117
1385
|
|
|
1118
|
-
###
|
|
1386
|
+
### \_startPromise
|
|
1119
1387
|
|
|
1120
1388
|
```ts
|
|
1121
|
-
|
|
1389
|
+
protected _startPromise: Promisable<boolean> | undefined;
|
|
1122
1390
|
```
|
|
1123
1391
|
|
|
1124
1392
|
### Inherited from
|
|
1125
1393
|
|
|
1126
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
1394
|
+
[`AbstractCreatable`](#AbstractCreatable).[`_startPromise`](AbstractCreatable.md#_startpromise)
|
|
1127
1395
|
|
|
1128
1396
|
***
|
|
1129
1397
|
|
|
@@ -1264,12 +1532,12 @@ get static maxHistoryDepth(): number;
|
|
|
1264
1532
|
### Get Signature
|
|
1265
1533
|
|
|
1266
1534
|
```ts
|
|
1267
|
-
get logger():
|
|
1535
|
+
get logger(): Logger | undefined;
|
|
1268
1536
|
```
|
|
1269
1537
|
|
|
1270
1538
|
#### Returns
|
|
1271
1539
|
|
|
1272
|
-
`
|
|
1540
|
+
`Logger` \| `undefined`
|
|
1273
1541
|
|
|
1274
1542
|
### Inherited from
|
|
1275
1543
|
|
|
@@ -1282,12 +1550,12 @@ get logger(): undefined | Logger;
|
|
|
1282
1550
|
### Get Signature
|
|
1283
1551
|
|
|
1284
1552
|
```ts
|
|
1285
|
-
get meter():
|
|
1553
|
+
get meter(): Meter | undefined;
|
|
1286
1554
|
```
|
|
1287
1555
|
|
|
1288
1556
|
#### Returns
|
|
1289
1557
|
|
|
1290
|
-
`
|
|
1558
|
+
`Meter` \| `undefined`
|
|
1291
1559
|
|
|
1292
1560
|
### Inherited from
|
|
1293
1561
|
|
|
@@ -1300,12 +1568,12 @@ get meter(): undefined | Meter;
|
|
|
1300
1568
|
### Get Signature
|
|
1301
1569
|
|
|
1302
1570
|
```ts
|
|
1303
|
-
get tracer():
|
|
1571
|
+
get tracer(): Tracer | undefined;
|
|
1304
1572
|
```
|
|
1305
1573
|
|
|
1306
1574
|
#### Returns
|
|
1307
1575
|
|
|
1308
|
-
`
|
|
1576
|
+
`Tracer` \| `undefined`
|
|
1309
1577
|
|
|
1310
1578
|
### Inherited from
|
|
1311
1579
|
|
|
@@ -1318,12 +1586,14 @@ get tracer(): undefined | Tracer;
|
|
|
1318
1586
|
### Get Signature
|
|
1319
1587
|
|
|
1320
1588
|
```ts
|
|
1321
|
-
get name():
|
|
1589
|
+
get name(): CreatableName;
|
|
1322
1590
|
```
|
|
1323
1591
|
|
|
1592
|
+
The name identifier for this creatable instance.
|
|
1593
|
+
|
|
1324
1594
|
#### Returns
|
|
1325
1595
|
|
|
1326
|
-
`
|
|
1596
|
+
[`CreatableName`](#../type-aliases/CreatableName)
|
|
1327
1597
|
|
|
1328
1598
|
### Inherited from
|
|
1329
1599
|
|
|
@@ -1336,12 +1606,14 @@ get name(): string;
|
|
|
1336
1606
|
### Get Signature
|
|
1337
1607
|
|
|
1338
1608
|
```ts
|
|
1339
|
-
get params(): TParams
|
|
1609
|
+
get params(): TParams & RequiredCreatableParams<void>;
|
|
1340
1610
|
```
|
|
1341
1611
|
|
|
1612
|
+
The validated and merged parameters for this instance.
|
|
1613
|
+
|
|
1342
1614
|
#### Returns
|
|
1343
1615
|
|
|
1344
|
-
`TParams`
|
|
1616
|
+
`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\<`void`\>
|
|
1345
1617
|
|
|
1346
1618
|
### Inherited from
|
|
1347
1619
|
|
|
@@ -1349,20 +1621,62 @@ get params(): TParams;
|
|
|
1349
1621
|
|
|
1350
1622
|
***
|
|
1351
1623
|
|
|
1624
|
+
### startable
|
|
1625
|
+
|
|
1626
|
+
### Get Signature
|
|
1627
|
+
|
|
1628
|
+
```ts
|
|
1629
|
+
get startable(): boolean;
|
|
1630
|
+
```
|
|
1631
|
+
|
|
1632
|
+
Whether this instance can be started (must be in 'created' or 'stopped' status).
|
|
1633
|
+
|
|
1634
|
+
#### Returns
|
|
1635
|
+
|
|
1636
|
+
`boolean`
|
|
1637
|
+
|
|
1638
|
+
### Inherited from
|
|
1639
|
+
|
|
1640
|
+
[`AbstractCreatable`](#AbstractCreatable).[`startable`](AbstractCreatable.md#startable)
|
|
1641
|
+
|
|
1642
|
+
***
|
|
1643
|
+
|
|
1644
|
+
### status
|
|
1645
|
+
|
|
1646
|
+
### Get Signature
|
|
1647
|
+
|
|
1648
|
+
```ts
|
|
1649
|
+
get status(): CreatableStatus | null;
|
|
1650
|
+
```
|
|
1651
|
+
|
|
1652
|
+
The current lifecycle status of this instance, or null if not yet initialized.
|
|
1653
|
+
|
|
1654
|
+
#### Returns
|
|
1655
|
+
|
|
1656
|
+
[`CreatableStatus`](#../type-aliases/CreatableStatus) \| `null`
|
|
1657
|
+
|
|
1658
|
+
### Inherited from
|
|
1659
|
+
|
|
1660
|
+
[`AbstractCreatable`](#AbstractCreatable).[`status`](AbstractCreatable.md#status)
|
|
1661
|
+
|
|
1662
|
+
***
|
|
1663
|
+
|
|
1352
1664
|
### statusReporter
|
|
1353
1665
|
|
|
1354
1666
|
### Get Signature
|
|
1355
1667
|
|
|
1356
1668
|
```ts
|
|
1357
1669
|
get statusReporter():
|
|
1358
|
-
|
|
|
1359
|
-
|
|
|
1670
|
+
| CreatableStatusReporter<void>
|
|
1671
|
+
| undefined;
|
|
1360
1672
|
```
|
|
1361
1673
|
|
|
1674
|
+
The status reporter used to broadcast lifecycle changes.
|
|
1675
|
+
|
|
1362
1676
|
#### Returns
|
|
1363
1677
|
|
|
1364
|
-
\| `undefined`
|
|
1365
1678
|
\| [`CreatableStatusReporter`](#../interfaces/CreatableStatusReporter)\<`void`\>
|
|
1679
|
+
\| `undefined`
|
|
1366
1680
|
|
|
1367
1681
|
### Inherited from
|
|
1368
1682
|
|
|
@@ -1402,7 +1716,7 @@ static gc(className): void;
|
|
|
1402
1716
|
|
|
1403
1717
|
##### className
|
|
1404
1718
|
|
|
1405
|
-
`
|
|
1719
|
+
`BaseClassName`
|
|
1406
1720
|
|
|
1407
1721
|
#### Returns
|
|
1408
1722
|
|
|
@@ -1424,7 +1738,7 @@ static instanceCount(className): number;
|
|
|
1424
1738
|
|
|
1425
1739
|
#### className
|
|
1426
1740
|
|
|
1427
|
-
`
|
|
1741
|
+
`BaseClassName`
|
|
1428
1742
|
|
|
1429
1743
|
### Returns
|
|
1430
1744
|
|
|
@@ -1487,9 +1801,12 @@ static stopHistory(): void;
|
|
|
1487
1801
|
### create()
|
|
1488
1802
|
|
|
1489
1803
|
```ts
|
|
1490
|
-
static create<T>(this, inParams): Promise<T>;
|
|
1804
|
+
static create<T>(this, inParams?): Promise<T>;
|
|
1491
1805
|
```
|
|
1492
1806
|
|
|
1807
|
+
Asynchronously creates a new instance by processing params, constructing,
|
|
1808
|
+
and running both static and instance createHandlers.
|
|
1809
|
+
|
|
1493
1810
|
### Type Parameters
|
|
1494
1811
|
|
|
1495
1812
|
#### T
|
|
@@ -1502,14 +1819,18 @@ static create<T>(this, inParams): Promise<T>;
|
|
|
1502
1819
|
|
|
1503
1820
|
[`Creatable`](#../interfaces/Creatable)\<`T`\>
|
|
1504
1821
|
|
|
1505
|
-
#### inParams
|
|
1822
|
+
#### inParams?
|
|
1506
1823
|
|
|
1507
1824
|
`Partial`\<`T`\[`"params"`\]\> = `{}`
|
|
1508
1825
|
|
|
1826
|
+
Optional partial parameters to configure the instance
|
|
1827
|
+
|
|
1509
1828
|
### Returns
|
|
1510
1829
|
|
|
1511
1830
|
`Promise`\<`T`\>
|
|
1512
1831
|
|
|
1832
|
+
The fully initialized instance
|
|
1833
|
+
|
|
1513
1834
|
### Inherited from
|
|
1514
1835
|
|
|
1515
1836
|
[`AbstractCreatable`](#AbstractCreatable).[`create`](AbstractCreatable.md#create)
|
|
@@ -1522,6 +1843,9 @@ static create<T>(this, inParams): Promise<T>;
|
|
|
1522
1843
|
static createHandler<T>(this, instance): Promisable<T>;
|
|
1523
1844
|
```
|
|
1524
1845
|
|
|
1846
|
+
Static hook called during creation to perform additional initialization.
|
|
1847
|
+
Override in subclasses to customize post-construction setup.
|
|
1848
|
+
|
|
1525
1849
|
### Type Parameters
|
|
1526
1850
|
|
|
1527
1851
|
#### T
|
|
@@ -1538,10 +1862,14 @@ static createHandler<T>(this, instance): Promisable<T>;
|
|
|
1538
1862
|
|
|
1539
1863
|
`T`
|
|
1540
1864
|
|
|
1865
|
+
The newly constructed instance
|
|
1866
|
+
|
|
1541
1867
|
### Returns
|
|
1542
1868
|
|
|
1543
1869
|
`Promisable`\<`T`\>
|
|
1544
1870
|
|
|
1871
|
+
The instance, potentially modified
|
|
1872
|
+
|
|
1545
1873
|
### Inherited from
|
|
1546
1874
|
|
|
1547
1875
|
[`AbstractCreatable`](#AbstractCreatable).[`createHandler`](AbstractCreatable.md#createhandler)
|
|
@@ -1551,9 +1879,12 @@ static createHandler<T>(this, instance): Promisable<T>;
|
|
|
1551
1879
|
### paramsHandler()
|
|
1552
1880
|
|
|
1553
1881
|
```ts
|
|
1554
|
-
static paramsHandler<T>(this, params): Promisable<T["params"]>;
|
|
1882
|
+
static paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
1555
1883
|
```
|
|
1556
1884
|
|
|
1885
|
+
Static hook called during creation to validate and transform params.
|
|
1886
|
+
Override in subclasses to add default values or validation.
|
|
1887
|
+
|
|
1557
1888
|
### Type Parameters
|
|
1558
1889
|
|
|
1559
1890
|
#### T
|
|
@@ -1566,109 +1897,335 @@ static paramsHandler<T>(this, params): Promisable<T["params"]>;
|
|
|
1566
1897
|
|
|
1567
1898
|
[`Creatable`](#../interfaces/Creatable)\<`T`\>
|
|
1568
1899
|
|
|
1569
|
-
#### params
|
|
1900
|
+
#### params?
|
|
1570
1901
|
|
|
1571
1902
|
`Partial`\<`T`\[`"params"`\]\> = `{}`
|
|
1572
1903
|
|
|
1904
|
+
The raw partial params provided to `create`
|
|
1905
|
+
|
|
1906
|
+
### Returns
|
|
1907
|
+
|
|
1908
|
+
`Promisable`\<`T`\[`"params"`\]\>
|
|
1909
|
+
|
|
1910
|
+
The processed params ready for construction
|
|
1911
|
+
|
|
1912
|
+
### Inherited from
|
|
1913
|
+
|
|
1914
|
+
[`AbstractCreatable`](#AbstractCreatable).[`paramsHandler`](AbstractCreatable.md#paramshandler)
|
|
1915
|
+
|
|
1916
|
+
***
|
|
1917
|
+
|
|
1918
|
+
### createHandler()
|
|
1919
|
+
|
|
1920
|
+
```ts
|
|
1921
|
+
createHandler(): Promisable<void>;
|
|
1922
|
+
```
|
|
1923
|
+
|
|
1924
|
+
Instance-level creation hook. Override in subclasses to perform setup after construction.
|
|
1925
|
+
|
|
1926
|
+
### Returns
|
|
1927
|
+
|
|
1928
|
+
`Promisable`\<`void`\>
|
|
1929
|
+
|
|
1930
|
+
### Inherited from
|
|
1931
|
+
|
|
1932
|
+
[`AbstractCreatable`](#AbstractCreatable).[`createHandler`](AbstractCreatable.md#createhandler-1)
|
|
1933
|
+
|
|
1934
|
+
***
|
|
1935
|
+
|
|
1936
|
+
### paramsValidator()
|
|
1937
|
+
|
|
1938
|
+
```ts
|
|
1939
|
+
paramsValidator(params): TParams & RequiredCreatableParams<void>;
|
|
1940
|
+
```
|
|
1941
|
+
|
|
1942
|
+
Validates and returns the merged params, ensuring required fields are present.
|
|
1943
|
+
Override in subclasses to add custom validation logic.
|
|
1944
|
+
|
|
1945
|
+
### Parameters
|
|
1946
|
+
|
|
1947
|
+
#### params
|
|
1948
|
+
|
|
1949
|
+
`Partial`\<`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\>
|
|
1950
|
+
|
|
1951
|
+
The raw partial params to validate
|
|
1952
|
+
|
|
1953
|
+
### Returns
|
|
1954
|
+
|
|
1955
|
+
`TParams` & [`RequiredCreatableParams`](#../interfaces/RequiredCreatableParams)\<`void`\>
|
|
1956
|
+
|
|
1957
|
+
The validated params
|
|
1958
|
+
|
|
1959
|
+
### Inherited from
|
|
1960
|
+
|
|
1961
|
+
[`AbstractCreatable`](#AbstractCreatable).[`paramsValidator`](AbstractCreatable.md#paramsvalidator)
|
|
1962
|
+
|
|
1963
|
+
***
|
|
1964
|
+
|
|
1965
|
+
### span()
|
|
1966
|
+
|
|
1967
|
+
```ts
|
|
1968
|
+
span<T>(name, fn): T;
|
|
1969
|
+
```
|
|
1970
|
+
|
|
1971
|
+
Executes a function within a telemetry span.
|
|
1972
|
+
|
|
1973
|
+
### Type Parameters
|
|
1974
|
+
|
|
1975
|
+
#### T
|
|
1976
|
+
|
|
1977
|
+
`T`
|
|
1978
|
+
|
|
1979
|
+
### Parameters
|
|
1980
|
+
|
|
1981
|
+
#### name
|
|
1982
|
+
|
|
1983
|
+
`string`
|
|
1984
|
+
|
|
1985
|
+
The span name
|
|
1986
|
+
|
|
1987
|
+
#### fn
|
|
1988
|
+
|
|
1989
|
+
() => `T`
|
|
1990
|
+
|
|
1991
|
+
The function to execute within the span
|
|
1992
|
+
|
|
1993
|
+
### Returns
|
|
1994
|
+
|
|
1995
|
+
`T`
|
|
1996
|
+
|
|
1997
|
+
### Inherited from
|
|
1998
|
+
|
|
1999
|
+
[`AbstractCreatable`](#AbstractCreatable).[`span`](AbstractCreatable.md#span)
|
|
2000
|
+
|
|
2001
|
+
***
|
|
2002
|
+
|
|
2003
|
+
### spanAsync()
|
|
2004
|
+
|
|
2005
|
+
```ts
|
|
2006
|
+
spanAsync<T>(
|
|
2007
|
+
name,
|
|
2008
|
+
fn,
|
|
2009
|
+
config?): Promise<T>;
|
|
2010
|
+
```
|
|
2011
|
+
|
|
2012
|
+
Executes an async function within a telemetry span.
|
|
2013
|
+
|
|
2014
|
+
### Type Parameters
|
|
2015
|
+
|
|
2016
|
+
#### T
|
|
2017
|
+
|
|
2018
|
+
`T`
|
|
2019
|
+
|
|
2020
|
+
### Parameters
|
|
2021
|
+
|
|
2022
|
+
#### name
|
|
2023
|
+
|
|
2024
|
+
`string`
|
|
2025
|
+
|
|
2026
|
+
The span name
|
|
2027
|
+
|
|
2028
|
+
#### fn
|
|
2029
|
+
|
|
2030
|
+
() => `Promise`\<`T`\>
|
|
2031
|
+
|
|
2032
|
+
The async function to execute within the span
|
|
2033
|
+
|
|
2034
|
+
#### config?
|
|
2035
|
+
|
|
2036
|
+
`SpanConfig` = `{}`
|
|
2037
|
+
|
|
2038
|
+
Optional span configuration
|
|
2039
|
+
|
|
2040
|
+
### Returns
|
|
2041
|
+
|
|
2042
|
+
`Promise`\<`T`\>
|
|
2043
|
+
|
|
2044
|
+
### Inherited from
|
|
2045
|
+
|
|
2046
|
+
[`AbstractCreatable`](#AbstractCreatable).[`spanAsync`](AbstractCreatable.md#spanasync)
|
|
2047
|
+
|
|
2048
|
+
***
|
|
2049
|
+
|
|
2050
|
+
### start()
|
|
2051
|
+
|
|
2052
|
+
```ts
|
|
2053
|
+
start(): Promise<boolean>;
|
|
2054
|
+
```
|
|
2055
|
+
|
|
2056
|
+
Starts the instance, transitioning through 'starting' to 'started' status.
|
|
2057
|
+
Thread-safe via mutex. Returns true if already started or started successfully.
|
|
2058
|
+
|
|
2059
|
+
### Returns
|
|
2060
|
+
|
|
2061
|
+
`Promise`\<`boolean`\>
|
|
2062
|
+
|
|
2063
|
+
### Inherited from
|
|
2064
|
+
|
|
2065
|
+
[`AbstractCreatable`](#AbstractCreatable).[`start`](AbstractCreatable.md#start)
|
|
2066
|
+
|
|
2067
|
+
***
|
|
2068
|
+
|
|
2069
|
+
### started()
|
|
2070
|
+
|
|
2071
|
+
```ts
|
|
2072
|
+
started(notStartedAction?): boolean;
|
|
2073
|
+
```
|
|
2074
|
+
|
|
2075
|
+
Checks whether this instance is currently started.
|
|
2076
|
+
Takes an action if not started, based on the notStartedAction parameter.
|
|
2077
|
+
|
|
2078
|
+
### Parameters
|
|
2079
|
+
|
|
2080
|
+
#### notStartedAction?
|
|
2081
|
+
|
|
2082
|
+
What to do if not started: 'error'/'throw' throws, 'warn'/'log' logs, 'none' is silent
|
|
2083
|
+
|
|
2084
|
+
`"error"` | `"throw"` | `"warn"` | `"log"` | `"none"`
|
|
2085
|
+
|
|
2086
|
+
### Returns
|
|
2087
|
+
|
|
2088
|
+
`boolean`
|
|
2089
|
+
|
|
2090
|
+
True if started, false otherwise
|
|
2091
|
+
|
|
2092
|
+
### Inherited from
|
|
2093
|
+
|
|
2094
|
+
[`AbstractCreatable`](#AbstractCreatable).[`started`](AbstractCreatable.md#started)
|
|
2095
|
+
|
|
2096
|
+
***
|
|
2097
|
+
|
|
2098
|
+
### startedAsync()
|
|
2099
|
+
|
|
2100
|
+
```ts
|
|
2101
|
+
startedAsync(notStartedAction?, tryStart?): Promise<boolean>;
|
|
2102
|
+
```
|
|
2103
|
+
|
|
2104
|
+
Async version of `started` that can optionally auto-start the instance.
|
|
2105
|
+
|
|
2106
|
+
### Parameters
|
|
2107
|
+
|
|
2108
|
+
#### notStartedAction?
|
|
2109
|
+
|
|
2110
|
+
What to do if not started and auto-start is disabled
|
|
2111
|
+
|
|
2112
|
+
`"error"` | `"throw"` | `"warn"` | `"log"` | `"none"`
|
|
2113
|
+
|
|
2114
|
+
#### tryStart?
|
|
2115
|
+
|
|
2116
|
+
`boolean` = `true`
|
|
2117
|
+
|
|
2118
|
+
If true, attempts to start the instance automatically
|
|
2119
|
+
|
|
1573
2120
|
### Returns
|
|
1574
2121
|
|
|
1575
|
-
`
|
|
2122
|
+
`Promise`\<`boolean`\>
|
|
2123
|
+
|
|
2124
|
+
True if the instance is or becomes started
|
|
1576
2125
|
|
|
1577
2126
|
### Inherited from
|
|
1578
2127
|
|
|
1579
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
2128
|
+
[`AbstractCreatable`](#AbstractCreatable).[`startedAsync`](AbstractCreatable.md#startedasync)
|
|
1580
2129
|
|
|
1581
2130
|
***
|
|
1582
2131
|
|
|
1583
|
-
###
|
|
2132
|
+
### stop()
|
|
1584
2133
|
|
|
1585
2134
|
```ts
|
|
1586
|
-
|
|
2135
|
+
stop(): Promise<boolean>;
|
|
1587
2136
|
```
|
|
1588
2137
|
|
|
2138
|
+
Stops the instance, transitioning through 'stopping' to 'stopped' status.
|
|
2139
|
+
Thread-safe via mutex. Returns true if already stopped or stopped successfully.
|
|
2140
|
+
|
|
1589
2141
|
### Returns
|
|
1590
2142
|
|
|
1591
|
-
`
|
|
2143
|
+
`Promise`\<`boolean`\>
|
|
1592
2144
|
|
|
1593
2145
|
### Inherited from
|
|
1594
2146
|
|
|
1595
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
2147
|
+
[`AbstractCreatable`](#AbstractCreatable).[`stop`](AbstractCreatable.md#stop)
|
|
1596
2148
|
|
|
1597
2149
|
***
|
|
1598
2150
|
|
|
1599
|
-
###
|
|
2151
|
+
### \_noOverride()
|
|
1600
2152
|
|
|
1601
2153
|
```ts
|
|
1602
|
-
|
|
2154
|
+
protected _noOverride(functionName?): void;
|
|
1603
2155
|
```
|
|
1604
2156
|
|
|
2157
|
+
Asserts that the given function has not been overridden in a subclass.
|
|
2158
|
+
Used to enforce the handler pattern (override `startHandler` not `start`).
|
|
2159
|
+
|
|
1605
2160
|
### Parameters
|
|
1606
2161
|
|
|
1607
|
-
####
|
|
2162
|
+
#### functionName?
|
|
1608
2163
|
|
|
1609
|
-
`
|
|
2164
|
+
`string` = `...`
|
|
1610
2165
|
|
|
1611
2166
|
### Returns
|
|
1612
2167
|
|
|
1613
|
-
`
|
|
2168
|
+
`void`
|
|
1614
2169
|
|
|
1615
2170
|
### Inherited from
|
|
1616
2171
|
|
|
1617
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
2172
|
+
[`AbstractCreatable`](#AbstractCreatable).[`_noOverride`](AbstractCreatable.md#_nooverride)
|
|
1618
2173
|
|
|
1619
2174
|
***
|
|
1620
2175
|
|
|
1621
|
-
###
|
|
2176
|
+
### setStatus()
|
|
2177
|
+
|
|
2178
|
+
### Call Signature
|
|
1622
2179
|
|
|
1623
2180
|
```ts
|
|
1624
|
-
|
|
2181
|
+
protected setStatus(value, progress?): void;
|
|
1625
2182
|
```
|
|
1626
2183
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
`Promise`\<`boolean`\>
|
|
1630
|
-
|
|
1631
|
-
### Inherited from
|
|
2184
|
+
Sets the lifecycle status and reports it via the status reporter.
|
|
1632
2185
|
|
|
1633
|
-
|
|
2186
|
+
#### Parameters
|
|
1634
2187
|
|
|
1635
|
-
|
|
2188
|
+
##### value
|
|
1636
2189
|
|
|
1637
|
-
|
|
2190
|
+
`"creating"` | `"created"` | `"starting"` | `"started"` | `"stopping"` | `"stopped"`
|
|
1638
2191
|
|
|
1639
|
-
|
|
1640
|
-
stop(): Promise<boolean>;
|
|
1641
|
-
```
|
|
2192
|
+
##### progress?
|
|
1642
2193
|
|
|
1643
|
-
|
|
2194
|
+
`number`
|
|
1644
2195
|
|
|
1645
|
-
|
|
2196
|
+
#### Returns
|
|
1646
2197
|
|
|
1647
|
-
|
|
2198
|
+
`void`
|
|
1648
2199
|
|
|
1649
|
-
|
|
2200
|
+
#### Inherited from
|
|
1650
2201
|
|
|
1651
|
-
|
|
2202
|
+
[`AbstractCreatable`](#AbstractCreatable).[`setStatus`](AbstractCreatable.md#setstatus)
|
|
1652
2203
|
|
|
1653
|
-
###
|
|
2204
|
+
### Call Signature
|
|
1654
2205
|
|
|
1655
2206
|
```ts
|
|
1656
|
-
protected
|
|
2207
|
+
protected setStatus(value, error?): void;
|
|
1657
2208
|
```
|
|
1658
2209
|
|
|
1659
|
-
|
|
2210
|
+
Sets the lifecycle status and reports it via the status reporter.
|
|
1660
2211
|
|
|
1661
|
-
####
|
|
2212
|
+
#### Parameters
|
|
1662
2213
|
|
|
1663
|
-
|
|
2214
|
+
##### value
|
|
1664
2215
|
|
|
1665
|
-
|
|
2216
|
+
`"error"`
|
|
2217
|
+
|
|
2218
|
+
##### error?
|
|
2219
|
+
|
|
2220
|
+
`Error`
|
|
2221
|
+
|
|
2222
|
+
#### Returns
|
|
1666
2223
|
|
|
1667
2224
|
`void`
|
|
1668
2225
|
|
|
1669
|
-
|
|
2226
|
+
#### Inherited from
|
|
1670
2227
|
|
|
1671
|
-
[`AbstractCreatable`](#AbstractCreatable).[`
|
|
2228
|
+
[`AbstractCreatable`](#AbstractCreatable).[`setStatus`](AbstractCreatable.md#setstatus)
|
|
1672
2229
|
|
|
1673
2230
|
***
|
|
1674
2231
|
|
|
@@ -1678,6 +2235,8 @@ protected _noOverride(functionName): void;
|
|
|
1678
2235
|
protected startHandler(): Promisable<void>;
|
|
1679
2236
|
```
|
|
1680
2237
|
|
|
2238
|
+
Override in subclasses to define start behavior. Throw an error on failure.
|
|
2239
|
+
|
|
1681
2240
|
### Returns
|
|
1682
2241
|
|
|
1683
2242
|
`Promisable`\<`void`\>
|
|
@@ -1694,6 +2253,8 @@ protected startHandler(): Promisable<void>;
|
|
|
1694
2253
|
protected stopHandler(): Promisable<void>;
|
|
1695
2254
|
```
|
|
1696
2255
|
|
|
2256
|
+
Override in subclasses to define stop behavior. Throw an error on failure.
|
|
2257
|
+
|
|
1697
2258
|
### Returns
|
|
1698
2259
|
|
|
1699
2260
|
`Promisable`\<`void`\>
|
|
@@ -1713,6 +2274,8 @@ static factory<T>(
|
|
|
1713
2274
|
labels?): CreatableFactory<T>;
|
|
1714
2275
|
```
|
|
1715
2276
|
|
|
2277
|
+
Creates a factory that produces instances of this class with pre-configured params and labels.
|
|
2278
|
+
|
|
1716
2279
|
### Type Parameters
|
|
1717
2280
|
|
|
1718
2281
|
#### T
|
|
@@ -1729,10 +2292,14 @@ labels?): CreatableFactory<T>;
|
|
|
1729
2292
|
|
|
1730
2293
|
`Partial`\<`T`\[`"params"`\]\>
|
|
1731
2294
|
|
|
2295
|
+
Default parameters for instances created by the factory
|
|
2296
|
+
|
|
1732
2297
|
#### labels?
|
|
1733
2298
|
|
|
1734
2299
|
[`Labels`](#../interfaces/Labels)
|
|
1735
2300
|
|
|
2301
|
+
Labels to assign to created instances
|
|
2302
|
+
|
|
1736
2303
|
### Returns
|
|
1737
2304
|
|
|
1738
2305
|
[`CreatableFactory`](#../interfaces/CreatableFactory)\<`T`\>
|
|
@@ -2017,6 +2584,9 @@ once<TEventName>(eventName, listener): () => void;
|
|
|
2017
2584
|
|
|
2018
2585
|
***
|
|
2019
2586
|
|
|
2587
|
+
A concrete factory that wraps a Creatable class with default parameters and labels.
|
|
2588
|
+
Instances are created by merging caller-provided params over the factory defaults.
|
|
2589
|
+
|
|
2020
2590
|
## Type Parameters
|
|
2021
2591
|
|
|
2022
2592
|
### T
|
|
@@ -2064,6 +2634,8 @@ labels?): Factory<T>;
|
|
|
2064
2634
|
creatable: Creatable<T>;
|
|
2065
2635
|
```
|
|
2066
2636
|
|
|
2637
|
+
The Creatable class this factory delegates creation to.
|
|
2638
|
+
|
|
2067
2639
|
***
|
|
2068
2640
|
|
|
2069
2641
|
### defaultParams?
|
|
@@ -2072,6 +2644,8 @@ creatable: Creatable<T>;
|
|
|
2072
2644
|
optional defaultParams: Partial<T["params"]>;
|
|
2073
2645
|
```
|
|
2074
2646
|
|
|
2647
|
+
Default parameters merged into every `create` call.
|
|
2648
|
+
|
|
2075
2649
|
***
|
|
2076
2650
|
|
|
2077
2651
|
### labels?
|
|
@@ -2080,6 +2654,8 @@ optional defaultParams: Partial<T["params"]>;
|
|
|
2080
2654
|
optional labels: Labels;
|
|
2081
2655
|
```
|
|
2082
2656
|
|
|
2657
|
+
Labels identifying resources created by this factory.
|
|
2658
|
+
|
|
2083
2659
|
## Methods
|
|
2084
2660
|
|
|
2085
2661
|
### withParams()
|
|
@@ -2091,6 +2667,8 @@ static withParams<T>(
|
|
|
2091
2667
|
labels?): Factory<T>;
|
|
2092
2668
|
```
|
|
2093
2669
|
|
|
2670
|
+
Creates a new Factory instance with the given default params and labels.
|
|
2671
|
+
|
|
2094
2672
|
### Type Parameters
|
|
2095
2673
|
|
|
2096
2674
|
#### T
|
|
@@ -2103,14 +2681,20 @@ labels?): Factory<T>;
|
|
|
2103
2681
|
|
|
2104
2682
|
[`Creatable`](#../interfaces/Creatable)\<`T`\>
|
|
2105
2683
|
|
|
2684
|
+
The Creatable class to wrap
|
|
2685
|
+
|
|
2106
2686
|
#### params?
|
|
2107
2687
|
|
|
2108
2688
|
`Partial`\<`T`\[`"params"`\]\>
|
|
2109
2689
|
|
|
2690
|
+
Default parameters for new instances
|
|
2691
|
+
|
|
2110
2692
|
#### labels?
|
|
2111
2693
|
|
|
2112
2694
|
[`Labels`](#../interfaces/Labels) = `{}`
|
|
2113
2695
|
|
|
2696
|
+
Labels to assign to created instances
|
|
2697
|
+
|
|
2114
2698
|
### Returns
|
|
2115
2699
|
|
|
2116
2700
|
`Factory`\<`T`\>
|
|
@@ -2123,12 +2707,16 @@ labels?): Factory<T>;
|
|
|
2123
2707
|
create(params?): Promise<T>;
|
|
2124
2708
|
```
|
|
2125
2709
|
|
|
2710
|
+
Creates a new instance, merging the provided params over the factory defaults.
|
|
2711
|
+
|
|
2126
2712
|
### Parameters
|
|
2127
2713
|
|
|
2128
2714
|
#### params?
|
|
2129
2715
|
|
|
2130
2716
|
`Partial`\<`T`\[`"params"`\]\>
|
|
2131
2717
|
|
|
2718
|
+
Optional parameters to override the factory defaults
|
|
2719
|
+
|
|
2132
2720
|
### Returns
|
|
2133
2721
|
|
|
2134
2722
|
`Promise`\<`T`\>
|
|
@@ -2261,6 +2849,10 @@ True of the source object has all the labels from the required set
|
|
|
2261
2849
|
|
|
2262
2850
|
***
|
|
2263
2851
|
|
|
2852
|
+
Static interface for classes that support asynchronous creation.
|
|
2853
|
+
Provides the `create`, `createHandler`, and `paramsHandler` static methods
|
|
2854
|
+
used to construct instances through the creatable lifecycle.
|
|
2855
|
+
|
|
2264
2856
|
## Extended by
|
|
2265
2857
|
|
|
2266
2858
|
- [`CreatableWithFactory`](#CreatableWithFactory)
|
|
@@ -2279,6 +2871,8 @@ True of the source object has all the labels from the required set
|
|
|
2279
2871
|
new Creatable(key, params): T & AbstractCreatable<T["params"], EventData>;
|
|
2280
2872
|
```
|
|
2281
2873
|
|
|
2874
|
+
Constructs a new raw instance. Should not be called directly; use `create` instead.
|
|
2875
|
+
|
|
2282
2876
|
### Parameters
|
|
2283
2877
|
|
|
2284
2878
|
#### key
|
|
@@ -2301,6 +2895,8 @@ new Creatable(key, params): T & AbstractCreatable<T["params"], EventData>;
|
|
|
2301
2895
|
optional defaultLogger: Logger;
|
|
2302
2896
|
```
|
|
2303
2897
|
|
|
2898
|
+
Optional default logger shared across instances created by this class.
|
|
2899
|
+
|
|
2304
2900
|
## Methods
|
|
2305
2901
|
|
|
2306
2902
|
### create()
|
|
@@ -2309,6 +2905,8 @@ optional defaultLogger: Logger;
|
|
|
2309
2905
|
create<T>(this, params?): Promise<T>;
|
|
2310
2906
|
```
|
|
2311
2907
|
|
|
2908
|
+
Asynchronously creates and initializes a new instance with the given params.
|
|
2909
|
+
|
|
2312
2910
|
### Type Parameters
|
|
2313
2911
|
|
|
2314
2912
|
#### T
|
|
@@ -2337,6 +2935,8 @@ create<T>(this, params?): Promise<T>;
|
|
|
2337
2935
|
createHandler<T>(this, instance): Promisable<T>;
|
|
2338
2936
|
```
|
|
2339
2937
|
|
|
2938
|
+
Hook called after construction to perform additional initialization on the instance.
|
|
2939
|
+
|
|
2340
2940
|
### Type Parameters
|
|
2341
2941
|
|
|
2342
2942
|
#### T
|
|
@@ -2362,9 +2962,11 @@ createHandler<T>(this, instance): Promisable<T>;
|
|
|
2362
2962
|
### paramsHandler()
|
|
2363
2963
|
|
|
2364
2964
|
```ts
|
|
2365
|
-
paramsHandler<T>(this, params?): Promisable<T["params"]
|
|
2965
|
+
paramsHandler<T>(this, params?): Promisable<T["params"] & RequiredCreatableParams<void>>;
|
|
2366
2966
|
```
|
|
2367
2967
|
|
|
2968
|
+
Hook called to validate and transform params before instance construction.
|
|
2969
|
+
|
|
2368
2970
|
### Type Parameters
|
|
2369
2971
|
|
|
2370
2972
|
#### T
|
|
@@ -2383,7 +2985,7 @@ paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
|
2383
2985
|
|
|
2384
2986
|
### Returns
|
|
2385
2987
|
|
|
2386
|
-
`Promisable`\<`T`\[`"params"`\]
|
|
2988
|
+
`Promisable`\<`T`\[`"params"`\] & [`RequiredCreatableParams`](#RequiredCreatableParams)\<`void`\>\>
|
|
2387
2989
|
|
|
2388
2990
|
### <a id="CreatableFactory"></a>CreatableFactory
|
|
2389
2991
|
|
|
@@ -2391,6 +2993,9 @@ paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
|
2391
2993
|
|
|
2392
2994
|
***
|
|
2393
2995
|
|
|
2996
|
+
A factory interface for creating instances of a Creatable with pre-configured parameters.
|
|
2997
|
+
Unlike the full Creatable, this only exposes the `create` method.
|
|
2998
|
+
|
|
2394
2999
|
## Extends
|
|
2395
3000
|
|
|
2396
3001
|
- `Omit`\<[`Creatable`](#Creatable)\<`T`\>,
|
|
@@ -2414,6 +3019,8 @@ paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
|
2414
3019
|
create(this, params?): Promise<T>;
|
|
2415
3020
|
```
|
|
2416
3021
|
|
|
3022
|
+
Creates a new instance, merging the provided params with the factory's defaults.
|
|
3023
|
+
|
|
2417
3024
|
### Parameters
|
|
2418
3025
|
|
|
2419
3026
|
#### this
|
|
@@ -2434,6 +3041,8 @@ create(this, params?): Promise<T>;
|
|
|
2434
3041
|
|
|
2435
3042
|
***
|
|
2436
3043
|
|
|
3044
|
+
Represents a created instance with a managed lifecycle (start/stop) and event emission.
|
|
3045
|
+
|
|
2437
3046
|
## Extends
|
|
2438
3047
|
|
|
2439
3048
|
- `EventEmitter`\<`TEventData`\>
|
|
@@ -2456,6 +3065,8 @@ create(this, params?): Promise<T>;
|
|
|
2456
3065
|
eventData: TEventData;
|
|
2457
3066
|
```
|
|
2458
3067
|
|
|
3068
|
+
The event data type associated with this instance.
|
|
3069
|
+
|
|
2459
3070
|
### Overrides
|
|
2460
3071
|
|
|
2461
3072
|
```ts
|
|
@@ -2467,9 +3078,11 @@ EventEmitter.eventData
|
|
|
2467
3078
|
### name
|
|
2468
3079
|
|
|
2469
3080
|
```ts
|
|
2470
|
-
name:
|
|
3081
|
+
name: CreatableName;
|
|
2471
3082
|
```
|
|
2472
3083
|
|
|
3084
|
+
The name identifier for this instance.
|
|
3085
|
+
|
|
2473
3086
|
***
|
|
2474
3087
|
|
|
2475
3088
|
### params
|
|
@@ -2478,6 +3091,36 @@ name: string;
|
|
|
2478
3091
|
params: TParams;
|
|
2479
3092
|
```
|
|
2480
3093
|
|
|
3094
|
+
The parameters used to configure this instance.
|
|
3095
|
+
|
|
3096
|
+
***
|
|
3097
|
+
|
|
3098
|
+
### start()
|
|
3099
|
+
|
|
3100
|
+
```ts
|
|
3101
|
+
start: () => Promise<boolean>;
|
|
3102
|
+
```
|
|
3103
|
+
|
|
3104
|
+
Starts the instance. Resolves to true if started successfully.
|
|
3105
|
+
|
|
3106
|
+
### Returns
|
|
3107
|
+
|
|
3108
|
+
`Promise`\<`boolean`\>
|
|
3109
|
+
|
|
3110
|
+
***
|
|
3111
|
+
|
|
3112
|
+
### stop()
|
|
3113
|
+
|
|
3114
|
+
```ts
|
|
3115
|
+
stop: () => Promise<boolean>;
|
|
3116
|
+
```
|
|
3117
|
+
|
|
3118
|
+
Stops the instance. Resolves to true if stopped successfully.
|
|
3119
|
+
|
|
3120
|
+
### Returns
|
|
3121
|
+
|
|
3122
|
+
`Promise`\<`boolean`\>
|
|
3123
|
+
|
|
2481
3124
|
## Methods
|
|
2482
3125
|
|
|
2483
3126
|
### clearListeners()
|
|
@@ -2750,9 +3393,11 @@ EventEmitter.once
|
|
|
2750
3393
|
|
|
2751
3394
|
***
|
|
2752
3395
|
|
|
3396
|
+
Parameters for creating a creatable instance, combining required params with emitter params.
|
|
3397
|
+
|
|
2753
3398
|
## Extends
|
|
2754
3399
|
|
|
2755
|
-
- `BaseEmitterParams`
|
|
3400
|
+
- [`RequiredCreatableParams`](#RequiredCreatableParams).`BaseEmitterParams`
|
|
2756
3401
|
|
|
2757
3402
|
## Properties
|
|
2758
3403
|
|
|
@@ -2764,9 +3409,7 @@ optional logger: Logger;
|
|
|
2764
3409
|
|
|
2765
3410
|
### Inherited from
|
|
2766
3411
|
|
|
2767
|
-
|
|
2768
|
-
BaseEmitterParams.logger
|
|
2769
|
-
```
|
|
3412
|
+
[`RequiredCreatableParams`](#RequiredCreatableParams).[`logger`](RequiredCreatableParams.md#logger)
|
|
2770
3413
|
|
|
2771
3414
|
***
|
|
2772
3415
|
|
|
@@ -2778,9 +3421,7 @@ optional meterProvider: MeterProvider;
|
|
|
2778
3421
|
|
|
2779
3422
|
### Inherited from
|
|
2780
3423
|
|
|
2781
|
-
|
|
2782
|
-
BaseEmitterParams.meterProvider
|
|
2783
|
-
```
|
|
3424
|
+
[`RequiredCreatableParams`](#RequiredCreatableParams).[`meterProvider`](RequiredCreatableParams.md#meterprovider)
|
|
2784
3425
|
|
|
2785
3426
|
***
|
|
2786
3427
|
|
|
@@ -2792,18 +3433,22 @@ optional traceProvider: TracerProvider;
|
|
|
2792
3433
|
|
|
2793
3434
|
### Inherited from
|
|
2794
3435
|
|
|
2795
|
-
|
|
2796
|
-
BaseEmitterParams.traceProvider
|
|
2797
|
-
```
|
|
3436
|
+
[`RequiredCreatableParams`](#RequiredCreatableParams).[`traceProvider`](RequiredCreatableParams.md#traceprovider)
|
|
2798
3437
|
|
|
2799
3438
|
***
|
|
2800
3439
|
|
|
2801
3440
|
### name?
|
|
2802
3441
|
|
|
2803
3442
|
```ts
|
|
2804
|
-
optional name:
|
|
3443
|
+
optional name: CreatableName;
|
|
2805
3444
|
```
|
|
2806
3445
|
|
|
3446
|
+
Optional name identifying this creatable instance.
|
|
3447
|
+
|
|
3448
|
+
### Inherited from
|
|
3449
|
+
|
|
3450
|
+
[`RequiredCreatableParams`](#RequiredCreatableParams).[`name`](RequiredCreatableParams.md#name)
|
|
3451
|
+
|
|
2807
3452
|
***
|
|
2808
3453
|
|
|
2809
3454
|
### statusReporter?
|
|
@@ -2812,17 +3457,25 @@ optional name: string;
|
|
|
2812
3457
|
optional statusReporter: CreatableStatusReporter<void>;
|
|
2813
3458
|
```
|
|
2814
3459
|
|
|
3460
|
+
Optional reporter for broadcasting status changes.
|
|
3461
|
+
|
|
3462
|
+
### Inherited from
|
|
3463
|
+
|
|
3464
|
+
[`RequiredCreatableParams`](#RequiredCreatableParams).[`statusReporter`](RequiredCreatableParams.md#statusreporter)
|
|
3465
|
+
|
|
2815
3466
|
### <a id="CreatableStatusReporter"></a>CreatableStatusReporter
|
|
2816
3467
|
|
|
2817
3468
|
[**@xylabs/creatable**](#../README)
|
|
2818
3469
|
|
|
2819
3470
|
***
|
|
2820
3471
|
|
|
3472
|
+
Reports status changes for a creatable, supporting progress tracking and error reporting.
|
|
3473
|
+
|
|
2821
3474
|
## Type Parameters
|
|
2822
3475
|
|
|
2823
|
-
###
|
|
3476
|
+
### TAdditionalStatus
|
|
2824
3477
|
|
|
2825
|
-
`
|
|
3478
|
+
`TAdditionalStatus` *extends* `void` \| `string` = `void`
|
|
2826
3479
|
|
|
2827
3480
|
## Methods
|
|
2828
3481
|
|
|
@@ -2834,20 +3487,22 @@ optional statusReporter: CreatableStatusReporter<void>;
|
|
|
2834
3487
|
report(
|
|
2835
3488
|
name,
|
|
2836
3489
|
status,
|
|
2837
|
-
progress
|
|
3490
|
+
progress): void;
|
|
2838
3491
|
```
|
|
2839
3492
|
|
|
3493
|
+
Report a non-error status with a numeric progress value.
|
|
3494
|
+
|
|
2840
3495
|
#### Parameters
|
|
2841
3496
|
|
|
2842
3497
|
##### name
|
|
2843
3498
|
|
|
2844
|
-
`
|
|
3499
|
+
`BaseClassName`
|
|
2845
3500
|
|
|
2846
3501
|
##### status
|
|
2847
3502
|
|
|
2848
|
-
`Exclude`\<`
|
|
3503
|
+
`"creating"` | `"created"` | `"starting"` | `"started"` | `"stopping"` | `"stopped"` | `Exclude`\<`TAdditionalStatus` *extends* `void` ? [`StandardCreatableStatus`](#../type-aliases/StandardCreatableStatus) : `TAdditionalStatus`, `"error"`\>
|
|
2849
3504
|
|
|
2850
|
-
##### progress
|
|
3505
|
+
##### progress
|
|
2851
3506
|
|
|
2852
3507
|
`number`
|
|
2853
3508
|
|
|
@@ -2861,25 +3516,49 @@ report(
|
|
|
2861
3516
|
report(
|
|
2862
3517
|
name,
|
|
2863
3518
|
status,
|
|
2864
|
-
error
|
|
3519
|
+
error): void;
|
|
2865
3520
|
```
|
|
2866
3521
|
|
|
3522
|
+
Report an error status with the associated Error.
|
|
3523
|
+
|
|
2867
3524
|
#### Parameters
|
|
2868
3525
|
|
|
2869
3526
|
##### name
|
|
2870
3527
|
|
|
2871
|
-
`
|
|
3528
|
+
`BaseClassName`
|
|
2872
3529
|
|
|
2873
3530
|
##### status
|
|
2874
3531
|
|
|
2875
|
-
`Extract`\<`
|
|
3532
|
+
`"error"` | `Extract`\<`TAdditionalStatus` *extends* `void` ? [`StandardCreatableStatus`](#../type-aliases/StandardCreatableStatus) : `TAdditionalStatus`, `"error"`\>
|
|
2876
3533
|
|
|
2877
|
-
##### error
|
|
3534
|
+
##### error
|
|
2878
3535
|
|
|
2879
3536
|
`Error`
|
|
2880
3537
|
|
|
2881
3538
|
#### Returns
|
|
2882
3539
|
|
|
3540
|
+
`void`
|
|
3541
|
+
|
|
3542
|
+
### Call Signature
|
|
3543
|
+
|
|
3544
|
+
```ts
|
|
3545
|
+
report(name, status): void;
|
|
3546
|
+
```
|
|
3547
|
+
|
|
3548
|
+
Report a status change without progress or error details.
|
|
3549
|
+
|
|
3550
|
+
#### Parameters
|
|
3551
|
+
|
|
3552
|
+
##### name
|
|
3553
|
+
|
|
3554
|
+
`BaseClassName`
|
|
3555
|
+
|
|
3556
|
+
##### status
|
|
3557
|
+
|
|
3558
|
+
[`CreatableStatus`](#../type-aliases/CreatableStatus)\<`TAdditionalStatus`\>
|
|
3559
|
+
|
|
3560
|
+
#### Returns
|
|
3561
|
+
|
|
2883
3562
|
`void`
|
|
2884
3563
|
|
|
2885
3564
|
### <a id="CreatableWithFactory"></a>CreatableWithFactory
|
|
@@ -2888,6 +3567,8 @@ report(
|
|
|
2888
3567
|
|
|
2889
3568
|
***
|
|
2890
3569
|
|
|
3570
|
+
Extends Creatable with a `factory` method that produces pre-configured CreatableFactory instances.
|
|
3571
|
+
|
|
2891
3572
|
## Extends
|
|
2892
3573
|
|
|
2893
3574
|
- [`Creatable`](#Creatable)\<`T`\>
|
|
@@ -2906,6 +3587,8 @@ report(
|
|
|
2906
3587
|
new CreatableWithFactory(key, params): T & AbstractCreatable<T["params"], EventData>;
|
|
2907
3588
|
```
|
|
2908
3589
|
|
|
3590
|
+
Constructs a new raw instance. Should not be called directly; use `create` instead.
|
|
3591
|
+
|
|
2909
3592
|
### Parameters
|
|
2910
3593
|
|
|
2911
3594
|
#### key
|
|
@@ -2932,6 +3615,8 @@ new CreatableWithFactory(key, params): T & AbstractCreatable<T["params"], EventD
|
|
|
2932
3615
|
optional defaultLogger: Logger;
|
|
2933
3616
|
```
|
|
2934
3617
|
|
|
3618
|
+
Optional default logger shared across instances created by this class.
|
|
3619
|
+
|
|
2935
3620
|
### Inherited from
|
|
2936
3621
|
|
|
2937
3622
|
[`Creatable`](#Creatable).[`defaultLogger`](Creatable.md#defaultlogger)
|
|
@@ -2944,6 +3629,8 @@ optional defaultLogger: Logger;
|
|
|
2944
3629
|
create<T>(this, params?): Promise<T>;
|
|
2945
3630
|
```
|
|
2946
3631
|
|
|
3632
|
+
Asynchronously creates and initializes a new instance with the given params.
|
|
3633
|
+
|
|
2947
3634
|
### Type Parameters
|
|
2948
3635
|
|
|
2949
3636
|
#### T
|
|
@@ -2976,6 +3663,8 @@ create<T>(this, params?): Promise<T>;
|
|
|
2976
3663
|
createHandler<T>(this, instance): Promisable<T>;
|
|
2977
3664
|
```
|
|
2978
3665
|
|
|
3666
|
+
Hook called after construction to perform additional initialization on the instance.
|
|
3667
|
+
|
|
2979
3668
|
### Type Parameters
|
|
2980
3669
|
|
|
2981
3670
|
#### T
|
|
@@ -3005,9 +3694,11 @@ createHandler<T>(this, instance): Promisable<T>;
|
|
|
3005
3694
|
### paramsHandler()
|
|
3006
3695
|
|
|
3007
3696
|
```ts
|
|
3008
|
-
paramsHandler<T>(this, params?): Promisable<T["params"]
|
|
3697
|
+
paramsHandler<T>(this, params?): Promisable<T["params"] & RequiredCreatableParams<void>>;
|
|
3009
3698
|
```
|
|
3010
3699
|
|
|
3700
|
+
Hook called to validate and transform params before instance construction.
|
|
3701
|
+
|
|
3011
3702
|
### Type Parameters
|
|
3012
3703
|
|
|
3013
3704
|
#### T
|
|
@@ -3026,7 +3717,7 @@ paramsHandler<T>(this, params?): Promisable<T["params"]>;
|
|
|
3026
3717
|
|
|
3027
3718
|
### Returns
|
|
3028
3719
|
|
|
3029
|
-
`Promisable`\<`T`\[`"params"`\]
|
|
3720
|
+
`Promisable`\<`T`\[`"params"`\] & [`RequiredCreatableParams`](#RequiredCreatableParams)\<`void`\>\>
|
|
3030
3721
|
|
|
3031
3722
|
### Inherited from
|
|
3032
3723
|
|
|
@@ -3043,6 +3734,8 @@ factory<T>(
|
|
|
3043
3734
|
labels?): CreatableFactory<T>;
|
|
3044
3735
|
```
|
|
3045
3736
|
|
|
3737
|
+
Creates a factory with the given default params and labels.
|
|
3738
|
+
|
|
3046
3739
|
### Type Parameters
|
|
3047
3740
|
|
|
3048
3741
|
#### T
|
|
@@ -3078,9 +3771,93 @@ Object used to represent labels identifying a resource.
|
|
|
3078
3771
|
## Indexable
|
|
3079
3772
|
|
|
3080
3773
|
```ts
|
|
3081
|
-
[key: string]:
|
|
3774
|
+
[key: string]: string | undefined
|
|
3775
|
+
```
|
|
3776
|
+
|
|
3777
|
+
### <a id="RequiredCreatableParams"></a>RequiredCreatableParams
|
|
3778
|
+
|
|
3779
|
+
[**@xylabs/creatable**](#../README)
|
|
3780
|
+
|
|
3781
|
+
***
|
|
3782
|
+
|
|
3783
|
+
The minimum required parameters for constructing a creatable.
|
|
3784
|
+
|
|
3785
|
+
## Extends
|
|
3786
|
+
|
|
3787
|
+
- `BaseEmitterParams`
|
|
3788
|
+
|
|
3789
|
+
## Extended by
|
|
3790
|
+
|
|
3791
|
+
- [`CreatableParams`](#CreatableParams)
|
|
3792
|
+
|
|
3793
|
+
## Type Parameters
|
|
3794
|
+
|
|
3795
|
+
### TAdditionalStatus
|
|
3796
|
+
|
|
3797
|
+
`TAdditionalStatus` *extends* [`CreatableStatus`](#../type-aliases/CreatableStatus) \| `void` = `void`
|
|
3798
|
+
|
|
3799
|
+
## Properties
|
|
3800
|
+
|
|
3801
|
+
### logger?
|
|
3802
|
+
|
|
3803
|
+
```ts
|
|
3804
|
+
optional logger: Logger;
|
|
3805
|
+
```
|
|
3806
|
+
|
|
3807
|
+
### Inherited from
|
|
3808
|
+
|
|
3809
|
+
```ts
|
|
3810
|
+
BaseEmitterParams.logger
|
|
3811
|
+
```
|
|
3812
|
+
|
|
3813
|
+
***
|
|
3814
|
+
|
|
3815
|
+
### meterProvider?
|
|
3816
|
+
|
|
3817
|
+
```ts
|
|
3818
|
+
optional meterProvider: MeterProvider;
|
|
3819
|
+
```
|
|
3820
|
+
|
|
3821
|
+
### Inherited from
|
|
3822
|
+
|
|
3823
|
+
```ts
|
|
3824
|
+
BaseEmitterParams.meterProvider
|
|
3825
|
+
```
|
|
3826
|
+
|
|
3827
|
+
***
|
|
3828
|
+
|
|
3829
|
+
### traceProvider?
|
|
3830
|
+
|
|
3831
|
+
```ts
|
|
3832
|
+
optional traceProvider: TracerProvider;
|
|
3833
|
+
```
|
|
3834
|
+
|
|
3835
|
+
### Inherited from
|
|
3836
|
+
|
|
3837
|
+
```ts
|
|
3838
|
+
BaseEmitterParams.traceProvider
|
|
3839
|
+
```
|
|
3840
|
+
|
|
3841
|
+
***
|
|
3842
|
+
|
|
3843
|
+
### name?
|
|
3844
|
+
|
|
3845
|
+
```ts
|
|
3846
|
+
optional name: CreatableName;
|
|
3847
|
+
```
|
|
3848
|
+
|
|
3849
|
+
Optional name identifying this creatable instance.
|
|
3850
|
+
|
|
3851
|
+
***
|
|
3852
|
+
|
|
3853
|
+
### statusReporter?
|
|
3854
|
+
|
|
3855
|
+
```ts
|
|
3856
|
+
optional statusReporter: CreatableStatusReporter<TAdditionalStatus>;
|
|
3082
3857
|
```
|
|
3083
3858
|
|
|
3859
|
+
Optional reporter for broadcasting status changes.
|
|
3860
|
+
|
|
3084
3861
|
### <a id="WithLabels"></a>WithLabels
|
|
3085
3862
|
|
|
3086
3863
|
[**@xylabs/creatable**](#../README)
|
|
@@ -3137,6 +3914,8 @@ optional labels: T;
|
|
|
3137
3914
|
type CreatableName = Exclude<string, "creatable-name-reserved-32546239486"> & BaseClassName;
|
|
3138
3915
|
```
|
|
3139
3916
|
|
|
3917
|
+
A branded string type used as the name identifier for creatables.
|
|
3918
|
+
|
|
3140
3919
|
### <a id="CreatableStatus"></a>CreatableStatus
|
|
3141
3920
|
|
|
3142
3921
|
[**@xylabs/creatable**](#../README)
|
|
@@ -3144,7 +3923,27 @@ type CreatableName = Exclude<string, "creatable-name-reserved-32546239486"> & Ba
|
|
|
3144
3923
|
***
|
|
3145
3924
|
|
|
3146
3925
|
```ts
|
|
3147
|
-
type CreatableStatus =
|
|
3926
|
+
type CreatableStatus<TAdditionalStatus> =
|
|
3927
|
+
| StandardCreatableStatus
|
|
3928
|
+
| TAdditionalStatus extends void ? StandardCreatableStatus : TAdditionalStatus;
|
|
3929
|
+
```
|
|
3930
|
+
|
|
3931
|
+
A creatable's status, optionally extended with additional custom status values.
|
|
3932
|
+
|
|
3933
|
+
## Type Parameters
|
|
3934
|
+
|
|
3935
|
+
### TAdditionalStatus
|
|
3936
|
+
|
|
3937
|
+
`TAdditionalStatus` *extends* `void` \| `string` = `void`
|
|
3938
|
+
|
|
3939
|
+
### <a id="StandardCreatableStatus"></a>StandardCreatableStatus
|
|
3940
|
+
|
|
3941
|
+
[**@xylabs/creatable**](#../README)
|
|
3942
|
+
|
|
3943
|
+
***
|
|
3944
|
+
|
|
3945
|
+
```ts
|
|
3946
|
+
type StandardCreatableStatus =
|
|
3148
3947
|
| "creating"
|
|
3149
3948
|
| "created"
|
|
3150
3949
|
| "starting"
|
|
@@ -3154,6 +3953,8 @@ type CreatableStatus =
|
|
|
3154
3953
|
| "error";
|
|
3155
3954
|
```
|
|
3156
3955
|
|
|
3956
|
+
The standard lifecycle statuses a creatable can transition through.
|
|
3957
|
+
|
|
3157
3958
|
|
|
3158
3959
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
3159
3960
|
|