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.
Files changed (272) hide show
  1. package/CHANGELOG.md +33 -86
  2. package/README.md +11 -6
  3. package/agent_config/bin/postinstall.mjs +20 -89
  4. package/agent_config/bin/setup.mjs +51 -264
  5. package/agent_config/lib/install-skills.mjs +108 -0
  6. package/agent_config/{claude-code/skills → skills}/ts-procedures/anti-patterns.md +8 -0
  7. package/agent_config/{claude-code/skills → skills}/ts-procedures/api-reference.md +25 -22
  8. package/agent_config/{claude-code/skills → skills}/ts-procedures/patterns.md +24 -13
  9. package/build/adapters/hono/envelope-parity.test.js +6 -17
  10. package/build/adapters/hono/envelope-parity.test.js.map +1 -1
  11. package/build/adapters/hono/handlers/http-stream.d.ts +2 -1
  12. package/build/adapters/hono/handlers/http-stream.js +9 -2
  13. package/build/adapters/hono/handlers/http-stream.js.map +1 -1
  14. package/build/adapters/hono/handlers/http.d.ts +2 -1
  15. package/build/adapters/hono/handlers/http.js +9 -2
  16. package/build/adapters/hono/handlers/http.js.map +1 -1
  17. package/build/adapters/hono/handlers/rpc.d.ts +2 -1
  18. package/build/adapters/hono/handlers/rpc.js +9 -2
  19. package/build/adapters/hono/handlers/rpc.js.map +1 -1
  20. package/build/adapters/hono/handlers/stream.d.ts +2 -1
  21. package/build/adapters/hono/handlers/stream.js +9 -2
  22. package/build/adapters/hono/handlers/stream.js.map +1 -1
  23. package/build/adapters/hono/index.d.ts +14 -7
  24. package/build/adapters/hono/index.js +45 -5
  25. package/build/adapters/hono/index.js.map +1 -1
  26. package/build/adapters/hono/index.test.js +55 -0
  27. package/build/adapters/hono/index.test.js.map +1 -1
  28. package/build/adapters/hono/request.d.ts +7 -0
  29. package/build/adapters/hono/request.js +15 -0
  30. package/build/adapters/hono/request.js.map +1 -1
  31. package/build/adapters/hono/types.d.ts +31 -0
  32. package/build/adapters/hono/types.js.map +1 -1
  33. package/build/codegen/bin/cli.js +1 -1
  34. package/build/codegen/bin/cli.js.map +1 -1
  35. package/build/codegen/constants.js +2 -2
  36. package/build/codegen/constants.js.map +1 -1
  37. package/build/codegen/emit/api-route.js +1 -1
  38. package/build/codegen/emit/api-route.js.map +1 -1
  39. package/build/codegen/emit/scope-file.js +1 -1
  40. package/build/codegen/emit/scope-file.js.map +1 -1
  41. package/build/codegen/emit-errors.integration.test.js +2 -2
  42. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  43. package/build/codegen/resolve-envelope.js +1 -1
  44. package/build/codegen/resolve-envelope.js.map +1 -1
  45. package/build/codegen/test-helpers/run-tsc.js +1 -1
  46. package/build/codegen/test-helpers/run-tsc.js.map +1 -1
  47. package/build/core/create-http-stream.d.ts +3 -14
  48. package/build/core/create-http-stream.js +4 -2
  49. package/build/core/create-http-stream.js.map +1 -1
  50. package/build/core/create-http.d.ts +2 -9
  51. package/build/core/create-http.js +3 -2
  52. package/build/core/create-http.js.map +1 -1
  53. package/build/core/create-http.test-d.js +104 -0
  54. package/build/core/create-http.test-d.js.map +1 -0
  55. package/build/core/create-stream.js +6 -2
  56. package/build/core/create-stream.js.map +1 -1
  57. package/build/core/create.js +5 -4
  58. package/build/core/create.js.map +1 -1
  59. package/build/core/create.test.js +63 -0
  60. package/build/core/create.test.js.map +1 -1
  61. package/build/core/internal.d.ts +16 -0
  62. package/build/core/internal.js +22 -0
  63. package/build/core/internal.js.map +1 -1
  64. package/build/core/procedures.d.ts +9 -16
  65. package/build/core/procedures.js +4 -0
  66. package/build/core/procedures.js.map +1 -1
  67. package/build/core/types.d.ts +85 -4
  68. package/build/errors.d.ts +33 -0
  69. package/build/errors.js +91 -0
  70. package/build/errors.js.map +1 -0
  71. package/build/errors.test.d.ts +1 -0
  72. package/build/errors.test.js +122 -0
  73. package/build/errors.test.js.map +1 -0
  74. package/build/exports.d.ts +1 -2
  75. package/build/exports.js +0 -4
  76. package/build/exports.js.map +1 -1
  77. package/build/implementations/http/doc-registry.d.ts +28 -0
  78. package/build/implementations/http/doc-registry.js +96 -0
  79. package/build/implementations/http/doc-registry.js.map +1 -0
  80. package/build/implementations/http/doc-registry.test.d.ts +1 -0
  81. package/build/implementations/http/doc-registry.test.js +516 -0
  82. package/build/implementations/http/doc-registry.test.js.map +1 -0
  83. package/build/implementations/http/error-taxonomy.d.ts +249 -0
  84. package/build/implementations/http/error-taxonomy.js +252 -0
  85. package/build/implementations/http/error-taxonomy.js.map +1 -0
  86. package/build/implementations/http/error-taxonomy.test.d.ts +1 -0
  87. package/build/implementations/http/error-taxonomy.test.js +399 -0
  88. package/build/implementations/http/error-taxonomy.test.js.map +1 -0
  89. package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +1 -0
  90. package/build/implementations/http/express-rpc/error-taxonomy.test.js +83 -0
  91. package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +1 -0
  92. package/build/implementations/http/express-rpc/index.d.ts +125 -0
  93. package/build/implementations/http/express-rpc/index.js +216 -0
  94. package/build/implementations/http/express-rpc/index.js.map +1 -0
  95. package/build/implementations/http/express-rpc/index.test.d.ts +1 -0
  96. package/build/implementations/http/express-rpc/index.test.js +684 -0
  97. package/build/implementations/http/express-rpc/index.test.js.map +1 -0
  98. package/build/implementations/http/express-rpc/types.d.ts +11 -0
  99. package/build/implementations/http/express-rpc/types.js +2 -0
  100. package/build/implementations/http/express-rpc/types.js.map +1 -0
  101. package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +1 -0
  102. package/build/implementations/http/hono-api/error-taxonomy.test.js +137 -0
  103. package/build/implementations/http/hono-api/error-taxonomy.test.js.map +1 -0
  104. package/build/implementations/http/hono-api/index.d.ts +151 -0
  105. package/build/implementations/http/hono-api/index.js +344 -0
  106. package/build/implementations/http/hono-api/index.js.map +1 -0
  107. package/build/implementations/http/hono-api/index.test.d.ts +1 -0
  108. package/build/implementations/http/hono-api/index.test.js +992 -0
  109. package/build/implementations/http/hono-api/index.test.js.map +1 -0
  110. package/build/implementations/http/hono-api/types.d.ts +13 -0
  111. package/build/implementations/http/hono-api/types.js +2 -0
  112. package/build/implementations/http/hono-api/types.js.map +1 -0
  113. package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +1 -0
  114. package/build/implementations/http/hono-rpc/error-taxonomy.test.js +64 -0
  115. package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +1 -0
  116. package/build/implementations/http/hono-rpc/index.d.ts +130 -0
  117. package/build/implementations/http/hono-rpc/index.js +209 -0
  118. package/build/implementations/http/hono-rpc/index.js.map +1 -0
  119. package/build/implementations/http/hono-rpc/index.test.d.ts +1 -0
  120. package/build/implementations/http/hono-rpc/index.test.js +828 -0
  121. package/build/implementations/http/hono-rpc/index.test.js.map +1 -0
  122. package/build/implementations/http/hono-rpc/types.d.ts +11 -0
  123. package/build/implementations/http/hono-rpc/types.js +2 -0
  124. package/build/implementations/http/hono-rpc/types.js.map +1 -0
  125. package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +1 -0
  126. package/build/implementations/http/hono-stream/error-taxonomy.test.js +159 -0
  127. package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +1 -0
  128. package/build/implementations/http/hono-stream/index.d.ts +171 -0
  129. package/build/implementations/http/hono-stream/index.js +415 -0
  130. package/build/implementations/http/hono-stream/index.js.map +1 -0
  131. package/build/implementations/http/hono-stream/index.test.d.ts +1 -0
  132. package/build/implementations/http/hono-stream/index.test.js +1383 -0
  133. package/build/implementations/http/hono-stream/index.test.js.map +1 -0
  134. package/build/implementations/http/hono-stream/types.d.ts +15 -0
  135. package/build/implementations/http/hono-stream/types.js +2 -0
  136. package/build/implementations/http/hono-stream/types.js.map +1 -0
  137. package/build/implementations/http/on-request-error.test.d.ts +1 -0
  138. package/build/implementations/http/on-request-error.test.js +173 -0
  139. package/build/implementations/http/on-request-error.test.js.map +1 -0
  140. package/build/implementations/http/route-errors.test.d.ts +1 -0
  141. package/build/implementations/http/route-errors.test.js +139 -0
  142. package/build/implementations/http/route-errors.test.js.map +1 -0
  143. package/build/implementations/types.d.ts +192 -0
  144. package/build/implementations/types.js +2 -0
  145. package/build/implementations/types.js.map +1 -0
  146. package/build/index.d.ts +165 -0
  147. package/build/index.js +258 -0
  148. package/build/index.js.map +1 -0
  149. package/build/index.test.d.ts +1 -0
  150. package/build/index.test.js +920 -0
  151. package/build/index.test.js.map +1 -0
  152. package/build/schema/compute-schema.js +1 -5
  153. package/build/schema/compute-schema.js.map +1 -1
  154. package/build/schema/compute-schema.test.js +0 -13
  155. package/build/schema/compute-schema.test.js.map +1 -1
  156. package/build/schema/extract-json-schema.d.ts +2 -0
  157. package/build/schema/extract-json-schema.js +12 -0
  158. package/build/schema/extract-json-schema.js.map +1 -0
  159. package/build/schema/extract-json-schema.test.d.ts +1 -0
  160. package/build/schema/extract-json-schema.test.js +23 -0
  161. package/build/schema/extract-json-schema.test.js.map +1 -0
  162. package/build/schema/parser.d.ts +28 -0
  163. package/build/schema/parser.js +170 -0
  164. package/build/schema/parser.js.map +1 -0
  165. package/build/schema/parser.test.d.ts +1 -0
  166. package/build/schema/parser.test.js +120 -0
  167. package/build/schema/parser.test.js.map +1 -0
  168. package/build/schema/resolve-schema-lib.d.ts +12 -0
  169. package/build/schema/resolve-schema-lib.js +11 -0
  170. package/build/schema/resolve-schema-lib.js.map +1 -0
  171. package/build/schema/resolve-schema-lib.test.d.ts +1 -0
  172. package/build/schema/resolve-schema-lib.test.js +17 -0
  173. package/build/schema/resolve-schema-lib.test.js.map +1 -0
  174. package/build/schema/typebox.d.ts +1 -1
  175. package/build/schema/typebox.js +2 -20
  176. package/build/schema/typebox.js.map +1 -1
  177. package/build/schema/typebox.test.js +0 -10
  178. package/build/schema/typebox.test.js.map +1 -1
  179. package/build/schema/types.d.ts +8 -0
  180. package/build/schema/types.js +2 -0
  181. package/build/schema/types.js.map +1 -0
  182. package/build/server/context.d.ts +12 -2
  183. package/build/server/context.js +49 -4
  184. package/build/server/context.js.map +1 -1
  185. package/build/server/context.test.js +32 -1
  186. package/build/server/context.test.js.map +1 -1
  187. package/build/server/doc-registry.js +0 -3
  188. package/build/server/doc-registry.js.map +1 -1
  189. package/build/server/doc-registry.test.js +0 -31
  190. package/build/server/doc-registry.test.js.map +1 -1
  191. package/build/server/index.d.ts +0 -1
  192. package/build/server/index.js +0 -1
  193. package/build/server/index.js.map +1 -1
  194. package/build/server/types.d.ts +6 -27
  195. package/build/stack-utils.d.ts +25 -0
  196. package/build/stack-utils.js +95 -0
  197. package/build/stack-utils.js.map +1 -0
  198. package/build/stack-utils.test.d.ts +1 -0
  199. package/build/stack-utils.test.js +80 -0
  200. package/build/stack-utils.test.js.map +1 -0
  201. package/docs/ai-agent-setup.md +19 -27
  202. package/docs/client-error-handling.md +1 -1
  203. package/docs/core.md +8 -0
  204. package/docs/http-integrations.md +42 -28
  205. package/package.json +8 -8
  206. package/src/adapters/astro/README.md +2 -0
  207. package/src/adapters/hono/envelope-parity.test.ts +6 -18
  208. package/src/adapters/hono/handlers/http-stream.ts +12 -3
  209. package/src/adapters/hono/handlers/http.ts +12 -3
  210. package/src/adapters/hono/handlers/rpc.ts +12 -3
  211. package/src/adapters/hono/handlers/stream.ts +12 -3
  212. package/src/adapters/hono/index.test.ts +70 -0
  213. package/src/adapters/hono/index.ts +53 -11
  214. package/src/adapters/hono/request.ts +18 -0
  215. package/src/adapters/hono/types.ts +37 -0
  216. package/src/codegen/bin/cli.ts +1 -1
  217. package/src/codegen/constants.ts +2 -2
  218. package/src/codegen/emit/api-route.ts +1 -1
  219. package/src/codegen/emit/scope-file.ts +1 -2
  220. package/src/codegen/emit-errors.integration.test.ts +2 -2
  221. package/src/codegen/resolve-envelope.ts +1 -1
  222. package/src/codegen/test-helpers/run-tsc.ts +0 -1
  223. package/src/core/create-http-stream.ts +20 -13
  224. package/src/core/create-http.test-d.ts +154 -0
  225. package/src/core/create-http.ts +19 -8
  226. package/src/core/create-stream.ts +12 -4
  227. package/src/core/create.test.ts +74 -0
  228. package/src/core/create.ts +10 -5
  229. package/src/core/internal.ts +35 -0
  230. package/src/core/procedures.ts +4 -0
  231. package/src/core/types.ts +99 -4
  232. package/src/exports.ts +6 -4
  233. package/src/schema/compute-schema.test.ts +0 -16
  234. package/src/schema/compute-schema.ts +1 -5
  235. package/src/schema/typebox.test.ts +0 -12
  236. package/src/schema/typebox.ts +2 -21
  237. package/src/server/context.test.ts +39 -1
  238. package/src/server/context.ts +54 -4
  239. package/src/server/doc-registry.test.ts +0 -34
  240. package/src/server/doc-registry.ts +0 -3
  241. package/src/server/index.ts +0 -1
  242. package/src/server/types.ts +8 -27
  243. package/agent_config/claude-code/.claude-plugin/plugin.json +0 -5
  244. package/agent_config/claude-code/agents/ts-procedures-architect.md +0 -138
  245. package/agent_config/copilot/copilot-instructions.md +0 -521
  246. package/agent_config/cursor/cursorrules +0 -521
  247. package/agent_config/lib/install-claude.mjs +0 -57
  248. package/build/schema/strip-internal-keywords.d.ts +0 -18
  249. package/build/schema/strip-internal-keywords.js +0 -33
  250. package/build/schema/strip-internal-keywords.js.map +0 -1
  251. package/build/schema/strip-internal-keywords.test.js +0 -38
  252. package/build/schema/strip-internal-keywords.test.js.map +0 -1
  253. package/build/server/spec-version.d.ts +0 -24
  254. package/build/server/spec-version.js +0 -26
  255. package/build/server/spec-version.js.map +0 -1
  256. package/build/version.d.ts +0 -9
  257. package/build/version.js +0 -11
  258. package/build/version.js.map +0 -1
  259. package/docs/doc-envelope-spec-v1.md +0 -296
  260. package/docs/doc-envelope-v1.schema.json +0 -253
  261. package/src/schema/strip-internal-keywords.test.ts +0 -43
  262. package/src/schema/strip-internal-keywords.ts +0 -36
  263. package/src/server/spec-version.ts +0 -27
  264. package/src/version.ts +0 -11
  265. /package/agent_config/{claude-code/skills → skills}/ts-procedures/SKILL.md +0 -0
  266. /package/agent_config/{claude-code/skills → skills}/ts-procedures/checklist.md +0 -0
  267. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/astro-catchall.md +0 -0
  268. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/client.md +0 -0
  269. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/hono.md +0 -0
  270. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/procedure.md +0 -0
  271. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/stream-procedure.md +0 -0
  272. /package/build/{schema/strip-internal-keywords.test.d.ts → core/create-http.test-d.d.ts} +0 -0
