@digilogiclabs/platform-core 1.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.
@@ -0,0 +1,97 @@
1
+ import { I as IPlatform, M as MemoryDatabase, a as MemoryCache, b as MemoryStorage, c as MemoryEmail, d as MemoryQueue, e as IDatabase } from './ConsoleEmail-XeUBAnwc.mjs';
2
+ export { C as ConsoleEmail, h as ConsoleLogger, t as EmailMessage, E as EnvSecrets, l as ICache, n as IEmail, p as ILogger, q as IMetrics, k as IQueryBuilder, o as IQueue, r as ISecrets, m as IStorage, J as Job, s as JobOptions, i as MemoryMetrics, f as MemorySecrets, N as NoopLogger, j as NoopMetrics, Q as QueryResult, S as StorageFile, g as createPlatform } from './ConsoleEmail-XeUBAnwc.mjs';
3
+ import 'zod';
4
+
5
+ /**
6
+ * Testing Utilities for Platform Core
7
+ *
8
+ * This module provides utilities for testing applications that use platform-core.
9
+ * Import from '@digilogiclabs/platform-core/testing' in your test files.
10
+ */
11
+
12
+ /**
13
+ * Create a fresh test platform with all memory adapters.
14
+ * Each call creates a new isolated platform instance.
15
+ */
16
+ declare function createTestPlatform(): IPlatform;
17
+ /**
18
+ * Test platform with access to underlying adapters for assertions.
19
+ * Allows direct inspection of emails sent, queue jobs, etc.
20
+ */
21
+ interface TestPlatformWithInternals extends IPlatform {
22
+ /** Access underlying memory database */
23
+ memoryDb: MemoryDatabase;
24
+ /** Access underlying memory cache */
25
+ memoryCache: MemoryCache;
26
+ /** Access underlying memory storage */
27
+ memoryStorage: MemoryStorage;
28
+ /** Access underlying memory email (check sent emails) */
29
+ memoryEmail: MemoryEmail;
30
+ /** Access underlying memory queue (check queued jobs) */
31
+ memoryQueue: MemoryQueue;
32
+ }
33
+ /**
34
+ * Create a test platform with direct access to underlying adapters.
35
+ * Useful for asserting on emails sent, jobs queued, etc.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const { platform, memoryEmail, memoryQueue } = createTestPlatformWithInternals();
40
+ *
41
+ * // Run your code that sends emails
42
+ * await myService.sendWelcomeEmail(user);
43
+ *
44
+ * // Assert email was sent
45
+ * const sentEmails = memoryEmail.getSentEmails();
46
+ * expect(sentEmails).toHaveLength(1);
47
+ * expect(sentEmails[0].to).toBe(user.email);
48
+ * ```
49
+ */
50
+ declare function createTestPlatformWithInternals(): TestPlatformWithInternals;
51
+ /**
52
+ * Seed test data into a memory database.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const platform = createTestPlatform();
57
+ * await seedTestData(platform.db, 'users', [
58
+ * { id: '1', name: 'Alice', email: 'alice@test.com' },
59
+ * { id: '2', name: 'Bob', email: 'bob@test.com' },
60
+ * ]);
61
+ * ```
62
+ */
63
+ declare function seedTestData<T extends Record<string, unknown>>(db: IDatabase, table: string, data: T[]): Promise<void>;
64
+ /**
65
+ * Clear all data from a test platform.
66
+ * Useful in beforeEach/afterEach hooks.
67
+ */
68
+ declare function clearTestPlatform(platform: TestPlatformWithInternals): Promise<void>;
69
+ /**
70
+ * Wait for all pending queue jobs to complete.
71
+ * Useful when testing async workflows.
72
+ *
73
+ * @param platform - Test platform with memory queue
74
+ * @param timeoutMs - Maximum time to wait (default: 5000ms)
75
+ */
76
+ declare function waitForQueueDrain(platform: TestPlatformWithInternals, timeoutMs?: number): Promise<void>;
77
+ /**
78
+ * Assert that an email was sent with specific properties.
79
+ */
80
+ declare function assertEmailSent(memoryEmail: MemoryEmail, expected: {
81
+ to?: string;
82
+ subject?: string | RegExp;
83
+ bodyContains?: string;
84
+ }): void;
85
+ /**
86
+ * Create a mock function that tracks calls.
87
+ * Simple alternative to jest.fn() for test frameworks without built-in mocking.
88
+ */
89
+ declare function createMockFn<TArgs extends unknown[], TReturn>(implementation?: (...args: TArgs) => TReturn): {
90
+ (...args: TArgs): TReturn;
91
+ calls: TArgs[];
92
+ callCount: number;
93
+ lastCall: TArgs | undefined;
94
+ reset: () => void;
95
+ };
96
+
97
+ export { IDatabase, IPlatform, MemoryCache, MemoryDatabase, MemoryEmail, MemoryQueue, MemoryStorage, type TestPlatformWithInternals, assertEmailSent, clearTestPlatform, createMockFn, createTestPlatform, createTestPlatformWithInternals, seedTestData, waitForQueueDrain };
@@ -0,0 +1,97 @@
1
+ import { I as IPlatform, M as MemoryDatabase, a as MemoryCache, b as MemoryStorage, c as MemoryEmail, d as MemoryQueue, e as IDatabase } from './ConsoleEmail-XeUBAnwc.js';
2
+ export { C as ConsoleEmail, h as ConsoleLogger, t as EmailMessage, E as EnvSecrets, l as ICache, n as IEmail, p as ILogger, q as IMetrics, k as IQueryBuilder, o as IQueue, r as ISecrets, m as IStorage, J as Job, s as JobOptions, i as MemoryMetrics, f as MemorySecrets, N as NoopLogger, j as NoopMetrics, Q as QueryResult, S as StorageFile, g as createPlatform } from './ConsoleEmail-XeUBAnwc.js';
3
+ import 'zod';
4
+
5
+ /**
6
+ * Testing Utilities for Platform Core
7
+ *
8
+ * This module provides utilities for testing applications that use platform-core.
9
+ * Import from '@digilogiclabs/platform-core/testing' in your test files.
10
+ */
11
+
12
+ /**
13
+ * Create a fresh test platform with all memory adapters.
14
+ * Each call creates a new isolated platform instance.
15
+ */
16
+ declare function createTestPlatform(): IPlatform;
17
+ /**
18
+ * Test platform with access to underlying adapters for assertions.
19
+ * Allows direct inspection of emails sent, queue jobs, etc.
20
+ */
21
+ interface TestPlatformWithInternals extends IPlatform {
22
+ /** Access underlying memory database */
23
+ memoryDb: MemoryDatabase;
24
+ /** Access underlying memory cache */
25
+ memoryCache: MemoryCache;
26
+ /** Access underlying memory storage */
27
+ memoryStorage: MemoryStorage;
28
+ /** Access underlying memory email (check sent emails) */
29
+ memoryEmail: MemoryEmail;
30
+ /** Access underlying memory queue (check queued jobs) */
31
+ memoryQueue: MemoryQueue;
32
+ }
33
+ /**
34
+ * Create a test platform with direct access to underlying adapters.
35
+ * Useful for asserting on emails sent, jobs queued, etc.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const { platform, memoryEmail, memoryQueue } = createTestPlatformWithInternals();
40
+ *
41
+ * // Run your code that sends emails
42
+ * await myService.sendWelcomeEmail(user);
43
+ *
44
+ * // Assert email was sent
45
+ * const sentEmails = memoryEmail.getSentEmails();
46
+ * expect(sentEmails).toHaveLength(1);
47
+ * expect(sentEmails[0].to).toBe(user.email);
48
+ * ```
49
+ */
50
+ declare function createTestPlatformWithInternals(): TestPlatformWithInternals;
51
+ /**
52
+ * Seed test data into a memory database.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const platform = createTestPlatform();
57
+ * await seedTestData(platform.db, 'users', [
58
+ * { id: '1', name: 'Alice', email: 'alice@test.com' },
59
+ * { id: '2', name: 'Bob', email: 'bob@test.com' },
60
+ * ]);
61
+ * ```
62
+ */
63
+ declare function seedTestData<T extends Record<string, unknown>>(db: IDatabase, table: string, data: T[]): Promise<void>;
64
+ /**
65
+ * Clear all data from a test platform.
66
+ * Useful in beforeEach/afterEach hooks.
67
+ */
68
+ declare function clearTestPlatform(platform: TestPlatformWithInternals): Promise<void>;
69
+ /**
70
+ * Wait for all pending queue jobs to complete.
71
+ * Useful when testing async workflows.
72
+ *
73
+ * @param platform - Test platform with memory queue
74
+ * @param timeoutMs - Maximum time to wait (default: 5000ms)
75
+ */
76
+ declare function waitForQueueDrain(platform: TestPlatformWithInternals, timeoutMs?: number): Promise<void>;
77
+ /**
78
+ * Assert that an email was sent with specific properties.
79
+ */
80
+ declare function assertEmailSent(memoryEmail: MemoryEmail, expected: {
81
+ to?: string;
82
+ subject?: string | RegExp;
83
+ bodyContains?: string;
84
+ }): void;
85
+ /**
86
+ * Create a mock function that tracks calls.
87
+ * Simple alternative to jest.fn() for test frameworks without built-in mocking.
88
+ */
89
+ declare function createMockFn<TArgs extends unknown[], TReturn>(implementation?: (...args: TArgs) => TReturn): {
90
+ (...args: TArgs): TReturn;
91
+ calls: TArgs[];
92
+ callCount: number;
93
+ lastCall: TArgs | undefined;
94
+ reset: () => void;
95
+ };
96
+
97
+ export { IDatabase, IPlatform, MemoryCache, MemoryDatabase, MemoryEmail, MemoryQueue, MemoryStorage, type TestPlatformWithInternals, assertEmailSent, clearTestPlatform, createMockFn, createTestPlatform, createTestPlatformWithInternals, seedTestData, waitForQueueDrain };