ts-procedures 10.1.2 → 10.2.1
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 +33 -86
- package/README.md +11 -6
- package/agent_config/bin/postinstall.mjs +20 -89
- package/agent_config/bin/setup.mjs +51 -264
- package/agent_config/lib/install-skills.mjs +108 -0
- package/agent_config/{claude-code/skills → skills}/ts-procedures/anti-patterns.md +8 -0
- package/agent_config/{claude-code/skills → skills}/ts-procedures/api-reference.md +25 -22
- package/agent_config/{claude-code/skills → skills}/ts-procedures/patterns.md +24 -13
- package/build/adapters/hono/envelope-parity.test.js +6 -17
- package/build/adapters/hono/envelope-parity.test.js.map +1 -1
- package/build/adapters/hono/handlers/http-stream.d.ts +2 -1
- package/build/adapters/hono/handlers/http-stream.js +9 -2
- package/build/adapters/hono/handlers/http-stream.js.map +1 -1
- package/build/adapters/hono/handlers/http.d.ts +2 -1
- package/build/adapters/hono/handlers/http.js +9 -2
- package/build/adapters/hono/handlers/http.js.map +1 -1
- package/build/adapters/hono/handlers/rpc.d.ts +2 -1
- package/build/adapters/hono/handlers/rpc.js +9 -2
- package/build/adapters/hono/handlers/rpc.js.map +1 -1
- package/build/adapters/hono/handlers/stream.d.ts +2 -1
- package/build/adapters/hono/handlers/stream.js +9 -2
- package/build/adapters/hono/handlers/stream.js.map +1 -1
- package/build/adapters/hono/index.d.ts +14 -7
- package/build/adapters/hono/index.js +45 -5
- package/build/adapters/hono/index.js.map +1 -1
- package/build/adapters/hono/index.test.js +55 -0
- package/build/adapters/hono/index.test.js.map +1 -1
- package/build/adapters/hono/request.d.ts +7 -0
- package/build/adapters/hono/request.js +15 -0
- package/build/adapters/hono/request.js.map +1 -1
- package/build/adapters/hono/types.d.ts +31 -0
- package/build/adapters/hono/types.js.map +1 -1
- package/build/codegen/bin/cli.js +1 -1
- package/build/codegen/bin/cli.js.map +1 -1
- package/build/codegen/constants.js +2 -2
- package/build/codegen/constants.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/build/core/create-http-stream.d.ts +3 -14
- package/build/core/create-http-stream.js +4 -2
- package/build/core/create-http-stream.js.map +1 -1
- package/build/core/create-http.d.ts +2 -9
- package/build/core/create-http.js +3 -2
- package/build/core/create-http.js.map +1 -1
- package/build/core/create-http.test-d.js +104 -0
- package/build/core/create-http.test-d.js.map +1 -0
- package/build/core/create-stream.js +6 -2
- package/build/core/create-stream.js.map +1 -1
- package/build/core/create.js +5 -4
- package/build/core/create.js.map +1 -1
- package/build/core/create.test.js +63 -0
- package/build/core/create.test.js.map +1 -1
- package/build/core/internal.d.ts +16 -0
- package/build/core/internal.js +22 -0
- package/build/core/internal.js.map +1 -1
- package/build/core/procedures.d.ts +9 -16
- package/build/core/procedures.js +4 -0
- package/build/core/procedures.js.map +1 -1
- package/build/core/types.d.ts +85 -4
- package/build/errors.d.ts +33 -0
- package/build/errors.js +91 -0
- package/build/errors.js.map +1 -0
- package/build/errors.test.d.ts +1 -0
- package/build/errors.test.js +122 -0
- package/build/errors.test.js.map +1 -0
- package/build/exports.d.ts +1 -2
- package/build/exports.js +0 -4
- package/build/exports.js.map +1 -1
- package/build/implementations/http/doc-registry.d.ts +28 -0
- package/build/implementations/http/doc-registry.js +96 -0
- package/build/implementations/http/doc-registry.js.map +1 -0
- package/build/implementations/http/doc-registry.test.d.ts +1 -0
- package/build/implementations/http/doc-registry.test.js +516 -0
- package/build/implementations/http/doc-registry.test.js.map +1 -0
- package/build/implementations/http/error-taxonomy.d.ts +249 -0
- package/build/implementations/http/error-taxonomy.js +252 -0
- package/build/implementations/http/error-taxonomy.js.map +1 -0
- package/build/implementations/http/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/error-taxonomy.test.js +399 -0
- package/build/implementations/http/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.js +83 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/express-rpc/index.d.ts +125 -0
- package/build/implementations/http/express-rpc/index.js +216 -0
- package/build/implementations/http/express-rpc/index.js.map +1 -0
- package/build/implementations/http/express-rpc/index.test.d.ts +1 -0
- package/build/implementations/http/express-rpc/index.test.js +684 -0
- package/build/implementations/http/express-rpc/index.test.js.map +1 -0
- package/build/implementations/http/express-rpc/types.d.ts +11 -0
- package/build/implementations/http/express-rpc/types.js +2 -0
- package/build/implementations/http/express-rpc/types.js.map +1 -0
- package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-api/error-taxonomy.test.js +137 -0
- package/build/implementations/http/hono-api/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-api/index.d.ts +151 -0
- package/build/implementations/http/hono-api/index.js +344 -0
- package/build/implementations/http/hono-api/index.js.map +1 -0
- package/build/implementations/http/hono-api/index.test.d.ts +1 -0
- package/build/implementations/http/hono-api/index.test.js +992 -0
- package/build/implementations/http/hono-api/index.test.js.map +1 -0
- package/build/implementations/http/hono-api/types.d.ts +13 -0
- package/build/implementations/http/hono-api/types.js +2 -0
- package/build/implementations/http/hono-api/types.js.map +1 -0
- package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js +64 -0
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-rpc/index.d.ts +130 -0
- package/build/implementations/http/hono-rpc/index.js +209 -0
- package/build/implementations/http/hono-rpc/index.js.map +1 -0
- package/build/implementations/http/hono-rpc/index.test.d.ts +1 -0
- package/build/implementations/http/hono-rpc/index.test.js +828 -0
- package/build/implementations/http/hono-rpc/index.test.js.map +1 -0
- package/build/implementations/http/hono-rpc/types.d.ts +11 -0
- package/build/implementations/http/hono-rpc/types.js +2 -0
- package/build/implementations/http/hono-rpc/types.js.map +1 -0
- package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-stream/error-taxonomy.test.js +159 -0
- package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-stream/index.d.ts +171 -0
- package/build/implementations/http/hono-stream/index.js +415 -0
- package/build/implementations/http/hono-stream/index.js.map +1 -0
- package/build/implementations/http/hono-stream/index.test.d.ts +1 -0
- package/build/implementations/http/hono-stream/index.test.js +1383 -0
- package/build/implementations/http/hono-stream/index.test.js.map +1 -0
- package/build/implementations/http/hono-stream/types.d.ts +15 -0
- package/build/implementations/http/hono-stream/types.js +2 -0
- package/build/implementations/http/hono-stream/types.js.map +1 -0
- package/build/implementations/http/on-request-error.test.d.ts +1 -0
- package/build/implementations/http/on-request-error.test.js +173 -0
- package/build/implementations/http/on-request-error.test.js.map +1 -0
- package/build/implementations/http/route-errors.test.d.ts +1 -0
- package/build/implementations/http/route-errors.test.js +139 -0
- package/build/implementations/http/route-errors.test.js.map +1 -0
- package/build/implementations/types.d.ts +192 -0
- package/build/implementations/types.js +2 -0
- package/build/implementations/types.js.map +1 -0
- package/build/index.d.ts +165 -0
- package/build/index.js +258 -0
- package/build/index.js.map +1 -0
- package/build/index.test.d.ts +1 -0
- package/build/index.test.js +920 -0
- package/build/index.test.js.map +1 -0
- package/build/schema/compute-schema.js +1 -5
- package/build/schema/compute-schema.js.map +1 -1
- package/build/schema/compute-schema.test.js +0 -13
- package/build/schema/compute-schema.test.js.map +1 -1
- package/build/schema/extract-json-schema.d.ts +2 -0
- package/build/schema/extract-json-schema.js +12 -0
- package/build/schema/extract-json-schema.js.map +1 -0
- package/build/schema/extract-json-schema.test.d.ts +1 -0
- package/build/schema/extract-json-schema.test.js +23 -0
- package/build/schema/extract-json-schema.test.js.map +1 -0
- package/build/schema/parser.d.ts +28 -0
- package/build/schema/parser.js +170 -0
- package/build/schema/parser.js.map +1 -0
- package/build/schema/parser.test.d.ts +1 -0
- package/build/schema/parser.test.js +120 -0
- package/build/schema/parser.test.js.map +1 -0
- package/build/schema/resolve-schema-lib.d.ts +12 -0
- package/build/schema/resolve-schema-lib.js +11 -0
- package/build/schema/resolve-schema-lib.js.map +1 -0
- package/build/schema/resolve-schema-lib.test.d.ts +1 -0
- package/build/schema/resolve-schema-lib.test.js +17 -0
- package/build/schema/resolve-schema-lib.test.js.map +1 -0
- package/build/schema/typebox.d.ts +1 -1
- package/build/schema/typebox.js +2 -20
- package/build/schema/typebox.js.map +1 -1
- package/build/schema/typebox.test.js +0 -10
- package/build/schema/typebox.test.js.map +1 -1
- package/build/schema/types.d.ts +8 -0
- package/build/schema/types.js +2 -0
- package/build/schema/types.js.map +1 -0
- package/build/server/context.d.ts +12 -2
- package/build/server/context.js +49 -4
- package/build/server/context.js.map +1 -1
- package/build/server/context.test.js +32 -1
- package/build/server/context.test.js.map +1 -1
- package/build/server/doc-registry.js +0 -3
- package/build/server/doc-registry.js.map +1 -1
- package/build/server/doc-registry.test.js +0 -31
- package/build/server/doc-registry.test.js.map +1 -1
- package/build/server/index.d.ts +0 -1
- package/build/server/index.js +0 -1
- package/build/server/index.js.map +1 -1
- package/build/server/types.d.ts +6 -27
- package/build/stack-utils.d.ts +25 -0
- package/build/stack-utils.js +95 -0
- package/build/stack-utils.js.map +1 -0
- package/build/stack-utils.test.d.ts +1 -0
- package/build/stack-utils.test.js +80 -0
- package/build/stack-utils.test.js.map +1 -0
- package/docs/ai-agent-setup.md +19 -27
- package/docs/client-error-handling.md +1 -1
- package/docs/core.md +8 -0
- package/docs/http-integrations.md +42 -28
- package/package.json +8 -8
- package/src/adapters/astro/README.md +2 -0
- package/src/adapters/hono/envelope-parity.test.ts +6 -18
- package/src/adapters/hono/handlers/http-stream.ts +12 -3
- package/src/adapters/hono/handlers/http.ts +12 -3
- package/src/adapters/hono/handlers/rpc.ts +12 -3
- package/src/adapters/hono/handlers/stream.ts +12 -3
- package/src/adapters/hono/index.test.ts +70 -0
- package/src/adapters/hono/index.ts +53 -11
- package/src/adapters/hono/request.ts +18 -0
- package/src/adapters/hono/types.ts +37 -0
- package/src/codegen/bin/cli.ts +1 -1
- package/src/codegen/constants.ts +2 -2
- package/src/codegen/emit/api-route.ts +1 -1
- package/src/codegen/emit/scope-file.ts +1 -2
- 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 +0 -1
- package/src/core/create-http-stream.ts +20 -13
- package/src/core/create-http.test-d.ts +154 -0
- package/src/core/create-http.ts +19 -8
- package/src/core/create-stream.ts +12 -4
- package/src/core/create.test.ts +74 -0
- package/src/core/create.ts +10 -5
- package/src/core/internal.ts +35 -0
- package/src/core/procedures.ts +4 -0
- package/src/core/types.ts +99 -4
- package/src/exports.ts +6 -4
- package/src/schema/compute-schema.test.ts +0 -16
- package/src/schema/compute-schema.ts +1 -5
- package/src/schema/typebox.test.ts +0 -12
- package/src/schema/typebox.ts +2 -21
- package/src/server/context.test.ts +39 -1
- package/src/server/context.ts +54 -4
- package/src/server/doc-registry.test.ts +0 -34
- package/src/server/doc-registry.ts +0 -3
- package/src/server/index.ts +0 -1
- package/src/server/types.ts +8 -27
- package/agent_config/claude-code/.claude-plugin/plugin.json +0 -5
- package/agent_config/claude-code/agents/ts-procedures-architect.md +0 -138
- package/agent_config/copilot/copilot-instructions.md +0 -521
- package/agent_config/cursor/cursorrules +0 -521
- package/agent_config/lib/install-claude.mjs +0 -57
- package/build/schema/strip-internal-keywords.d.ts +0 -18
- package/build/schema/strip-internal-keywords.js +0 -33
- package/build/schema/strip-internal-keywords.js.map +0 -1
- package/build/schema/strip-internal-keywords.test.js +0 -38
- package/build/schema/strip-internal-keywords.test.js.map +0 -1
- package/build/server/spec-version.d.ts +0 -24
- package/build/server/spec-version.js +0 -26
- package/build/server/spec-version.js.map +0 -1
- package/build/version.d.ts +0 -9
- package/build/version.js +0 -11
- package/build/version.js.map +0 -1
- package/docs/doc-envelope-spec-v1.md +0 -296
- package/docs/doc-envelope-v1.schema.json +0 -253
- package/src/schema/strip-internal-keywords.test.ts +0 -43
- package/src/schema/strip-internal-keywords.ts +0 -36
- package/src/server/spec-version.ts +0 -27
- package/src/version.ts +0 -11
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/SKILL.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/checklist.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/astro-catchall.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/client.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/hono.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/procedure.md +0 -0
- /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/stream-procedure.md +0 -0
- /package/build/{schema/strip-internal-keywords.test.d.ts → core/create-http.test-d.d.ts} +0 -0
|
@@ -5,9 +5,7 @@ import type {
|
|
|
5
5
|
THttpStreamProcedureRegistration,
|
|
6
6
|
TProcedureRegistration,
|
|
7
7
|
} from '../core/types.js'
|
|
8
|
-
import pkg from '../../package.json' with { type: 'json' }
|
|
9
8
|
import { DocRegistry } from './doc-registry.js'
|
|
10
|
-
import { DOC_ENVELOPE_SPEC_VERSION, DOC_ENVELOPE_GENERATOR_VERSION } from './spec-version.js'
|
|
11
9
|
import { defineErrorTaxonomy } from './errors/taxonomy.js'
|
|
12
10
|
import { buildRpcRouteDoc } from './docs/rpc-doc.js'
|
|
13
11
|
import { buildHttpStreamRouteDoc } from './docs/http-stream-doc.js'
|
|
@@ -203,38 +201,6 @@ describe('DocRegistry', () => {
|
|
|
203
201
|
})
|
|
204
202
|
})
|
|
205
203
|
|
|
206
|
-
// --------------------------------------------------------------------------
|
|
207
|
-
// toJSON() spec metadata
|
|
208
|
-
// --------------------------------------------------------------------------
|
|
209
|
-
describe('toJSON() spec metadata', () => {
|
|
210
|
-
test('emits specVersion (the constant, a number) and generatorVersion (the package version)', () => {
|
|
211
|
-
const out = new DocRegistry().toJSON()
|
|
212
|
-
expect(out.specVersion).toBe(DOC_ENVELOPE_SPEC_VERSION)
|
|
213
|
-
expect(typeof out.specVersion).toBe('number')
|
|
214
|
-
expect(out.generatorVersion).toBe(pkg.version)
|
|
215
|
-
// the exported constant must track the real package version
|
|
216
|
-
expect(DOC_ENVELOPE_GENERATOR_VERSION).toBe(pkg.version)
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
test('metadata is present even on an otherwise-empty envelope', () => {
|
|
220
|
-
const out = new DocRegistry({ includeDefaults: false }).toJSON()
|
|
221
|
-
expect(out).toMatchObject({
|
|
222
|
-
specVersion: DOC_ENVELOPE_SPEC_VERSION,
|
|
223
|
-
generatorVersion: pkg.version,
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
test('transform receives the metadata on its envelope argument', () => {
|
|
228
|
-
const seen = new DocRegistry().toJSON({
|
|
229
|
-
transform: ({ specVersion, generatorVersion }) => ({ specVersion, generatorVersion }),
|
|
230
|
-
})
|
|
231
|
-
expect(seen).toEqual({
|
|
232
|
-
specVersion: DOC_ENVELOPE_SPEC_VERSION,
|
|
233
|
-
generatorVersion: pkg.version,
|
|
234
|
-
})
|
|
235
|
-
})
|
|
236
|
-
})
|
|
237
|
-
|
|
238
204
|
// --------------------------------------------------------------------------
|
|
239
205
|
// toJSON() filter
|
|
240
206
|
// --------------------------------------------------------------------------
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
taxonomyToErrorDocs,
|
|
14
14
|
type ErrorTaxonomy,
|
|
15
15
|
} from './errors/taxonomy.js'
|
|
16
|
-
import { DOC_ENVELOPE_SPEC_VERSION, DOC_ENVELOPE_GENERATOR_VERSION } from './spec-version.js'
|
|
17
16
|
|
|
18
17
|
export type {
|
|
19
18
|
AnyHttpRouteDoc,
|
|
@@ -113,8 +112,6 @@ export class DocRegistry {
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
const envelope: DocEnvelope = {
|
|
116
|
-
specVersion: DOC_ENVELOPE_SPEC_VERSION,
|
|
117
|
-
generatorVersion: DOC_ENVELOPE_GENERATOR_VERSION,
|
|
118
115
|
basePath: this.basePath,
|
|
119
116
|
headers: [...this.headers],
|
|
120
117
|
errors: [...this.errors],
|
package/src/server/index.ts
CHANGED
|
@@ -25,6 +25,5 @@ export { buildStreamRouteDoc } from './docs/stream-doc.js'
|
|
|
25
25
|
export { buildHttpRouteDoc } from './docs/http-doc.js'
|
|
26
26
|
export { buildHttpStreamRouteDoc } from './docs/http-stream-doc.js'
|
|
27
27
|
export { DocRegistry } from './doc-registry.js'
|
|
28
|
-
export { DOC_ENVELOPE_SPEC_VERSION, DOC_ENVELOPE_GENERATOR_VERSION } from './spec-version.js'
|
|
29
28
|
export { writeDocEnvelope } from './doc-envelope.js'
|
|
30
29
|
export type { DocEnvelopeSource } from './doc-envelope.js'
|
package/src/server/types.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* guarantees byte-identical generated output vs v8. Do not change field names,
|
|
7
7
|
* optionality, or nesting without re-validating the codegen goldens.
|
|
8
8
|
*/
|
|
9
|
-
import type { ProcedureKind } from '../core/types.js'
|
|
9
|
+
import type { ProcedureKind, THttpReqInput } from '../core/types.js'
|
|
10
10
|
import type { ErrorTaxonomy } from './errors/taxonomy.js'
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -97,6 +97,9 @@ export interface APIHttpRouteDoc {
|
|
|
97
97
|
* Constrains `schema.req` channel names to valid HTTP input sources.
|
|
98
98
|
* Use with `satisfies` to catch typos at compile time:
|
|
99
99
|
*
|
|
100
|
+
* The same shape also powers autocomplete inside `schema.req` when using
|
|
101
|
+
* CreateHttp / CreateHttpStream.
|
|
102
|
+
*
|
|
100
103
|
* @example
|
|
101
104
|
* schema: {
|
|
102
105
|
* req: {
|
|
@@ -105,17 +108,10 @@ export interface APIHttpRouteDoc {
|
|
|
105
108
|
* } satisfies APIInput
|
|
106
109
|
* }
|
|
107
110
|
*/
|
|
108
|
-
export type APIInput<T extends
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
headers?: unknown
|
|
113
|
-
} = {
|
|
114
|
-
pathParams?: unknown
|
|
115
|
-
query?: unknown
|
|
116
|
-
body?: unknown
|
|
117
|
-
headers?: unknown
|
|
118
|
-
}> = T
|
|
111
|
+
export type APIInput<T extends THttpReqInput = THttpReqInput> = T
|
|
112
|
+
|
|
113
|
+
// Re-export the canonical input shapes (useful for advanced typing or custom wrappers)
|
|
114
|
+
export type { THttpReqInput, THttpResInput } from '../core/types.js'
|
|
119
115
|
|
|
120
116
|
export interface StreamHttpRouteDoc extends RPCConfig {
|
|
121
117
|
kind: 'stream'
|
|
@@ -250,21 +246,6 @@ export interface DocRegistryOutputOptions<TEnvelope = DocEnvelope> {
|
|
|
250
246
|
}
|
|
251
247
|
|
|
252
248
|
export interface DocEnvelope {
|
|
253
|
-
/**
|
|
254
|
-
* Wire-format version of this envelope. Every envelope produced by
|
|
255
|
-
* `DocRegistry.toJSON()` / `builder.toDocEnvelope()` carries it. Downstream
|
|
256
|
-
* consumers branch on it to pick a parser; bumped only on envelope format
|
|
257
|
-
* changes, NOT on package releases. Optional on the type so hand-built
|
|
258
|
-
* envelopes and pre-existing documents remain valid — an absent value MUST be
|
|
259
|
-
* treated as spec version 1. See {@link DOC_ENVELOPE_SPEC_VERSION}.
|
|
260
|
-
*/
|
|
261
|
-
specVersion?: number
|
|
262
|
-
/**
|
|
263
|
-
* ts-procedures package version that produced this envelope (e.g. `"10.0.0"`).
|
|
264
|
-
* Informational only — do not use for parse-compatibility decisions (use
|
|
265
|
-
* {@link specVersion} for that). See {@link DOC_ENVELOPE_GENERATOR_VERSION}.
|
|
266
|
-
*/
|
|
267
|
-
generatorVersion?: string
|
|
268
249
|
basePath: string
|
|
269
250
|
headers: HeaderDoc[]
|
|
270
251
|
errors: ErrorDoc[]
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ts-procedures",
|
|
3
|
-
"version": "9.0.0",
|
|
4
|
-
"description": "AI coding assistant plugin for ts-procedures — a TypeScript RPC framework for type-safe, schema-validated procedure calls with automatic validation, streaming support, and HTTP framework integrations."
|
|
5
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ts-procedures-architect
|
|
3
|
-
description: "Architecture planning agent for ts-procedures RPC applications. Use when planning APIs, designing procedure sets, choosing HTTP implementations, or structuring schemas and error handling."
|
|
4
|
-
model: sonnet
|
|
5
|
-
disallowedTools: Write, Edit
|
|
6
|
-
skills:
|
|
7
|
-
- ts-procedures
|
|
8
|
-
color: blue
|
|
9
|
-
effort: high
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
You are an architecture planning agent for applications built with **ts-procedures**, a TypeScript RPC framework that creates type-safe, schema-validated procedure calls. You help developers plan APIs by deciding procedure structure, schema design, context shape, and HTTP integration strategy.
|
|
13
|
-
|
|
14
|
-
The full ts-procedures framework reference is preloaded via the `ts-procedures` skill — use it for API details, schema rules, error classes, and HTTP builder specifics.
|
|
15
|
-
|
|
16
|
-
## Your Process
|
|
17
|
-
|
|
18
|
-
When asked to plan an API or procedure set:
|
|
19
|
-
|
|
20
|
-
1. **Understand the requirement** — ask clarifying questions if ambiguous
|
|
21
|
-
2. **Identify procedure groups** — which factories, what context/config types
|
|
22
|
-
3. **List procedures** — name, type (Create vs CreateStream), description
|
|
23
|
-
4. **Design schemas** — params (validated), returnType/yieldType (documented)
|
|
24
|
-
5. **Design context** — what each handler needs from the request
|
|
25
|
-
6. **Choose HTTP implementation** — `HonoAppBuilder` covers all four procedure kinds (rpc, rpc-stream, http, http-stream); pick which kinds the app needs
|
|
26
|
-
7. **Plan error handling** — which layer for each error type
|
|
27
|
-
8. **Map route structure** — scope + version for RPC routes, path + method for API routes
|
|
28
|
-
|
|
29
|
-
## Architecture Rules
|
|
30
|
-
|
|
31
|
-
- `schema.params` is validated at runtime; `schema.returnType` is documentation only.
|
|
32
|
-
- Handlers receive `(ctx, params)` where ctx includes base context + `error()` function + optional `signal`.
|
|
33
|
-
- Stream handlers always get `ctx.signal` (guaranteed `AbortSignal`). Standard handlers get it when provided by the HTTP implementation.
|
|
34
|
-
- Pass `signal` to all downstream async calls (fetch, database queries) for cancellation support.
|
|
35
|
-
- `onCreate` callback on the factory enables framework integration — use it for route registration, middleware setup, or documentation generation. Every registration carries a `kind` discriminant (`'rpc' | 'rpc-stream' | 'http' | 'http-stream'`). For a full custom server adapter, build on the transport-agnostic `ts-procedures/server` toolkit (route-doc builders, error dispatch, request channel extraction, SSE sequencing).
|
|
36
|
-
- `getProcedures()` returns all registered procedures for introspection (OpenAPI generation, testing, etc.).
|
|
37
|
-
- AJV is configured with `allErrors: true`, `coerceTypes: true`, `removeAdditional: true` — customizable per factory via `Procedures({ validation: { ajv } })`; `validation: false` skips per-call validation for trusted internal factories only.
|
|
38
|
-
- TypeBox is the built-in schema library; other libraries plug in via `Procedures({ schema: { adapters: [SchemaAdapter] } })` (runtime validation + docs only — `Infer<T>` works only for TypeBox).
|
|
39
|
-
- `Procedures({ http: { pathPrefix, scope } })` sets factory-level defaults for `CreateHttp` / `CreateHttpStream` routes (per-route values win).
|
|
40
|
-
- `schema.params` and `schema.req` are mutually exclusive — defining both throws `ProcedureRegistrationError`.
|
|
41
|
-
- Path param names in route template (`:id`) must match `schema.req.pathParams` property names.
|
|
42
|
-
- Use `DocRegistry` to compose route docs from multiple builders — never manually wire `/docs` endpoints. Pass your taxonomy directly: `new DocRegistry({ errors: appErrors })` — framework defaults are auto-merged and deduped. For errors outside your taxonomy (middleware, infrastructure, doc-only), chain `.documentError(...docs)`.
|
|
43
|
-
- Two first-class peer error-handling modes: **declarative taxonomy** (`defineErrorTaxonomy` + `errors` config) OR **imperative callback** (`onError`). Neither is deprecated. Pick the taxonomy for structured apps with typed client dispatch; pick `onError` for simple apps or full response control. Mixing both is allowed — the taxonomy handles what it covers, `onError` handles the tail. The anti-pattern is `instanceof` ladders inside `onError` (see anti-pattern #20 in the skill reference) — that's exactly what the taxonomy expresses declaratively.
|
|
44
|
-
- Per-route `errors: ['UseCaseError', ...]` narrows typed errors on the generated client. For compile-time typo protection, narrow `RPCConfig<keyof typeof appErrors & string>` on RPC factories; on `CreateHttp` routes attach `satisfies (keyof typeof appErrors & string)[]` to the `errors` array (an explicit generic would bind `TName` and break `schema.req`/`schema.res` inference).
|
|
45
|
-
- Generated `_errors.ts` emits real runtime classes extending `${Service}ProcedureError` — consumers catch with `instanceof ${Service}Errors.${Name}` and access `err.body`, `err.status`, `err.procedureName`, `err.scope`. Use the generated `create${Service}Client(config)` factory to wire the error registry automatically.
|
|
46
|
-
|
|
47
|
-
## Context Design Patterns
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
// Minimal — just auth
|
|
51
|
-
type AppContext = { userId: string }
|
|
52
|
-
|
|
53
|
-
// With services — inject dependencies
|
|
54
|
-
type AppContext = { userId: string; db: Database; logger: Logger }
|
|
55
|
-
|
|
56
|
-
// With request metadata
|
|
57
|
-
type AppContext = { userId: string; requestId: string; signal?: AbortSignal }
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Context is resolved per-request by the HTTP builder's `factoryContext` function.
|
|
61
|
-
|
|
62
|
-
## Extended Config Patterns
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
// RPC-style: scope + version (required for RPC builders)
|
|
66
|
-
interface AppConfig extends RPCConfig {
|
|
67
|
-
scope: string | string[]
|
|
68
|
-
version: number
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// REST-style: no extended config needed — path, method, scope, errors are
|
|
72
|
-
// first-class fields on the CreateHttp / CreateHttpStream config itself.
|
|
73
|
-
const API = Procedures<AppContext>()
|
|
74
|
-
API.CreateHttp('GetUser', { path: '/users/:id', method: 'get', schema: { /* req/res */ } }, handler)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Output Format
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
## API: [name]
|
|
81
|
-
|
|
82
|
-
### Procedure Groups
|
|
83
|
-
- `PublicRPC` — context: { requestId }, config: RPCConfig
|
|
84
|
-
- `AuthRPC` — context: { userId, requestId }, config: RPCConfig
|
|
85
|
-
|
|
86
|
-
### Procedures
|
|
87
|
-
|
|
88
|
-
#### PublicRPC
|
|
89
|
-
- `HealthCheck` (Create) — Returns service health status
|
|
90
|
-
- `GetPublicConfig` (Create) — Returns public configuration
|
|
91
|
-
|
|
92
|
-
#### AuthRPC
|
|
93
|
-
- `GetUser` (Create) — Fetch user by ID
|
|
94
|
-
- `UpdateUser` (Create) — Update user fields
|
|
95
|
-
- `StreamActivity` (CreateStream, SSE) — Real-time activity feed
|
|
96
|
-
|
|
97
|
-
### Schema Design
|
|
98
|
-
```typescript
|
|
99
|
-
// GetUser params
|
|
100
|
-
Type.Object({ userId: Type.String() })
|
|
101
|
-
|
|
102
|
-
// GetUser returnType
|
|
103
|
-
Type.Object({ id: Type.String(), name: Type.String(), email: Type.String() })
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Context Design
|
|
107
|
-
```typescript
|
|
108
|
-
type PublicContext = { requestId: string }
|
|
109
|
-
type AuthContext = { userId: string; requestId: string; db: Database }
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### HTTP Setup
|
|
113
|
-
- HonoAppBuilder for RPC, streams (SSE/text), and REST endpoints
|
|
114
|
-
- DocRegistry to compose docs across multiple builders (or `builder.toDocEnvelope()` for single-app)
|
|
115
|
-
- Path prefix: /api
|
|
116
|
-
|
|
117
|
-
### Route Map
|
|
118
|
-
- POST /api/health/health-check/1
|
|
119
|
-
- POST /api/users/get-user/1
|
|
120
|
-
- GET|POST /api/activity/stream-activity/1
|
|
121
|
-
- GET /api/users/:id (HonoAppBuilder)
|
|
122
|
-
- POST /api/users (HonoAppBuilder, 201)
|
|
123
|
-
- DELETE /api/users/:id (HonoAppBuilder, 204)
|
|
124
|
-
|
|
125
|
-
### Error Handling (pick a mode, optionally combine)
|
|
126
|
-
- **Declarative mode (recommended for structured apps)**: `defineErrorTaxonomy({ AuthError: {class, 401}, NotFoundError: {class, 404}, ... })` wired via `errors` config. Drives typed client dispatch + DocEnvelope.
|
|
127
|
-
- **Imperative mode (simple apps or full response control)**: `onError: (procedure, c|req/res, err) => Response|void` — first-class peer.
|
|
128
|
-
- `unknownError` — fallback serializer for errors the taxonomy doesn't cover (pairs with declarative mode).
|
|
129
|
-
- `onRequestError` — cross-cutting observer for logging/tracing/metrics. Fires for every error, before dispatch.
|
|
130
|
-
- Input validation is automatic (default taxonomy: `ProcedureValidationError` → 400).
|
|
131
|
-
- Business errors: throw typed class instances — registered taxonomy classes auto-serialize, or handle in `onError`.
|
|
132
|
-
- Per-route: declare `errors: ['AuthError', ...]` on each route config so the generated client narrows `catch` types.
|
|
133
|
-
- Stream pre-errors: both peer modes apply. Mid-stream errors: `onMidStreamError` → yield error event, close stream.
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Next Steps
|
|
137
|
-
|
|
138
|
-
After planning, use `/ts-procedures scaffold <type> <Name>` to generate each procedure with correct patterns and tests.
|