@fluojs/runtime 2.0.1 → 3.0.0

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.
Files changed (127) hide show
  1. package/README.ko.md +278 -20
  2. package/README.md +278 -20
  3. package/dist/adapters/internal-request-response-factory.d.ts +1 -1
  4. package/dist/adapters/internal-request-response-factory.d.ts.map +1 -1
  5. package/dist/adapters/internal-request-response-factory.js +1 -1
  6. package/dist/adapters/request-response-factory.d.ts +20 -1
  7. package/dist/adapters/request-response-factory.d.ts.map +1 -1
  8. package/dist/adapters/request-response-factory.js +75 -22
  9. package/dist/bootstrap.d.ts +3 -9
  10. package/dist/bootstrap.d.ts.map +1 -1
  11. package/dist/bootstrap.js +179 -75
  12. package/dist/devtools/contracts.d.ts +3 -135
  13. package/dist/devtools/contracts.d.ts.map +1 -1
  14. package/dist/devtools/index.d.ts +2 -3
  15. package/dist/devtools/index.d.ts.map +1 -1
  16. package/dist/devtools/index.js +1 -2
  17. package/dist/devtools/snapshot.d.ts +1 -1
  18. package/dist/devtools/snapshot.d.ts.map +1 -1
  19. package/dist/devtools/snapshot.js +18 -17
  20. package/dist/devtools/studio-request-observer.d.ts +14 -0
  21. package/dist/devtools/studio-request-observer.d.ts.map +1 -0
  22. package/dist/devtools/studio-request-observer.js +112 -0
  23. package/dist/devtools/studio-runtime-config.d.ts +25 -0
  24. package/dist/devtools/studio-runtime-config.d.ts.map +1 -0
  25. package/dist/devtools/studio-runtime-config.js +59 -0
  26. package/dist/devtools/studio-runtime.d.ts +12 -18
  27. package/dist/devtools/studio-runtime.d.ts.map +1 -1
  28. package/dist/devtools/studio-runtime.js +25 -169
  29. package/dist/errors.d.ts +26 -0
  30. package/dist/errors.d.ts.map +1 -1
  31. package/dist/errors.js +38 -0
  32. package/dist/health/health.d.ts +6 -2
  33. package/dist/health/health.d.ts.map +1 -1
  34. package/dist/health/health.js +3 -2
  35. package/dist/http-adapter-shared.d.ts +1 -1
  36. package/dist/http-adapter-shared.d.ts.map +1 -1
  37. package/dist/http-adapter-shared.js +1 -1
  38. package/dist/index.d.ts +6 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -1
  41. package/dist/internal/route-inspection-metadata.d.ts +30 -0
  42. package/dist/internal/route-inspection-metadata.d.ts.map +1 -0
  43. package/dist/internal/route-inspection-metadata.js +68 -0
  44. package/dist/internal.d.ts +6 -1
  45. package/dist/internal.d.ts.map +1 -1
  46. package/dist/internal.js +4 -1
  47. package/dist/module-definition.d.ts +10 -0
  48. package/dist/module-definition.d.ts.map +1 -0
  49. package/dist/module-definition.js +12 -0
  50. package/dist/module-graph.d.ts +41 -0
  51. package/dist/module-graph.d.ts.map +1 -1
  52. package/dist/module-graph.js +108 -13
  53. package/dist/multipart.d.ts +67 -3
  54. package/dist/multipart.d.ts.map +1 -1
  55. package/dist/multipart.js +665 -103
  56. package/dist/platform-component-registry.d.ts +9 -0
  57. package/dist/platform-component-registry.d.ts.map +1 -0
  58. package/dist/platform-component-registry.js +70 -0
  59. package/dist/platform-diagnostic-retention.d.ts +13 -0
  60. package/dist/platform-diagnostic-retention.d.ts.map +1 -0
  61. package/dist/platform-diagnostic-retention.js +43 -0
  62. package/dist/platform-shell-probe-reports.d.ts +8 -0
  63. package/dist/platform-shell-probe-reports.d.ts.map +1 -0
  64. package/dist/platform-shell-probe-reports.js +95 -0
  65. package/dist/platform-shell-probes.d.ts +16 -0
  66. package/dist/platform-shell-probes.d.ts.map +1 -0
  67. package/dist/platform-shell-probes.js +141 -0
  68. package/dist/platform-shell.d.ts +7 -13
  69. package/dist/platform-shell.d.ts.map +1 -1
  70. package/dist/platform-shell.js +58 -310
  71. package/dist/retryable-shutdown.d.ts +7 -0
  72. package/dist/retryable-shutdown.d.ts.map +1 -0
  73. package/dist/retryable-shutdown.js +20 -0
  74. package/dist/route-inspection.d.ts +56 -0
  75. package/dist/route-inspection.d.ts.map +1 -0
  76. package/dist/route-inspection.js +80 -0
  77. package/dist/tokens.d.ts +6 -4
  78. package/dist/tokens.d.ts.map +1 -1
  79. package/dist/tokens.js +5 -0
  80. package/dist/types.d.ts +53 -8
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/web.d.ts +22 -3
  83. package/dist/web.d.ts.map +1 -1
  84. package/dist/web.js +80 -34
  85. package/package.json +13 -26
  86. package/dist/internal-node.d.ts +0 -2
  87. package/dist/internal-node.d.ts.map +0 -1
  88. package/dist/internal-node.js +0 -1
  89. package/dist/logging/json-logger.d.ts +0 -8
  90. package/dist/logging/json-logger.d.ts.map +0 -1
  91. package/dist/logging/json-logger.js +0 -45
  92. package/dist/logging/logger.d.ts +0 -37
  93. package/dist/logging/logger.d.ts.map +0 -1
  94. package/dist/logging/logger.js +0 -103
  95. package/dist/node/internal-node-compression.d.ts +0 -22
  96. package/dist/node/internal-node-compression.d.ts.map +0 -1
  97. package/dist/node/internal-node-compression.js +0 -84
  98. package/dist/node/internal-node-request.d.ts +0 -162
  99. package/dist/node/internal-node-request.d.ts.map +0 -1
  100. package/dist/node/internal-node-request.js +0 -478
  101. package/dist/node/internal-node-response.d.ts +0 -28
  102. package/dist/node/internal-node-response.d.ts.map +0 -1
  103. package/dist/node/internal-node-response.js +0 -205
  104. package/dist/node/internal-node-shutdown.d.ts +0 -34
  105. package/dist/node/internal-node-shutdown.d.ts.map +0 -1
  106. package/dist/node/internal-node-shutdown.js +0 -83
  107. package/dist/node/internal-node.d.ts +0 -111
  108. package/dist/node/internal-node.d.ts.map +0 -1
  109. package/dist/node/internal-node.js +0 -283
  110. package/dist/node/node-compression.d.ts +0 -2
  111. package/dist/node/node-compression.d.ts.map +0 -1
  112. package/dist/node/node-compression.js +0 -1
  113. package/dist/node/node-request.d.ts +0 -2
  114. package/dist/node/node-request.d.ts.map +0 -1
  115. package/dist/node/node-request.js +0 -1
  116. package/dist/node/node-response.d.ts +0 -2
  117. package/dist/node/node-response.d.ts.map +0 -1
  118. package/dist/node/node-response.js +0 -1
  119. package/dist/node/node-shutdown.d.ts +0 -2
  120. package/dist/node/node-shutdown.d.ts.map +0 -1
  121. package/dist/node/node-shutdown.js +0 -1
  122. package/dist/node/node.d.ts +0 -2
  123. package/dist/node/node.d.ts.map +0 -1
  124. package/dist/node/node.js +0 -1
  125. package/dist/node.d.ts +0 -5
  126. package/dist/node.d.ts.map +0 -1
  127. package/dist/node.js +0 -3
