ts-procedures 9.2.0 → 10.0.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/CHANGELOG.md +25 -0
- package/build/codegen/bin/cli.js +1 -1
- package/build/codegen/bin/cli.js.map +1 -1
- package/build/codegen/emit/api-route.js +1 -1
- package/build/codegen/emit/api-route.js.map +1 -1
- package/build/codegen/emit/scope-file.js +1 -1
- package/build/codegen/emit/scope-file.js.map +1 -1
- package/build/codegen/emit-errors.integration.test.js +2 -2
- package/build/codegen/emit-errors.integration.test.js.map +1 -1
- package/build/codegen/resolve-envelope.js +1 -1
- package/build/codegen/resolve-envelope.js.map +1 -1
- package/build/codegen/test-helpers/run-tsc.js +1 -1
- package/build/codegen/test-helpers/run-tsc.js.map +1 -1
- package/package.json +8 -8
- package/src/codegen/bin/cli.ts +1 -1
- package/src/codegen/emit/api-route.ts +1 -1
- package/src/codegen/emit/scope-file.ts +2 -1
- package/src/codegen/emit-errors.integration.test.ts +2 -2
- package/src/codegen/resolve-envelope.ts +1 -1
- package/src/codegen/test-helpers/run-tsc.ts +1 -0
- package/build/errors.d.ts +0 -33
- package/build/errors.js +0 -91
- package/build/errors.js.map +0 -1
- package/build/errors.test.d.ts +0 -1
- package/build/errors.test.js +0 -122
- package/build/errors.test.js.map +0 -1
- package/build/implementations/http/doc-registry.d.ts +0 -28
- package/build/implementations/http/doc-registry.js +0 -96
- package/build/implementations/http/doc-registry.js.map +0 -1
- package/build/implementations/http/doc-registry.test.d.ts +0 -1
- package/build/implementations/http/doc-registry.test.js +0 -516
- package/build/implementations/http/doc-registry.test.js.map +0 -1
- package/build/implementations/http/error-taxonomy.d.ts +0 -249
- package/build/implementations/http/error-taxonomy.js +0 -252
- package/build/implementations/http/error-taxonomy.js.map +0 -1
- package/build/implementations/http/error-taxonomy.test.d.ts +0 -1
- package/build/implementations/http/error-taxonomy.test.js +0 -399
- package/build/implementations/http/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +0 -1
- package/build/implementations/http/express-rpc/error-taxonomy.test.js +0 -83
- package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/express-rpc/index.d.ts +0 -125
- package/build/implementations/http/express-rpc/index.js +0 -216
- package/build/implementations/http/express-rpc/index.js.map +0 -1
- package/build/implementations/http/express-rpc/index.test.d.ts +0 -1
- package/build/implementations/http/express-rpc/index.test.js +0 -684
- package/build/implementations/http/express-rpc/index.test.js.map +0 -1
- package/build/implementations/http/express-rpc/types.d.ts +0 -11
- package/build/implementations/http/express-rpc/types.js +0 -2
- package/build/implementations/http/express-rpc/types.js.map +0 -1
- package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +0 -1
- package/build/implementations/http/hono-api/error-taxonomy.test.js +0 -137
- package/build/implementations/http/hono-api/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-api/index.d.ts +0 -151
- package/build/implementations/http/hono-api/index.js +0 -344
- package/build/implementations/http/hono-api/index.js.map +0 -1
- package/build/implementations/http/hono-api/index.test.d.ts +0 -1
- package/build/implementations/http/hono-api/index.test.js +0 -992
- package/build/implementations/http/hono-api/index.test.js.map +0 -1
- package/build/implementations/http/hono-api/types.d.ts +0 -13
- package/build/implementations/http/hono-api/types.js +0 -2
- package/build/implementations/http/hono-api/types.js.map +0 -1
- package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +0 -1
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js +0 -64
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-rpc/index.d.ts +0 -130
- package/build/implementations/http/hono-rpc/index.js +0 -209
- package/build/implementations/http/hono-rpc/index.js.map +0 -1
- package/build/implementations/http/hono-rpc/index.test.d.ts +0 -1
- package/build/implementations/http/hono-rpc/index.test.js +0 -828
- package/build/implementations/http/hono-rpc/index.test.js.map +0 -1
- package/build/implementations/http/hono-rpc/types.d.ts +0 -11
- package/build/implementations/http/hono-rpc/types.js +0 -2
- package/build/implementations/http/hono-rpc/types.js.map +0 -1
- package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +0 -1
- package/build/implementations/http/hono-stream/error-taxonomy.test.js +0 -159
- package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-stream/index.d.ts +0 -171
- package/build/implementations/http/hono-stream/index.js +0 -415
- package/build/implementations/http/hono-stream/index.js.map +0 -1
- package/build/implementations/http/hono-stream/index.test.d.ts +0 -1
- package/build/implementations/http/hono-stream/index.test.js +0 -1383
- package/build/implementations/http/hono-stream/index.test.js.map +0 -1
- package/build/implementations/http/hono-stream/types.d.ts +0 -15
- package/build/implementations/http/hono-stream/types.js +0 -2
- package/build/implementations/http/hono-stream/types.js.map +0 -1
- package/build/implementations/http/on-request-error.test.d.ts +0 -1
- package/build/implementations/http/on-request-error.test.js +0 -173
- package/build/implementations/http/on-request-error.test.js.map +0 -1
- package/build/implementations/http/route-errors.test.d.ts +0 -1
- package/build/implementations/http/route-errors.test.js +0 -139
- package/build/implementations/http/route-errors.test.js.map +0 -1
- package/build/implementations/types.d.ts +0 -192
- package/build/implementations/types.js +0 -2
- package/build/implementations/types.js.map +0 -1
- package/build/index.d.ts +0 -165
- package/build/index.js +0 -258
- package/build/index.js.map +0 -1
- package/build/index.test.d.ts +0 -1
- package/build/index.test.js +0 -920
- package/build/index.test.js.map +0 -1
- package/build/schema/extract-json-schema.d.ts +0 -2
- package/build/schema/extract-json-schema.js +0 -12
- package/build/schema/extract-json-schema.js.map +0 -1
- package/build/schema/extract-json-schema.test.d.ts +0 -1
- package/build/schema/extract-json-schema.test.js +0 -23
- package/build/schema/extract-json-schema.test.js.map +0 -1
- package/build/schema/parser.d.ts +0 -28
- package/build/schema/parser.js +0 -170
- package/build/schema/parser.js.map +0 -1
- package/build/schema/parser.test.d.ts +0 -1
- package/build/schema/parser.test.js +0 -120
- package/build/schema/parser.test.js.map +0 -1
- package/build/schema/resolve-schema-lib.d.ts +0 -12
- package/build/schema/resolve-schema-lib.js +0 -11
- package/build/schema/resolve-schema-lib.js.map +0 -1
- package/build/schema/resolve-schema-lib.test.d.ts +0 -1
- package/build/schema/resolve-schema-lib.test.js +0 -17
- package/build/schema/resolve-schema-lib.test.js.map +0 -1
- package/build/schema/types.d.ts +0 -8
- package/build/schema/types.js +0 -2
- package/build/schema/types.js.map +0 -1
- package/build/stack-utils.d.ts +0 -25
- package/build/stack-utils.js +0 -95
- package/build/stack-utils.js.map +0 -1
- package/build/stack-utils.test.d.ts +0 -1
- package/build/stack-utils.test.js +0 -80
- package/build/stack-utils.test.js.map +0 -1
package/build/errors.test.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { ProcedureError, ProcedureValidationError, ProcedureRegistrationError, } from './errors.js';
|
|
3
|
-
describe('Error Classes', () => {
|
|
4
|
-
test('ProcedureError has correct properties', () => {
|
|
5
|
-
const err = new ProcedureError('TestProc', 'Something failed', { code: 123 });
|
|
6
|
-
expect(err.name).toBe('ProcedureError');
|
|
7
|
-
expect(err.procedureName).toBe('TestProc');
|
|
8
|
-
expect(err.message).toBe('Something failed');
|
|
9
|
-
expect(err.meta).toEqual({ code: 123 });
|
|
10
|
-
expect(err instanceof Error).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
test('ProcedureValidationError extends ProcedureError', () => {
|
|
13
|
-
const err = new ProcedureValidationError('TestProc', 'Validation failed', []);
|
|
14
|
-
expect(err instanceof ProcedureError).toBe(true);
|
|
15
|
-
expect(err instanceof Error).toBe(true);
|
|
16
|
-
expect(err.name).toBe('ProcedureValidationError');
|
|
17
|
-
});
|
|
18
|
-
test('ProcedureRegistrationError extends ProcedureError', () => {
|
|
19
|
-
const err = new ProcedureRegistrationError('TestProc', 'Registration failed');
|
|
20
|
-
expect(err instanceof ProcedureError).toBe(true);
|
|
21
|
-
expect(err instanceof Error).toBe(true);
|
|
22
|
-
expect(err.name).toBe('ProcedureRegistrationError');
|
|
23
|
-
expect(err.procedureName).toBe('TestProc');
|
|
24
|
-
});
|
|
25
|
-
test('ProcedureError supports cause property', () => {
|
|
26
|
-
const cause = new Error('Original error');
|
|
27
|
-
const err = new ProcedureError('TestProc', 'Wrapped error');
|
|
28
|
-
err.cause = cause;
|
|
29
|
-
expect(err.cause).toBe(cause);
|
|
30
|
-
});
|
|
31
|
-
test('All error types have consistent procedureName property', () => {
|
|
32
|
-
const baseErr = new ProcedureError('Proc1', 'message');
|
|
33
|
-
const validationErr = new ProcedureValidationError('Proc2', 'message', []);
|
|
34
|
-
const registrationErr = new ProcedureRegistrationError('Proc3', 'message');
|
|
35
|
-
expect(baseErr.procedureName).toBe('Proc1');
|
|
36
|
-
expect(validationErr.procedureName).toBe('Proc2');
|
|
37
|
-
expect(registrationErr.procedureName).toBe('Proc3');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('Error Classes - Definition Info', () => {
|
|
41
|
-
const mockDefinitionInfo = {
|
|
42
|
-
definedAt: {
|
|
43
|
-
file: '/app/procedures/user.ts',
|
|
44
|
-
line: 25,
|
|
45
|
-
column: 3,
|
|
46
|
-
raw: 'at Object.<anonymous> (/app/procedures/user.ts:25:3)',
|
|
47
|
-
},
|
|
48
|
-
definitionStack: 'Error\n at Object.<anonymous> (/app/procedures/user.ts:25:3)',
|
|
49
|
-
};
|
|
50
|
-
test('ProcedureError includes definedAt when provided', () => {
|
|
51
|
-
const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
|
|
52
|
-
expect(err.definedAt).toBeDefined();
|
|
53
|
-
expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
|
|
54
|
-
expect(err.definedAt?.line).toBe(25);
|
|
55
|
-
expect(err.definedAt?.column).toBe(3);
|
|
56
|
-
});
|
|
57
|
-
test('ProcedureError includes definitionStack when provided', () => {
|
|
58
|
-
const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
|
|
59
|
-
expect(err.definitionStack).toBeDefined();
|
|
60
|
-
expect(err.definitionStack).toContain('/app/procedures/user.ts');
|
|
61
|
-
});
|
|
62
|
-
test('ProcedureError works without definitionInfo (backward compat)', () => {
|
|
63
|
-
const err = new ProcedureError('TestProc', 'Something failed', { code: 123 });
|
|
64
|
-
expect(err.definedAt).toBeUndefined();
|
|
65
|
-
expect(err.definitionStack).toBeUndefined();
|
|
66
|
-
expect(err.procedureName).toBe('TestProc');
|
|
67
|
-
expect(err.message).toBe('Something failed');
|
|
68
|
-
expect(err.meta).toEqual({ code: 123 });
|
|
69
|
-
});
|
|
70
|
-
test('ProcedureValidationError includes definedAt when provided', () => {
|
|
71
|
-
const err = new ProcedureValidationError('TestProc', 'Validation failed', [], mockDefinitionInfo);
|
|
72
|
-
expect(err.definedAt).toBeDefined();
|
|
73
|
-
expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
|
|
74
|
-
expect(err.definedAt?.line).toBe(25);
|
|
75
|
-
});
|
|
76
|
-
test('ProcedureValidationError works without definitionInfo (backward compat)', () => {
|
|
77
|
-
const err = new ProcedureValidationError('TestProc', 'Validation failed', []);
|
|
78
|
-
expect(err.definedAt).toBeUndefined();
|
|
79
|
-
expect(err.definitionStack).toBeUndefined();
|
|
80
|
-
expect(err.name).toBe('ProcedureValidationError');
|
|
81
|
-
});
|
|
82
|
-
test('ProcedureRegistrationError includes definedAt when provided', () => {
|
|
83
|
-
const err = new ProcedureRegistrationError('TestProc', 'Registration failed', mockDefinitionInfo);
|
|
84
|
-
expect(err.definedAt).toBeDefined();
|
|
85
|
-
expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
|
|
86
|
-
});
|
|
87
|
-
test('ProcedureRegistrationError works without definitionInfo (backward compat)', () => {
|
|
88
|
-
const err = new ProcedureRegistrationError('TestProc', 'Registration failed');
|
|
89
|
-
expect(err.definedAt).toBeUndefined();
|
|
90
|
-
expect(err.definitionStack).toBeUndefined();
|
|
91
|
-
expect(err.name).toBe('ProcedureRegistrationError');
|
|
92
|
-
});
|
|
93
|
-
test('getDefinitionLocation returns formatted location string', () => {
|
|
94
|
-
const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
|
|
95
|
-
const location = err.getDefinitionLocation();
|
|
96
|
-
expect(location).toBe('/app/procedures/user.ts:25:3');
|
|
97
|
-
});
|
|
98
|
-
test('getDefinitionLocation returns undefined when no definedAt', () => {
|
|
99
|
-
const err = new ProcedureError('TestProc', 'Something failed');
|
|
100
|
-
const location = err.getDefinitionLocation();
|
|
101
|
-
expect(location).toBeUndefined();
|
|
102
|
-
});
|
|
103
|
-
test('enhanced stack contains definition location', () => {
|
|
104
|
-
const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
|
|
105
|
-
expect(err.stack).toContain('--- Procedure "TestProc" defined at ---');
|
|
106
|
-
expect(err.stack).toContain('/app/procedures/user.ts:25:3');
|
|
107
|
-
});
|
|
108
|
-
test('stack is not modified when no definitionInfo', () => {
|
|
109
|
-
const err = new ProcedureError('TestProc', 'Something failed');
|
|
110
|
-
expect(err.stack).toBeDefined();
|
|
111
|
-
expect(err.stack).not.toContain('--- Procedure');
|
|
112
|
-
});
|
|
113
|
-
test('all error types enhance stack with definition location', () => {
|
|
114
|
-
const baseErr = new ProcedureError('Proc1', 'message', undefined, mockDefinitionInfo);
|
|
115
|
-
const validationErr = new ProcedureValidationError('Proc2', 'message', [], mockDefinitionInfo);
|
|
116
|
-
const registrationErr = new ProcedureRegistrationError('Proc3', 'message', mockDefinitionInfo);
|
|
117
|
-
expect(baseErr.stack).toContain('--- Procedure "Proc1" defined at ---');
|
|
118
|
-
expect(validationErr.stack).toContain('--- Procedure "Proc2" defined at ---');
|
|
119
|
-
expect(registrationErr.stack).toContain('--- Procedure "Proc3" defined at ---');
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
//# sourceMappingURL=errors.test.js.map
|
package/build/errors.test.js.map
DELETED
|
@@ -1 +0,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CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAA;QAC7E,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAA;IACjF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AnyHttpRouteDoc, DocEnvelope, DocRegistryConfig, DocRegistryOutputOptions, DocSource, ErrorDoc } from '../types.js';
|
|
2
|
-
export type { AnyHttpRouteDoc, DocEnvelope, DocRegistryConfig, DocRegistryOutputOptions, DocSource, ErrorDoc, HeaderDoc, } from '../types.js';
|
|
3
|
-
export declare class DocRegistry {
|
|
4
|
-
private readonly basePath;
|
|
5
|
-
private readonly headers;
|
|
6
|
-
private errors;
|
|
7
|
-
private readonly sources;
|
|
8
|
-
constructor(config?: DocRegistryConfig);
|
|
9
|
-
from(source: DocSource<AnyHttpRouteDoc>): this;
|
|
10
|
-
/**
|
|
11
|
-
* Adds one or more {@link ErrorDoc} entries to the envelope. Use for errors
|
|
12
|
-
* outside your runtime taxonomy — middleware-level errors, infrastructure
|
|
13
|
-
* errors (502/503/504), or doc-only meta errors.
|
|
14
|
-
*
|
|
15
|
-
* Deduped by `name` — last write wins.
|
|
16
|
-
*/
|
|
17
|
-
documentError(...docs: ErrorDoc[]): this;
|
|
18
|
-
toJSON<T = DocEnvelope>(options?: DocRegistryOutputOptions<T>): T;
|
|
19
|
-
/**
|
|
20
|
-
* Framework error defaults — derived from {@link defaultErrorTaxonomy} plus
|
|
21
|
-
* `ProcedureRegistrationError` (which is thrown only at registration time
|
|
22
|
-
* and therefore lives in the catalog, not the runtime taxonomy).
|
|
23
|
-
*
|
|
24
|
-
* Most consumers do not need to call this directly — the `DocRegistry`
|
|
25
|
-
* constructor auto-includes these unless `includeDefaults: false` is passed.
|
|
26
|
-
*/
|
|
27
|
-
static defaultErrors(): ErrorDoc[];
|
|
28
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { PROCEDURE_REGISTRATION_ERROR_DOC, defaultErrorTaxonomy, taxonomyToErrorDocs, } from './error-taxonomy.js';
|
|
2
|
-
function isTaxonomy(input) {
|
|
3
|
-
return !Array.isArray(input);
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Dedupes ErrorDocs by `name`, last occurrence wins. Map insertion order
|
|
7
|
-
* preserves the latest position of each name.
|
|
8
|
-
*/
|
|
9
|
-
function dedupeByName(docs) {
|
|
10
|
-
const byName = new Map();
|
|
11
|
-
for (const doc of docs)
|
|
12
|
-
byName.set(doc.name, doc);
|
|
13
|
-
return Array.from(byName.values());
|
|
14
|
-
}
|
|
15
|
-
export class DocRegistry {
|
|
16
|
-
basePath;
|
|
17
|
-
headers;
|
|
18
|
-
errors;
|
|
19
|
-
sources = [];
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.basePath = config?.basePath ?? '';
|
|
22
|
-
this.headers = config?.headers ?? [];
|
|
23
|
-
const includeDefaults = config?.includeDefaults ?? true;
|
|
24
|
-
const userErrors = config?.errors
|
|
25
|
-
? isTaxonomy(config.errors)
|
|
26
|
-
? taxonomyToErrorDocs(config.errors)
|
|
27
|
-
: config.errors
|
|
28
|
-
: [];
|
|
29
|
-
// Precedence: defaults come first, user errors override via dedupe
|
|
30
|
-
// (last-write-wins). Matches runtime resolution order.
|
|
31
|
-
const merged = includeDefaults
|
|
32
|
-
? [...DocRegistry.defaultErrors(), ...userErrors]
|
|
33
|
-
: userErrors;
|
|
34
|
-
this.errors = dedupeByName(merged);
|
|
35
|
-
}
|
|
36
|
-
from(source) {
|
|
37
|
-
this.sources.push(source);
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Adds one or more {@link ErrorDoc} entries to the envelope. Use for errors
|
|
42
|
-
* outside your runtime taxonomy — middleware-level errors, infrastructure
|
|
43
|
-
* errors (502/503/504), or doc-only meta errors.
|
|
44
|
-
*
|
|
45
|
-
* Deduped by `name` — last write wins.
|
|
46
|
-
*/
|
|
47
|
-
documentError(...docs) {
|
|
48
|
-
this.errors = dedupeByName([...this.errors, ...docs]);
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
toJSON(options) {
|
|
52
|
-
let routes = this.sources.flatMap((source) => source.docs);
|
|
53
|
-
if (options?.filter) {
|
|
54
|
-
routes = routes.filter(options.filter);
|
|
55
|
-
}
|
|
56
|
-
// Surface coverage gaps — when a builder skipped procedures (e.g. a
|
|
57
|
-
// streaming procedure registered with HonoRPCAppBuilder), the per-builder
|
|
58
|
-
// warning fires once at `build()` time, but consumers who only call
|
|
59
|
-
// `registry.toJSON()` (e.g. to dump the envelope to disk for codegen)
|
|
60
|
-
// wouldn't see it without this aggregate. Single warning per call,
|
|
61
|
-
// suppressed when the env var is set so CI pipelines stay quiet.
|
|
62
|
-
if (process.env.TS_PROCEDURES_SUPPRESS_COVERAGE_WARNINGS !== '1') {
|
|
63
|
-
const skipped = this.sources.flatMap((source) => source.skippedProcedures ?? []);
|
|
64
|
-
if (skipped.length > 0) {
|
|
65
|
-
const lines = skipped.map(({ name, reason }) => ` - "${name}": ${reason}`);
|
|
66
|
-
console.warn(`[ts-procedures DocRegistry] ${skipped.length} procedure(s) registered with a builder but not served — they will be missing from the doc envelope:\n${lines.join('\n')}\n` +
|
|
67
|
-
`(Suppress with TS_PROCEDURES_SUPPRESS_COVERAGE_WARNINGS=1)`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const envelope = {
|
|
71
|
-
basePath: this.basePath,
|
|
72
|
-
headers: [...this.headers],
|
|
73
|
-
errors: [...this.errors],
|
|
74
|
-
routes,
|
|
75
|
-
};
|
|
76
|
-
if (options?.transform) {
|
|
77
|
-
return options.transform(envelope);
|
|
78
|
-
}
|
|
79
|
-
return envelope;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Framework error defaults — derived from {@link defaultErrorTaxonomy} plus
|
|
83
|
-
* `ProcedureRegistrationError` (which is thrown only at registration time
|
|
84
|
-
* and therefore lives in the catalog, not the runtime taxonomy).
|
|
85
|
-
*
|
|
86
|
-
* Most consumers do not need to call this directly — the `DocRegistry`
|
|
87
|
-
* constructor auto-includes these unless `includeDefaults: false` is passed.
|
|
88
|
-
*/
|
|
89
|
-
static defaultErrors() {
|
|
90
|
-
return [
|
|
91
|
-
...taxonomyToErrorDocs(defaultErrorTaxonomy),
|
|
92
|
-
PROCEDURE_REGISTRATION_ERROR_DOC,
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=doc-registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc-registry.js","sourceRoot":"","sources":["../../../src/implementations/http/doc-registry.ts"],"names":[],"mappings":"AASA,OAAO,EACL,gCAAgC,EAChC,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,qBAAqB,CAAA;AAY5B,SAAS,UAAU,CAAC,KAAiC;IACnD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,IAAgB;IACpC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAA;IAC1C,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACjD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,OAAO,WAAW;IACL,QAAQ,CAAQ;IAChB,OAAO,CAAa;IAC7B,MAAM,CAAY;IACT,OAAO,GAAiC,EAAE,CAAA;IAE3D,YAAY,MAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO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