@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
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/initTRPC.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { defaultFormatter } from './error/formatter.mjs';
|
|
2
|
+
import { createMiddlewareFactory } from './middleware.mjs';
|
|
3
|
+
import { createBuilder } from './procedureBuilder.mjs';
|
|
4
|
+
import { isServerDefault } from './rootConfig.mjs';
|
|
5
|
+
import { createRouterFactory, mergeRouters, createCallerFactory } from './router.mjs';
|
|
6
|
+
import { getDataTransformer, defaultTransformer } from './transformer.mjs';
|
|
7
|
+
|
|
8
|
+
class TRPCBuilder {
|
|
9
|
+
/**
|
|
10
|
+
* Add a context shape as a generic to the root object
|
|
11
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
12
|
+
*/ context() {
|
|
13
|
+
return new TRPCBuilder();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Add a meta shape as a generic to the root object
|
|
17
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
18
|
+
*/ meta() {
|
|
19
|
+
return new TRPCBuilder();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create the root object
|
|
23
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
24
|
+
*/ create(opts) {
|
|
25
|
+
const config = {
|
|
26
|
+
...opts,
|
|
27
|
+
transformer: getDataTransformer(opts?.transformer ?? defaultTransformer),
|
|
28
|
+
isDev: opts?.isDev ?? // eslint-disable-next-line @typescript-eslint/dot-notation
|
|
29
|
+
globalThis.process?.env['NODE_ENV'] !== 'production',
|
|
30
|
+
allowOutsideOfServer: opts?.allowOutsideOfServer ?? false,
|
|
31
|
+
errorFormatter: opts?.errorFormatter ?? defaultFormatter,
|
|
32
|
+
isServer: opts?.isServer ?? isServerDefault,
|
|
33
|
+
/**
|
|
34
|
+
* These are just types, they can't be used at runtime
|
|
35
|
+
* @internal
|
|
36
|
+
*/ $types: null
|
|
37
|
+
};
|
|
38
|
+
{
|
|
39
|
+
// Server check
|
|
40
|
+
const isServer = opts?.isServer ?? isServerDefault;
|
|
41
|
+
if (!isServer && opts?.allowOutsideOfServer !== true) {
|
|
42
|
+
throw new Error(`You're trying to use @trpc/server in a non-server environment. This is not supported by default.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
/**
|
|
47
|
+
* Your router config
|
|
48
|
+
* @internal
|
|
49
|
+
*/ _config: config,
|
|
50
|
+
/**
|
|
51
|
+
* Builder object for creating procedures
|
|
52
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
53
|
+
*/ procedure: createBuilder({
|
|
54
|
+
meta: opts?.defaultMeta
|
|
55
|
+
}),
|
|
56
|
+
/**
|
|
57
|
+
* Create reusable middlewares
|
|
58
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
59
|
+
*/ middleware: createMiddlewareFactory(),
|
|
60
|
+
/**
|
|
61
|
+
* Create a router
|
|
62
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
63
|
+
*/ router: createRouterFactory(config),
|
|
64
|
+
/**
|
|
65
|
+
* Merge Routers
|
|
66
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
67
|
+
*/ mergeRouters,
|
|
68
|
+
/**
|
|
69
|
+
* Create a server-side caller for a router
|
|
70
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
71
|
+
*/ createCallerFactory: createCallerFactory()
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
77
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
78
|
+
*/ const initTRPC = new TRPCBuilder();
|
|
79
|
+
|
|
80
|
+
export { initTRPC };
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TRPCError } from './error/TRPCError.mjs';
|
|
2
|
+
import { isObject } from './utils.mjs';
|
|
3
|
+
|
|
4
|
+
/** @internal */ const middlewareMarker = 'middlewareMarker';
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/ function createMiddlewareFactory() {
|
|
8
|
+
function createMiddlewareInner(middlewares) {
|
|
9
|
+
return {
|
|
10
|
+
_middlewares: middlewares,
|
|
11
|
+
unstable_pipe (middlewareBuilderOrFn) {
|
|
12
|
+
const pipedMiddleware = '_middlewares' in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [
|
|
13
|
+
middlewareBuilderOrFn
|
|
14
|
+
];
|
|
15
|
+
return createMiddlewareInner([
|
|
16
|
+
...middlewares,
|
|
17
|
+
...pipedMiddleware
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function createMiddleware(fn) {
|
|
23
|
+
return createMiddlewareInner([
|
|
24
|
+
fn
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
return createMiddleware;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a standalone middleware
|
|
31
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
32
|
+
* @deprecated use `.unstable_concat()` instead
|
|
33
|
+
*/ const experimental_standaloneMiddleware = ()=>({
|
|
34
|
+
create: createMiddlewareFactory()
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
* Please note, `trpc-openapi` uses this function.
|
|
39
|
+
*/ function createInputMiddleware(parse) {
|
|
40
|
+
const inputMiddleware = async function inputValidatorMiddleware(opts) {
|
|
41
|
+
let parsedInput;
|
|
42
|
+
const rawInput = await opts.getRawInput();
|
|
43
|
+
try {
|
|
44
|
+
parsedInput = await parse(rawInput);
|
|
45
|
+
} catch (cause) {
|
|
46
|
+
throw new TRPCError({
|
|
47
|
+
code: 'BAD_REQUEST',
|
|
48
|
+
cause
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Multiple input parsers
|
|
52
|
+
const combinedInput = isObject(opts.input) && isObject(parsedInput) ? {
|
|
53
|
+
...opts.input,
|
|
54
|
+
...parsedInput
|
|
55
|
+
} : parsedInput;
|
|
56
|
+
return opts.next({
|
|
57
|
+
input: combinedInput
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
inputMiddleware._type = 'input';
|
|
61
|
+
return inputMiddleware;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/ function createOutputMiddleware(parse) {
|
|
66
|
+
const outputMiddleware = async function outputValidatorMiddleware({ next }) {
|
|
67
|
+
const result = await next();
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
// pass through failures without validating
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const data = await parse(result.data);
|
|
74
|
+
return {
|
|
75
|
+
...result,
|
|
76
|
+
data
|
|
77
|
+
};
|
|
78
|
+
} catch (cause) {
|
|
79
|
+
throw new TRPCError({
|
|
80
|
+
message: 'Output validation failed',
|
|
81
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
82
|
+
cause
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
outputMiddleware._type = 'output';
|
|
87
|
+
return outputMiddleware;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { createInputMiddleware, createMiddlewareFactory, createOutputMiddleware, experimental_standaloneMiddleware, middlewareMarker };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// zod / typeschema
|
|
2
|
+
function getParseFn(procedureParser) {
|
|
3
|
+
const parser = procedureParser;
|
|
4
|
+
if (typeof parser === 'function' && typeof parser.assert === 'function') {
|
|
5
|
+
// ParserArkTypeEsque - arktype schemas shouldn't be called as a function because they return a union type instead of throwing
|
|
6
|
+
return parser.assert.bind(parser);
|
|
7
|
+
}
|
|
8
|
+
if (typeof parser === 'function') {
|
|
9
|
+
// ParserValibotEsque (>= v0.31.0)
|
|
10
|
+
// ParserCustomValidatorEsque
|
|
11
|
+
return parser;
|
|
12
|
+
}
|
|
13
|
+
if (typeof parser.parseAsync === 'function') {
|
|
14
|
+
// ParserZodEsque
|
|
15
|
+
return parser.parseAsync.bind(parser);
|
|
16
|
+
}
|
|
17
|
+
if (typeof parser.parse === 'function') {
|
|
18
|
+
// ParserZodEsque
|
|
19
|
+
// ParserValibotEsque (< v0.13.0)
|
|
20
|
+
return parser.parse.bind(parser);
|
|
21
|
+
}
|
|
22
|
+
if (typeof parser.validateSync === 'function') {
|
|
23
|
+
// ParserYupEsque
|
|
24
|
+
return parser.validateSync.bind(parser);
|
|
25
|
+
}
|
|
26
|
+
if (typeof parser.create === 'function') {
|
|
27
|
+
// ParserSuperstructEsque
|
|
28
|
+
return parser.create.bind(parser);
|
|
29
|
+
}
|
|
30
|
+
if (typeof parser.assert === 'function') {
|
|
31
|
+
// ParserScaleEsque
|
|
32
|
+
return (value)=>{
|
|
33
|
+
parser.assert(value);
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
throw new Error('Could not find a validator fn');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { getParseFn };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { TRPCError, getTRPCErrorFromUnknown } from './error/TRPCError.mjs';
|
|
2
|
+
import { createInputMiddleware, createOutputMiddleware, middlewareMarker } from './middleware.mjs';
|
|
3
|
+
import { getParseFn } from './parser.mjs';
|
|
4
|
+
import { mergeWithoutOverrides } from './utils.mjs';
|
|
5
|
+
|
|
6
|
+
function createNewBuilder(def1, def2) {
|
|
7
|
+
const { middlewares = [], inputs, meta, ...rest } = def2;
|
|
8
|
+
// TODO: maybe have a fn here to warn about calls
|
|
9
|
+
return createBuilder({
|
|
10
|
+
...mergeWithoutOverrides(def1, rest),
|
|
11
|
+
inputs: [
|
|
12
|
+
...def1.inputs,
|
|
13
|
+
...inputs ?? []
|
|
14
|
+
],
|
|
15
|
+
middlewares: [
|
|
16
|
+
...def1.middlewares,
|
|
17
|
+
...middlewares
|
|
18
|
+
],
|
|
19
|
+
meta: def1.meta && meta ? {
|
|
20
|
+
...def1.meta,
|
|
21
|
+
...meta
|
|
22
|
+
} : meta ?? def1.meta
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function createBuilder(initDef = {}) {
|
|
26
|
+
const _def = {
|
|
27
|
+
procedure: true,
|
|
28
|
+
inputs: [],
|
|
29
|
+
middlewares: [],
|
|
30
|
+
...initDef
|
|
31
|
+
};
|
|
32
|
+
const builder = {
|
|
33
|
+
_def,
|
|
34
|
+
input (input) {
|
|
35
|
+
const parser = getParseFn(input);
|
|
36
|
+
return createNewBuilder(_def, {
|
|
37
|
+
inputs: [
|
|
38
|
+
input
|
|
39
|
+
],
|
|
40
|
+
middlewares: [
|
|
41
|
+
createInputMiddleware(parser)
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
output (output) {
|
|
46
|
+
const parser = getParseFn(output);
|
|
47
|
+
return createNewBuilder(_def, {
|
|
48
|
+
output,
|
|
49
|
+
middlewares: [
|
|
50
|
+
createOutputMiddleware(parser)
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
meta (meta) {
|
|
55
|
+
return createNewBuilder(_def, {
|
|
56
|
+
meta
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
use (middlewareBuilderOrFn) {
|
|
60
|
+
// Distinguish between a middleware builder and a middleware function
|
|
61
|
+
const middlewares = '_middlewares' in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [
|
|
62
|
+
middlewareBuilderOrFn
|
|
63
|
+
];
|
|
64
|
+
return createNewBuilder(_def, {
|
|
65
|
+
middlewares: middlewares
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
unstable_concat (builder) {
|
|
69
|
+
return createNewBuilder(_def, builder._def);
|
|
70
|
+
},
|
|
71
|
+
query (resolver) {
|
|
72
|
+
return createResolver({
|
|
73
|
+
..._def,
|
|
74
|
+
type: 'query'
|
|
75
|
+
}, resolver);
|
|
76
|
+
},
|
|
77
|
+
mutation (resolver) {
|
|
78
|
+
return createResolver({
|
|
79
|
+
..._def,
|
|
80
|
+
type: 'mutation'
|
|
81
|
+
}, resolver);
|
|
82
|
+
},
|
|
83
|
+
subscription (resolver) {
|
|
84
|
+
return createResolver({
|
|
85
|
+
..._def,
|
|
86
|
+
type: 'subscription'
|
|
87
|
+
}, resolver);
|
|
88
|
+
},
|
|
89
|
+
experimental_caller (caller) {
|
|
90
|
+
return createNewBuilder(_def, {
|
|
91
|
+
caller
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return builder;
|
|
96
|
+
}
|
|
97
|
+
function createResolver(_defIn, resolver) {
|
|
98
|
+
const finalBuilder = createNewBuilder(_defIn, {
|
|
99
|
+
resolver,
|
|
100
|
+
middlewares: [
|
|
101
|
+
async function resolveMiddleware(opts) {
|
|
102
|
+
const data = await resolver(opts);
|
|
103
|
+
return {
|
|
104
|
+
marker: middlewareMarker,
|
|
105
|
+
ok: true,
|
|
106
|
+
data,
|
|
107
|
+
ctx: opts.ctx
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
const _def = {
|
|
113
|
+
...finalBuilder._def,
|
|
114
|
+
type: _defIn.type,
|
|
115
|
+
experimental_caller: Boolean(finalBuilder._def.caller),
|
|
116
|
+
meta: finalBuilder._def.meta,
|
|
117
|
+
$types: null
|
|
118
|
+
};
|
|
119
|
+
const invoke = createProcedureCaller(finalBuilder._def);
|
|
120
|
+
const callerOverride = finalBuilder._def.caller;
|
|
121
|
+
if (!callerOverride) {
|
|
122
|
+
return invoke;
|
|
123
|
+
}
|
|
124
|
+
const callerWrapper = async (...args)=>{
|
|
125
|
+
return await callerOverride({
|
|
126
|
+
args,
|
|
127
|
+
invoke,
|
|
128
|
+
_def: _def
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
callerWrapper._def = _def;
|
|
132
|
+
return callerWrapper;
|
|
133
|
+
}
|
|
134
|
+
const codeblock = `
|
|
135
|
+
This is a client-only function.
|
|
136
|
+
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
137
|
+
`.trim();
|
|
138
|
+
// run the middlewares recursively with the resolver as the last one
|
|
139
|
+
async function callRecursive(index, _def, opts) {
|
|
140
|
+
try {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
142
|
+
const middleware = _def.middlewares[index];
|
|
143
|
+
const result = await middleware({
|
|
144
|
+
...opts,
|
|
145
|
+
meta: _def.meta,
|
|
146
|
+
input: opts.input,
|
|
147
|
+
next (_nextOpts) {
|
|
148
|
+
const nextOpts = _nextOpts;
|
|
149
|
+
return callRecursive(index + 1, _def, {
|
|
150
|
+
...opts,
|
|
151
|
+
ctx: nextOpts?.ctx ? {
|
|
152
|
+
...opts.ctx,
|
|
153
|
+
...nextOpts.ctx
|
|
154
|
+
} : opts.ctx,
|
|
155
|
+
input: nextOpts && 'input' in nextOpts ? nextOpts.input : opts.input,
|
|
156
|
+
getRawInput: nextOpts?.getRawInput ?? opts.getRawInput
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return result;
|
|
161
|
+
} catch (cause) {
|
|
162
|
+
return {
|
|
163
|
+
ok: false,
|
|
164
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
165
|
+
marker: middlewareMarker
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function createProcedureCaller(_def) {
|
|
170
|
+
async function procedure(opts) {
|
|
171
|
+
// is direct server-side call
|
|
172
|
+
if (!opts || !('getRawInput' in opts)) {
|
|
173
|
+
throw new Error(codeblock);
|
|
174
|
+
}
|
|
175
|
+
// there's always at least one "next" since we wrap this.resolver in a middleware
|
|
176
|
+
const result = await callRecursive(0, _def, opts);
|
|
177
|
+
if (!result) {
|
|
178
|
+
throw new TRPCError({
|
|
179
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
180
|
+
message: 'No result from middlewares - did you forget to `return next()`?'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!result.ok) {
|
|
184
|
+
// re-throw original error
|
|
185
|
+
throw result.error;
|
|
186
|
+
}
|
|
187
|
+
return result.data;
|
|
188
|
+
}
|
|
189
|
+
procedure._def = _def;
|
|
190
|
+
// FIXME typecast shouldn't be needed - fixittt
|
|
191
|
+
return procedure;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { createBuilder };
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/rootConfig.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default check to see if we're in a server
|
|
3
|
+
*/ const isServerDefault = typeof window === 'undefined' || 'Deno' in window || // eslint-disable-next-line @typescript-eslint/dot-notation
|
|
4
|
+
globalThis.process?.env?.['NODE_ENV'] === 'test' || !!globalThis.process?.env?.['JEST_WORKER_ID'] || !!globalThis.process?.env?.['VITEST_WORKER_ID'];
|
|
5
|
+
|
|
6
|
+
export { isServerDefault };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createRecursiveProxy } from './createProxy.mjs';
|
|
2
|
+
import { defaultFormatter } from './error/formatter.mjs';
|
|
3
|
+
import { TRPCError, getTRPCErrorFromUnknown } from './error/TRPCError.mjs';
|
|
4
|
+
import { defaultTransformer } from './transformer.mjs';
|
|
5
|
+
import { mergeWithoutOverrides, omitPrototype, isFunction } from './utils.mjs';
|
|
6
|
+
|
|
7
|
+
function isRouter(procedureOrRouter) {
|
|
8
|
+
return procedureOrRouter._def && 'router' in procedureOrRouter._def;
|
|
9
|
+
}
|
|
10
|
+
const emptyRouter = {
|
|
11
|
+
_ctx: null,
|
|
12
|
+
_errorShape: null,
|
|
13
|
+
_meta: null,
|
|
14
|
+
queries: {},
|
|
15
|
+
mutations: {},
|
|
16
|
+
subscriptions: {},
|
|
17
|
+
errorFormatter: defaultFormatter,
|
|
18
|
+
transformer: defaultTransformer
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Reserved words that can't be used as router or procedure names
|
|
22
|
+
*/ const reservedWords = [
|
|
23
|
+
/**
|
|
24
|
+
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
|
|
25
|
+
* since JS will think that `.then` is something that exists
|
|
26
|
+
*/ 'then',
|
|
27
|
+
/**
|
|
28
|
+
* `fn.call()` and `fn.apply()` are reserved words because otherwise we can't call a function using `.call` or `.apply`
|
|
29
|
+
*/ 'call',
|
|
30
|
+
'apply'
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/ function createRouterFactory(config) {
|
|
35
|
+
function createRouterInner(input) {
|
|
36
|
+
const reservedWordsUsed = new Set(Object.keys(input).filter((v)=>reservedWords.includes(v)));
|
|
37
|
+
if (reservedWordsUsed.size > 0) {
|
|
38
|
+
throw new Error('Reserved words used in `router({})` call: ' + Array.from(reservedWordsUsed).join(', '));
|
|
39
|
+
}
|
|
40
|
+
const procedures = omitPrototype({});
|
|
41
|
+
function step(from, path = []) {
|
|
42
|
+
const aggregate = omitPrototype({});
|
|
43
|
+
for (const [key, item] of Object.entries(from ?? {})){
|
|
44
|
+
if (isRouter(item)) {
|
|
45
|
+
aggregate[key] = step(item._def.record, [
|
|
46
|
+
...path,
|
|
47
|
+
key
|
|
48
|
+
]);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!isProcedure(item)) {
|
|
52
|
+
// RouterRecord
|
|
53
|
+
aggregate[key] = step(item, [
|
|
54
|
+
...path,
|
|
55
|
+
key
|
|
56
|
+
]);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const newPath = [
|
|
60
|
+
...path,
|
|
61
|
+
key
|
|
62
|
+
].join('.');
|
|
63
|
+
if (procedures[newPath]) {
|
|
64
|
+
throw new Error(`Duplicate key: ${newPath}`);
|
|
65
|
+
}
|
|
66
|
+
procedures[newPath] = item;
|
|
67
|
+
aggregate[key] = item;
|
|
68
|
+
}
|
|
69
|
+
return aggregate;
|
|
70
|
+
}
|
|
71
|
+
const record = step(input);
|
|
72
|
+
const _def = {
|
|
73
|
+
_config: config,
|
|
74
|
+
router: true,
|
|
75
|
+
procedures,
|
|
76
|
+
...emptyRouter,
|
|
77
|
+
record
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...record,
|
|
81
|
+
_def,
|
|
82
|
+
createCaller: createCallerFactory()({
|
|
83
|
+
_def
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return createRouterInner;
|
|
88
|
+
}
|
|
89
|
+
function isProcedure(procedureOrRouter) {
|
|
90
|
+
return typeof procedureOrRouter === 'function';
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/ function callProcedure(opts) {
|
|
95
|
+
const { type, path } = opts;
|
|
96
|
+
const proc = opts.procedures[path];
|
|
97
|
+
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
98
|
+
throw new TRPCError({
|
|
99
|
+
code: 'NOT_FOUND',
|
|
100
|
+
message: `No "${type}"-procedure on path "${path}"`
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/* istanbul ignore if -- @preserve */ if (proc._def.type !== type && opts.allowMethodOverride && proc._def.type === 'subscription') {
|
|
104
|
+
throw new TRPCError({
|
|
105
|
+
code: 'METHOD_NOT_SUPPORTED',
|
|
106
|
+
message: `Method override is not supported for subscriptions`
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return proc(opts);
|
|
110
|
+
}
|
|
111
|
+
function createCallerFactory() {
|
|
112
|
+
return function createCallerInner(router) {
|
|
113
|
+
const _def = router._def;
|
|
114
|
+
return function createCaller(ctxOrCallback, opts) {
|
|
115
|
+
return createRecursiveProxy(async ({ path, args })=>{
|
|
116
|
+
const fullPath = path.join('.');
|
|
117
|
+
if (path.length === 1 && path[0] === '_def') {
|
|
118
|
+
return _def;
|
|
119
|
+
}
|
|
120
|
+
const procedure = _def.procedures[fullPath];
|
|
121
|
+
let ctx = undefined;
|
|
122
|
+
try {
|
|
123
|
+
ctx = isFunction(ctxOrCallback) ? await Promise.resolve(ctxOrCallback()) : ctxOrCallback;
|
|
124
|
+
return await procedure({
|
|
125
|
+
path: fullPath,
|
|
126
|
+
getRawInput: async ()=>args[0],
|
|
127
|
+
ctx,
|
|
128
|
+
type: procedure._def.type,
|
|
129
|
+
signal: opts?.signal
|
|
130
|
+
});
|
|
131
|
+
} catch (cause) {
|
|
132
|
+
opts?.onError?.({
|
|
133
|
+
ctx,
|
|
134
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
135
|
+
input: args[0],
|
|
136
|
+
path: fullPath,
|
|
137
|
+
type: procedure._def.type
|
|
138
|
+
});
|
|
139
|
+
throw cause;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function mergeRouters(...routerList) {
|
|
146
|
+
const record = mergeWithoutOverrides({}, ...routerList.map((r)=>r._def.record));
|
|
147
|
+
const errorFormatter = routerList.reduce((currentErrorFormatter, nextRouter)=>{
|
|
148
|
+
if (nextRouter._def._config.errorFormatter && nextRouter._def._config.errorFormatter !== defaultFormatter) {
|
|
149
|
+
if (currentErrorFormatter !== defaultFormatter && currentErrorFormatter !== nextRouter._def._config.errorFormatter) {
|
|
150
|
+
throw new Error('You seem to have several error formatters');
|
|
151
|
+
}
|
|
152
|
+
return nextRouter._def._config.errorFormatter;
|
|
153
|
+
}
|
|
154
|
+
return currentErrorFormatter;
|
|
155
|
+
}, defaultFormatter);
|
|
156
|
+
const transformer = routerList.reduce((prev, current)=>{
|
|
157
|
+
if (current._def._config.transformer && current._def._config.transformer !== defaultTransformer) {
|
|
158
|
+
if (prev !== defaultTransformer && prev !== current._def._config.transformer) {
|
|
159
|
+
throw new Error('You seem to have several transformers');
|
|
160
|
+
}
|
|
161
|
+
return current._def._config.transformer;
|
|
162
|
+
}
|
|
163
|
+
return prev;
|
|
164
|
+
}, defaultTransformer);
|
|
165
|
+
const router = createRouterFactory({
|
|
166
|
+
errorFormatter,
|
|
167
|
+
transformer,
|
|
168
|
+
isDev: routerList.every((r)=>r._def._config.isDev),
|
|
169
|
+
allowOutsideOfServer: routerList.every((r)=>r._def._config.allowOutsideOfServer),
|
|
170
|
+
isServer: routerList.every((r)=>r._def._config.isServer),
|
|
171
|
+
$types: routerList[0]?._def._config.$types
|
|
172
|
+
})(record);
|
|
173
|
+
return router;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { callProcedure, createCallerFactory, createRouterFactory, mergeRouters };
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/rpc/codes.mjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// reference: https://www.jsonrpc.org/specification
|
|
2
|
+
/**
|
|
3
|
+
* JSON-RPC 2.0 Error codes
|
|
4
|
+
*
|
|
5
|
+
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
6
|
+
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
7
|
+
*/ const TRPC_ERROR_CODES_BY_KEY = {
|
|
8
|
+
/**
|
|
9
|
+
* Invalid JSON was received by the server.
|
|
10
|
+
* An error occurred on the server while parsing the JSON text.
|
|
11
|
+
*/ PARSE_ERROR: -32700,
|
|
12
|
+
/**
|
|
13
|
+
* The JSON sent is not a valid Request object.
|
|
14
|
+
*/ BAD_REQUEST: -32600,
|
|
15
|
+
// Internal JSON-RPC error
|
|
16
|
+
INTERNAL_SERVER_ERROR: -32603,
|
|
17
|
+
NOT_IMPLEMENTED: -32603,
|
|
18
|
+
BAD_GATEWAY: -32603,
|
|
19
|
+
SERVICE_UNAVAILABLE: -32603,
|
|
20
|
+
GATEWAY_TIMEOUT: -32603,
|
|
21
|
+
// Implementation specific errors
|
|
22
|
+
UNAUTHORIZED: -32001,
|
|
23
|
+
FORBIDDEN: -32003,
|
|
24
|
+
NOT_FOUND: -32004,
|
|
25
|
+
METHOD_NOT_SUPPORTED: -32005,
|
|
26
|
+
TIMEOUT: -32008,
|
|
27
|
+
CONFLICT: -32009,
|
|
28
|
+
PRECONDITION_FAILED: -32012,
|
|
29
|
+
PAYLOAD_TOO_LARGE: -32013,
|
|
30
|
+
UNSUPPORTED_MEDIA_TYPE: -32015,
|
|
31
|
+
UNPROCESSABLE_CONTENT: -32022,
|
|
32
|
+
TOO_MANY_REQUESTS: -32029,
|
|
33
|
+
CLIENT_CLOSED_REQUEST: -32099
|
|
34
|
+
};
|
|
35
|
+
// pure
|
|
36
|
+
const TRPC_ERROR_CODES_BY_NUMBER = {
|
|
37
|
+
[-32700]: 'PARSE_ERROR',
|
|
38
|
+
[-32600]: 'BAD_REQUEST',
|
|
39
|
+
[-32603]: 'INTERNAL_SERVER_ERROR',
|
|
40
|
+
[-32001]: 'UNAUTHORIZED',
|
|
41
|
+
[-32003]: 'FORBIDDEN',
|
|
42
|
+
[-32004]: 'NOT_FOUND',
|
|
43
|
+
[-32005]: 'METHOD_NOT_SUPPORTED',
|
|
44
|
+
[-32008]: 'TIMEOUT',
|
|
45
|
+
[-32009]: 'CONFLICT',
|
|
46
|
+
[-32012]: 'PRECONDITION_FAILED',
|
|
47
|
+
[-32013]: 'PAYLOAD_TOO_LARGE',
|
|
48
|
+
[-32015]: 'UNSUPPORTED_MEDIA_TYPE',
|
|
49
|
+
[-32022]: 'UNPROCESSABLE_CONTENT',
|
|
50
|
+
[-32029]: 'TOO_MANY_REQUESTS',
|
|
51
|
+
[-32099]: 'CLIENT_CLOSED_REQUEST'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER };
|