@togatherlabs/shared-utils 1.0.10 β 1.2.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.
- package/README.md +206 -110
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -0
- package/dist/logger/ILogger.d.ts +97 -0
- package/dist/logger/ILogger.d.ts.map +1 -0
- package/dist/logger/ILogger.js +2 -0
- package/dist/logger/ILogger.js.map +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +2 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger.d.ts +51 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +138 -0
- package/dist/logger/logger.js.map +1 -0
- package/package.json +77 -87
- package/dist/constants/index.d.ts +0 -2
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -1
- package/dist/constants/sample.d.ts +0 -4
- package/dist/constants/sample.d.ts.map +0 -1
- package/dist/constants/sample.js +0 -3
- package/dist/helpers/formatDate.d.ts +0 -2
- package/dist/helpers/formatDate.d.ts.map +0 -1
- package/dist/helpers/formatDate.js +0 -10
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/user.d.ts +0 -6
- package/dist/types/user.d.ts.map +0 -1
- package/dist/types/user.js +0 -1
package/README.md
CHANGED
|
@@ -1,175 +1,271 @@
|
|
|
1
1
|
# @togatherlabs/shared-utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared utilities library for Togather services, providing production-grade utilities including logger, validators, and common helpers.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/@togatherlabs/shared-utils)
|
|
7
|
-
[](./LICENSE)
|
|
5
|
+
## π¦ Installation
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @togatherlabs/shared-utils
|
|
9
|
+
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
2. [Package Development](#package-development)
|
|
11
|
+
## π Features
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
### Logger Module
|
|
14
|
+
Production-ready logging built on [Pino](https://getpino.io/) with:
|
|
15
|
+
- π Automatic sensitive data redaction
|
|
16
|
+
- π Structured logging with context
|
|
17
|
+
- π¨ Environment-aware (pretty dev logs, JSON production logs)
|
|
18
|
+
- π§ Fully configurable
|
|
19
|
+
- β‘ High performance
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
4. [Best Practices](#best-practices)
|
|
22
|
-
5. [Troubleshooting](#troubleshooting)
|
|
23
|
-
6. [License](#license)
|
|
21
|
+
## π Available Modules
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
### Logger
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
```typescript
|
|
26
|
+
import { Logger, ILogger } from '@togatherlabs/shared-utils/logger';
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
// Minimal - uses defaults
|
|
29
|
+
const logger = new Logger();
|
|
30
|
+
|
|
31
|
+
// With environment config from service (recommended)
|
|
32
|
+
const logger = new Logger(undefined, {
|
|
33
|
+
nodeEnv: process.env.NODE_ENV,
|
|
34
|
+
logLevel: process.env.LOG_LEVEL,
|
|
35
|
+
serviceName: process.env.SERVICE_NAME
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
logger.info({ label: 'app' }, 'Application started');
|
|
39
|
+
logger.error({ err, label: 'database' }, 'Connection failed');
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
* **utils**: Reusable utility functions
|
|
42
|
-
* **types**: Shared TypeScript types and interfaces
|
|
43
|
-
* **index.ts**: Exports all public utilities
|
|
42
|
+
**Full documentation**: [Logger README](./src/logger/README.md)
|
|
44
43
|
|
|
45
|
-
##
|
|
44
|
+
## π§ Usage
|
|
46
45
|
|
|
47
|
-
###
|
|
46
|
+
### Basic Import
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
```typescript
|
|
49
|
+
// Import from main entry point
|
|
50
|
+
import { Logger, ILogger, type LoggerConfig } from '@togatherlabs/shared-utils';
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
// Or import from specific module
|
|
53
|
+
import { Logger, ILogger, type LoggerConfig } from '@togatherlabs/shared-utils/logger';
|
|
54
|
+
```
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
### Configuration
|
|
57
|
+
|
|
58
|
+
**Services pass environment variables via LoggerConfig:**
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Logger, type LoggerConfig } from '@togatherlabs/shared-utils/logger';
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const config: LoggerConfig = {
|
|
64
|
+
nodeEnv: process.env.NODE_ENV,
|
|
65
|
+
logLevel: process.env.LOG_LEVEL,
|
|
66
|
+
serviceName: process.env.SERVICE_NAME
|
|
67
|
+
};
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
export * from './utils';
|
|
69
|
+
const logger = new Logger(undefined, config);
|
|
66
70
|
```
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
**LoggerConfig fields:**
|
|
73
|
+
- `nodeEnv` - Environment: `'development'` (pretty logs) or `'production'` (JSON logs)
|
|
74
|
+
- `logLevel` - Log level (default: `'info'`)
|
|
75
|
+
- `serviceName` - Service name for context
|
|
76
|
+
- `hostname` - Hostname override (optional)
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
See the [Logger README](./src/logger/README.md) for detailed configuration options.
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
### With Dependency Injection
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { injectable, inject } from 'inversify';
|
|
84
|
+
import type { ILogger } from '@togatherlabs/shared-utils/logger';
|
|
85
|
+
|
|
86
|
+
@injectable()
|
|
87
|
+
class UserService {
|
|
88
|
+
constructor(
|
|
89
|
+
@inject(TYPES.Logger) private logger: ILogger
|
|
90
|
+
) {}
|
|
91
|
+
|
|
92
|
+
async createUser(data: CreateUserDTO) {
|
|
93
|
+
this.logger.info({ userId: data.id, label: 'UserService' }, 'Creating user');
|
|
94
|
+
// ... implementation
|
|
95
|
+
}
|
|
96
|
+
}
|
|
75
97
|
```
|
|
76
98
|
|
|
77
|
-
|
|
99
|
+
## π οΈ Development
|
|
78
100
|
|
|
79
|
-
|
|
101
|
+
### Setup
|
|
80
102
|
|
|
81
103
|
```bash
|
|
82
|
-
|
|
104
|
+
# Install dependencies
|
|
105
|
+
pnpm install
|
|
106
|
+
|
|
107
|
+
# Build the library
|
|
108
|
+
pnpm run build
|
|
109
|
+
|
|
110
|
+
# Run type checking
|
|
111
|
+
pnpm run typecheck
|
|
112
|
+
|
|
113
|
+
# Run linting
|
|
114
|
+
pnpm run lint
|
|
115
|
+
|
|
116
|
+
# Format code
|
|
117
|
+
pnpm run format
|
|
83
118
|
```
|
|
84
119
|
|
|
85
|
-
|
|
120
|
+
### Project Structure
|
|
86
121
|
|
|
87
|
-
```
|
|
88
|
-
|
|
122
|
+
```
|
|
123
|
+
togather-shared-utils/
|
|
124
|
+
βββ src/
|
|
125
|
+
β βββ logger/ # Logger module
|
|
126
|
+
β β βββ ILogger.ts # Logger interface
|
|
127
|
+
β β βββ logger.ts # Logger implementation
|
|
128
|
+
β β βββ index.ts # Module exports
|
|
129
|
+
β β βββ README.md # Logger documentation
|
|
130
|
+
β βββ index.ts # Main library exports
|
|
131
|
+
βββ dist/ # Compiled output (generated)
|
|
132
|
+
βββ scripts/ # Publishing scripts
|
|
133
|
+
β βββ publish.js # NPM publishing script
|
|
134
|
+
β βββ version.js # Version bumping script
|
|
135
|
+
βββ package.json
|
|
136
|
+
βββ tsconfig.json
|
|
137
|
+
βββ biome.json
|
|
138
|
+
βββ README.md
|
|
89
139
|
```
|
|
90
140
|
|
|
91
|
-
|
|
141
|
+
## π€ Publishing
|
|
92
142
|
|
|
93
|
-
|
|
143
|
+
### Version Bumping
|
|
94
144
|
|
|
95
145
|
```bash
|
|
96
|
-
|
|
146
|
+
# Bump patch version (1.0.0 -> 1.0.1) for bug fixes
|
|
147
|
+
pnpm run version:patch
|
|
148
|
+
|
|
149
|
+
# Bump minor version (1.0.0 -> 1.1.0) for new features
|
|
150
|
+
pnpm run version:minor
|
|
151
|
+
|
|
152
|
+
# Bump major version (1.0.0 -> 2.0.0) for breaking changes
|
|
153
|
+
pnpm run version:major
|
|
97
154
|
```
|
|
98
155
|
|
|
99
|
-
|
|
156
|
+
### Publishing to NPM
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Dry run (test publishing without actually publishing)
|
|
160
|
+
pnpm run publish:npm -- --dry-run
|
|
161
|
+
|
|
162
|
+
# Publish to npm with 'latest' tag
|
|
163
|
+
pnpm run publish:npm
|
|
100
164
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* Publishes to npm with public access
|
|
165
|
+
# Publish with a specific tag (e.g., beta)
|
|
166
|
+
pnpm run publish:npm -- --tag beta
|
|
167
|
+
```
|
|
105
168
|
|
|
106
|
-
|
|
169
|
+
The publish script automatically:
|
|
170
|
+
- β
Checks git status
|
|
171
|
+
- β
Runs type checking
|
|
172
|
+
- β
Runs linting
|
|
173
|
+
- β
Builds the package
|
|
174
|
+
- β
Checks if version already exists
|
|
175
|
+
- β
Publishes to npm
|
|
176
|
+
- β
Creates and pushes git tag
|
|
107
177
|
|
|
108
|
-
##
|
|
178
|
+
## π Workflow
|
|
109
179
|
|
|
110
|
-
###
|
|
180
|
+
### Adding a New Feature
|
|
111
181
|
|
|
112
|
-
|
|
182
|
+
1. Create a new branch
|
|
183
|
+
```bash
|
|
184
|
+
git checkout -b feat/new-utility
|
|
185
|
+
```
|
|
113
186
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
187
|
+
2. Make your changes and commit
|
|
188
|
+
```bash
|
|
189
|
+
git add .
|
|
190
|
+
pnpm run commit # Uses commitizen for conventional commits
|
|
191
|
+
```
|
|
117
192
|
|
|
118
|
-
|
|
193
|
+
3. Bump version
|
|
194
|
+
```bash
|
|
195
|
+
pnpm run version:minor # or patch/major
|
|
196
|
+
```
|
|
119
197
|
|
|
120
|
-
|
|
121
|
-
|
|
198
|
+
4. Push changes
|
|
199
|
+
```bash
|
|
200
|
+
git push origin feat/new-utility
|
|
201
|
+
git push --tags
|
|
202
|
+
```
|
|
122
203
|
|
|
123
|
-
|
|
124
|
-
|
|
204
|
+
5. Publish to npm
|
|
205
|
+
```bash
|
|
206
|
+
pnpm run publish:npm
|
|
207
|
+
```
|
|
125
208
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
209
|
+
## π Commit Convention
|
|
210
|
+
|
|
211
|
+
This project uses [Conventional Commits](https://www.conventionalcommits.org/):
|
|
129
212
|
|
|
130
|
-
// Log messages
|
|
131
|
-
logger.info('Service started');
|
|
132
|
-
logger.error('Failed to fetch data', { error: new Error('Network error') });
|
|
133
213
|
```
|
|
214
|
+
<type>(<scope>): <subject>
|
|
134
215
|
|
|
135
|
-
|
|
216
|
+
<body>
|
|
217
|
+
```
|
|
136
218
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
219
|
+
**Types:**
|
|
220
|
+
- `feat`: New feature
|
|
221
|
+
- `fix`: Bug fix
|
|
222
|
+
- `docs`: Documentation changes
|
|
223
|
+
- `style`: Code style changes (formatting)
|
|
224
|
+
- `refactor`: Code refactoring
|
|
225
|
+
- `test`: Adding or updating tests
|
|
226
|
+
- `chore`: Maintenance tasks
|
|
142
227
|
|
|
143
|
-
|
|
228
|
+
**Example:**
|
|
229
|
+
```
|
|
230
|
+
feat(logger): Add support for custom log formatters
|
|
231
|
+
|
|
232
|
+
Added a new option to Logger constructor that allows users to
|
|
233
|
+
provide custom formatters for log messages. This enables better
|
|
234
|
+
integration with external logging services.
|
|
235
|
+
```
|
|
144
236
|
|
|
145
|
-
|
|
237
|
+
Use `pnpm run commit` for an interactive commit prompt.
|
|
146
238
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
239
|
+
## π§ͺ Testing
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Run tests (when available)
|
|
243
|
+
pnpm test
|
|
244
|
+
|
|
245
|
+
# Run tests with coverage
|
|
246
|
+
pnpm test:coverage
|
|
247
|
+
```
|
|
150
248
|
|
|
151
|
-
|
|
249
|
+
## π Documentation
|
|
152
250
|
|
|
153
|
-
|
|
154
|
-
* Verify the import path matches the package export
|
|
251
|
+
- [Logger Documentation](./src/logger/README.md)
|
|
155
252
|
|
|
156
|
-
|
|
253
|
+
## π€ Contributing
|
|
157
254
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
255
|
+
1. Follow the commit convention
|
|
256
|
+
2. Write tests for new features
|
|
257
|
+
3. Update documentation
|
|
258
|
+
4. Ensure all checks pass before publishing
|
|
161
259
|
|
|
162
|
-
|
|
260
|
+
## π License
|
|
163
261
|
|
|
164
|
-
|
|
165
|
-
* Check changelog for breaking changes
|
|
262
|
+
Internal use only - Togather Infrastructure
|
|
166
263
|
|
|
167
|
-
|
|
264
|
+
## π Support
|
|
168
265
|
|
|
169
|
-
|
|
170
|
-
* Verify the `types` field in `package.json` points to the correct declaration file
|
|
171
|
-
* Run `pnpm build` to regenerate type definitions
|
|
266
|
+
For questions or issues, contact the platform team.
|
|
172
267
|
|
|
173
|
-
##
|
|
268
|
+
## π Related Packages
|
|
174
269
|
|
|
175
|
-
|
|
270
|
+
- [@togatherlabs/shared-protos](../togather-shared-protos) - Shared Protocol Buffers
|
|
271
|
+
- [@togatherlabs/event-sdk](../togather-shared-events) - Event handling SDK
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
|
|
1
|
+
// Main library exports
|
|
2
|
+
export * from './logger/index.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface for structured logging.
|
|
3
|
+
*/
|
|
4
|
+
export interface ILogger {
|
|
5
|
+
/**
|
|
6
|
+
* Log informational messages
|
|
7
|
+
*
|
|
8
|
+
* @param labels - Context object that can include:
|
|
9
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
10
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
11
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
12
|
+
* @param args - Values for string interpolation in the message (e.g., logger.info({}, 'User %s logged in', userId))
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* logger.info({ label: 'UserService' }, 'User created');
|
|
16
|
+
* logger.info({ label: ['UserService', 'createUser'] }, 'Creating user');
|
|
17
|
+
* logger.info({ userId: '123', label: 'UserService.createUser' }, 'User created successfully');
|
|
18
|
+
* logger.info({ label: 'UserService' }, 'User %s created with email %s', userId, email);
|
|
19
|
+
*/
|
|
20
|
+
info(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Log warning messages
|
|
23
|
+
*
|
|
24
|
+
* @param labels - Context object that can include:
|
|
25
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
26
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
27
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
28
|
+
* @param args - Values for string interpolation in the message
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* logger.warn({ label: 'RateLimiter' }, 'Rate limit approaching');
|
|
32
|
+
* logger.warn({ userId: '123', label: ['AuthService', 'login'] }, 'Multiple failed attempts');
|
|
33
|
+
* logger.warn({ label: 'RateLimiter' }, 'User %s exceeded %d requests', userId, maxRequests);
|
|
34
|
+
*/
|
|
35
|
+
warn(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Log error messages
|
|
38
|
+
*
|
|
39
|
+
* @param labels - Context object that can include:
|
|
40
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
41
|
+
* - `err`: Error - The error object for proper serialization
|
|
42
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
43
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
44
|
+
* @param args - Values for string interpolation in the message
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* logger.error({ err, label: 'DatabaseService' }, 'Connection failed');
|
|
48
|
+
* logger.error({ err, userId: '123', label: ['UserRepository', 'findById'] }, 'Query failed');
|
|
49
|
+
* logger.error({ err, label: 'DatabaseService' }, 'Failed to connect to %s on port %d', host, port);
|
|
50
|
+
*/
|
|
51
|
+
error(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Log debug messages
|
|
54
|
+
*
|
|
55
|
+
* @param labels - Context object that can include:
|
|
56
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
57
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
58
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
59
|
+
* @param args - Values for string interpolation in the message
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* logger.debug({ label: 'CacheService' }, 'Cache hit');
|
|
63
|
+
* logger.debug({ cacheKey: 'user:123', label: ['CacheService', 'get'] }, 'Retrieved from cache');
|
|
64
|
+
* logger.debug({ label: 'CacheService' }, 'Cache hit for key %s in %dms', cacheKey, duration);
|
|
65
|
+
*/
|
|
66
|
+
debug(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Log fatal messages (highest severity)
|
|
69
|
+
*
|
|
70
|
+
* @param labels - Context object that can include:
|
|
71
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
72
|
+
* - `err`: Error - The error object for proper serialization
|
|
73
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
74
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
75
|
+
* @param args - Values for string interpolation in the message
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* logger.fatal({ err, label: 'Application' }, 'Critical system failure');
|
|
79
|
+
* logger.fatal({ err, label: 'Application' }, 'System crashed after %d retries', retryCount);
|
|
80
|
+
*/
|
|
81
|
+
fatal(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Log trace messages (lowest severity)
|
|
84
|
+
*
|
|
85
|
+
* @param labels - Context object that can include:
|
|
86
|
+
* - `label`: string | string[] - Categorization labels (e.g., class name, method name, operation type)
|
|
87
|
+
* - Any other contextual data (userId, requestId, etc.)
|
|
88
|
+
* @param msg - Human-readable log message (supports string interpolation with args)
|
|
89
|
+
* @param args - Values for string interpolation in the message
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* logger.trace({ label: ['UserService', 'createUser', 'validation'] }, 'Validating input');
|
|
93
|
+
* logger.trace({ label: 'UserService' }, 'Step %d: %s', stepNumber, stepName);
|
|
94
|
+
*/
|
|
95
|
+
trace(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=ILogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILogger.d.ts","sourceRoot":"","sources":["../../src/logger/ILogger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEtE;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEtE;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEvE;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEvE;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEvE;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILogger.js","sourceRoot":"","sources":["../../src/logger/ILogger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type LoggerOptions } from 'pino';
|
|
2
|
+
import type { ILogger } from './ILogger.js';
|
|
3
|
+
export interface LoggerConfig {
|
|
4
|
+
/** Node environment (e.g., 'development', 'production', 'test') */
|
|
5
|
+
nodeEnv?: string;
|
|
6
|
+
/** Log level (e.g., 'info', 'debug', 'warn', 'error') */
|
|
7
|
+
logLevel?: string;
|
|
8
|
+
/** Service name for log context */
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
/** Hostname override */
|
|
11
|
+
hostname?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Pino logger implementation with configurable options.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Minimal - uses defaults
|
|
18
|
+
* const logger = new Logger();
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // With environment config from service
|
|
22
|
+
* const logger = new Logger(undefined, {
|
|
23
|
+
* nodeEnv: process.env.NODE_ENV,
|
|
24
|
+
* logLevel: process.env.LOG_LEVEL,
|
|
25
|
+
* serviceName: process.env.SERVICE_NAME
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With custom Pino options
|
|
30
|
+
* const logger = new Logger({
|
|
31
|
+
* level: 'debug',
|
|
32
|
+
* base: { service: 'my-service', version: '1.0.0' }
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
export declare class Logger implements ILogger {
|
|
36
|
+
private logger;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new Logger instance.
|
|
39
|
+
*
|
|
40
|
+
* @param options - logger options for advanced configuration
|
|
41
|
+
* @param config - Environment configuration passed from the service
|
|
42
|
+
*/
|
|
43
|
+
constructor(options?: LoggerOptions, config?: LoggerConfig);
|
|
44
|
+
info(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
45
|
+
warn(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
46
|
+
error(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
47
|
+
debug(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
48
|
+
fatal(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
49
|
+
trace(labels: object | string, msg?: string, ...args: unknown[]): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAa,EAAqC,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAEnF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,WAAW,YAAY;IAC5B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,MAAO,YAAW,OAAO;IACrC,OAAO,CAAC,MAAM,CAAqB;IAEnC;;;;;OAKG;gBACS,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,YAAY;IA8E1D,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIrE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIrE,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAItE,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAItE,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAItE,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGtE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import pino from 'pino';
|
|
11
|
+
import { injectable } from 'inversify';
|
|
12
|
+
import { hostname } from 'node:os';
|
|
13
|
+
/**
|
|
14
|
+
* Pino logger implementation with configurable options.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Minimal - uses defaults
|
|
18
|
+
* const logger = new Logger();
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // With environment config from service
|
|
22
|
+
* const logger = new Logger(undefined, {
|
|
23
|
+
* nodeEnv: process.env.NODE_ENV,
|
|
24
|
+
* logLevel: process.env.LOG_LEVEL,
|
|
25
|
+
* serviceName: process.env.SERVICE_NAME
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With custom Pino options
|
|
30
|
+
* const logger = new Logger({
|
|
31
|
+
* level: 'debug',
|
|
32
|
+
* base: { service: 'my-service', version: '1.0.0' }
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
let Logger = class Logger {
|
|
36
|
+
logger;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new Logger instance.
|
|
39
|
+
*
|
|
40
|
+
* @param options - logger options for advanced configuration
|
|
41
|
+
* @param config - Environment configuration passed from the service
|
|
42
|
+
*/
|
|
43
|
+
constructor(options, config) {
|
|
44
|
+
const nodeEnv = config?.nodeEnv || 'development';
|
|
45
|
+
const isDevelopment = nodeEnv === 'development';
|
|
46
|
+
const isProduction = nodeEnv === 'production';
|
|
47
|
+
const defaultOptions = {
|
|
48
|
+
level: config?.logLevel || 'info',
|
|
49
|
+
base: {
|
|
50
|
+
pid: process.pid,
|
|
51
|
+
hostname: config?.hostname || hostname(),
|
|
52
|
+
service: config?.serviceName,
|
|
53
|
+
environment: nodeEnv,
|
|
54
|
+
},
|
|
55
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
56
|
+
// Error serialization for proper error logging
|
|
57
|
+
serializers: {
|
|
58
|
+
err: pino.stdSerializers.err,
|
|
59
|
+
error: pino.stdSerializers.err,
|
|
60
|
+
req: pino.stdSerializers.req,
|
|
61
|
+
res: pino.stdSerializers.res,
|
|
62
|
+
},
|
|
63
|
+
// Redact sensitive information in production
|
|
64
|
+
redact: {
|
|
65
|
+
paths: [
|
|
66
|
+
'password',
|
|
67
|
+
'*.password',
|
|
68
|
+
'token',
|
|
69
|
+
'*.token',
|
|
70
|
+
'accessToken',
|
|
71
|
+
'*.accessToken',
|
|
72
|
+
'refreshToken',
|
|
73
|
+
'*.refreshToken',
|
|
74
|
+
'secret',
|
|
75
|
+
'*.secret',
|
|
76
|
+
'authorization',
|
|
77
|
+
'*.authorization',
|
|
78
|
+
'cookie',
|
|
79
|
+
'*.cookie',
|
|
80
|
+
'apiKey',
|
|
81
|
+
'*.apiKey',
|
|
82
|
+
],
|
|
83
|
+
remove: isProduction, // Remove in production, mask in development
|
|
84
|
+
},
|
|
85
|
+
// Pretty printing for development
|
|
86
|
+
transport: isDevelopment
|
|
87
|
+
? {
|
|
88
|
+
target: 'pino-pretty',
|
|
89
|
+
options: {
|
|
90
|
+
colorize: true,
|
|
91
|
+
translateTime: 'HH:MM:ss Z',
|
|
92
|
+
ignore: 'pid,hostname',
|
|
93
|
+
singleLine: false,
|
|
94
|
+
messageFormat: '{levelLabel} - {msg}',
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
: undefined,
|
|
98
|
+
};
|
|
99
|
+
const mergedOptions = {
|
|
100
|
+
...defaultOptions,
|
|
101
|
+
...options,
|
|
102
|
+
base: {
|
|
103
|
+
...defaultOptions.base,
|
|
104
|
+
...(options?.base || {}),
|
|
105
|
+
},
|
|
106
|
+
serializers: {
|
|
107
|
+
...defaultOptions.serializers,
|
|
108
|
+
...(options?.serializers || {}),
|
|
109
|
+
},
|
|
110
|
+
redact: options?.redact !== undefined ? options.redact : defaultOptions.redact,
|
|
111
|
+
};
|
|
112
|
+
this.logger = pino(mergedOptions);
|
|
113
|
+
}
|
|
114
|
+
info(labels, msg, ...args) {
|
|
115
|
+
this.logger.info(labels, msg, ...args);
|
|
116
|
+
}
|
|
117
|
+
warn(labels, msg, ...args) {
|
|
118
|
+
this.logger.warn(labels, msg, ...args);
|
|
119
|
+
}
|
|
120
|
+
error(labels, msg, ...args) {
|
|
121
|
+
this.logger.error(labels, msg, ...args);
|
|
122
|
+
}
|
|
123
|
+
debug(labels, msg, ...args) {
|
|
124
|
+
this.logger.debug(labels, msg, ...args);
|
|
125
|
+
}
|
|
126
|
+
fatal(labels, msg, ...args) {
|
|
127
|
+
this.logger.fatal(labels, msg, ...args);
|
|
128
|
+
}
|
|
129
|
+
trace(labels, msg, ...args) {
|
|
130
|
+
this.logger.trace(labels, msg, ...args);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
Logger = __decorate([
|
|
134
|
+
injectable(),
|
|
135
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
136
|
+
], Logger);
|
|
137
|
+
export { Logger };
|
|
138
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAA+D,MAAM,MAAM,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAanC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,MAAM,GAAZ,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66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"commit": "git-cz",
|
|
80
|
-
"package:patch": "pnpm version patch",
|
|
81
|
-
"package:minor": "pnpm version minor",
|
|
82
|
-
"package:major": "pnpm version major",
|
|
83
|
-
"package:publish": "pnpm publish --access public",
|
|
84
|
-
"release:patch": "pnpm build && git add . && pnpm commit && pnpm package:patch && git push --follow-tags && pnpm package:publish",
|
|
85
|
-
"release:minor": "pnpm build && git add . && pnpm commit && pnpm package:minor && git push --follow-tags && pnpm package:publish",
|
|
86
|
-
"release:major": "pnpm build && git add . && pnpm commit && pnpm package:major && git push --follow-tags && pnpm package:publish"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
2
|
+
"name": "@togatherlabs/shared-utils",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Shared utilities for Togather services including logger, validators, and common helpers",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepare": "husky",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"lint": "biome check .",
|
|
13
|
+
"lint:fix": "biome check . --write",
|
|
14
|
+
"format": "biome format . --write",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"prebuild": "pnpm run clean",
|
|
17
|
+
"prepublishOnly": "pnpm run build",
|
|
18
|
+
"commit": "cz",
|
|
19
|
+
"publish:npm": "./scripts/publish.sh",
|
|
20
|
+
"version:patch": "./scripts/version.sh patch",
|
|
21
|
+
"version:minor": "./scripts/version.sh minor",
|
|
22
|
+
"version:major": "./scripts/version.sh major"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"togather",
|
|
26
|
+
"utilities",
|
|
27
|
+
"logger",
|
|
28
|
+
"pino",
|
|
29
|
+
"shared"
|
|
30
|
+
],
|
|
31
|
+
"author": "Togather Team",
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"packageManager": "pnpm@10.7.1",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./logger": {
|
|
45
|
+
"import": "./dist/logger/index.js",
|
|
46
|
+
"types": "./dist/logger/index.d.ts"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"inversify": "^7.10.4",
|
|
51
|
+
"pino": "^10.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "2.2.5",
|
|
55
|
+
"@commitlint/cli": "^20.1.0",
|
|
56
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
57
|
+
"@commitlint/cz-commitlint": "^20.1.0",
|
|
58
|
+
"@commitlint/types": "^20.0.0",
|
|
59
|
+
"@types/node": "^24.9.1",
|
|
60
|
+
"commitizen": "^4.3.1",
|
|
61
|
+
"husky": "^9.1.7",
|
|
62
|
+
"pino-pretty": "^13.1.2",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"pino-pretty": "^13.1.2"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"pino-pretty": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"config": {
|
|
74
|
+
"commitizen": {
|
|
75
|
+
"path": "@commitlint/cz-commitlint"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/constants/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./sample.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../../src/constants/sample.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;CAElB,CAAC"}
|
package/dist/constants/sample.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatDate.d.ts","sourceRoot":"","sources":["../../src/helpers/formatDate.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,SAAU,GAAG,MAAM,CAU/D"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function formatDate(date, locale = "en-IN") {
|
|
2
|
-
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
3
|
-
throw new Error("Invalid Date");
|
|
4
|
-
}
|
|
5
|
-
return date.toLocaleDateString(locale, {
|
|
6
|
-
year: "numeric",
|
|
7
|
-
month: "short",
|
|
8
|
-
day: "numeric",
|
|
9
|
-
});
|
|
10
|
-
}
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/helpers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./formatDate.js";
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
package/dist/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./user.js";
|
package/dist/types/user.d.ts
DELETED
package/dist/types/user.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/dist/types/user.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|