@sera4/essentia 1.1.66-rc.1 → 3.0.6
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.
- package/README.md +352 -8
- package/dist/ts/index.d.ts +1 -2
- package/dist/ts/index.js +1 -3
- package/dist/ts/index.js.map +1 -1
- package/dist/ts/logger/s4-logger.js +0 -2
- package/dist/ts/logger/s4-logger.js.map +1 -1
- package/dist/ts/queue/index.d.ts +2 -38
- package/dist/ts/queue/index.js +67 -136
- package/dist/ts/queue/index.js.map +1 -1
- package/package.json +51 -12
- package/package.tar.gz +0 -0
- package/cache/index.js +0 -188
- package/constants/index.js +0 -9
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/configurations/index.html +0 -116
- package/coverage/configurations/server-config.ts.html +0 -94
- package/coverage/dns/DnsCache.ts.html +0 -598
- package/coverage/dns/index.html +0 -131
- package/coverage/dns/index.ts.html +0 -94
- package/coverage/favicon.png +0 -0
- package/coverage/health/index.html +0 -116
- package/coverage/health/index.ts.html +0 -778
- package/coverage/index.html +0 -161
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/configurations/index.html +0 -116
- package/coverage/lcov-report/configurations/server-config.ts.html +0 -94
- package/coverage/lcov-report/dns/DnsCache.ts.html +0 -598
- package/coverage/lcov-report/dns/index.html +0 -131
- package/coverage/lcov-report/dns/index.ts.html +0 -94
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/health/index.html +0 -116
- package/coverage/lcov-report/health/index.ts.html +0 -778
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/logger/index.html +0 -131
- package/coverage/lcov-report/logger/index.ts.html +0 -94
- package/coverage/lcov-report/logger/s4-logger.ts.html +0 -514
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -747
- package/coverage/logger/index.html +0 -131
- package/coverage/logger/index.ts.html +0 -94
- package/coverage/logger/s4-logger.ts.html +0 -514
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/tmp/coverage-24302-1746472691313-0.json +0 -1
- package/coverage/tmp/coverage-24302-1746472691366-1.json +0 -1
- package/dist/cache/index.d.ts +0 -22
- package/dist/cache/index.js +0 -166
- package/dist/cache/index.js.map +0 -1
- package/dist/constants/index.d.ts +0 -6
- package/dist/constants/index.js +0 -9
- package/dist/constants/index.js.map +0 -1
- package/dist/coverage/block-navigation.d.ts +0 -1
- package/dist/coverage/block-navigation.js +0 -70
- package/dist/coverage/block-navigation.js.map +0 -1
- package/dist/coverage/lcov-report/block-navigation.d.ts +0 -1
- package/dist/coverage/lcov-report/block-navigation.js +0 -70
- package/dist/coverage/lcov-report/block-navigation.js.map +0 -1
- package/dist/coverage/lcov-report/prettify.d.ts +0 -0
- package/dist/coverage/lcov-report/prettify.js +0 -477
- package/dist/coverage/lcov-report/prettify.js.map +0 -1
- package/dist/coverage/lcov-report/sorter.d.ts +0 -1
- package/dist/coverage/lcov-report/sorter.js +0 -163
- package/dist/coverage/lcov-report/sorter.js.map +0 -1
- package/dist/coverage/prettify.d.ts +0 -0
- package/dist/coverage/prettify.js +0 -477
- package/dist/coverage/prettify.js.map +0 -1
- package/dist/coverage/sorter.d.ts +0 -1
- package/dist/coverage/sorter.js +0 -163
- package/dist/coverage/sorter.js.map +0 -1
- package/dist/formatter/index.d.ts +0 -37
- package/dist/formatter/index.js +0 -75
- package/dist/formatter/index.js.map +0 -1
- package/dist/hal/index.d.ts +0 -5
- package/dist/hal/index.js +0 -69
- package/dist/hal/index.js.map +0 -1
- package/dist/health/health-logger.d.ts +0 -9
- package/dist/health/health-logger.js +0 -34
- package/dist/health/health-logger.js.map +0 -1
- package/dist/health/index.d.ts +0 -19
- package/dist/health/index.js +0 -175
- package/dist/health/index.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -2
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/test-server-wrapper.d.ts +0 -120
- package/dist/helpers/test-server-wrapper.js +0 -165
- package/dist/helpers/test-server-wrapper.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/last-commit.d.ts +0 -1
- package/dist/last-commit.js +0 -12
- package/dist/last-commit.js.map +0 -1
- package/dist/last_commit/index.d.ts +0 -7
- package/dist/last_commit/index.js +0 -83
- package/dist/last_commit/index.js.map +0 -1
- package/dist/paginator/s4-pagination.d.ts +0 -9
- package/dist/paginator/s4-pagination.js +0 -49
- package/dist/paginator/s4-pagination.js.map +0 -1
- package/dist/paginator/sql-pagination.d.ts +0 -27
- package/dist/paginator/sql-pagination.js +0 -166
- package/dist/paginator/sql-pagination.js.map +0 -1
- package/dist/paper-trail/helpers.d.ts +0 -11
- package/dist/paper-trail/helpers.js +0 -74
- package/dist/paper-trail/helpers.js.map +0 -1
- package/dist/paper-trail/index.d.ts +0 -13
- package/dist/paper-trail/index.js +0 -662
- package/dist/paper-trail/index.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -14
- package/dist/prompts/index.js +0 -63
- package/dist/prompts/index.js.map +0 -1
- package/dist/queue/index.d.ts +0 -166
- package/dist/queue/index.js +0 -371
- package/dist/queue/index.js.map +0 -1
- package/dist/queue/publisher.d.ts +0 -31
- package/dist/queue/publisher.js +0 -84
- package/dist/queue/publisher.js.map +0 -1
- package/dist/queue/queue-logger.d.ts +0 -9
- package/dist/queue/queue-logger.js +0 -35
- package/dist/queue/queue-logger.js.map +0 -1
- package/dist/queue/subscriber.d.ts +0 -39
- package/dist/queue/subscriber.js +0 -97
- package/dist/queue/subscriber.js.map +0 -1
- package/dist/safe_proxy/index.d.ts +0 -13
- package/dist/safe_proxy/index.js +0 -54
- package/dist/safe_proxy/index.js.map +0 -1
- package/dist/serializer/index.d.ts +0 -5
- package/dist/serializer/index.js +0 -83
- package/dist/serializer/index.js.map +0 -1
- package/dist/test/debug-array.d.ts +0 -0
- package/dist/test/debug-array.js +0 -1
- package/dist/test/debug-array.js.map +0 -1
- package/dist/test/debug-setJSONB.d.ts +0 -0
- package/dist/test/debug-setJSONB.js +0 -1
- package/dist/test/debug-setJSONB.js.map +0 -1
- package/dist/test/prompt.test.d.ts +0 -1
- package/dist/test/prompt.test.js +0 -74
- package/dist/test/prompt.test.js.map +0 -1
- package/dist/test/s4-formatter.spec.d.ts +0 -1
- package/dist/test/s4-formatter.spec.js +0 -67
- package/dist/test/s4-formatter.spec.js.map +0 -1
- package/dist/test/s4-pagination.spec.d.ts +0 -1
- package/dist/test/s4-pagination.spec.js +0 -170
- package/dist/test/s4-pagination.spec.js.map +0 -1
- package/dist/test/safe-proxy.spec.d.ts +0 -1
- package/dist/test/safe-proxy.spec.js +0 -252
- package/dist/test/safe-proxy.spec.js.map +0 -1
- package/dist/test/serializer.spec.d.ts +0 -1
- package/dist/test/serializer.spec.js +0 -27
- package/dist/test/serializer.spec.js.map +0 -1
- package/dist/test/utils.spec.d.ts +0 -1
- package/dist/test/utils.spec.js +0 -446
- package/dist/test/utils.spec.js.map +0 -1
- package/dist/ts/task-scheduler/index.d.ts +0 -130
- package/dist/ts/task-scheduler/index.js +0 -259
- package/dist/ts/task-scheduler/index.js.map +0 -1
- package/formatter/index.js +0 -81
- package/hal/README.md +0 -54
- package/hal/index.js +0 -75
- package/health/health-logger.js +0 -40
- package/health/index.js +0 -188
- package/helpers/index.js +0 -1
- package/helpers/test-server-wrapper.js +0 -196
- package/last-commit.js +0 -12
- package/last_commit/index.js +0 -82
- package/logger/s4-logger.js +0 -128
- package/paginator/README.md +0 -183
- package/paginator/s4-pagination.js +0 -51
- package/paginator/sql-pagination.js +0 -178
- package/paper-trail/README.md +0 -68
- package/paper-trail/helpers.js +0 -99
- package/paper-trail/index.js +0 -843
- package/prompts/index.js +0 -78
- package/queue/index.js +0 -402
- package/queue/publisher.js +0 -96
- package/queue/queue-logger.js +0 -40
- package/queue/subscriber.js +0 -107
- package/safe_proxy/index.js +0 -61
- package/scripts/publish.sh +0 -46
- package/serializer/index.js +0 -90
- package/test/health.spec.js +0 -213
- package/test/prompt.test.js +0 -91
- package/test/s4-formatter.spec.js +0 -80
- package/test/s4-pagination.spec.js +0 -196
- package/test/serializer.spec.js +0 -34
- package/test/utils.spec.js +0 -145
- package/utils/index.js +0 -74
package/README.md
CHANGED
|
@@ -1,10 +1,354 @@
|
|
|
1
1
|
# ESSENTIA
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://hub.docker.com/)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
|
|
8
|
+
A comprehensive TypeScript library providing essential utilities for TWS services. Built with modern TypeScript practices and full type safety.
|
|
9
|
+
|
|
10
|
+
## Project Structure
|
|
11
|
+
|
|
12
|
+
All modules are written in TypeScript and located in the `/ts` directory:
|
|
13
|
+
|
|
14
|
+
- `/ts/logger` - S4Logger implementation with Winston integration
|
|
15
|
+
- `/ts/utils` - Utility functions (UUID validation, array conversion, etc.)
|
|
16
|
+
- `/ts/dns` - DNS caching functionality with configurable TTL
|
|
17
|
+
- `/ts/health` - Health check utilities for service monitoring
|
|
18
|
+
- `/ts/cycle` - Cycle deployment watcher for version tracking
|
|
19
|
+
- `/ts/constants` - Shared constants and configuration
|
|
20
|
+
- `/ts/helpers` - Helper functions and utilities
|
|
21
|
+
- `/ts/paginator` - Pagination utilities for SQL and data arrays
|
|
22
|
+
- `/ts/cache` - Redis cache helper with connection management
|
|
23
|
+
- `/ts/prompts` - CLI prompt utilities with argument parsing
|
|
24
|
+
- `/ts/safe-proxy` - Safe object property access with error handling
|
|
25
|
+
- `/ts/queue` - AMQP message queue management
|
|
26
|
+
- `/ts/last-commit` - Git commit information retrieval
|
|
27
|
+
- `/ts/hal` - HAL decorator for API responses
|
|
28
|
+
- `/ts/formatter` - Data formatting and error response utilities
|
|
29
|
+
- `/ts/serializer` - Sequelize model serialization utilities
|
|
30
|
+
- `/ts/paper-trail` - Data versioning and change tracking
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Install the package:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @sera4/essentia
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Basic Usage
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
sqlPaginator,
|
|
45
|
+
paginator,
|
|
46
|
+
DnsCache,
|
|
47
|
+
S4Logger,
|
|
48
|
+
utils,
|
|
49
|
+
constants
|
|
50
|
+
} from '@sera4/essentia';
|
|
51
|
+
|
|
52
|
+
// Pagination
|
|
53
|
+
const result = sqlPaginator('SELECT * FROM users', { page: 1, limit: 10 });
|
|
54
|
+
const paginated = paginator(data, { page: 1, limit: 20 });
|
|
55
|
+
|
|
56
|
+
// DNS caching
|
|
57
|
+
const dnsCache = new DnsCache();
|
|
58
|
+
const ip = await dnsCache.resolveTarget('https://example.com');
|
|
59
|
+
|
|
60
|
+
// Logging
|
|
61
|
+
const logger = new S4Logger();
|
|
62
|
+
logger.configure({ level: 'debug', service: 'my-service' });
|
|
63
|
+
logger.info('Application started');
|
|
64
|
+
|
|
65
|
+
// Utilities
|
|
66
|
+
const isValidUuid = utils.isValidUuidV4('123e4567-e89b-12d3-a456-426614174000');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Advanced Usage
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import {
|
|
73
|
+
sqlPaginator,
|
|
74
|
+
paginator,
|
|
75
|
+
DnsCache,
|
|
76
|
+
S4Logger,
|
|
77
|
+
HealthCheck,
|
|
78
|
+
CycleDeploymentWatcher,
|
|
79
|
+
halDecorator,
|
|
80
|
+
formatter,
|
|
81
|
+
queue,
|
|
82
|
+
paperTrail,
|
|
83
|
+
serializer,
|
|
84
|
+
lastCommit,
|
|
85
|
+
utils,
|
|
86
|
+
constants,
|
|
87
|
+
helpers,
|
|
88
|
+
prompts,
|
|
89
|
+
safeProxy
|
|
90
|
+
} from '@sera4/essentia';
|
|
91
|
+
|
|
92
|
+
// Pagination examples
|
|
93
|
+
const sqlResult = sqlPaginator('SELECT * FROM users WHERE active = ?', {
|
|
94
|
+
page: 1,
|
|
95
|
+
limit: 10,
|
|
96
|
+
orderBy: 'created_at',
|
|
97
|
+
orderDirection: 'DESC'
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const paginatedData = paginator(userList, {
|
|
101
|
+
page: 1,
|
|
102
|
+
limit: 20,
|
|
103
|
+
total: 100
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// DNS caching with configuration
|
|
107
|
+
const dnsCache = DnsCache.getInstance({
|
|
108
|
+
cacheTtlMs: 5000,
|
|
109
|
+
purgeIntervalMs: 120000,
|
|
110
|
+
debug: true
|
|
111
|
+
});
|
|
112
|
+
const ip = await dnsCache.resolveTarget('https://example.com');
|
|
113
|
+
|
|
114
|
+
// Logging with advanced configuration
|
|
115
|
+
const logger = new S4Logger();
|
|
116
|
+
logger.configure({
|
|
117
|
+
level: 'debug',
|
|
118
|
+
service: 'my-service',
|
|
119
|
+
format: 'json'
|
|
120
|
+
});
|
|
121
|
+
logger.info('Application started');
|
|
122
|
+
|
|
123
|
+
// Health checks
|
|
124
|
+
const healthCheck = new HealthCheck();
|
|
125
|
+
healthCheck.addCheck('database', async () => {
|
|
126
|
+
// Your database health check logic
|
|
127
|
+
return { status: 'healthy' };
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Cycle deployment monitoring
|
|
131
|
+
const watcher = CycleDeploymentWatcher.getInstance();
|
|
132
|
+
const currentVersion = watcher.getCurrentVersion('gateway');
|
|
133
|
+
|
|
134
|
+
// HAL decorator for API responses
|
|
135
|
+
const response = halDecorator(data, {
|
|
136
|
+
self: '/api/users',
|
|
137
|
+
next: '/api/users?page=2'
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Queue management
|
|
141
|
+
await queue.openConnection({
|
|
142
|
+
connectionUrl: 'amqp://localhost',
|
|
143
|
+
logEnabled: true
|
|
144
|
+
});
|
|
145
|
+
await queue.registerPublisher({
|
|
146
|
+
exchange: { name: 'my-exchange', type: 'topic' }
|
|
147
|
+
});
|
|
148
|
+
await queue.publishMessage('my-exchange', 'my-routing-key', { data: 'message' });
|
|
149
|
+
|
|
150
|
+
// Paper trail for data versioning
|
|
151
|
+
const trail = paperTrail(originalData, {
|
|
152
|
+
userId: 'user123',
|
|
153
|
+
action: 'update'
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Data serialization
|
|
157
|
+
const serialized = serializer(data, {
|
|
158
|
+
format: 'json',
|
|
159
|
+
pretty: true
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Last commit information
|
|
163
|
+
const commitInfo = await lastCommit.getLastCommit();
|
|
164
|
+
console.log(`Deployed version: ${commitInfo.hash}`);
|
|
165
|
+
|
|
166
|
+
// Utility functions
|
|
167
|
+
const safeData = safeProxy(data);
|
|
168
|
+
const helper = helpers.someHelperFunction();
|
|
169
|
+
const parser = prompts.setupCLIParser('My CLI Tool');
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Available Modules
|
|
173
|
+
|
|
174
|
+
All modules are written in TypeScript and provide full type safety:
|
|
175
|
+
|
|
176
|
+
### Core Modules
|
|
177
|
+
- **Logging**: `S4Logger` - Winston-based logging utility with multiple log levels and formatting options
|
|
178
|
+
- **DNS Cache**: `DnsCache` - Singleton class for caching DNS lookups with configurable TTL
|
|
179
|
+
- **Health Checks**: `HealthCheck` - Utilities for implementing health check endpoints
|
|
180
|
+
- **Cycle Deployment Watcher**: `CycleDeploymentWatcher` - Monitor and react to changes in Cycle deployment tags
|
|
181
|
+
- **Utils**: `utils` - General utility functions (UUID validation, array conversion, route type detection, JSONB helpers)
|
|
182
|
+
|
|
183
|
+
### Data Management
|
|
184
|
+
- **Pagination**: `sqlPaginator`, `paginator` - Utilities for handling pagination in SQL queries and data arrays
|
|
185
|
+
- **Cache**: `cache` - Redis cache helper with connection management and key generation
|
|
186
|
+
- **Serializer**: `serializer` - Sequelize model serialization utilities with custom decorators
|
|
187
|
+
- **Paper Trail**: `paperTrail` - Track changes to data models with automatic versioning and diff generation
|
|
188
|
+
|
|
189
|
+
### API & Communication
|
|
190
|
+
- **HAL Decorator**: `halDecorator` - Adds HAL (Hypertext Application Language) support to API responses
|
|
191
|
+
- **Formatter**: `formatter` - Data formatting utilities and error response formatting
|
|
192
|
+
- **Queue**: `queue` - AMQP message queue management with publishers and subscribers
|
|
193
|
+
- **Safe Proxy**: `safeProxy` - Safe object property access with error handling
|
|
194
|
+
|
|
195
|
+
### Utilities
|
|
196
|
+
- **Constants**: `constants` - Shared constants and configuration values
|
|
197
|
+
- **Helpers**: `helpers` - Helper functions and utilities
|
|
198
|
+
- **Prompts**: `prompts` - CLI prompt utilities with argument parsing
|
|
199
|
+
- **Last Commit**: `lastCommit` - Retrieve and display git commit information
|
|
200
|
+
|
|
201
|
+
### Cycle Deployment Watcher
|
|
202
|
+
|
|
203
|
+
The Cycle Deployment Watcher provides functionality to monitor and react to changes in Cycle deployment tags. It's particularly useful for tracking deployment tags in a Cycle environment.
|
|
204
|
+
|
|
205
|
+
#### Methods
|
|
206
|
+
|
|
207
|
+
- `getInstance()`: Returns the singleton instance of the watcher
|
|
208
|
+
- `getCurrentVersion(service: string)`: Returns the current version for a service
|
|
209
|
+
- `getLegacyVersion(service: string)`: Returns the legacy version for a service
|
|
210
|
+
- `getTagsForVersion(version: string)`: Returns all tags that match a specific version
|
|
211
|
+
- `addListener(listener: (tags: Record<string, string>) => void)`: Adds a listener for tag changes
|
|
212
|
+
- `destroy()`: Cleans up resources and removes all listeners
|
|
213
|
+
|
|
214
|
+
#### Environment Variables
|
|
215
|
+
|
|
216
|
+
- `CYCLE_DEPLOYMENT_VERSION`: Optional environment variable to specify the current deployment version
|
|
217
|
+
|
|
218
|
+
## TypeScript Support
|
|
219
|
+
|
|
220
|
+
This package is built entirely in TypeScript and provides:
|
|
221
|
+
|
|
222
|
+
- **Full Type Safety**: All modules include comprehensive TypeScript interfaces and type definitions
|
|
223
|
+
- **IntelliSense Support**: Complete autocomplete and IntelliSense in modern IDEs
|
|
224
|
+
- **Compile-time Error Checking**: Catch errors at compile time rather than runtime
|
|
225
|
+
- **Modern ES Modules**: Uses ES modules with proper import/export syntax
|
|
226
|
+
- **Declaration Files**: Generated `.d.ts` files for all modules
|
|
227
|
+
|
|
228
|
+
### Type Definitions
|
|
229
|
+
|
|
230
|
+
All modules export their TypeScript interfaces, allowing you to use them in your own code:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import {
|
|
234
|
+
LoggerOptions,
|
|
235
|
+
DnsCacheConfig,
|
|
236
|
+
HealthCheckOptions,
|
|
237
|
+
PaginationOptions
|
|
238
|
+
} from '@sera4/essentia';
|
|
239
|
+
|
|
240
|
+
// Use the types in your own interfaces
|
|
241
|
+
interface MyServiceConfig {
|
|
242
|
+
logger: LoggerOptions;
|
|
243
|
+
dns: DnsCacheConfig;
|
|
244
|
+
health: HealthCheckOptions;
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Contributing
|
|
249
|
+
|
|
250
|
+
When contributing new features or fixes, please:
|
|
251
|
+
|
|
252
|
+
1. Use TypeScript for all new code
|
|
253
|
+
2. Follow the existing TypeScript patterns and conventions
|
|
254
|
+
3. Include appropriate type definitions and interfaces
|
|
255
|
+
4. Add unit tests for new functionality
|
|
256
|
+
5. Update this documentation as needed
|
|
257
|
+
6. Ensure all code passes the TypeScript compiler with strict mode enabled
|
|
258
|
+
|
|
259
|
+
## Running Tests
|
|
260
|
+
|
|
261
|
+
The project uses Mocha and Chai for testing. To run the tests:
|
|
262
|
+
|
|
263
|
+
1. Install dependencies:
|
|
264
|
+
```bash
|
|
265
|
+
npm install
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
2. Run all tests:
|
|
269
|
+
```bash
|
|
270
|
+
npm test
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
3. Run tests for a specific module:
|
|
274
|
+
```bash
|
|
275
|
+
npm test -- --grep "DnsCache"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
4. Run tests with coverage:
|
|
279
|
+
```bash
|
|
280
|
+
npm run test:coverage
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
5. Run tests in watch mode (useful during development):
|
|
284
|
+
```bash
|
|
285
|
+
npm run test:watch
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Test Environment
|
|
289
|
+
|
|
290
|
+
The test environment is configured to:
|
|
291
|
+
- Use ES modules
|
|
292
|
+
- Support TypeScript
|
|
293
|
+
- Mock external dependencies
|
|
294
|
+
- Run tests in parallel
|
|
295
|
+
|
|
296
|
+
### Writing Tests
|
|
297
|
+
|
|
298
|
+
When writing new tests:
|
|
299
|
+
1. Place test files in the `test` directory, mirroring the source structure
|
|
300
|
+
2. Use `.test.ts` extension for TypeScript test files
|
|
301
|
+
3. Follow the existing test patterns and conventions
|
|
302
|
+
4. Use sinon for mocking and stubbing
|
|
303
|
+
5. Include both positive and negative test cases
|
|
304
|
+
6. Test edge cases and error conditions
|
|
305
|
+
|
|
306
|
+
Example test structure:
|
|
307
|
+
```typescript
|
|
308
|
+
import { expect } from 'chai';
|
|
309
|
+
import sinon from 'sinon';
|
|
310
|
+
import { MyModule } from '../../ts/my-module';
|
|
311
|
+
|
|
312
|
+
describe('MyModule', () => {
|
|
313
|
+
let myModule: MyModule;
|
|
314
|
+
let mockDependency: sinon.SinonStub;
|
|
315
|
+
|
|
316
|
+
beforeEach(() => {
|
|
317
|
+
myModule = new MyModule();
|
|
318
|
+
mockDependency = sinon.stub();
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
afterEach(() => {
|
|
322
|
+
sinon.restore();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('someMethod', () => {
|
|
326
|
+
it('should do something', async () => {
|
|
327
|
+
mockDependency.resolves('expected result');
|
|
328
|
+
|
|
329
|
+
const result = await myModule.someMethod();
|
|
330
|
+
|
|
331
|
+
expect(result).to.equal('expected result');
|
|
332
|
+
expect(mockDependency.calledOnce).to.be.true;
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Building
|
|
339
|
+
|
|
340
|
+
To build the project:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
npm run build
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
This will:
|
|
347
|
+
- Compile all TypeScript files to JavaScript
|
|
348
|
+
- Generate declaration files (`.d.ts`)
|
|
349
|
+
- Create source maps for debugging
|
|
350
|
+
- Output everything to the `dist/` directory
|
|
351
|
+
|
|
352
|
+
## License
|
|
353
|
+
|
|
354
|
+
This project is proprietary software. All rights reserved.
|
package/dist/ts/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./dns/index.js";
|
|
2
2
|
export * from "./logger/index.js";
|
|
3
|
+
export * from "./health/index.js";
|
|
3
4
|
export * from "./cycle/index.js";
|
|
4
5
|
export * from "./constants/index.js";
|
|
5
6
|
export * from "./utils/index.js";
|
|
@@ -12,8 +13,6 @@ export { DnsCache } from "./dns/DnsCache.js";
|
|
|
12
13
|
export { S4Logger } from "./logger/s4-logger.js";
|
|
13
14
|
export { s4Paginator as paginator } from "./paginator/index.js";
|
|
14
15
|
export { sqlPaginator } from "./paginator/index.js";
|
|
15
|
-
export { HealthCheck as healthCheck } from "./health/index.js";
|
|
16
|
-
export { default as logger } from "./logger/s4-logger.js";
|
|
17
16
|
export { default as queue } from "./queue/index.js";
|
|
18
17
|
export { default as lastCommit } from "./last-commit/index.js";
|
|
19
18
|
export { default as halDecorator } from "./hal/index.js";
|
package/dist/ts/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Export all TypeScript modules
|
|
2
2
|
export * from "./dns/index.js";
|
|
3
3
|
export * from "./logger/index.js";
|
|
4
|
+
export * from "./health/index.js";
|
|
4
5
|
export * from "./cycle/index.js";
|
|
5
6
|
export * from "./constants/index.js";
|
|
6
7
|
export * from "./utils/index.js";
|
|
@@ -14,9 +15,6 @@ export { DnsCache } from "./dns/DnsCache.js";
|
|
|
14
15
|
export { S4Logger } from "./logger/s4-logger.js";
|
|
15
16
|
export { s4Paginator as paginator } from "./paginator/index.js";
|
|
16
17
|
export { sqlPaginator } from "./paginator/index.js";
|
|
17
|
-
export { HealthCheck as healthCheck } from "./health/index.js";
|
|
18
|
-
// Export default logger instance
|
|
19
|
-
export { default as logger } from "./logger/s4-logger.js";
|
|
20
18
|
// Export default exports
|
|
21
19
|
export { default as queue } from "./queue/index.js";
|
|
22
20
|
export { default as lastCommit } from "./last-commit/index.js";
|
package/dist/ts/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AAEtC,6CAA6C;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OA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61
61
|
if (level && ["trace", "debug", "info", "error", "warn"].indexOf(level.toLowerCase()) >= 0) {
|
|
62
62
|
logger.level = level;
|
|
63
|
-
// Also update the transport level to ensure proper filtering
|
|
64
|
-
defaultTransport.level = level;
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
mute() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s4-logger.js","sourceRoot":"","sources":["../../../ts/logger/s4-logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,kBAAkB,CAAC;AAE1B,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;AAE5C,gBAAgB;AAChB,wGAAwG;AACxG,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,iFAAiF;AACjF,wCAAwC;AACxC,OAAO,CAAC,SAAS,CAAC;IAChB,KAAK,EAAE,OAAO;CACf,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAQ9E,MAAM,SAAS,GAAG;IAChB,SAAS,CAAC,IAAS;QACjB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC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GAAG,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,SAAS;QACP,OAAO;YACL,KAAK,EAAE,UAAS,OAAe,EAAE,QAAiB;gBAChD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;AAChC,eAAe,QAAQ,CAAC"}
|
package/dist/ts/queue/index.d.ts
CHANGED
|
@@ -26,19 +26,6 @@ interface UnregisterSubscriberOptions {
|
|
|
26
26
|
};
|
|
27
27
|
key: string;
|
|
28
28
|
}
|
|
29
|
-
interface FanoutQueueConfig {
|
|
30
|
-
name: string;
|
|
31
|
-
routingKey?: string;
|
|
32
|
-
options?: any;
|
|
33
|
-
}
|
|
34
|
-
interface FanoutConfiguration {
|
|
35
|
-
exchange: {
|
|
36
|
-
name: string;
|
|
37
|
-
type: "fanout";
|
|
38
|
-
options?: any;
|
|
39
|
-
};
|
|
40
|
-
queues: FanoutQueueConfig[];
|
|
41
|
-
}
|
|
42
29
|
type MessageListener = (payload: any, error?: any) => void;
|
|
43
30
|
/**
|
|
44
31
|
* An interface to AMQP service
|
|
@@ -49,7 +36,6 @@ declare class S4Queue {
|
|
|
49
36
|
private retry;
|
|
50
37
|
private pubs;
|
|
51
38
|
private subs;
|
|
52
|
-
private fanouts;
|
|
53
39
|
constructor();
|
|
54
40
|
/**
|
|
55
41
|
* Tests the connection to the service.
|
|
@@ -112,13 +98,6 @@ declare class S4Queue {
|
|
|
112
98
|
* @returns true if registered already, false otherwise
|
|
113
99
|
*/
|
|
114
100
|
hasPublisher(exchange: string): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Checks whether or not a fanout with given exchange name
|
|
117
|
-
* has been registered already
|
|
118
|
-
* @param exchange the name of the exchange.
|
|
119
|
-
* @returns true if registered already, false otherwise
|
|
120
|
-
*/
|
|
121
|
-
hasFanout(exchange: string): boolean;
|
|
122
101
|
/**
|
|
123
102
|
* Removes a previously registered publisher
|
|
124
103
|
* @param options
|
|
@@ -201,24 +180,10 @@ declare class S4Queue {
|
|
|
201
180
|
* @param listener callback
|
|
202
181
|
*/
|
|
203
182
|
addMessageListener(key: string, listener: MessageListener): void;
|
|
204
|
-
/**
|
|
205
|
-
* Registers a fanout exchange with multiple bound queues.
|
|
206
|
-
* Creates the fanout exchange if it doesn't exist, then creates and binds
|
|
207
|
-
* all specified queues to the exchange.
|
|
208
|
-
* @param config Fanout configuration with exchange and queue definitions
|
|
209
|
-
*/
|
|
210
|
-
registerFanout(config: FanoutConfiguration): Promise<void>;
|
|
211
|
-
/**
|
|
212
|
-
* Unregisters a fanout configuration by removing all associated subscribers
|
|
213
|
-
* and optionally the publisher/exchange.
|
|
214
|
-
* @param config Fanout configuration to unregister
|
|
215
|
-
* @param removeExchange Whether to also remove the exchange (default: false)
|
|
216
|
-
*/
|
|
217
|
-
unregisterFanout(config: FanoutConfiguration, removeExchange?: boolean): Promise<void>;
|
|
218
183
|
/**
|
|
219
184
|
* Updates the connection reference to all the previously
|
|
220
|
-
* registered publishers
|
|
221
|
-
* After we successfully establish a connection and register pubs/subs
|
|
185
|
+
* registered publishers and subscribers.
|
|
186
|
+
* After we successfully establish a connection and register pubs/subs,
|
|
222
187
|
* it's possible for the connection to break. This object will try
|
|
223
188
|
* to re-establish a new connection every 3 seconds (or whatever configuration is set)
|
|
224
189
|
* and if a new connection is established, we need to pass that connection to
|
|
@@ -229,4 +194,3 @@ declare class S4Queue {
|
|
|
229
194
|
}
|
|
230
195
|
declare const queue: S4Queue;
|
|
231
196
|
export default queue;
|
|
232
|
-
export type { FanoutConfiguration, FanoutQueueConfig, Exchange, PublisherOptions, SubscriberOptions };
|