@gravito/core 2.0.6 → 3.0.1

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 (72) hide show
  1. package/README.md +64 -25
  2. package/dist/Application.d.ts +2 -9
  3. package/dist/Container.d.ts +18 -1
  4. package/dist/GravitoServer.d.ts +8 -8
  5. package/dist/HookManager.d.ts +36 -34
  6. package/dist/PlanetCore.d.ts +54 -0
  7. package/dist/Route.d.ts +5 -0
  8. package/dist/Router.d.ts +14 -1
  9. package/dist/adapters/bun/BunContext.d.ts +1 -1
  10. package/dist/adapters/bun/BunNativeAdapter.d.ts +11 -1
  11. package/dist/adapters/bun/FastPathRegistry.d.ts +31 -0
  12. package/dist/adapters/bun/RadixNode.d.ts +4 -3
  13. package/dist/adapters/bun/RadixRouter.d.ts +2 -2
  14. package/dist/adapters/bun/types.d.ts +7 -0
  15. package/dist/adapters/types.d.ts +20 -0
  16. package/dist/compat/async-local-storage.d.ts +5 -1
  17. package/dist/compat/async-local-storage.js.map +2 -2
  18. package/dist/compat/crypto.d.ts +6 -1
  19. package/dist/compat/crypto.js.map +2 -2
  20. package/dist/engine/AOTRouter.d.ts +1 -1
  21. package/dist/engine/FastContext.d.ts +4 -4
  22. package/dist/engine/MinimalContext.d.ts +3 -3
  23. package/dist/engine/index.js +29 -8
  24. package/dist/engine/index.js.map +10 -10
  25. package/dist/engine/types.d.ts +5 -5
  26. package/dist/events/CircuitBreaker.d.ts +12 -0
  27. package/dist/events/MessageQueueBridge.d.ts +2 -1
  28. package/dist/events/observability/EventMetrics.d.ts +1 -2
  29. package/dist/events/observability/ObservableHookManager.d.ts +1 -1
  30. package/dist/exceptions/AuthException.d.ts +19 -0
  31. package/dist/exceptions/AuthenticationException.d.ts +9 -3
  32. package/dist/exceptions/AuthorizationException.d.ts +2 -2
  33. package/dist/exceptions/CacheException.d.ts +9 -0
  34. package/dist/exceptions/CircularDependencyException.d.ts +2 -1
  35. package/dist/exceptions/ConfigurationException.d.ts +9 -0
  36. package/dist/exceptions/ContainerBindingCollisionException.d.ts +10 -0
  37. package/dist/exceptions/DatabaseException.d.ts +9 -0
  38. package/dist/exceptions/DomainException.d.ts +9 -0
  39. package/dist/exceptions/InfrastructureException.d.ts +17 -0
  40. package/dist/exceptions/MiddlewareDriftException.d.ts +10 -0
  41. package/dist/exceptions/QueueException.d.ts +9 -0
  42. package/dist/exceptions/StorageException.d.ts +9 -0
  43. package/dist/exceptions/StreamException.d.ts +9 -0
  44. package/dist/exceptions/SystemException.d.ts +9 -0
  45. package/dist/exceptions/ValidationException.d.ts +2 -2
  46. package/dist/exceptions/index.d.ts +12 -0
  47. package/dist/ffi/NativeAccelerator.js.map +3 -3
  48. package/dist/ffi/NativeHasher.d.ts +14 -0
  49. package/dist/ffi/NativeHasher.js +24 -1
  50. package/dist/ffi/NativeHasher.js.map +4 -4
  51. package/dist/ffi/cbor-fallback.js.map +1 -1
  52. package/dist/ffi/hash-fallback.d.ts +15 -0
  53. package/dist/ffi/hash-fallback.js +12 -1
  54. package/dist/ffi/hash-fallback.js.map +3 -3
  55. package/dist/ffi/types.d.ts +13 -0
  56. package/dist/ffi/types.js.map +1 -1
  57. package/dist/hooks/types.d.ts +7 -3
  58. package/dist/http/types.d.ts +2 -2
  59. package/dist/index.browser.d.ts +5 -5
  60. package/dist/index.browser.js +190 -47
  61. package/dist/index.browser.js.map +50 -46
  62. package/dist/index.d.ts +17 -7
  63. package/dist/index.js +613 -202
  64. package/dist/index.js.map +82 -68
  65. package/dist/runtime/NativeOrbitDetector.d.ts +59 -0
  66. package/dist/runtime/index.browser.d.ts +1 -1
  67. package/dist/runtime/index.d.ts +7 -0
  68. package/dist/runtime.d.ts +1 -1
  69. package/dist/testing/HttpTester.d.ts +4 -4
  70. package/dist/testing/TestResponse.d.ts +4 -4
  71. package/dist/types.d.ts +3 -3
  72. package/package.json +4 -3
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Native Orbit Detector — Bun capability introspection utility.
3
+ *
4
+ * Allows any Orbit to probe Bun-native APIs without importing Bun directly.
5
+ * All Bun access is performed via globalThis type narrowing.
6
+ *
7
+ * @module runtime/NativeOrbitDetector
8
+ * @since 3.3.0
9
+ */
10
+ /**
11
+ * A frozen snapshot of Bun-native capability flags detected at runtime.
12
+ */
13
+ export interface NativeFeatures {
14
+ readonly runtime: 'bun' | 'node' | 'deno' | 'unknown';
15
+ readonly bunVersion: string | null;
16
+ readonly password: {
17
+ readonly available: boolean;
18
+ readonly argon2id: boolean;
19
+ readonly bcrypt: boolean;
20
+ };
21
+ readonly cryptoHasher: {
22
+ readonly available: boolean;
23
+ readonly sha256: boolean;
24
+ readonly sha512: boolean;
25
+ readonly blake2b: boolean;
26
+ };
27
+ readonly glob: boolean;
28
+ }
29
+ /**
30
+ * Utility that detects and caches Bun-native capabilities.
31
+ *
32
+ * Usage:
33
+ * ```typescript
34
+ * const features = NativeOrbitDetector.detectBunCapabilities()
35
+ * if (features.cryptoHasher.sha512) { ... }
36
+ * ```
37
+ */
38
+ export declare class NativeOrbitDetector {
39
+ /** @internal */
40
+ private static cached;
41
+ /**
42
+ * Detect Bun capabilities and return a frozen, cached NativeFeatures object.
43
+ * On non-Bun runtimes, all native fields are false and runtime is set accordingly.
44
+ */
45
+ static detectBunCapabilities(): NativeFeatures;
46
+ /**
47
+ * Reset the capability cache. Used in tests.
48
+ */
49
+ static reset(): void;
50
+ }
51
+ /**
52
+ * Format a human-readable capability report for logging.
53
+ *
54
+ * @example
55
+ * ```
56
+ * [gravito] native: Bun.password argon2id ✓, Bun.CryptoHasher ✓, Bun.Glob ✓
57
+ * ```
58
+ */
59
+ export declare function formatCapabilityReport(f: NativeFeatures): string;
@@ -12,7 +12,7 @@ export declare function getArchiveAdapter(): void;
12
12
  export declare function getCompressionAdapter(): void;
