@vistagenic/vista 0.3.2 → 0.3.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/bin/vista.js +79 -109
- package/dist/ai/embeddings.d.ts +11 -11
- package/dist/ai/embeddings.js +71 -71
- package/dist/ai/index.d.ts +10 -10
- package/dist/ai/index.js +26 -26
- package/dist/ai/providers/base.js +85 -85
- package/dist/ai/react/react-server.d.ts +1 -1
- package/dist/ai/react/react-server.js +17 -17
- package/dist/ai/react/use-agent.js +138 -138
- package/dist/auth/core.d.ts +140 -140
- package/dist/auth/core.js +165 -165
- package/dist/auth/index.d.ts +20 -20
- package/dist/auth/index.js +369 -369
- package/dist/auth/react-server.d.ts +1 -1
- package/dist/auth/react-server.js +10 -10
- package/dist/auth/react.d.ts +18 -18
- package/dist/auth/react.js +71 -71
- package/dist/bin/build-rsc-flashpack.js +6 -0
- package/dist/bin/build-rsc.js +537 -492
- package/dist/bin/build.js +355 -353
- package/dist/bin/generate.js +513 -510
- package/dist/bin/webpack.config.js +4 -3
- package/dist/build/manifest.d.ts +169 -169
- package/dist/build/manifest.js +423 -423
- package/dist/build/rsc/client-manifest.d.ts +62 -62
- package/dist/build/rsc/client-manifest.js +295 -295
- package/dist/build/rsc/compiler.js +5 -4
- package/dist/build/rsc/native-scanner.d.ts +135 -135
- package/dist/build/rsc/native-scanner.js +203 -203
- package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -28
- package/dist/build/rsc/react-client-reference-manifest.js +240 -240
- package/dist/build/standalone.js +260 -254
- package/dist/client/dynamic.react-server.d.ts +2 -2
- package/dist/client/dynamic.react-server.js +23 -23
- package/dist/client/link.react-server.d.ts +2 -2
- package/dist/client/link.react-server.js +11 -11
- package/dist/client/navigation.react-server.d.ts +1 -1
- package/dist/client/navigation.react-server.js +17 -17
- package/dist/client/router.react-server.d.ts +1 -1
- package/dist/client/router.react-server.js +17 -17
- package/dist/client/rsc-router.react-server.d.ts +1 -1
- package/dist/client/rsc-router.react-server.js +17 -17
- package/dist/client/script.react-server.d.ts +2 -2
- package/dist/client/script.react-server.js +23 -23
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -7
- package/dist/deploy/adapters/cloudflare.js +43 -19
- package/dist/deploy/adapters/docker.d.ts +1 -0
- package/dist/deploy/adapters/docker.js +5 -4
- package/dist/deploy/adapters/netlify.js +62 -17
- package/dist/deploy/adapters/vercel.js +80 -50
- package/dist/deploy/preflight.js +4 -3
- package/dist/deploy/runtime-pack.d.ts +11 -0
- package/dist/deploy/runtime-pack.js +300 -0
- package/dist/deploy/utils.d.ts +1 -1
- package/dist/deploy/utils.js +31 -2
- package/dist/flashpack/command.js +1 -0
- package/dist/flashpack/runtime.js +2 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +61 -61
- package/dist/server/app-dir.d.ts +22 -0
- package/dist/server/app-dir.js +77 -0
- package/dist/server/cookie-parse.d.ts +4 -4
- package/dist/server/cookie-parse.js +14 -14
- package/dist/server/engine.js +5 -5
- package/dist/server/image-optimizer.js +2 -1
- package/dist/server/index.d.ts +109 -109
- package/dist/server/index.js +315 -315
- package/dist/server/middleware-runner.d.ts +125 -125
- package/dist/server/middleware-runner.js +607 -615
- package/dist/server/middleware-security.d.ts +36 -36
- package/dist/server/middleware-security.js +183 -183
- package/dist/server/module-compile-hook.js +695 -695
- package/dist/server/root-resolver.js +6 -5
- package/dist/server/rsc-engine-flashpack.d.ts +3 -1
- package/dist/server/rsc-engine-flashpack.js +12 -1
- package/dist/server/rsc-engine.d.ts +6 -1
- package/dist/server/rsc-engine.js +203 -219
- package/dist/server/rsc-upstream.js +893 -892
- package/dist/server/static-generator.js +4 -3
- package/dist/server/structure-validator.js +2 -1
- package/dist/server/structure-watch.js +2 -0
- package/dist/server/typed-api-runtime.js +639 -635
- package/dist/server/vista-import-map.js +134 -134
- package/dist/stack/index.d.ts +34 -34
- package/dist/stack/index.js +49 -49
- package/dist/stack/server/caller.d.ts +13 -13
- package/dist/stack/server/caller.js +42 -42
- package/dist/stack/server/executor.d.ts +40 -40
- package/dist/stack/server/executor.js +222 -222
- package/dist/stack/server/index.d.ts +11 -11
- package/dist/stack/server/index.js +24 -24
- package/dist/stack/server/procedure.d.ts +20 -20
- package/dist/stack/server/procedure.js +66 -66
- package/dist/stack/server/types.d.ts +113 -113
- package/dist/theme/react-server.d.ts +10 -10
- package/dist/theme/react-server.js +16 -16
- package/package.json +1 -1
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveVistaSourceRequest = resolveVistaSourceRequest;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
let nativeModule = null;
|
|
10
|
-
let nativeLoadAttempted = false;
|
|
11
|
-
function loadNativeModule() {
|
|
12
|
-
if (nativeLoadAttempted) {
|
|
13
|
-
return nativeModule;
|
|
14
|
-
}
|
|
15
|
-
nativeLoadAttempted = true;
|
|
16
|
-
const possiblePaths = [
|
|
17
|
-
path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
|
|
18
|
-
path_1.default.resolve(__dirname, '../../../crates/vista-napi'),
|
|
19
|
-
path_1.default.resolve(process.cwd(), '../crates/vista-napi'),
|
|
20
|
-
'@aspect-build/vista-napi',
|
|
21
|
-
];
|
|
22
|
-
for (const modulePath of possiblePaths) {
|
|
23
|
-
try {
|
|
24
|
-
nativeModule = require(modulePath);
|
|
25
|
-
return nativeModule;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
// continue
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
function resolveExistingModuleBase(candidateBase) {
|
|
34
|
-
for (const extension of ['.js', '.ts', '.tsx', '.jsx']) {
|
|
35
|
-
const absolutePath = `${candidateBase}${extension}`;
|
|
36
|
-
if (fs_1.default.existsSync(absolutePath)) {
|
|
37
|
-
return absolutePath;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
for (const extension of ['.js', '.ts', '.tsx', '.jsx']) {
|
|
41
|
-
const indexPath = path_1.default.join(candidateBase, `index${extension}`);
|
|
42
|
-
if (fs_1.default.existsSync(indexPath)) {
|
|
43
|
-
return indexPath;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
function normalizeVistaRequest(request) {
|
|
49
|
-
const normalizedRequest = request === '@vistagenic/vista'
|
|
50
|
-
? 'vista'
|
|
51
|
-
: request.startsWith('@vistagenic/vista/')
|
|
52
|
-
? `vista/${request.slice('@vistagenic/vista/'.length)}`
|
|
53
|
-
: request;
|
|
54
|
-
if (normalizedRequest !== 'vista' && !normalizedRequest.startsWith('vista/')) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return normalizedRequest;
|
|
58
|
-
}
|
|
59
|
-
function resolveSourceCandidates(packageRoot, subpath) {
|
|
60
|
-
if (subpath === '') {
|
|
61
|
-
return [path_1.default.join(packageRoot, 'react-server'), path_1.default.join(packageRoot, 'index')];
|
|
62
|
-
}
|
|
63
|
-
const sourceMap = {
|
|
64
|
-
link: [path_1.default.join(packageRoot, 'client', 'link.react-server'), path_1.default.join(packageRoot, 'client', 'link')],
|
|
65
|
-
image: [path_1.default.join(packageRoot, 'image', 'react-server'), path_1.default.join(packageRoot, 'image', 'index')],
|
|
66
|
-
router: [path_1.default.join(packageRoot, 'client', 'router.react-server'), path_1.default.join(packageRoot, 'client', 'router')],
|
|
67
|
-
navigation: [
|
|
68
|
-
path_1.default.join(packageRoot, 'client', 'navigation.react-server'),
|
|
69
|
-
path_1.default.join(packageRoot, 'client', 'navigation'),
|
|
70
|
-
],
|
|
71
|
-
dynamic: [path_1.default.join(packageRoot, 'client', 'dynamic.react-server'), path_1.default.join(packageRoot, 'client', 'dynamic')],
|
|
72
|
-
script: [path_1.default.join(packageRoot, 'client', 'script.react-server'), path_1.default.join(packageRoot, 'client', 'script')],
|
|
73
|
-
font: [path_1.default.join(packageRoot, 'font', 'index')],
|
|
74
|
-
'font/google': [path_1.default.join(packageRoot, 'font', 'google')],
|
|
75
|
-
'font/local': [path_1.default.join(packageRoot, 'font', 'local')],
|
|
76
|
-
theme: [path_1.default.join(packageRoot, 'theme', 'react-server'), path_1.default.join(packageRoot, 'theme', 'index')],
|
|
77
|
-
head: [path_1.default.join(packageRoot, 'client', 'head.react-server'), path_1.default.join(packageRoot, 'client', 'head')],
|
|
78
|
-
config: [path_1.default.join(packageRoot, 'config')],
|
|
79
|
-
auth: [path_1.default.join(packageRoot, 'auth', 'index')],
|
|
80
|
-
'auth/react': [path_1.default.join(packageRoot, 'auth', 'react-server'), path_1.default.join(packageRoot, 'auth', 'react')],
|
|
81
|
-
ai: [path_1.default.join(packageRoot, 'ai', 'index')],
|
|
82
|
-
'ai/react': [path_1.default.join(packageRoot, 'ai', 'react', 'react-server'), path_1.default.join(packageRoot, 'ai', 'react', 'index')],
|
|
83
|
-
stack: [path_1.default.join(packageRoot, 'stack', 'index')],
|
|
84
|
-
'stack/client': [path_1.default.join(packageRoot, 'stack', 'client', 'index')],
|
|
85
|
-
'client/rsc-router': [
|
|
86
|
-
path_1.default.join(packageRoot, 'client', 'rsc-router.react-server'),
|
|
87
|
-
path_1.default.join(packageRoot, 'client', 'rsc-router'),
|
|
88
|
-
],
|
|
89
|
-
'client/server-actions': [path_1.default.join(packageRoot, 'client', 'server-actions')],
|
|
90
|
-
server: [path_1.default.join(packageRoot, 'server', 'index')],
|
|
91
|
-
'server/runtime-actions': [path_1.default.join(packageRoot, 'server', 'runtime-actions')],
|
|
92
|
-
cache: [path_1.default.join(packageRoot, 'server', 'cache')],
|
|
93
|
-
};
|
|
94
|
-
if (sourceMap[subpath]) {
|
|
95
|
-
return sourceMap[subpath];
|
|
96
|
-
}
|
|
97
|
-
if (subpath.startsWith('server/')) {
|
|
98
|
-
return [path_1.default.join(packageRoot, 'server', subpath.slice('server/'.length))];
|
|
99
|
-
}
|
|
100
|
-
if (subpath.startsWith('client/')) {
|
|
101
|
-
return [path_1.default.join(packageRoot, 'client', subpath.slice('client/'.length))];
|
|
102
|
-
}
|
|
103
|
-
return [path_1.default.join(packageRoot, subpath)];
|
|
104
|
-
}
|
|
105
|
-
function resolveVistaSourceRequest(request, packageRoot) {
|
|
106
|
-
const native = loadNativeModule();
|
|
107
|
-
if (native?.resolveVistaSourceImport) {
|
|
108
|
-
try {
|
|
109
|
-
const nativeResolution = native.resolveVistaSourceImport(request, packageRoot);
|
|
110
|
-
if (nativeResolution?.resolvedPath) {
|
|
111
|
-
return nativeResolution.resolvedPath;
|
|
112
|
-
}
|
|
113
|
-
if (nativeResolution) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
// fall through to JS fallback
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const normalizedRequest = normalizeVistaRequest(request);
|
|
122
|
-
if (!normalizedRequest) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
const subpath = normalizedRequest === 'vista' ? '' : normalizedRequest.slice('vista/'.length);
|
|
126
|
-
const candidateBases = resolveSourceCandidates(packageRoot, subpath);
|
|
127
|
-
for (const candidateBase of candidateBases) {
|
|
128
|
-
const resolved = resolveExistingModuleBase(candidateBase);
|
|
129
|
-
if (resolved) {
|
|
130
|
-
return resolved;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveVistaSourceRequest = resolveVistaSourceRequest;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
let nativeModule = null;
|
|
10
|
+
let nativeLoadAttempted = false;
|
|
11
|
+
function loadNativeModule() {
|
|
12
|
+
if (nativeLoadAttempted) {
|
|
13
|
+
return nativeModule;
|
|
14
|
+
}
|
|
15
|
+
nativeLoadAttempted = true;
|
|
16
|
+
const possiblePaths = [
|
|
17
|
+
path_1.default.resolve(__dirname, '../../../../crates/vista-napi'),
|
|
18
|
+
path_1.default.resolve(__dirname, '../../../crates/vista-napi'),
|
|
19
|
+
path_1.default.resolve(process.cwd(), '../crates/vista-napi'),
|
|
20
|
+
'@aspect-build/vista-napi',
|
|
21
|
+
];
|
|
22
|
+
for (const modulePath of possiblePaths) {
|
|
23
|
+
try {
|
|
24
|
+
nativeModule = require(modulePath);
|
|
25
|
+
return nativeModule;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// continue
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function resolveExistingModuleBase(candidateBase) {
|
|
34
|
+
for (const extension of ['.js', '.ts', '.tsx', '.jsx']) {
|
|
35
|
+
const absolutePath = `${candidateBase}${extension}`;
|
|
36
|
+
if (fs_1.default.existsSync(absolutePath)) {
|
|
37
|
+
return absolutePath;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const extension of ['.js', '.ts', '.tsx', '.jsx']) {
|
|
41
|
+
const indexPath = path_1.default.join(candidateBase, `index${extension}`);
|
|
42
|
+
if (fs_1.default.existsSync(indexPath)) {
|
|
43
|
+
return indexPath;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function normalizeVistaRequest(request) {
|
|
49
|
+
const normalizedRequest = request === '@vistagenic/vista'
|
|
50
|
+
? 'vista'
|
|
51
|
+
: request.startsWith('@vistagenic/vista/')
|
|
52
|
+
? `vista/${request.slice('@vistagenic/vista/'.length)}`
|
|
53
|
+
: request;
|
|
54
|
+
if (normalizedRequest !== 'vista' && !normalizedRequest.startsWith('vista/')) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return normalizedRequest;
|
|
58
|
+
}
|
|
59
|
+
function resolveSourceCandidates(packageRoot, subpath) {
|
|
60
|
+
if (subpath === '') {
|
|
61
|
+
return [path_1.default.join(packageRoot, 'react-server'), path_1.default.join(packageRoot, 'index')];
|
|
62
|
+
}
|
|
63
|
+
const sourceMap = {
|
|
64
|
+
link: [path_1.default.join(packageRoot, 'client', 'link.react-server'), path_1.default.join(packageRoot, 'client', 'link')],
|
|
65
|
+
image: [path_1.default.join(packageRoot, 'image', 'react-server'), path_1.default.join(packageRoot, 'image', 'index')],
|
|
66
|
+
router: [path_1.default.join(packageRoot, 'client', 'router.react-server'), path_1.default.join(packageRoot, 'client', 'router')],
|
|
67
|
+
navigation: [
|
|
68
|
+
path_1.default.join(packageRoot, 'client', 'navigation.react-server'),
|
|
69
|
+
path_1.default.join(packageRoot, 'client', 'navigation'),
|
|
70
|
+
],
|
|
71
|
+
dynamic: [path_1.default.join(packageRoot, 'client', 'dynamic.react-server'), path_1.default.join(packageRoot, 'client', 'dynamic')],
|
|
72
|
+
script: [path_1.default.join(packageRoot, 'client', 'script.react-server'), path_1.default.join(packageRoot, 'client', 'script')],
|
|
73
|
+
font: [path_1.default.join(packageRoot, 'font', 'index')],
|
|
74
|
+
'font/google': [path_1.default.join(packageRoot, 'font', 'google')],
|
|
75
|
+
'font/local': [path_1.default.join(packageRoot, 'font', 'local')],
|
|
76
|
+
theme: [path_1.default.join(packageRoot, 'theme', 'react-server'), path_1.default.join(packageRoot, 'theme', 'index')],
|
|
77
|
+
head: [path_1.default.join(packageRoot, 'client', 'head.react-server'), path_1.default.join(packageRoot, 'client', 'head')],
|
|
78
|
+
config: [path_1.default.join(packageRoot, 'config')],
|
|
79
|
+
auth: [path_1.default.join(packageRoot, 'auth', 'index')],
|
|
80
|
+
'auth/react': [path_1.default.join(packageRoot, 'auth', 'react-server'), path_1.default.join(packageRoot, 'auth', 'react')],
|
|
81
|
+
ai: [path_1.default.join(packageRoot, 'ai', 'index')],
|
|
82
|
+
'ai/react': [path_1.default.join(packageRoot, 'ai', 'react', 'react-server'), path_1.default.join(packageRoot, 'ai', 'react', 'index')],
|
|
83
|
+
stack: [path_1.default.join(packageRoot, 'stack', 'index')],
|
|
84
|
+
'stack/client': [path_1.default.join(packageRoot, 'stack', 'client', 'index')],
|
|
85
|
+
'client/rsc-router': [
|
|
86
|
+
path_1.default.join(packageRoot, 'client', 'rsc-router.react-server'),
|
|
87
|
+
path_1.default.join(packageRoot, 'client', 'rsc-router'),
|
|
88
|
+
],
|
|
89
|
+
'client/server-actions': [path_1.default.join(packageRoot, 'client', 'server-actions')],
|
|
90
|
+
server: [path_1.default.join(packageRoot, 'server', 'index')],
|
|
91
|
+
'server/runtime-actions': [path_1.default.join(packageRoot, 'server', 'runtime-actions')],
|
|
92
|
+
cache: [path_1.default.join(packageRoot, 'server', 'cache')],
|
|
93
|
+
};
|
|
94
|
+
if (sourceMap[subpath]) {
|
|
95
|
+
return sourceMap[subpath];
|
|
96
|
+
}
|
|
97
|
+
if (subpath.startsWith('server/')) {
|
|
98
|
+
return [path_1.default.join(packageRoot, 'server', subpath.slice('server/'.length))];
|
|
99
|
+
}
|
|
100
|
+
if (subpath.startsWith('client/')) {
|
|
101
|
+
return [path_1.default.join(packageRoot, 'client', subpath.slice('client/'.length))];
|
|
102
|
+
}
|
|
103
|
+
return [path_1.default.join(packageRoot, subpath)];
|
|
104
|
+
}
|
|
105
|
+
function resolveVistaSourceRequest(request, packageRoot) {
|
|
106
|
+
const native = loadNativeModule();
|
|
107
|
+
if (native?.resolveVistaSourceImport) {
|
|
108
|
+
try {
|
|
109
|
+
const nativeResolution = native.resolveVistaSourceImport(request, packageRoot);
|
|
110
|
+
if (nativeResolution?.resolvedPath) {
|
|
111
|
+
return nativeResolution.resolvedPath;
|
|
112
|
+
}
|
|
113
|
+
if (nativeResolution) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// fall through to JS fallback
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const normalizedRequest = normalizeVistaRequest(request);
|
|
122
|
+
if (!normalizedRequest) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const subpath = normalizedRequest === 'vista' ? '' : normalizedRequest.slice('vista/'.length);
|
|
126
|
+
const candidateBases = resolveSourceCandidates(packageRoot, subpath);
|
|
127
|
+
for (const candidateBase of candidateBases) {
|
|
128
|
+
const resolved = resolveExistingModuleBase(candidateBase);
|
|
129
|
+
if (resolved) {
|
|
130
|
+
return resolved;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
package/dist/stack/index.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { mergeRouters as mergeStackRouters } from './server/merge-routers';
|
|
2
|
-
import { type CreateCallerOptions, type InferCaller } from './server/caller';
|
|
3
|
-
import { type ProcedureBuilder } from './server/procedure';
|
|
4
|
-
import { type CreateRouterOptions } from './server/router';
|
|
5
|
-
import { type StackSerializer } from './server/serialization';
|
|
6
|
-
import type { MiddlewareFunction, ProcedureRecord, StackRouter, StackSerializationMode } from './server/types';
|
|
7
|
-
/**
|
|
8
|
-
* Package entry for `@vistagenic/vista/stack`.
|
|
9
|
-
*
|
|
10
|
-
* Example:
|
|
11
|
-
* import { vstack } from '@vistagenic/vista/stack'
|
|
12
|
-
* const v = vstack.init()
|
|
13
|
-
*/
|
|
14
|
-
export interface VStackInitOptions {
|
|
15
|
-
serialization?: StackSerializationMode;
|
|
16
|
-
}
|
|
17
|
-
export interface VStackInstance<TCtx, TEnv> {
|
|
18
|
-
procedure: ProcedureBuilder<TCtx, TEnv>;
|
|
19
|
-
middleware<TCurrentCtx extends TCtx, TOutput extends Record<string, unknown> = {}>(handler: MiddlewareFunction<TCurrentCtx, TOutput, TEnv>): MiddlewareFunction<TCurrentCtx, TOutput, TEnv>;
|
|
20
|
-
router<TProcedures extends ProcedureRecord>(procedures: TProcedures, options?: CreateRouterOptions<TEnv>): StackRouter<TProcedures, TCtx, TEnv>;
|
|
21
|
-
mergeRouters: typeof mergeStackRouters;
|
|
22
|
-
createCaller<TProcedures extends ProcedureRecord>(router: StackRouter<TProcedures, TCtx, TEnv>, options: CreateCallerOptions<TCtx, TEnv>): InferCaller<TProcedures>;
|
|
23
|
-
serializer: StackSerializer;
|
|
24
|
-
options: Required<VStackInitOptions>;
|
|
25
|
-
}
|
|
26
|
-
export declare function initStack<TCtx extends Record<string, unknown> = {}, TEnv = unknown>(options?: VStackInitOptions): VStackInstance<TCtx, TEnv>;
|
|
27
|
-
export declare const vstack: {
|
|
28
|
-
init: typeof initStack;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Re-export server stack primitives from `@vistagenic/vista/stack`.
|
|
32
|
-
*/
|
|
33
|
-
export type { CreateRouterOptions } from './server/router';
|
|
34
|
-
export * from './server';
|
|
1
|
+
import { mergeRouters as mergeStackRouters } from './server/merge-routers';
|
|
2
|
+
import { type CreateCallerOptions, type InferCaller } from './server/caller';
|
|
3
|
+
import { type ProcedureBuilder } from './server/procedure';
|
|
4
|
+
import { type CreateRouterOptions } from './server/router';
|
|
5
|
+
import { type StackSerializer } from './server/serialization';
|
|
6
|
+
import type { MiddlewareFunction, ProcedureRecord, StackRouter, StackSerializationMode } from './server/types';
|
|
7
|
+
/**
|
|
8
|
+
* Package entry for `@vistagenic/vista/stack`.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* import { vstack } from '@vistagenic/vista/stack'
|
|
12
|
+
* const v = vstack.init()
|
|
13
|
+
*/
|
|
14
|
+
export interface VStackInitOptions {
|
|
15
|
+
serialization?: StackSerializationMode;
|
|
16
|
+
}
|
|
17
|
+
export interface VStackInstance<TCtx, TEnv> {
|
|
18
|
+
procedure: ProcedureBuilder<TCtx, TEnv>;
|
|
19
|
+
middleware<TCurrentCtx extends TCtx, TOutput extends Record<string, unknown> = {}>(handler: MiddlewareFunction<TCurrentCtx, TOutput, TEnv>): MiddlewareFunction<TCurrentCtx, TOutput, TEnv>;
|
|
20
|
+
router<TProcedures extends ProcedureRecord>(procedures: TProcedures, options?: CreateRouterOptions<TEnv>): StackRouter<TProcedures, TCtx, TEnv>;
|
|
21
|
+
mergeRouters: typeof mergeStackRouters;
|
|
22
|
+
createCaller<TProcedures extends ProcedureRecord>(router: StackRouter<TProcedures, TCtx, TEnv>, options: CreateCallerOptions<TCtx, TEnv>): InferCaller<TProcedures>;
|
|
23
|
+
serializer: StackSerializer;
|
|
24
|
+
options: Required<VStackInitOptions>;
|
|
25
|
+
}
|
|
26
|
+
export declare function initStack<TCtx extends Record<string, unknown> = {}, TEnv = unknown>(options?: VStackInitOptions): VStackInstance<TCtx, TEnv>;
|
|
27
|
+
export declare const vstack: {
|
|
28
|
+
init: typeof initStack;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Re-export server stack primitives from `@vistagenic/vista/stack`.
|
|
32
|
+
*/
|
|
33
|
+
export type { CreateRouterOptions } from './server/router';
|
|
34
|
+
export * from './server';
|
package/dist/stack/index.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.vstack = void 0;
|
|
18
|
-
exports.initStack = initStack;
|
|
19
|
-
const merge_routers_1 = require("./server/merge-routers");
|
|
20
|
-
const caller_1 = require("./server/caller");
|
|
21
|
-
const procedure_1 = require("./server/procedure");
|
|
22
|
-
const router_1 = require("./server/router");
|
|
23
|
-
const serialization_1 = require("./server/serialization");
|
|
24
|
-
function initStack(options = {}) {
|
|
25
|
-
const normalizedOptions = {
|
|
26
|
-
serialization: options.serialization ?? 'json',
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
procedure: (0, procedure_1.createProcedureBuilder)(),
|
|
30
|
-
middleware(handler) {
|
|
31
|
-
return handler;
|
|
32
|
-
},
|
|
33
|
-
router(procedures, routerOptions) {
|
|
34
|
-
return (0, router_1.createRouter)(procedures, routerOptions);
|
|
35
|
-
},
|
|
36
|
-
mergeRouters(...routers) {
|
|
37
|
-
return (0, merge_routers_1.mergeRouters)(...routers);
|
|
38
|
-
},
|
|
39
|
-
createCaller(router, callerOptions) {
|
|
40
|
-
return (0, caller_1.createCaller)(router, callerOptions);
|
|
41
|
-
},
|
|
42
|
-
serializer: (0, serialization_1.createSerializer)(normalizedOptions.serialization),
|
|
43
|
-
options: normalizedOptions,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
exports.vstack = {
|
|
47
|
-
init: initStack,
|
|
48
|
-
};
|
|
49
|
-
__exportStar(require("./server"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.vstack = void 0;
|
|
18
|
+
exports.initStack = initStack;
|
|
19
|
+
const merge_routers_1 = require("./server/merge-routers");
|
|
20
|
+
const caller_1 = require("./server/caller");
|
|
21
|
+
const procedure_1 = require("./server/procedure");
|
|
22
|
+
const router_1 = require("./server/router");
|
|
23
|
+
const serialization_1 = require("./server/serialization");
|
|
24
|
+
function initStack(options = {}) {
|
|
25
|
+
const normalizedOptions = {
|
|
26
|
+
serialization: options.serialization ?? 'json',
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
procedure: (0, procedure_1.createProcedureBuilder)(),
|
|
30
|
+
middleware(handler) {
|
|
31
|
+
return handler;
|
|
32
|
+
},
|
|
33
|
+
router(procedures, routerOptions) {
|
|
34
|
+
return (0, router_1.createRouter)(procedures, routerOptions);
|
|
35
|
+
},
|
|
36
|
+
mergeRouters(...routers) {
|
|
37
|
+
return (0, merge_routers_1.mergeRouters)(...routers);
|
|
38
|
+
},
|
|
39
|
+
createCaller(router, callerOptions) {
|
|
40
|
+
return (0, caller_1.createCaller)(router, callerOptions);
|
|
41
|
+
},
|
|
42
|
+
serializer: (0, serialization_1.createSerializer)(normalizedOptions.serialization),
|
|
43
|
+
options: normalizedOptions,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.vstack = {
|
|
47
|
+
init: initStack,
|
|
48
|
+
};
|
|
49
|
+
__exportStar(require("./server"), exports);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { OperationType, ProcedureRecord, StackRequestLike, StackRouter, StackSerializationMode } from './types';
|
|
2
|
-
export interface CreateCallerOptions<TCtx, TEnv> {
|
|
3
|
-
ctx: TCtx;
|
|
4
|
-
env: TEnv;
|
|
5
|
-
req?: StackRequestLike;
|
|
6
|
-
serialization?: StackSerializationMode;
|
|
7
|
-
}
|
|
8
|
-
type CallerFn<TInput, TOutput> = [TInput] extends [void] ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
9
|
-
export type InferCaller<TNode> = TNode extends OperationType<infer TInput, infer TOutput, any, any> ? CallerFn<TInput, TOutput> : TNode extends ProcedureRecord ? {
|
|
10
|
-
[TKey in keyof TNode]: InferCaller<TNode[TKey]>;
|
|
11
|
-
} : never;
|
|
12
|
-
export declare function createCaller<TProcedures extends ProcedureRecord, TCtx, TEnv>(router: StackRouter<TProcedures, TCtx, TEnv>, options: CreateCallerOptions<TCtx, TEnv>): InferCaller<TProcedures>;
|
|
13
|
-
export {};
|
|
1
|
+
import type { OperationType, ProcedureRecord, StackRequestLike, StackRouter, StackSerializationMode } from './types';
|
|
2
|
+
export interface CreateCallerOptions<TCtx, TEnv> {
|
|
3
|
+
ctx: TCtx;
|
|
4
|
+
env: TEnv;
|
|
5
|
+
req?: StackRequestLike;
|
|
6
|
+
serialization?: StackSerializationMode;
|
|
7
|
+
}
|
|
8
|
+
type CallerFn<TInput, TOutput> = [TInput] extends [void] ? () => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
|
|
9
|
+
export type InferCaller<TNode> = TNode extends OperationType<infer TInput, infer TOutput, any, any> ? CallerFn<TInput, TOutput> : TNode extends ProcedureRecord ? {
|
|
10
|
+
[TKey in keyof TNode]: InferCaller<TNode[TKey]>;
|
|
11
|
+
} : never;
|
|
12
|
+
export declare function createCaller<TProcedures extends ProcedureRecord, TCtx, TEnv>(router: StackRouter<TProcedures, TCtx, TEnv>, options: CreateCallerOptions<TCtx, TEnv>): InferCaller<TProcedures>;
|
|
13
|
+
export {};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCaller = createCaller;
|
|
4
|
-
const procedure_1 = require("./procedure");
|
|
5
|
-
const executor_1 = require("./executor");
|
|
6
|
-
function buildRequest(operation, input, base) {
|
|
7
|
-
if (operation.type === 'get') {
|
|
8
|
-
return {
|
|
9
|
-
...base,
|
|
10
|
-
method: 'GET',
|
|
11
|
-
query: input ?? base?.query ?? {},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
...base,
|
|
16
|
-
method: 'POST',
|
|
17
|
-
body: input ?? base?.body,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function createNodeCaller(node, router, options) {
|
|
21
|
-
if ((0, procedure_1.isOperation)(node)) {
|
|
22
|
-
return async (input) => {
|
|
23
|
-
const toolkit = (0, executor_1.createResponseToolkit)(options.serialization ?? 'json');
|
|
24
|
-
return (0, executor_1.executeOperation)(node, {
|
|
25
|
-
ctx: options.ctx,
|
|
26
|
-
env: options.env,
|
|
27
|
-
req: buildRequest(node, input, options.req),
|
|
28
|
-
c: toolkit,
|
|
29
|
-
middlewares: router.metadata.globalMiddlewares,
|
|
30
|
-
serialization: options.serialization,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const nested = {};
|
|
35
|
-
for (const [key, child] of Object.entries(node)) {
|
|
36
|
-
nested[key] = createNodeCaller(child, router, options);
|
|
37
|
-
}
|
|
38
|
-
return nested;
|
|
39
|
-
}
|
|
40
|
-
function createCaller(router, options) {
|
|
41
|
-
return createNodeCaller(router.procedures, router, options);
|
|
42
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCaller = createCaller;
|
|
4
|
+
const procedure_1 = require("./procedure");
|
|
5
|
+
const executor_1 = require("./executor");
|
|
6
|
+
function buildRequest(operation, input, base) {
|
|
7
|
+
if (operation.type === 'get') {
|
|
8
|
+
return {
|
|
9
|
+
...base,
|
|
10
|
+
method: 'GET',
|
|
11
|
+
query: input ?? base?.query ?? {},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...base,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: input ?? base?.body,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createNodeCaller(node, router, options) {
|
|
21
|
+
if ((0, procedure_1.isOperation)(node)) {
|
|
22
|
+
return async (input) => {
|
|
23
|
+
const toolkit = (0, executor_1.createResponseToolkit)(options.serialization ?? 'json');
|
|
24
|
+
return (0, executor_1.executeOperation)(node, {
|
|
25
|
+
ctx: options.ctx,
|
|
26
|
+
env: options.env,
|
|
27
|
+
req: buildRequest(node, input, options.req),
|
|
28
|
+
c: toolkit,
|
|
29
|
+
middlewares: router.metadata.globalMiddlewares,
|
|
30
|
+
serialization: options.serialization,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const nested = {};
|
|
35
|
+
for (const [key, child] of Object.entries(node)) {
|
|
36
|
+
nested[key] = createNodeCaller(child, router, options);
|
|
37
|
+
}
|
|
38
|
+
return nested;
|
|
39
|
+
}
|
|
40
|
+
function createCaller(router, options) {
|
|
41
|
+
return createNodeCaller(router.procedures, router, options);
|
|
42
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import type { MiddlewareFunction, OperationType, ProcedureRecord, StackExecutionContext, StackRequestLike, StackResponseToolkit, StackRouter, StackSerializationMode } from './types';
|
|
2
|
-
export declare class StackRouteNotFoundError extends Error {
|
|
3
|
-
status: number;
|
|
4
|
-
constructor(path: string);
|
|
5
|
-
}
|
|
6
|
-
export declare class StackMethodNotAllowedError extends Error {
|
|
7
|
-
status: number;
|
|
8
|
-
constructor(path: string, method: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class StackValidationError extends Error {
|
|
11
|
-
status: number;
|
|
12
|
-
cause: unknown;
|
|
13
|
-
constructor(message: string, cause?: unknown);
|
|
14
|
-
}
|
|
15
|
-
export declare class StackOutputValidationError extends StackValidationError {
|
|
16
|
-
status: number;
|
|
17
|
-
constructor(message: string, cause?: unknown);
|
|
18
|
-
}
|
|
19
|
-
export declare function createResponseToolkit(mode?: StackSerializationMode): StackResponseToolkit;
|
|
20
|
-
export declare function runMiddlewareChain<TCtx, TEnv>(middlewares: MiddlewareFunction<any, any, TEnv>[], context: TCtx, env: TEnv, req: StackRequestLike, c: StackResponseToolkit): Promise<TCtx>;
|
|
21
|
-
export interface ExecuteOperationOptions<TCtx, TEnv> extends StackExecutionContext<TCtx, TEnv> {
|
|
22
|
-
middlewares?: MiddlewareFunction<any, any, TEnv>[];
|
|
23
|
-
serialization?: StackSerializationMode;
|
|
24
|
-
}
|
|
25
|
-
export declare function executeOperation<TCtx, TInput, TOutput, TEnv>(operation: OperationType<TInput, TOutput, TCtx, TEnv>, options: ExecuteOperationOptions<TCtx, TEnv>): Promise<TOutput>;
|
|
26
|
-
export interface ExecuteRouteOptions<TCtx, TEnv> {
|
|
27
|
-
path: string;
|
|
28
|
-
method: string;
|
|
29
|
-
req: StackRequestLike;
|
|
30
|
-
ctx: TCtx;
|
|
31
|
-
env: TEnv;
|
|
32
|
-
serialization?: StackSerializationMode;
|
|
33
|
-
}
|
|
34
|
-
export interface ExecuteRouteResult<TData = unknown> {
|
|
35
|
-
path: string;
|
|
36
|
-
method: string;
|
|
37
|
-
data: TData;
|
|
38
|
-
serializedData: unknown;
|
|
39
|
-
}
|
|
40
|
-
export declare function executeRoute<TProcedures extends ProcedureRecord, TCtx, TEnv>(router: StackRouter<TProcedures, TCtx, TEnv>, options: ExecuteRouteOptions<TCtx, TEnv>): Promise<ExecuteRouteResult>;
|
|
1
|
+
import type { MiddlewareFunction, OperationType, ProcedureRecord, StackExecutionContext, StackRequestLike, StackResponseToolkit, StackRouter, StackSerializationMode } from './types';
|
|
2
|
+
export declare class StackRouteNotFoundError extends Error {
|
|
3
|
+
status: number;
|
|
4
|
+
constructor(path: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class StackMethodNotAllowedError extends Error {
|
|
7
|
+
status: number;
|
|
8
|
+
constructor(path: string, method: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class StackValidationError extends Error {
|
|
11
|
+
status: number;
|
|
12
|
+
cause: unknown;
|
|
13
|
+
constructor(message: string, cause?: unknown);
|
|
14
|
+
}
|
|
15
|
+
export declare class StackOutputValidationError extends StackValidationError {
|
|
16
|
+
status: number;
|
|
17
|
+
constructor(message: string, cause?: unknown);
|
|
18
|
+
}
|
|
19
|
+
export declare function createResponseToolkit(mode?: StackSerializationMode): StackResponseToolkit;
|
|
20
|
+
export declare function runMiddlewareChain<TCtx, TEnv>(middlewares: MiddlewareFunction<any, any, TEnv>[], context: TCtx, env: TEnv, req: StackRequestLike, c: StackResponseToolkit): Promise<TCtx>;
|
|
21
|
+
export interface ExecuteOperationOptions<TCtx, TEnv> extends StackExecutionContext<TCtx, TEnv> {
|
|
22
|
+
middlewares?: MiddlewareFunction<any, any, TEnv>[];
|
|
23
|
+
serialization?: StackSerializationMode;
|
|
24
|
+
}
|
|
25
|
+
export declare function executeOperation<TCtx, TInput, TOutput, TEnv>(operation: OperationType<TInput, TOutput, TCtx, TEnv>, options: ExecuteOperationOptions<TCtx, TEnv>): Promise<TOutput>;
|
|
26
|
+
export interface ExecuteRouteOptions<TCtx, TEnv> {
|
|
27
|
+
path: string;
|
|
28
|
+
method: string;
|
|
29
|
+
req: StackRequestLike;
|
|
30
|
+
ctx: TCtx;
|
|
31
|
+
env: TEnv;
|
|
32
|
+
serialization?: StackSerializationMode;
|
|
33
|
+
}
|
|
34
|
+
export interface ExecuteRouteResult<TData = unknown> {
|
|
35
|
+
path: string;
|
|
36
|
+
method: string;
|
|
37
|
+
data: TData;
|
|
38
|
+
serializedData: unknown;
|
|
39
|
+
}
|
|
40
|
+
export declare function executeRoute<TProcedures extends ProcedureRecord, TCtx, TEnv>(router: StackRouter<TProcedures, TCtx, TEnv>, options: ExecuteRouteOptions<TCtx, TEnv>): Promise<ExecuteRouteResult>;
|