@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.
Files changed (69) hide show
  1. package/dist/cache/cacheControl.type.d.ts +0 -1
  2. package/dist/cache/cacheControl.type.js +0 -1
  3. package/dist/cache/cacheStrategy.type.d.ts +0 -1
  4. package/dist/cache/cacheStrategy.type.js +0 -1
  5. package/dist/cache/index.d.ts +0 -1
  6. package/dist/cache/index.js +0 -1
  7. package/dist/common/common.constant.d.ts +3 -36
  8. package/dist/common/common.constant.js +2 -52
  9. package/dist/common/common.factory.d.ts +0 -1
  10. package/dist/common/common.factory.js +0 -1
  11. package/dist/common/common.identifier.d.ts +69 -0
  12. package/dist/common/common.identifier.js +100 -0
  13. package/dist/common/common.lifecycle.d.ts +0 -1
  14. package/dist/common/common.lifecycle.js +0 -1
  15. package/dist/common/common.schema.d.ts +0 -1
  16. package/dist/common/common.schema.js +0 -1
  17. package/dist/common/common.serialization.d.ts +0 -1
  18. package/dist/common/common.serialization.js +0 -1
  19. package/dist/common/common.type.d.ts +9 -1
  20. package/dist/common/common.type.js +0 -1
  21. package/dist/common/index.d.ts +2 -2
  22. package/dist/common/index.js +2 -2
  23. package/dist/constantsErrors/constantsError.base.d.ts +0 -1
  24. package/dist/constantsErrors/constantsError.base.js +0 -1
  25. package/dist/constantsErrors/index.d.ts +0 -1
  26. package/dist/constantsErrors/index.js +0 -1
  27. package/dist/environment/environment.constant.d.ts +0 -1
  28. package/dist/environment/environment.constant.js +0 -1
  29. package/dist/environment/environment.type.d.ts +0 -1
  30. package/dist/environment/environment.type.js +0 -1
  31. package/dist/environment/index.d.ts +0 -1
  32. package/dist/environment/index.js +0 -1
  33. package/dist/http/httpContentType.type.d.ts +0 -1
  34. package/dist/http/httpContentType.type.js +0 -1
  35. package/dist/http/httpHeader.type.d.ts +0 -1
  36. package/dist/http/httpHeader.type.js +0 -1
  37. package/dist/http/httpMethod.type.d.ts +0 -1
  38. package/dist/http/httpMethod.type.js +0 -1
  39. package/dist/http/httpStatus.type.d.ts +0 -1
  40. package/dist/http/httpStatus.type.js +0 -1
  41. package/dist/http/index.d.ts +0 -1
  42. package/dist/http/index.js +0 -1
  43. package/dist/index.d.ts +0 -1
  44. package/dist/index.js +0 -1
  45. package/dist/internal/immutableSet.d.ts +0 -1
  46. package/dist/internal/immutableSet.js +0 -1
  47. package/dist/priority/index.d.ts +0 -1
  48. package/dist/priority/index.js +0 -1
  49. package/dist/priority/priority.type.d.ts +0 -1
  50. package/dist/priority/priority.type.js +0 -1
  51. package/dist/runtime/clock.d.ts +10 -1
  52. package/dist/runtime/clock.js +4 -1
  53. package/dist/runtime/index.d.ts +4 -1
  54. package/dist/runtime/index.js +4 -1
  55. package/dist/runtime/random.d.ts +14 -4
  56. package/dist/runtime/random.js +4 -1
  57. package/dist/time/index.d.ts +0 -1
  58. package/dist/time/index.js +0 -1
  59. package/dist/time/time.constant.d.ts +5 -1
  60. package/dist/time/time.constant.js +7 -1
  61. package/dist/time/time.unit.type.d.ts +0 -1
  62. package/dist/time/time.unit.type.js +0 -1
  63. package/dist/validation/index.d.ts +0 -1
  64. package/dist/validation/index.js +0 -1
  65. package/dist/validation/validation.constant.d.ts +0 -1
  66. package/dist/validation/validation.constant.js +0 -1
  67. package/dist/validation/validation.pattern.type.d.ts +0 -1
  68. package/dist/validation/validation.pattern.type.js +0 -1
  69. package/package.json +2 -2