@@ -1,253 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://ts-procedures.dev/schemas/doc-envelope-v1.schema.json",
4
- "title": "ts-procedures DocEnvelope (specVersion 1)",
5
- "description": "The JSON document a ts-procedures server exposes (via builder.toDocEnvelope() / DocRegistry.toJSON()). Describes every procedure/route the server serves, the global error catalog, and global headers. Payload schemas embedded under each route's `jsonSchema` are arbitrary JSON Schema (Draft-07) objects and are intentionally left unconstrained here.",
6
- "type": "object",
7
- "required": ["basePath", "headers", "errors", "routes"],
8
- "properties": {
9
- "specVersion": {
10
- "type": "integer",
11
- "minimum": 1,
12
- "description": "Wire-format version of the envelope. A small monotonic integer, bumped ONLY when the envelope shape changes — not on every package release. Branch on this to pick a parser. ABSENT means treat as 1 (envelopes predating this field). Emitted by ts-procedures servers; optional here so older/hand-built documents still validate."
13
- },
14
- "generatorVersion": {
15
- "type": "string",
16
- "description": "ts-procedures package version that produced the envelope, e.g. \"10.0.0\". Informational only (telemetry/debugging) — do NOT use it for parse-compatibility decisions; use specVersion."
17
- },
18
- "basePath": {
19
- "type": "string",
20
- "description": "Path prefix shared by all routes, e.g. \"/api\". May be the empty string."
21
- },
22
- "headers": {
23
- "type": "array",
24
- "description": "Global HTTP headers documented for the whole API.",
25
- "items": { "$ref": "#/definitions/HeaderDoc" }
26
- },
27
- "errors": {
28
- "type": "array",
29
- "description": "Catalog of every error the API may return (framework defaults + user-defined taxonomy). Routes reference these by name via their `errors` array.",
30
- "items": { "$ref": "#/definitions/ErrorDoc" }
31
- },
32
- "routes": {
33
- "type": "array",
34
- "description": "All procedures/routes. Discriminated union on `kind`.",
35
- "items": { "$ref": "#/definitions/AnyRouteDoc" }
36
- }
37
- },
38
- "additionalProperties": true,
39
- "definitions": {
40
- "JsonSchema": {
41
- "description": "An embedded JSON Schema (Draft-07) object describing a payload. Left unconstrained on purpose — render it generically.",
42
- "type": "object",
43
- "additionalProperties": true
44
- },
45
- "HeaderDoc": {
46
- "type": "object",
47
- "required": ["name"],
48
- "properties": {
49
- "name": { "type": "string" },
50
- "description": { "type": "string" },
51
- "required": { "type": "boolean" },
52
- "example": { "type": "string" }
53
- },
54
- "additionalProperties": true
55
- },
56
- "ErrorDoc": {
57
- "type": "object",
58
- "required": ["name", "statusCode", "description"],
59
- "properties": {
60
- "name": {
61
- "type": "string",
62
- "description": "Unique error name. Routes link to it via their `errors` array."
63
- },
64
- "statusCode": {
65
- "type": "integer",
66
- "description": "HTTP status code returned for this error.",
67
- "minimum": 100,
68
- "maximum": 599
69
- },
70
- "description": { "type": "string" },
71
- "schema": {
72
- "$ref": "#/definitions/JsonSchema",
73
- "description": "JSON Schema of the error response body. Optional."
74
- }
75
- },
76
- "additionalProperties": true
77
- },
78
-
79
- "AnyRouteDoc": {
80
- "oneOf": [
81
- { "$ref": "#/definitions/RPCRouteDoc" },
82
- { "$ref": "#/definitions/StreamRouteDoc" },
83
- { "$ref": "#/definitions/APIRouteDoc" },
84
- { "$ref": "#/definitions/HttpStreamRouteDoc" }
85
- ]
86
- },
87
-
88
- "HttpMethod": {
89
- "description": "HTTP method. Canonical wire form is lowercase; treat case-insensitively when rendering.",
90
- "type": "string",
91
- "enum": ["get", "post", "put", "delete", "patch", "head", "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"]
92
- },
93
-
94
- "StreamMode": {
95
- "type": "string",
96
- "enum": ["sse", "text"],
97
- "description": "Stream transport. `sse` = Server-Sent Events; `text` = raw text chunks."
98
- },
99
-
100
- "Scope": {
101
- "description": "Logical grouping. A single segment or an array of segments.",
102
- "oneOf": [
103
- { "type": "string" },
104
- { "type": "array", "items": { "type": "string" } }
105
- ]
106
- },
107
-
108
- "RPCRouteDoc": {
109
- "title": "RPC route (kind = rpc)",
110
- "description": "JSON-RPC-style procedure. Always POST. Path embeds scope + version.",
111
- "type": "object",
112
- "required": ["kind", "name", "path", "method", "scope", "version", "jsonSchema"],
113
- "properties": {
114
- "kind": { "const": "rpc" },
115
- "name": { "type": "string" },
116
- "path": { "type": "string", "description": "Full path incl. basePath + version, e.g. /api/users/get-user/1" },
117
- "method": { "const": "post" },
118
- "scope": { "$ref": "#/definitions/Scope" },
119
- "version": { "type": "number" },
120
- "errors": { "type": "array", "items": { "type": "string" } },
121
- "jsonSchema": {
122
- "type": "object",
123
- "properties": {
124
- "body": { "$ref": "#/definitions/JsonSchema", "description": "Request body schema (validated)." },
125
- "response": { "$ref": "#/definitions/JsonSchema", "description": "Response body schema (doc only)." }
126
- },
127
- "additionalProperties": true
128
- }
129
- },
130
- "additionalProperties": true
131
- },
132
-
133
- "StreamRouteDoc": {
134
- "title": "RPC stream route (kind = stream)",
135
- "description": "Streaming RPC procedure. Served over both POST and GET. Path embeds scope + version.",
136
- "type": "object",
137
- "required": ["kind", "name", "path", "methods", "streamMode", "scope", "version", "jsonSchema"],
138
- "properties": {
139
- "kind": { "const": "stream" },
140
- "name": { "type": "string" },
141
- "path": { "type": "string" },
142
- "methods": {
143
- "type": "array",
144
- "description": "Allowed methods, conventionally [\"post\", \"get\"].",
145
- "items": { "type": "string", "enum": ["get", "post"] }
146
- },
147
- "streamMode": { "$ref": "#/definitions/StreamMode" },
148
- "scope": { "$ref": "#/definitions/Scope" },
149
- "version": { "type": "number" },
150
- "errors": { "type": "array", "items": { "type": "string" }, "description": "Pre-stream errors only." },
151
- "jsonSchema": {
152
- "type": "object",
153
- "properties": {
154
- "params": { "$ref": "#/definitions/JsonSchema", "description": "Query params (GET) or body (POST)." },
155
- "yieldType": {
156
- "$ref": "#/definitions/JsonSchema",
157
- "description": "Schema for each streamed value. In `sse` mode this is the SSE envelope { data, event, id, retry } whose `data` holds the user's yield schema; in `text` mode it is the raw yield schema."
158
- },
159
- "returnType": { "$ref": "#/definitions/JsonSchema", "description": "Final return value schema." }
160
- },
161
- "additionalProperties": true
162
- }
163
- },
164
- "additionalProperties": true
165
- },
166
-
167
- "APIRouteDoc": {
168
- "title": "REST route (kind = api)",
169
- "description": "REST-style HTTP endpoint with explicit method + path.",
170
- "type": "object",
171
- "required": ["kind", "name", "method", "fullPath", "jsonSchema"],
172
- "properties": {
173
- "kind": { "const": "api" },
174
- "name": { "type": "string" },
175
- "scope": { "type": "string" },
176
- "path": { "type": "string", "description": "Path as registered (may include :params), e.g. /users/:id. May be omitted in some envelopes; prefer fullPath." },
177
- "method": { "$ref": "#/definitions/HttpMethod" },
178
- "fullPath": { "type": "string", "description": "Resolved path incl. basePath prefix, e.g. /api/users/:id." },
179
- "successStatus": { "type": "integer", "description": "Status on success. Defaults: POST→201, DELETE→204, else 200." },
180
- "errors": { "type": "array", "items": { "type": "string" } },
181
- "jsonSchema": {
182
- "type": "object",
183
- "properties": {
184
- "req": {
185
- "type": "object",
186
- "properties": {
187
- "pathParams": { "$ref": "#/definitions/JsonSchema" },
188
- "query": { "$ref": "#/definitions/JsonSchema" },
189
- "body": { "$ref": "#/definitions/JsonSchema" },
190
- "headers": { "$ref": "#/definitions/JsonSchema" }
191
- },
192
- "additionalProperties": true
193
- },
194
- "res": {
195
- "type": "object",
196
- "properties": {
197
- "body": { "$ref": "#/definitions/JsonSchema" },
198
- "headers": { "$ref": "#/definitions/JsonSchema" }
199
- },
200
- "additionalProperties": true
201
- }
202
- },
203
- "additionalProperties": true
204
- }
205
- },
206
- "additionalProperties": true
207
- },
208
-
209
- "HttpStreamRouteDoc": {
210
- "title": "REST stream route (kind = http-stream)",
211
- "description": "REST-style streaming endpoint. Response has no single body; values arrive via `yield`. Currently always SSE.",
212
- "type": "object",
213
- "required": ["kind", "name", "method", "fullPath", "streamMode", "jsonSchema"],
214
- "properties": {
215
- "kind": { "const": "http-stream" },
216
- "name": { "type": "string" },
217
- "scope": { "type": "string" },
218
- "path": { "type": "string" },
219
- "method": { "$ref": "#/definitions/HttpMethod" },
220
- "fullPath": { "type": "string" },
221
- "streamMode": { "$ref": "#/definitions/StreamMode" },
222
- "errors": { "type": "array", "items": { "type": "string" } },
223
- "jsonSchema": {
224
- "type": "object",
225
- "properties": {
226
- "req": {
227
- "type": "object",
228
- "properties": {
229
- "pathParams": { "$ref": "#/definitions/JsonSchema" },
230
- "query": { "$ref": "#/definitions/JsonSchema" },
231
- "body": { "$ref": "#/definitions/JsonSchema" },
232
- "headers": { "$ref": "#/definitions/JsonSchema" }
233
- },
234
- "additionalProperties": true
235
- },
236
- "res": {
237
- "type": "object",
238
- "description": "Response headers only — streaming responses have no single body.",
239
- "properties": {
240
- "headers": { "$ref": "#/definitions/JsonSchema" }
241
- },
242
- "additionalProperties": true
243
- },
244
- "yield": { "$ref": "#/definitions/JsonSchema", "description": "Schema for each streamed value. NOT wrapped in an SSE envelope (unlike kind=stream)." },
245
- "returnType": { "$ref": "#/definitions/JsonSchema", "description": "Final return value schema." }
246
- },
247
- "additionalProperties": true
248
- }
249
- },
250
- "additionalProperties": true
251
- }
252
- }
253
- }
@@ -1,43 +0,0 @@
1
- import { describe, expect, test } from 'vitest'
2
- import { Type } from 'typebox'
3
- import { stripInternalKeywords } from './strip-internal-keywords.js'
4
-
5
- describe('stripInternalKeywords', () => {
6
- test('removes enumerable ~-prefixed markers leaked by Type.Optional(Type.Unsafe(...))', () => {
7
- // This composition emits `~unsafe`/`~optional` as ENUMERABLE own props.
8
- const leaky = Type.Optional(Type.Unsafe({ type: 'string' })) as unknown as Record<string, unknown>
9
- expect(Object.keys(leaky).some((k) => k.startsWith('~'))).toBe(true)
10
-
11
- const clean = stripInternalKeywords(leaky)
12
- expect(clean).toEqual({ type: 'string' })
13
- expect(Object.keys(clean as object).some((k) => k.startsWith('~'))).toBe(false)
14
- })
15
-
16
- test('strips markers nested inside object properties', () => {
17
- const schema = Type.Object({ x: Type.Optional(Type.Unsafe({ type: 'string' })) })
18
- const clean = stripInternalKeywords(schema) as any
19
- expect(JSON.stringify(clean)).not.toMatch(/~/)
20
- expect(clean.properties.x).toEqual({ type: 'string' })
21
- })
22
-
23
- test('strips markers inside arrays (e.g. anyOf members)', () => {
24
- const schema = {
25
- anyOf: [Type.Unsafe({ type: 'string' }), { type: 'number', '~optional': true }],
26
- }
27
- const clean = stripInternalKeywords(schema) as any
28
- expect(clean.anyOf).toEqual([{ type: 'string' }, { type: 'number' }])
29
- })
30
-
31
- test('leaves a clean schema structurally equal and does not mutate the input', () => {
32
- const input = { type: 'object', properties: { a: { type: 'string' } } }
33
- const clean = stripInternalKeywords(input)
34
- expect(clean).toEqual(input)
35
- expect(clean).not.toBe(input) // fresh structure
36
- })
37
-
38
- test('passes primitives through unchanged', () => {
39
- expect(stripInternalKeywords('x')).toBe('x')
40
- expect(stripInternalKeywords(5)).toBe(5)
41
- expect(stripInternalKeywords(null)).toBe(null)
42
- })
43
- })
@@ -1,36 +0,0 @@
1
- import type { TJSONSchema } from './json-schema.js'
2
-
3
- /** TypeBox v1 prefixes every internal marker key with `~`. */
4
- const TILDE = '~'
5
-
6
- /**
7
- * Deep-removes TypeBox v1 internal markers (`~kind`, `~unsafe`, `~optional`, …)
8
- * from an extracted JSON Schema, returning a fresh structure (never mutates the
9
- * input).
10
- *
11
- * These markers are *usually* non-enumerable, so they stay out of JSON Schema on
12
- * their own. But some compositions leak them as **enumerable** own properties —
13
- * notably `Type.Optional(Type.Unsafe({...}))`, which emits `~unsafe`/`~optional`
14
- * inline. Left in place those markers (a) pollute serialized docs/codegen output
15
- * and (b) make strict AJV throw `unknown keyword: "~unsafe"` at registration.
16
- *
17
- * Stripping by the `~`-prefix convention (rather than a fixed name list) keeps
18
- * this robust against future TypeBox markers — same convention the TypeBox
19
- * adapter detects on.
20
- */
21
- export function stripInternalKeywords<T>(schema: T): T {
22
- if (Array.isArray(schema)) {
23
- return schema.map((item) => stripInternalKeywords(item)) as T
24
- }
25
- if (schema !== null && typeof schema === 'object') {
26
- const out: Record<string, unknown> = {}
27
- for (const [key, value] of Object.entries(schema)) {
28
- if (key.startsWith(TILDE)) continue
29
- out[key] = stripInternalKeywords(value)
30
- }
31
- return out as T
32
- }
33
- return schema
34
- }
35
-
36
- export type { TJSONSchema }
@@ -1,27 +0,0 @@
1
- import { PACKAGE_VERSION } from '../version.js'
2
-
3
- /**
4
- * Spec version of the {@link DocEnvelope} wire format.
5
- *
6
- * Bump this ONLY when the envelope shape changes in a way downstream parsers
7
- * must react to — field renames, nesting changes, or semantic changes. Do NOT
8
- * bump it on ordinary package releases (dependency upgrades, bug fixes, new
9
- * optional fields that older parsers can safely ignore). It is decoupled from
10
- * the npm package version on purpose, so consumers get a small monotonic
11
- * integer to branch on instead of having to interpret semver.
12
- *
13
- * Consumer contract: an envelope with no `specVersion` field predates this
14
- * field and MUST be treated as spec version 1.
15
- */
16
- export const DOC_ENVELOPE_SPEC_VERSION = 1
17
-
18
- /**
19
- * The ts-procedures package version that produced an envelope (e.g. `"10.0.0"`).
20
- * Populates the envelope's `generatorVersion` field.
21
- *
22
- * Informational only — for telemetry, debugging, and "which release served
23
- * this?" questions. Do NOT use it to decide parse compatibility; it churns on
24
- * every release regardless of whether the envelope format changed. Use
25
- * {@link DOC_ENVELOPE_SPEC_VERSION} for compatibility decisions.
26
- */
27
- export const DOC_ENVELOPE_GENERATOR_VERSION: string = PACKAGE_VERSION
package/src/version.ts DELETED
@@ -1,11 +0,0 @@
1
- import pkg from '../package.json' with { type: 'json' }
2
-
3
- /**
4
- * The ts-procedures package version (e.g. `"10.0.0"`), read from `package.json`.
5
- *
6
- * Single source of truth for "which version is this build?" — consumed by the
7
- * codegen file header and the doc-envelope `generatorVersion`. Import this
8
- * rather than re-importing `package.json`, so there's one place the version
9
- * enters the source tree.
10
- */
11
- export const PACKAGE_VERSION: string = pkg.version