veryfront 0.1.114 → 0.1.116
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/esm/deno.js +1 -1
- package/esm/src/server/handlers/dev/files/dev-file.handler.d.ts +1 -0
- package/esm/src/server/handlers/dev/files/dev-file.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/files/dev-file.handler.js +31 -2
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/server/handlers/dev/files/dev-file.handler.ts +44 -2
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -4,6 +4,7 @@ import type { HandlerContext, HandlerMetadata, HandlerResult } from "../../types
|
|
|
4
4
|
export declare class DevFileHandler extends BaseHandler {
|
|
5
5
|
metadata: HandlerMetadata;
|
|
6
6
|
handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult>;
|
|
7
|
+
private handleWithContext;
|
|
7
8
|
private createErrorModule;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=dev-file.handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-file.handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/dev/files/dev-file.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-file.handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/dev/files/dev-file.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;AAWxB,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,EAAE,eAAe,CAKvB;IAEI,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;YA4CjE,iBAAiB;IAmC/B,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -3,20 +3,49 @@ import { BaseHandler } from "../../response/base.js";
|
|
|
3
3
|
import { validateDevFilePath } from "./path-validator.js";
|
|
4
4
|
import { bundleDevFile } from "./esbuild-bundler.js";
|
|
5
5
|
import { HTTP_INTERNAL_SERVER_ERROR, HTTP_NOT_FOUND, PRIORITY_MEDIUM_DEV_FILES, } from "../../../../utils/constants/index.js";
|
|
6
|
+
import { isExtendedFSAdapter } from "../../../../platform/adapters/fs/wrapper.js";
|
|
7
|
+
import { getHostEnv } from "../../../../platform/compat/process.js";
|
|
6
8
|
export class DevFileHandler extends BaseHandler {
|
|
7
9
|
metadata = {
|
|
8
10
|
name: "DevFileHandler",
|
|
9
11
|
priority: PRIORITY_MEDIUM_DEV_FILES,
|
|
10
12
|
patterns: [{ pattern: "/_veryfront/fs/", prefix: true, method: "GET" }],
|
|
11
|
-
enabled: (ctx) => !!ctx.isLocalProject,
|
|
13
|
+
enabled: (ctx) => !!ctx.isLocalProject || ctx.requestContext?.mode === "preview",
|
|
12
14
|
};
|
|
13
15
|
async handle(req, ctx) {
|
|
14
16
|
const { pathname } = new URL(req.url);
|
|
15
|
-
|
|
17
|
+
const isPreviewMode = ctx.requestContext?.mode === "preview";
|
|
18
|
+
if (!ctx.isLocalProject && !isPreviewMode)
|
|
16
19
|
return this.continue();
|
|
17
20
|
if (req.method !== "GET" || !pathname.startsWith("/_veryfront/fs/")) {
|
|
18
21
|
return this.continue();
|
|
19
22
|
}
|
|
23
|
+
const fsAdapter = ctx.adapter.fs;
|
|
24
|
+
const isExtended = isExtendedFSAdapter(fsAdapter);
|
|
25
|
+
if (!ctx.isLocalProject && ctx.projectSlug && isExtended && fsAdapter.isMultiProjectMode()) {
|
|
26
|
+
const effectiveToken = ctx.proxyToken || getHostEnv("VERYFRONT_API_TOKEN") || "";
|
|
27
|
+
const branch = ctx.parsedDomain?.branch ?? null;
|
|
28
|
+
return await fsAdapter.runWithContext(ctx.projectSlug, effectiveToken, () => this.handleWithContext(req, pathname, ctx), ctx.projectId, {
|
|
29
|
+
productionMode: false,
|
|
30
|
+
releaseId: ctx.releaseId,
|
|
31
|
+
branch,
|
|
32
|
+
environmentName: ctx.environmentName,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (isExtended && fsAdapter.isContextualMode()) {
|
|
36
|
+
try {
|
|
37
|
+
if (ctx.proxyToken)
|
|
38
|
+
fsAdapter.setRequestToken(ctx.proxyToken);
|
|
39
|
+
fsAdapter.setRequestBranch(ctx.parsedDomain?.branch ?? null);
|
|
40
|
+
fsAdapter.setProductionMode(false, ctx.releaseId);
|
|
41
|
+
}
|
|
42
|
+
catch (_) {
|
|
43
|
+
/* expected: some fs adapter operations may not be supported */
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return await this.handleWithContext(req, pathname, ctx);
|
|
47
|
+
}
|
|
48
|
+
async handleWithContext(req, pathname, ctx) {
|
|
20
49
|
const encoded = pathname.slice("/_veryfront/fs/".length).replace(/\.js$/, "");
|
|
21
50
|
const absPath = await validateDevFilePath(encoded, ctx);
|
|
22
51
|
if (absPath.startsWith("Error:")) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.116";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -13,24 +13,66 @@ import {
|
|
|
13
13
|
HTTP_NOT_FOUND,
|
|
14
14
|
PRIORITY_MEDIUM_DEV_FILES,
|
|
15
15
|
} from "../../../../utils/constants/index.js";
|
|
16
|
+
import { isExtendedFSAdapter } from "../../../../platform/adapters/fs/wrapper.js";
|
|
17
|
+
import { getHostEnv } from "../../../../platform/compat/process.js";
|
|
16
18
|
|
|
17
19
|
export class DevFileHandler extends BaseHandler {
|
|
18
20
|
metadata: HandlerMetadata = {
|
|
19
21
|
name: "DevFileHandler",
|
|
20
22
|
priority: PRIORITY_MEDIUM_DEV_FILES as HandlerPriority,
|
|
21
23
|
patterns: [{ pattern: "/_veryfront/fs/", prefix: true, method: "GET" }],
|
|
22
|
-
enabled: (ctx) => !!ctx.isLocalProject,
|
|
24
|
+
enabled: (ctx) => !!ctx.isLocalProject || ctx.requestContext?.mode === "preview",
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
async handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult> {
|
|
26
28
|
const { pathname } = new URL(req.url);
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
const isPreviewMode = ctx.requestContext?.mode === "preview";
|
|
31
|
+
if (!ctx.isLocalProject && !isPreviewMode) return this.continue();
|
|
29
32
|
|
|
30
33
|
if (req.method !== "GET" || !pathname.startsWith("/_veryfront/fs/")) {
|
|
31
34
|
return this.continue();
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
const fsAdapter = ctx.adapter.fs;
|
|
38
|
+
const isExtended = isExtendedFSAdapter(fsAdapter);
|
|
39
|
+
|
|
40
|
+
if (!ctx.isLocalProject && ctx.projectSlug && isExtended && fsAdapter.isMultiProjectMode()) {
|
|
41
|
+
const effectiveToken = ctx.proxyToken || getHostEnv("VERYFRONT_API_TOKEN") || "";
|
|
42
|
+
const branch = ctx.parsedDomain?.branch ?? null;
|
|
43
|
+
|
|
44
|
+
return await fsAdapter.runWithContext(
|
|
45
|
+
ctx.projectSlug,
|
|
46
|
+
effectiveToken,
|
|
47
|
+
() => this.handleWithContext(req, pathname, ctx),
|
|
48
|
+
ctx.projectId,
|
|
49
|
+
{
|
|
50
|
+
productionMode: false,
|
|
51
|
+
releaseId: ctx.releaseId,
|
|
52
|
+
branch,
|
|
53
|
+
environmentName: ctx.environmentName,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (isExtended && fsAdapter.isContextualMode()) {
|
|
59
|
+
try {
|
|
60
|
+
if (ctx.proxyToken) fsAdapter.setRequestToken(ctx.proxyToken);
|
|
61
|
+
fsAdapter.setRequestBranch(ctx.parsedDomain?.branch ?? null);
|
|
62
|
+
fsAdapter.setProductionMode(false, ctx.releaseId);
|
|
63
|
+
} catch (_) {
|
|
64
|
+
/* expected: some fs adapter operations may not be supported */
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return await this.handleWithContext(req, pathname, ctx);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private async handleWithContext(
|
|
72
|
+
req: dntShim.Request,
|
|
73
|
+
pathname: string,
|
|
74
|
+
ctx: HandlerContext,
|
|
75
|
+
): Promise<HandlerResult> {
|
|
34
76
|
const encoded = pathname.slice("/_veryfront/fs/".length).replace(/\.js$/, "");
|
|
35
77
|
const absPath = await validateDevFilePath(encoded, ctx);
|
|
36
78
|
|