13
13
  export declare function createHtmlRenderCallbacks(): void;
14
14
  export declare function getMarkdownAdapter(): void;
15
- export declare function getDeepEquals(): (a: any, b: any) => boolean;
15
+ export declare function getDeepEquals(): (a: unknown, b: unknown) => boolean;
16
16
  export declare function getEscapeHtml(): (str: string) => string;
17
17
  /**
18
18
  * Convert various data types to Uint8Array.
@@ -10,6 +10,8 @@
10
10
  import type { RuntimeAdapter, RuntimePasswordAdapter, RuntimeSqliteDatabase } from './types';
11
11
  export type { ArchiveCreateOptions, ArchiveEntry, ArchiveExtractOptions, ArchiveFileInfo, ArchiveFromDirectoryOptions, CompressionOptions, MarkdownRenderCallbacks, MarkdownRenderOptions, OptionalRuntimeResourceUsage, RuntimeAdapter, RuntimeArchiveAdapter, RuntimeCompressionAdapter, RuntimeFileSink, RuntimeFileStat, RuntimeKind, RuntimeMarkdownAdapter, RuntimePasswordAdapter, RuntimeProcess, RuntimeProcessOutput, RuntimeResourceUsage, RuntimeServeConfig, RuntimeServer, RuntimeSpawnOptions, RuntimeSpawnSyncResult, RuntimeSqliteDatabase, RuntimeSqliteStatement, } from './types';
12
12
  export { getRuntimeEnv, getRuntimeKind } from './detection';
13
+ export type { NativeFeatures } from './NativeOrbitDetector';
14
+ export { NativeOrbitDetector, formatCapabilityReport } from './NativeOrbitDetector';
13
15
  export { archiveFromDirectory, getArchiveAdapter, } from './archive';
14
16
  export { getCompressionAdapter } from './compression';
15
17
  export { createHtmlRenderCallbacks, getMarkdownAdapter } from './markdown';
@@ -32,6 +34,11 @@ export declare function resetRuntimeAdapter(): void;
32
34
  * @public
33
35
  */
34
36
  export declare function getPasswordAdapter(): RuntimePasswordAdapter;
37
+ /**
38
+ * Reset the password adapter singleton (mainly for testing).
39
+ * @internal
40
+ */
41
+ export declare function resetPasswordAdapter(): void;
35
42
  /**
36
43
  * Create a SQLite database connection using runtime-native drivers.
37
44
  * @public
package/dist/runtime.d.ts CHANGED
@@ -8,4 +8,4 @@
8
8
  * @since 3.2.0
9
9
  */
