@twin.org/core 0.0.1-next.16 → 0.0.1-next.18
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/cjs/index.cjs +23 -0
- package/dist/esm/index.mjs +23 -0
- package/dist/types/factories/factory.d.ts +15 -0
- package/dist/types/models/IComponent.d.ts +12 -3
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/Factory.md +38 -0
- package/docs/reference/interfaces/IComponent.md +18 -6
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1871,6 +1871,29 @@ class Factory {
|
|
|
1871
1871
|
}
|
|
1872
1872
|
return Factory._factories[typeName];
|
|
1873
1873
|
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Get all the factories.
|
|
1876
|
+
* @returns All the factories.
|
|
1877
|
+
*/
|
|
1878
|
+
static getFactories() {
|
|
1879
|
+
return Factory._factories;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Reset all the factories, which removes any created instances, but not the registrations.
|
|
1883
|
+
*/
|
|
1884
|
+
static resetFactories() {
|
|
1885
|
+
for (const typeName in Factory._factories) {
|
|
1886
|
+
Factory._factories[typeName].reset();
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Clear all the factories, which removes anything registered with the factories.
|
|
1891
|
+
*/
|
|
1892
|
+
static clearFactories() {
|
|
1893
|
+
for (const typeName in Factory._factories) {
|
|
1894
|
+
Factory._factories[typeName].clear();
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1874
1897
|
/**
|
|
1875
1898
|
* Register a new generator.
|
|
1876
1899
|
* @param name The name of the generator.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1869,6 +1869,29 @@ class Factory {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
return Factory._factories[typeName];
|
|
1871
1871
|
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Get all the factories.
|
|
1874
|
+
* @returns All the factories.
|
|
1875
|
+
*/
|
|
1876
|
+
static getFactories() {
|
|
1877
|
+
return Factory._factories;
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Reset all the factories, which removes any created instances, but not the registrations.
|
|
1881
|
+
*/
|
|
1882
|
+
static resetFactories() {
|
|
1883
|
+
for (const typeName in Factory._factories) {
|
|
1884
|
+
Factory._factories[typeName].reset();
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Clear all the factories, which removes anything registered with the factories.
|
|
1889
|
+
*/
|
|
1890
|
+
static clearFactories() {
|
|
1891
|
+
for (const typeName in Factory._factories) {
|
|
1892
|
+
Factory._factories[typeName].clear();
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1872
1895
|
/**
|
|
1873
1896
|
* Register a new generator.
|
|
1874
1897
|
* @param name The name of the generator.
|
|
@@ -10,6 +10,21 @@ export declare class Factory<T> {
|
|
|
10
10
|
* @returns The factory instance.
|
|
11
11
|
*/
|
|
12
12
|
static createFactory<U>(typeName: string, autoInstance?: boolean, matcher?: (names: string[], name: string) => string | undefined): Factory<U>;
|
|
13
|
+
/**
|
|
14
|
+
* Get all the factories.
|
|
15
|
+
* @returns All the factories.
|
|
16
|
+
*/
|
|
17
|
+
static getFactories(): {
|
|
18
|
+
[typeName: string]: Factory<unknown>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Reset all the factories, which removes any created instances, but not the registrations.
|
|
22
|
+
*/
|
|
23
|
+
static resetFactories(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Clear all the factories, which removes anything registered with the factories.
|
|
26
|
+
*/
|
|
27
|
+
static clearFactories(): void;
|
|
13
28
|
/**
|
|
14
29
|
* Register a new generator.
|
|
15
30
|
* @param name The name of the generator.
|
|
@@ -9,21 +9,30 @@ export interface IComponent {
|
|
|
9
9
|
/**
|
|
10
10
|
* Bootstrap the component by creating and initializing any resources it needs.
|
|
11
11
|
* @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
|
|
12
|
+
* @param componentState A persistent state which can be modified by bootstrap.
|
|
12
13
|
* @returns True if the bootstrapping process was successful.
|
|
13
14
|
*/
|
|
14
|
-
bootstrap?(nodeLoggingConnectorType
|
|
15
|
+
bootstrap?(nodeLoggingConnectorType: string | undefined, componentState?: {
|
|
16
|
+
[id: string]: unknown;
|
|
17
|
+
}): Promise<boolean>;
|
|
15
18
|
/**
|
|
16
19
|
* The component needs to be started when the node is initialized.
|
|
17
20
|
* @param nodeIdentity The identity of the node starting the component.
|
|
18
21
|
* @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
|
|
22
|
+
* @param componentState A persistent state which can be modified by bootstrap.
|
|
19
23
|
* @returns Nothing.
|
|
20
24
|
*/
|
|
21
|
-
start?(nodeIdentity: string, nodeLoggingConnectorType
|
|
25
|
+
start?(nodeIdentity: string, nodeLoggingConnectorType: string | undefined, componentState?: {
|
|
26
|
+
[id: string]: unknown;
|
|
27
|
+
}): Promise<void>;
|
|
22
28
|
/**
|
|
23
29
|
* The component needs to be stopped when the node is closed.
|
|
24
30
|
* @param nodeIdentity The identity of the node stopping the component.
|
|
25
31
|
* @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
|
|
32
|
+
* @param componentState A persistent state which can be modified by bootstrap.
|
|
26
33
|
* @returns Nothing.
|
|
27
34
|
*/
|
|
28
|
-
stop?(nodeIdentity: string, nodeLoggingConnectorType
|
|
35
|
+
stop?(nodeIdentity: string, nodeLoggingConnectorType: string | undefined, componentState?: {
|
|
36
|
+
[id: string]: unknown;
|
|
37
|
+
}): Promise<void>;
|
|
29
38
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -40,6 +40,44 @@ The factory instance.
|
|
|
40
40
|
|
|
41
41
|
***
|
|
42
42
|
|
|
43
|
+
### getFactories()
|
|
44
|
+
|
|
45
|
+
> `static` **getFactories**(): `object`
|
|
46
|
+
|
|
47
|
+
Get all the factories.
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`object`
|
|
52
|
+
|
|
53
|
+
All the factories.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### resetFactories()
|
|
58
|
+
|
|
59
|
+
> `static` **resetFactories**(): `void`
|
|
60
|
+
|
|
61
|
+
Reset all the factories, which removes any created instances, but not the registrations.
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
`void`
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
69
|
+
### clearFactories()
|
|
70
|
+
|
|
71
|
+
> `static` **clearFactories**(): `void`
|
|
72
|
+
|
|
73
|
+
Clear all the factories, which removes anything registered with the factories.
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`void`
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
43
81
|
### register()
|
|
44
82
|
|
|
45
83
|
> **register**\<`U`\>(`name`, `generator`): `void`
|
|
@@ -14,16 +14,20 @@ The name of the component.
|
|
|
14
14
|
|
|
15
15
|
### bootstrap()?
|
|
16
16
|
|
|
17
|
-
> `optional` **bootstrap**(`nodeLoggingConnectorType`?): `Promise`\<`boolean`\>
|
|
17
|
+
> `optional` **bootstrap**(`nodeLoggingConnectorType`, `componentState`?): `Promise`\<`boolean`\>
|
|
18
18
|
|
|
19
19
|
Bootstrap the component by creating and initializing any resources it needs.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
23
|
-
• **nodeLoggingConnectorType
|
|
23
|
+
• **nodeLoggingConnectorType**: `undefined` \| `string`
|
|
24
24
|
|
|
25
25
|
The node logging connector type, defaults to "node-logging".
|
|
26
26
|
|
|
27
|
+
• **componentState?**
|
|
28
|
+
|
|
29
|
+
A persistent state which can be modified by bootstrap.
|
|
30
|
+
|
|
27
31
|
#### Returns
|
|
28
32
|
|
|
29
33
|
`Promise`\<`boolean`\>
|
|
@@ -34,7 +38,7 @@ True if the bootstrapping process was successful.
|
|
|
34
38
|
|
|
35
39
|
### start()?
|
|
36
40
|
|
|
37
|
-
> `optional` **start**(`nodeIdentity`, `nodeLoggingConnectorType`?): `Promise`\<`void`\>
|
|
41
|
+
> `optional` **start**(`nodeIdentity`, `nodeLoggingConnectorType`, `componentState`?): `Promise`\<`void`\>
|
|
38
42
|
|
|
39
43
|
The component needs to be started when the node is initialized.
|
|
40
44
|
|
|
@@ -44,10 +48,14 @@ The component needs to be started when the node is initialized.
|
|
|
44
48
|
|
|
45
49
|
The identity of the node starting the component.
|
|
46
50
|
|
|
47
|
-
• **nodeLoggingConnectorType
|
|
51
|
+
• **nodeLoggingConnectorType**: `undefined` \| `string`
|
|
48
52
|
|
|
49
53
|
The node logging connector type, defaults to "node-logging".
|
|
50
54
|
|
|
55
|
+
• **componentState?**
|
|
56
|
+
|
|
57
|
+
A persistent state which can be modified by bootstrap.
|
|
58
|
+
|
|
51
59
|
#### Returns
|
|
52
60
|
|
|
53
61
|
`Promise`\<`void`\>
|
|
@@ -58,7 +66,7 @@ Nothing.
|
|
|
58
66
|
|
|
59
67
|
### stop()?
|
|
60
68
|
|
|
61
|
-
> `optional` **stop**(`nodeIdentity`, `nodeLoggingConnectorType`?): `Promise`\<`void`\>
|
|
69
|
+
> `optional` **stop**(`nodeIdentity`, `nodeLoggingConnectorType`, `componentState`?): `Promise`\<`void`\>
|
|
62
70
|
|
|
63
71
|
The component needs to be stopped when the node is closed.
|
|
64
72
|
|
|
@@ -68,10 +76,14 @@ The component needs to be stopped when the node is closed.
|
|
|
68
76
|
|
|
69
77
|
The identity of the node stopping the component.
|
|
70
78
|
|
|
71
|
-
• **nodeLoggingConnectorType
|
|
79
|
+
• **nodeLoggingConnectorType**: `undefined` \| `string`
|
|
72
80
|
|
|
73
81
|
The node logging connector type, defaults to "node-logging".
|
|
74
82
|
|
|
83
|
+
• **componentState?**
|
|
84
|
+
|
|
85
|
+
A persistent state which can be modified by bootstrap.
|
|
86
|
+
|
|
75
87
|
#### Returns
|
|
76
88
|
|
|
77
89
|
`Promise`\<`void`\>
|