ts-procedures 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +21 -0
  2. package/agent_config/claude-code/skills/guide/SKILL.md +1 -0
  3. package/agent_config/claude-code/skills/guide/anti-patterns.md +37 -4
  4. package/agent_config/claude-code/skills/guide/api-reference.md +86 -0
  5. package/agent_config/claude-code/skills/guide/patterns.md +33 -0
  6. package/agent_config/claude-code/skills/review/checklist.md +2 -0
  7. package/agent_config/claude-code/skills/scaffold/templates/hono-api.md +1 -1
  8. package/agent_config/copilot/copilot-instructions.md +4 -0
  9. package/agent_config/cursor/cursorrules +4 -0
  10. package/build/implementations/http/doc-registry.d.ts +12 -0
  11. package/build/implementations/http/doc-registry.js +114 -0
  12. package/build/implementations/http/doc-registry.js.map +1 -0
  13. package/build/implementations/http/doc-registry.test.d.ts +1 -0
  14. package/build/implementations/http/doc-registry.test.js +321 -0
  15. package/build/implementations/http/doc-registry.test.js.map +1 -0
  16. package/build/implementations/types.d.ts +31 -0
  17. package/package.json +5 -2
  18. package/src/errors.test.ts +0 -163
  19. package/src/errors.ts +0 -107
  20. package/src/exports.ts +0 -7
  21. package/src/implementations/http/README.md +0 -260
  22. package/src/implementations/http/express-rpc/README.md +0 -281
  23. package/src/implementations/http/express-rpc/index.test.ts +0 -957
  24. package/src/implementations/http/express-rpc/index.ts +0 -265
  25. package/src/implementations/http/express-rpc/types.ts +0 -16
  26. package/src/implementations/http/hono-api/index.test.ts +0 -1328
  27. package/src/implementations/http/hono-api/index.ts +0 -461
  28. package/src/implementations/http/hono-api/types.ts +0 -16
  29. package/src/implementations/http/hono-rpc/README.md +0 -358
  30. package/src/implementations/http/hono-rpc/index.test.ts +0 -1075
  31. package/src/implementations/http/hono-rpc/index.ts +0 -237
  32. package/src/implementations/http/hono-rpc/types.ts +0 -16
  33. package/src/implementations/http/hono-stream/README.md +0 -526
  34. package/src/implementations/http/hono-stream/index.test.ts +0 -1676
  35. package/src/implementations/http/hono-stream/index.ts +0 -435
  36. package/src/implementations/http/hono-stream/types.ts +0 -29
  37. package/src/implementations/types.ts +0 -127
  38. package/src/index.test.ts +0 -1194
  39. package/src/index.ts +0 -512
  40. package/src/schema/compute-schema.test.ts +0 -128
  41. package/src/schema/compute-schema.ts +0 -88
  42. package/src/schema/extract-json-schema.test.ts +0 -25
  43. package/src/schema/extract-json-schema.ts +0 -15
  44. package/src/schema/parser.test.ts +0 -182
  45. package/src/schema/parser.ts +0 -215
  46. package/src/schema/resolve-schema-lib.test.ts +0 -19
  47. package/src/schema/resolve-schema-lib.ts +0 -29
  48. package/src/schema/types.ts +0 -20
  49. package/src/stack-utils.test.ts +0 -94
  50. package/src/stack-utils.ts +0 -129
@@ -1,129 +0,0 @@
1
- /**
2
- * Represents a specific location in source code where a procedure was defined.
3
- */
4
- export type DefinitionLocation = {
5
- file: string
6
- line: number
7
- column: number
8
- raw: string
9
- }
10
-
11
- /**
12
- * Contains information about where a procedure was defined.
13
- */
14
- export type DefinitionInfo = {
15
- definedAt?: DefinitionLocation
16
- definitionStack?: string
17
- }
18
-
19
- /**
20
- * Internal ts-procedures files that should be skipped when finding user code.
21
- * Only skip the core library files, not test files or user code.
22
- */
23
- const INTERNAL_FILES = [
24
- '/index.ts',
25
- '/index.js',
26
- '/errors.ts',
27
- '/errors.js',
28
- '/stack-utils.ts',
29
- '/stack-utils.js',
30
- '/compute-schema.ts',
31
- '/compute-schema.js',
32
- '/parser.ts',
33
- '/parser.js',
34
- ]
35
-
36
- /**
37
- * Captures the stack trace at the call site and extracts the definition location.
38
- * Finds the first stack frame outside of ts-procedures internal files.
39
- */
40
- export function captureDefinitionInfo(): DefinitionInfo {
41
- const err = new Error()
42
- const stack = err.stack
43
-
44
- if (!stack) {
45
- return {}
46
- }
47
-
48
- const lines = stack.split('\n')
49
-
50
- // Find the first frame that's not from ts-procedures internals
51
- // Skip the first line (Error message) and frames from this module
52
- let userFrame: string | undefined
53
-
54
- for (let i = 1; i < lines.length; i++) {
55
- const rawLine = lines[i]
56
- if (!rawLine) continue
57
- const line = rawLine.trim()
58
-
59
- // Skip empty or invalid frames
60
- if (!line.startsWith('at ')) {
61
- continue
62
- }
63
-
64
- // Skip frames from ts-procedures internal source files
65
- const isInternalFile = INTERNAL_FILES.some(file => line.includes(file))
66
- if (isInternalFile) {
67
- continue
68
- }
69
-
70
- // Skip frames from ts-procedures in node_modules (when used as a dependency)
71
- if (line.includes('/node_modules/ts-procedures/') || line.includes('\\node_modules\\ts-procedures\\')) {
72
- continue
73
- }
74
-
75
- // Skip internal node frames
76
- if (line.includes('node:') || line.startsWith('at Module.') || line.startsWith('at Object.<anonymous> (node:')) {
77
- continue
78
- }
79
-
80
- userFrame = line
81
- break
82
- }
83
-
84
- if (!userFrame) {
85
- return { definitionStack: stack }
86
- }
87
-
88
- const definedAt = parseStackFrame(userFrame)
89
-
90
- return {
91
- definedAt,
92
- definitionStack: stack,
93
- }
94
- }
95
-
96
- /**
97
- * Parses a V8 stack frame line to extract file, line, and column info.
98
- * Handles formats like:
99
- * - "at Object.<anonymous> (/path/to/file.ts:10:5)"
100
- * - "at functionName (/path/to/file.ts:10:5)"
101
- * - "at /path/to/file.ts:10:5"
102
- */
103
- function parseStackFrame(frame: string): DefinitionLocation | undefined {
104
- // Match patterns like "(path:line:column)" or just "path:line:column"
105
- const match = frame.match(/\(([^)]+):(\d+):(\d+)\)$/) || frame.match(/at ([^:]+):(\d+):(\d+)$/)
106
-
107
- if (match && match[1] && match[2] && match[3]) {
108
- return {
109
- file: match[1],
110
- line: parseInt(match[2], 10),
111
- column: parseInt(match[3], 10),
112
- raw: frame,
113
- }
114
- }
115
-
116
- return undefined
117
- }
118
-
119
- /**
120
- * Formats definition info for appending to error stacks.
121
- */
122
- export function formatDefinitionInfo(info: DefinitionInfo, procedureName: string): string | undefined {
123
- if (!info.definedAt) {
124
- return undefined
125
- }
126
-
127
- const { file, line, column } = info.definedAt
128
- return `\n--- Procedure "${procedureName}" defined at ---\n at ${file}:${line}:${column}`
129
- }