@zudojs/constants 1.1.3 → 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/dist/cache/cacheControl.type.d.ts +0 -1
- package/dist/cache/cacheControl.type.js +0 -1
- package/dist/cache/cacheStrategy.type.d.ts +0 -1
- package/dist/cache/cacheStrategy.type.js +0 -1
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +0 -1
- package/dist/common/common.constant.d.ts +3 -36
- package/dist/common/common.constant.js +2 -52
- package/dist/common/common.factory.d.ts +0 -1
- package/dist/common/common.factory.js +0 -1
- package/dist/common/common.identifier.d.ts +69 -0
- package/dist/common/common.identifier.js +100 -0
- package/dist/common/common.lifecycle.d.ts +0 -1
- package/dist/common/common.lifecycle.js +0 -1
- package/dist/common/common.schema.d.ts +0 -1
- package/dist/common/common.schema.js +0 -1
- package/dist/common/common.serialization.d.ts +0 -1
- package/dist/common/common.serialization.js +0 -1
- package/dist/common/common.type.d.ts +9 -1
- package/dist/common/common.type.js +0 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +2 -2
- package/dist/constantsErrors/constantsError.base.d.ts +0 -1
- package/dist/constantsErrors/constantsError.base.js +0 -1
- package/dist/constantsErrors/index.d.ts +0 -1
- package/dist/constantsErrors/index.js +0 -1
- package/dist/environment/environment.constant.d.ts +0 -1
- package/dist/environment/environment.constant.js +0 -1
- package/dist/environment/environment.type.d.ts +0 -1
- package/dist/environment/environment.type.js +0 -1
- package/dist/environment/index.d.ts +0 -1
- package/dist/environment/index.js +0 -1
- package/dist/http/httpContentType.type.d.ts +0 -1
- package/dist/http/httpContentType.type.js +0 -1
- package/dist/http/httpHeader.type.d.ts +0 -1
- package/dist/http/httpHeader.type.js +0 -1
- package/dist/http/httpMethod.type.d.ts +0 -1
- package/dist/http/httpMethod.type.js +0 -1
- package/dist/http/httpStatus.type.d.ts +0 -1
- package/dist/http/httpStatus.type.js +0 -1
- package/dist/http/index.d.ts +0 -1
- package/dist/http/index.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/internal/immutableSet.d.ts +0 -1
- package/dist/internal/immutableSet.js +0 -1
- package/dist/priority/index.d.ts +0 -1
- package/dist/priority/index.js +0 -1
- package/dist/priority/priority.type.d.ts +0 -1
- package/dist/priority/priority.type.js +0 -1
- package/dist/runtime/clock.d.ts +10 -1
- package/dist/runtime/clock.js +4 -1
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.js +4 -1
- package/dist/runtime/random.d.ts +14 -4
- package/dist/runtime/random.js +4 -1
- package/dist/time/index.d.ts +0 -1
- package/dist/time/index.js +0 -1
- package/dist/time/time.constant.d.ts +5 -1
- package/dist/time/time.constant.js +7 -1
- package/dist/time/time.unit.type.d.ts +0 -1
- package/dist/time/time.unit.type.js +0 -1
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +0 -1
- package/dist/validation/validation.constant.d.ts +0 -1
- package/dist/validation/validation.constant.js +0 -1
- package/dist/validation/validation.pattern.type.d.ts +0 -1
- package/dist/validation/validation.pattern.type.js +0 -1
- package/package.json +2 -2
package/dist/cache/index.d.ts
CHANGED
package/dist/cache/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Common default values, limits, sentinel constants, and branded
|
|
3
|
-
* factories.
|
|
2
|
+
* Common default values, limits, sentinel constants, and branded string
|
|
3
|
+
* factories. Identifier factories live in `common.identifier.ts`.
|
|
4
4
|
*
|
|
5
5
|
* @module common/common
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import type { Url, HexString, Base64String, JsonString } from "./common.type.js";
|
|
8
8
|
/** Sentinel value indicating absence of a value. */
|
|
9
9
|
export declare const NONE: "NONE";
|
|
10
10
|
/** Sentinel value indicating an uninitialized state. */
|
|
@@ -89,38 +89,6 @@ export declare const Sentinel: Readonly<{
|
|
|
89
89
|
/** Wildcard for matching all */
|
|
90
90
|
readonly WILDCARD: "*";
|
|
91
91
|
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Create a branded UserId from a raw string.
|
|
94
|
-
*/
|
|
95
|
-
export declare function createUserId(id: string): UserId;
|
|
96
|
-
/**
|
|
97
|
-
* Create a branded EventId from a raw string.
|
|
98
|
-
*/
|
|
99
|
-
export declare function createEventId(id: string): EventId;
|
|
100
|
-
/**
|
|
101
|
-
* Create a branded RequestId from a raw string.
|
|
102
|
-
*/
|
|
103
|
-
export declare function createRequestId(id: string): RequestId;
|
|
104
|
-
/**
|
|
105
|
-
* Create a branded CorrelationId from a raw string.
|
|
106
|
-
*/
|
|
107
|
-
export declare function createCorrelationId(id: string): CorrelationId;
|
|
108
|
-
/**
|
|
109
|
-
* Create a branded SessionId from a raw string.
|
|
110
|
-
*/
|
|
111
|
-
export declare function createSessionId(id: string): SessionId;
|
|
112
|
-
/**
|
|
113
|
-
* Create a branded MessageId from a raw string.
|
|
114
|
-
*/
|
|
115
|
-
export declare function createMessageId(id: string): MessageId;
|
|
116
|
-
/**
|
|
117
|
-
* Create a branded MessageCausationId from a raw string.
|
|
118
|
-
*/
|
|
119
|
-
export declare function createMessageCausationId(id: string): MessageCausationId;
|
|
120
|
-
/**
|
|
121
|
-
* Create a branded TokenId from a raw string.
|
|
122
|
-
*/
|
|
123
|
-
export declare function createTokenId(id: string): TokenId;
|
|
124
92
|
/**
|
|
125
93
|
* Create a branded Url from a raw string.
|
|
126
94
|
*
|
|
@@ -145,4 +113,3 @@ export declare function createBase64String(base64: string): Base64String;
|
|
|
145
113
|
* @throws {InvalidConstantError} if the input is not parseable JSON.
|
|
146
114
|
*/
|
|
147
115
|
export declare function createJsonString(json: string): JsonString;
|
|
148
|
-
//# sourceMappingURL=common.constant.d.ts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Common default values, limits, sentinel constants, and branded
|
|
3
|
-
* factories.
|
|
2
|
+
* Common default values, limits, sentinel constants, and branded string
|
|
3
|
+
* factories. Identifier factories live in `common.identifier.ts`.
|
|
4
4
|
*
|
|
5
5
|
* @module common/common
|
|
6
6
|
*/
|
|
7
|
-
import {} from "./common.type.js";
|
|
8
7
|
import { ContentTypes, Charset } from "../http/httpContentType.type.js";
|
|
9
8
|
import { InvalidConstantError } from "../constantsErrors/constantsError.base.js";
|
|
10
9
|
/** Sentinel value indicating absence of a value. */
|
|
@@ -91,54 +90,6 @@ export const Sentinel = Object.freeze({
|
|
|
91
90
|
/** Wildcard for matching all */
|
|
92
91
|
WILDCARD: "*",
|
|
93
92
|
});
|
|
94
|
-
/**
|
|
95
|
-
* Create a branded UserId from a raw string.
|
|
96
|
-
*/
|
|
97
|
-
export function createUserId(id) {
|
|
98
|
-
return id;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Create a branded EventId from a raw string.
|
|
102
|
-
*/
|
|
103
|
-
export function createEventId(id) {
|
|
104
|
-
return id;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Create a branded RequestId from a raw string.
|
|
108
|
-
*/
|
|
109
|
-
export function createRequestId(id) {
|
|
110
|
-
return id;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a branded CorrelationId from a raw string.
|
|
114
|
-
*/
|
|
115
|
-
export function createCorrelationId(id) {
|
|
116
|
-
return id;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Create a branded SessionId from a raw string.
|
|
120
|
-
*/
|
|
121
|
-
export function createSessionId(id) {
|
|
122
|
-
return id;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Create a branded MessageId from a raw string.
|
|
126
|
-
*/
|
|
127
|
-
export function createMessageId(id) {
|
|
128
|
-
return id;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Create a branded MessageCausationId from a raw string.
|
|
132
|
-
*/
|
|
133
|
-
export function createMessageCausationId(id) {
|
|
134
|
-
return id;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Create a branded TokenId from a raw string.
|
|
138
|
-
*/
|
|
139
|
-
export function createTokenId(id) {
|
|
140
|
-
return id;
|
|
141
|
-
}
|
|
142
93
|
/**
|
|
143
94
|
* Create a branded Url from a raw string.
|
|
144
95
|
*
|
|
@@ -186,4 +137,3 @@ export function createJsonString(json) {
|
|
|
186
137
|
}
|
|
187
138
|
return json;
|
|
188
139
|
}
|
|
189
|
-
//# sourceMappingURL=common.constant.js.map
|
|
@@ -44,4 +44,3 @@ export declare function createTimestamp(iso: string): Timestamp;
|
|
|
44
44
|
* @throws {InvalidConstantError} if the input is not a valid email address.
|
|
45
45
|
*/
|
|
46
46
|
export declare function createEmailAddress(email: string): EmailAddress;
|
|
47
|
-
//# sourceMappingURL=common.factory.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded identifier factories.
|
|
3
|
+
*
|
|
4
|
+
* Each factory checks that it was handed a non-empty string before applying
|
|
5
|
+
* the brand. The brand is compile-time only (see {@link Brand}), so without
|
|
6
|
+
* this check `createUserId("")` and `createUserId(123 as never)` produced a
|
|
7
|
+
* "UserId" that no consumer could tell apart from a real one until it
|
|
8
|
+
* reached a database or a URL.
|
|
9
|
+
*
|
|
10
|
+
* @module common/identifier
|
|
11
|
+
*/
|
|
12
|
+
import type { UserId, EventId, RequestId, CorrelationId, SessionId, MessageId, MessageCausationId, TokenId } from "./common.type.js";
|
|
13
|
+
/**
|
|
14
|
+
* Asserts that an identifier is a non-empty string.
|
|
15
|
+
*
|
|
16
|
+
* The value itself is never echoed: identifiers include session and token
|
|
17
|
+
* ids, which must not land in a log line through an error message.
|
|
18
|
+
*
|
|
19
|
+
* @throws {InvalidConstantError} when `id` is not a string or is empty.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertIdentifier(id: unknown, label: string): asserts id is string;
|
|
22
|
+
/**
|
|
23
|
+
* Create a branded UserId from a raw string.
|
|
24
|
+
*
|
|
25
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createUserId(id: string): UserId;
|
|
28
|
+
/**
|
|
29
|
+
* Create a branded EventId from a raw string.
|
|
30
|
+
*
|
|
31
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createEventId(id: string): EventId;
|
|
34
|
+
/**
|
|
35
|
+
* Create a branded RequestId from a raw string.
|
|
36
|
+
*
|
|
37
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createRequestId(id: string): RequestId;
|
|
40
|
+
/**
|
|
41
|
+
* Create a branded CorrelationId from a raw string.
|
|
42
|
+
*
|
|
43
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCorrelationId(id: string): CorrelationId;
|
|
46
|
+
/**
|
|
47
|
+
* Create a branded SessionId from a raw string.
|
|
48
|
+
*
|
|
49
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createSessionId(id: string): SessionId;
|
|
52
|
+
/**
|
|
53
|
+
* Create a branded MessageId from a raw string.
|
|
54
|
+
*
|
|
55
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createMessageId(id: string): MessageId;
|
|
58
|
+
/**
|
|
59
|
+
* Create a branded MessageCausationId from a raw string.
|
|
60
|
+
*
|
|
61
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createMessageCausationId(id: string): MessageCausationId;
|
|
64
|
+
/**
|
|
65
|
+
* Create a branded TokenId from a raw string.
|
|
66
|
+
*
|
|
67
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createTokenId(id: string): TokenId;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded identifier factories.
|
|
3
|
+
*
|
|
4
|
+
* Each factory checks that it was handed a non-empty string before applying
|
|
5
|
+
* the brand. The brand is compile-time only (see {@link Brand}), so without
|
|
6
|
+
* this check `createUserId("")` and `createUserId(123 as never)` produced a
|
|
7
|
+
* "UserId" that no consumer could tell apart from a real one until it
|
|
8
|
+
* reached a database or a URL.
|
|
9
|
+
*
|
|
10
|
+
* @module common/identifier
|
|
11
|
+
*/
|
|
12
|
+
import { InvalidConstantError } from "../constantsErrors/constantsError.base.js";
|
|
13
|
+
/**
|
|
14
|
+
* Asserts that an identifier is a non-empty string.
|
|
15
|
+
*
|
|
16
|
+
* The value itself is never echoed: identifiers include session and token
|
|
17
|
+
* ids, which must not land in a log line through an error message.
|
|
18
|
+
*
|
|
19
|
+
* @throws {InvalidConstantError} when `id` is not a string or is empty.
|
|
20
|
+
*/
|
|
21
|
+
export function assertIdentifier(id, label) {
|
|
22
|
+
if (typeof id !== "string") {
|
|
23
|
+
throw new InvalidConstantError(`${label} must be a non-empty string, received ${id === null ? "null" : typeof id}.`);
|
|
24
|
+
}
|
|
25
|
+
if (id.length === 0) {
|
|
26
|
+
throw new InvalidConstantError(`${label} must be a non-empty string.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a branded UserId from a raw string.
|
|
31
|
+
*
|
|
32
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
33
|
+
*/
|
|
34
|
+
export function createUserId(id) {
|
|
35
|
+
assertIdentifier(id, "UserId");
|
|
36
|
+
return id;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a branded EventId from a raw string.
|
|
40
|
+
*
|
|
41
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
42
|
+
*/
|
|
43
|
+
export function createEventId(id) {
|
|
44
|
+
assertIdentifier(id, "EventId");
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a branded RequestId from a raw string.
|
|
49
|
+
*
|
|
50
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
51
|
+
*/
|
|
52
|
+
export function createRequestId(id) {
|
|
53
|
+
assertIdentifier(id, "RequestId");
|
|
54
|
+
return id;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a branded CorrelationId from a raw string.
|
|
58
|
+
*
|
|
59
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
60
|
+
*/
|
|
61
|
+
export function createCorrelationId(id) {
|
|
62
|
+
assertIdentifier(id, "CorrelationId");
|
|
63
|
+
return id;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a branded SessionId from a raw string.
|
|
67
|
+
*
|
|
68
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
69
|
+
*/
|
|
70
|
+
export function createSessionId(id) {
|
|
71
|
+
assertIdentifier(id, "SessionId");
|
|
72
|
+
return id;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a branded MessageId from a raw string.
|
|
76
|
+
*
|
|
77
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
78
|
+
*/
|
|
79
|
+
export function createMessageId(id) {
|
|
80
|
+
assertIdentifier(id, "MessageId");
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a branded MessageCausationId from a raw string.
|
|
85
|
+
*
|
|
86
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
87
|
+
*/
|
|
88
|
+
export function createMessageCausationId(id) {
|
|
89
|
+
assertIdentifier(id, "MessageCausationId");
|
|
90
|
+
return id;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a branded TokenId from a raw string.
|
|
94
|
+
*
|
|
95
|
+
* @throws {InvalidConstantError} if the input is not a non-empty string.
|
|
96
|
+
*/
|
|
97
|
+
export function createTokenId(id) {
|
|
98
|
+
assertIdentifier(id, "TokenId");
|
|
99
|
+
return id;
|
|
100
|
+
}
|
|
@@ -60,4 +60,3 @@ export declare const LIFECYCLE_DEFAULT_RETRY_ATTEMPTS: 3;
|
|
|
60
60
|
export declare const LIFECYCLE_DEFAULT_RETRY_DELAY = 500;
|
|
61
61
|
/** Maximum retry delay (ms). */
|
|
62
62
|
export declare const LIFECYCLE_DEFAULT_RETRY_MAX_DELAY = 10000;
|
|
63
|
-
//# sourceMappingURL=common.lifecycle.d.ts.map
|
|
@@ -95,4 +95,3 @@ export const LIFECYCLE_DEFAULT_RETRY_ATTEMPTS = DefaultRetry.MAX_ATTEMPTS;
|
|
|
95
95
|
export const LIFECYCLE_DEFAULT_RETRY_DELAY = 500;
|
|
96
96
|
/** Maximum retry delay (ms). */
|
|
97
97
|
export const LIFECYCLE_DEFAULT_RETRY_MAX_DELAY = 10_000;
|
|
98
|
-
//# sourceMappingURL=common.lifecycle.js.map
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Brands prevent accidental assignment between structurally identical types
|
|
10
10
|
* (e.g. a UserId cannot be passed where an EventId is expected).
|
|
11
|
+
*
|
|
12
|
+
* The brand is compile-time only. At runtime a `UserId` is a plain string:
|
|
13
|
+
* `__brand` is never present as a property, `typeof` and `JSON.stringify`
|
|
14
|
+
* see an ordinary string, and any value cast with `as UserId` passes the
|
|
15
|
+
* type. The key is a string rather than a `unique symbol` on purpose: two
|
|
16
|
+
* copies of `@zudojs/constants` (or a consumer that declares its own
|
|
17
|
+
* `Brand<string, "UserId">`) stay assignable to each other, which a symbol
|
|
18
|
+
* brand would forbid. Runtime checks belong in the `create*Id` factories,
|
|
19
|
+
* which reject empty and non-string input.
|
|
11
20
|
*/
|
|
12
21
|
export type Brand<T, B extends string> = T & {
|
|
13
22
|
readonly __brand: B;
|
|
@@ -44,4 +53,3 @@ export type HexString = Brand<string, "HexString">;
|
|
|
44
53
|
export type Base64String = Brand<string, "Base64String">;
|
|
45
54
|
/** JSON-serialized string. */
|
|
46
55
|
export type JsonString = Brand<string, "JsonString">;
|
|
47
|
-
//# sourceMappingURL=common.type.d.ts.map
|
package/dist/common/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @module common
|
|
5
5
|
*/
|
|
6
6
|
export { type Brand, type EntityId, type UserId, type EventId, type RequestId, type CorrelationId, type SessionId, type TenantId, type MessageId, type MessageCausationId, type TokenId, type Timestamp, type Url, type EmailAddress, type HexString, type Base64String, type JsonString, } from "./common.type.js";
|
|
7
|
-
export { NONE, UNINITIALIZED, EMPTY, Limits, Defaults, Sentinel,
|
|
7
|
+
export { NONE, UNINITIALIZED, EMPTY, Limits, Defaults, Sentinel, createUrl, createHexString, createBase64String, createJsonString, } from "./common.constant.js";
|
|
8
|
+
export { assertIdentifier, createUserId, createEventId, createRequestId, createCorrelationId, createSessionId, createMessageId, createMessageCausationId, createTokenId, } from "./common.identifier.js";
|
|
8
9
|
export { createTenantId, createTimestamp, createEmailAddress, TENANT_ID_PATTERN, MAX_TENANT_ID_LENGTH, } from "./common.factory.js";
|
|
9
10
|
export { SerializationFormat, SerializationContentType, SerializationLimits, SerializationTags, SERIALIZATION_SCHEMA_VERSION, } from "./common.serialization.js";
|
|
10
11
|
export { SchemaIssueCode, SCHEMA_DEFAULT_MAX_DEPTH, SCHEMA_DEFAULT_MAX_STRING_LENGTH, SCHEMA_DEFAULT_MAX_ARRAY_LENGTH, SCHEMA_DEFAULT_MAX_OBJECT_KEYS, SCHEMA_FORBIDDEN_KEYS, SCHEMA_STRING_FORMATS, } from "./common.schema.js";
|
|
11
12
|
export { LifecycleState, LifecyclePhase, LIFECYCLE_VALID_TRANSITIONS, LIFECYCLE_DEFAULT_TIMEOUT, LIFECYCLE_DEFAULT_START_TIMEOUT, LIFECYCLE_DEFAULT_STOP_TIMEOUT, LIFECYCLE_DEFAULT_SHUTDOWN_TIMEOUT, LIFECYCLE_DEFAULT_CONCURRENCY, LIFECYCLE_DEFAULT_RETRY_ATTEMPTS, LIFECYCLE_DEFAULT_RETRY_DELAY, LIFECYCLE_DEFAULT_RETRY_MAX_DELAY, } from "./common.lifecycle.js";
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/common/index.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @module common
|
|
5
5
|
*/
|
|
6
6
|
export {} from "./common.type.js";
|
|
7
|
-
export { NONE, UNINITIALIZED, EMPTY, Limits, Defaults, Sentinel,
|
|
7
|
+
export { NONE, UNINITIALIZED, EMPTY, Limits, Defaults, Sentinel, createUrl, createHexString, createBase64String, createJsonString, } from "./common.constant.js";
|
|
8
|
+
export { assertIdentifier, createUserId, createEventId, createRequestId, createCorrelationId, createSessionId, createMessageId, createMessageCausationId, createTokenId, } from "./common.identifier.js";
|
|
8
9
|
export { createTenantId, createTimestamp, createEmailAddress, TENANT_ID_PATTERN, MAX_TENANT_ID_LENGTH, } from "./common.factory.js";
|
|
9
10
|
export { SerializationFormat, SerializationContentType, SerializationLimits, SerializationTags, SERIALIZATION_SCHEMA_VERSION, } from "./common.serialization.js";
|
|
10
11
|
export { SchemaIssueCode, SCHEMA_DEFAULT_MAX_DEPTH, SCHEMA_DEFAULT_MAX_STRING_LENGTH, SCHEMA_DEFAULT_MAX_ARRAY_LENGTH, SCHEMA_DEFAULT_MAX_OBJECT_KEYS, SCHEMA_FORBIDDEN_KEYS, SCHEMA_STRING_FORMATS, } from "./common.schema.js";
|
|
11
12
|
export { LifecycleState, LifecyclePhase, LIFECYCLE_VALID_TRANSITIONS, LIFECYCLE_DEFAULT_TIMEOUT, LIFECYCLE_DEFAULT_START_TIMEOUT, LIFECYCLE_DEFAULT_STOP_TIMEOUT, LIFECYCLE_DEFAULT_SHUTDOWN_TIMEOUT, LIFECYCLE_DEFAULT_CONCURRENCY, LIFECYCLE_DEFAULT_RETRY_ATTEMPTS, LIFECYCLE_DEFAULT_RETRY_DELAY, LIFECYCLE_DEFAULT_RETRY_MAX_DELAY, } from "./common.lifecycle.js";
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -51,4 +51,3 @@ export declare function isDevelopment(envOverride?: Record<string, string | unde
|
|
|
51
51
|
* Check whether the current environment is test.
|
|
52
52
|
*/
|
|
53
53
|
export declare function isTest(envOverride?: Record<string, string | undefined>): boolean;
|
|
54
|
-
//# sourceMappingURL=environment.constant.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { type Environment, Environments, ENVIRONMENTS, isValidEnvironment, } from "./environment.type.js";
|
|
7
7
|
export { NODE_ENV_KEY, type ResolveEnvironmentOptions, resolveEnvironment, isProduction, isDevelopment, isTest, } from "./environment.constant.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -25,4 +25,3 @@ export declare const HTTP_METHODS: ReadonlySet<HttpMethod>;
|
|
|
25
25
|
export declare const SAFE_HTTP_METHODS: ReadonlySet<HttpMethod>;
|
|
26
26
|
/** HTTP methods that are idempotent. Immutable at runtime. */
|
|
27
27
|
export declare const IDEMPOTENT_HTTP_METHODS: ReadonlySet<HttpMethod>;
|
|
28
|
-
//# sourceMappingURL=httpMethod.type.d.ts.map
|
package/dist/http/index.d.ts
CHANGED
|
@@ -7,4 +7,3 @@ export { type HttpMethod, HttpMethods, HTTP_METHODS, SAFE_HTTP_METHODS, IDEMPOTE
|
|
|
7
7
|
export { type HttpStatusCode, type AnyHttpStatusCode, HttpStatus, isSuccessStatus, isRedirectStatus, isClientError, isServerError, isErrorStatus, } from "./httpStatus.type.js";
|
|
8
8
|
export { type HttpHeaderName, type AnyHttpHeaderName, HttpHeader, } from "./httpHeader.type.js";
|
|
9
9
|
export { type ContentType, type AnyContentType, ContentTypes, Charset, buildContentType, } from "./httpContentType.type.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/http/index.js
CHANGED
|
@@ -7,4 +7,3 @@ export { HttpMethods, HTTP_METHODS, SAFE_HTTP_METHODS, IDEMPOTENT_HTTP_METHODS,
|
|
|
7
7
|
export { HttpStatus, isSuccessStatus, isRedirectStatus, isClientError, isServerError, isErrorStatus, } from "./httpStatus.type.js";
|
|
8
8
|
export { HttpHeader, } from "./httpHeader.type.js";
|
|
9
9
|
export { ContentTypes, Charset, buildContentType, } from "./httpContentType.type.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/priority/index.d.ts
CHANGED
package/dist/priority/index.js
CHANGED
package/dist/runtime/clock.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Provides deterministic time for testing.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Import `Clock` from `@zudojs/types`, the owning package. This
|
|
10
|
+
* copy differs in shape (it adds `Date()`) and is kept only so existing
|
|
11
|
+
* imports keep compiling; it will be removed in the next major.
|
|
8
12
|
*/
|
|
9
13
|
export interface Clock {
|
|
10
14
|
/**
|
|
@@ -21,6 +25,8 @@ export interface Clock {
|
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* A mock {@link Clock} whose time can be advanced or set explicitly.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Use `FixedClock` from `@zudojs/types`.
|
|
24
30
|
*/
|
|
25
31
|
export interface MockClock extends Clock {
|
|
26
32
|
/**
|
|
@@ -35,6 +41,8 @@ export interface MockClock extends Clock {
|
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* Default clock using real system time.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Import `systemClock` from `@zudojs/types`.
|
|
38
46
|
*/
|
|
39
47
|
export declare const systemClock: Clock;
|
|
40
48
|
/**
|
|
@@ -42,6 +50,7 @@ export declare const systemClock: Clock;
|
|
|
42
50
|
*
|
|
43
51
|
* The clock starts at `fixedTime` and stays there until `advance(ms)` or
|
|
44
52
|
* `set(time)` is called.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated Use `FixedClock` from `@zudojs/types`.
|
|
45
55
|
*/
|
|
46
56
|
export declare function createMockClock(fixedTime?: number): MockClock;
|
|
47
|
-
//# sourceMappingURL=clock.d.ts.map
|
package/dist/runtime/clock.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Default clock using real system time.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Import `systemClock` from `@zudojs/types`.
|
|
8
10
|
*/
|
|
9
11
|
export const systemClock = {
|
|
10
12
|
now: () => Date.now(),
|
|
@@ -15,6 +17,8 @@ export const systemClock = {
|
|
|
15
17
|
*
|
|
16
18
|
* The clock starts at `fixedTime` and stays there until `advance(ms)` or
|
|
17
19
|
* `set(time)` is called.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use `FixedClock` from `@zudojs/types`.
|
|
18
22
|
*/
|
|
19
23
|
export function createMockClock(fixedTime = 0) {
|
|
20
24
|
let time = fixedTime;
|
|
@@ -29,4 +33,3 @@ export function createMockClock(fixedTime = 0) {
|
|
|
29
33
|
},
|
|
30
34
|
};
|
|
31
35
|
}
|
|
32
|
-
//# sourceMappingURL=clock.js.map
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Injectable Clock and Random interfaces for deterministic testing.
|
|
3
3
|
*
|
|
4
|
+
* @deprecated `@zudojs/types` owns `Clock`, `Random`, `systemClock` and
|
|
5
|
+
* `systemRandom` (see the type ownership table). Everything here is kept so
|
|
6
|
+
* existing imports keep compiling and will be removed in the next major.
|
|
7
|
+
*
|
|
4
8
|
* @module runtime
|
|
5
9
|
*/
|
|
6
10
|
export { systemClock, createMockClock } from "./clock.js";
|
|
7
11
|
export type { Clock, MockClock } from "./clock.js";
|
|
8
12
|
export { systemRandom, createMockRandom } from "./random.js";
|
|
9
13
|
export type { Random, RandomSource, MockRandom } from "./random.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Injectable Clock and Random interfaces for deterministic testing.
|
|
3
3
|
*
|
|
4
|
+
* @deprecated `@zudojs/types` owns `Clock`, `Random`, `systemClock` and
|
|
5
|
+
* `systemRandom` (see the type ownership table). Everything here is kept so
|
|
6
|
+
* existing imports keep compiling and will be removed in the next major.
|
|
7
|
+
*
|
|
4
8
|
* @module runtime
|
|
5
9
|
*/
|
|
6
10
|
export { systemClock, createMockClock } from "./clock.js";
|
|
7
11
|
export { systemRandom, createMockRandom } from "./random.js";
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/runtime/random.d.ts
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
* so a predictable test double could be injected where tokens are minted.
|
|
12
12
|
*/
|
|
13
13
|
declare const SecureRandomBrand: unique symbol;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The randomness operations shared by {@link Random} and {@link MockRandom}.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Use the `Random`/`PseudoRandom` pair from `@zudojs/types`.
|
|
18
|
+
*/
|
|
15
19
|
export interface RandomSource {
|
|
16
20
|
/**
|
|
17
21
|
* Returns a random float between 0 (inclusive) and 1 (exclusive).
|
|
@@ -35,8 +39,9 @@ export interface RandomSource {
|
|
|
35
39
|
* salts. Branded: only {@link systemRandom} (or an implementation cast
|
|
36
40
|
* deliberately) satisfies it, and {@link MockRandom} never does.
|
|
37
41
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
42
|
+
* @deprecated Import `Random` from `@zudojs/types`, the owning package. The
|
|
43
|
+
* two interfaces have different method sets; this one is kept only so
|
|
44
|
+
* existing imports keep compiling and will be removed in the next major.
|
|
40
45
|
*/
|
|
41
46
|
export interface Random extends RandomSource {
|
|
42
47
|
/** @internal Marks the implementation as unpredictable. */
|
|
@@ -45,6 +50,8 @@ export interface Random extends RandomSource {
|
|
|
45
50
|
/**
|
|
46
51
|
* A seeded, fully predictable generator for tests.
|
|
47
52
|
*
|
|
53
|
+
* @deprecated Use `SeededRandom` from `@zudojs/types`.
|
|
54
|
+
*
|
|
48
55
|
* Structurally distinct from {@link Random} (it lacks the security brand and
|
|
49
56
|
* carries `deterministic: true`), so the compiler rejects it wherever a
|
|
50
57
|
* secure generator is required.
|
|
@@ -56,6 +63,8 @@ export interface MockRandom extends RandomSource {
|
|
|
56
63
|
/**
|
|
57
64
|
* Default random backed by `node:crypto` (CSPRNG).
|
|
58
65
|
*
|
|
66
|
+
* @deprecated Import `systemRandom` from `@zudojs/types`.
|
|
67
|
+
*
|
|
59
68
|
* Every method — including `random()` — draws from the platform CSPRNG, so
|
|
60
69
|
* this singleton is safe to use for tokens, session IDs, salts, and other
|
|
61
70
|
* security-sensitive values. `random()` builds a 53-bit float in `[0, 1)`
|
|
@@ -65,10 +74,11 @@ export declare const systemRandom: Random;
|
|
|
65
74
|
/**
|
|
66
75
|
* Creates a mock random with a seeded sequence for deterministic testing.
|
|
67
76
|
*
|
|
77
|
+
* @deprecated Use `SeededRandom` from `@zudojs/types`.
|
|
78
|
+
*
|
|
68
79
|
* Uses a 32-bit linear congruential generator (Numerical Recipes constants)
|
|
69
80
|
* with `Math.imul` for exact 32-bit arithmetic. Outputs are always in
|
|
70
81
|
* `[0, 1)`. Not cryptographically secure — tests only.
|
|
71
82
|
*/
|
|
72
83
|
export declare function createMockRandom(seed?: number): MockRandom;
|
|
73
84
|
export {};
|
|
74
|
-
//# sourceMappingURL=random.d.ts.map
|
package/dist/runtime/random.js
CHANGED
|
@@ -11,6 +11,8 @@ const RANDOM_FLOAT_WORDS = new Uint32Array(2);
|
|
|
11
11
|
/**
|
|
12
12
|
* Default random backed by `node:crypto` (CSPRNG).
|
|
13
13
|
*
|
|
14
|
+
* @deprecated Import `systemRandom` from `@zudojs/types`.
|
|
15
|
+
*
|
|
14
16
|
* Every method — including `random()` — draws from the platform CSPRNG, so
|
|
15
17
|
* this singleton is safe to use for tokens, session IDs, salts, and other
|
|
16
18
|
* security-sensitive values. `random()` builds a 53-bit float in `[0, 1)`
|
|
@@ -39,6 +41,8 @@ export const systemRandom = {
|
|
|
39
41
|
/**
|
|
40
42
|
* Creates a mock random with a seeded sequence for deterministic testing.
|
|
41
43
|
*
|
|
44
|
+
* @deprecated Use `SeededRandom` from `@zudojs/types`.
|
|
45
|
+
*
|
|
42
46
|
* Uses a 32-bit linear congruential generator (Numerical Recipes constants)
|
|
43
47
|
* with `Math.imul` for exact 32-bit arithmetic. Outputs are always in
|
|
44
48
|
* `[0, 1)`. Not cryptographically secure — tests only.
|
|
@@ -70,4 +74,3 @@ export function createMockRandom(seed = 1) {
|
|
|
70
74
|
},
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
|
-
//# sourceMappingURL=random.js.map
|
package/dist/time/index.d.ts
CHANGED
package/dist/time/index.js
CHANGED
|
@@ -73,8 +73,12 @@ export declare function toMilliseconds(value: number, unit: "milliseconds" | "se
|
|
|
73
73
|
/**
|
|
74
74
|
* Format a millisecond duration to a human-readable string.
|
|
75
75
|
*
|
|
76
|
+
* Shows the two most significant units and truncates the rest, so
|
|
77
|
+
* `formatDuration(90_500)` is "1m 30s" and `formatDuration(3_599_999)` is
|
|
78
|
+
* "59m 59s". A negative duration is formatted like its absolute value with a
|
|
79
|
+
* leading minus sign ("-1m 30s"); it used to fall through to "-90000ms".
|
|
80
|
+
*
|
|
76
81
|
* @param ms - Duration in milliseconds
|
|
77
82
|
* @returns Human-readable string (e.g. "5s", "2m 30s", "1h 15m")
|
|
78
83
|
*/
|
|
79
84
|
export declare function formatDuration(ms: number): string;
|
|
80
|
-
//# sourceMappingURL=time.constant.d.ts.map
|
|
@@ -86,10 +86,17 @@ export function toMilliseconds(value, unit) {
|
|
|
86
86
|
/**
|
|
87
87
|
* Format a millisecond duration to a human-readable string.
|
|
88
88
|
*
|
|
89
|
+
* Shows the two most significant units and truncates the rest, so
|
|
90
|
+
* `formatDuration(90_500)` is "1m 30s" and `formatDuration(3_599_999)` is
|
|
91
|
+
* "59m 59s". A negative duration is formatted like its absolute value with a
|
|
92
|
+
* leading minus sign ("-1m 30s"); it used to fall through to "-90000ms".
|
|
93
|
+
*
|
|
89
94
|
* @param ms - Duration in milliseconds
|
|
90
95
|
* @returns Human-readable string (e.g. "5s", "2m 30s", "1h 15m")
|
|
91
96
|
*/
|
|
92
97
|
export function formatDuration(ms) {
|
|
98
|
+
if (ms < 0)
|
|
99
|
+
return `-${formatDuration(-ms)}`;
|
|
93
100
|
if (ms < TimeMs.SECOND)
|
|
94
101
|
return `${ms}ms`;
|
|
95
102
|
if (ms < TimeMs.MINUTE)
|
|
@@ -108,4 +115,3 @@ export function formatDuration(ms) {
|
|
|
108
115
|
const h = Math.floor((ms % TimeMs.DAY) / TimeMs.HOUR);
|
|
109
116
|
return h > 0 ? `${d}d ${h}h` : `${d}d`;
|
|
110
117
|
}
|
|
111
|
-
//# sourceMappingURL=time.constant.js.map
|
package/dist/validation/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/constants",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared constants, enums, and type-safe literals for the Zudojs framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"!dist/.tsbuildinfo"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zudojs/errors": "1.
|
|
29
|
+
"@zudojs/errors": "1.4.0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=24.0.0"
|