ts-procedures 5.4.0 → 5.4.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 (34) hide show
  1. package/package.json +1 -2
  2. package/src/errors.test.ts +0 -163
  3. package/src/errors.ts +0 -107
  4. package/src/exports.ts +0 -7
  5. package/src/implementations/http/README.md +0 -260
  6. package/src/implementations/http/express-rpc/README.md +0 -281
  7. package/src/implementations/http/express-rpc/index.test.ts +0 -957
  8. package/src/implementations/http/express-rpc/index.ts +0 -265
  9. package/src/implementations/http/express-rpc/types.ts +0 -16
  10. package/src/implementations/http/hono-api/index.test.ts +0 -1328
  11. package/src/implementations/http/hono-api/index.ts +0 -461
  12. package/src/implementations/http/hono-api/types.ts +0 -16
  13. package/src/implementations/http/hono-rpc/README.md +0 -358
  14. package/src/implementations/http/hono-rpc/index.test.ts +0 -1075
  15. package/src/implementations/http/hono-rpc/index.ts +0 -237
  16. package/src/implementations/http/hono-rpc/types.ts +0 -16
  17. package/src/implementations/http/hono-stream/README.md +0 -526
  18. package/src/implementations/http/hono-stream/index.test.ts +0 -1676
  19. package/src/implementations/http/hono-stream/index.ts +0 -435
  20. package/src/implementations/http/hono-stream/types.ts +0 -29
  21. package/src/implementations/types.ts +0 -127
  22. package/src/index.test.ts +0 -1194
  23. package/src/index.ts +0 -512
  24. package/src/schema/compute-schema.test.ts +0 -128
  25. package/src/schema/compute-schema.ts +0 -88
  26. package/src/schema/extract-json-schema.test.ts +0 -25
  27. package/src/schema/extract-json-schema.ts +0 -15
  28. package/src/schema/parser.test.ts +0 -182
  29. package/src/schema/parser.ts +0 -215
  30. package/src/schema/resolve-schema-lib.test.ts +0 -19
  31. package/src/schema/resolve-schema-lib.ts +0 -29
  32. package/src/schema/types.ts +0 -20
  33. package/src/stack-utils.test.ts +0 -94
  34. 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
- }