@@ -0,0 +1,9 @@
1
+ import type { PlatformComponent, PlatformComponentInput } from './platform-contract.js';
2
+ export interface RegisteredPlatformComponent {
3
+ readonly component: PlatformComponent;
4
+ readonly dependencies: readonly string[];
5
+ }
6
+ export declare function registerPlatformComponents(components: readonly PlatformComponentInput[] | undefined): RegisteredPlatformComponent[];
7
+ export declare function assertValidPlatformComponentGraph(components: readonly RegisteredPlatformComponent[]): void;
8
+ export declare function orderPlatformComponents(components: readonly RegisteredPlatformComponent[]): RegisteredPlatformComponent[];
9
+ //# sourceMappingURL=platform-component-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-component-registry.d.ts","sourceRoot":"","sources":["../src/platform-component-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EAEvB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAoBD,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,GACxD,2BAA2B,EAAE,CAE/B;AAED,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,SAAS,2BAA2B,EAAE,GAAG,IAAI,CA4B1G;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,2BAA2B,EAAE,GACjD,2BAA2B,EAAE,CAoC/B"}
@@ -0,0 +1,70 @@
1
+ import { InvariantError } from '@fluojs/core';
2
+ function isRegistration(value) {
3
+ return typeof value === 'object' && value !== null && 'component' in value;
4
+ }
5
+ function normalizeRegistration(input) {
6
+ if (isRegistration(input)) {
7
+ return {
8
+ component: input.component,
9
+ dependencies: [...(input.dependencies ?? [])]
10
+ };
11
+ }
12
+ return {
13
+ component: input,
14
+ dependencies: []
15
+ };
16
+ }
17
+ export function registerPlatformComponents(components) {
18
+ return (components ?? []).map(component => normalizeRegistration(component));
19
+ }
20
+ export function assertValidPlatformComponentGraph(components) {
21
+ const ids = new Set();
22
+ for (const registration of components) {
23
+ if (!registration.component.id || registration.component.id.trim().length === 0) {
24
+ throw new InvariantError('Platform component id must be a non-empty string.');
25
+ }
26
+ if (ids.has(registration.component.id)) {
27
+ throw new InvariantError(`Duplicate platform component id "${registration.component.id}" is not allowed.`);
28
+ }
29
+ ids.add(registration.component.id);
30
+ }
31
+ for (const registration of components) {
32
+ for (const dependency of registration.dependencies) {
33
+ if (!ids.has(dependency)) {
34
+ throw new InvariantError(`Platform component "${registration.component.id}" depends on unknown component "${dependency}".`);
35
+ }
36
+ if (dependency === registration.component.id) {
37
+ throw new InvariantError(`Platform component "${registration.component.id}" cannot depend on itself.`);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ export function orderPlatformComponents(components) {
43
+ const byId = new Map(components.map(registration => [registration.component.id, registration]));
44
+ const visiting = new Set();
45
+ const visited = new Set();
46
+ const ordered = [];
47
+ const visit = id => {
48
+ if (visited.has(id)) {
49
+ return;
50
+ }
51
+ if (visiting.has(id)) {
52
+ throw new InvariantError(`Platform component dependency cycle detected at "${id}".`);
53
+ }
54
+ visiting.add(id);
55
+ const registration = byId.get(id);
56
+ if (!registration) {
57
+ throw new InvariantError(`Platform component "${id}" is missing from runtime registration.`);
58
+ }
59
+ for (const dependency of registration.dependencies) {
60
+ visit(dependency);
61
+ }
62
+ visiting.delete(id);
63
+ visited.add(id);
64
+ ordered.push(registration);
65
+ };
66
+ for (const registration of components) {
67
+ visit(registration.component.id);
68
+ }
69
+ return ordered;
70
+ }
@@ -0,0 +1,13 @@
1
+ import type { PlatformDiagnosticIssue } from './platform-contract.js';
2
+ export type PlatformProbePhase = 'health' | 'ready' | 'snapshot';
3
+ export type PlatformDiagnosticPhase = PlatformProbePhase | 'start' | 'start-rollback' | 'stop' | 'validate';
4
+ export declare function createPlatformFailureIssue(componentId: string, phase: PlatformDiagnosticPhase, error: unknown): PlatformDiagnosticIssue;
5
+ export declare function createPlatformValidationFailureIssue(componentId: string): PlatformDiagnosticIssue;
6
+ export declare class PlatformDiagnosticRetention {
7
+ private readonly retained;
8
+ private readonly probeIndexesByComponent;
9
+ append(issues: readonly PlatformDiagnosticIssue[]): void;
10
+ retainProbe(phase: PlatformProbePhase, issue: PlatformDiagnosticIssue): void;
11
+ toArray(): PlatformDiagnosticIssue[];
12
+ }
13
+ //# sourceMappingURL=platform-diagnostic-retention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-diagnostic-retention.d.ts","sourceRoot":"","sources":["../src/platform-diagnostic-retention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AACjE,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GAAG,OAAO,GAAG,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5G,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,uBAAuB,EAC9B,KAAK,EAAE,OAAO,GACb,uBAAuB,CASzB;AAED,wBAAgB,oCAAoC,CAAC,WAAW,EAAE,MAAM,GAAG,uBAAuB,CAQjG;AAED,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiC;IAC1D,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAsD;IAE9F,MAAM,CAAC,MAAM,EAAE,SAAS,uBAAuB,EAAE,GAAG,IAAI;IAIxD,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,uBAAuB,GAAG,IAAI;IAiB5E,OAAO,IAAI,uBAAuB,EAAE;CAGrC"}
@@ -0,0 +1,43 @@
1
+ export function createPlatformFailureIssue(componentId, phase, error) {
2
+ return {
3
+ cause: error instanceof Error ? error.message : String(error),
4
+ code: 'RUNTIME_PLATFORM_COMPONENT_FAILURE',
5
+ componentId,
6
+ fixHint: 'Inspect component implementation and ensure validate/start/ready/health/snapshot contracts are deterministic.',
7
+ message: `Platform component failed during ${phase}.`,
8
+ severity: 'error'
9
+ };
10
+ }
11
+ export function createPlatformValidationFailureIssue(componentId) {
12
+ return {
13
+ code: 'RUNTIME_PLATFORM_VALIDATION_FAILED',
14
+ componentId,
15
+ fixHint: 'Return at least one error-severity issue from validate() so the failure cause is diagnosable.',
16
+ message: 'Platform component reported validation failure without diagnostic issues.',
17
+ severity: 'error'
18
+ };
19
+ }
20
+ export class PlatformDiagnosticRetention {
21
+ retained = [];
22
+ probeIndexesByComponent = new Map();
23
+ append(issues) {
24
+ this.retained.push(...issues);
25
+ }
26
+ retainProbe(phase, issue) {
27
+ let probeIndexes = this.probeIndexesByComponent.get(issue.componentId);
28
+ if (probeIndexes === undefined) {
29
+ probeIndexes = new Map();
30
+ this.probeIndexesByComponent.set(issue.componentId, probeIndexes);
31
+ }
32
+ const retainedIndex = probeIndexes.get(phase);
33
+ if (retainedIndex === undefined) {
34
+ probeIndexes.set(phase, this.retained.length);
35
+ this.retained.push(issue);
36
+ return;
37
+ }
38
+ this.retained[retainedIndex] = issue;
39
+ }
40
+ toArray() {
41
+ return [...this.retained];
42
+ }
43
+ }
@@ -0,0 +1,8 @@
1
+ import type { RegisteredPlatformComponent } from './platform-component-registry.js';
2
+ import type { PlatformDiagnosticIssue, PlatformHealthReport, PlatformReadinessReport, PlatformShellSnapshot, PlatformSnapshot } from './platform-contract.js';
3
+ export declare function aggregateReadiness(reports: readonly PlatformReadinessReport[]): PlatformReadinessReport;
4
+ export declare function aggregateHealth(reports: readonly PlatformHealthReport[]): PlatformHealthReport;
5
+ export declare function createEmptyShellSnapshot(diagnostics: PlatformDiagnosticIssue[]): PlatformShellSnapshot;
6
+ export declare function normalizeSnapshot(snapshot: PlatformSnapshot, registration: RegisteredPlatformComponent): PlatformSnapshot;
7
+ export declare function createFailedPlatformSnapshot(registration: RegisteredPlatformComponent, issue: PlatformDiagnosticIssue): PlatformSnapshot;
8
+ //# sourceMappingURL=platform-shell-probe-reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-shell-probe-reports.d.ts","sourceRoot":"","sources":["../src/platform-shell-probe-reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,GAAG,uBAAuB,CA4BvG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,GAAG,oBAAoB,CAuB9F;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,uBAAuB,EAAE,GAAG,qBAAqB,CAatG;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,EAC1B,YAAY,EAAE,2BAA2B,GACxC,gBAAgB,CAOlB;AAED,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,2BAA2B,EACzC,KAAK,EAAE,uBAAuB,GAC7B,gBAAgB,CAyBlB"}
@@ -0,0 +1,95 @@
1
+ export function aggregateReadiness(reports) {
2
+ const hasCriticalNotReady = reports.some(report => report.critical && report.status === 'not-ready');
3
+ const hasNotReady = reports.some(report => report.status === 'not-ready');
4
+ const hasDegraded = reports.some(report => report.status === 'degraded');
5
+ const hasCritical = reports.some(report => report.critical);
6
+ if (hasCriticalNotReady) {
7
+ const reason = reports.find(report => report.critical && report.status === 'not-ready')?.reason;
8
+ return {
9
+ critical: hasCritical,
10
+ reason: reason ?? 'One or more critical platform components are not ready.',
11
+ status: 'not-ready'
12
+ };
13
+ }
14
+ if (hasNotReady || hasDegraded) {
15
+ const reason = reports.find(report => report.status !== 'ready')?.reason;
16
+ return {
17
+ critical: hasCritical,
18
+ reason: reason ?? 'One or more platform components are degraded or not ready.',
19
+ status: 'degraded'
20
+ };
21
+ }
22
+ return {
23
+ critical: hasCritical,
24
+ status: 'ready'
25
+ };
26
+ }
27
+ export function aggregateHealth(reports) {
28
+ const hasUnhealthy = reports.some(report => report.status === 'unhealthy');
29
+ const hasDegraded = reports.some(report => report.status === 'degraded');
30
+ if (hasUnhealthy) {
31
+ const reason = reports.find(report => report.status === 'unhealthy')?.reason;
32
+ return {
33
+ reason: reason ?? 'One or more platform components are unhealthy.',
34
+ status: 'unhealthy'
35
+ };
36
+ }
37
+ if (hasDegraded) {
38
+ const reason = reports.find(report => report.status === 'degraded')?.reason;
39
+ return {
40
+ reason: reason ?? 'One or more platform components are degraded.',
41
+ status: 'degraded'
42
+ };
43
+ }
44
+ return {
45
+ status: 'healthy'
46
+ };
47
+ }
48
+ export function createEmptyShellSnapshot(diagnostics) {
49
+ return {
50
+ components: [],
51
+ diagnostics,
52
+ generatedAt: new Date().toISOString(),
53
+ health: {
54
+ status: 'healthy'
55
+ },
56
+ readiness: {
57
+ critical: false,
58
+ status: 'ready'
59
+ }
60
+ };
61
+ }
62
+ export function normalizeSnapshot(snapshot, registration) {
63
+ return {
64
+ ...snapshot,
65
+ dependencies: [...registration.dependencies],
66
+ id: registration.component.id,
67
+ kind: registration.component.kind
68
+ };
69
+ }
70
+ export function createFailedPlatformSnapshot(registration, issue) {
71
+ return {
72
+ dependencies: [...registration.dependencies],
73
+ details: {},
74
+ health: {
75
+ reason: issue.cause,
76
+ status: 'unhealthy'
77
+ },
78
+ id: registration.component.id,
79
+ kind: registration.component.kind,
80
+ ownership: {
81
+ externallyManaged: false,
82
+ ownsResources: false
83
+ },
84
+ readiness: {
85
+ critical: true,
86
+ reason: issue.cause,
87
+ status: 'not-ready'
88
+ },
89
+ state: 'failed',
90
+ telemetry: {
91
+ namespace: 'fluo.platform',
92
+ tags: {}
93
+ }
94
+ };
95
+ }
@@ -0,0 +1,16 @@
1
+ import type { RegisteredPlatformComponent } from './platform-component-registry.js';
2
+ import type { PlatformHealthReport, PlatformReadinessReport, PlatformShellSnapshot } from './platform-contract.js';
3
+ import { type PlatformDiagnosticRetention } from './platform-diagnostic-retention.js';
4
+ export declare class PlatformShellProbeCollector {
5
+ private readonly registeredComponents;
6
+ private readonly diagnostics;
7
+ constructor(registeredComponents: readonly RegisteredPlatformComponent[], diagnostics: PlatformDiagnosticRetention);
8
+ ready(): Promise<PlatformReadinessReport>;
9
+ health(): Promise<PlatformHealthReport>;
10
+ snapshot(): Promise<PlatformShellSnapshot>;
11
+ private collectSnapshotProbe;
12
+ private collectComponentSnapshot;
13
+ private collectComponentReadiness;
14
+ private collectComponentHealth;
15
+ }
16
+ //# sourceMappingURL=platform-shell-probes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-shell-probes.d.ts","sourceRoot":"","sources":["../src/platform-shell-probes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,KAAK,EAEV,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,oCAAoC,CAAC;AAoC5C,qBAAa,2BAA2B;IAEpC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,oBAAoB,EAAE,SAAS,2BAA2B,EAAE,EAC5D,WAAW,EAAE,2BAA2B;IAGrD,KAAK,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA2BzC,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAyBvC,QAAQ,IAAI,OAAO,CAAC,qBAAqB,CAAC;YA0BlC,oBAAoB;IAiBlC,OAAO,CAAC,wBAAwB;YAgBlB,yBAAyB;YAqBzB,sBAAsB;CAiBrC"}
@@ -0,0 +1,141 @@
1
+ import { createPlatformFailureIssue } from './platform-diagnostic-retention.js';
2
+ import { aggregateHealth, aggregateReadiness, createEmptyShellSnapshot, createFailedPlatformSnapshot, normalizeSnapshot } from './platform-shell-probe-reports.js';
3
+ export class PlatformShellProbeCollector {
4
+ constructor(registeredComponents, diagnostics) {
5
+ this.registeredComponents = registeredComponents;
6
+ this.diagnostics = diagnostics;
7
+ }
8
+ async ready() {
9
+ if (this.registeredComponents.length === 0) {
10
+ return {
11
+ critical: false,
12
+ status: 'ready'
13
+ };
14
+ }
15
+ const reports = [];
16
+ for (const component of this.registeredComponents) {
17
+ try {
18
+ reports.push(await component.component.ready());
19
+ } catch (error) {
20
+ const issue = createPlatformFailureIssue(component.component.id, 'ready', error);
21
+ this.diagnostics.retainProbe('ready', issue);
22
+ reports.push({
23
+ critical: true,
24
+ reason: issue.cause,
25
+ status: 'not-ready'
26
+ });
27
+ }
28
+ }
29
+ return aggregateReadiness(reports);
30
+ }
31
+ async health() {
32
+ if (this.registeredComponents.length === 0) {
33
+ return {
34
+ status: 'healthy'
35
+ };
36
+ }
37
+ const reports = [];
38
+ for (const component of this.registeredComponents) {
39
+ try {
40
+ reports.push(await component.component.health());
41
+ } catch (error) {
42
+ const issue = createPlatformFailureIssue(component.component.id, 'health', error);
43
+ this.diagnostics.retainProbe('health', issue);
44
+ reports.push({
45
+ reason: issue.cause,
46
+ status: 'unhealthy'
47
+ });
48
+ }
49
+ }
50
+ return aggregateHealth(reports);
51
+ }
52
+ async snapshot() {
53
+ if (this.registeredComponents.length === 0) {
54
+ return createEmptyShellSnapshot(this.diagnostics.toArray());
55
+ }
56
+ const probeResults = await Promise.all(this.registeredComponents.map(registration => this.collectSnapshotProbe(registration)));
57
+ const components = probeResults.map(result => result.snapshot);
58
+ const readiness = aggregateReadiness(probeResults.map(result => result.readiness));
59
+ const health = aggregateHealth(probeResults.map(result => result.health));
60
+ for (const result of probeResults) {
61
+ for (const diagnostic of result.diagnostics) {
62
+ this.diagnostics.retainProbe(diagnostic.phase, diagnostic.issue);
63
+ }
64
+ }
65
+ return {
66
+ components,
67
+ diagnostics: this.diagnostics.toArray(),
68
+ generatedAt: new Date().toISOString(),
69
+ health,
70
+ readiness
71
+ };
72
+ }
73
+ async collectSnapshotProbe(registration) {
74
+ const [snapshot, readiness, health] = await Promise.all([this.collectComponentSnapshot(registration), this.collectComponentReadiness(registration), this.collectComponentHealth(registration)]);
75
+ return {
76
+ diagnostics: [...snapshot.diagnostics, ...readiness.diagnostics, ...health.diagnostics],
77
+ health: health.health,
78
+ readiness: readiness.readiness,
79
+ snapshot: snapshot.snapshot
80
+ };
81
+ }
82
+ collectComponentSnapshot(registration) {
83
+ try {
84
+ const snapshot = registration.component.snapshot();
85
+ return {
86
+ diagnostics: [],
87
+ snapshot: normalizeSnapshot(snapshot, registration)
88
+ };
89
+ } catch (error) {
90
+ const issue = createPlatformFailureIssue(registration.component.id, 'snapshot', error);
91
+ return {
92
+ diagnostics: [{
93
+ issue,
94
+ phase: 'snapshot'
95
+ }],
96
+ snapshot: createFailedPlatformSnapshot(registration, issue)
97
+ };
98
+ }
99
+ }
100
+ async collectComponentReadiness(registration) {
101
+ try {
102
+ return {
103
+ diagnostics: [],
104
+ readiness: await registration.component.ready()
105
+ };
106
+ } catch (error) {
107
+ const issue = createPlatformFailureIssue(registration.component.id, 'ready', error);
108
+ return {
109
+ diagnostics: [{
110
+ issue,
111
+ phase: 'ready'
112
+ }],
113
+ readiness: {
114
+ critical: true,
115
+ reason: issue.cause,
116
+ status: 'not-ready'
117
+ }
118
+ };
119
+ }
120
+ }
121
+ async collectComponentHealth(registration) {
122
+ try {
123
+ return {
124
+ diagnostics: [],
125
+ health: await registration.component.health()
126
+ };
127
+ } catch (error) {
128
+ const issue = createPlatformFailureIssue(registration.component.id, 'health', error);
129
+ return {
130
+ diagnostics: [{
131
+ issue,
132
+ phase: 'health'
133
+ }],
134
+ health: {
135
+ reason: issue.cause,
136
+ status: 'unhealthy'
137
+ }
138
+ };
139
+ }
140
+ }
141
+ }
@@ -1,8 +1,5 @@
1
- import type { PlatformComponent, PlatformComponentInput, PlatformHealthReport, PlatformReadinessReport, PlatformShell, PlatformShellSnapshot } from './platform-contract.js';
2
- interface RegisteredPlatformComponent {
3
- component: PlatformComponent;
4
- dependencies: readonly string[];
5
- }
1
+ import { type RegisteredPlatformComponent } from './platform-component-registry.js';
2
+ import type { PlatformComponentInput, PlatformHealthReport, PlatformReadinessReport, PlatformShell, PlatformShellSnapshot } from './platform-contract.js';
6
3
  /**
7
4
  * A runtime implementation of the {@link PlatformShell} that manages the lifecycle
8
5
  * of registered platform components, including dependency ordering and diagnostics.
@@ -10,10 +7,11 @@ interface RegisteredPlatformComponent {
10
7
  export declare class RuntimePlatformShell implements PlatformShell {
11
8
  private readonly registeredComponents;
12
9
  private started;
13
- private stopped;
14
10
  private orderedComponents;
15
11
  private rollbackPendingComponents;
16
12
  private readonly diagnostics;
13
+ private readonly probes;
14
+ private activeLifecycleTransition;
17
15
  constructor(registeredComponents: RegisteredPlatformComponent[]);
18
16
  /**
19
17
  * Creates a {@link RuntimePlatformShell} from an optional array of platform component inputs.
@@ -25,17 +23,14 @@ export declare class RuntimePlatformShell implements PlatformShell {
25
23
  hasRegisteredComponents(): boolean;
26
24
  start(): Promise<void>;
27
25
  stop(): Promise<void>;
26
+ private runLifecycleTransition;
27
+ private startComponents;
28
+ private stopComponents;
28
29
  ready(): Promise<PlatformReadinessReport>;
29
30
  health(): Promise<PlatformHealthReport>;
30
31
  snapshot(): Promise<PlatformShellSnapshot>;
31
- private collectSnapshotProbe;
32
- private collectComponentSnapshot;
33
- private collectComponentReadiness;
34
- private collectComponentHealth;
35
32
  assertCriticalReadiness(): Promise<void>;
36
- private validateIdentityAndDependencies;
37
33
  private validateComponents;
38
- private orderByDependency;
39
34
  private stopStartedComponents;
40
35
  }
41
36
  /**
@@ -45,5 +40,4 @@ export declare class RuntimePlatformShell implements PlatformShell {
45
40
  * @returns A new {@link RuntimePlatformShell} instance.
46
41
  */
47
42
  export declare function createRuntimePlatformShell(components: readonly PlatformComponentInput[] | undefined): RuntimePlatformShell;
48
- export {};
49
43
  //# sourceMappingURL=platform-shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-shell.d.ts","sourceRoot":"","sources":["../src/platform-shell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EAGtB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EAGtB,MAAM,wBAAwB,CAAC;AAEhC,UAAU,2BAA2B;IACnC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAwID;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IAO5C,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IANjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAqC;IAC9D,OAAO,CAAC,yBAAyB,CAAqC;IACtE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;gBAEhC,oBAAoB,EAAE,2BAA2B,EAAE;IAEhF;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,GAAG,oBAAoB;IAIlG,uBAAuB,IAAI,OAAO;IAI5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBrB,KAAK,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA2BzC,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAyBvC,QAAQ,IAAI,OAAO,CAAC,qBAAqB,CAAC;YAuBlC,oBAAoB;IAmBlC,OAAO,CAAC,wBAAwB;YAuClB,yBAAyB;YAmBzB,sBAAsB;IAkB9B,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9C,OAAO,CAAC,+BAA+B;YAgCzB,kBAAkB;IA4BhC,OAAO,CAAC,iBAAiB;YAsCX,qBAAqB;CAgBpC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,GAAG,oBAAoB,CAE1H"}
1
+ {"version":3,"file":"platform-shell.d.ts","sourceRoot":"","sources":["../src/platform-shell.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,2BAA2B,EAEjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EAEtB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EAEtB,MAAM,wBAAwB,CAAC;AAYhC;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IAQ5C,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IAPjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,iBAAiB,CAAqC;IAC9D,OAAO,CAAC,yBAAyB,CAAqC;IACtE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,yBAAyB,CAA0C;gBAE9C,oBAAoB,EAAE,2BAA2B,EAAE;IAIhF;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,GAAG,oBAAoB;IAIlG,uBAAuB,IAAI,OAAO;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,OAAO,CAAC,sBAAsB;YAoBhB,eAAe;YAiDf,cAAc;IAmB5B,KAAK,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAIzC,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAIvC,QAAQ,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAIpC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;YAUhC,kBAAkB;YA8BlB,qBAAqB;CAmBpC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAAG,SAAS,GAAG,oBAAoB,CAE1H"}