arri 0.40.0 → 0.42.0
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/dist/cli.cjs +80 -79
- package/dist/cli.mjs +80 -78
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +31 -24
- package/dist/index.d.mts +31 -24
- package/dist/index.d.ts +31 -24
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.ebe44c73.cjs → arri.0628c07d.cjs} +4 -2
- package/dist/shared/{arri.1fc3f099.mjs → arri.c3a553fc.mjs} +4 -2
- package/package.json +9 -6
package/dist/cli.cjs
CHANGED
|
@@ -11,13 +11,12 @@ const esbuild = require('esbuild');
|
|
|
11
11
|
const esbuildPluginReplace = require('esbuild-plugin-replace');
|
|
12
12
|
const path = require('pathe');
|
|
13
13
|
const prettier = require('prettier');
|
|
14
|
-
const config = require('./shared/arri.
|
|
14
|
+
const config = require('./shared/arri.0628c07d.cjs');
|
|
15
15
|
const consola = require('consola');
|
|
16
16
|
const globby = require('globby');
|
|
17
17
|
const scule = require('scule');
|
|
18
18
|
const ofetch = require('ofetch');
|
|
19
19
|
const listhen = require('@joshmossas/listhen');
|
|
20
|
-
const watcher = require('@parcel/watcher');
|
|
21
20
|
const Degit = require('degit');
|
|
22
21
|
const enquirer = require('enquirer');
|
|
23
22
|
require('h3');
|
|
@@ -43,13 +42,12 @@ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs$1);
|
|
|
43
42
|
const esbuild__namespace = /*#__PURE__*/_interopNamespaceCompat(esbuild);
|
|
44
43
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
45
44
|
const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
|
|
46
|
-
const watcher__default = /*#__PURE__*/_interopDefaultCompat(watcher);
|
|
47
45
|
const Degit__default = /*#__PURE__*/_interopDefaultCompat(Degit);
|
|
48
46
|
const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
|
|
49
47
|
|
|
50
48
|
const logger = consola.createConsola().withTag("arri");
|
|
51
|
-
const GEN_APP_FILE = "__arri_app.
|
|
52
|
-
const GEN_SERVER_ENTRY_FILE = "__arri_server.
|
|
49
|
+
const GEN_APP_FILE = "__arri_app.ts";
|
|
50
|
+
const GEN_SERVER_ENTRY_FILE = "__arri_server.ts";
|
|
53
51
|
const OUT_APP_FILE = "app.mjs";
|
|
54
52
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
55
53
|
const OUT_CODEGEN = "codegen.mjs";
|
|
@@ -67,7 +65,7 @@ async function setupWorkingDir(config) {
|
|
|
67
65
|
}
|
|
68
66
|
async function createAppWithRoutesModule(config) {
|
|
69
67
|
const appModule = path__default.resolve(config.rootDir, config.srcDir, config.entry);
|
|
70
|
-
const appImportParts = path__default.relative(path__default.resolve(config.rootDir, config.
|
|
68
|
+
const appImportParts = path__default.relative(path__default.resolve(config.rootDir, config.buildDir), appModule).split(".");
|
|
71
69
|
appImportParts.pop();
|
|
72
70
|
const routes = [];
|
|
73
71
|
const existingRoutes = [];
|
|
@@ -84,11 +82,13 @@ async function createAppWithRoutesModule(config) {
|
|
|
84
82
|
);
|
|
85
83
|
routes.sort((a, b) => a.name < b.name ? -1 : 1);
|
|
86
84
|
const module = await prettier__default.format(
|
|
87
|
-
`import
|
|
85
|
+
`import sourceMapSupport from 'source-map-support';
|
|
86
|
+
sourceMapSupport.install();
|
|
87
|
+
import app from '${appImportParts.join(".")}';
|
|
88
88
|
${routes.map(
|
|
89
89
|
(route) => `import ${route.importName} from '${route.importPath}';`
|
|
90
90
|
).join("\n")}
|
|
91
|
-
const routes = [${routes.map(
|
|
91
|
+
const routes: {id: string; route: any}[] = [${routes.map(
|
|
92
92
|
(route) => `{ id: '${route.name}', route: ${route.importName} }`
|
|
93
93
|
).join(",\n")}
|
|
94
94
|
];
|
|
@@ -98,11 +98,14 @@ async function createAppWithRoutesModule(config) {
|
|
|
98
98
|
name: route.id,
|
|
99
99
|
...route.route,
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (route.route.transport === 'ws') {
|
|
102
104
|
app.wsRpc({
|
|
103
105
|
name: route.id,
|
|
104
106
|
...route.route,
|
|
105
107
|
});
|
|
108
|
+
continue;
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
export default app`,
|
|
@@ -125,7 +128,7 @@ async function getFsRouteBatch(globPattern, config) {
|
|
|
125
128
|
for (const file of files) {
|
|
126
129
|
const meta = getRpcMetaFromPath(config, file);
|
|
127
130
|
if (meta) {
|
|
128
|
-
const importParts = path__default.relative(path__default.resolve(config.rootDir, config.
|
|
131
|
+
const importParts = path__default.relative(path__default.resolve(config.rootDir, config.buildDir), file).split(".");
|
|
129
132
|
importParts.pop();
|
|
130
133
|
importParts.push("js");
|
|
131
134
|
routes.push({
|
|
@@ -171,24 +174,11 @@ const getRpcMetaFromPath = (config, filePath) => {
|
|
|
171
174
|
httpPath: `/${httpParts.join("/")}`
|
|
172
175
|
};
|
|
173
176
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
await esbuild__namespace.build({
|
|
180
|
-
entryPoints: [
|
|
181
|
-
...files.map(
|
|
182
|
-
(file) => path__default.resolve(config.rootDir, config.srcDir, file)
|
|
183
|
-
)
|
|
184
|
-
],
|
|
185
|
-
outdir: outDir,
|
|
186
|
-
bundle: false,
|
|
187
|
-
format: "esm",
|
|
188
|
-
target: "node20",
|
|
189
|
-
platform: "node",
|
|
190
|
-
allowOverwrite: true
|
|
191
|
-
});
|
|
177
|
+
function isInsideDir(dir, parentDir) {
|
|
178
|
+
if (path__default.resolve(dir).startsWith(path__default.resolve(parentDir))) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
192
182
|
}
|
|
193
183
|
|
|
194
184
|
const build = citty.defineCommand({
|
|
@@ -212,6 +202,14 @@ const build = citty.defineCommand({
|
|
|
212
202
|
if (!config$1) {
|
|
213
203
|
throw new Error("Unable to find arri config");
|
|
214
204
|
}
|
|
205
|
+
const appEntry = path__default.resolve(
|
|
206
|
+
config$1.rootDir,
|
|
207
|
+
config$1.srcDir,
|
|
208
|
+
config$1.entry
|
|
209
|
+
);
|
|
210
|
+
if (!fs.existsSync(appEntry)) {
|
|
211
|
+
throw new Error(`Unable to find entry at ${appEntry}`);
|
|
212
|
+
}
|
|
215
213
|
await startBuild(config$1, args.skipCodegen);
|
|
216
214
|
}
|
|
217
215
|
});
|
|
@@ -226,8 +224,7 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
226
224
|
await Promise.all([
|
|
227
225
|
createAppWithRoutesModule(config),
|
|
228
226
|
createServerEntryFile(config),
|
|
229
|
-
createCodegenEntryFile(config)
|
|
230
|
-
transpileFiles(config)
|
|
227
|
+
createCodegenEntryFile(config)
|
|
231
228
|
]);
|
|
232
229
|
await bundleAppEntry(config);
|
|
233
230
|
logger.log("Finished bundling");
|
|
@@ -498,7 +495,7 @@ export default app.h3App;`;
|
|
|
498
495
|
path__default.resolve(config.rootDir, ".output", OUT_SERVER_ENTRY),
|
|
499
496
|
serverContent
|
|
500
497
|
);
|
|
501
|
-
await esbuild__namespace.
|
|
498
|
+
return await esbuild__namespace.context({
|
|
502
499
|
...config.esbuild,
|
|
503
500
|
entryPoints: [
|
|
504
501
|
path__default.resolve(config.rootDir, config.buildDir, GEN_APP_FILE)
|
|
@@ -509,19 +506,19 @@ export default app.h3App;`;
|
|
|
509
506
|
sourcemap: true,
|
|
510
507
|
target: "node20",
|
|
511
508
|
platform: "node",
|
|
512
|
-
packages: "external"
|
|
513
|
-
allowOverwrite: true
|
|
509
|
+
packages: "external"
|
|
514
510
|
});
|
|
515
511
|
}
|
|
516
512
|
async function startDevServer(config) {
|
|
517
513
|
await setupWorkingDir(config);
|
|
514
|
+
const watcher = await import('chokidar');
|
|
518
515
|
let fileWatcher;
|
|
519
516
|
await Promise.all([
|
|
520
517
|
createEntryModule(config),
|
|
521
|
-
createAppWithRoutesModule(config)
|
|
522
|
-
transpileFiles(config)
|
|
518
|
+
createAppWithRoutesModule(config)
|
|
523
519
|
]);
|
|
524
|
-
await bundleFilesContext(config);
|
|
520
|
+
const context = await bundleFilesContext(config);
|
|
521
|
+
await context.rebuild();
|
|
525
522
|
const listener = await startListener(config, true);
|
|
526
523
|
setTimeout(async () => {
|
|
527
524
|
await generateClients(config);
|
|
@@ -532,65 +529,69 @@ async function startDevServer(config) {
|
|
|
532
529
|
process.on("exit", async () => {
|
|
533
530
|
await Promise.allSettled([
|
|
534
531
|
listener.close(),
|
|
535
|
-
fileWatcher?.
|
|
532
|
+
fileWatcher?.close(),
|
|
533
|
+
context.dispose()
|
|
536
534
|
]);
|
|
537
535
|
});
|
|
538
536
|
process.on("SIGINT", cleanExit);
|
|
539
537
|
process.on("SIGTERM", cleanExit);
|
|
540
538
|
async function load(isRestart, reason) {
|
|
541
539
|
if (fileWatcher) {
|
|
542
|
-
await fileWatcher.
|
|
540
|
+
await fileWatcher.close();
|
|
543
541
|
}
|
|
544
542
|
const srcDir = path__default.resolve(config.rootDir ?? "", config.srcDir);
|
|
543
|
+
const dirsToWatch = [srcDir];
|
|
545
544
|
if (config.esbuild.alias) {
|
|
546
545
|
for (const key of Object.keys(config.esbuild.alias)) {
|
|
547
|
-
config.esbuild.alias[key];
|
|
546
|
+
const alias = config.esbuild.alias[key];
|
|
547
|
+
if (alias) {
|
|
548
|
+
if (!isInsideDir(alias, srcDir)) {
|
|
549
|
+
dirsToWatch.push(alias);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (config.devServer.additionalWatchDirs?.length) {
|
|
555
|
+
for (const dir of config.devServer.additionalWatchDirs) {
|
|
556
|
+
dirsToWatch.push(dir);
|
|
548
557
|
}
|
|
549
558
|
}
|
|
550
559
|
const buildDir = path__default.resolve(config.rootDir, config.buildDir);
|
|
551
560
|
const outDir = path__default.resolve(config.rootDir, ".output");
|
|
552
|
-
fileWatcher =
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
561
|
+
fileWatcher = watcher.watch(dirsToWatch, {
|
|
562
|
+
ignoreInitial: true,
|
|
563
|
+
ignored: [
|
|
564
|
+
buildDir,
|
|
565
|
+
outDir,
|
|
566
|
+
"**/.output",
|
|
567
|
+
"**/dist/**",
|
|
568
|
+
"**/node_modules/**",
|
|
569
|
+
"**/.git/**"
|
|
570
|
+
]
|
|
571
|
+
});
|
|
572
|
+
fileWatcher.on("all", async (eventName, path2) => {
|
|
573
|
+
if (eventName === "addDir" || eventName === "add") {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
await createAppWithRoutesModule(config);
|
|
577
|
+
let bundleCreated = false;
|
|
578
|
+
try {
|
|
579
|
+
logger.log(
|
|
580
|
+
"Change detected. Bundling files and restarting server...."
|
|
581
|
+
);
|
|
582
|
+
await context.rebuild();
|
|
583
|
+
bundleCreated = true;
|
|
584
|
+
} catch (err) {
|
|
585
|
+
logger.error("ERROR", err);
|
|
586
|
+
bundleCreated = false;
|
|
587
|
+
}
|
|
588
|
+
if (bundleCreated && config.generators.length) {
|
|
589
|
+
setTimeout(async () => {
|
|
590
|
+
await generateClients(config);
|
|
581
591
|
bundleCreated = false;
|
|
582
|
-
}
|
|
583
|
-
if (bundleCreated && config.generators.length) {
|
|
584
|
-
setTimeout(async () => {
|
|
585
|
-
await generateClients(config);
|
|
586
|
-
bundleCreated = false;
|
|
587
|
-
}, 1e3);
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
ignore: [buildDir, outDir]
|
|
592
|
+
}, 1e3);
|
|
592
593
|
}
|
|
593
|
-
);
|
|
594
|
+
});
|
|
594
595
|
}
|
|
595
596
|
await load();
|
|
596
597
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -10,13 +10,12 @@ import { build as build$1 } from 'esbuild';
|
|
|
10
10
|
import { replace } from 'esbuild-plugin-replace';
|
|
11
11
|
import path from 'pathe';
|
|
12
12
|
import prettier from 'prettier';
|
|
13
|
-
import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.
|
|
13
|
+
import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.c3a553fc.mjs';
|
|
14
14
|
import { createConsola } from 'consola';
|
|
15
15
|
import { globby } from 'globby';
|
|
16
16
|
import { camelCase, kebabCase } from 'scule';
|
|
17
17
|
import { ofetch } from 'ofetch';
|
|
18
18
|
import { listenAndWatch } from '@joshmossas/listhen';
|
|
19
|
-
import watcher from '@parcel/watcher';
|
|
20
19
|
import Degit from 'degit';
|
|
21
20
|
import enquirer from 'enquirer';
|
|
22
21
|
import 'h3';
|
|
@@ -24,8 +23,8 @@ import 'arri-validate';
|
|
|
24
23
|
import 'h3-sse';
|
|
25
24
|
|
|
26
25
|
const logger = createConsola().withTag("arri");
|
|
27
|
-
const GEN_APP_FILE = "__arri_app.
|
|
28
|
-
const GEN_SERVER_ENTRY_FILE = "__arri_server.
|
|
26
|
+
const GEN_APP_FILE = "__arri_app.ts";
|
|
27
|
+
const GEN_SERVER_ENTRY_FILE = "__arri_server.ts";
|
|
29
28
|
const OUT_APP_FILE = "app.mjs";
|
|
30
29
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
31
30
|
const OUT_CODEGEN = "codegen.mjs";
|
|
@@ -43,7 +42,7 @@ async function setupWorkingDir(config) {
|
|
|
43
42
|
}
|
|
44
43
|
async function createAppWithRoutesModule(config) {
|
|
45
44
|
const appModule = path.resolve(config.rootDir, config.srcDir, config.entry);
|
|
46
|
-
const appImportParts = path.relative(path.resolve(config.rootDir, config.
|
|
45
|
+
const appImportParts = path.relative(path.resolve(config.rootDir, config.buildDir), appModule).split(".");
|
|
47
46
|
appImportParts.pop();
|
|
48
47
|
const routes = [];
|
|
49
48
|
const existingRoutes = [];
|
|
@@ -60,11 +59,13 @@ async function createAppWithRoutesModule(config) {
|
|
|
60
59
|
);
|
|
61
60
|
routes.sort((a, b) => a.name < b.name ? -1 : 1);
|
|
62
61
|
const module = await prettier.format(
|
|
63
|
-
`import
|
|
62
|
+
`import sourceMapSupport from 'source-map-support';
|
|
63
|
+
sourceMapSupport.install();
|
|
64
|
+
import app from '${appImportParts.join(".")}';
|
|
64
65
|
${routes.map(
|
|
65
66
|
(route) => `import ${route.importName} from '${route.importPath}';`
|
|
66
67
|
).join("\n")}
|
|
67
|
-
const routes = [${routes.map(
|
|
68
|
+
const routes: {id: string; route: any}[] = [${routes.map(
|
|
68
69
|
(route) => `{ id: '${route.name}', route: ${route.importName} }`
|
|
69
70
|
).join(",\n")}
|
|
70
71
|
];
|
|
@@ -74,11 +75,14 @@ async function createAppWithRoutesModule(config) {
|
|
|
74
75
|
name: route.id,
|
|
75
76
|
...route.route,
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (route.route.transport === 'ws') {
|
|
78
81
|
app.wsRpc({
|
|
79
82
|
name: route.id,
|
|
80
83
|
...route.route,
|
|
81
84
|
});
|
|
85
|
+
continue;
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
export default app`,
|
|
@@ -101,7 +105,7 @@ async function getFsRouteBatch(globPattern, config) {
|
|
|
101
105
|
for (const file of files) {
|
|
102
106
|
const meta = getRpcMetaFromPath(config, file);
|
|
103
107
|
if (meta) {
|
|
104
|
-
const importParts = path.relative(path.resolve(config.rootDir, config.
|
|
108
|
+
const importParts = path.relative(path.resolve(config.rootDir, config.buildDir), file).split(".");
|
|
105
109
|
importParts.pop();
|
|
106
110
|
importParts.push("js");
|
|
107
111
|
routes.push({
|
|
@@ -147,24 +151,11 @@ const getRpcMetaFromPath = (config, filePath) => {
|
|
|
147
151
|
httpPath: `/${httpParts.join("/")}`
|
|
148
152
|
};
|
|
149
153
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
await esbuild.build({
|
|
156
|
-
entryPoints: [
|
|
157
|
-
...files.map(
|
|
158
|
-
(file) => path.resolve(config.rootDir, config.srcDir, file)
|
|
159
|
-
)
|
|
160
|
-
],
|
|
161
|
-
outdir: outDir,
|
|
162
|
-
bundle: false,
|
|
163
|
-
format: "esm",
|
|
164
|
-
target: "node20",
|
|
165
|
-
platform: "node",
|
|
166
|
-
allowOverwrite: true
|
|
167
|
-
});
|
|
154
|
+
function isInsideDir(dir, parentDir) {
|
|
155
|
+
if (path.resolve(dir).startsWith(path.resolve(parentDir))) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
168
159
|
}
|
|
169
160
|
|
|
170
161
|
const build = defineCommand({
|
|
@@ -188,6 +179,14 @@ const build = defineCommand({
|
|
|
188
179
|
if (!config) {
|
|
189
180
|
throw new Error("Unable to find arri config");
|
|
190
181
|
}
|
|
182
|
+
const appEntry = path.resolve(
|
|
183
|
+
config.rootDir,
|
|
184
|
+
config.srcDir,
|
|
185
|
+
config.entry
|
|
186
|
+
);
|
|
187
|
+
if (!existsSync(appEntry)) {
|
|
188
|
+
throw new Error(`Unable to find entry at ${appEntry}`);
|
|
189
|
+
}
|
|
191
190
|
await startBuild(config, args.skipCodegen);
|
|
192
191
|
}
|
|
193
192
|
});
|
|
@@ -202,8 +201,7 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
202
201
|
await Promise.all([
|
|
203
202
|
createAppWithRoutesModule(config),
|
|
204
203
|
createServerEntryFile(config),
|
|
205
|
-
createCodegenEntryFile(config)
|
|
206
|
-
transpileFiles(config)
|
|
204
|
+
createCodegenEntryFile(config)
|
|
207
205
|
]);
|
|
208
206
|
await bundleAppEntry(config);
|
|
209
207
|
logger.log("Finished bundling");
|
|
@@ -474,7 +472,7 @@ export default app.h3App;`;
|
|
|
474
472
|
path.resolve(config.rootDir, ".output", OUT_SERVER_ENTRY),
|
|
475
473
|
serverContent
|
|
476
474
|
);
|
|
477
|
-
await esbuild.
|
|
475
|
+
return await esbuild.context({
|
|
478
476
|
...config.esbuild,
|
|
479
477
|
entryPoints: [
|
|
480
478
|
path.resolve(config.rootDir, config.buildDir, GEN_APP_FILE)
|
|
@@ -485,19 +483,19 @@ export default app.h3App;`;
|
|
|
485
483
|
sourcemap: true,
|
|
486
484
|
target: "node20",
|
|
487
485
|
platform: "node",
|
|
488
|
-
packages: "external"
|
|
489
|
-
allowOverwrite: true
|
|
486
|
+
packages: "external"
|
|
490
487
|
});
|
|
491
488
|
}
|
|
492
489
|
async function startDevServer(config) {
|
|
493
490
|
await setupWorkingDir(config);
|
|
491
|
+
const watcher = await import('chokidar');
|
|
494
492
|
let fileWatcher;
|
|
495
493
|
await Promise.all([
|
|
496
494
|
createEntryModule(config),
|
|
497
|
-
createAppWithRoutesModule(config)
|
|
498
|
-
transpileFiles(config)
|
|
495
|
+
createAppWithRoutesModule(config)
|
|
499
496
|
]);
|
|
500
|
-
await bundleFilesContext(config);
|
|
497
|
+
const context = await bundleFilesContext(config);
|
|
498
|
+
await context.rebuild();
|
|
501
499
|
const listener = await startListener(config, true);
|
|
502
500
|
setTimeout(async () => {
|
|
503
501
|
await generateClients(config);
|
|
@@ -508,65 +506,69 @@ async function startDevServer(config) {
|
|
|
508
506
|
process.on("exit", async () => {
|
|
509
507
|
await Promise.allSettled([
|
|
510
508
|
listener.close(),
|
|
511
|
-
fileWatcher?.
|
|
509
|
+
fileWatcher?.close(),
|
|
510
|
+
context.dispose()
|
|
512
511
|
]);
|
|
513
512
|
});
|
|
514
513
|
process.on("SIGINT", cleanExit);
|
|
515
514
|
process.on("SIGTERM", cleanExit);
|
|
516
515
|
async function load(isRestart, reason) {
|
|
517
516
|
if (fileWatcher) {
|
|
518
|
-
await fileWatcher.
|
|
517
|
+
await fileWatcher.close();
|
|
519
518
|
}
|
|
520
519
|
const srcDir = path.resolve(config.rootDir ?? "", config.srcDir);
|
|
520
|
+
const dirsToWatch = [srcDir];
|
|
521
521
|
if (config.esbuild.alias) {
|
|
522
522
|
for (const key of Object.keys(config.esbuild.alias)) {
|
|
523
|
-
config.esbuild.alias[key];
|
|
523
|
+
const alias = config.esbuild.alias[key];
|
|
524
|
+
if (alias) {
|
|
525
|
+
if (!isInsideDir(alias, srcDir)) {
|
|
526
|
+
dirsToWatch.push(alias);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (config.devServer.additionalWatchDirs?.length) {
|
|
532
|
+
for (const dir of config.devServer.additionalWatchDirs) {
|
|
533
|
+
dirsToWatch.push(dir);
|
|
524
534
|
}
|
|
525
535
|
}
|
|
526
536
|
const buildDir = path.resolve(config.rootDir, config.buildDir);
|
|
527
537
|
const outDir = path.resolve(config.rootDir, ".output");
|
|
528
|
-
fileWatcher =
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
538
|
+
fileWatcher = watcher.watch(dirsToWatch, {
|
|
539
|
+
ignoreInitial: true,
|
|
540
|
+
ignored: [
|
|
541
|
+
buildDir,
|
|
542
|
+
outDir,
|
|
543
|
+
"**/.output",
|
|
544
|
+
"**/dist/**",
|
|
545
|
+
"**/node_modules/**",
|
|
546
|
+
"**/.git/**"
|
|
547
|
+
]
|
|
548
|
+
});
|
|
549
|
+
fileWatcher.on("all", async (eventName, path2) => {
|
|
550
|
+
if (eventName === "addDir" || eventName === "add") {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
await createAppWithRoutesModule(config);
|
|
554
|
+
let bundleCreated = false;
|
|
555
|
+
try {
|
|
556
|
+
logger.log(
|
|
557
|
+
"Change detected. Bundling files and restarting server...."
|
|
558
|
+
);
|
|
559
|
+
await context.rebuild();
|
|
560
|
+
bundleCreated = true;
|
|
561
|
+
} catch (err) {
|
|
562
|
+
logger.error("ERROR", err);
|
|
563
|
+
bundleCreated = false;
|
|
564
|
+
}
|
|
565
|
+
if (bundleCreated && config.generators.length) {
|
|
566
|
+
setTimeout(async () => {
|
|
567
|
+
await generateClients(config);
|
|
557
568
|
bundleCreated = false;
|
|
558
|
-
}
|
|
559
|
-
if (bundleCreated && config.generators.length) {
|
|
560
|
-
setTimeout(async () => {
|
|
561
|
-
await generateClients(config);
|
|
562
|
-
bundleCreated = false;
|
|
563
|
-
}, 1e3);
|
|
564
|
-
}
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
ignore: [buildDir, outDir]
|
|
569
|
+
}, 1e3);
|
|
568
570
|
}
|
|
569
|
-
);
|
|
571
|
+
});
|
|
570
572
|
}
|
|
571
573
|
await load();
|
|
572
574
|
}
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -28,9 +28,26 @@ declare function errorResponseFromValidationErrors(errors: ValidationError["erro
|
|
|
28
28
|
type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
|
|
29
29
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
type ArriEventContext = Record<string, any>;
|
|
32
|
+
interface RpcEventContext<TParams = undefined> extends ArriEventContext, Omit<H3EventContext, "params"> {
|
|
33
|
+
rpcName: string;
|
|
34
|
+
params: TParams;
|
|
35
|
+
}
|
|
36
|
+
interface RpcPostEventContext<TParams = undefined, TResponse = undefined> extends RpcEventContext<TParams> {
|
|
37
|
+
response: TResponse;
|
|
38
|
+
}
|
|
39
|
+
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends ArriEventContext, H3EventContext {
|
|
40
|
+
params: ExtractParams<TPath>;
|
|
41
|
+
query: TQuery;
|
|
42
|
+
body: TBody;
|
|
43
|
+
}
|
|
44
|
+
interface RoutePostEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
45
|
+
response: TResponse;
|
|
46
|
+
}
|
|
47
|
+
interface MiddlewareEventContext extends ArriEventContext, H3EventContext {
|
|
32
48
|
rpcName?: string;
|
|
33
49
|
}
|
|
50
|
+
|
|
34
51
|
interface MiddlewareEvent extends H3Event {
|
|
35
52
|
context: MiddlewareEventContext;
|
|
36
53
|
}
|
|
@@ -39,19 +56,11 @@ declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
|
39
56
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
40
57
|
type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
|
|
41
58
|
|
|
42
|
-
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
|
|
43
|
-
params: ExtractParams<TPath>;
|
|
44
|
-
query: TQuery;
|
|
45
|
-
body: TBody;
|
|
46
|
-
}
|
|
47
59
|
interface RouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3Event {
|
|
48
60
|
context: RouteEventContext<TPath, TQuery, TBody>;
|
|
49
61
|
}
|
|
50
|
-
interface PostRouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
51
|
-
response: TResponse;
|
|
52
|
-
}
|
|
53
62
|
interface PostRouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends H3Event {
|
|
54
|
-
context:
|
|
63
|
+
context: RoutePostEventContext<TPath, TQuery, TBody, TResponse>;
|
|
55
64
|
}
|
|
56
65
|
interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends ASchema<any> = any, TResponse = any> {
|
|
57
66
|
path: TPath;
|
|
@@ -75,7 +84,7 @@ interface EventStreamRpc<TParams extends RpcParamSchema | undefined = undefined,
|
|
|
75
84
|
handler: EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
76
85
|
}
|
|
77
86
|
type EventStreamRpcHandler<TParams, TResponse> = (context: EventStreamRpcHandlerContext<TParams, TResponse>, event: RpcEvent<TResponse>) => void | Promise<void>;
|
|
78
|
-
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends
|
|
87
|
+
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends RpcEventContext<TParams> {
|
|
79
88
|
stream: EventStreamConnection<TResponse>;
|
|
80
89
|
}
|
|
81
90
|
interface EventStreamConnectionOptions<TData> {
|
|
@@ -185,22 +194,14 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
|
|
|
185
194
|
postHandler?: TIsEventStream extends true ? undefined : RpcPostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
186
195
|
}
|
|
187
196
|
type HttpRpc<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> = Omit<Rpc<false, TParams, TResponse>, "isEventStream">;
|
|
188
|
-
type HandlerContext = Record<string, any>;
|
|
189
|
-
interface RpcHandlerContext<TParams = undefined> extends HandlerContext, Omit<H3EventContext, "params"> {
|
|
190
|
-
rpcName: string;
|
|
191
|
-
params: TParams;
|
|
192
|
-
}
|
|
193
|
-
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
194
|
-
response: TResponse;
|
|
195
|
-
}
|
|
196
197
|
interface RpcEvent<TParams = undefined> extends Omit<H3Event, "context"> {
|
|
197
|
-
context:
|
|
198
|
+
context: RpcEventContext<TParams>;
|
|
198
199
|
}
|
|
199
200
|
interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<H3Event, "context"> {
|
|
200
|
-
context:
|
|
201
|
+
context: RpcPostEventContext<TParams, TResponse>;
|
|
201
202
|
}
|
|
202
|
-
type RpcHandler<TParams, TResponse> = (context:
|
|
203
|
-
type RpcPostHandler<TParams, TResponse> = (context:
|
|
203
|
+
type RpcHandler<TParams, TResponse> = (context: RpcEventContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
204
|
+
type RpcPostHandler<TParams, TResponse> = (context: RpcPostEventContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
204
205
|
declare function isRpc(input: unknown): input is Rpc<any, any>;
|
|
205
206
|
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: Omit<HttpRpc<TParams, TResponse>, "transport">): Rpc<false, TParams, TResponse>;
|
|
206
207
|
declare function createHttpRpcDefinition(rpcName: string, httpPath: string, procedure: Rpc<any, any, any>): HttpRpcDefinition;
|
|
@@ -296,6 +297,12 @@ interface ArriConfig {
|
|
|
296
297
|
passphrase?: string;
|
|
297
298
|
} | boolean;
|
|
298
299
|
http2?: boolean;
|
|
300
|
+
devServer?: {
|
|
301
|
+
/**
|
|
302
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
303
|
+
*/
|
|
304
|
+
additionalWatchDirs?: string[];
|
|
305
|
+
};
|
|
299
306
|
}
|
|
300
307
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
308
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
|
@@ -303,4 +310,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
303
310
|
declare const defaultConfig: Required<ArriConfig>;
|
|
304
311
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
305
312
|
|
|
306
|
-
export { ArriApp, type ArriConfig, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type
|
|
313
|
+
export { ArriApp, type ArriConfig, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ModelMap, type NamedRpc, type NamedWebsocketRpc, type PostRouteEvent, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type StatusCode, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defaultConfig, defineConfig, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isEventStreamRpc, isResolvedArriConfig, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.d.mts
CHANGED
|
@@ -28,9 +28,26 @@ declare function errorResponseFromValidationErrors(errors: ValidationError["erro
|
|
|
28
28
|
type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
|
|
29
29
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
type ArriEventContext = Record<string, any>;
|
|
32
|
+
interface RpcEventContext<TParams = undefined> extends ArriEventContext, Omit<H3EventContext, "params"> {
|
|
33
|
+
rpcName: string;
|
|
34
|
+
params: TParams;
|
|
35
|
+
}
|
|
36
|
+
interface RpcPostEventContext<TParams = undefined, TResponse = undefined> extends RpcEventContext<TParams> {
|
|
37
|
+
response: TResponse;
|
|
38
|
+
}
|
|
39
|
+
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends ArriEventContext, H3EventContext {
|
|
40
|
+
params: ExtractParams<TPath>;
|
|
41
|
+
query: TQuery;
|
|
42
|
+
body: TBody;
|
|
43
|
+
}
|
|
44
|
+
interface RoutePostEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
45
|
+
response: TResponse;
|
|
46
|
+
}
|
|
47
|
+
interface MiddlewareEventContext extends ArriEventContext, H3EventContext {
|
|
32
48
|
rpcName?: string;
|
|
33
49
|
}
|
|
50
|
+
|
|
34
51
|
interface MiddlewareEvent extends H3Event {
|
|
35
52
|
context: MiddlewareEventContext;
|
|
36
53
|
}
|
|
@@ -39,19 +56,11 @@ declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
|
39
56
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
40
57
|
type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
|
|
41
58
|
|
|
42
|
-
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
|
|
43
|
-
params: ExtractParams<TPath>;
|
|
44
|
-
query: TQuery;
|
|
45
|
-
body: TBody;
|
|
46
|
-
}
|
|
47
59
|
interface RouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3Event {
|
|
48
60
|
context: RouteEventContext<TPath, TQuery, TBody>;
|
|
49
61
|
}
|
|
50
|
-
interface PostRouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
51
|
-
response: TResponse;
|
|
52
|
-
}
|
|
53
62
|
interface PostRouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends H3Event {
|
|
54
|
-
context:
|
|
63
|
+
context: RoutePostEventContext<TPath, TQuery, TBody, TResponse>;
|
|
55
64
|
}
|
|
56
65
|
interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends ASchema<any> = any, TResponse = any> {
|
|
57
66
|
path: TPath;
|
|
@@ -75,7 +84,7 @@ interface EventStreamRpc<TParams extends RpcParamSchema | undefined = undefined,
|
|
|
75
84
|
handler: EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
76
85
|
}
|
|
77
86
|
type EventStreamRpcHandler<TParams, TResponse> = (context: EventStreamRpcHandlerContext<TParams, TResponse>, event: RpcEvent<TResponse>) => void | Promise<void>;
|
|
78
|
-
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends
|
|
87
|
+
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends RpcEventContext<TParams> {
|
|
79
88
|
stream: EventStreamConnection<TResponse>;
|
|
80
89
|
}
|
|
81
90
|
interface EventStreamConnectionOptions<TData> {
|
|
@@ -185,22 +194,14 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
|
|
|
185
194
|
postHandler?: TIsEventStream extends true ? undefined : RpcPostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
186
195
|
}
|
|
187
196
|
type HttpRpc<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> = Omit<Rpc<false, TParams, TResponse>, "isEventStream">;
|
|
188
|
-
type HandlerContext = Record<string, any>;
|
|
189
|
-
interface RpcHandlerContext<TParams = undefined> extends HandlerContext, Omit<H3EventContext, "params"> {
|
|
190
|
-
rpcName: string;
|
|
191
|
-
params: TParams;
|
|
192
|
-
}
|
|
193
|
-
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
194
|
-
response: TResponse;
|
|
195
|
-
}
|
|
196
197
|
interface RpcEvent<TParams = undefined> extends Omit<H3Event, "context"> {
|
|
197
|
-
context:
|
|
198
|
+
context: RpcEventContext<TParams>;
|
|
198
199
|
}
|
|
199
200
|
interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<H3Event, "context"> {
|
|
200
|
-
context:
|
|
201
|
+
context: RpcPostEventContext<TParams, TResponse>;
|
|
201
202
|
}
|
|
202
|
-
type RpcHandler<TParams, TResponse> = (context:
|
|
203
|
-
type RpcPostHandler<TParams, TResponse> = (context:
|
|
203
|
+
type RpcHandler<TParams, TResponse> = (context: RpcEventContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
204
|
+
type RpcPostHandler<TParams, TResponse> = (context: RpcPostEventContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
204
205
|
declare function isRpc(input: unknown): input is Rpc<any, any>;
|
|
205
206
|
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: Omit<HttpRpc<TParams, TResponse>, "transport">): Rpc<false, TParams, TResponse>;
|
|
206
207
|
declare function createHttpRpcDefinition(rpcName: string, httpPath: string, procedure: Rpc<any, any, any>): HttpRpcDefinition;
|
|
@@ -296,6 +297,12 @@ interface ArriConfig {
|
|
|
296
297
|
passphrase?: string;
|
|
297
298
|
} | boolean;
|
|
298
299
|
http2?: boolean;
|
|
300
|
+
devServer?: {
|
|
301
|
+
/**
|
|
302
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
303
|
+
*/
|
|
304
|
+
additionalWatchDirs?: string[];
|
|
305
|
+
};
|
|
299
306
|
}
|
|
300
307
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
308
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
|
@@ -303,4 +310,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
303
310
|
declare const defaultConfig: Required<ArriConfig>;
|
|
304
311
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
305
312
|
|
|
306
|
-
export { ArriApp, type ArriConfig, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type
|
|
313
|
+
export { ArriApp, type ArriConfig, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ModelMap, type NamedRpc, type NamedWebsocketRpc, type PostRouteEvent, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type StatusCode, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defaultConfig, defineConfig, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isEventStreamRpc, isResolvedArriConfig, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,9 +28,26 @@ declare function errorResponseFromValidationErrors(errors: ValidationError["erro
|
|
|
28
28
|
type StatusCode = number | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
|
|
29
29
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
type ArriEventContext = Record<string, any>;
|
|
32
|
+
interface RpcEventContext<TParams = undefined> extends ArriEventContext, Omit<H3EventContext, "params"> {
|
|
33
|
+
rpcName: string;
|
|
34
|
+
params: TParams;
|
|
35
|
+
}
|
|
36
|
+
interface RpcPostEventContext<TParams = undefined, TResponse = undefined> extends RpcEventContext<TParams> {
|
|
37
|
+
response: TResponse;
|
|
38
|
+
}
|
|
39
|
+
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends ArriEventContext, H3EventContext {
|
|
40
|
+
params: ExtractParams<TPath>;
|
|
41
|
+
query: TQuery;
|
|
42
|
+
body: TBody;
|
|
43
|
+
}
|
|
44
|
+
interface RoutePostEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
45
|
+
response: TResponse;
|
|
46
|
+
}
|
|
47
|
+
interface MiddlewareEventContext extends ArriEventContext, H3EventContext {
|
|
32
48
|
rpcName?: string;
|
|
33
49
|
}
|
|
50
|
+
|
|
34
51
|
interface MiddlewareEvent extends H3Event {
|
|
35
52
|
context: MiddlewareEventContext;
|
|
36
53
|
}
|
|
@@ -39,19 +56,11 @@ declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
|
39
56
|
type ExtractParam<Path, NextPart> = Path extends `:${infer Param}` ? Record<Param, string> & NextPart : NextPart;
|
|
40
57
|
type ExtractParams<Path> = Path extends `${infer Segment}/${infer Rest}` ? ExtractParam<Segment, ExtractParams<Rest>> : ExtractParam<Path, {}>;
|
|
41
58
|
|
|
42
|
-
interface RouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3EventContext {
|
|
43
|
-
params: ExtractParams<TPath>;
|
|
44
|
-
query: TQuery;
|
|
45
|
-
body: TBody;
|
|
46
|
-
}
|
|
47
59
|
interface RouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any> extends H3Event {
|
|
48
60
|
context: RouteEventContext<TPath, TQuery, TBody>;
|
|
49
61
|
}
|
|
50
|
-
interface PostRouteEventContext<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends RouteEventContext<TPath, TQuery, TBody> {
|
|
51
|
-
response: TResponse;
|
|
52
|
-
}
|
|
53
62
|
interface PostRouteEvent<TPath extends string, TQuery extends Record<any, any> = any, TBody = any, TResponse = any> extends H3Event {
|
|
54
|
-
context:
|
|
63
|
+
context: RoutePostEventContext<TPath, TQuery, TBody, TResponse>;
|
|
55
64
|
}
|
|
56
65
|
interface ArriRoute<TPath extends string, TQuery extends AObjectSchema<any, any> = any, TBody extends ASchema<any> = any, TResponse = any> {
|
|
57
66
|
path: TPath;
|
|
@@ -75,7 +84,7 @@ interface EventStreamRpc<TParams extends RpcParamSchema | undefined = undefined,
|
|
|
75
84
|
handler: EventStreamRpcHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
76
85
|
}
|
|
77
86
|
type EventStreamRpcHandler<TParams, TResponse> = (context: EventStreamRpcHandlerContext<TParams, TResponse>, event: RpcEvent<TResponse>) => void | Promise<void>;
|
|
78
|
-
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends
|
|
87
|
+
interface EventStreamRpcHandlerContext<TParams = any, TResponse = any> extends RpcEventContext<TParams> {
|
|
79
88
|
stream: EventStreamConnection<TResponse>;
|
|
80
89
|
}
|
|
81
90
|
interface EventStreamConnectionOptions<TData> {
|
|
@@ -185,22 +194,14 @@ interface Rpc<TIsEventStream extends boolean = false, TParams extends RpcParamSc
|
|
|
185
194
|
postHandler?: TIsEventStream extends true ? undefined : RpcPostHandler<TParams extends RpcParamSchema ? InferType<TParams> : undefined, TResponse extends RpcParamSchema ? InferType<TResponse> : undefined>;
|
|
186
195
|
}
|
|
187
196
|
type HttpRpc<TParams extends RpcParamSchema | undefined, TResponse extends RpcParamSchema | undefined> = Omit<Rpc<false, TParams, TResponse>, "isEventStream">;
|
|
188
|
-
type HandlerContext = Record<string, any>;
|
|
189
|
-
interface RpcHandlerContext<TParams = undefined> extends HandlerContext, Omit<H3EventContext, "params"> {
|
|
190
|
-
rpcName: string;
|
|
191
|
-
params: TParams;
|
|
192
|
-
}
|
|
193
|
-
interface RpcPostHandlerContext<TParams = undefined, TResponse = undefined> extends RpcHandlerContext<TParams> {
|
|
194
|
-
response: TResponse;
|
|
195
|
-
}
|
|
196
197
|
interface RpcEvent<TParams = undefined> extends Omit<H3Event, "context"> {
|
|
197
|
-
context:
|
|
198
|
+
context: RpcEventContext<TParams>;
|
|
198
199
|
}
|
|
199
200
|
interface RpcPostEvent<TParams = undefined, TResponse = undefined> extends Omit<H3Event, "context"> {
|
|
200
|
-
context:
|
|
201
|
+
context: RpcPostEventContext<TParams, TResponse>;
|
|
201
202
|
}
|
|
202
|
-
type RpcHandler<TParams, TResponse> = (context:
|
|
203
|
-
type RpcPostHandler<TParams, TResponse> = (context:
|
|
203
|
+
type RpcHandler<TParams, TResponse> = (context: RpcEventContext<TParams>, event: RpcEvent<TParams>) => TResponse | Promise<TResponse>;
|
|
204
|
+
type RpcPostHandler<TParams, TResponse> = (context: RpcPostEventContext<TParams, TResponse>, event: RpcPostEvent<TParams, TResponse>) => any;
|
|
204
205
|
declare function isRpc(input: unknown): input is Rpc<any, any>;
|
|
205
206
|
declare function defineRpc<TParams extends RpcParamSchema | undefined = undefined, TResponse extends RpcParamSchema | undefined | never = undefined>(config: Omit<HttpRpc<TParams, TResponse>, "transport">): Rpc<false, TParams, TResponse>;
|
|
206
207
|
declare function createHttpRpcDefinition(rpcName: string, httpPath: string, procedure: Rpc<any, any, any>): HttpRpcDefinition;
|
|
@@ -296,6 +297,12 @@ interface ArriConfig {
|
|
|
296
297
|
passphrase?: string;
|
|
297
298
|
} | boolean;
|
|
298
299
|
http2?: boolean;
|
|
300
|
+
devServer?: {
|
|
301
|
+
/**
|
|
302
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
303
|
+
*/
|
|
304
|
+
additionalWatchDirs?: string[];
|
|
305
|
+
};
|
|
299
306
|
}
|
|
300
307
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
308
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
|
@@ -303,4 +310,4 @@ type ResolvedArriConfig = Required<ArriConfig>;
|
|
|
303
310
|
declare const defaultConfig: Required<ArriConfig>;
|
|
304
311
|
declare function defineConfig(config: ArriConfig): ResolvedArriConfig;
|
|
305
312
|
|
|
306
|
-
export { ArriApp, type ArriConfig, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type
|
|
313
|
+
export { ArriApp, type ArriConfig, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, type ArriRouterBase, ArriServerError, ArriServerErrorResponse, DEV_DEFINITION_ENDPOINT, DEV_ENDPOINT_ROOT, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type ModelMap, type NamedRpc, type NamedWebsocketRpc, type PostRouteEvent, type ResolvedArriConfig, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type StatusCode, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defaultConfig, defineConfig, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, handleH3Error, handleRoute, isArriConfig, isEventStreamRpc, isResolvedArriConfig, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.
|
|
1
|
+
export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.c3a553fc.mjs';
|
|
2
2
|
export * from 'h3';
|
|
3
3
|
import 'arri-codegen-utils';
|
|
4
4
|
import 'arri-validate';
|
|
@@ -1228,7 +1228,8 @@ const defaultConfig = {
|
|
|
1228
1228
|
buildDir: ".arri",
|
|
1229
1229
|
esbuild: {},
|
|
1230
1230
|
https: false,
|
|
1231
|
-
http2: false
|
|
1231
|
+
http2: false,
|
|
1232
|
+
devServer: {}
|
|
1232
1233
|
};
|
|
1233
1234
|
function defineConfig(config) {
|
|
1234
1235
|
return {
|
|
@@ -1243,7 +1244,8 @@ function defineConfig(config) {
|
|
|
1243
1244
|
esbuild: config.esbuild ?? defaultConfig.esbuild,
|
|
1244
1245
|
serverEntry: config.serverEntry ?? "",
|
|
1245
1246
|
https: config.https ?? false,
|
|
1246
|
-
http2: config.http2 ?? false
|
|
1247
|
+
http2: config.http2 ?? false,
|
|
1248
|
+
devServer: config.devServer ?? {}
|
|
1247
1249
|
};
|
|
1248
1250
|
}
|
|
1249
1251
|
|
|
@@ -1226,7 +1226,8 @@ const defaultConfig = {
|
|
|
1226
1226
|
buildDir: ".arri",
|
|
1227
1227
|
esbuild: {},
|
|
1228
1228
|
https: false,
|
|
1229
|
-
http2: false
|
|
1229
|
+
http2: false,
|
|
1230
|
+
devServer: {}
|
|
1230
1231
|
};
|
|
1231
1232
|
function defineConfig(config) {
|
|
1232
1233
|
return {
|
|
@@ -1241,7 +1242,8 @@ function defineConfig(config) {
|
|
|
1241
1242
|
esbuild: config.esbuild ?? defaultConfig.esbuild,
|
|
1242
1243
|
serverEntry: config.serverEntry ?? "",
|
|
1243
1244
|
https: config.https ?? false,
|
|
1244
|
-
http2: config.http2 ?? false
|
|
1245
|
+
http2: config.http2 ?? false,
|
|
1246
|
+
devServer: config.devServer ?? {}
|
|
1245
1247
|
};
|
|
1246
1248
|
}
|
|
1247
1249
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,9 +25,11 @@
|
|
|
25
25
|
"arri": "./dist/cli.mjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@joshmossas/listhen": "1.10.
|
|
28
|
+
"@joshmossas/listhen": "1.10.1",
|
|
29
29
|
"@parcel/watcher": "^2.4.1",
|
|
30
|
+
"@types/source-map-support": "^0.5.10",
|
|
30
31
|
"c12": "^1.10.0",
|
|
32
|
+
"chokidar": "^3.6.0",
|
|
31
33
|
"citty": "^0.1.6",
|
|
32
34
|
"consola": "^3.2.3",
|
|
33
35
|
"crossws": "^0.2.4",
|
|
@@ -43,11 +45,12 @@
|
|
|
43
45
|
"pathe": "^1.1.2",
|
|
44
46
|
"prettier": "^3.2.5",
|
|
45
47
|
"scule": "^1.3.0",
|
|
48
|
+
"source-map-support": "^0.5.21",
|
|
46
49
|
"uncrypto": "^0.1.3",
|
|
47
|
-
"arri-codegen-
|
|
48
|
-
"arri-codegen-utils": "0.
|
|
49
|
-
"arri-
|
|
50
|
-
"arri-
|
|
50
|
+
"arri-codegen-ts": "0.42.0",
|
|
51
|
+
"arri-codegen-utils": "0.42.0",
|
|
52
|
+
"arri-codegen-dart": "0.42.0",
|
|
53
|
+
"arri-validate": "0.42.0"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@types/degit": "^2.8.6",
|