@bymax-one/nest-core 1.3.0 → 1.3.2
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/CHANGELOG.md +151 -1
- package/README.md +200 -16
- package/dist/index.cjs +22 -9
- package/dist/index.d.cts +123 -3
- package/dist/index.d.ts +123 -3
- package/dist/index.mjs +22 -9
- package/dist/openapi/index.cjs +235 -12
- package/dist/openapi/index.d.cts +12 -2
- package/dist/openapi/index.d.ts +12 -2
- package/dist/openapi/index.mjs +236 -13
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -68,6 +68,44 @@ interface OpenApiServerDescriptor {
|
|
|
68
68
|
* so the consumer's declaration reaches the UI unchanged.
|
|
69
69
|
*/
|
|
70
70
|
type OpenApiSecurityScheme = Readonly<Record<string, unknown>>;
|
|
71
|
+
/**
|
|
72
|
+
* One security requirement: scheme name to the scopes it needs, empty for a
|
|
73
|
+
* scheme that takes none. An operation's requirements are alternatives — any
|
|
74
|
+
* one of them satisfies it — so an empty *array* of requirements means the
|
|
75
|
+
* operation needs no authentication at all, which is how the specification
|
|
76
|
+
* expresses a public route that overrides a document-level default.
|
|
77
|
+
*/
|
|
78
|
+
type OpenApiSecurityRequirement = Readonly<Record<string, readonly string[]>>;
|
|
79
|
+
/** The HTTP methods an OpenAPI path item can carry an operation under. */
|
|
80
|
+
type OpenApiHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE';
|
|
81
|
+
/**
|
|
82
|
+
* Addresses one operation in the generated document, as `"<METHOD> <path>"`.
|
|
83
|
+
*
|
|
84
|
+
* This format is a documented contract, not an implementation detail: a sibling
|
|
85
|
+
* library may ship a plain-data map of its own operations keyed this way, so a
|
|
86
|
+
* consumer spreads it into {@link OpenApiOptions.operationSecurity} instead of
|
|
87
|
+
* restating which of that library's routes are public. Import the type to get
|
|
88
|
+
* that map checked at the library's own compile time.
|
|
89
|
+
*
|
|
90
|
+
* The method is uppercase, one space separates the two parts, and the path is
|
|
91
|
+
* written **exactly as it appears in the generated document**: leading slash,
|
|
92
|
+
* OpenAPI template braces (`/users/{id}`), no trailing slash, and including any
|
|
93
|
+
* global prefix the application sets. That last part is the one that surprises:
|
|
94
|
+
* `@nestjs/swagger` includes `app.setGlobalPrefix('api')` in the documented
|
|
95
|
+
* paths, so the key is `'POST /api/auth/login'` in an application that sets one.
|
|
96
|
+
* A library shipping such a map should therefore expose a *function* taking the
|
|
97
|
+
* prefix rather than a frozen constant — the call site is the only place that
|
|
98
|
+
* knows it.
|
|
99
|
+
*
|
|
100
|
+
* @example 'GET /users/{id}'
|
|
101
|
+
* @example 'POST /api/auth/login'
|
|
102
|
+
*/
|
|
103
|
+
type OpenApiOperationKey = `${OpenApiHttpMethod} /${string}`;
|
|
104
|
+
/**
|
|
105
|
+
* Per-operation security requirements, keyed by {@link OpenApiOperationKey}.
|
|
106
|
+
* An empty array marks the operation public, overriding any document default.
|
|
107
|
+
*/
|
|
108
|
+
type OperationSecurityMap = Readonly<Record<OpenApiOperationKey, readonly OpenApiSecurityRequirement[]>>;
|
|
71
109
|
/**
|
|
72
110
|
* OpenAPI document configuration.
|
|
73
111
|
*
|
|
@@ -96,10 +134,53 @@ interface OpenApiOptions {
|
|
|
96
134
|
servers?: readonly OpenApiServerDescriptor[];
|
|
97
135
|
/** Security schemes added to the document's components. Default: `{}`. */
|
|
98
136
|
securitySchemes?: Readonly<Record<string, OpenApiSecurityScheme>>;
|
|
137
|
+
/**
|
|
138
|
+
* The requirement every operation carries unless it says otherwise, naming
|
|
139
|
+
* schemes declared in {@link OpenApiOptions.securitySchemes}. Default: `[]`,
|
|
140
|
+
* which documents nothing and leaves every operation as it was generated.
|
|
141
|
+
*
|
|
142
|
+
* Set this when most of the API is authenticated, and mark the exceptions
|
|
143
|
+
* public through {@link OpenApiOptions.operationSecurity}. An operation that
|
|
144
|
+
* already declares its own requirement is never overwritten.
|
|
145
|
+
*
|
|
146
|
+
* @example [{ cookieAuth: [] }]
|
|
147
|
+
*/
|
|
148
|
+
security?: readonly OpenApiSecurityRequirement[];
|
|
149
|
+
/**
|
|
150
|
+
* Per-operation overrides of {@link OpenApiOptions.security}, keyed by
|
|
151
|
+
* {@link OpenApiOperationKey}. An empty array marks that operation public.
|
|
152
|
+
* Default: `{}`.
|
|
153
|
+
*
|
|
154
|
+
* A key matching no operation in the generated document is a configuration
|
|
155
|
+
* error and fails the document build, naming the keys that do exist. Silence
|
|
156
|
+
* would be worse: a route renamed out from under a stale key would quietly
|
|
157
|
+
* inherit the document default and be documented as authenticated when it is
|
|
158
|
+
* not, or the reverse.
|
|
159
|
+
*
|
|
160
|
+
* That check runs only when the document is built. With
|
|
161
|
+
* {@link OpenApiOptions.enabled} false, or in a production runtime where the
|
|
162
|
+
* feature is forced off, a stale key is not reported — refusing to boot a
|
|
163
|
+
* service over a documentation setting it never serves would be the wrong
|
|
164
|
+
* trade. The cost is that the error waits for an environment that has the
|
|
165
|
+
* document switched on.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* {
|
|
169
|
+
* 'POST /auth/login': [],
|
|
170
|
+
* 'POST /auth/refresh': [{ refreshCookie: [] }]
|
|
171
|
+
* }
|
|
172
|
+
*/
|
|
173
|
+
operationSecurity?: OperationSecurityMap;
|
|
99
174
|
/**
|
|
100
175
|
* Contribute the schemas this package owns — the error envelope, the health
|
|
101
|
-
* response, and the pagination shapes — to the document's components
|
|
102
|
-
*
|
|
176
|
+
* response, and the pagination shapes — to the document's components, and
|
|
177
|
+
* reference them from the operations that return them: the error envelope as
|
|
178
|
+
* every operation's `default` response, and the health response on the health
|
|
179
|
+
* endpoints this package registers. Default: `true`.
|
|
180
|
+
*
|
|
181
|
+
* The two halves are one switch because they are one decision. Referencing a
|
|
182
|
+
* schema this package did not contribute would leave a dangling `$ref`, and a
|
|
183
|
+
* document that resolves nowhere is worse than one that says less.
|
|
103
184
|
*/
|
|
104
185
|
includeCoreSchemas?: boolean;
|
|
105
186
|
}
|
|
@@ -221,6 +302,8 @@ interface ResolvedOpenApiOptions {
|
|
|
221
302
|
version: string;
|
|
222
303
|
servers: readonly OpenApiServerDescriptor[];
|
|
223
304
|
securitySchemes: Readonly<Record<string, OpenApiSecurityScheme>>;
|
|
305
|
+
security: readonly OpenApiSecurityRequirement[];
|
|
306
|
+
operationSecurity: OperationSecurityMap;
|
|
224
307
|
includeCoreSchemas: boolean;
|
|
225
308
|
}
|
|
226
309
|
/**
|
|
@@ -295,6 +378,43 @@ declare class BymaxCoreModule extends BymaxCoreModuleBase {
|
|
|
295
378
|
* @fileoverview Dependency-injection tokens for `@bymax-one/nest-core`.
|
|
296
379
|
* Every token is a `Symbol`, so the container never collides with a consumer's
|
|
297
380
|
* string tokens and the public contracts stay explicit at every injection site.
|
|
381
|
+
*
|
|
382
|
+
* Every token is minted with `Symbol.for`, never `Symbol()`. This package ships
|
|
383
|
+
* one bundle per published subpath and the bundler inlines shared modules into
|
|
384
|
+
* each of them, so this file exists once per bundle at runtime: a `Symbol()`
|
|
385
|
+
* token would mint a *different* identity in `dist/index.cjs` than in
|
|
386
|
+
* `dist/openapi/index.cjs`, and a provider registered from the package root
|
|
387
|
+
* would be unreachable from a subpath that injects "the same" token. That is not
|
|
388
|
+
* hypothetical — it is the 1.3.0 defect that made `applyBymaxOpenApi` throw on
|
|
389
|
+
* every consumer boot. `Symbol.for` resolves through the runtime's global symbol
|
|
390
|
+
* registry, so all copies converge on one identity no matter how many bundles
|
|
391
|
+
* carry them. The same reasoning keeps the health marker's metadata key a
|
|
392
|
+
* literal; see `health/health.marker.ts`.
|
|
393
|
+
*
|
|
394
|
+
* The registry keys below are therefore part of the package's public contract,
|
|
395
|
+
* as binding as the export names: changing one is a breaking change even though
|
|
396
|
+
* no signature moves. They are namespaced with the full npm package name because
|
|
397
|
+
* the registry is process-global and shared with every other library in the
|
|
398
|
+
* application — the package name is the one string guaranteed not to collide.
|
|
399
|
+
*
|
|
400
|
+
* The keys carry no version, which is a deliberate choice with a consequence
|
|
401
|
+
* worth stating plainly. Every copy of this package loaded into one process
|
|
402
|
+
* shares these identities, whatever its version. Within a major that is exactly
|
|
403
|
+
* what is wanted: two resolved instances of the same major agree on what each
|
|
404
|
+
* token binds, so sharing one identity is what makes a duplicated install
|
|
405
|
+
* harmless rather than broken. Across majors it is a hazard: a consumer of one
|
|
406
|
+
* major would resolve, without complaint, a value registered by another against
|
|
407
|
+
* a contract it does not know, and fail later on an unexpected shape instead of
|
|
408
|
+
* immediately on an unresolvable token.
|
|
409
|
+
*
|
|
410
|
+
* That hazard is not specific to the options snapshot. Each token below binds
|
|
411
|
+
* its own contract — the correlation provider, the timing sink, the health
|
|
412
|
+
* indicator array, the metrics registry, the trace-context reader — and every
|
|
413
|
+
* one of them is now shared across majors by the same mechanism. So this belongs
|
|
414
|
+
* on the major-release checklist, not in a comment nobody reads at the right
|
|
415
|
+
* moment: **a major that changes the contract behind any token here must change
|
|
416
|
+
* that token's key in the same commit.** Changing a key is already a breaking
|
|
417
|
+
* change, which is precisely why a major is the only place it can happen.
|
|
298
418
|
* @layer Constants
|
|
299
419
|
*/
|
|
300
420
|
/**
|
|
@@ -787,4 +907,4 @@ declare const BYMAX_GATEWAY_TIMEOUT = "BYMAX_GATEWAY_TIMEOUT";
|
|
|
787
907
|
*/
|
|
788
908
|
declare function codeForStatus(status: number): string;
|
|
789
909
|
|
|
790
|
-
export { BYMAX_BAD_GATEWAY, BYMAX_BAD_REQUEST, BYMAX_CLIENT_ERROR, BYMAX_CONFLICT, BYMAX_CORE_OPTIONS, BYMAX_CORRELATION_PROVIDER, BYMAX_FORBIDDEN, BYMAX_GATEWAY_TIMEOUT, BYMAX_HEALTH_INDICATORS, BYMAX_INTERNAL_ERROR, BYMAX_METRICS_REGISTRY, BYMAX_NOT_FOUND, BYMAX_NOT_IMPLEMENTED, BYMAX_PAYLOAD_TOO_LARGE, BYMAX_SERVICE_UNAVAILABLE, BYMAX_TIMING_SINK, BYMAX_TOO_MANY_REQUESTS, BYMAX_TRACE_CONTEXT, BYMAX_UNAUTHORIZED, BYMAX_UNPROCESSABLE_ENTITY, BYMAX_UNSUPPORTED_MEDIA_TYPE, BYMAX_VALIDATION_FAILED, type BuildErrorEnvelopeInput, BymaxCoreModule, type BymaxCoreModuleOptions, BymaxExceptionFilter, type EnvelopeOptions, type ErrorDetails, type ErrorEnvelope, type FilterErrorContext, type HealthOptions, type ICorrelationIdProvider, type ITimingSink, type ITraceContextProvider, type MetricsOptions, type OpenApiOptions, type OpenApiSecurityScheme, type OpenApiServerDescriptor, type RequestTimingSample, type ResolvedCoreOptions, type TelemetryOptions, TimingInterceptor, type TimingOptions, type TraceContext, buildErrorEnvelope, codeForStatus };
|
|
910
|
+
export { BYMAX_BAD_GATEWAY, BYMAX_BAD_REQUEST, BYMAX_CLIENT_ERROR, BYMAX_CONFLICT, BYMAX_CORE_OPTIONS, BYMAX_CORRELATION_PROVIDER, BYMAX_FORBIDDEN, BYMAX_GATEWAY_TIMEOUT, BYMAX_HEALTH_INDICATORS, BYMAX_INTERNAL_ERROR, BYMAX_METRICS_REGISTRY, BYMAX_NOT_FOUND, BYMAX_NOT_IMPLEMENTED, BYMAX_PAYLOAD_TOO_LARGE, BYMAX_SERVICE_UNAVAILABLE, BYMAX_TIMING_SINK, BYMAX_TOO_MANY_REQUESTS, BYMAX_TRACE_CONTEXT, BYMAX_UNAUTHORIZED, BYMAX_UNPROCESSABLE_ENTITY, BYMAX_UNSUPPORTED_MEDIA_TYPE, BYMAX_VALIDATION_FAILED, type BuildErrorEnvelopeInput, BymaxCoreModule, type BymaxCoreModuleOptions, BymaxExceptionFilter, type EnvelopeOptions, type ErrorDetails, type ErrorEnvelope, type FilterErrorContext, type HealthOptions, type ICorrelationIdProvider, type ITimingSink, type ITraceContextProvider, type MetricsOptions, type OpenApiHttpMethod, type OpenApiOperationKey, type OpenApiOptions, type OpenApiSecurityRequirement, type OpenApiSecurityScheme, type OpenApiServerDescriptor, type OperationSecurityMap, type RequestTimingSample, type ResolvedCoreOptions, type TelemetryOptions, TimingInterceptor, type TimingOptions, type TraceContext, buildErrorEnvelope, codeForStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,44 @@ interface OpenApiServerDescriptor {
|
|
|
68
68
|
* so the consumer's declaration reaches the UI unchanged.
|
|
69
69
|
*/
|
|
70
70
|
type OpenApiSecurityScheme = Readonly<Record<string, unknown>>;
|
|
71
|
+
/**
|
|
72
|
+
* One security requirement: scheme name to the scopes it needs, empty for a
|
|
73
|
+
* scheme that takes none. An operation's requirements are alternatives — any
|
|
74
|
+
* one of them satisfies it — so an empty *array* of requirements means the
|
|
75
|
+
* operation needs no authentication at all, which is how the specification
|
|
76
|
+
* expresses a public route that overrides a document-level default.
|
|
77
|
+
*/
|
|
78
|
+
type OpenApiSecurityRequirement = Readonly<Record<string, readonly string[]>>;
|
|
79
|
+
/** The HTTP methods an OpenAPI path item can carry an operation under. */
|
|
80
|
+
type OpenApiHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE';
|
|
81
|
+
/**
|
|
82
|
+
* Addresses one operation in the generated document, as `"<METHOD> <path>"`.
|
|
83
|
+
*
|
|
84
|
+
* This format is a documented contract, not an implementation detail: a sibling
|
|
85
|
+
* library may ship a plain-data map of its own operations keyed this way, so a
|
|
86
|
+
* consumer spreads it into {@link OpenApiOptions.operationSecurity} instead of
|
|
87
|
+
* restating which of that library's routes are public. Import the type to get
|
|
88
|
+
* that map checked at the library's own compile time.
|
|
89
|
+
*
|
|
90
|
+
* The method is uppercase, one space separates the two parts, and the path is
|
|
91
|
+
* written **exactly as it appears in the generated document**: leading slash,
|
|
92
|
+
* OpenAPI template braces (`/users/{id}`), no trailing slash, and including any
|
|
93
|
+
* global prefix the application sets. That last part is the one that surprises:
|
|
94
|
+
* `@nestjs/swagger` includes `app.setGlobalPrefix('api')` in the documented
|
|
95
|
+
* paths, so the key is `'POST /api/auth/login'` in an application that sets one.
|
|
96
|
+
* A library shipping such a map should therefore expose a *function* taking the
|
|
97
|
+
* prefix rather than a frozen constant — the call site is the only place that
|
|
98
|
+
* knows it.
|
|
99
|
+
*
|
|
100
|
+
* @example 'GET /users/{id}'
|
|
101
|
+
* @example 'POST /api/auth/login'
|
|
102
|
+
*/
|
|
103
|
+
type OpenApiOperationKey = `${OpenApiHttpMethod} /${string}`;
|
|
104
|
+
/**
|
|
105
|
+
* Per-operation security requirements, keyed by {@link OpenApiOperationKey}.
|
|
106
|
+
* An empty array marks the operation public, overriding any document default.
|
|
107
|
+
*/
|
|
108
|
+
type OperationSecurityMap = Readonly<Record<OpenApiOperationKey, readonly OpenApiSecurityRequirement[]>>;
|
|
71
109
|
/**
|
|
72
110
|
* OpenAPI document configuration.
|
|
73
111
|
*
|
|
@@ -96,10 +134,53 @@ interface OpenApiOptions {
|
|
|
96
134
|
servers?: readonly OpenApiServerDescriptor[];
|
|
97
135
|
/** Security schemes added to the document's components. Default: `{}`. */
|
|
98
136
|
securitySchemes?: Readonly<Record<string, OpenApiSecurityScheme>>;
|
|
137
|
+
/**
|
|
138
|
+
* The requirement every operation carries unless it says otherwise, naming
|
|
139
|
+
* schemes declared in {@link OpenApiOptions.securitySchemes}. Default: `[]`,
|
|
140
|
+
* which documents nothing and leaves every operation as it was generated.
|
|
141
|
+
*
|
|
142
|
+
* Set this when most of the API is authenticated, and mark the exceptions
|
|
143
|
+
* public through {@link OpenApiOptions.operationSecurity}. An operation that
|
|
144
|
+
* already declares its own requirement is never overwritten.
|
|
145
|
+
*
|
|
146
|
+
* @example [{ cookieAuth: [] }]
|
|
147
|
+
*/
|
|
148
|
+
security?: readonly OpenApiSecurityRequirement[];
|
|
149
|
+
/**
|
|
150
|
+
* Per-operation overrides of {@link OpenApiOptions.security}, keyed by
|
|
151
|
+
* {@link OpenApiOperationKey}. An empty array marks that operation public.
|
|
152
|
+
* Default: `{}`.
|
|
153
|
+
*
|
|
154
|
+
* A key matching no operation in the generated document is a configuration
|
|
155
|
+
* error and fails the document build, naming the keys that do exist. Silence
|
|
156
|
+
* would be worse: a route renamed out from under a stale key would quietly
|
|
157
|
+
* inherit the document default and be documented as authenticated when it is
|
|
158
|
+
* not, or the reverse.
|
|
159
|
+
*
|
|
160
|
+
* That check runs only when the document is built. With
|
|
161
|
+
* {@link OpenApiOptions.enabled} false, or in a production runtime where the
|
|
162
|
+
* feature is forced off, a stale key is not reported — refusing to boot a
|
|
163
|
+
* service over a documentation setting it never serves would be the wrong
|
|
164
|
+
* trade. The cost is that the error waits for an environment that has the
|
|
165
|
+
* document switched on.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* {
|
|
169
|
+
* 'POST /auth/login': [],
|
|
170
|
+
* 'POST /auth/refresh': [{ refreshCookie: [] }]
|
|
171
|
+
* }
|
|
172
|
+
*/
|
|
173
|
+
operationSecurity?: OperationSecurityMap;
|
|
99
174
|
/**
|
|
100
175
|
* Contribute the schemas this package owns — the error envelope, the health
|
|
101
|
-
* response, and the pagination shapes — to the document's components
|
|
102
|
-
*
|
|
176
|
+
* response, and the pagination shapes — to the document's components, and
|
|
177
|
+
* reference them from the operations that return them: the error envelope as
|
|
178
|
+
* every operation's `default` response, and the health response on the health
|
|
179
|
+
* endpoints this package registers. Default: `true`.
|
|
180
|
+
*
|
|
181
|
+
* The two halves are one switch because they are one decision. Referencing a
|
|
182
|
+
* schema this package did not contribute would leave a dangling `$ref`, and a
|
|
183
|
+
* document that resolves nowhere is worse than one that says less.
|
|
103
184
|
*/
|
|
104
185
|
includeCoreSchemas?: boolean;
|
|
105
186
|
}
|
|
@@ -221,6 +302,8 @@ interface ResolvedOpenApiOptions {
|
|
|
221
302
|
version: string;
|
|
222
303
|
servers: readonly OpenApiServerDescriptor[];
|
|
223
304
|
securitySchemes: Readonly<Record<string, OpenApiSecurityScheme>>;
|
|
305
|
+
security: readonly OpenApiSecurityRequirement[];
|
|
306
|
+
operationSecurity: OperationSecurityMap;
|
|
224
307
|
includeCoreSchemas: boolean;
|
|
225
308
|
}
|
|
226
309
|
/**
|
|
@@ -295,6 +378,43 @@ declare class BymaxCoreModule extends BymaxCoreModuleBase {
|
|
|
295
378
|
* @fileoverview Dependency-injection tokens for `@bymax-one/nest-core`.
|
|
296
379
|
* Every token is a `Symbol`, so the container never collides with a consumer's
|
|
297
380
|
* string tokens and the public contracts stay explicit at every injection site.
|
|
381
|
+
*
|
|
382
|
+
* Every token is minted with `Symbol.for`, never `Symbol()`. This package ships
|
|
383
|
+
* one bundle per published subpath and the bundler inlines shared modules into
|
|
384
|
+
* each of them, so this file exists once per bundle at runtime: a `Symbol()`
|
|
385
|
+
* token would mint a *different* identity in `dist/index.cjs` than in
|
|
386
|
+
* `dist/openapi/index.cjs`, and a provider registered from the package root
|
|
387
|
+
* would be unreachable from a subpath that injects "the same" token. That is not
|
|
388
|
+
* hypothetical — it is the 1.3.0 defect that made `applyBymaxOpenApi` throw on
|
|
389
|
+
* every consumer boot. `Symbol.for` resolves through the runtime's global symbol
|
|
390
|
+
* registry, so all copies converge on one identity no matter how many bundles
|
|
391
|
+
* carry them. The same reasoning keeps the health marker's metadata key a
|
|
392
|
+
* literal; see `health/health.marker.ts`.
|
|
393
|
+
*
|
|
394
|
+
* The registry keys below are therefore part of the package's public contract,
|
|
395
|
+
* as binding as the export names: changing one is a breaking change even though
|
|
396
|
+
* no signature moves. They are namespaced with the full npm package name because
|
|
397
|
+
* the registry is process-global and shared with every other library in the
|
|
398
|
+
* application — the package name is the one string guaranteed not to collide.
|
|
399
|
+
*
|
|
400
|
+
* The keys carry no version, which is a deliberate choice with a consequence
|
|
401
|
+
* worth stating plainly. Every copy of this package loaded into one process
|
|
402
|
+
* shares these identities, whatever its version. Within a major that is exactly
|
|
403
|
+
* what is wanted: two resolved instances of the same major agree on what each
|
|
404
|
+
* token binds, so sharing one identity is what makes a duplicated install
|
|
405
|
+
* harmless rather than broken. Across majors it is a hazard: a consumer of one
|
|
406
|
+
* major would resolve, without complaint, a value registered by another against
|
|
407
|
+
* a contract it does not know, and fail later on an unexpected shape instead of
|
|
408
|
+
* immediately on an unresolvable token.
|
|
409
|
+
*
|
|
410
|
+
* That hazard is not specific to the options snapshot. Each token below binds
|
|
411
|
+
* its own contract — the correlation provider, the timing sink, the health
|
|
412
|
+
* indicator array, the metrics registry, the trace-context reader — and every
|
|
413
|
+
* one of them is now shared across majors by the same mechanism. So this belongs
|
|
414
|
+
* on the major-release checklist, not in a comment nobody reads at the right
|
|
415
|
+
* moment: **a major that changes the contract behind any token here must change
|
|
416
|
+
* that token's key in the same commit.** Changing a key is already a breaking
|
|
417
|
+
* change, which is precisely why a major is the only place it can happen.
|
|
298
418
|
* @layer Constants
|
|
299
419
|
*/
|
|
300
420
|
/**
|
|
@@ -787,4 +907,4 @@ declare const BYMAX_GATEWAY_TIMEOUT = "BYMAX_GATEWAY_TIMEOUT";
|
|
|
787
907
|
*/
|
|
788
908
|
declare function codeForStatus(status: number): string;
|
|
789
909
|
|
|
790
|
-
export { BYMAX_BAD_GATEWAY, BYMAX_BAD_REQUEST, BYMAX_CLIENT_ERROR, BYMAX_CONFLICT, BYMAX_CORE_OPTIONS, BYMAX_CORRELATION_PROVIDER, BYMAX_FORBIDDEN, BYMAX_GATEWAY_TIMEOUT, BYMAX_HEALTH_INDICATORS, BYMAX_INTERNAL_ERROR, BYMAX_METRICS_REGISTRY, BYMAX_NOT_FOUND, BYMAX_NOT_IMPLEMENTED, BYMAX_PAYLOAD_TOO_LARGE, BYMAX_SERVICE_UNAVAILABLE, BYMAX_TIMING_SINK, BYMAX_TOO_MANY_REQUESTS, BYMAX_TRACE_CONTEXT, BYMAX_UNAUTHORIZED, BYMAX_UNPROCESSABLE_ENTITY, BYMAX_UNSUPPORTED_MEDIA_TYPE, BYMAX_VALIDATION_FAILED, type BuildErrorEnvelopeInput, BymaxCoreModule, type BymaxCoreModuleOptions, BymaxExceptionFilter, type EnvelopeOptions, type ErrorDetails, type ErrorEnvelope, type FilterErrorContext, type HealthOptions, type ICorrelationIdProvider, type ITimingSink, type ITraceContextProvider, type MetricsOptions, type OpenApiOptions, type OpenApiSecurityScheme, type OpenApiServerDescriptor, type RequestTimingSample, type ResolvedCoreOptions, type TelemetryOptions, TimingInterceptor, type TimingOptions, type TraceContext, buildErrorEnvelope, codeForStatus };
|
|
910
|
+
export { BYMAX_BAD_GATEWAY, BYMAX_BAD_REQUEST, BYMAX_CLIENT_ERROR, BYMAX_CONFLICT, BYMAX_CORE_OPTIONS, BYMAX_CORRELATION_PROVIDER, BYMAX_FORBIDDEN, BYMAX_GATEWAY_TIMEOUT, BYMAX_HEALTH_INDICATORS, BYMAX_INTERNAL_ERROR, BYMAX_METRICS_REGISTRY, BYMAX_NOT_FOUND, BYMAX_NOT_IMPLEMENTED, BYMAX_PAYLOAD_TOO_LARGE, BYMAX_SERVICE_UNAVAILABLE, BYMAX_TIMING_SINK, BYMAX_TOO_MANY_REQUESTS, BYMAX_TRACE_CONTEXT, BYMAX_UNAUTHORIZED, BYMAX_UNPROCESSABLE_ENTITY, BYMAX_UNSUPPORTED_MEDIA_TYPE, BYMAX_VALIDATION_FAILED, type BuildErrorEnvelopeInput, BymaxCoreModule, type BymaxCoreModuleOptions, BymaxExceptionFilter, type EnvelopeOptions, type ErrorDetails, type ErrorEnvelope, type FilterErrorContext, type HealthOptions, type ICorrelationIdProvider, type ITimingSink, type ITraceContextProvider, type MetricsOptions, type OpenApiHttpMethod, type OpenApiOperationKey, type OpenApiOptions, type OpenApiSecurityRequirement, type OpenApiSecurityScheme, type OpenApiServerDescriptor, type OperationSecurityMap, type RequestTimingSample, type ResolvedCoreOptions, type TelemetryOptions, TimingInterceptor, type TimingOptions, type TraceContext, buildErrorEnvelope, codeForStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,10 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
17
17
|
|
|
18
|
+
// src/route-defaults.ts
|
|
19
|
+
var DEFAULT_HEALTH_PATH = "health";
|
|
20
|
+
var DEFAULT_METRICS_PATH = "metrics";
|
|
21
|
+
|
|
18
22
|
// src/runtime.environment.ts
|
|
19
23
|
var NON_PRODUCTION_ENVIRONMENTS = /* @__PURE__ */ new Set(["development", "test"]);
|
|
20
24
|
function isProductionRuntime(value = process.env["NODE_ENV"]) {
|
|
@@ -25,9 +29,7 @@ function isProductionRuntime(value = process.env["NODE_ENV"]) {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
// src/core.options.ts
|
|
28
|
-
var DEFAULT_HEALTH_PATH = "health";
|
|
29
32
|
var DEFAULT_INDICATOR_TIMEOUT_MS = 5e3;
|
|
30
|
-
var DEFAULT_METRICS_PATH = "metrics";
|
|
31
33
|
var DEFAULT_OPENAPI_PATH = "docs";
|
|
32
34
|
var DEFAULT_OPENAPI_JSON_PATH = "docs-json";
|
|
33
35
|
var DEFAULT_OPENAPI_TITLE = "API";
|
|
@@ -103,6 +105,11 @@ function resolveOpenApi(raw) {
|
|
|
103
105
|
// consumer-owned nested objects, and the deep-freeze below would otherwise
|
|
104
106
|
// reach into them.
|
|
105
107
|
securitySchemes: structuredClone(raw?.securitySchemes ?? {}),
|
|
108
|
+
// Cloned for the same reason as the schemes above: both are consumer-owned
|
|
109
|
+
// nested structures, and the deep-freeze applied to the snapshot would
|
|
110
|
+
// otherwise reach into objects the consumer still holds a reference to.
|
|
111
|
+
security: structuredClone(raw?.security ?? []),
|
|
112
|
+
operationSecurity: structuredClone(raw?.operationSecurity ?? {}),
|
|
106
113
|
includeCoreSchemas: raw?.includeCoreSchemas ?? true
|
|
107
114
|
};
|
|
108
115
|
}
|
|
@@ -125,12 +132,18 @@ function normalizeCoreOptions(raw) {
|
|
|
125
132
|
normalizeCoreOptions();
|
|
126
133
|
|
|
127
134
|
// src/core.tokens.ts
|
|
128
|
-
var BYMAX_CORE_OPTIONS = /* @__PURE__ */ Symbol("
|
|
129
|
-
var BYMAX_CORRELATION_PROVIDER = /* @__PURE__ */ Symbol(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var
|
|
133
|
-
var
|
|
135
|
+
var BYMAX_CORE_OPTIONS = /* @__PURE__ */ Symbol.for("@bymax-one/nest-core:core-options");
|
|
136
|
+
var BYMAX_CORRELATION_PROVIDER = /* @__PURE__ */ Symbol.for(
|
|
137
|
+
"@bymax-one/nest-core:correlation-provider"
|
|
138
|
+
);
|
|
139
|
+
var BYMAX_TIMING_SINK = /* @__PURE__ */ Symbol.for("@bymax-one/nest-core:timing-sink");
|
|
140
|
+
var BYMAX_HEALTH_INDICATORS = /* @__PURE__ */ Symbol.for(
|
|
141
|
+
"@bymax-one/nest-core:health-indicators"
|
|
142
|
+
);
|
|
143
|
+
var BYMAX_METRICS_REGISTRY = /* @__PURE__ */ Symbol.for(
|
|
144
|
+
"@bymax-one/nest-core:metrics-registry"
|
|
145
|
+
);
|
|
146
|
+
var BYMAX_TRACE_CONTEXT = /* @__PURE__ */ Symbol.for("@bymax-one/nest-core:trace-context");
|
|
134
147
|
|
|
135
148
|
// src/optional-peer.ts
|
|
136
149
|
function isMissingModuleError(cause) {
|
|
@@ -199,7 +212,7 @@ async function resolveTraceContextProvider(options) {
|
|
|
199
212
|
var DEFAULT_MONOTONIC_CLOCK = {
|
|
200
213
|
now: () => performance.now()
|
|
201
214
|
};
|
|
202
|
-
var BYMAX_TIMING_CLOCK = /* @__PURE__ */ Symbol("
|
|
215
|
+
var BYMAX_TIMING_CLOCK = /* @__PURE__ */ Symbol.for("@bymax-one/nest-core:timing-clock");
|
|
203
216
|
|
|
204
217
|
// src/defaults.providers.ts
|
|
205
218
|
var NoopCorrelationIdProvider = class {
|