@webpieces/http-api 0.2.16 → 0.2.21
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/package.json +4 -2
- package/src/ContextReader.d.ts +1 -0
- package/src/ContextReader.js +3 -0
- package/src/ContextReader.js.map +1 -0
- package/src/HeaderMethods.d.ts +94 -0
- package/src/HeaderMethods.js +122 -0
- package/src/HeaderMethods.js.map +1 -0
- package/src/HeaderTypes.d.ts +29 -0
- package/src/HeaderTypes.js +33 -0
- package/src/HeaderTypes.js.map +1 -0
- package/src/LogApiCall.d.ts +41 -0
- package/src/LogApiCall.js +77 -0
- package/src/LogApiCall.js.map +1 -0
- package/src/PlatformHeader.d.ts +43 -0
- package/src/PlatformHeader.js +32 -0
- package/src/PlatformHeader.js.map +1 -0
- package/src/PlatformHeadersExtension.d.ts +51 -0
- package/src/PlatformHeadersExtension.js +55 -0
- package/src/PlatformHeadersExtension.js.map +1 -0
- package/src/datetime.d.ts +284 -0
- package/src/datetime.js +270 -0
- package/src/datetime.js.map +1 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +19 -1
- package/src/index.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformHeadersExtension.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/PlatformHeadersExtension.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAa,wBAAwB;IAMjC,YAAY,OAAyB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAjBD,4DAiBC","sourcesContent":["import { PlatformHeader } from './PlatformHeader';\n\n/**\n * PlatformHeadersExtension - Extension that contributes platform headers to the framework.\n *\n * This is a DI-level extension (not an app-level Plugin).\n * Multiple modules can bind PlatformHeadersExtension instances, and the framework\n * collects them via Inversify @multiInject.\n *\n * Two-level plugin system:\n * 1. **Extensions** (DI-level): Contribute specific capabilities to framework\n * - Examples: PlatformHeadersExtension, BodyContentExtension, EntityLookupExtension\n * - Pattern: Bound via multiInject, consumed by framework\n * - Java equivalent: Multibinder<AddPlatformHeaders>, Multibinder<BodyContentBinder>\n *\n * 2. **Plugins** (App-level): Provide complete features with modules + routes\n * - Examples: HibernatePlugin, JacksonPlugin, Auth0Plugin\n * - Pattern: Implements getGuiceModules() + getRouteModules()\n * - Java equivalent: Plugin interface with getGuiceModules() + getRouteModules()\n *\n * Usage:\n * ```typescript\n * // In WebpiecesModule\n * const coreExtension = new PlatformHeadersExtension([\n * WebpiecesCoreHeaders.REQUEST_ID,\n * WebpiecesCoreHeaders.CORRELATION_ID,\n * ]);\n * bind(HEADER_TYPES.PlatformHeadersExtension).toConstantValue(coreExtension);\n *\n * // In CompanyModule\n * const companyExtension = new PlatformHeadersExtension([\n * CompanyHeaders.TENANT_ID,\n * CompanyHeaders.API_VERSION,\n * ]);\n * bind(HEADER_TYPES.PlatformHeadersExtension).toConstantValue(companyExtension);\n *\n * // Framework collects all extensions\n * constructor(@multiInject(HEADER_TYPES.PlatformHeadersExtension) extensions: PlatformHeadersExtension[]) {}\n * ```\n */\nexport class PlatformHeadersExtension {\n /**\n * The set of platform headers contributed by this extension.\n */\n readonly headers: PlatformHeader[];\n\n constructor(headers: PlatformHeader[]) {\n this.headers = headers;\n }\n\n /**\n * Get all headers from this extension.\n * @returns Array of platform headers\n */\n getHeaders(): PlatformHeader[] {\n return this.headers;\n }\n}\n"]}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date/Time DTOs and Utilities for JSON serialization (inspired by Java Time / JSR-310)
|
|
3
|
+
*
|
|
4
|
+
* DTOs are simple interfaces - just data, no logic!
|
|
5
|
+
* Utilities provide conversion logic.
|
|
6
|
+
*
|
|
7
|
+
* Design Philosophy:
|
|
8
|
+
* - DTOs are plain objects with { value: string } - perfect for JSON.stringify/parse
|
|
9
|
+
* - Utilities contain ALL conversion logic (no business logic in DTOs)
|
|
10
|
+
* - Store as ISO-8601 strings (human-readable, unambiguous, sortable)
|
|
11
|
+
* - Always use UTC for timestamps (avoid timezone confusion)
|
|
12
|
+
*
|
|
13
|
+
* References:
|
|
14
|
+
* - Java Time API (JSR-310): https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html
|
|
15
|
+
* - ISO-8601: https://www.iso.org/iso-8601-date-and-time-format.html
|
|
16
|
+
* - REST API Best Practices: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* InstantDto - Represents an absolute point in time (UTC).
|
|
20
|
+
*
|
|
21
|
+
* Equivalent to Java's java.time.Instant or JavaScript's Date.
|
|
22
|
+
*
|
|
23
|
+
* **Use cases:**
|
|
24
|
+
* - Timestamps (createdAt, updatedAt, lastModified)
|
|
25
|
+
* - Audit logs
|
|
26
|
+
* - Event timestamps
|
|
27
|
+
* - Any absolute point in time
|
|
28
|
+
*
|
|
29
|
+
* **JSON format:** ISO-8601 string with UTC timezone (Z suffix)
|
|
30
|
+
* - Example: "2024-12-03T14:30:00.000Z"
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const now = InstantUtil.now();
|
|
35
|
+
* const json = JSON.stringify({ timestamp: now });
|
|
36
|
+
* // {"timestamp":{"value":"2024-12-03T14:30:00.000Z"}}
|
|
37
|
+
*
|
|
38
|
+
* const parsed = JSON.parse(json);
|
|
39
|
+
* const date = InstantUtil.toDate(parsed.timestamp);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export interface InstantDto {
|
|
43
|
+
/**
|
|
44
|
+
* ISO-8601 string in UTC with Z suffix.
|
|
45
|
+
* Example: "2024-12-03T14:30:00.000Z"
|
|
46
|
+
*/
|
|
47
|
+
value: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* DateDto - Represents a date without time or timezone (e.g., 2024-12-03).
|
|
51
|
+
*
|
|
52
|
+
* Equivalent to Java's java.time.LocalDate.
|
|
53
|
+
*
|
|
54
|
+
* **Use cases:**
|
|
55
|
+
* - Birth dates
|
|
56
|
+
* - Holidays
|
|
57
|
+
* - Calendar dates
|
|
58
|
+
* - Any date where time/timezone is irrelevant
|
|
59
|
+
*
|
|
60
|
+
* **JSON format:** ISO-8601 date string (YYYY-MM-DD)
|
|
61
|
+
* - Example: "2024-12-03"
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const christmas = DateUtil.of(2024, 12, 25);
|
|
66
|
+
* const json = JSON.stringify({ birthDate: christmas });
|
|
67
|
+
* // {"birthDate":{"value":"2024-12-25"}}
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface DateDto {
|
|
71
|
+
/**
|
|
72
|
+
* ISO-8601 date string (YYYY-MM-DD).
|
|
73
|
+
* Example: "2024-12-03"
|
|
74
|
+
*/
|
|
75
|
+
value: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* TimeDto - Represents a time without date or timezone (e.g., 14:30:00.123).
|
|
79
|
+
*
|
|
80
|
+
* Equivalent to Java's java.time.LocalTime.
|
|
81
|
+
*
|
|
82
|
+
* **Use cases:**
|
|
83
|
+
* - Opening/closing hours (e.g., "Store opens at 09:00")
|
|
84
|
+
* - Recurring event times (e.g., "Daily standup at 10:00")
|
|
85
|
+
* - Alarm times
|
|
86
|
+
* - Precise timing measurements
|
|
87
|
+
* - Any time where date/timezone is irrelevant
|
|
88
|
+
*
|
|
89
|
+
* **JSON format:** ISO-8601 time string with milliseconds (HH:mm:ss.SSS)
|
|
90
|
+
* - Example: "14:30:00.123"
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const lunch = TimeUtil.of(12, 30, 0, 500);
|
|
95
|
+
* const json = JSON.stringify({ openingTime: lunch });
|
|
96
|
+
* // {"openingTime":{"value":"12:30:00.500"}}
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export interface TimeDto {
|
|
100
|
+
/**
|
|
101
|
+
* ISO-8601 time string with milliseconds (HH:mm:ss.SSS).
|
|
102
|
+
* Example: "14:30:00.123"
|
|
103
|
+
*/
|
|
104
|
+
value: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* DateTimeDto - Represents a date and time without timezone (e.g., 2024-12-03T14:30:00.123).
|
|
108
|
+
*
|
|
109
|
+
* Equivalent to Java's java.time.LocalDateTime.
|
|
110
|
+
*
|
|
111
|
+
* **⚠️ WARNING: Use with caution!**
|
|
112
|
+
* "LocalDateTime does not have a time zone, so if you use JSON to send date/time info,
|
|
113
|
+
* you might get in trouble if the client interprets the lack of time zone as default UTC
|
|
114
|
+
* (or its own time zone)."
|
|
115
|
+
*
|
|
116
|
+
* **Use cases:**
|
|
117
|
+
* - Appointment times (when timezone is implied by context)
|
|
118
|
+
* - Event dates/times (when all participants are in same timezone)
|
|
119
|
+
* - **Prefer InstantDto for most use cases to avoid timezone confusion!**
|
|
120
|
+
*
|
|
121
|
+
* **JSON format:** ISO-8601 datetime string without timezone (milliseconds optional)
|
|
122
|
+
* - Example: "2024-12-03T14:30:00" or "2024-12-03T14:30:00.123"
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const meeting = DateTimeUtil.of(2024, 12, 3, 14, 30, 0, 500);
|
|
127
|
+
* const json = JSON.stringify({ appointmentTime: meeting });
|
|
128
|
+
* // {"appointmentTime":{"value":"2024-12-03T14:30:00.500"}}
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export interface DateTimeDto {
|
|
132
|
+
/**
|
|
133
|
+
* ISO-8601 datetime string without timezone (YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS).
|
|
134
|
+
* Example: "2024-12-03T14:30:00" or "2024-12-03T14:30:00.123"
|
|
135
|
+
*/
|
|
136
|
+
value: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* InstantUtil - Utility for converting InstantDto to/from various formats.
|
|
140
|
+
*
|
|
141
|
+
* All methods are static - this is a pure utility class with no state.
|
|
142
|
+
*
|
|
143
|
+
* **Why UTC?** "It's recommended to convert all dates to UTC before storing.
|
|
144
|
+
* Don't use local timezone. Otherwise, you'll be pulling your hair out when
|
|
145
|
+
* your database is deployed in high availability designs across multiple data
|
|
146
|
+
* centers across multiple timezones."
|
|
147
|
+
* - Source: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/
|
|
148
|
+
*/
|
|
149
|
+
export declare class InstantUtil {
|
|
150
|
+
/**
|
|
151
|
+
* Create InstantDto representing the current moment (UTC).
|
|
152
|
+
*/
|
|
153
|
+
static now(): InstantDto;
|
|
154
|
+
/**
|
|
155
|
+
* Create InstantDto from JavaScript Date object.
|
|
156
|
+
*/
|
|
157
|
+
static fromDate(date: Date): InstantDto;
|
|
158
|
+
/**
|
|
159
|
+
* Create InstantDto from ISO-8601 string.
|
|
160
|
+
* @param iso - ISO-8601 string (e.g., "2024-12-03T14:30:00.000Z")
|
|
161
|
+
*/
|
|
162
|
+
static fromString(iso: string): InstantDto;
|
|
163
|
+
/**
|
|
164
|
+
* Create InstantDto from epoch milliseconds.
|
|
165
|
+
* @param millis - Milliseconds since Unix epoch (January 1, 1970, 00:00:00 UTC)
|
|
166
|
+
*/
|
|
167
|
+
static fromEpochMillis(millis: number): InstantDto;
|
|
168
|
+
/**
|
|
169
|
+
* Convert InstantDto to JavaScript Date object.
|
|
170
|
+
*/
|
|
171
|
+
static toDate(instant: InstantDto): Date;
|
|
172
|
+
/**
|
|
173
|
+
* Get ISO-8601 string representation.
|
|
174
|
+
*/
|
|
175
|
+
static toString(instant: InstantDto): string;
|
|
176
|
+
/**
|
|
177
|
+
* Get epoch milliseconds (Unix timestamp).
|
|
178
|
+
*/
|
|
179
|
+
static toEpochMillis(instant: InstantDto): number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* DateUtil - Utility for converting DateDto to/from various formats.
|
|
183
|
+
*
|
|
184
|
+
* All methods are static - this is a pure utility class with no state.
|
|
185
|
+
*
|
|
186
|
+
* **Note:** DateDto represents a date in the abstract sense, not tied to any timezone.
|
|
187
|
+
* December 25th is Christmas regardless of what timezone you're in.
|
|
188
|
+
*/
|
|
189
|
+
export declare class DateUtil {
|
|
190
|
+
/**
|
|
191
|
+
* Create DateDto from year, month, day.
|
|
192
|
+
* @param year - Full year (e.g., 2024)
|
|
193
|
+
* @param month - Month (1-12, where 1 = January)
|
|
194
|
+
* @param day - Day of month (1-31)
|
|
195
|
+
*/
|
|
196
|
+
static of(year: number, month: number, day: number): DateDto;
|
|
197
|
+
/**
|
|
198
|
+
* Create DateDto from JavaScript Date object.
|
|
199
|
+
* Uses the local timezone's date.
|
|
200
|
+
*/
|
|
201
|
+
static fromDate(date: Date): DateDto;
|
|
202
|
+
/**
|
|
203
|
+
* Create DateDto from ISO-8601 date string.
|
|
204
|
+
* @param iso - ISO-8601 date string (e.g., "2024-12-03")
|
|
205
|
+
*/
|
|
206
|
+
static fromString(iso: string): DateDto;
|
|
207
|
+
/**
|
|
208
|
+
* Convert DateDto to JavaScript Date object (at midnight local time).
|
|
209
|
+
*/
|
|
210
|
+
static toDate(dateDto: DateDto): Date;
|
|
211
|
+
/**
|
|
212
|
+
* Get ISO-8601 date string.
|
|
213
|
+
*/
|
|
214
|
+
static toString(dateDto: DateDto): string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* TimeUtil - Utility for converting TimeDto to/from various formats.
|
|
218
|
+
*
|
|
219
|
+
* All methods are static - this is a pure utility class with no state.
|
|
220
|
+
*/
|
|
221
|
+
export declare class TimeUtil {
|
|
222
|
+
/**
|
|
223
|
+
* Create TimeDto from hour, minute, second, and optional milliseconds.
|
|
224
|
+
* @param hour - Hour (0-23)
|
|
225
|
+
* @param minute - Minute (0-59)
|
|
226
|
+
* @param second - Second (0-59)
|
|
227
|
+
* @param millis - Milliseconds (0-999), optional
|
|
228
|
+
*/
|
|
229
|
+
static of(hour: number, minute: number, second: number, millis?: number): TimeDto;
|
|
230
|
+
/**
|
|
231
|
+
* Create TimeDto from JavaScript Date object.
|
|
232
|
+
* Uses the local timezone's time.
|
|
233
|
+
* Includes milliseconds.
|
|
234
|
+
*/
|
|
235
|
+
static fromDate(date: Date): TimeDto;
|
|
236
|
+
/**
|
|
237
|
+
* Create TimeDto from ISO-8601 time string.
|
|
238
|
+
* @param iso - ISO-8601 time string (e.g., "14:30:00" or "14:30:00.123")
|
|
239
|
+
*/
|
|
240
|
+
static fromString(iso: string): TimeDto;
|
|
241
|
+
/**
|
|
242
|
+
* Get ISO-8601 time string.
|
|
243
|
+
*/
|
|
244
|
+
static toString(timeDto: TimeDto): string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* DateTimeUtil - Utility for converting DateTimeDto to/from various formats.
|
|
248
|
+
*
|
|
249
|
+
* All methods are static - this is a pure utility class with no state.
|
|
250
|
+
*
|
|
251
|
+
* **⚠️ WARNING:** Prefer InstantDto for most use cases to avoid timezone confusion!
|
|
252
|
+
*/
|
|
253
|
+
export declare class DateTimeUtil {
|
|
254
|
+
/**
|
|
255
|
+
* Create DateTimeDto from components.
|
|
256
|
+
* @param year - Full year (e.g., 2024)
|
|
257
|
+
* @param month - Month (1-12, where 1 = January)
|
|
258
|
+
* @param day - Day of month (1-31)
|
|
259
|
+
* @param hour - Hour (0-23)
|
|
260
|
+
* @param minute - Minute (0-59)
|
|
261
|
+
* @param second - Second (0-59)
|
|
262
|
+
* @param millis - Milliseconds (0-999), optional
|
|
263
|
+
*/
|
|
264
|
+
static of(year: number, month: number, day: number, hour: number, minute: number, second: number, millis?: number): DateTimeDto;
|
|
265
|
+
/**
|
|
266
|
+
* Create DateTimeDto from JavaScript Date object.
|
|
267
|
+
* Uses the local timezone's date/time.
|
|
268
|
+
* Includes milliseconds.
|
|
269
|
+
*/
|
|
270
|
+
static fromDate(date: Date): DateTimeDto;
|
|
271
|
+
/**
|
|
272
|
+
* Create DateTimeDto from ISO-8601 datetime string.
|
|
273
|
+
* @param iso - ISO-8601 datetime string (e.g., "2024-12-03T14:30:00" or "2024-12-03T14:30:00.123")
|
|
274
|
+
*/
|
|
275
|
+
static fromString(iso: string): DateTimeDto;
|
|
276
|
+
/**
|
|
277
|
+
* Convert DateTimeDto to JavaScript Date object (interprets as local timezone).
|
|
278
|
+
*/
|
|
279
|
+
static toDate(dateTime: DateTimeDto): Date;
|
|
280
|
+
/**
|
|
281
|
+
* Get ISO-8601 datetime string.
|
|
282
|
+
*/
|
|
283
|
+
static toString(dateTime: DateTimeDto): string;
|
|
284
|
+
}
|
package/src/datetime.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Date/Time DTOs and Utilities for JSON serialization (inspired by Java Time / JSR-310)
|
|
4
|
+
*
|
|
5
|
+
* DTOs are simple interfaces - just data, no logic!
|
|
6
|
+
* Utilities provide conversion logic.
|
|
7
|
+
*
|
|
8
|
+
* Design Philosophy:
|
|
9
|
+
* - DTOs are plain objects with { value: string } - perfect for JSON.stringify/parse
|
|
10
|
+
* - Utilities contain ALL conversion logic (no business logic in DTOs)
|
|
11
|
+
* - Store as ISO-8601 strings (human-readable, unambiguous, sortable)
|
|
12
|
+
* - Always use UTC for timestamps (avoid timezone confusion)
|
|
13
|
+
*
|
|
14
|
+
* References:
|
|
15
|
+
* - Java Time API (JSR-310): https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html
|
|
16
|
+
* - ISO-8601: https://www.iso.org/iso-8601-date-and-time-format.html
|
|
17
|
+
* - REST API Best Practices: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.DateTimeUtil = exports.TimeUtil = exports.DateUtil = exports.InstantUtil = void 0;
|
|
21
|
+
// ============================================================
|
|
22
|
+
// Utilities - All conversion logic lives here
|
|
23
|
+
// ============================================================
|
|
24
|
+
/**
|
|
25
|
+
* InstantUtil - Utility for converting InstantDto to/from various formats.
|
|
26
|
+
*
|
|
27
|
+
* All methods are static - this is a pure utility class with no state.
|
|
28
|
+
*
|
|
29
|
+
* **Why UTC?** "It's recommended to convert all dates to UTC before storing.
|
|
30
|
+
* Don't use local timezone. Otherwise, you'll be pulling your hair out when
|
|
31
|
+
* your database is deployed in high availability designs across multiple data
|
|
32
|
+
* centers across multiple timezones."
|
|
33
|
+
* - Source: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/
|
|
34
|
+
*/
|
|
35
|
+
class InstantUtil {
|
|
36
|
+
/**
|
|
37
|
+
* Create InstantDto representing the current moment (UTC).
|
|
38
|
+
*/
|
|
39
|
+
static now() {
|
|
40
|
+
return { value: new Date().toISOString() };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create InstantDto from JavaScript Date object.
|
|
44
|
+
*/
|
|
45
|
+
static fromDate(date) {
|
|
46
|
+
return { value: date.toISOString() };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create InstantDto from ISO-8601 string.
|
|
50
|
+
* @param iso - ISO-8601 string (e.g., "2024-12-03T14:30:00.000Z")
|
|
51
|
+
*/
|
|
52
|
+
static fromString(iso) {
|
|
53
|
+
// Validate by parsing
|
|
54
|
+
const date = new Date(iso);
|
|
55
|
+
if (isNaN(date.getTime())) {
|
|
56
|
+
throw new Error(`Invalid ISO-8601 string: ${iso}`);
|
|
57
|
+
}
|
|
58
|
+
return { value: date.toISOString() };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create InstantDto from epoch milliseconds.
|
|
62
|
+
* @param millis - Milliseconds since Unix epoch (January 1, 1970, 00:00:00 UTC)
|
|
63
|
+
*/
|
|
64
|
+
static fromEpochMillis(millis) {
|
|
65
|
+
return { value: new Date(millis).toISOString() };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert InstantDto to JavaScript Date object.
|
|
69
|
+
*/
|
|
70
|
+
static toDate(instant) {
|
|
71
|
+
return new Date(instant.value);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get ISO-8601 string representation.
|
|
75
|
+
*/
|
|
76
|
+
static toString(instant) {
|
|
77
|
+
return instant.value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get epoch milliseconds (Unix timestamp).
|
|
81
|
+
*/
|
|
82
|
+
static toEpochMillis(instant) {
|
|
83
|
+
return new Date(instant.value).getTime();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.InstantUtil = InstantUtil;
|
|
87
|
+
/**
|
|
88
|
+
* DateUtil - Utility for converting DateDto to/from various formats.
|
|
89
|
+
*
|
|
90
|
+
* All methods are static - this is a pure utility class with no state.
|
|
91
|
+
*
|
|
92
|
+
* **Note:** DateDto represents a date in the abstract sense, not tied to any timezone.
|
|
93
|
+
* December 25th is Christmas regardless of what timezone you're in.
|
|
94
|
+
*/
|
|
95
|
+
class DateUtil {
|
|
96
|
+
/**
|
|
97
|
+
* Create DateDto from year, month, day.
|
|
98
|
+
* @param year - Full year (e.g., 2024)
|
|
99
|
+
* @param month - Month (1-12, where 1 = January)
|
|
100
|
+
* @param day - Day of month (1-31)
|
|
101
|
+
*/
|
|
102
|
+
static of(year, month, day) {
|
|
103
|
+
const monthStr = month.toString().padStart(2, '0');
|
|
104
|
+
const dayStr = day.toString().padStart(2, '0');
|
|
105
|
+
return { value: `${year}-${monthStr}-${dayStr}` };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create DateDto from JavaScript Date object.
|
|
109
|
+
* Uses the local timezone's date.
|
|
110
|
+
*/
|
|
111
|
+
static fromDate(date) {
|
|
112
|
+
const year = date.getFullYear();
|
|
113
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
114
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
115
|
+
return { value: `${year}-${month}-${day}` };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create DateDto from ISO-8601 date string.
|
|
119
|
+
* @param iso - ISO-8601 date string (e.g., "2024-12-03")
|
|
120
|
+
*/
|
|
121
|
+
static fromString(iso) {
|
|
122
|
+
// Validate format: YYYY-MM-DD
|
|
123
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(iso)) {
|
|
124
|
+
throw new Error(`Invalid date format: ${iso}. Expected YYYY-MM-DD`);
|
|
125
|
+
}
|
|
126
|
+
return { value: iso };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Convert DateDto to JavaScript Date object (at midnight local time).
|
|
130
|
+
*/
|
|
131
|
+
static toDate(dateDto) {
|
|
132
|
+
return new Date(dateDto.value + 'T00:00:00');
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get ISO-8601 date string.
|
|
136
|
+
*/
|
|
137
|
+
static toString(dateDto) {
|
|
138
|
+
return dateDto.value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.DateUtil = DateUtil;
|
|
142
|
+
/**
|
|
143
|
+
* TimeUtil - Utility for converting TimeDto to/from various formats.
|
|
144
|
+
*
|
|
145
|
+
* All methods are static - this is a pure utility class with no state.
|
|
146
|
+
*/
|
|
147
|
+
class TimeUtil {
|
|
148
|
+
/**
|
|
149
|
+
* Create TimeDto from hour, minute, second, and optional milliseconds.
|
|
150
|
+
* @param hour - Hour (0-23)
|
|
151
|
+
* @param minute - Minute (0-59)
|
|
152
|
+
* @param second - Second (0-59)
|
|
153
|
+
* @param millis - Milliseconds (0-999), optional
|
|
154
|
+
*/
|
|
155
|
+
static of(hour, minute, second, millis) {
|
|
156
|
+
const hourStr = hour.toString().padStart(2, '0');
|
|
157
|
+
const minuteStr = minute.toString().padStart(2, '0');
|
|
158
|
+
const secondStr = second.toString().padStart(2, '0');
|
|
159
|
+
if (millis !== undefined) {
|
|
160
|
+
const millisStr = millis.toString().padStart(3, '0');
|
|
161
|
+
return { value: `${hourStr}:${minuteStr}:${secondStr}.${millisStr}` };
|
|
162
|
+
}
|
|
163
|
+
return { value: `${hourStr}:${minuteStr}:${secondStr}` };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create TimeDto from JavaScript Date object.
|
|
167
|
+
* Uses the local timezone's time.
|
|
168
|
+
* Includes milliseconds.
|
|
169
|
+
*/
|
|
170
|
+
static fromDate(date) {
|
|
171
|
+
const hour = date.getHours().toString().padStart(2, '0');
|
|
172
|
+
const minute = date.getMinutes().toString().padStart(2, '0');
|
|
173
|
+
const second = date.getSeconds().toString().padStart(2, '0');
|
|
174
|
+
const millis = date.getMilliseconds().toString().padStart(3, '0');
|
|
175
|
+
return { value: `${hour}:${minute}:${second}.${millis}` };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create TimeDto from ISO-8601 time string.
|
|
179
|
+
* @param iso - ISO-8601 time string (e.g., "14:30:00" or "14:30:00.123")
|
|
180
|
+
*/
|
|
181
|
+
static fromString(iso) {
|
|
182
|
+
// Validate format: HH:mm:ss or HH:mm:ss.SSS
|
|
183
|
+
if (!/^\d{2}:\d{2}:\d{2}(\.\d{3})?$/.test(iso)) {
|
|
184
|
+
throw new Error(`Invalid time format: ${iso}. Expected HH:mm:ss or HH:mm:ss.SSS`);
|
|
185
|
+
}
|
|
186
|
+
return { value: iso };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get ISO-8601 time string.
|
|
190
|
+
*/
|
|
191
|
+
static toString(timeDto) {
|
|
192
|
+
return timeDto.value;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.TimeUtil = TimeUtil;
|
|
196
|
+
/**
|
|
197
|
+
* DateTimeUtil - Utility for converting DateTimeDto to/from various formats.
|
|
198
|
+
*
|
|
199
|
+
* All methods are static - this is a pure utility class with no state.
|
|
200
|
+
*
|
|
201
|
+
* **⚠️ WARNING:** Prefer InstantDto for most use cases to avoid timezone confusion!
|
|
202
|
+
*/
|
|
203
|
+
class DateTimeUtil {
|
|
204
|
+
/**
|
|
205
|
+
* Create DateTimeDto from components.
|
|
206
|
+
* @param year - Full year (e.g., 2024)
|
|
207
|
+
* @param month - Month (1-12, where 1 = January)
|
|
208
|
+
* @param day - Day of month (1-31)
|
|
209
|
+
* @param hour - Hour (0-23)
|
|
210
|
+
* @param minute - Minute (0-59)
|
|
211
|
+
* @param second - Second (0-59)
|
|
212
|
+
* @param millis - Milliseconds (0-999), optional
|
|
213
|
+
*/
|
|
214
|
+
static of(year, month, day, hour, minute, second, millis) {
|
|
215
|
+
const monthStr = month.toString().padStart(2, '0');
|
|
216
|
+
const dayStr = day.toString().padStart(2, '0');
|
|
217
|
+
const hourStr = hour.toString().padStart(2, '0');
|
|
218
|
+
const minuteStr = minute.toString().padStart(2, '0');
|
|
219
|
+
const secondStr = second.toString().padStart(2, '0');
|
|
220
|
+
if (millis !== undefined) {
|
|
221
|
+
const millisStr = millis.toString().padStart(3, '0');
|
|
222
|
+
return {
|
|
223
|
+
value: `${year}-${monthStr}-${dayStr}T${hourStr}:${minuteStr}:${secondStr}.${millisStr}`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
value: `${year}-${monthStr}-${dayStr}T${hourStr}:${minuteStr}:${secondStr}`,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create DateTimeDto from JavaScript Date object.
|
|
232
|
+
* Uses the local timezone's date/time.
|
|
233
|
+
* Includes milliseconds.
|
|
234
|
+
*/
|
|
235
|
+
static fromDate(date) {
|
|
236
|
+
const year = date.getFullYear();
|
|
237
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
238
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
239
|
+
const hour = date.getHours().toString().padStart(2, '0');
|
|
240
|
+
const minute = date.getMinutes().toString().padStart(2, '0');
|
|
241
|
+
const second = date.getSeconds().toString().padStart(2, '0');
|
|
242
|
+
const millis = date.getMilliseconds().toString().padStart(3, '0');
|
|
243
|
+
return { value: `${year}-${month}-${day}T${hour}:${minute}:${second}.${millis}` };
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create DateTimeDto from ISO-8601 datetime string.
|
|
247
|
+
* @param iso - ISO-8601 datetime string (e.g., "2024-12-03T14:30:00" or "2024-12-03T14:30:00.123")
|
|
248
|
+
*/
|
|
249
|
+
static fromString(iso) {
|
|
250
|
+
// Validate format: YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS
|
|
251
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?$/.test(iso)) {
|
|
252
|
+
throw new Error(`Invalid datetime format: ${iso}. Expected YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS`);
|
|
253
|
+
}
|
|
254
|
+
return { value: iso };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert DateTimeDto to JavaScript Date object (interprets as local timezone).
|
|
258
|
+
*/
|
|
259
|
+
static toDate(dateTime) {
|
|
260
|
+
return new Date(dateTime.value);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get ISO-8601 datetime string.
|
|
264
|
+
*/
|
|
265
|
+
static toString(dateTime) {
|
|
266
|
+
return dateTime.value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.DateTimeUtil = DateTimeUtil;
|
|
270
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/datetime.ts"],"names":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,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAClE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,EAAE,CAAC;IACtF,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,GAAW;QACzB,kEAAkE;QAClE,IAAI,CAAC,iDAAiD,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,KAAK,CACX,4BAA4B,GAAG,2DAA2D,CAC7F,CAAC;QACN,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAqB;QAC/B,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAqB;QACjC,OAAO,QAAQ,CAAC,KAAK,CAAC;IAC1B,CAAC;CACJ;AAjFD,oCAiFC","sourcesContent":["/**\n * Date/Time DTOs and Utilities for JSON serialization (inspired by Java Time / JSR-310)\n *\n * DTOs are simple interfaces - just data, no logic!\n * Utilities provide conversion logic.\n *\n * Design Philosophy:\n * - DTOs are plain objects with { value: string } - perfect for JSON.stringify/parse\n * - Utilities contain ALL conversion logic (no business logic in DTOs)\n * - Store as ISO-8601 strings (human-readable, unambiguous, sortable)\n * - Always use UTC for timestamps (avoid timezone confusion)\n *\n * References:\n * - Java Time API (JSR-310): https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html\n * - ISO-8601: https://www.iso.org/iso-8601-date-and-time-format.html\n * - REST API Best Practices: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/\n */\n\n// ============================================================\n// DTOs (Data Transfer Objects) - Pure data, no logic\n// ============================================================\n\n/**\n * InstantDto - Represents an absolute point in time (UTC).\n *\n * Equivalent to Java's java.time.Instant or JavaScript's Date.\n *\n * **Use cases:**\n * - Timestamps (createdAt, updatedAt, lastModified)\n * - Audit logs\n * - Event timestamps\n * - Any absolute point in time\n *\n * **JSON format:** ISO-8601 string with UTC timezone (Z suffix)\n * - Example: \"2024-12-03T14:30:00.000Z\"\n *\n * @example\n * ```typescript\n * const now = InstantUtil.now();\n * const json = JSON.stringify({ timestamp: now });\n * // {\"timestamp\":{\"value\":\"2024-12-03T14:30:00.000Z\"}}\n *\n * const parsed = JSON.parse(json);\n * const date = InstantUtil.toDate(parsed.timestamp);\n * ```\n */\nexport interface InstantDto {\n /**\n * ISO-8601 string in UTC with Z suffix.\n * Example: \"2024-12-03T14:30:00.000Z\"\n */\n value: string;\n}\n\n/**\n * DateDto - Represents a date without time or timezone (e.g., 2024-12-03).\n *\n * Equivalent to Java's java.time.LocalDate.\n *\n * **Use cases:**\n * - Birth dates\n * - Holidays\n * - Calendar dates\n * - Any date where time/timezone is irrelevant\n *\n * **JSON format:** ISO-8601 date string (YYYY-MM-DD)\n * - Example: \"2024-12-03\"\n *\n * @example\n * ```typescript\n * const christmas = DateUtil.of(2024, 12, 25);\n * const json = JSON.stringify({ birthDate: christmas });\n * // {\"birthDate\":{\"value\":\"2024-12-25\"}}\n * ```\n */\nexport interface DateDto {\n /**\n * ISO-8601 date string (YYYY-MM-DD).\n * Example: \"2024-12-03\"\n */\n value: string;\n}\n\n/**\n * TimeDto - Represents a time without date or timezone (e.g., 14:30:00.123).\n *\n * Equivalent to Java's java.time.LocalTime.\n *\n * **Use cases:**\n * - Opening/closing hours (e.g., \"Store opens at 09:00\")\n * - Recurring event times (e.g., \"Daily standup at 10:00\")\n * - Alarm times\n * - Precise timing measurements\n * - Any time where date/timezone is irrelevant\n *\n * **JSON format:** ISO-8601 time string with milliseconds (HH:mm:ss.SSS)\n * - Example: \"14:30:00.123\"\n *\n * @example\n * ```typescript\n * const lunch = TimeUtil.of(12, 30, 0, 500);\n * const json = JSON.stringify({ openingTime: lunch });\n * // {\"openingTime\":{\"value\":\"12:30:00.500\"}}\n * ```\n */\nexport interface TimeDto {\n /**\n * ISO-8601 time string with milliseconds (HH:mm:ss.SSS).\n * Example: \"14:30:00.123\"\n */\n value: string;\n}\n\n/**\n * DateTimeDto - Represents a date and time without timezone (e.g., 2024-12-03T14:30:00.123).\n *\n * Equivalent to Java's java.time.LocalDateTime.\n *\n * **⚠️ WARNING: Use with caution!**\n * \"LocalDateTime does not have a time zone, so if you use JSON to send date/time info,\n * you might get in trouble if the client interprets the lack of time zone as default UTC\n * (or its own time zone).\"\n *\n * **Use cases:**\n * - Appointment times (when timezone is implied by context)\n * - Event dates/times (when all participants are in same timezone)\n * - **Prefer InstantDto for most use cases to avoid timezone confusion!**\n *\n * **JSON format:** ISO-8601 datetime string without timezone (milliseconds optional)\n * - Example: \"2024-12-03T14:30:00\" or \"2024-12-03T14:30:00.123\"\n *\n * @example\n * ```typescript\n * const meeting = DateTimeUtil.of(2024, 12, 3, 14, 30, 0, 500);\n * const json = JSON.stringify({ appointmentTime: meeting });\n * // {\"appointmentTime\":{\"value\":\"2024-12-03T14:30:00.500\"}}\n * ```\n */\nexport interface DateTimeDto {\n /**\n * ISO-8601 datetime string without timezone (YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS).\n * Example: \"2024-12-03T14:30:00\" or \"2024-12-03T14:30:00.123\"\n */\n value: string;\n}\n\n// ============================================================\n// Utilities - All conversion logic lives here\n// ============================================================\n\n/**\n * InstantUtil - Utility for converting InstantDto to/from various formats.\n *\n * All methods are static - this is a pure utility class with no state.\n *\n * **Why UTC?** \"It's recommended to convert all dates to UTC before storing.\n * Don't use local timezone. Otherwise, you'll be pulling your hair out when\n * your database is deployed in high availability designs across multiple data\n * centers across multiple timezones.\"\n * - Source: https://www.moesif.com/blog/technical/timestamp/manage-datetime-timestamp-timezones-in-api/\n */\nexport class InstantUtil {\n /**\n * Create InstantDto representing the current moment (UTC).\n */\n static now(): InstantDto {\n return { value: new Date().toISOString() };\n }\n\n /**\n * Create InstantDto from JavaScript Date object.\n */\n static fromDate(date: Date): InstantDto {\n return { value: date.toISOString() };\n }\n\n /**\n * Create InstantDto from ISO-8601 string.\n * @param iso - ISO-8601 string (e.g., \"2024-12-03T14:30:00.000Z\")\n */\n static fromString(iso: string): InstantDto {\n // Validate by parsing\n const date = new Date(iso);\n if (isNaN(date.getTime())) {\n throw new Error(`Invalid ISO-8601 string: ${iso}`);\n }\n return { value: date.toISOString() };\n }\n\n /**\n * Create InstantDto from epoch milliseconds.\n * @param millis - Milliseconds since Unix epoch (January 1, 1970, 00:00:00 UTC)\n */\n static fromEpochMillis(millis: number): InstantDto {\n return { value: new Date(millis).toISOString() };\n }\n\n /**\n * Convert InstantDto to JavaScript Date object.\n */\n static toDate(instant: InstantDto): Date {\n return new Date(instant.value);\n }\n\n /**\n * Get ISO-8601 string representation.\n */\n static toString(instant: InstantDto): string {\n return instant.value;\n }\n\n /**\n * Get epoch milliseconds (Unix timestamp).\n */\n static toEpochMillis(instant: InstantDto): number {\n return new Date(instant.value).getTime();\n }\n}\n\n/**\n * DateUtil - Utility for converting DateDto to/from various formats.\n *\n * All methods are static - this is a pure utility class with no state.\n *\n * **Note:** DateDto represents a date in the abstract sense, not tied to any timezone.\n * December 25th is Christmas regardless of what timezone you're in.\n */\nexport class DateUtil {\n /**\n * Create DateDto from year, month, day.\n * @param year - Full year (e.g., 2024)\n * @param month - Month (1-12, where 1 = January)\n * @param day - Day of month (1-31)\n */\n static of(year: number, month: number, day: number): DateDto {\n const monthStr = month.toString().padStart(2, '0');\n const dayStr = day.toString().padStart(2, '0');\n return { value: `${year}-${monthStr}-${dayStr}` };\n }\n\n /**\n * Create DateDto from JavaScript Date object.\n * Uses the local timezone's date.\n */\n static fromDate(date: Date): DateDto {\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const day = date.getDate().toString().padStart(2, '0');\n return { value: `${year}-${month}-${day}` };\n }\n\n /**\n * Create DateDto from ISO-8601 date string.\n * @param iso - ISO-8601 date string (e.g., \"2024-12-03\")\n */\n static fromString(iso: string): DateDto {\n // Validate format: YYYY-MM-DD\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(iso)) {\n throw new Error(`Invalid date format: ${iso}. Expected YYYY-MM-DD`);\n }\n return { value: iso };\n }\n\n /**\n * Convert DateDto to JavaScript Date object (at midnight local time).\n */\n static toDate(dateDto: DateDto): Date {\n return new Date(dateDto.value + 'T00:00:00');\n }\n\n /**\n * Get ISO-8601 date string.\n */\n static toString(dateDto: DateDto): string {\n return dateDto.value;\n }\n}\n\n/**\n * TimeUtil - Utility for converting TimeDto to/from various formats.\n *\n * All methods are static - this is a pure utility class with no state.\n */\nexport class TimeUtil {\n /**\n * Create TimeDto from hour, minute, second, and optional milliseconds.\n * @param hour - Hour (0-23)\n * @param minute - Minute (0-59)\n * @param second - Second (0-59)\n * @param millis - Milliseconds (0-999), optional\n */\n static of(hour: number, minute: number, second: number, millis?: number): TimeDto {\n const hourStr = hour.toString().padStart(2, '0');\n const minuteStr = minute.toString().padStart(2, '0');\n const secondStr = second.toString().padStart(2, '0');\n\n if (millis !== undefined) {\n const millisStr = millis.toString().padStart(3, '0');\n return { value: `${hourStr}:${minuteStr}:${secondStr}.${millisStr}` };\n }\n\n return { value: `${hourStr}:${minuteStr}:${secondStr}` };\n }\n\n /**\n * Create TimeDto from JavaScript Date object.\n * Uses the local timezone's time.\n * Includes milliseconds.\n */\n static fromDate(date: Date): TimeDto {\n const hour = date.getHours().toString().padStart(2, '0');\n const minute = date.getMinutes().toString().padStart(2, '0');\n const second = date.getSeconds().toString().padStart(2, '0');\n const millis = date.getMilliseconds().toString().padStart(3, '0');\n return { value: `${hour}:${minute}:${second}.${millis}` };\n }\n\n /**\n * Create TimeDto from ISO-8601 time string.\n * @param iso - ISO-8601 time string (e.g., \"14:30:00\" or \"14:30:00.123\")\n */\n static fromString(iso: string): TimeDto {\n // Validate format: HH:mm:ss or HH:mm:ss.SSS\n if (!/^\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?$/.test(iso)) {\n throw new Error(`Invalid time format: ${iso}. Expected HH:mm:ss or HH:mm:ss.SSS`);\n }\n return { value: iso };\n }\n\n /**\n * Get ISO-8601 time string.\n */\n static toString(timeDto: TimeDto): string {\n return timeDto.value;\n }\n}\n\n/**\n * DateTimeUtil - Utility for converting DateTimeDto to/from various formats.\n *\n * All methods are static - this is a pure utility class with no state.\n *\n * **⚠️ WARNING:** Prefer InstantDto for most use cases to avoid timezone confusion!\n */\nexport class DateTimeUtil {\n /**\n * Create DateTimeDto from components.\n * @param year - Full year (e.g., 2024)\n * @param month - Month (1-12, where 1 = January)\n * @param day - Day of month (1-31)\n * @param hour - Hour (0-23)\n * @param minute - Minute (0-59)\n * @param second - Second (0-59)\n * @param millis - Milliseconds (0-999), optional\n */\n static of(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n second: number,\n millis?: number,\n ): DateTimeDto {\n const monthStr = month.toString().padStart(2, '0');\n const dayStr = day.toString().padStart(2, '0');\n const hourStr = hour.toString().padStart(2, '0');\n const minuteStr = minute.toString().padStart(2, '0');\n const secondStr = second.toString().padStart(2, '0');\n\n if (millis !== undefined) {\n const millisStr = millis.toString().padStart(3, '0');\n return {\n value: `${year}-${monthStr}-${dayStr}T${hourStr}:${minuteStr}:${secondStr}.${millisStr}`,\n };\n }\n\n return {\n value: `${year}-${monthStr}-${dayStr}T${hourStr}:${minuteStr}:${secondStr}`,\n };\n }\n\n /**\n * Create DateTimeDto from JavaScript Date object.\n * Uses the local timezone's date/time.\n * Includes milliseconds.\n */\n static fromDate(date: Date): DateTimeDto {\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const day = date.getDate().toString().padStart(2, '0');\n const hour = date.getHours().toString().padStart(2, '0');\n const minute = date.getMinutes().toString().padStart(2, '0');\n const second = date.getSeconds().toString().padStart(2, '0');\n const millis = date.getMilliseconds().toString().padStart(3, '0');\n return { value: `${year}-${month}-${day}T${hour}:${minute}:${second}.${millis}` };\n }\n\n /**\n * Create DateTimeDto from ISO-8601 datetime string.\n * @param iso - ISO-8601 datetime string (e.g., \"2024-12-03T14:30:00\" or \"2024-12-03T14:30:00.123\")\n */\n static fromString(iso: string): DateTimeDto {\n // Validate format: YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS\n if (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?$/.test(iso)) {\n throw new Error(\n `Invalid datetime format: ${iso}. Expected YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm:ss.SSS`,\n );\n }\n return { value: iso };\n }\n\n /**\n * Convert DateTimeDto to JavaScript Date object (interprets as local timezone).\n */\n static toDate(dateTime: DateTimeDto): Date {\n return new Date(dateTime.value);\n }\n\n /**\n * Get ISO-8601 datetime string.\n */\n static toString(dateTime: DateTimeDto): string {\n return dateTime.value;\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -19,3 +19,9 @@
|
|
|
19
19
|
export { ApiInterface, Get, Post, Put, Delete, Patch, Path, getRoutes, isApiInterface, RouteMetadata, METADATA_KEYS, } from './decorators';
|
|
20
20
|
export { ValidateImplementation } from './validators';
|
|
21
21
|
export { ProtocolError, HttpError, HttpNotFoundError, EndpointNotFoundError, HttpBadRequestError, HttpUnauthorizedError, HttpForbiddenError, HttpTimeoutError, HttpBadGatewayError, HttpGatewayTimeoutError, HttpInternalServerError, HttpVendorError, HttpUserError, ENTITY_NOT_FOUND, WRONG_LOGIN_TYPE, WRONG_LOGIN, NOT_APPROVED, EMAIL_NOT_CONFIRMED, WRONG_DOMAIN, WRONG_COMPANY, NO_REG_CODE, } from './errors';
|
|
22
|
+
export { InstantDto, DateDto, TimeDto, DateTimeDto, InstantUtil, DateUtil, TimeUtil, DateTimeUtil, } from './datetime';
|
|
23
|
+
export { PlatformHeader } from './PlatformHeader';
|
|
24
|
+
export { PlatformHeadersExtension } from './PlatformHeadersExtension';
|
|
25
|
+
export { HeaderMethods, ContextReader } from './HeaderMethods';
|
|
26
|
+
export { HEADER_TYPES } from './HeaderTypes';
|
|
27
|
+
export { LogApiCall } from './LogApiCall';
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.HttpUserError = exports.HttpVendorError = exports.HttpInternalServerError = exports.HttpGatewayTimeoutError = exports.HttpBadGatewayError = exports.HttpTimeoutError = exports.HttpForbiddenError = exports.HttpUnauthorizedError = exports.HttpBadRequestError = exports.EndpointNotFoundError = exports.HttpNotFoundError = exports.HttpError = exports.ProtocolError = exports.METADATA_KEYS = exports.RouteMetadata = exports.isApiInterface = exports.getRoutes = exports.Path = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.ApiInterface = void 0;
|
|
21
|
+
exports.LogApiCall = exports.HEADER_TYPES = exports.HeaderMethods = exports.PlatformHeadersExtension = exports.PlatformHeader = exports.DateTimeUtil = exports.TimeUtil = exports.DateUtil = exports.InstantUtil = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.HttpUserError = exports.HttpVendorError = exports.HttpInternalServerError = exports.HttpGatewayTimeoutError = exports.HttpBadGatewayError = exports.HttpTimeoutError = exports.HttpForbiddenError = exports.HttpUnauthorizedError = exports.HttpBadRequestError = exports.EndpointNotFoundError = exports.HttpNotFoundError = exports.HttpError = exports.ProtocolError = exports.METADATA_KEYS = exports.RouteMetadata = exports.isApiInterface = exports.getRoutes = exports.Path = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.ApiInterface = void 0;
|
|
22
22
|
// API definition decorators
|
|
23
23
|
var decorators_1 = require("./decorators");
|
|
24
24
|
Object.defineProperty(exports, "ApiInterface", { enumerable: true, get: function () { return decorators_1.ApiInterface; } });
|
|
@@ -56,4 +56,22 @@ Object.defineProperty(exports, "EMAIL_NOT_CONFIRMED", { enumerable: true, get: f
|
|
|
56
56
|
Object.defineProperty(exports, "WRONG_DOMAIN", { enumerable: true, get: function () { return errors_1.WRONG_DOMAIN; } });
|
|
57
57
|
Object.defineProperty(exports, "WRONG_COMPANY", { enumerable: true, get: function () { return errors_1.WRONG_COMPANY; } });
|
|
58
58
|
Object.defineProperty(exports, "NO_REG_CODE", { enumerable: true, get: function () { return errors_1.NO_REG_CODE; } });
|
|
59
|
+
// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)
|
|
60
|
+
var datetime_1 = require("./datetime");
|
|
61
|
+
Object.defineProperty(exports, "InstantUtil", { enumerable: true, get: function () { return datetime_1.InstantUtil; } });
|
|
62
|
+
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return datetime_1.DateUtil; } });
|
|
63
|
+
Object.defineProperty(exports, "TimeUtil", { enumerable: true, get: function () { return datetime_1.TimeUtil; } });
|
|
64
|
+
Object.defineProperty(exports, "DateTimeUtil", { enumerable: true, get: function () { return datetime_1.DateTimeUtil; } });
|
|
65
|
+
// Platform Headers
|
|
66
|
+
var PlatformHeader_1 = require("./PlatformHeader");
|
|
67
|
+
Object.defineProperty(exports, "PlatformHeader", { enumerable: true, get: function () { return PlatformHeader_1.PlatformHeader; } });
|
|
68
|
+
var PlatformHeadersExtension_1 = require("./PlatformHeadersExtension");
|
|
69
|
+
Object.defineProperty(exports, "PlatformHeadersExtension", { enumerable: true, get: function () { return PlatformHeadersExtension_1.PlatformHeadersExtension; } });
|
|
70
|
+
var HeaderMethods_1 = require("./HeaderMethods");
|
|
71
|
+
Object.defineProperty(exports, "HeaderMethods", { enumerable: true, get: function () { return HeaderMethods_1.HeaderMethods; } });
|
|
72
|
+
var HeaderTypes_1 = require("./HeaderTypes");
|
|
73
|
+
Object.defineProperty(exports, "HEADER_TYPES", { enumerable: true, get: function () { return HeaderTypes_1.HEADER_TYPES; } });
|
|
74
|
+
// Logging
|
|
75
|
+
var LogApiCall_1 = require("./LogApiCall");
|
|
76
|
+
Object.defineProperty(exports, "LogApiCall", { enumerable: true, get: function () { return LogApiCall_1.LogApiCall; } });
|
|
59
77
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,4BAA4B;AAC5B,2CAYsB;AAXlB,0GAAA,YAAY,OAAA;AACZ,iGAAA,GAAG,OAAA;AACH,kGAAA,IAAI,OAAA;AACJ,iGAAA,GAAG,OAAA;AACH,oGAAA,MAAM,OAAA;AACN,mGAAA,KAAK,OAAA;AACL,kGAAA,IAAI,OAAA;AACJ,uGAAA,SAAS,OAAA;AACT,4GAAA,cAAc,OAAA;AACd,2GAAA,aAAa,OAAA;AACb,2GAAA,aAAa,OAAA;AAMjB,cAAc;AACd,mCAuBkB;AAtBd,uGAAA,aAAa,OAAA;AACb,mGAAA,SAAS,OAAA;AACT,2GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,6GAAA,mBAAmB,OAAA;AACnB,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,iHAAA,uBAAuB,OAAA;AACvB,iHAAA,uBAAuB,OAAA;AACvB,yGAAA,eAAe,OAAA;AACf,uGAAA,aAAa,OAAA;AACb,0BAA0B;AAC1B,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAChB,qGAAA,WAAW,OAAA;AACX,sGAAA,YAAY,OAAA;AACZ,6GAAA,mBAAmB,OAAA;AACnB,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AACb,qGAAA,WAAW,OAAA","sourcesContent":["/**\n * @webpieces/http-api\n *\n * Core HTTP API definition package.\n * Contains decorators and utilities for defining HTTP APIs.\n *\n * This package is used by:\n * - @webpieces/http-routing (server-side): Routes HTTP requests to controllers\n * - @webpieces/http-client (client-side): Generates HTTP clients from API definitions\n *\n * Architecture:\n * ```\n * http-api (defines the contract)\n * ↑\n * ├── http-routing (server: contract → handlers)\n * └── http-client (client: contract → HTTP requests)\n * ```\n */\n\n// API definition decorators\nexport {\n ApiInterface,\n Get,\n Post,\n Put,\n Delete,\n Patch,\n Path,\n getRoutes,\n isApiInterface,\n RouteMetadata,\n METADATA_KEYS,\n} from './decorators';\n\n// Type validators\nexport { ValidateImplementation } from './validators';\n\n// HTTP errors\nexport {\n ProtocolError,\n HttpError,\n HttpNotFoundError,\n EndpointNotFoundError,\n HttpBadRequestError,\n HttpUnauthorizedError,\n HttpForbiddenError,\n HttpTimeoutError,\n HttpBadGatewayError,\n HttpGatewayTimeoutError,\n HttpInternalServerError,\n HttpVendorError,\n HttpUserError,\n // Error subtype constants\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages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;AACtB,6CAA6C;AAApC,2GAAA,YAAY,OAAA;AAErB,UAAU;AACV,2CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["/**\n * @webpieces/http-api\n *\n * Core HTTP API definition package.\n * Contains decorators and utilities for defining HTTP APIs.\n *\n * This package is used by:\n * - @webpieces/http-routing (server-side): Routes HTTP requests to controllers\n * - @webpieces/http-client (client-side): Generates HTTP clients from API definitions\n *\n * Architecture:\n * ```\n * http-api (defines the contract)\n * ↑\n * ├── http-routing (server: contract → handlers)\n * └── http-client (client: contract → HTTP requests)\n * ```\n */\n\n// API definition decorators\nexport {\n ApiInterface,\n Get,\n Post,\n Put,\n Delete,\n Patch,\n Path,\n getRoutes,\n isApiInterface,\n RouteMetadata,\n METADATA_KEYS,\n} from './decorators';\n\n// Type validators\nexport { ValidateImplementation } from './validators';\n\n// HTTP errors\nexport {\n ProtocolError,\n HttpError,\n HttpNotFoundError,\n EndpointNotFoundError,\n HttpBadRequestError,\n HttpUnauthorizedError,\n HttpForbiddenError,\n HttpTimeoutError,\n HttpBadGatewayError,\n HttpGatewayTimeoutError,\n HttpInternalServerError,\n HttpVendorError,\n HttpUserError,\n // Error subtype constants\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './datetime';\n\n// Platform Headers\nexport { PlatformHeader } from './PlatformHeader';\nexport { PlatformHeadersExtension } from './PlatformHeadersExtension';\nexport { HeaderMethods, ContextReader } from './HeaderMethods';\nexport { HEADER_TYPES } from './HeaderTypes';\n\n// Logging\nexport { LogApiCall } from './LogApiCall';\n"]}
|