harperdb 4.6.6 → 4.7.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +1 -1
  3. package/bin/harperdb.js +89 -78
  4. package/bin/lite.js +85 -74
  5. package/components/requestRestart.d.ts +3 -0
  6. package/components/status/ComponentStatus.d.ts +61 -0
  7. package/components/status/ComponentStatusRegistry.d.ts +80 -0
  8. package/components/status/api.d.ts +104 -0
  9. package/components/status/crossThread.d.ts +62 -0
  10. package/components/status/errors.d.ts +68 -0
  11. package/components/status/index.d.ts +35 -0
  12. package/components/status/internal.d.ts +40 -0
  13. package/components/status/registry.d.ts +10 -0
  14. package/components/status/types.d.ts +75 -0
  15. package/json/systemSchema.json +68 -7
  16. package/launchServiceScripts/launchNatsIngestService.js +85 -74
  17. package/launchServiceScripts/launchNatsReplyService.js +85 -74
  18. package/launchServiceScripts/launchUpdateNodes4-0-0.js +85 -74
  19. package/npm-shrinkwrap.json +361 -71
  20. package/package.json +6 -6
  21. package/resources/RequestTarget.d.ts +1 -1
  22. package/resources/Resource.d.ts +3 -3
  23. package/resources/ResourceInterface.d.ts +33 -10
  24. package/resources/Resources.d.ts +1 -0
  25. package/resources/Table.d.ts +3 -3
  26. package/resources/analytics/hostnames.d.ts +3 -3
  27. package/resources/analytics/write.d.ts +2 -0
  28. package/resources/auditStore.d.ts +2 -0
  29. package/resources/databases.d.ts +3 -3
  30. package/resources/usageLicensing.d.ts +23 -0
  31. package/security/certificateVerification.d.ts +80 -0
  32. package/security/pkijs-ed25519-patch.d.ts +14 -0
  33. package/server/jobs/jobProcess.js +85 -74
  34. package/server/replication/knownNodes.d.ts +13 -1
  35. package/server/replication/replicationConnection.d.ts +2 -1
  36. package/server/status/index.d.ts +14 -5
  37. package/server/threads/threadServer.js +85 -74
  38. package/studio/build-local/asset-manifest.json +2 -2
  39. package/studio/build-local/index.html +1 -1
  40. package/studio/build-local/static/js/main.b93998e3.js +2 -0
  41. package/utility/hdbTerms.d.ts +8 -0
  42. package/utility/scripts/restartHdb.js +85 -74
  43. package/validation/usageLicensing.d.ts +34 -0
  44. package/studio/build-local/static/js/main.f9919fa0.js +0 -2
  45. /package/studio/build-local/static/js/{main.f9919fa0.js.LICENSE.txt → main.b93998e3.js.LICENSE.txt} +0 -0
