@c9up/ream 0.2.29 → 0.2.30
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/README.md +5 -6
- package/dist/Codemods.d.ts +8 -0
- package/dist/Codemods.d.ts.map +1 -1
- package/dist/Codemods.js +29 -1
- package/dist/Codemods.js.map +1 -1
- package/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +17 -5
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts +5 -0
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +12 -1
- package/dist/Ignitor.js.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.d.ts +4 -4
- package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.js +38 -11
- package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
- package/dist/bodyparser/MultipartFile.d.ts +21 -15
- package/dist/bodyparser/MultipartFile.d.ts.map +1 -1
- package/dist/bodyparser/MultipartFile.js +40 -58
- package/dist/bodyparser/MultipartFile.js.map +1 -1
- package/dist/bodyparser/parseSize.d.ts +7 -4
- package/dist/bodyparser/parseSize.d.ts.map +1 -1
- package/dist/bodyparser/parseSize.js +12 -17
- package/dist/bodyparser/parseSize.js.map +1 -1
- package/dist/bodyparser/qsParse.d.ts +10 -0
- package/dist/bodyparser/qsParse.d.ts.map +1 -1
- package/dist/bodyparser/qsParse.js +27 -12
- package/dist/bodyparser/qsParse.js.map +1 -1
- package/dist/console/prompts.d.ts.map +1 -1
- package/dist/console/prompts.js +3 -1
- package/dist/console/prompts.js.map +1 -1
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +61 -71
- package/dist/container/Container.js.map +1 -1
- package/dist/events/Emitter.d.ts +12 -0
- package/dist/events/Emitter.d.ts.map +1 -1
- package/dist/events/Emitter.js +36 -9
- package/dist/events/Emitter.js.map +1 -1
- package/dist/events/helix/helpers.d.ts.map +1 -1
- package/dist/events/helix/helpers.js +19 -9
- package/dist/events/helix/helpers.js.map +1 -1
- package/dist/graphql/GraphQLEngine.d.ts +8 -0
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
- package/dist/graphql/GraphQLEngine.js +77 -11
- package/dist/graphql/GraphQLEngine.js.map +1 -1
- package/dist/helpers/MessageBuilder.d.ts +4 -2
- package/dist/helpers/MessageBuilder.d.ts.map +1 -1
- package/dist/helpers/MessageBuilder.js +4 -2
- package/dist/helpers/MessageBuilder.js.map +1 -1
- package/dist/helpers/errors.d.ts +11 -0
- package/dist/helpers/errors.d.ts.map +1 -0
- package/dist/helpers/errors.js +17 -0
- package/dist/helpers/errors.js.map +1 -0
- package/dist/helpers/napi-loader.d.ts.map +1 -1
- package/dist/helpers/napi-loader.js +3 -2
- package/dist/helpers/napi-loader.js.map +1 -1
- package/dist/http/HttpContext.d.ts +20 -2
- package/dist/http/HttpContext.d.ts.map +1 -1
- package/dist/http/HttpContext.js +10 -4
- package/dist/http/HttpContext.js.map +1 -1
- package/dist/http/RedirectBuilder.d.ts.map +1 -1
- package/dist/http/RedirectBuilder.js +4 -0
- package/dist/http/RedirectBuilder.js.map +1 -1
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +15 -29
- package/dist/http/Request.js.map +1 -1
- package/dist/http/Response.d.ts +7 -4
- package/dist/http/Response.d.ts.map +1 -1
- package/dist/http/Response.js +14 -6
- package/dist/http/Response.js.map +1 -1
- package/dist/http/permissions.d.ts +14 -8
- package/dist/http/permissions.d.ts.map +1 -1
- package/dist/http/permissions.js +26 -16
- package/dist/http/permissions.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/Pipeline.js +1 -1
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/native/generated.d.ts +16 -30
- package/dist/native/generated.d.ts.map +1 -1
- package/dist/profiler/Profiler.d.ts.map +1 -1
- package/dist/profiler/Profiler.js +4 -1
- package/dist/profiler/Profiler.js.map +1 -1
- package/dist/profiler/client.generated.d.ts +5 -0
- package/dist/profiler/client.generated.d.ts.map +1 -0
- package/dist/profiler/client.generated.js +6 -0
- package/dist/profiler/client.generated.js.map +1 -0
- package/dist/profiler/collectors.d.ts +92 -13
- package/dist/profiler/collectors.d.ts.map +1 -1
- package/dist/profiler/collectors.js +106 -19
- package/dist/profiler/collectors.js.map +1 -1
- package/dist/profiler/endpoint.d.ts +2 -1
- package/dist/profiler/endpoint.d.ts.map +1 -1
- package/dist/profiler/endpoint.js +25 -1
- package/dist/profiler/endpoint.js.map +1 -1
- package/dist/profiler/index.d.ts +8 -4
- package/dist/profiler/index.d.ts.map +1 -1
- package/dist/profiler/index.js +11 -4
- package/dist/profiler/index.js.map +1 -1
- package/dist/profiler/middleware.d.ts.map +1 -1
- package/dist/profiler/middleware.js +76 -10
- package/dist/profiler/middleware.js.map +1 -1
- package/dist/profiler/preview.d.ts +17 -0
- package/dist/profiler/preview.d.ts.map +1 -0
- package/dist/profiler/preview.js +100 -0
- package/dist/profiler/preview.js.map +1 -0
- package/dist/profiler/toolbar.d.ts +15 -23
- package/dist/profiler/toolbar.d.ts.map +1 -1
- package/dist/profiler/toolbar.js +25 -91
- package/dist/profiler/toolbar.js.map +1 -1
- package/dist/profiler/types.d.ts +6 -1
- package/dist/profiler/types.d.ts.map +1 -1
- package/dist/router/Router.d.ts +6 -0
- package/dist/router/Router.d.ts.map +1 -1
- package/dist/router/Router.js +115 -12
- package/dist/router/Router.js.map +1 -1
- package/dist/rpc/RpcRouter.js +3 -3
- package/dist/rpc/RpcRouter.js.map +1 -1
- package/dist/scheduler/Scheduler.js +1 -1
- package/dist/scheduler/Scheduler.js.map +1 -1
- package/dist/security/CookieSigner.d.ts.map +1 -1
- package/dist/security/CookieSigner.js +15 -5
- package/dist/security/CookieSigner.js.map +1 -1
- package/dist/security/SignedUrl.d.ts.map +1 -1
- package/dist/security/SignedUrl.js +10 -18
- package/dist/security/SignedUrl.js.map +1 -1
- package/dist/server/Server.d.ts +4 -1
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js.map +1 -1
- package/dist/server/nativeLimits.d.ts +9 -1
- package/dist/server/nativeLimits.d.ts.map +1 -1
- package/dist/server/nativeLimits.js +8 -0
- package/dist/server/nativeLimits.js.map +1 -1
- package/dist/session/Session.d.ts.map +1 -1
- package/dist/session/Session.js +13 -4
- package/dist/session/Session.js.map +1 -1
- package/dist/session/drivers/MemoryDriver.d.ts.map +1 -1
- package/dist/session/drivers/MemoryDriver.js +14 -2
- package/dist/session/drivers/MemoryDriver.js.map +1 -1
- package/dist/storage/StaticMiddleware.d.ts.map +1 -1
- package/dist/storage/StaticMiddleware.js +20 -9
- package/dist/storage/StaticMiddleware.js.map +1 -1
- package/dist/testing/ApiResponse.d.ts.map +1 -1
- package/dist/testing/ApiResponse.js +7 -1
- package/dist/testing/ApiResponse.js.map +1 -1
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +16 -4
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/utils/Macroable.d.ts +1 -1
- package/dist/utils/Macroable.js +2 -2
- package/dist/utils/Macroable.js.map +1 -1
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -2
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/Codemods.ts +49 -3
- package/src/HttpKernel.ts +18 -7
- package/src/Ignitor.ts +21 -4
- package/src/bodyparser/BodyParserMiddleware.ts +42 -16
- package/src/bodyparser/MultipartFile.ts +46 -67
- package/src/bodyparser/parseSize.ts +17 -17
- package/src/bodyparser/qsParse.ts +28 -13
- package/src/console/prompts.ts +3 -1
- package/src/container/Container.ts +97 -81
- package/src/events/Emitter.ts +37 -10
- package/src/events/helix/helpers.ts +24 -19
- package/src/graphql/GraphQLEngine.ts +89 -13
- package/src/helpers/MessageBuilder.ts +4 -2
- package/src/helpers/errors.ts +16 -0
- package/src/helpers/napi-loader.ts +3 -2
- package/src/http/HttpContext.ts +20 -4
- package/src/http/RedirectBuilder.ts +3 -0
- package/src/http/Request.ts +15 -29
- package/src/http/Response.ts +15 -7
- package/src/http/permissions.ts +31 -15
- package/src/index.ts +2 -1
- package/src/middleware/Pipeline.ts +1 -1
- package/src/native/generated.ts +18 -42
- package/src/profiler/Profiler.ts +4 -1
- package/src/profiler/client/toolbar.css +595 -0
- package/src/profiler/client/toolbar.js +1299 -0
- package/src/profiler/client.generated.ts +7 -0
- package/src/profiler/collectors.ts +156 -19
- package/src/profiler/endpoint.ts +27 -1
- package/src/profiler/index.ts +17 -3
- package/src/profiler/middleware.ts +74 -9
- package/src/profiler/preview.ts +104 -0
- package/src/profiler/toolbar.ts +28 -91
- package/src/profiler/types.ts +6 -1
- package/src/router/Router.ts +136 -13
- package/src/rpc/RpcRouter.ts +4 -4
- package/src/scheduler/Scheduler.ts +1 -1
- package/src/security/CookieSigner.ts +13 -5
- package/src/security/SignedUrl.ts +12 -16
- package/src/server/Server.ts +4 -1
- package/src/server/nativeLimits.ts +18 -1
- package/src/session/Session.ts +13 -4
- package/src/session/drivers/MemoryDriver.ts +15 -2
- package/src/storage/StaticMiddleware.ts +18 -9
- package/src/testing/ApiResponse.ts +7 -1
- package/src/testing/TestClient.ts +14 -5
- package/src/utils/Macroable.ts +2 -2
- package/scripts/build-napi-types.mjs +0 -69
- package/scripts/copy-napi.mjs +0 -121
- package/scripts/generate-mime.mjs +0 -119
- package/scripts/generate-napi-types.mjs +0 -187
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Generate the TypeScript surface of the native modules FROM the Rust.
|
|
4
|
-
*
|
|
5
|
-
* `napi-derive`'s `type-def` feature emits one JSON line per exported item
|
|
6
|
-
* while cargo compiles. Those lines are the source of truth: they are derived
|
|
7
|
-
* from the `#[napi]` items themselves, so a signature cannot drift from the
|
|
8
|
-
* Rust without this file changing.
|
|
9
|
-
*
|
|
10
|
-
* Hand-written interfaces are what we had before, and they DID drift — making
|
|
11
|
-
* `Bus::on_request` synchronous changed the Rust with nothing on the TypeScript
|
|
12
|
-
* side to notice.
|
|
13
|
-
*
|
|
14
|
-
* One thing napi-rs cannot infer: the shape of a `JsFunction` callback. It
|
|
15
|
-
* emits `(...args: any[]) => any`. Those few are refined below, by name, and
|
|
16
|
-
* the script fails if a refinement no longer matches anything — so the table
|
|
17
|
-
* cannot rot either.
|
|
18
|
-
*
|
|
19
|
-
* TYPE_DEF_TMP_PATH=<file> cargo build -p <crates…>
|
|
20
|
-
* node scripts/generate-napi-types.mjs <file> <out.d.ts>
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { readFileSync, writeFileSync } from 'node:fs'
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Callback signatures napi-rs erases to `any`, restored here.
|
|
27
|
-
*
|
|
28
|
-
* Keyed by `<owner>.<method>`; the value replaces the whole parameter. Every
|
|
29
|
-
* entry must match, or the script fails: a stale refinement is how a hand
|
|
30
|
-
* annotation quietly stops describing the Rust.
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* napi-derive 3 emits `callback: (arg: unknown) => unknown` where 2 emitted
|
|
34
|
-
* `(...args: any[]) => any` — better, since it no longer reaches for `any`,
|
|
35
|
-
* but a different string to match on. These refinements exist because the
|
|
36
|
-
* generated shape says nothing about what the callback actually receives.
|
|
37
|
-
*/
|
|
38
|
-
const CALLBACK_REFINEMENTS = {
|
|
39
|
-
'EventBus.subscribe': {
|
|
40
|
-
from: 'callback: (arg: unknown) => unknown',
|
|
41
|
-
to: 'callback: (eventJson: string) => void',
|
|
42
|
-
},
|
|
43
|
-
'EventBus.onRequest': {
|
|
44
|
-
from: 'callback: (arg: unknown) => unknown',
|
|
45
|
-
to: 'callback: (eventJson: string, reply: (response: string) => void) => void',
|
|
46
|
-
},
|
|
47
|
-
'HyperServer.onRequest': {
|
|
48
|
-
// Only the argument is named. The `to` used to say
|
|
49
|
-
// `(request: string) => Promise<string> | string`, which described the
|
|
50
|
-
// boundary as it was BEFORE it stopped serialising: the Rust hands the
|
|
51
|
-
// handler a JsObject and awaits a `NapiResponse`, and napi's own output
|
|
52
|
-
// already said so. The refinement was overwriting a correct shape with a
|
|
53
|
-
// stale one, and nothing noticed because every caller of `onRequest` was
|
|
54
|
-
// outside the typecheck.
|
|
55
|
-
from: 'callback: (arg: unknown) => Promise<NapiResponse>',
|
|
56
|
-
to: 'callback: (request: Record<string, unknown>) => Promise<NapiResponse>',
|
|
57
|
-
},
|
|
58
|
-
'HyperServer.onStreamDisconnect': {
|
|
59
|
-
from: 'callback: (arg: unknown) => unknown',
|
|
60
|
-
to: 'callback: (streamId: string) => void',
|
|
61
|
-
},
|
|
62
|
-
// The Rust hands over a serialised JsTaskPayload — `{ task_name,
|
|
63
|
-
// scheduled_for_ms }` renamed to camelCase by serde.
|
|
64
|
-
'RustScheduler.register': {
|
|
65
|
-
from: 'callback: (arg: unknown) => unknown',
|
|
66
|
-
to: 'callback: (invocation: { taskName: string; scheduledForMs: number }) => void',
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const [input, output] = process.argv.slice(2)
|
|
71
|
-
if (!input || !output) {
|
|
72
|
-
console.error('usage: generate-napi-types.mjs <type-def file> <out.d.ts>')
|
|
73
|
-
process.exit(2)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const entries = readFileSync(input, 'utf8')
|
|
77
|
-
.split('\n')
|
|
78
|
-
.map((l) => l.trim())
|
|
79
|
-
.filter(Boolean)
|
|
80
|
-
.map((l) => JSON.parse(l))
|
|
81
|
-
|
|
82
|
-
const used = new Set()
|
|
83
|
-
|
|
84
|
-
/** Apply the refinements that belong to `owner`, tracking which ones matched. */
|
|
85
|
-
function refine(owner, body) {
|
|
86
|
-
let out = body
|
|
87
|
-
for (const [key, { from, to }] of Object.entries(CALLBACK_REFINEMENTS)) {
|
|
88
|
-
const [entryOwner] = key.split('.')
|
|
89
|
-
if (entryOwner !== owner) continue
|
|
90
|
-
if (out.includes(from)) {
|
|
91
|
-
out = out.replace(from, to)
|
|
92
|
-
used.add(key)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return out
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* JSDoc as emitted by napi-derive, indented to sit above its member.
|
|
100
|
-
*
|
|
101
|
-
* `*` followed by `/` inside the text closes the comment early — a Rust doc
|
|
102
|
-
* example holding a cron expression (`0 */5 * * *`) is enough to do it, and
|
|
103
|
-
* the generated file then fails to parse. Escaped rather than stripped, so the
|
|
104
|
-
* example still reads correctly.
|
|
105
|
-
*/
|
|
106
|
-
function docBlock(doc, indent = '') {
|
|
107
|
-
if (!doc) return ''
|
|
108
|
-
// Escape every `*/` EXCEPT the one that closes the block. A Rust doc example
|
|
109
|
-
// holding a cron expression (`0 */5 * * *`) closes the comment early
|
|
110
|
-
// otherwise, and the generated file stops parsing — but escaping the closer
|
|
111
|
-
// too breaks it just as thoroughly, whether the block spans one line or many.
|
|
112
|
-
const closer = doc.lastIndexOf('*/')
|
|
113
|
-
const escaped =
|
|
114
|
-
closer === -1
|
|
115
|
-
? doc
|
|
116
|
-
: doc.slice(0, closer).replaceAll('*/', '*\\/') + doc.slice(closer)
|
|
117
|
-
return (
|
|
118
|
-
escaped
|
|
119
|
-
.split('\n')
|
|
120
|
-
.filter((l) => l.length > 0)
|
|
121
|
-
.map((l) => `${indent}${l}`)
|
|
122
|
-
.join('\n') + '\n'
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const interfaces = entries.filter((e) => e.kind === 'interface')
|
|
127
|
-
const structs = entries.filter((e) => e.kind === 'struct')
|
|
128
|
-
const impls = new Map(entries.filter((e) => e.kind === 'impl').map((e) => [e.name, e]))
|
|
129
|
-
const fns = entries.filter((e) => e.kind === 'fn')
|
|
130
|
-
|
|
131
|
-
const out = [
|
|
132
|
-
'// GENERATED FROM THE RUST — do not edit.',
|
|
133
|
-
'//',
|
|
134
|
-
'// Produced by scripts/generate-napi-types.mjs from napi-derive\'s type-def',
|
|
135
|
-
'// output. Editing this file by hand puts it back where it started: a',
|
|
136
|
-
'// description that can disagree with the code it describes.',
|
|
137
|
-
'',
|
|
138
|
-
]
|
|
139
|
-
|
|
140
|
-
for (const iface of interfaces) {
|
|
141
|
-
out.push(docBlock(iface.js_doc))
|
|
142
|
-
out.push(`export interface ${iface.name} {`)
|
|
143
|
-
for (const line of iface.def.split('\n')) {
|
|
144
|
-
out.push(line ? ` ${line.trim()}` : '')
|
|
145
|
-
}
|
|
146
|
-
out.push('}', '')
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
for (const struct of structs) {
|
|
150
|
-
const impl = impls.get(struct.name)
|
|
151
|
-
out.push(docBlock(struct.js_doc))
|
|
152
|
-
out.push(`export declare class ${struct.name} {`)
|
|
153
|
-
if (impl) {
|
|
154
|
-
for (const line of refine(struct.name, impl.def).split('\n')) {
|
|
155
|
-
out.push(line ? ` ${line.trim()}` : '')
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
out.push('}', '')
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
for (const fn of fns) {
|
|
162
|
-
out.push(docBlock(fn.js_doc))
|
|
163
|
-
// napi-derive emits the whole declaration for a function, unlike a struct
|
|
164
|
-
// where `def` holds only the members.
|
|
165
|
-
const declaration = fn.def.trim()
|
|
166
|
-
// napi-derive 3 emits a bare `function name(...)` where 2 emitted the
|
|
167
|
-
// signature after the name; concatenating onto the former produced
|
|
168
|
-
// `function xfunction x(...)`.
|
|
169
|
-
const rendered = declaration.startsWith('export declare function')
|
|
170
|
-
? declaration
|
|
171
|
-
: declaration.startsWith('function ')
|
|
172
|
-
? `export declare ${declaration}`
|
|
173
|
-
: `export declare function ${fn.name}${declaration}`
|
|
174
|
-
out.push(`${rendered};`, '')
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const stale = Object.keys(CALLBACK_REFINEMENTS).filter((k) => !used.has(k))
|
|
178
|
-
if (stale.length > 0) {
|
|
179
|
-
console.error(
|
|
180
|
-
`[napi-types] refinement(s) that matched nothing: ${stale.join(', ')}\n` +
|
|
181
|
-
'[napi-types] the Rust changed under them — update or remove the entry.',
|
|
182
|
-
)
|
|
183
|
-
process.exit(1)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
writeFileSync(output, out.join('\n'))
|
|
187
|
-
console.log(`[napi-types] ${output} — ${interfaces.length} interface(s), ${structs.length} class(es), ${fns.length} function(s)`)
|