@@ -50,4 +50,3 @@ export interface CacheControlOptions {
50
50
  * non-negative finite integer
51
51
  */
52
52
  export declare function buildCacheControl(options: CacheControlOptions): string;
53
- //# sourceMappingURL=cacheControl.type.d.ts.map
@@ -73,4 +73,3 @@ export function buildCacheControl(options) {
73
73
  }
74
74
  return parts.join(", ");
75
75
  }
76
- //# sourceMappingURL=cacheControl.type.js.map
@@ -22,4 +22,3 @@ export declare const CacheStrategies: Readonly<{
22
22
  /** Cache indefinitely, never revalidate */
23
23
  readonly IMMUTABLE: "immutable";
24
24
  }>;
25
- //# sourceMappingURL=cacheStrategy.type.d.ts.map
@@ -20,4 +20,3 @@ export const CacheStrategies = Object.freeze({
20
20
  /** Cache indefinitely, never revalidate */
21
21
  IMMUTABLE: "immutable",
22
22
  });
23
- //# sourceMappingURL=cacheStrategy.type.js.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { type CacheStrategy, CacheStrategies } from "./cacheStrategy.type.js";
7
7
  export { CacheDuration, type CacheControlOptions, buildCacheControl, } from "./cacheControl.type.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { CacheStrategies } from "./cacheStrategy.type.js";
7
7
  export { CacheDuration, buildCacheControl, } from "./cacheControl.type.js";
8
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Common default values, limits, sentinel constants, and branded-type
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 { type UserId, type EventId, type RequestId, type CorrelationId, type SessionId, type MessageId, type MessageCausationId, type TokenId, type Url, type HexString, type Base64String, type JsonString } from "./common.type.js";
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-type
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
@@ -93,4 +93,3 @@ export function createEmailAddress(email) {
93
93
  }
94
94
  return email;
95
95
  }
96
- //# sourceMappingURL=common.factory.js.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
@@ -80,4 +80,3 @@ export declare const SCHEMA_STRING_FORMATS: Readonly<{
80
80
  readonly HEX_COLOR: RegExp;
81
81
  readonly PHONE: RegExp;
82
82
  }>;
83
- //# sourceMappingURL=common.schema.d.ts.map
@@ -85,4 +85,3 @@ export const SCHEMA_STRING_FORMATS = Object.freeze({
85
85
  HEX_COLOR: ValidationPattern.HEX_COLOR,
86
86
  PHONE: ValidationPattern.PHONE,
87
87
  });
88
- //# sourceMappingURL=common.schema.js.map
@@ -58,4 +58,3 @@ export declare const SerializationTags: Readonly<{
58
58
  }>;
59
59
  /** Current serialization schema version. */
60
60
  export declare const SERIALIZATION_SCHEMA_VERSION = 1;
61
- //# sourceMappingURL=common.serialization.d.ts.map
@@ -60,4 +60,3 @@ export const SerializationTags = Object.freeze({
60
60
  });
61
61
  /** Current serialization schema version. */
62
62
  export const SERIALIZATION_SCHEMA_VERSION = 1;
63
- //# sourceMappingURL=common.serialization.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
@@ -4,4 +4,3 @@
4
4
  * @module common/common
5
5
  */
6
6
  export {};
7
- //# sourceMappingURL=common.type.js.map
@@ -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, createUserId, createEventId, createRequestId, createCorrelationId, createSessionId, createMessageId, createMessageCausationId, createTokenId, createUrl, createHexString, createBase64String, createJsonString, } from "./common.constant.js";
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
@@ -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, createUserId, createEventId, createRequestId, createCorrelationId, createSessionId, createMessageId, createMessageCausationId, createTokenId, createUrl, createHexString, createBase64String, createJsonString, } from "./common.constant.js";
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
@@ -7,4 +7,3 @@
7
7
  * @module constantsErrors
8
8
  */
9
9
  export { InvalidConstantError, ConstantContextError } from "@zudojs/errors";
10
- //# sourceMappingURL=constantsError.base.d.ts.map
@@ -7,4 +7,3 @@
7
7
  * @module constantsErrors
8
8
  */
9
9
  export { InvalidConstantError, ConstantContextError } from "@zudojs/errors";
