@objectstack/core 1.0.2 → 1.0.5

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 (125) hide show
  1. package/.turbo/turbo-build.log +58 -0
  2. package/CHANGELOG.md +25 -0
  3. package/dist/index.cjs +4294 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1777 -0
  6. package/dist/index.d.ts +1776 -21
  7. package/dist/index.js +4246 -23
  8. package/dist/index.js.map +1 -0
  9. package/package.json +4 -4
  10. package/tsconfig.json +1 -3
  11. package/dist/api-registry-plugin.d.ts +0 -54
  12. package/dist/api-registry-plugin.d.ts.map +0 -1
  13. package/dist/api-registry-plugin.js +0 -53
  14. package/dist/api-registry-plugin.test.d.ts +0 -2
  15. package/dist/api-registry-plugin.test.d.ts.map +0 -1
  16. package/dist/api-registry-plugin.test.js +0 -334
  17. package/dist/api-registry.d.ts +0 -259
  18. package/dist/api-registry.d.ts.map +0 -1
  19. package/dist/api-registry.js +0 -600
  20. package/dist/api-registry.test.d.ts +0 -2
  21. package/dist/api-registry.test.d.ts.map +0 -1
  22. package/dist/api-registry.test.js +0 -957
  23. package/dist/contracts/data-engine.d.ts +0 -62
  24. package/dist/contracts/data-engine.d.ts.map +0 -1
  25. package/dist/contracts/data-engine.js +0 -1
  26. package/dist/contracts/http-server.d.ts +0 -119
  27. package/dist/contracts/http-server.d.ts.map +0 -1
  28. package/dist/contracts/http-server.js +0 -11
  29. package/dist/contracts/logger.d.ts +0 -63
  30. package/dist/contracts/logger.d.ts.map +0 -1
  31. package/dist/contracts/logger.js +0 -1
  32. package/dist/dependency-resolver.d.ts +0 -62
  33. package/dist/dependency-resolver.d.ts.map +0 -1
  34. package/dist/dependency-resolver.js +0 -317
  35. package/dist/dependency-resolver.test.d.ts +0 -2
  36. package/dist/dependency-resolver.test.d.ts.map +0 -1
  37. package/dist/dependency-resolver.test.js +0 -241
  38. package/dist/health-monitor.d.ts +0 -65
  39. package/dist/health-monitor.d.ts.map +0 -1
  40. package/dist/health-monitor.js +0 -269
  41. package/dist/health-monitor.test.d.ts +0 -2
  42. package/dist/health-monitor.test.d.ts.map +0 -1
  43. package/dist/health-monitor.test.js +0 -68
  44. package/dist/hot-reload.d.ts +0 -79
  45. package/dist/hot-reload.d.ts.map +0 -1
  46. package/dist/hot-reload.js +0 -313
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/kernel-base.d.ts +0 -84
  49. package/dist/kernel-base.d.ts.map +0 -1
  50. package/dist/kernel-base.js +0 -219
  51. package/dist/kernel.d.ts +0 -113
  52. package/dist/kernel.d.ts.map +0 -1
  53. package/dist/kernel.js +0 -472
  54. package/dist/kernel.test.d.ts +0 -2
  55. package/dist/kernel.test.d.ts.map +0 -1
  56. package/dist/kernel.test.js +0 -414
  57. package/dist/lite-kernel.d.ts +0 -55
  58. package/dist/lite-kernel.d.ts.map +0 -1
  59. package/dist/lite-kernel.js +0 -112
  60. package/dist/lite-kernel.test.d.ts +0 -2
  61. package/dist/lite-kernel.test.d.ts.map +0 -1
  62. package/dist/lite-kernel.test.js +0 -161
  63. package/dist/logger.d.ts +0 -71
  64. package/dist/logger.d.ts.map +0 -1
  65. package/dist/logger.js +0 -312
  66. package/dist/logger.test.d.ts +0 -2
  67. package/dist/logger.test.d.ts.map +0 -1
  68. package/dist/logger.test.js +0 -92
  69. package/dist/plugin-loader.d.ts +0 -164
  70. package/dist/plugin-loader.d.ts.map +0 -1
  71. package/dist/plugin-loader.js +0 -319
  72. package/dist/plugin-loader.test.d.ts +0 -2
  73. package/dist/plugin-loader.test.d.ts.map +0 -1
  74. package/dist/plugin-loader.test.js +0 -348
  75. package/dist/qa/adapter.d.ts +0 -14
  76. package/dist/qa/adapter.d.ts.map +0 -1
  77. package/dist/qa/adapter.js +0 -1
  78. package/dist/qa/http-adapter.d.ts +0 -16
  79. package/dist/qa/http-adapter.d.ts.map +0 -1
  80. package/dist/qa/http-adapter.js +0 -107
  81. package/dist/qa/index.d.ts +0 -4
  82. package/dist/qa/index.d.ts.map +0 -1
  83. package/dist/qa/index.js +0 -3
  84. package/dist/qa/runner.d.ts +0 -27
  85. package/dist/qa/runner.d.ts.map +0 -1
  86. package/dist/qa/runner.js +0 -157
  87. package/dist/security/index.d.ts +0 -17
  88. package/dist/security/index.d.ts.map +0 -1
  89. package/dist/security/index.js +0 -17
  90. package/dist/security/permission-manager.d.ts +0 -96
  91. package/dist/security/permission-manager.d.ts.map +0 -1
  92. package/dist/security/permission-manager.js +0 -235
  93. package/dist/security/permission-manager.test.d.ts +0 -2
  94. package/dist/security/permission-manager.test.d.ts.map +0 -1
  95. package/dist/security/permission-manager.test.js +0 -220
  96. package/dist/security/plugin-config-validator.d.ts +0 -79
  97. package/dist/security/plugin-config-validator.d.ts.map +0 -1
  98. package/dist/security/plugin-config-validator.js +0 -166
  99. package/dist/security/plugin-config-validator.test.d.ts +0 -2
  100. package/dist/security/plugin-config-validator.test.d.ts.map +0 -1
  101. package/dist/security/plugin-config-validator.test.js +0 -223
  102. package/dist/security/plugin-permission-enforcer.d.ts +0 -154
  103. package/dist/security/plugin-permission-enforcer.d.ts.map +0 -1
  104. package/dist/security/plugin-permission-enforcer.js +0 -323
  105. package/dist/security/plugin-permission-enforcer.test.d.ts +0 -2
  106. package/dist/security/plugin-permission-enforcer.test.d.ts.map +0 -1
  107. package/dist/security/plugin-permission-enforcer.test.js +0 -205
  108. package/dist/security/plugin-signature-verifier.d.ts +0 -96
  109. package/dist/security/plugin-signature-verifier.d.ts.map +0 -1
  110. package/dist/security/plugin-signature-verifier.js +0 -250
  111. package/dist/security/sandbox-runtime.d.ts +0 -115
  112. package/dist/security/sandbox-runtime.d.ts.map +0 -1
  113. package/dist/security/sandbox-runtime.js +0 -311
  114. package/dist/security/security-scanner.d.ts +0 -92
  115. package/dist/security/security-scanner.d.ts.map +0 -1
  116. package/dist/security/security-scanner.js +0 -273
  117. package/dist/types.d.ts +0 -89
  118. package/dist/types.d.ts.map +0 -1
  119. package/dist/types.js +0 -1
  120. package/dist/utils/env.d.ts +0 -20
  121. package/dist/utils/env.d.ts.map +0 -1
  122. package/dist/utils/env.js +0 -46
  123. package/dist/utils/env.test.d.ts +0 -2
  124. package/dist/utils/env.test.d.ts.map +0 -1
  125. package/dist/utils/env.test.js +0 -52
