@highstate/designer 0.4.2 → 0.4.3
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/.output/nitro.json +15 -0
- package/.output/public/_nuxt/B-YqONwZ.js +1 -0
- package/.output/public/_nuxt/COXQCz2I.js +1 -0
- package/.output/public/_nuxt/DNF_Kfc9.js +1 -0
- package/.output/public/_nuxt/DYyPqv2f.js +164 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/83577d4c-8c1d-41fa-bec1-21181eaa9f33.json +1 -0
- package/.output/public/_nuxt/entry.BSAdMt6G.css +5 -0
- package/.output/public/_nuxt/error-404.BJkSn6RI.css +1 -0
- package/.output/public/_nuxt/error-500.TOCKLquH.css +1 -0
- package/.output/public/favicon.ico +0 -0
- package/.output/public/robots.txt +1 -0
- package/.output/server/index.mjs +12266 -0
- package/.output/server/index.mjs.map +1 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14183 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@trpc/server/dist/http.mjs +7 -0
- package/.output/server/node_modules/@trpc/server/dist/index.mjs +11 -0
- package/.output/server/node_modules/@trpc/server/dist/observable/observable.mjs +175 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs +73 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/TRPCError.mjs +78 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/formatter.mjs +5 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/getErrorShape.mjs +29 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentType.mjs +224 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +12 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +76 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/isAbortError.mjs +7 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +39 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveResponse.mjs +569 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/initTRPC.mjs +80 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs +90 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/parser.mjs +40 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs +194 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/rootConfig.mjs +6 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs +176 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/rpc/codes.mjs +54 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.mjs +597 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.mjs +359 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/tracked.mjs +25 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +167 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +15 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +41 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +239 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.mjs +23 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/timerResource.mjs +23 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +127 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/transformer.mjs +101 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/utils.mjs +83 -0
- package/.output/server/node_modules/@trpc/server/dist/vendor/unpromise/unpromise.mjs +289 -0
- package/.output/server/node_modules/@trpc/server/package.json +156 -0
- package/.output/server/node_modules/@unhead/dom/dist/index.mjs +197 -0
- package/.output/server/node_modules/@unhead/dom/package.json +40 -0
- package/.output/server/node_modules/@unhead/shared/dist/index.mjs +641 -0
- package/.output/server/node_modules/@unhead/shared/package.json +45 -0
- package/.output/server/node_modules/@unhead/ssr/dist/index.mjs +95 -0
- package/.output/server/node_modules/@unhead/ssr/package.json +40 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6690 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +686 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1404 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1789 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6654 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1669 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +857 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +594 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +3 -0
- package/.output/server/node_modules/devalue/package.json +34 -0
- package/.output/server/node_modules/devalue/src/base64.js +110 -0
- package/.output/server/node_modules/devalue/src/constants.js +6 -0
- package/.output/server/node_modules/devalue/src/parse.js +160 -0
- package/.output/server/node_modules/devalue/src/stringify.js +232 -0
- package/.output/server/node_modules/devalue/src/uneval.js +351 -0
- package/.output/server/node_modules/devalue/src/utils.js +113 -0
- package/.output/server/node_modules/entities/lib/decode.js +536 -0
- package/.output/server/node_modules/entities/lib/decode_codepoint.js +76 -0
- package/.output/server/node_modules/entities/lib/generated/decode-data-html.js +9 -0
- package/.output/server/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
- package/.output/server/node_modules/entities/package.json +90 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +290 -0
- package/.output/server/node_modules/hookable/package.json +49 -0
- package/.output/server/node_modules/packrup/dist/index.mjs +108 -0
- package/.output/server/node_modules/packrup/package.json +58 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +630 -0
- package/.output/server/node_modules/ufo/package.json +47 -0
- package/.output/server/node_modules/unhead/dist/index.mjs +748 -0
- package/.output/server/node_modules/unhead/package.json +46 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +196 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +50 -0
- package/.output/server/node_modules/zod/lib/index.mjs +4382 -0
- package/.output/server/node_modules/zod/package.json +122 -0
- package/.output/server/package.json +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@babel/parser",
|
|
3
|
+
"version": "7.26.5",
|
|
4
|
+
"description": "A JavaScript parser",
|
|
5
|
+
"author": "The Babel Team (https://babel.dev/team)",
|
|
6
|
+
"homepage": "https://babel.dev/docs/en/next/babel-parser",
|
|
7
|
+
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"babel",
|
|
14
|
+
"javascript",
|
|
15
|
+
"parser",
|
|
16
|
+
"tc39",
|
|
17
|
+
"ecmascript",
|
|
18
|
+
"@babel/parser"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/babel/babel.git",
|
|
23
|
+
"directory": "packages/babel-parser"
|
|
24
|
+
},
|
|
25
|
+
"main": "./lib/index.js",
|
|
26
|
+
"types": "./typings/babel-parser.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"bin",
|
|
29
|
+
"lib",
|
|
30
|
+
"typings/babel-parser.d.ts",
|
|
31
|
+
"index.cjs"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=6.0.0"
|
|
35
|
+
},
|
|
36
|
+
"# dependencies": "This package doesn't actually have runtime dependencies. @babel/types is only needed for type definitions.",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@babel/types": "^7.26.5"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/code-frame": "^7.26.2",
|
|
42
|
+
"@babel/helper-check-duplicate-nodes": "^7.25.9",
|
|
43
|
+
"@babel/helper-fixtures": "^7.26.0",
|
|
44
|
+
"@babel/helper-string-parser": "^7.25.9",
|
|
45
|
+
"@babel/helper-validator-identifier": "^7.25.9",
|
|
46
|
+
"charcodes": "^0.2.0"
|
|
47
|
+
},
|
|
48
|
+
"bin": "./bin/babel-parser.js",
|
|
49
|
+
"type": "commonjs"
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
|
|
2
|
+
export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
|
|
3
|
+
export { octetInputParser } from './unstable-core-do-not-import/http/contentTypeParsers.mjs';
|
|
4
|
+
export { resolveResponse } from './unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
5
|
+
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
6
|
+
import './vendor/unpromise/unpromise.mjs';
|
|
7
|
+
import './unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createFlatProxy as createTRPCFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
|
|
2
|
+
export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
3
|
+
export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
|
|
4
|
+
import './vendor/unpromise/unpromise.mjs';
|
|
5
|
+
import './unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
6
|
+
export { isTrackedEnvelope, sse, tracked } from './unstable-core-do-not-import/stream/tracked.mjs';
|
|
7
|
+
export { transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
|
|
8
|
+
export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
|
|
9
|
+
export { experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware } from './unstable-core-do-not-import/middleware.mjs';
|
|
10
|
+
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
11
|
+
export { callProcedure, callProcedure as callTRPCProcedure } from './unstable-core-do-not-import/router.mjs';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/** @public */ function isObservable(x) {
|
|
2
|
+
return typeof x === 'object' && x !== null && 'subscribe' in x;
|
|
3
|
+
}
|
|
4
|
+
/** @public */ function observable(subscribe) {
|
|
5
|
+
const self = {
|
|
6
|
+
subscribe (observer) {
|
|
7
|
+
let teardownRef = null;
|
|
8
|
+
let isDone = false;
|
|
9
|
+
let unsubscribed = false;
|
|
10
|
+
let teardownImmediately = false;
|
|
11
|
+
function unsubscribe() {
|
|
12
|
+
if (teardownRef === null) {
|
|
13
|
+
teardownImmediately = true;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (unsubscribed) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
unsubscribed = true;
|
|
20
|
+
if (typeof teardownRef === 'function') {
|
|
21
|
+
teardownRef();
|
|
22
|
+
} else if (teardownRef) {
|
|
23
|
+
teardownRef.unsubscribe();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
teardownRef = subscribe({
|
|
27
|
+
next (value) {
|
|
28
|
+
if (isDone) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
observer.next?.(value);
|
|
32
|
+
},
|
|
33
|
+
error (err) {
|
|
34
|
+
if (isDone) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
isDone = true;
|
|
38
|
+
observer.error?.(err);
|
|
39
|
+
unsubscribe();
|
|
40
|
+
},
|
|
41
|
+
complete () {
|
|
42
|
+
if (isDone) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
isDone = true;
|
|
46
|
+
observer.complete?.();
|
|
47
|
+
unsubscribe();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (teardownImmediately) {
|
|
51
|
+
unsubscribe();
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
unsubscribe
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
pipe (...operations) {
|
|
58
|
+
return operations.reduce(pipeReducer, self);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return self;
|
|
62
|
+
}
|
|
63
|
+
function pipeReducer(prev, fn) {
|
|
64
|
+
return fn(prev);
|
|
65
|
+
}
|
|
66
|
+
/** @internal */ function observableToPromise(observable) {
|
|
67
|
+
const ac = new AbortController();
|
|
68
|
+
const promise = new Promise((resolve, reject)=>{
|
|
69
|
+
let isDone = false;
|
|
70
|
+
function onDone() {
|
|
71
|
+
if (isDone) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
isDone = true;
|
|
75
|
+
obs$.unsubscribe();
|
|
76
|
+
}
|
|
77
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
78
|
+
reject(ac.signal.reason);
|
|
79
|
+
});
|
|
80
|
+
const obs$ = observable.subscribe({
|
|
81
|
+
next (data) {
|
|
82
|
+
isDone = true;
|
|
83
|
+
resolve(data);
|
|
84
|
+
onDone();
|
|
85
|
+
},
|
|
86
|
+
error (data) {
|
|
87
|
+
reject(data);
|
|
88
|
+
},
|
|
89
|
+
complete () {
|
|
90
|
+
ac.abort();
|
|
91
|
+
onDone();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
return promise;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/ function observableToReadableStream(observable, signal) {
|
|
100
|
+
let unsub = null;
|
|
101
|
+
const onAbort = ()=>{
|
|
102
|
+
unsub?.unsubscribe();
|
|
103
|
+
unsub = null;
|
|
104
|
+
signal.removeEventListener('abort', onAbort);
|
|
105
|
+
};
|
|
106
|
+
return new ReadableStream({
|
|
107
|
+
start (controller) {
|
|
108
|
+
unsub = observable.subscribe({
|
|
109
|
+
next (data) {
|
|
110
|
+
controller.enqueue({
|
|
111
|
+
ok: true,
|
|
112
|
+
value: data
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
error (error) {
|
|
116
|
+
controller.enqueue({
|
|
117
|
+
ok: false,
|
|
118
|
+
error
|
|
119
|
+
});
|
|
120
|
+
controller.close();
|
|
121
|
+
},
|
|
122
|
+
complete () {
|
|
123
|
+
controller.close();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (signal.aborted) {
|
|
127
|
+
onAbort();
|
|
128
|
+
} else {
|
|
129
|
+
signal.addEventListener('abort', onAbort, {
|
|
130
|
+
once: true
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
cancel () {
|
|
135
|
+
onAbort();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** @internal */ function observableToAsyncIterable(observable, signal) {
|
|
140
|
+
const stream = observableToReadableStream(observable, signal);
|
|
141
|
+
const reader = stream.getReader();
|
|
142
|
+
const iterator = {
|
|
143
|
+
async next () {
|
|
144
|
+
const value = await reader.read();
|
|
145
|
+
if (value.done) {
|
|
146
|
+
return {
|
|
147
|
+
value: undefined,
|
|
148
|
+
done: true
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const { value: result } = value;
|
|
152
|
+
if (!result.ok) {
|
|
153
|
+
throw result.error;
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
value: result.value,
|
|
157
|
+
done: false
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
async return () {
|
|
161
|
+
await reader.cancel();
|
|
162
|
+
return {
|
|
163
|
+
value: undefined,
|
|
164
|
+
done: true
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
[Symbol.asyncIterator] () {
|
|
170
|
+
return iterator;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export { isObservable, observable, observableToAsyncIterable, observableToPromise };
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const noop = ()=>{
|
|
2
|
+
// noop
|
|
3
|
+
};
|
|
4
|
+
const freezeIfAvailable = (obj)=>{
|
|
5
|
+
if (Object.freeze) {
|
|
6
|
+
Object.freeze(obj);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function createInnerProxy(callback, path, memo) {
|
|
10
|
+
var _memo, _cacheKey;
|
|
11
|
+
const cacheKey = path.join('.');
|
|
12
|
+
(_memo = memo)[_cacheKey = cacheKey] ?? (_memo[_cacheKey] = new Proxy(noop, {
|
|
13
|
+
get (_obj, key) {
|
|
14
|
+
if (typeof key !== 'string' || key === 'then') {
|
|
15
|
+
// special case for if the proxy is accidentally treated
|
|
16
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return createInnerProxy(callback, [
|
|
20
|
+
...path,
|
|
21
|
+
key
|
|
22
|
+
], memo);
|
|
23
|
+
},
|
|
24
|
+
apply (_1, _2, args) {
|
|
25
|
+
const lastOfPath = path[path.length - 1];
|
|
26
|
+
let opts = {
|
|
27
|
+
args,
|
|
28
|
+
path
|
|
29
|
+
};
|
|
30
|
+
// special handling for e.g. `trpc.hello.call(this, 'there')` and `trpc.hello.apply(this, ['there'])
|
|
31
|
+
if (lastOfPath === 'call') {
|
|
32
|
+
opts = {
|
|
33
|
+
args: args.length >= 2 ? [
|
|
34
|
+
args[1]
|
|
35
|
+
] : [],
|
|
36
|
+
path: path.slice(0, -1)
|
|
37
|
+
};
|
|
38
|
+
} else if (lastOfPath === 'apply') {
|
|
39
|
+
opts = {
|
|
40
|
+
args: args.length >= 2 ? args[1] : [],
|
|
41
|
+
path: path.slice(0, -1)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
freezeIfAvailable(opts.args);
|
|
45
|
+
freezeIfAvailable(opts.path);
|
|
46
|
+
return callback(opts);
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
return memo[cacheKey];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
|
|
56
|
+
/**
|
|
57
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/ const createFlatProxy = (callback)=>{
|
|
61
|
+
return new Proxy(noop, {
|
|
62
|
+
get (_obj, name) {
|
|
63
|
+
if (typeof name !== 'string' || name === 'then') {
|
|
64
|
+
// special case for if the proxy is accidentally treated
|
|
65
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return callback(name);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { createFlatProxy, createRecursiveProxy };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { isObject } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) {
|
|
5
|
+
Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
} else {
|
|
12
|
+
obj[key] = value;
|
|
13
|
+
}
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
class UnknownCauseError extends Error {
|
|
17
|
+
}
|
|
18
|
+
function getCauseFromUnknown(cause) {
|
|
19
|
+
if (cause instanceof Error) {
|
|
20
|
+
return cause;
|
|
21
|
+
}
|
|
22
|
+
const type = typeof cause;
|
|
23
|
+
if (type === 'undefined' || type === 'function' || cause === null) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
// Primitive types just get wrapped in an error
|
|
27
|
+
if (type !== 'object') {
|
|
28
|
+
return new Error(String(cause));
|
|
29
|
+
}
|
|
30
|
+
// If it's an object, we'll create a synthetic error
|
|
31
|
+
if (isObject(cause)) {
|
|
32
|
+
const err = new UnknownCauseError();
|
|
33
|
+
for(const key in cause){
|
|
34
|
+
err[key] = cause[key];
|
|
35
|
+
}
|
|
36
|
+
return err;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function getTRPCErrorFromUnknown(cause) {
|
|
41
|
+
if (cause instanceof TRPCError) {
|
|
42
|
+
return cause;
|
|
43
|
+
}
|
|
44
|
+
if (cause instanceof Error && cause.name === 'TRPCError') {
|
|
45
|
+
// https://github.com/trpc/trpc/pull/4848
|
|
46
|
+
return cause;
|
|
47
|
+
}
|
|
48
|
+
const trpcError = new TRPCError({
|
|
49
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
50
|
+
cause
|
|
51
|
+
});
|
|
52
|
+
// Inherit stack from error
|
|
53
|
+
if (cause instanceof Error && cause.stack) {
|
|
54
|
+
trpcError.stack = cause.stack;
|
|
55
|
+
}
|
|
56
|
+
return trpcError;
|
|
57
|
+
}
|
|
58
|
+
class TRPCError extends Error {
|
|
59
|
+
constructor(opts){
|
|
60
|
+
const cause = getCauseFromUnknown(opts.cause);
|
|
61
|
+
const message = opts.message ?? cause?.message ?? opts.code;
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
+
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
64
|
+
super(message, {
|
|
65
|
+
cause
|
|
66
|
+
}), // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
67
|
+
// @ts-ignore override doesn't work in all environments due to "This member cannot have an 'override' modifier because it is not declared in the base class 'Error'"
|
|
68
|
+
_define_property(this, "cause", void 0), _define_property(this, "code", void 0);
|
|
69
|
+
this.code = opts.code;
|
|
70
|
+
this.name = 'TRPCError';
|
|
71
|
+
if (!this.cause) {
|
|
72
|
+
// < ES2022 / < Node 16.9.0 compatability
|
|
73
|
+
this.cause = cause;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getHTTPStatusCodeFromError } from '../http/getHTTPStatusCode.mjs';
|
|
2
|
+
import { TRPC_ERROR_CODES_BY_KEY } from '../rpc/codes.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/ function getErrorShape(opts) {
|
|
7
|
+
const { path, error, config } = opts;
|
|
8
|
+
const { code } = opts.error;
|
|
9
|
+
const shape = {
|
|
10
|
+
message: error.message,
|
|
11
|
+
code: TRPC_ERROR_CODES_BY_KEY[code],
|
|
12
|
+
data: {
|
|
13
|
+
code,
|
|
14
|
+
httpStatus: getHTTPStatusCodeFromError(error)
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
if (config.isDev && typeof opts.error.stack === 'string') {
|
|
18
|
+
shape.data.stack = opts.error.stack;
|
|
19
|
+
}
|
|
20
|
+
if (typeof path === 'string') {
|
|
21
|
+
shape.data.path = path;
|
|
22
|
+
}
|
|
23
|
+
return config.errorFormatter({
|
|
24
|
+
...opts,
|
|
25
|
+
shape
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { getErrorShape };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { TRPCError } from '../error/TRPCError.mjs';
|
|
2
|
+
import { isObject, unsetMarker } from '../utils.mjs';
|
|
3
|
+
import { parseConnectionParamsFromString } from './parseConnectionParams.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Memoize a function that takes no arguments
|
|
7
|
+
* @internal
|
|
8
|
+
*/ function memo(fn) {
|
|
9
|
+
let promise = null;
|
|
10
|
+
let value = unsetMarker;
|
|
11
|
+
return {
|
|
12
|
+
/**
|
|
13
|
+
* Lazily read the value
|
|
14
|
+
*/ read: async ()=>{
|
|
15
|
+
if (value !== unsetMarker) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if (promise === null) {
|
|
19
|
+
// dedupes promises and catches errors
|
|
20
|
+
promise = fn().catch((cause)=>{
|
|
21
|
+
if (cause instanceof TRPCError) {
|
|
22
|
+
throw cause;
|
|
23
|
+
}
|
|
24
|
+
throw new TRPCError({
|
|
25
|
+
code: 'BAD_REQUEST',
|
|
26
|
+
message: cause instanceof Error ? cause.message : 'Invalid input',
|
|
27
|
+
cause
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
value = await promise;
|
|
32
|
+
promise = null;
|
|
33
|
+
return value;
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Get an already stored result
|
|
37
|
+
*/ result: ()=>{
|
|
38
|
+
return value !== unsetMarker ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const jsonContentTypeHandler = {
|
|
43
|
+
isMatch (req) {
|
|
44
|
+
return !!req.headers.get('content-type')?.startsWith('application/json');
|
|
45
|
+
},
|
|
46
|
+
parse (opts) {
|
|
47
|
+
const { req } = opts;
|
|
48
|
+
const isBatchCall = opts.searchParams.get('batch') === '1';
|
|
49
|
+
const paths = isBatchCall ? opts.path.split(',') : [
|
|
50
|
+
opts.path
|
|
51
|
+
];
|
|
52
|
+
const getInputs = memo(async ()=>{
|
|
53
|
+
let inputs = undefined;
|
|
54
|
+
if (req.method === 'GET') {
|
|
55
|
+
const queryInput = opts.searchParams.get('input');
|
|
56
|
+
if (queryInput) {
|
|
57
|
+
inputs = JSON.parse(queryInput);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
inputs = await req.json();
|
|
61
|
+
}
|
|
62
|
+
if (inputs === undefined) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
if (!isBatchCall) {
|
|
66
|
+
return {
|
|
67
|
+
0: opts.router._def._config.transformer.input.deserialize(inputs)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (!isObject(inputs)) {
|
|
71
|
+
throw new TRPCError({
|
|
72
|
+
code: 'BAD_REQUEST',
|
|
73
|
+
message: '"input" needs to be an object when doing a batch call'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const acc = {};
|
|
77
|
+
for (const index of paths.keys()){
|
|
78
|
+
const input = inputs[index];
|
|
79
|
+
if (input !== undefined) {
|
|
80
|
+
acc[index] = opts.router._def._config.transformer.input.deserialize(input);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return acc;
|
|
84
|
+
});
|
|
85
|
+
const calls = paths.map((path, index)=>{
|
|
86
|
+
const procedure = opts.router._def.procedures[path] ?? null;
|
|
87
|
+
return {
|
|
88
|
+
path,
|
|
89
|
+
procedure,
|
|
90
|
+
getRawInput: async ()=>{
|
|
91
|
+
const inputs = await getInputs.read();
|
|
92
|
+
let input = inputs[index];
|
|
93
|
+
if (procedure?._def.type === 'subscription') {
|
|
94
|
+
const lastEventId = opts.headers.get('last-event-id') ?? opts.searchParams.get('lastEventId') ?? opts.searchParams.get('Last-Event-Id');
|
|
95
|
+
if (lastEventId) {
|
|
96
|
+
if (isObject(input)) {
|
|
97
|
+
input = {
|
|
98
|
+
...input,
|
|
99
|
+
lastEventId: lastEventId
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
input ?? (input = {
|
|
103
|
+
lastEventId: lastEventId
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return input;
|
|
109
|
+
},
|
|
110
|
+
result: ()=>{
|
|
111
|
+
return getInputs.result()?.[index];
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const types = new Set(calls.map((call)=>call.procedure?._def.type).filter(Boolean));
|
|
116
|
+
/* istanbul ignore if -- @preserve */ if (types.size > 1) {
|
|
117
|
+
throw new TRPCError({
|
|
118
|
+
code: 'BAD_REQUEST',
|
|
119
|
+
message: `Cannot mix procedure types in call: ${Array.from(types).join(', ')}`
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const type = types.values().next().value ?? 'unknown';
|
|
123
|
+
const connectionParamsStr = opts.searchParams.get('connectionParams');
|
|
124
|
+
const info = {
|
|
125
|
+
isBatchCall,
|
|
126
|
+
accept: req.headers.get('trpc-accept'),
|
|
127
|
+
calls,
|
|
128
|
+
type,
|
|
129
|
+
connectionParams: connectionParamsStr === null ? null : parseConnectionParamsFromString(connectionParamsStr),
|
|
130
|
+
signal: req.signal
|
|
131
|
+
};
|
|
132
|
+
return info;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const formDataContentTypeHandler = {
|
|
136
|
+
isMatch (req) {
|
|
137
|
+
return !!req.headers.get('content-type')?.startsWith('multipart/form-data');
|
|
138
|
+
},
|
|
139
|
+
parse (opts) {
|
|
140
|
+
const { req } = opts;
|
|
141
|
+
if (req.method !== 'POST') {
|
|
142
|
+
throw new TRPCError({
|
|
143
|
+
code: 'METHOD_NOT_SUPPORTED',
|
|
144
|
+
message: 'Only POST requests are supported for multipart/form-data requests'
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const getInputs = memo(async ()=>{
|
|
148
|
+
const fd = await req.formData();
|
|
149
|
+
return fd;
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
accept: null,
|
|
153
|
+
calls: [
|
|
154
|
+
{
|
|
155
|
+
path: opts.path,
|
|
156
|
+
getRawInput: getInputs.read,
|
|
157
|
+
result: getInputs.result,
|
|
158
|
+
procedure: opts.router._def.procedures[opts.path] ?? null
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
isBatchCall: false,
|
|
162
|
+
type: 'mutation',
|
|
163
|
+
connectionParams: null,
|
|
164
|
+
signal: req.signal
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const octetStreamContentTypeHandler = {
|
|
169
|
+
isMatch (req) {
|
|
170
|
+
return !!req.headers.get('content-type')?.startsWith('application/octet-stream');
|
|
171
|
+
},
|
|
172
|
+
parse (opts) {
|
|
173
|
+
const { req } = opts;
|
|
174
|
+
if (req.method !== 'POST') {
|
|
175
|
+
throw new TRPCError({
|
|
176
|
+
code: 'METHOD_NOT_SUPPORTED',
|
|
177
|
+
message: 'Only POST requests are supported for application/octet-stream requests'
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const getInputs = memo(async ()=>{
|
|
181
|
+
return req.body;
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
calls: [
|
|
185
|
+
{
|
|
186
|
+
path: opts.path,
|
|
187
|
+
getRawInput: getInputs.read,
|
|
188
|
+
result: getInputs.result,
|
|
189
|
+
procedure: opts.router._def.procedures[opts.path] ?? null
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
isBatchCall: false,
|
|
193
|
+
accept: null,
|
|
194
|
+
type: 'mutation',
|
|
195
|
+
connectionParams: null,
|
|
196
|
+
signal: req.signal
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const handlers = [
|
|
201
|
+
jsonContentTypeHandler,
|
|
202
|
+
formDataContentTypeHandler,
|
|
203
|
+
octetStreamContentTypeHandler
|
|
204
|
+
];
|
|
205
|
+
function getContentTypeHandler(req) {
|
|
206
|
+
const handler = handlers.find((handler)=>handler.isMatch(req));
|
|
207
|
+
if (handler) {
|
|
208
|
+
return handler;
|
|
209
|
+
}
|
|
210
|
+
if (!handler && req.method === 'GET') {
|
|
211
|
+
// fallback to JSON for get requests so GET-requests can be opened in browser easily
|
|
212
|
+
return jsonContentTypeHandler;
|
|
213
|
+
}
|
|
214
|
+
throw new TRPCError({
|
|
215
|
+
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
216
|
+
message: req.headers.has('content-type') ? `Unsupported content-type "${req.headers.get('content-type')}` : 'Missing content-type header'
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function getRequestInfo(opts) {
|
|
220
|
+
const handler = getContentTypeHandler(opts.req);
|
|
221
|
+
return handler.parse(opts);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { getRequestInfo };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const octetInputParser = {
|
|
2
|
+
_input: null,
|
|
3
|
+
_output: null,
|
|
4
|
+
parse (input) {
|
|
5
|
+
if (input instanceof ReadableStream) {
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { octetInputParser };
|