@@ -0,0 +1,3 @@
1
+ export declare function requestRestart(): void;
2
+ export declare function restartNeeded(): boolean;
3
+ export declare function resetRestartNeeded(): void;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ComponentStatus Class
3
+ *
4
+ * This module contains the ComponentStatus class which represents an individual
5
+ * component's status with methods for status management.
6
+ */
7
+ import { ComponentStatusLevel } from './types.ts';
8
+ /**
9
+ * Component status information class
10
+ */
11
+ export declare class ComponentStatus {
12
+ /** Last time this status was checked/updated */
13
+ lastChecked: Date;
14
+ /** Current status level */
15
+ status: ComponentStatusLevel;
16
+ /** Human-readable status message */
17
+ message?: string;
18
+ /** Error information if status is 'error' */
19
+ error?: Error | string;
20
+ constructor(status: ComponentStatusLevel, message?: string, error?: Error | string);
21
+ /**
22
+ * Update the status level and refresh the timestamp
23
+ */
24
+ updateStatus(status: ComponentStatusLevel, message?: string): void;
25
+ /**
26
+ * Set status to healthy
27
+ */
28
+ markHealthy(message?: string): void;
29
+ /**
30
+ * Set status to error
31
+ */
32
+ markError(error: Error | string, message?: string): void;
33
+ /**
34
+ * Set status to warning
35
+ */
36
+ markWarning(message: string): void;
37
+ /**
38
+ * Set status to loading
39
+ */
40
+ markLoading(message?: string): void;
41
+ /**
42
+ * Check if component is healthy
43
+ */
44
+ isHealthy(): boolean;
45
+ /**
46
+ * Check if component has an error
47
+ */
48
+ hasError(): boolean;
49
+ /**
50
+ * Check if component is loading
51
+ */
52
+ isLoading(): boolean;
53
+ /**
54
+ * Check if component has a warning
55
+ */
56
+ hasWarning(): boolean;
57
+ /**
58
+ * Get a summary string of the component status
59
+ */
60
+ getSummary(): string;
61
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * ComponentStatusRegistry Class
3
+ *
4
+ * This module contains the ComponentStatusRegistry class which provides
5
+ * centralized management of component health status.
6
+ */
7
+ import { ComponentStatus } from './ComponentStatus.ts';
8
+ import { ComponentStatusLevel, AggregatedComponentStatus } from './types.ts';
9
+ /**
10
+ * Map of component names to their status information
11
+ */
12
+ export type ComponentStatusMap = Map<string, ComponentStatus>;
13
+ /**
14
+ * Component Status Registry Class
15
+ * Provides a centralized registry for managing component health status
16
+ */
17
+ export declare class ComponentStatusRegistry {
18
+ private statusMap;
19
+ /**
20
+ * Reset the component status registry, clearing all existing status data
21
+ * This should be called when the component system starts up
22
+ */
23
+ reset(): void;
24
+ /**
25
+ * Register or update component health status
26
+ * This function allows components to report their own health status
27
+ */
28
+ setStatus(componentName: string, status: ComponentStatusLevel, message?: string, error?: Error | string): void;
29
+ /**
30
+ * Get the current status of a component
31
+ */
32
+ getStatus(componentName: string): ComponentStatus | undefined;
33
+ /**
34
+ * Get all component statuses
35
+ */
36
+ getAllStatuses(): ComponentStatusMap;
37
+ /**
38
+ * Report component as healthy
39
+ */
40
+ reportHealthy(componentName: string, message?: string): void;
41
+ /**
42
+ * Report component error
43
+ */
44
+ reportError(componentName: string, error: Error | string, message?: string): void;
45
+ /**
46
+ * Report component warning
47
+ */
48
+ reportWarning(componentName: string, message: string): void;
49
+ /**
50
+ * Component Lifecycle Management
51
+ */
52
+ /**
53
+ * Initialize component as loading - call this when component loading begins
54
+ */
55
+ initializeLoading(componentName: string, message?: string): void;
56
+ /**
57
+ * Mark component as successfully loaded
58
+ */
59
+ markLoaded(componentName: string, message?: string): void;
60
+ /**
61
+ * Mark component as failed to load
62
+ */
63
+ markFailed(componentName: string, error: Error | string, message?: string): void;
64
+ /**
65
+ * Get all components with a specific status level
66
+ */
67
+ getComponentsByStatus(statusLevel: ComponentStatusLevel): Array<{
68
+ name: string;
69
+ status: ComponentStatus;
70
+ }>;
71
+ /**
72
+ * Get a summary of all component statuses
73
+ */
74
+ getStatusSummary(): Record<ComponentStatusLevel, number>;
75
+ /**
76
+ * Static method to get aggregated component statuses from all threads
77
+ * Returns a Map with one entry per component showing overall status and thread distribution
78
+ */
79
+ static getAggregatedFromAllThreads(registry: ComponentStatusRegistry): Promise<Map<string, AggregatedComponentStatus>>;
80
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Component Status Public API
3
+ *
4
+ * This module provides the clean, simple public API for component status tracking.
5
+ * All internal implementation details are hidden behind this interface.
6
+ */
7
+ import { ComponentStatus } from './ComponentStatus.ts';
8
+ /**
9
+ * Component Status Builder
10
+ * Provides a fluent interface for reporting component status
11
+ */
12
+ export declare class ComponentStatusBuilder {
13
+ private componentName;
14
+ constructor(componentName: string);
15
+ /**
16
+ * Report component as healthy
17
+ * @param message Optional status message
18
+ * @returns this for chaining
19
+ */
20
+ healthy(message?: string): this;
21
+ /**
22
+ * Report component warning
23
+ * @param message Warning message (required for warnings)
24
+ * @returns this for chaining
25
+ */
26
+ warning(message: string): this;
27
+ /**
28
+ * Report component error
29
+ * @param message Error message
30
+ * @param error Optional error object for additional context
31
+ * @returns this for chaining
32
+ */
33
+ error(message: string, error?: Error): this;
34
+ /**
35
+ * Report component as loading
36
+ * @param message Optional loading message
37
+ * @returns this for chaining
38
+ */
39
+ loading(message?: string): this;
40
+ /**
41
+ * Report component status as unknown
42
+ * @param message Optional message explaining why status is unknown
43
+ * @returns this for chaining
44
+ */
45
+ unknown(message?: string): this;
46
+ /**
47
+ * Get the current status of this component
48
+ * @returns Current component status or undefined if not set
49
+ */
50
+ get(): ComponentStatus | undefined;
51
+ }
52
+ /**
53
+ * Get a status builder for a component
54
+ * This is the primary API for reporting component status
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Report status
59
+ * statusForComponent('my-service').healthy('Service started');
60
+ * statusForComponent('database').error('Connection failed', err);
61
+ * statusForComponent('cache').warning('Memory usage high');
62
+ *
63
+ * // Get status
64
+ * const status = statusForComponent('my-service').get();
65
+ * ```
66
+ */
67
+ export declare function statusForComponent(name: string): ComponentStatusBuilder;
68
+ /**
69
+ * Component lifecycle hooks for internal use
70
+ * These are used by the component loader
71
+ */
72
+ export declare const lifecycle: {
73
+ /**
74
+ * Mark component as starting to load
75
+ */
76
+ loading(componentName: string, message?: string): void;
77
+ /**
78
+ * Mark component as successfully loaded
79
+ */
80
+ loaded(componentName: string, message?: string): void;
81
+ /**
82
+ * Mark component as failed to load
83
+ */
84
+ failed(componentName: string, error: Error | string, message?: string): void;
85
+ };
86
+ /**
87
+ * Reset all component statuses (useful for testing)
88
+ */
89
+ export declare function reset(): void;
90
+ /**
91
+ * Status level constants for external use
92
+ */
93
+ export declare const STATUS: {
94
+ readonly HEALTHY: "healthy";
95
+ readonly WARNING: "warning";
96
+ readonly ERROR: "error";
97
+ readonly UNKNOWN: "unknown";
98
+ readonly LOADING: "loading";
99
+ };
100
+ /**
101
+ * Re-export only the types that external users need
102
+ */
103
+ export type { ComponentStatusLevel, AggregatedComponentStatus } from './types.ts';
104
+ export type { ComponentStatus } from './ComponentStatus.ts';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Cross-Thread Component Status Collection
3
+ *
4
+ * This module handles collecting component status information from all worker threads
5
+ * and aggregating it into a unified view.
6
+ */
7
+ import { ComponentStatusRegistry } from './ComponentStatusRegistry.ts';
8
+ import { ComponentStatusSummary, AggregatedComponentStatus } from './types.ts';
9
+ /**
10
+ * CrossThreadStatusCollector Class
11
+ * Handles collection of component status from all worker threads
12
+ */
13
+ export declare class CrossThreadStatusCollector {
14
+ private awaitingResponses;
15
+ private responseCheckers;
16
+ private nextRequestId;
17
+ private listenerAttached;
18
+ private readonly timeout;
19
+ private cleanupTimer;
20
+ constructor(timeoutMs?: number);
21
+ /**
22
+ * Attach the message listener for cross-thread responses
23
+ * This is done once per collector instance to avoid duplicate listeners
24
+ */
25
+ private attachListener;
26
+ /**
27
+ * Schedule cleanup of stale requests if needed
28
+ */
29
+ private scheduleCleanup;
30
+ /**
31
+ * Collect component status information from all threads
32
+ * Returns a Map with component names namespaced by worker index
33
+ */
34
+ collect(registry: ComponentStatusRegistry): Promise<Map<string, ComponentStatusSummary>>;
35
+ /**
36
+ * Get status from local thread only (fallback when cross-thread collection fails)
37
+ */
38
+ private getLocalStatusOnly;
39
+ /**
40
+ * Clean up any pending requests and timers (useful for testing)
41
+ */
42
+ cleanup(): void;
43
+ }
44
+ /**
45
+ * StatusAggregator Class
46
+ * Handles aggregation of component statuses from multiple threads
47
+ */
48
+ export declare class StatusAggregator {
49
+ /**
50
+ * Aggregate component statuses from multiple threads into aggregated view
51
+ */
52
+ static aggregate(allStatuses: Map<string, ComponentStatusSummary>): Map<string, AggregatedComponentStatus>;
53
+ /**
54
+ * Aggregate status entries for a single component across threads
55
+ */
56
+ private static aggregateComponentGroup;
57
+ /**
58
+ * Determine overall status based on priority
59
+ */
60
+ private static determineOverallStatus;
61
+ }
62
+ export declare const crossThreadCollector: CrossThreadStatusCollector;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Component Status Error Types
3
+ *
4
+ * This module defines specific error types for the component status system,
5
+ * providing better diagnostics and error handling capabilities.
6
+ */
7
+ /**
8
+ * Base error class for component status system
9
+ */
10
+ export declare class ComponentStatusError extends Error {
11
+ readonly statusCode: number;
12
+ readonly timestamp: Date;
13
+ constructor(message: string, statusCode?: number);
14
+ }
15
+ /**
16
+ * Error thrown when cross-thread status collection times out
17
+ */
18
+ export declare class CrossThreadTimeoutError extends ComponentStatusError {
19
+ readonly requestId: number;
20
+ readonly timeoutMs: number;
21
+ readonly collectedCount: number;
22
+ constructor(requestId: number, timeoutMs: number, collectedCount: number);
23
+ }
24
+ /**
25
+ * Error thrown when ITC (Inter-Thread Communication) fails
26
+ */
27
+ export declare class ITCError extends ComponentStatusError {
28
+ readonly operation: string;
29
+ readonly cause?: Error;
30
+ constructor(operation: string, cause?: Error);
31
+ }
32
+ /**
33
+ * Error thrown when component status aggregation fails
34
+ */
35
+ export declare class AggregationError extends ComponentStatusError {
36
+ readonly componentCount: number;
37
+ readonly cause?: Error;
38
+ constructor(componentCount: number, cause?: Error);
39
+ }
40
+ /**
41
+ * Error thrown when a component status operation fails
42
+ */
43
+ export declare class ComponentStatusOperationError extends ComponentStatusError {
44
+ readonly componentName: string;
45
+ readonly operation: string;
46
+ constructor(componentName: string, operation: string, message: string);
47
+ }
48
+ /**
49
+ * Information about cross-thread collection results
50
+ */
51
+ export interface CrossThreadCollectionResult {
52
+ success: boolean;
53
+ collectedFromThreads: number;
54
+ expectedThreads?: number;
55
+ timedOutThreads: number[];
56
+ errors: Error[];
57
+ }
58
+ /**
59
+ * Error thrown with detailed cross-thread collection diagnostics
60
+ */
61
+ export declare class CrossThreadCollectionError extends ComponentStatusError {
62
+ readonly result: CrossThreadCollectionResult;
63
+ constructor(result: CrossThreadCollectionResult);
64
+ /**
65
+ * Get detailed diagnostic information
66
+ */
67
+ getDiagnostics(): string;
68
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Component Status System
3
+ *
4
+ * A simple, clean API for tracking component health across Harper's distributed architecture.
5
+ *
6
+ * @example Basic usage:
7
+ * ```typescript
8
+ * import { statusForComponent, STATUS } from './components/status';
9
+ *
10
+ * // Report component status
11
+ * statusForComponent('my-service').healthy('Service initialized');
12
+ * statusForComponent('database').error('Connection timeout', error);
13
+ * statusForComponent('cache').warning('High memory usage');
14
+ *
15
+ * // Get component status
16
+ * const status = statusForComponent('my-service').get();
17
+ * ```
18
+ *
19
+ * @example Lifecycle usage (for component loader):
20
+ * ```typescript
21
+ * import { lifecycle } from './components/status';
22
+ *
23
+ * lifecycle.loading('my-component');
24
+ * // ... load component ...
25
+ * lifecycle.loaded('my-component', 'Successfully initialized');
26
+ * // or
27
+ * lifecycle.failed('my-component', error);
28
+ * ```
29
+ */
30
+ export { statusForComponent, // Main API for reporting status
31
+ lifecycle, // Component loader lifecycle hooks
32
+ reset, // Reset all statuses (testing)
33
+ STATUS } from './api.ts';
34
+ export type { ComponentStatusLevel, AggregatedComponentStatus, ComponentStatus } from './api.ts';
35
+ export * as internal from './internal.ts';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Internal Component Status Exports
3
+ *
4
+ * These exports are for Harper core internal use only.
5
+ * Components should use the public API from index.ts
6
+ */
7
+ import type { ComponentStatusLevel } from './types.ts';
8
+ export { ComponentStatus } from './ComponentStatus.ts';
9
+ export { ComponentStatusRegistry } from './ComponentStatusRegistry.ts';
10
+ export { CrossThreadStatusCollector, StatusAggregator, crossThreadCollector } from './crossThread.ts';
11
+ export type { ComponentStatusMap } from './ComponentStatusRegistry.ts';
12
+ export { componentStatusRegistry } from './registry.ts';
13
+ export * from './errors.ts';
14
+ export * from './types.ts';
15
+ export declare const query: {
16
+ /**
17
+ * Get a single component's status
18
+ */
19
+ get(componentName: string): import("./ComponentStatus.ts").ComponentStatus;
20
+ /**
21
+ * Get all component statuses in the current thread
22
+ */
23
+ all(): import("./ComponentStatusRegistry.ts").ComponentStatusMap;
24
+ /**
25
+ * Get components by status level
26
+ */
27
+ byStatus(status: ComponentStatusLevel): {
28
+ name: string;
29
+ status: import("./ComponentStatus.ts").ComponentStatus;
30
+ }[];
31
+ /**
32
+ * Get a summary of component statuses
33
+ */
34
+ summary(): Record<ComponentStatusLevel, number>;
35
+ /**
36
+ * Get aggregated status from all threads
37
+ * This is an async operation that collects status from all worker threads
38
+ */
39
+ allThreads(): Promise<Map<string, import("./types.ts").AggregatedComponentStatus>>;
40
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Component Status Registry Singleton
3
+ *
4
+ * This module provides the global component status registry instance.
5
+ */
6
+ import { ComponentStatusRegistry } from './ComponentStatusRegistry.ts';
7
+ /**
8
+ * Global component status registry instance
9
+ */
10
+ export declare const componentStatusRegistry: ComponentStatusRegistry;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Component Status Type Definitions
3
+ *
4
+ * This module defines the core types, constants, and interfaces for the
5
+ * component status tracking system.
6
+ */
7
+ /**
8
+ * Status levels for components
9
+ */
10
+ export declare const COMPONENT_STATUS_LEVELS: {
11
+ readonly HEALTHY: "healthy";
12
+ readonly WARNING: "warning";
13
+ readonly ERROR: "error";
14
+ readonly UNKNOWN: "unknown";
15
+ readonly LOADING: "loading";
16
+ };
17
+ export type ComponentStatusLevel = typeof COMPONENT_STATUS_LEVELS[keyof typeof COMPONENT_STATUS_LEVELS];
18
+ /**
19
+ * Component status information as a plain object
20
+ */
21
+ export interface ComponentStatusSummary {
22
+ /** Last time this status was checked/updated */
23
+ lastChecked: Date;
24
+ /** Current status level */
25
+ status: ComponentStatusLevel;
26
+ /** Human-readable status message */
27
+ message?: string;
28
+ /** Error information if status is 'error' */
29
+ error?: Error | string;
30
+ /** Worker index for cross-thread tracking */
31
+ workerIndex?: number;
32
+ }
33
+ /**
34
+ * Abnormal component status information for a specific thread
35
+ */
36
+ export interface ComponentStatusAbnormality {
37
+ /** Worker index for the thread with abnormal status */
38
+ workerIndex: number;
39
+ /** The abnormal status level */
40
+ status: ComponentStatusLevel;
41
+ /** Status message for this abnormal instance */
42
+ message?: string;
43
+ /** Error information if status is 'error' */
44
+ error?: Error | string;
45
+ }
46
+ /**
47
+ * Aggregated component status with thread information
48
+ */
49
+ export interface AggregatedComponentStatus {
50
+ /** Component name (without thread suffix) */
51
+ componentName: string;
52
+ /** Overall status - error if any thread has error, warning if any has warning, etc */
53
+ status: ComponentStatusLevel;
54
+ /** Last checked times for each thread (ms since epoch) */
55
+ lastChecked: {
56
+ /** Main thread last checked time (if component runs on main) */
57
+ main?: number;
58
+ /** Worker thread last checked times indexed by worker number */
59
+ workers: Record<number, number>;
60
+ };
61
+ /** Map of thread-specific statuses if they differ (only populated when inconsistent) */
62
+ abnormalities?: Map<string, ComponentStatusAbnormality>;
63
+ /** Most recent message across all threads */
64
+ latestMessage?: string;
65
+ /** Any error from any thread */
66
+ error?: Error | string;
67
+ }
68
+ /**
69
+ * Component status information from a worker thread
70
+ */
71
+ export interface WorkerComponentStatuses {
72
+ workerIndex: number | undefined;
73
+ isMainThread: boolean;
74
+ statuses: Array<[string, ComponentStatusSummary]>;
75
+ }
@@ -98,21 +98,82 @@
98
98
  ]
99
99
  },
100
100
  "hdb_license": {
101
- "hash_attribute": "license_key",
102
- "name": "hdb_license",
103
- "schema": "system",
101
+ "primaryKey": "id",
102
+ "table": "hdb_license",
103
+ "database": "system",
104
+ "audit": true,
104
105
  "attributes": [
105
106
  {
106
- "attribute": "license_key"
107
+ "attribute": "id"
107
108
  },
108
109
  {
109
- "attribute": "company"
110
+ "name": "level"
110
111
  },
111
112
  {
112
- "attribute": "__createdtime__"
113
+ "name": "region",
114
+ "indexed": true
113
115
  },
114
116
  {
115
- "attribute": "__updatedtime__"
117
+ "name": "reads"
118
+ },
119
+ {
120
+ "name": "writes"
121
+ },
122
+ {
123
+ "name": "readBytes"
124
+ },
125
+ {
126
+ "name": "writeBytes"
127
+ },
128
+ {
129
+ "name": "realTimeMessages"
130
+ },
131
+ {
132
+ "name": "realTimeBytes"
133
+ },
134
+ {
135
+ "name": "cpuTime"
136
+ },
137
+ {
138
+ "name": "storage"
139
+ },
140
+ {
141
+ "name": "usedReads"
142
+ },
143
+ {
144
+ "name": "usedWrites"
145
+ },
146
+ {
147
+ "name": "usedReadBytes"
148
+ },
149
+ {
150
+ "name": "usedWriteBytes"
151
+ },
152
+ {
153
+ "name": "usedRealTimeMessages"
154
+ },
155
+ {
156
+ "name": "usedRealTimeBytes"
157
+ },
158
+ {
159
+ "name": "usedCpuTime"
160
+ },
161
+ {
162
+ "name": "usedStorage"
163
+ },
164
+ {
165
+ "name": "expiration"
166
+ },
167
+ {
168
+ "name": "autoRenew"
169
+ },
170
+ {
171
+ "name": "__createdtime__",
172
+ "indexed": true
173
+ },
174
+ {
175
+ "name": "__updatedtime__",
176
+ "indexed": true
116
177
  }
117
178
  ]
118
179
  },