@zuplo/cli 7.15.16 → 7.15.18

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 (32) hide show
  1. package/node_modules/@hono/node-server/dist/index.cjs +16 -4
  2. package/node_modules/@hono/node-server/dist/index.mjs +16 -4
  3. package/node_modules/@hono/node-server/package.json +1 -1
  4. package/node_modules/@zuplo/core/package.json +1 -1
  5. package/node_modules/@zuplo/graphql/package.json +1 -1
  6. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  7. package/node_modules/@zuplo/otel/out/esm/{chunk-6YAK7LGJ.js → chunk-BJ3PRHGL.js} +2 -2
  8. package/node_modules/@zuplo/otel/out/esm/chunk-BJ3PRHGL.js.map +1 -0
  9. package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
  10. package/node_modules/@zuplo/otel/out/types/index.d.ts +10 -0
  11. package/node_modules/@zuplo/otel/package.json +1 -1
  12. package/node_modules/@zuplo/runtime/out/esm/{chunk-HMKEMARF.js → chunk-6KHAYHSW.js} +76 -78
  13. package/node_modules/@zuplo/runtime/out/esm/chunk-6KHAYHSW.js.map +1 -0
  14. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  15. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  16. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  17. package/node_modules/@zuplo/runtime/package.json +1 -1
  18. package/node_modules/router/HISTORY.md +67 -52
  19. package/node_modules/router/README.md +222 -2
  20. package/node_modules/router/index.d.ts +188 -0
  21. package/node_modules/router/index.js +86 -50
  22. package/node_modules/router/lib/layer.js +154 -47
  23. package/node_modules/router/lib/param.js +47 -0
  24. package/node_modules/router/lib/route.d.ts +118 -0
  25. package/node_modules/router/lib/route.js +14 -8
  26. package/node_modules/router/lib/symbols.js +4 -0
  27. package/node_modules/router/lib/tracing.js +173 -0
  28. package/node_modules/router/package.json +24 -9
  29. package/package.json +11 -11
  30. package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js.map +0 -1
  31. package/node_modules/@zuplo/runtime/out/esm/chunk-HMKEMARF.js.map +0 -1
  32. /package/node_modules/@zuplo/runtime/out/esm/{chunk-HMKEMARF.js.LEGAL.txt → chunk-6KHAYHSW.js.LEGAL.txt} +0 -0
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * router
3
+ * MIT Licensed
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const isPromise = require('is-promise')
9
+ const deprecate = require('depd')('router')
10
+
11
+ module.exports = callParam
12
+
13
+ // Share invocation and promise handling between traced and untraced callbacks.
14
+ // A resolved promise may notify tracing, but does not call next(). onSettle gets
15
+ // the resolved value, or (reason, true) if the promise rejected.
16
+ function callParam (fn, req, res, next, value, name, onSettle) {
17
+ try {
18
+ const ret = fn(req, res, next, value, name)
19
+ if (isPromise(ret)) {
20
+ if (!(ret instanceof Promise)) {
21
+ deprecate('parameters that are Promise-like are deprecated, use a native Promise instead')
22
+ }
23
+
24
+ try {
25
+ ret.then(onSettle || noop, function (err) {
26
+ rejected(err || new Error('Rejected promise'))
27
+ })
28
+ } catch (err) {
29
+ // A `then` that throws is a rejection, forwarded verbatim as before
30
+ rejected(err)
31
+ }
32
+ }
33
+ } catch (err) {
34
+ next(err)
35
+ }
36
+
37
+ function rejected (err) {
38
+ next(err)
39
+ if (onSettle) onSettle(err, true)
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Passed to then() instead of null, since some thenables call their callbacks
45
+ * without checking, and the traced path always passes a function.
46
+ */
47
+ function noop () {}
@@ -0,0 +1,118 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http'
2
+ import type { Layer as RouterLayer, Params as RouterParams, Request as RouterRequest, Response as RouterResponse } from '../index'
3
+
4
+ declare const Route: Route.RouteConstructor
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-redeclare -- Merge types with the CommonJS constructor export.
7
+ declare namespace Route {
8
+ /**
9
+ * Call `next()` to continue to the next handler.
10
+ * In a route handler, `next('route')` skips the remaining handlers of that route.
11
+ * `next('router')` exits the current router and invokes its completion callback.
12
+ * Other truthy arguments enter error handling; falsy arguments continue normally.
13
+ */
14
+ type NextFunction = (err?: any) => void
15
+
16
+ type Params = RouterParams
17
+ type Request<P = Params> = RouterRequest<P>
18
+ type Response = RouterResponse
19
+ type Layer = RouterLayer
20
+
21
+ type RequestHandler<P = Params> = (req: Request<P>, res: Response, next: NextFunction) => unknown
22
+ type ErrorRequestHandler<P = Params> = (err: any, req: Request<P>, res: Response, next: NextFunction) => unknown
23
+
24
+ type Handler<P = Params> = RequestHandler<P> | ErrorRequestHandler<P>
25
+ type HandlerArg<F extends Handler<any> = Handler> = F | ReadonlyArray<HandlerArg<F>>
26
+
27
+ type NestedStringPath = string | ReadonlyArray<NestedStringPath>
28
+ type Path = string | RegExp | ReadonlyArray<RegExp | NestedStringPath>
29
+
30
+ // Follow the route parameter inference used by @types/express-serve-static-core.
31
+ type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S
32
+ type GetRouteParameter<S extends string> = RemoveTail<RemoveTail<RemoveTail<S, `/${string}`>, `-${string}`>, `.${string}`>
33
+
34
+ type RouteParameters<R extends Path> = R extends string
35
+ ? R extends `${infer Required}{${infer Optional}}${infer Next}`
36
+ ? ParseRouteParameters<Required> & Partial<ParseRouteParameters<Optional>> & RouteParameters<Next>
37
+ : ParseRouteParameters<R>
38
+ : Params
39
+
40
+ type ParseRouteParameters<R extends string> = string extends R ? Params
41
+ : R extends `${string}:${infer Rest}`
42
+ ? (GetRouteParameter<Rest> extends never ? Params : { [P in GetRouteParameter<Rest>]: string })
43
+ & (Rest extends `${GetRouteParameter<Rest>}${infer Next}` ? RouteParameters<Next> : unknown)
44
+ : R extends `${string}*${infer Rest}`
45
+ ? (GetRouteParameter<Rest> extends never ? Params : { [P in GetRouteParameter<Rest>]: string[] })
46
+ & (Rest extends `${GetRouteParameter<Rest>}${infer Next}` ? RouteParameters<Next> : unknown)
47
+ : {}
48
+
49
+ type RouteMethod<T, DefaultParams = Params> = {
50
+ <F extends Handler<any> = RequestHandler<DefaultParams>>(handler: HandlerArg<F>, ...handlers: Array<HandlerArg<F>>): T
51
+ <P = DefaultParams>(handler: HandlerArg<RequestHandler<P>>, ...handlers: Array<HandlerArg<RequestHandler<P>>>): T
52
+ <P = DefaultParams>(handler: HandlerArg<Handler<P>>, ...handlers: Array<HandlerArg<Handler<P>>>): T
53
+ }
54
+
55
+ type Method =
56
+ | 'acl' | 'bind' | 'checkout' | 'connect' | 'copy' | 'delete' | 'get'
57
+ | 'head' | 'link' | 'lock' | 'm-search' | 'merge' | 'mkactivity'
58
+ | 'mkcalendar' | 'mkcol' | 'move' | 'notify' | 'options' | 'patch'
59
+ | 'post' | 'propfind' | 'proppatch' | 'purge' | 'put' | 'query'
60
+ | 'rebind' | 'report' | 'search' | 'source' | 'subscribe' | 'trace'
61
+ | 'unbind' | 'unlink' | 'unlock' | 'unsubscribe'
62
+
63
+ type MethodHandlers<T> = { [M in Method | 'all']: RouteMethod<T> }
64
+
65
+ interface Route<R extends Path = Path> {
66
+ path: R
67
+ stack: Layer[]
68
+ methods: Record<string, boolean>
69
+
70
+ _handlesMethod(method: string): boolean
71
+ /** Include `'*'` for `.all()` handlers when `includeAll` is true. */
72
+ _methods(includeAll?: boolean): string[]
73
+ dispatch(req: IncomingMessage, res: ServerResponse, done: NextFunction): void
74
+
75
+ all: RouteMethod<this, RouteParameters<R>>
76
+ acl: RouteMethod<this, RouteParameters<R>>
77
+ bind: RouteMethod<this, RouteParameters<R>>
78
+ checkout: RouteMethod<this, RouteParameters<R>>
79
+ connect: RouteMethod<this, RouteParameters<R>>
80
+ copy: RouteMethod<this, RouteParameters<R>>
81
+ delete: RouteMethod<this, RouteParameters<R>>
82
+ get: RouteMethod<this, RouteParameters<R>>
83
+ head: RouteMethod<this, RouteParameters<R>>
84
+ link: RouteMethod<this, RouteParameters<R>>
85
+ lock: RouteMethod<this, RouteParameters<R>>
86
+ 'm-search': RouteMethod<this, RouteParameters<R>>
87
+ merge: RouteMethod<this, RouteParameters<R>>
88
+ mkactivity: RouteMethod<this, RouteParameters<R>>
89
+ mkcalendar: RouteMethod<this, RouteParameters<R>>
90
+ mkcol: RouteMethod<this, RouteParameters<R>>
91
+ move: RouteMethod<this, RouteParameters<R>>
92
+ notify: RouteMethod<this, RouteParameters<R>>
93
+ options: RouteMethod<this, RouteParameters<R>>
94
+ patch: RouteMethod<this, RouteParameters<R>>
95
+ post: RouteMethod<this, RouteParameters<R>>
96
+ propfind: RouteMethod<this, RouteParameters<R>>
97
+ proppatch: RouteMethod<this, RouteParameters<R>>
98
+ purge: RouteMethod<this, RouteParameters<R>>
99
+ put: RouteMethod<this, RouteParameters<R>>
100
+ query: RouteMethod<this, RouteParameters<R>>
101
+ rebind: RouteMethod<this, RouteParameters<R>>
102
+ report: RouteMethod<this, RouteParameters<R>>
103
+ search: RouteMethod<this, RouteParameters<R>>
104
+ source: RouteMethod<this, RouteParameters<R>>
105
+ subscribe: RouteMethod<this, RouteParameters<R>>
106
+ trace: RouteMethod<this, RouteParameters<R>>
107
+ unbind: RouteMethod<this, RouteParameters<R>>
108
+ unlink: RouteMethod<this, RouteParameters<R>>
109
+ unlock: RouteMethod<this, RouteParameters<R>>
110
+ unsubscribe: RouteMethod<this, RouteParameters<R>>
111
+ }
112
+
113
+ interface RouteConstructor {
114
+ new <R extends Path>(path: R): Route<R>
115
+ }
116
+ }
117
+
118
+ export = Route
@@ -69,21 +69,27 @@ Route.prototype._handlesMethod = function _handlesMethod (method) {
69
69
  }
70
70
 
71
71
  /**
72
+ * @param {boolean} [includeAll=false] include a wildcard for `.all()` handlers
72
73
  * @return {array} supported HTTP methods
73
74
  * @private
74
75
  */
75
76
 
76
- Route.prototype._methods = function _methods () {
77
- const methods = Object.keys(this.methods)
77
+ Route.prototype._methods = function _methods (includeAll) {
78
+ const methods = []
78
79
 
79
- // append automatic head
80
- if (this.methods.get && !this.methods.head) {
81
- methods.push('head')
80
+ for (const method of Object.keys(this.methods)) {
81
+ if (method === '_all') {
82
+ if (includeAll) {
83
+ methods.push('*')
84
+ }
85
+ } else {
86
+ methods.push(method.toUpperCase())
87
+ }
82
88
  }
83
89
 
84
- for (let i = 0; i < methods.length; i++) {
85
- // make upper case
86
- methods[i] = methods[i].toUpperCase()
90
+ // append automatic head
91
+ if (this.methods.get && !this.methods.head) {
92
+ methods.push('HEAD')
87
93
  }
88
94
 
89
95
  return methods
@@ -0,0 +1,4 @@
1
+ 'use strict'
2
+
3
+ // Shared by matching, tracing, and router state restoration within this copy.
4
+ exports.matchedRoute = Symbol('router.tracing.matchedRoute')
@@ -0,0 +1,173 @@
1
+ /*!
2
+ * router
3
+ * MIT Licensed
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const dc = require('node:diagnostics_channel')
9
+ const isPromise = require('is-promise')
10
+ const callParam = require('./param')
11
+
12
+ const requestChannel = dc.tracingChannel && dc.tracingChannel('express.router.request')
13
+
14
+ // Share error identity tracking across callbacks and router boundaries. Keep
15
+ // the registered symbol compatible with separately installed copies of router.
16
+ const seenErrors = Symbol.for('router.tracing.publishedErrors')
17
+
18
+ exports.publishEnd = publishEnd
19
+ exports.recordError = recordError
20
+ exports.recordThrown = recordThrown
21
+ exports.requestChannel = requestChannel
22
+ exports.shouldTrace = shouldTrace
23
+ exports.traceAsyncEnd = traceAsyncEnd
24
+ exports.traceParam = traceParam
25
+ exports.wrapNext = wrapNext
26
+
27
+ // TracingChannel#hasSubscribers is undefined before Node 20.13/22.
28
+ function shouldTrace (ch) {
29
+ return Boolean(ch) && (
30
+ ch.start.hasSubscribers ||
31
+ ch.end.hasSubscribers ||
32
+ ch.asyncStart.hasSubscribers ||
33
+ ch.asyncEnd.hasSubscribers ||
34
+ ch.error.hasSubscribers
35
+ )
36
+ }
37
+
38
+ // Remember errors already observed, including those from untraced code or
39
+ // route matching. Only the first report from a traced invocation is published.
40
+ function recordError (req, err) {
41
+ if (!err || isRoutingSignal(err)) return false
42
+
43
+ let seen = req[seenErrors]
44
+ if (!seen) {
45
+ seen = req[seenErrors] = new Set()
46
+ } else if (seen.has(err)) {
47
+ return false
48
+ }
49
+ seen.add(err)
50
+ return true
51
+ }
52
+
53
+ /**
54
+ * `'route'` and `'router'` are routing signals, not errors.
55
+ */
56
+ function isRoutingSignal (err) {
57
+ return err === 'route' || err === 'router'
58
+ }
59
+
60
+ /**
61
+ * Record a throw or rejection on the context. A rethrown error isn't published
62
+ * again, but the terminal event still needs it. A routing signal isn't an
63
+ * error, so a sync one finishes like calling next('route') and returning.
64
+ */
65
+ function recordThrown (ctx, err, sync) {
66
+ if (isRoutingSignal(err)) {
67
+ if (sync) ctx.result = undefined
68
+
69
+ return
70
+ }
71
+ if (!('error' in ctx)) ctx.error = err
72
+ }
73
+
74
+ /**
75
+ * Forget an error an error handler has dealt with, so a later report of the
76
+ * same object is published again.
77
+ */
78
+ function forgetError (req, err) {
79
+ const seen = req[seenErrors]
80
+ if (seen) seen.delete(err)
81
+ }
82
+
83
+ function wrapNext (ctx, next) {
84
+ // An error received by an error handler did not originate there, even if
85
+ // tracing was disabled at its origin. A replacement error is still reported.
86
+ if (ctx.errorHandler) recordError(ctx.req, ctx.incomingError)
87
+
88
+ return function wrappedNext (err) {
89
+ // An error handler that recovers or replaces the error has handled it, so
90
+ // the same object reported later in the request is a new failure.
91
+ if (ctx.errorHandler && err !== ctx.incomingError) forgetError(ctx.req, ctx.incomingError)
92
+ // Routing signals aren't errors. Report a real error once, at its origin,
93
+ // before forwarding it to another callback, layer or enclosing router.
94
+ if (err && recordError(ctx.req, err)) {
95
+ ctx.error = err
96
+ requestChannel.error.publish(ctx)
97
+ }
98
+ next(err)
99
+ }
100
+ }
101
+
102
+ // An error reported before a promise is returned is published before `end`, so
103
+ // it's hidden during `end` to keep `result` or `error` there meaning done.
104
+ function publishEnd (ctx, async) {
105
+ if (!async || !('error' in ctx)) return requestChannel.end.publish(ctx)
106
+
107
+ const error = ctx.error
108
+ delete ctx.error
109
+ requestChannel.end.publish(ctx)
110
+ ctx.error = error
111
+ }
112
+
113
+ function traceAsyncEnd (ctx) {
114
+ // Scope completion to asyncStart's bound stores without scheduling more work.
115
+ requestChannel.asyncStart.runStores(ctx, publishAsyncEnd, null, ctx)
116
+ }
117
+
118
+ function publishAsyncEnd (ctx) {
119
+ requestChannel.asyncEnd.publish(ctx)
120
+ }
121
+
122
+ // Wrap the shared parameter invocation with its tracing context and lifecycle.
123
+ function traceParam (fn, ctx, next, value, name) {
124
+ const wrappedNext = wrapNext(ctx, next)
125
+ let async = false
126
+ let ended = false
127
+ let settled = false
128
+ let early
129
+
130
+ requestChannel.start.runStores(ctx, function () {
131
+ try {
132
+ callParam(invoke, ctx.req, ctx.res, wrappedNext, value, name, settle)
133
+ } finally {
134
+ publishEnd(ctx, async)
135
+ ended = true
136
+ if (early) early()
137
+ }
138
+ })
139
+
140
+ // Same as layers, a throw skips the assignment so no result is set
141
+ function invoke (req, res, next, value, name) {
142
+ let ret
143
+ try {
144
+ ret = fn(req, res, next, value, name)
145
+ } catch (err) {
146
+ recordThrown(ctx, err, true)
147
+ throw err
148
+ }
149
+ async = isPromise(ret)
150
+ if (!async) ctx.result = ret
151
+
152
+ return ret
153
+ }
154
+
155
+ function settle (value, rejected) {
156
+ // Same as tracePromise, only the first outcome settles the trace
157
+ if (settled) return
158
+ settled = true
159
+ // Same as layers, a thenable that settles synchronously still settles after `end`
160
+ if (!ended) {
161
+ early = function () { finish(value, rejected) }
162
+
163
+ return
164
+ }
165
+ finish(value, rejected)
166
+ }
167
+
168
+ function finish (value, rejected) {
169
+ if (!rejected) ctx.result = value
170
+ else recordThrown(ctx, value, false)
171
+ traceAsyncEnd(ctx)
172
+ }
173
+ }
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "router",
3
3
  "description": "Simple middleware-style router",
4
- "version": "2.2.0",
4
+ "version": "2.3.0",
5
5
  "author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
6
6
  "contributors": [
7
7
  "Blake Embrey <hello@blakeembrey.com>"
8
8
  ],
9
9
  "license": "MIT",
10
10
  "repository": "pillarjs/router",
11
+ "type": "commonjs",
12
+ "main": "index.js",
13
+ "types": "index.d.ts",
14
+ "funding": {
15
+ "type": "opencollective",
16
+ "url": "https://opencollective.com/express"
17
+ },
11
18
  "dependencies": {
12
19
  "debug": "^4.4.0",
13
20
  "depd": "^2.0.0",
@@ -16,29 +23,37 @@
16
23
  "path-to-regexp": "^8.0.0"
17
24
  },
18
25
  "devDependencies": {
26
+ "@arethetypeswrong/cli": "0.18.5",
27
+ "@tsconfig/node18": "18.2.7",
28
+ "@types/node": "18.19.130",
29
+ "eslint": "^9.0.0",
19
30
  "finalhandler": "^2.1.0",
20
- "mocha": "10.2.0",
31
+ "expect-type": "1.4.0",
32
+ "mocha": "10.8.2",
33
+ "neostandard": "^0.14.1",
21
34
  "nyc": "15.1.0",
22
35
  "run-series": "^1.1.9",
23
- "standard": "^17.1.0",
24
- "supertest": "6.3.3"
36
+ "supertest": "6.3.3",
37
+ "typescript": "5.9.3"
25
38
  },
26
39
  "files": [
27
40
  "lib/",
28
41
  "LICENSE",
29
42
  "HISTORY.md",
30
43
  "README.md",
31
- "index.js"
44
+ "index.js",
45
+ "index.d.ts"
32
46
  ],
33
47
  "engines": {
34
48
  "node": ">= 18"
35
49
  },
36
50
  "scripts": {
37
- "lint": "standard",
38
- "test": "mocha --reporter spec --bail --check-leaks test/",
39
- "test:debug": "mocha --reporter spec --bail --check-leaks test/ --inspect --inspect-brk",
51
+ "lint": "eslint .",
52
+ "test": "mocha --reporter spec --check-leaks test/",
53
+ "test:debug": "mocha --reporter spec --check-leaks test/ --inspect --inspect-brk",
40
54
  "test-ci": "nyc --reporter=lcov --reporter=text npm test",
41
55
  "test-cov": "nyc --reporter=text npm test",
42
- "version": "node scripts/version-history.js && git add HISTORY.md"
56
+ "version": "node scripts/version-history.js && git add HISTORY.md",
57
+ "test-types": "tsc --noEmit && tsc -p test/types/tsconfig.augmentation.json && attw --pack"
43
58
  }
44
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "7.15.16",
3
+ "version": "7.15.18",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -32,10 +32,10 @@
32
32
  "@opentelemetry/api": "1.9.0",
33
33
  "@opentelemetry/api-logs": "0.220.0",
34
34
  "@swc/core": "1.10.18",
35
- "@zuplo/core": "7.15.16",
35
+ "@zuplo/core": "7.15.18",
36
36
  "@zuplo/editor": "1.0.39603386871",
37
- "@zuplo/openapi-tools": "7.15.16",
38
- "@zuplo/runtime": "7.15.16",
37
+ "@zuplo/openapi-tools": "7.15.18",
38
+ "@zuplo/runtime": "7.15.18",
39
39
  "chalk": "5.4.1",
40
40
  "chokidar": "3.5.3",
41
41
  "cookie": "1.0.2",
@@ -66,15 +66,15 @@
66
66
  "workerd": "1.20261002.1",
67
67
  "yargs": "17.7.2",
68
68
  "zod": "4.6.7",
69
- "@zuplo/graphql": "7.15.16",
70
- "@zuplo/otel": "7.15.16"
69
+ "@zuplo/graphql": "7.15.18",
70
+ "@zuplo/otel": "7.15.18"
71
71
  },
72
72
  "optionalDependencies": {
73
- "@zuplo/lint-darwin-arm64": "7.15.16",
74
- "@zuplo/lint-darwin-x64": "7.15.16",
75
- "@zuplo/lint-linux-x64": "7.15.16",
76
- "@zuplo/lint-linux-arm64": "7.15.16",
77
- "@zuplo/lint-win32-x64": "7.15.16"
73
+ "@zuplo/lint-darwin-arm64": "7.15.18",
74
+ "@zuplo/lint-darwin-x64": "7.15.18",
75
+ "@zuplo/lint-linux-x64": "7.15.18",
76
+ "@zuplo/lint-linux-arm64": "7.15.18",
77
+ "@zuplo/lint-win32-x64": "7.15.18"
78
78
  },
79
79
  "bundleDependencies": [
80
80
  "@inquirer/prompts",