@@ -1,92 +0,0 @@
1
- import type { SecurityVulnerability, SecurityScanResult } from '@objectstack/spec/kernel';
2
- import type { ObjectLogger } from '../logger.js';
3
- /**
4
- * Scan Target
5
- */
6
- export interface ScanTarget {
7
- pluginId: string;
8
- version: string;
9
- files?: string[];
10
- dependencies?: Record<string, string>;
11
- }
12
- /**
13
- * Security Issue
14
- */
15
- export interface SecurityIssue {
16
- id: string;
17
- severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
18
- category: 'vulnerability' | 'malware' | 'license' | 'code-quality' | 'configuration';
19
- title: string;
20
- description: string;
21
- location?: {
22
- file?: string;
23
- line?: number;
24
- column?: number;
25
- };
26
- remediation?: string;
27
- cve?: string;
28
- cvss?: number;
29
- }
30
- /**
31
- * Plugin Security Scanner
32
- *
33
- * Scans plugins for security vulnerabilities, malware, and license issues
34
- */
35
- export declare class PluginSecurityScanner {
36
- private logger;
37
- private vulnerabilityDb;
38
- private scanResults;
39
- private passThreshold;
40
- constructor(logger: ObjectLogger, config?: {
41
- passThreshold?: number;
42
- });
43
- /**
44
- * Perform a comprehensive security scan on a plugin
45
- */
46
- scan(target: ScanTarget): Promise<SecurityScanResult>;
47
- /**
48
- * Scan code for vulnerabilities
49
- */
50
- private scanCode;
51
- /**
52
- * Scan dependencies for known vulnerabilities
53
- */
54
- private scanDependencies;
55
- /**
56
- * Scan for malware patterns
57
- */
58
- private scanMalware;
59
- /**
60
- * Check license compliance
61
- */
62
- private scanLicenses;
63
- /**
64
- * Check configuration security
65
- */
66
- private scanConfiguration;
67
- /**
68
- * Calculate security score based on issues
69
- */
70
- private calculateSecurityScore;
71
- /**
72
- * Add a vulnerability to the database
73
- */
74
- addVulnerability(packageName: string, version: string, vulnerability: SecurityVulnerability): void;
75
- /**
76
- * Get scan result from cache
77
- */
78
- getScanResult(pluginId: string, version: string): SecurityScanResult | undefined;
79
- /**
80
- * Clear scan results cache
81
- */
82
- clearCache(): void;
83
- /**
84
- * Update vulnerability database from external source
85
- */
86
- updateVulnerabilityDatabase(): Promise<void>;
87
- /**
88
- * Shutdown security scanner
89
- */
90
- shutdown(): void;
91
- }
92
- //# sourceMappingURL=security-scanner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"security-scanner.d.ts","sourceRoot":"","sources":["../../src/security/security-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IAC1D,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,eAAe,CAAC;IACrF,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAe;IAG7B,OAAO,CAAC,eAAe,CAA4C;IAGnE,OAAO,CAAC,WAAW,CAAyC;IAE5D,OAAO,CAAC,aAAa,CAAc;gBAEvB,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAOrE;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8E3D;;OAEG;YACW,QAAQ;IAmBtB;;OAEG;YACW,gBAAgB;IAyC9B;;OAEG;YACW,WAAW;IAmBzB;;OAEG;YACW,YAAY;IAsB1B;;OAEG;YACW,iBAAiB;IAkB/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6B9B;;OAEG;IACH,gBAAgB,CACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,qBAAqB,GACnC,IAAI;IAWP;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIhF;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;OAEG;IACG,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAclD;;OAEG;IACH,QAAQ,IAAI,IAAI;CAMjB"}
@@ -1,273 +0,0 @@
1
- /**
2
- * Plugin Security Scanner
3
- *
4
- * Scans plugins for security vulnerabilities, malware, and license issues
5
- */
6
- export class PluginSecurityScanner {
7
- constructor(logger, config) {
8
- // Known vulnerabilities database (CVE cache)
9
- this.vulnerabilityDb = new Map();
10
- // Scan results cache
11
- this.scanResults = new Map();
12
- this.passThreshold = 70;
13
- this.logger = logger.child({ component: 'SecurityScanner' });
14
- if (config?.passThreshold !== undefined) {
15
- this.passThreshold = config.passThreshold;
16
- }
17
- }
18
- /**
19
- * Perform a comprehensive security scan on a plugin
20
- */
21
- async scan(target) {
22
- this.logger.info('Starting security scan', {
23
- pluginId: target.pluginId,
24
- version: target.version
25
- });
26
- const issues = [];
27
- try {
28
- // 1. Scan for code vulnerabilities
29
- const codeIssues = await this.scanCode(target);
30
- issues.push(...codeIssues);
31
- // 2. Scan dependencies for known vulnerabilities
32
- const depIssues = await this.scanDependencies(target);
33
- issues.push(...depIssues);
34
- // 3. Scan for malware patterns
35
- const malwareIssues = await this.scanMalware(target);
36
- issues.push(...malwareIssues);
37
- // 4. Check license compliance
38
- const licenseIssues = await this.scanLicenses(target);
39
- issues.push(...licenseIssues);
40
- // 5. Check configuration security
41
- const configIssues = await this.scanConfiguration(target);
42
- issues.push(...configIssues);
43
- // Calculate security score (0-100, higher is better)
44
- const score = this.calculateSecurityScore(issues);
45
- const result = {
46
- timestamp: new Date().toISOString(),
47
- scanner: { name: 'ObjectStack Security Scanner', version: '1.0.0' },
48
- status: score >= this.passThreshold ? 'passed' : 'failed',
49
- vulnerabilities: issues.map(issue => ({
50
- id: issue.id,
51
- severity: issue.severity,
52
- category: issue.category,
53
- title: issue.title,
54
- description: issue.description,
55
- location: issue.location ? `${issue.location.file}:${issue.location.line}` : undefined,
56
- remediation: issue.remediation,
57
- affectedVersions: [],
58
- exploitAvailable: false,
59
- patchAvailable: false,
60
- })),
61
- summary: {
62
- totalVulnerabilities: issues.length,
63
- criticalCount: issues.filter(i => i.severity === 'critical').length,
64
- highCount: issues.filter(i => i.severity === 'high').length,
65
- mediumCount: issues.filter(i => i.severity === 'medium').length,
66
- lowCount: issues.filter(i => i.severity === 'low').length,
67
- infoCount: issues.filter(i => i.severity === 'info').length,
68
- },
69
- };
70
- this.scanResults.set(`${target.pluginId}:${target.version}`, result);
71
- this.logger.info('Security scan complete', {
72
- pluginId: target.pluginId,
73
- score,
74
- status: result.status,
75
- summary: result.summary
76
- });
77
- return result;
78
- }
79
- catch (error) {
80
- this.logger.error('Security scan failed', {
81
- pluginId: target.pluginId,
82
- error
83
- });
84
- throw error;
85
- }
86
- }
87
- /**
88
- * Scan code for vulnerabilities
89
- */
90
- async scanCode(target) {
91
- const issues = [];
92
- // In a real implementation, this would:
93
- // - Parse code with AST (e.g., using @typescript-eslint/parser)
94
- // - Check for dangerous patterns (eval, Function constructor, etc.)
95
- // - Check for XSS vulnerabilities
96
- // - Check for SQL injection patterns
97
- // - Check for insecure crypto usage
98
- // - Check for path traversal vulnerabilities
99
- this.logger.debug('Code scan complete', {
100
- pluginId: target.pluginId,
101
- issuesFound: issues.length
102
- });
103
- return issues;
104
- }
105
- /**
106
- * Scan dependencies for known vulnerabilities
107
- */
108
- async scanDependencies(target) {
109
- const issues = [];
110
- if (!target.dependencies) {
111
- return issues;
112
- }
113
- // In a real implementation, this would:
114
- // - Query npm audit API
115
- // - Check GitHub Advisory Database
116
- // - Check Snyk vulnerability database
117
- // - Check OSV (Open Source Vulnerabilities)
118
- for (const [depName, version] of Object.entries(target.dependencies)) {
119
- const vulnKey = `${depName}@${version}`;
120
- const vulnerability = this.vulnerabilityDb.get(vulnKey);
121
- if (vulnerability) {
122
- issues.push({
123
- id: `vuln-${vulnerability.cve || depName}`,
124
- severity: vulnerability.severity,
125
- category: 'vulnerability',
126
- title: `Vulnerable dependency: ${depName}`,
127
- description: `${depName}@${version} has known security vulnerabilities`,
128
- remediation: vulnerability.fixedIn
129
- ? `Upgrade to ${vulnerability.fixedIn.join(' or ')}`
130
- : 'No fix available',
131
- cve: vulnerability.cve,
132
- });
133
- }
134
- }
135
- this.logger.debug('Dependency scan complete', {
136
- pluginId: target.pluginId,
137
- dependencies: Object.keys(target.dependencies).length,
138
- vulnerabilities: issues.length
139
- });
140
- return issues;
141
- }
142
- /**
143
- * Scan for malware patterns
144
- */
145
- async scanMalware(target) {
146
- const issues = [];
147
- // In a real implementation, this would:
148
- // - Check for obfuscated code
149
- // - Check for suspicious network activity patterns
150
- // - Check for crypto mining patterns
151
- // - Check for data exfiltration patterns
152
- // - Use ML-based malware detection
153
- // - Check file hashes against known malware databases
154
- this.logger.debug('Malware scan complete', {
155
- pluginId: target.pluginId,
156
- issuesFound: issues.length
157
- });
158
- return issues;
159
- }
160
- /**
161
- * Check license compliance
162
- */
163
- async scanLicenses(target) {
164
- const issues = [];
165
- if (!target.dependencies) {
166
- return issues;
167
- }
168
- // In a real implementation, this would:
169
- // - Check license compatibility
170
- // - Detect GPL contamination
171
- // - Flag proprietary dependencies
172
- // - Check for missing licenses
173
- // - Verify SPDX identifiers
174
- this.logger.debug('License scan complete', {
175
- pluginId: target.pluginId,
176
- issuesFound: issues.length
177
- });
178
- return issues;
179
- }
180
- /**
181
- * Check configuration security
182
- */
183
- async scanConfiguration(target) {
184
- const issues = [];
185
- // In a real implementation, this would:
186
- // - Check for hardcoded secrets
187
- // - Check for weak permissions
188
- // - Check for insecure defaults
189
- // - Check for missing security headers
190
- // - Check CSP policies
191
- this.logger.debug('Configuration scan complete', {
192
- pluginId: target.pluginId,
193
- issuesFound: issues.length
194
- });
195
- return issues;
196
- }
197
- /**
198
- * Calculate security score based on issues
199
- */
200
- calculateSecurityScore(issues) {
201
- // Start with perfect score
202
- let score = 100;
203
- // Deduct points based on severity
204
- for (const issue of issues) {
205
- switch (issue.severity) {
206
- case 'critical':
207
- score -= 20;
208
- break;
209
- case 'high':
210
- score -= 10;
211
- break;
212
- case 'medium':
213
- score -= 5;
214
- break;
215
- case 'low':
216
- score -= 2;
217
- break;
218
- case 'info':
219
- score -= 0;
220
- break;
221
- }
222
- }
223
- // Ensure score doesn't go below 0
224
- return Math.max(0, score);
225
- }
226
- /**
227
- * Add a vulnerability to the database
228
- */
229
- addVulnerability(packageName, version, vulnerability) {
230
- const key = `${packageName}@${version}`;
231
- this.vulnerabilityDb.set(key, vulnerability);
232
- this.logger.debug('Vulnerability added to database', {
233
- package: packageName,
234
- version,
235
- cve: vulnerability.cve
236
- });
237
- }
238
- /**
239
- * Get scan result from cache
240
- */
241
- getScanResult(pluginId, version) {
242
- return this.scanResults.get(`${pluginId}:${version}`);
243
- }
244
- /**
245
- * Clear scan results cache
246
- */
247
- clearCache() {
248
- this.scanResults.clear();
249
- this.logger.debug('Scan results cache cleared');
250
- }
251
- /**
252
- * Update vulnerability database from external source
253
- */
254
- async updateVulnerabilityDatabase() {
255
- this.logger.info('Updating vulnerability database');
256
- // In a real implementation, this would:
257
- // - Fetch from GitHub Advisory Database
258
- // - Fetch from npm audit
259
- // - Fetch from NVD (National Vulnerability Database)
260
- // - Parse and cache vulnerability data
261
- this.logger.info('Vulnerability database updated', {
262
- entries: this.vulnerabilityDb.size
263
- });
264
- }
265
- /**
266
- * Shutdown security scanner
267
- */
268
- shutdown() {
269
- this.vulnerabilityDb.clear();
270
- this.scanResults.clear();
271
- this.logger.info('Security scanner shutdown complete');
272
- }
273
- }
package/dist/types.d.ts DELETED
@@ -1,89 +0,0 @@
1
- import { ObjectKernel } from './kernel.js';
2
- import type { Logger } from '@objectstack/spec/contracts';
3
- /**
4
- * PluginContext - Runtime context available to plugins
5
- *
6
- * Provides access to:
7
- * - Service registry (registerService/getService)
8
- * - Event/Hook system (hook/trigger)
9
- * - Logger
10
- * - Kernel instance (for advanced use cases)
11
- */
12
- export interface PluginContext {
13
- /**
14
- * Register a service that can be consumed by other plugins
15
- * @param name - Service name (e.g., 'db', 'http-server', 'objectql')
16
- * @param service - Service instance
17
- */
18
- registerService(name: string, service: any): void;
19
- /**
20
- * Get a service registered by another plugin
21
- * @param name - Service name
22
- * @returns Service instance
23
- * @throws Error if service not found
24
- */
25
- getService<T>(name: string): T;
26
- /**
27
- * Get all registered services
28
- */
29
- getServices(): Map<string, any>;
30
- /**
31
- * Register a hook handler
32
- * @param name - Hook name (e.g., 'kernel:ready', 'data:beforeInsert')
33
- * @param handler - Hook handler function
34
- */
35
- hook(name: string, handler: (...args: any[]) => void | Promise<void>): void;
36
- /**
37
- * Trigger a hook
38
- * @param name - Hook name
39
- * @param args - Arguments to pass to hook handlers
40
- */
41
- trigger(name: string, ...args: any[]): Promise<void>;
42
- /**
43
- * Logger instance
44
- */
45
- logger: Logger;
46
- /**
47
- * Get the kernel instance (for advanced use cases)
48
- * @returns Kernel instance
49
- */
50
- getKernel(): ObjectKernel;
51
- }
52
- /**
53
- * Plugin Interface
54
- *
55
- * All ObjectStack plugins must implement this interface.
56
- */
57
- export interface Plugin {
58
- /**
59
- * Unique plugin name (e.g., 'com.objectstack.engine.objectql')
60
- */
61
- name: string;
62
- /**
63
- * Plugin version
64
- */
65
- version?: string;
66
- /**
67
- * List of other plugin names that this plugin depends on.
68
- * The kernel ensures these plugins are initialized before this one.
69
- */
70
- dependencies?: string[];
71
- /**
72
- * Init Phase: Register services
73
- * Called when kernel is initializing.
74
- * Use this to register services that other plugins might need.
75
- */
76
- init(ctx: PluginContext): Promise<void> | void;
77
- /**
78
- * Start Phase: Execute business logic
79
- * Called after all plugins have been initialized.
80
- * Use this to start servers, connect to DBs, or execute main logic.
81
- */
82
- start?(ctx: PluginContext): Promise<void> | void;
83
- /**
84
- * Destroy Phase: Cleanup
85
- * Called when kernel is shutting down.
86
- */
87
- destroy?(): Promise<void> | void;
88
- }
89
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IAElD;;;;;OAKG;IACH,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC;IAE/B;;OAEG;IACH,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE5E;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,IAAI,YAAY,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE/C;;;;OAIG;IACH,KAAK,CAAC,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACpC"}
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- /**
2
- * Environment utilities for universal (Node/Browser) compatibility.
3
- */
4
- export declare const isNode: boolean;
5
- /**
6
- * Safely access environment variables
7
- */
8
- export declare function getEnv(key: string, defaultValue?: string): string | undefined;
9
- /**
10
- * Safely exit the process if in Node.js
11
- */
12
- export declare function safeExit(code?: number): void;
13
- /**
14
- * Safely get memory usage
15
- */
16
- export declare function getMemoryUsage(): {
17
- heapUsed: number;
18
- heapTotal: number;
19
- };
20
- //# sourceMappingURL=env.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,MAAM,SAEgC,CAAC;AAEpD;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmB7E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,GAAE,MAAU,GAAG,IAAI,CAI/C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAKxE"}
package/dist/utils/env.js DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * Environment utilities for universal (Node/Browser) compatibility.
3
- */
4
- // Check if running in a Node.js environment
5
- export const isNode = typeof process !== 'undefined' &&
6
- process.versions != null &&
7
- process.versions.node != null;
8
- /**
9
- * Safely access environment variables
10
- */
11
- export function getEnv(key, defaultValue) {
12
- // Node.js
13
- if (typeof process !== 'undefined' && process.env) {
14
- return process.env[key] || defaultValue;
15
- }
16
- // Browser (Vite/Webpack replacement usually handles process.env,
17
- // but if not, we check safe global access)
18
- try {
19
- // @ts-ignore
20
- if (typeof globalThis !== 'undefined' && globalThis.process?.env) {
21
- // @ts-ignore
22
- return globalThis.process.env[key] || defaultValue;
23
- }
24
- }
25
- catch (e) {
26
- // Ignore access errors
27
- }
28
- return defaultValue;
29
- }
30
- /**
31
- * Safely exit the process if in Node.js
32
- */
33
- export function safeExit(code = 0) {
34
- if (isNode) {
35
- process.exit(code);
36
- }
37
- }
38
- /**
39
- * Safely get memory usage
40
- */
41
- export function getMemoryUsage() {
42
- if (isNode) {
43
- return process.memoryUsage();
44
- }
45
- return { heapUsed: 0, heapTotal: 0 };
46
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=env.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.test.d.ts","sourceRoot":"","sources":["../../src/utils/env.test.ts"],"names":[],"mappings":""}
@@ -1,52 +0,0 @@
1
- import { describe, it, expect, vi, afterEach } from 'vitest';
2
- import * as envUtils from './env';
3
- describe('Environment Utilities', () => {
4
- // Save original process
5
- const originalProcess = globalThis.process;
6
- afterEach(() => {
7
- // Restore process after each test
8
- globalThis.process = originalProcess;
9
- vi.restoreAllMocks();
10
- });
11
- describe('isNode', () => {
12
- it('should detect Node environment', () => {
13
- // Since we are running in Vitest (Node), this should be true
14
- expect(envUtils.isNode).toBe(true);
15
- });
16
- });
17
- describe('getEnv', () => {
18
- it('should retrieve environment variable in Node', () => {
19
- process.env.TEST_VAR = 'test_value';
20
- expect(envUtils.getEnv('TEST_VAR')).toBe('test_value');
21
- delete process.env.TEST_VAR;
22
- });
23
- it('should return default value if variable not found', () => {
24
- expect(envUtils.getEnv('NON_EXISTENT_VAR', 'default')).toBe('default');
25
- });
26
- it('should access globalThis.process.env if process is not available directly', () => {
27
- // This is tricky to test in Node because 'process' is globally available.
28
- // We can't easily delete global.process in strict mode or without breaking tooling.
29
- // But we can verify it works via globalThis
30
- // @ts-ignore
31
- globalThis.process.env.TEST_GLOBAL_VAR = 'global_value';
32
- expect(envUtils.getEnv('TEST_GLOBAL_VAR')).toBe('global_value');
33
- // @ts-ignore
34
- delete globalThis.process.env.TEST_GLOBAL_VAR;
35
- });
36
- });
37
- describe('getMemoryUsage', () => {
38
- it('should return memory usage in Node', () => {
39
- const usage = envUtils.getMemoryUsage();
40
- expect(usage).toHaveProperty('heapUsed');
41
- expect(usage).toHaveProperty('heapTotal');
42
- expect(usage.heapUsed).toBeGreaterThan(0);
43
- });
44
- });
45
- describe('safeExit', () => {
46
- it('should call process.exit in Node', () => {
47
- const exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => { }));
48
- envUtils.safeExit(1);
49
- expect(exitSpy).toHaveBeenCalledWith(1);
50
- });
51
- });
52
- });