10
10
  export type { ArchiveCreateOptions, ArchiveEntry, ArchiveExtractOptions, ArchiveFileInfo, ArchiveFromDirectoryOptions, CompressionOptions, EscapeHtmlFn, MarkdownRenderCallbacks, MarkdownRenderOptions, OptionalRuntimeResourceUsage, RuntimeAdapter, RuntimeArchiveAdapter, RuntimeCompressionAdapter, RuntimeFileSink, RuntimeFileStat, RuntimeKind, RuntimeMarkdownAdapter, RuntimePasswordAdapter, RuntimeProcess, RuntimeProcessOutput, RuntimeResourceUsage, RuntimeServeConfig, RuntimeServer, RuntimeSpawnOptions, RuntimeSpawnSyncResult, RuntimeSqliteDatabase, RuntimeSqliteStatement, } from './runtime/index';
11
- export { archiveFromDirectory, createHtmlRenderCallbacks, createSqliteDatabase, getArchiveAdapter, getCompressionAdapter, getEscapeHtml, getMarkdownAdapter, getPasswordAdapter, getRuntimeAdapter, getRuntimeEnv, getRuntimeKind, resetRuntimeAdapter, toUint8Array, } from './runtime/index';
11
+ export { archiveFromDirectory, createHtmlRenderCallbacks, createSqliteDatabase, getArchiveAdapter, getCompressionAdapter, getEscapeHtml, getMarkdownAdapter, getPasswordAdapter, resetPasswordAdapter, getRuntimeAdapter, getRuntimeEnv, getRuntimeKind, resetRuntimeAdapter, toUint8Array, } from './runtime/index';
@@ -15,19 +15,19 @@ export declare class HttpTester {
15
15
  /**
16
16
  * Make a POST request
17
17
  */
18
- post(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
18
+ post(uri: string, data?: unknown, headers?: Record<string, string>): Promise<TestResponse>;
19
19
  /**
20
20
  * Make a PUT request
21
21
  */
22
- put(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
22
+ put(uri: string, data?: unknown, headers?: Record<string, string>): Promise<TestResponse>;
23
23
  /**
24
24
  * Make a PATCH request
25
25
  */
26
- patch(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
26
+ patch(uri: string, data?: unknown, headers?: Record<string, string>): Promise<TestResponse>;
27
27
  /**
28
28
  * Make a DELETE request
29
29
  */
30
- delete(uri: string, data?: any, headers?: Record<string, string>): Promise<TestResponse>;
30
+ delete(uri: string, data?: unknown, headers?: Record<string, string>): Promise<TestResponse>;
31
31
  /**
32
32
  * Core call method
33
33
  */
@@ -38,15 +38,15 @@ export declare class TestResponse {
38
38
  /**
39
39
  * Assert that the response contains the given JSON data.
40
40
  */
41
- assertJson(data: any): Promise<this>;
41
+ assertJson(data: unknown): Promise<this>;
42
42
  /**
43
43
  * Assert that the response contains exactly the given JSON data.
44
44
  */
45
- assertExactJson(data: any): Promise<this>;
45
+ assertExactJson(data: unknown): Promise<this>;
46
46
  /**
47
47
  * Assert the structure of the JSON response.
48
48
  */
49
- assertJsonStructure(structure: any): Promise<this>;
49
+ assertJsonStructure(structure: unknown): Promise<this>;
50
50
  /**
51
51
  * Assert that the response contains the given string.
52
52
  */
@@ -66,7 +66,7 @@ export declare class TestResponse {
66
66
  /**
67
67
  * Get the JSON content
68
68
  */
69
- getJson(): Promise<any>;
69
+ getJson(): Promise<unknown>;
70
70
  /**
71
71
  * Get the text content
72
72
  */
package/dist/types.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * 用於解耦核心引擎與具體單體/微服務插件
4
4
  */
5
5
  export interface GravitoContext {
6
- req: any;
7
- res: any;
8
- json(data: any, status?: number): Response;
6
+ req: unknown;
7
+ res: unknown;
8
+ json(data: unknown, status?: number): Response;
9
9
  text(text: string, status?: number): Response;
10
10
  redirect(url: string, status?: number): Response;
11
11
  get<T>(key: string): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/core",
3
- "version": "2.0.6",
3
+ "version": "3.0.1",
4
4
  "description": "",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
@@ -9,9 +9,9 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
+ "types": "./dist/index.d.ts",
12
13
  "browser": "./dist/index.browser.js",
13
14
  "bun": "./dist/index.js",
14
- "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
16
  },
17
17
  "./compat": {
@@ -57,7 +57,8 @@
57
57
  "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
58
58
  "prepublishOnly": "bun run typecheck && bun run test && bun run build",
59
59
  "test:unit": "bun test $(find tests -name '*.test.ts' ! -name '*.integration.test.ts' 2>/dev/null | tr '\\n' ' ') --timeout=10000",
60
- "test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'"
60
+ "test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'",
61
+ "publint": "publint"
61
62
  },
62
63
  "keywords": [],
63
64
  "author": "Carl Lee <carllee0520@gmail.com>",