10
- //# sourceMappingURL=constantsError.base.js.map
@@ -4,4 +4,3 @@
4
4
  * @module constantsErrors
5
5
  */
6
6
  export { InvalidConstantError, ConstantContextError, } from "./constantsError.base.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * @module constantsErrors
5
5
  */
6
6
  export { InvalidConstantError, ConstantContextError, } from "./constantsError.base.js";
7
- //# 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
@@ -71,4 +71,3 @@ export function isDevelopment(envOverride) {
71
71
  export function isTest(envOverride) {
72
72
  return resolveEnvironment(envOverride) === "test";
73
73
  }
74
- //# sourceMappingURL=environment.constant.js.map
@@ -20,4 +20,3 @@ export declare const ENVIRONMENTS: ReadonlySet<Environment>;
20
20
  * Check whether a string is a valid Environment value.
21
21
  */
22
22
  export declare function isValidEnvironment(value: string): value is Environment;
23
- //# sourceMappingURL=environment.type.d.ts.map
@@ -21,4 +21,3 @@ export const ENVIRONMENTS = new ImmutableSet(Object.values(Environments));
21
21
  export function isValidEnvironment(value) {
22
22
  return ENVIRONMENTS.has(value);
23
23
  }
24
- //# sourceMappingURL=environment.type.js.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
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { Environments, ENVIRONMENTS, isValidEnvironment, } from "./environment.type.js";
7
7
  export { NODE_ENV_KEY, resolveEnvironment, isProduction, isDevelopment, isTest, } from "./environment.constant.js";
8
- //# sourceMappingURL=index.js.map
@@ -62,4 +62,3 @@ export declare const Charset: Readonly<{
62
62
  * provided but empty/blank.
63
63
  */
64
64
  export declare function buildContentType(mimeType: AnyContentType, charset?: string): string;
65
- //# sourceMappingURL=httpContentType.type.d.ts.map
@@ -68,4 +68,3 @@ export function buildContentType(mimeType, charset) {
68
68
  }
69
69
  return `${mimeType}; charset=${charset}`;
70
70
  }
71
- //# sourceMappingURL=httpContentType.type.js.map
@@ -44,4 +44,3 @@ export type HttpHeaderName = (typeof HttpHeader)[keyof typeof HttpHeader];
44
44
  * {@link HttpHeader} catalogue (still autocompletes the known names).
45
45
  */
46
46
  export type AnyHttpHeaderName = HttpHeaderName | (string & {});
47
- //# sourceMappingURL=httpHeader.type.d.ts.map
@@ -37,4 +37,3 @@ export const HttpHeader = Object.freeze({
37
37
  X_API_KEY: "X-Api-Key",
38
38
  X_CORRELATION_ID: "X-Correlation-Id",
39
39
  });
40
- //# sourceMappingURL=httpHeader.type.js.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
@@ -35,4 +35,3 @@ export const IDEMPOTENT_HTTP_METHODS = new ImmutableSet([
35
35
  HttpMethods.OPTIONS,
36
36
  HttpMethods.TRACE,
37
37
  ]);
38
- //# sourceMappingURL=httpMethod.type.js.map
@@ -96,4 +96,3 @@ export declare function isServerError(code: number): boolean;
96
96
  * Check whether a status code represents any error (4xx or 5xx).
97
97
  */
98
98
  export declare function isErrorStatus(code: number): boolean;
99
- //# sourceMappingURL=httpStatus.type.d.ts.map
@@ -104,4 +104,3 @@ export function isServerError(code) {
104
104
  export function isErrorStatus(code) {
105
105
  return isClientError(code) || isServerError(code);
106
106
  }
107
- //# sourceMappingURL=httpStatus.type.js.map
@@ -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
@@ -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
@@ -18,4 +18,3 @@ export * from "./cache/index.js";
18
18
  export * from "./priority/index.js";
19
19
  export * from "./constantsErrors/index.js";
20
20
  export * from "./runtime/index.js";
21
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -18,4 +18,3 @@ export * from "./cache/index.js";
18
18
  export * from "./priority/index.js";
19
19
  export * from "./constantsErrors/index.js";
20
20
  export * from "./runtime/index.js";
21
- //# sourceMappingURL=index.js.map
@@ -41,4 +41,3 @@ export declare class ImmutableSet<T> implements ReadonlySet<T> {
41
41
  /** @throws {TypeError} always — this set is immutable. */
42
42
  clear(): never;
43
43
  }
44
- //# sourceMappingURL=immutableSet.d.ts.map
@@ -68,4 +68,3 @@ export class ImmutableSet {
68
68
  }
69
69
  }
70
70
  Object.freeze(ImmutableSet.prototype);
71
- //# sourceMappingURL=immutableSet.js.map
@@ -4,4 +4,3 @@
4
4
  * @module priority
5
5
  */
6
6
  export { type Priority, Priorities, PriorityWeight, comparePriority, } from "./priority.type.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * @module priority
5
5
  */
6
6
  export { Priorities, PriorityWeight, comparePriority, } from "./priority.type.js";
7
- //# sourceMappingURL=index.js.map
@@ -31,4 +31,3 @@ export declare const PriorityWeight: Readonly<{
31
31
  * @returns Negative if a is more urgent, positive if b is more urgent, 0 if equal
32
32
  */
33
33
  export declare function comparePriority(a: Priority, b: Priority): number;
34
- //# sourceMappingURL=priority.type.d.ts.map
@@ -31,4 +31,3 @@ export const PriorityWeight = Object.freeze({
31
31
  export function comparePriority(a, b) {
32
32
  return PriorityWeight[b] - PriorityWeight[a];
33
33
  }
34
- //# sourceMappingURL=priority.type.js.map
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
- /** The randomness operations shared by {@link Random} and {@link MockRandom}. */
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
- * The richer, separately-branded `Random` in `@zudojs/types` is the
39
- * long-term owner of this contract.
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
@@ -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
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { type TimeUnit, TimeUnits } from "./time.unit.type.js";
7
7
  export { TimeMs, DefaultTimeout, DefaultRetry, toMilliseconds, formatDuration, } from "./time.constant.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { TimeUnits } from "./time.unit.type.js";
7
7
  export { TimeMs, DefaultTimeout, DefaultRetry, toMilliseconds, formatDuration, } from "./time.constant.js";
8
- //# sourceMappingURL=index.js.map
@@ -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
@@ -15,4 +15,3 @@ export declare const TimeUnits: Readonly<{
15
15
  readonly HOURS: "hours";
16
16
  readonly DAYS: "days";
17
17
  }>;
18
- //# sourceMappingURL=time.unit.type.d.ts.map
@@ -13,4 +13,3 @@ export const TimeUnits = Object.freeze({
13
13
  HOURS: "hours",
14
14
  DAYS: "days",
15
15
  });
16
- //# sourceMappingURL=time.unit.type.js.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { ValidationPattern } from "./validation.pattern.type.js";
7
7
  export { ValidationLength, ValidationRange } from "./validation.constant.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { ValidationPattern } from "./validation.pattern.type.js";
7
7
  export { ValidationLength, ValidationRange } from "./validation.constant.js";
8
- //# sourceMappingURL=index.js.map
@@ -58,4 +58,3 @@ export declare const ValidationRange: Readonly<{
58
58
  */
59
59
  readonly MAX_RETRIES: 10;
60
60
  }>;
61
- //# sourceMappingURL=validation.constant.d.ts.map
@@ -59,4 +59,3 @@ export const ValidationRange = Object.freeze({
59
59
  */
60
60
  MAX_RETRIES: Limits.MAX_RETRY_ATTEMPTS,
61
61
  });
62
- //# sourceMappingURL=validation.constant.js.map
@@ -69,4 +69,3 @@ export declare const ValidationPattern: Readonly<{
69
69
  */
70
70
  readonly FILE_NAME: RegExp;
71
71
  }>;
72
- //# sourceMappingURL=validation.pattern.type.d.ts.map
@@ -69,4 +69,3 @@ export const ValidationPattern = Object.freeze({
69
69
  */
70
70
  FILE_NAME: /^(?!\.{1,2}$)(?!(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$))(?!.*[. ]$)[^<>:"/\\|?*\x00-\x1f]+$/i,
71
71
  });
72
- //# sourceMappingURL=validation.pattern.type.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/constants",
3
- "version": "1.1.3",
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.3.1"
29
+ "@zudojs/errors": "1.4.0"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=24.0.0"