@probelabs/visor 0.1.90 → 0.1.93
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/README.md +68 -2
- package/action.yml +1 -1
- package/defaults/.visor.yaml +133 -168
- package/dist/13.index.js +82 -0
- package/dist/159.index.js +38 -0
- package/dist/168.index.js +82 -0
- package/dist/201.index.js +82 -0
- package/dist/262.index.js +48 -0
- package/dist/272.index.js +82 -0
- package/dist/273.index.js +48 -0
- package/dist/320.index.js +38 -0
- package/dist/34.index.js +81 -0
- package/dist/421.index.js +48 -0
- package/dist/437.index.js +82 -0
- package/dist/441.index.js +81 -0
- package/dist/450.index.js +82 -0
- package/dist/54.index.js +81 -0
- package/dist/544.index.js +38 -0
- package/dist/558.index.js +82 -0
- package/dist/715.index.js +38 -0
- package/dist/737.index.js +82 -0
- package/dist/834.index.js +48 -0
- package/dist/85.index.js +82 -0
- package/dist/861.index.js +48 -0
- package/dist/878.index.js +81 -0
- package/dist/940.index.js +38 -0
- package/dist/989.index.js +81 -0
- package/dist/996.index.js +82 -0
- package/dist/ai-review-service.d.ts +11 -1
- package/dist/ai-review-service.d.ts.map +1 -1
- package/dist/check-execution-engine.d.ts +15 -2
- package/dist/check-execution-engine.d.ts.map +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/defaults/.visor.yaml +133 -168
- package/dist/failure-condition-evaluator.d.ts +3 -2
- package/dist/failure-condition-evaluator.d.ts.map +1 -1
- package/dist/generated/config-schema.d.ts +89 -2
- package/dist/generated/config-schema.d.ts.map +1 -1
- package/dist/generated/config-schema.json +109 -1
- package/dist/git-repository-analyzer.d.ts +17 -1
- package/dist/git-repository-analyzer.d.ts.map +1 -1
- package/dist/github-comments.d.ts.map +1 -1
- package/dist/github-reactions.d.ts +36 -0
- package/dist/github-reactions.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173112 -46133
- package/dist/liquid-extensions.d.ts +15 -0
- package/dist/liquid-extensions.d.ts.map +1 -1
- package/dist/memory-store.d.ts +129 -0
- package/dist/memory-store.d.ts.map +1 -0
- package/dist/output/issue-assistant/schema.json +42 -0
- package/dist/output/issue-assistant/template.liquid +1 -0
- package/dist/output/overview/schema.json +33 -0
- package/dist/output/overview/template.liquid +16 -0
- package/dist/output-formatters.d.ts +1 -0
- package/dist/output-formatters.d.ts.map +1 -1
- package/dist/pr-analyzer.d.ts +2 -0
- package/dist/pr-analyzer.d.ts.map +1 -1
- package/dist/proto/channelz.proto +564 -0
- package/dist/providers/check-provider-registry.d.ts.map +1 -1
- package/dist/providers/command-check-provider.d.ts.map +1 -1
- package/dist/providers/github-ops-provider.d.ts +18 -0
- package/dist/providers/github-ops-provider.d.ts.map +1 -0
- package/dist/providers/memory-check-provider.d.ts +56 -0
- package/dist/providers/memory-check-provider.d.ts.map +1 -0
- package/dist/reviewer.d.ts +2 -0
- package/dist/reviewer.d.ts.map +1 -1
- package/dist/sdk/check-execution-engine-RORGGGGP.mjs +11 -0
- package/dist/sdk/chunk-I3GQJIR7.mjs +752 -0
- package/dist/sdk/chunk-I3GQJIR7.mjs.map +1 -0
- package/dist/sdk/chunk-KVHVCGY6.mjs +103 -0
- package/dist/sdk/chunk-KVHVCGY6.mjs.map +1 -0
- package/dist/sdk/chunk-TWJKAYT6.mjs +1124 -0
- package/dist/sdk/chunk-TWJKAYT6.mjs.map +1 -0
- package/dist/sdk/{chunk-N2PPFOSF.mjs → chunk-Z47UECAT.mjs} +2593 -264
- package/dist/sdk/chunk-Z47UECAT.mjs.map +1 -0
- package/dist/sdk/liquid-extensions-GMEGEGC3.mjs +18 -0
- package/dist/sdk/mermaid-telemetry-LZGDD35I.mjs +61 -0
- package/dist/sdk/mermaid-telemetry-LZGDD35I.mjs.map +1 -0
- package/dist/sdk/sdk.d.mts +48 -2
- package/dist/sdk/sdk.d.ts +48 -2
- package/dist/sdk/sdk.js +5372 -781
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +112 -7
- package/dist/sdk/sdk.mjs.map +1 -1
- package/dist/sdk/tracer-init-O7RLXMJ3.mjs +10 -0
- package/dist/sdk/tracer-init-O7RLXMJ3.mjs.map +1 -0
- package/dist/session-registry.d.ts +19 -5
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/telemetry/fallback-ndjson.d.ts +7 -0
- package/dist/telemetry/fallback-ndjson.d.ts.map +1 -0
- package/dist/telemetry/file-span-exporter.d.ts +17 -0
- package/dist/telemetry/file-span-exporter.d.ts.map +1 -0
- package/dist/telemetry/metrics.d.ts +13 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/opentelemetry.d.ts +26 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -0
- package/dist/telemetry/trace-helpers.d.ts +9 -0
- package/dist/telemetry/trace-helpers.d.ts.map +1 -0
- package/dist/telemetry/trace-report-exporter.d.ts +17 -0
- package/dist/telemetry/trace-report-exporter.d.ts.map +1 -0
- package/dist/traces/run-2025-10-15T11-54-04-087Z.ndjson +33 -0
- package/dist/traces/run-2025-10-15T11-54-14-046Z.ndjson +33 -0
- package/dist/traces/run-2025-10-15T11-54-14-575Z.ndjson +33 -0
- package/dist/traces/run-2025-10-15T11-54-15-082Z.ndjson +33 -0
- package/dist/traces/run-2025-10-15T11-54-15-561Z.ndjson +12 -0
- package/dist/types/cli.d.ts +4 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +56 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/author-permissions.d.ts +74 -0
- package/dist/utils/author-permissions.d.ts.map +1 -0
- package/dist/utils/head-sha.d.ts +8 -0
- package/dist/utils/head-sha.d.ts.map +1 -0
- package/dist/utils/mermaid-telemetry.d.ts +3 -0
- package/dist/utils/mermaid-telemetry.d.ts.map +1 -0
- package/dist/utils/tracer-init.d.ts +12 -0
- package/dist/utils/tracer-init.d.ts.map +1 -0
- package/dist/utils/ui-helpers.d.ts +3 -0
- package/dist/utils/ui-helpers.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/sdk/check-execution-engine-Z2USLMN5.mjs +0 -9
- package/dist/sdk/chunk-FIL2OGF6.mjs +0 -68
- package/dist/sdk/chunk-FIL2OGF6.mjs.map +0 -1
- package/dist/sdk/chunk-N2PPFOSF.mjs.map +0 -1
- package/dist/sdk/liquid-extensions-KDECAJTV.mjs +0 -12
- /package/dist/sdk/{check-execution-engine-Z2USLMN5.mjs.map → check-execution-engine-RORGGGGP.mjs.map} +0 -0
- /package/dist/sdk/{liquid-extensions-KDECAJTV.mjs.map → liquid-extensions-GMEGEGC3.mjs.map} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author permission utilities for checking GitHub author associations
|
|
3
|
+
*
|
|
4
|
+
* GitHub provides author_association field with these values (in order of privilege):
|
|
5
|
+
* - OWNER: Repository owner
|
|
6
|
+
* - MEMBER: Organization member
|
|
7
|
+
* - COLLABORATOR: Invited collaborator
|
|
8
|
+
* - CONTRIBUTOR: Has contributed before
|
|
9
|
+
* - FIRST_TIME_CONTRIBUTOR: First PR to this repo
|
|
10
|
+
* - FIRST_TIMER: First GitHub contribution ever
|
|
11
|
+
* - NONE: No association
|
|
12
|
+
*/
|
|
13
|
+
export type AuthorAssociation = 'OWNER' | 'MEMBER' | 'COLLABORATOR' | 'CONTRIBUTOR' | 'FIRST_TIME_CONTRIBUTOR' | 'FIRST_TIMER' | 'NONE';
|
|
14
|
+
/**
|
|
15
|
+
* Check if author has at least the specified permission level (>= logic)
|
|
16
|
+
*
|
|
17
|
+
* @param authorAssociation - The author's association from GitHub API
|
|
18
|
+
* @param minPermission - Minimum required permission level
|
|
19
|
+
* @param isLocalMode - Whether running in local/CLI mode (defaults to true for local runs)
|
|
20
|
+
* @returns true if author has at least the specified permission level
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* hasMinPermission('MEMBER', 'MEMBER') // true (exact match)
|
|
24
|
+
* hasMinPermission('OWNER', 'MEMBER') // true (owner >= member)
|
|
25
|
+
* hasMinPermission('COLLABORATOR', 'MEMBER') // false (collaborator < member)
|
|
26
|
+
* hasMinPermission(undefined, 'OWNER', true) // true (local mode)
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasMinPermission(authorAssociation: string | undefined, minPermission: AuthorAssociation, isLocalMode?: boolean): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if author is exactly the repository owner
|
|
31
|
+
*/
|
|
32
|
+
export declare function isOwner(authorAssociation: string | undefined, isLocalMode?: boolean): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if author is an organization member or owner
|
|
35
|
+
*/
|
|
36
|
+
export declare function isMember(authorAssociation: string | undefined, isLocalMode?: boolean): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if author is a collaborator (or higher)
|
|
39
|
+
*/
|
|
40
|
+
export declare function isCollaborator(authorAssociation: string | undefined, isLocalMode?: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if author is a contributor (has contributed before)
|
|
43
|
+
*/
|
|
44
|
+
export declare function isContributor(authorAssociation: string | undefined, isLocalMode?: boolean): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Check if author is a first-time contributor (to this repo or GitHub)
|
|
47
|
+
*/
|
|
48
|
+
export declare function isFirstTimer(authorAssociation: string | undefined, isLocalMode?: boolean): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Create permission helper functions bound to a specific author association
|
|
51
|
+
* This is used to inject functions into JavaScript execution contexts
|
|
52
|
+
*
|
|
53
|
+
* @param authorAssociation - The author's association from PR data
|
|
54
|
+
* @param isLocalMode - Whether running in local/CLI mode
|
|
55
|
+
*/
|
|
56
|
+
export declare function createPermissionHelpers(authorAssociation: string | undefined, isLocalMode?: boolean): {
|
|
57
|
+
hasMinPermission: (minPermission: AuthorAssociation) => boolean;
|
|
58
|
+
isOwner: () => boolean;
|
|
59
|
+
isMember: () => boolean;
|
|
60
|
+
isCollaborator: () => boolean;
|
|
61
|
+
isContributor: () => boolean;
|
|
62
|
+
isFirstTimer: () => boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Determine if we're running in local mode (not GitHub Actions)
|
|
66
|
+
*/
|
|
67
|
+
export declare function detectLocalMode(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the most relevant GitHub author association from an event context.
|
|
70
|
+
* Prefers commenter association for issue_comment events, then issue/PR author,
|
|
71
|
+
* and finally falls back to the provided default association.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveAssociationFromEvent(eventContext: any | undefined, fallback?: string): string | undefined;
|
|
74
|
+
//# sourceMappingURL=author-permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author-permissions.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/utils/author-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,aAAa,GACb,wBAAwB,GACxB,aAAa,GACb,MAAM,CAAC;AAwBX;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,aAAa,EAAE,iBAAiB,EAChC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAWT;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe,GAC3B,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,WAAW,GAAE,OAAe;sCAGQ,iBAAiB;;;;;;EAQtD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,GAAG,GAAG,SAAS,EAC7B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAYpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GitHubContext } from '../action-cli-bridge';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the PR head SHA for contexts like issue_comment where payload may not include head.sha.
|
|
4
|
+
* Falls back to a pulls.get API call when needed.
|
|
5
|
+
* Note: typed loosely to avoid importing Octokit in tests.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveHeadShaFromEvent(octokit: any, owner: string, repo: string, context: GitHubContext): Promise<string>;
|
|
8
|
+
//# sourceMappingURL=head-sha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"head-sha.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/utils/head-sha.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,GAAG,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-telemetry.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/utils/mermaid-telemetry.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,GACpB,MAAM,CAoDR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TelemetryConfig, AppTracer } from '@probelabs/probe';
|
|
2
|
+
/**
|
|
3
|
+
* Safely initialize a tracer for ProbeAgent with proper path sanitization
|
|
4
|
+
* Uses full OpenTelemetry integration for hierarchical span relationships
|
|
5
|
+
* This prevents path traversal vulnerabilities by sanitizing the checkName
|
|
6
|
+
*/
|
|
7
|
+
export declare function initializeTracer(sessionId: string, checkName?: string): Promise<{
|
|
8
|
+
tracer: AppTracer;
|
|
9
|
+
telemetryConfig: TelemetryConfig;
|
|
10
|
+
filePath: string;
|
|
11
|
+
} | null>;
|
|
12
|
+
//# sourceMappingURL=tracer-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracer-init.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/utils/tracer-init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAoC,MAAM,kBAAkB,CAAC;AAEhG;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,eAAe,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAkI3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-helpers.d.ts","sourceRoot":"","sources":["file:///home/runner/work/visor/visor/src/utils/ui-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAQtF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@probelabs/visor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"visor": "./dist/index.js"
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@octokit/auth-app": "^8.1.0",
|
|
91
91
|
"@octokit/core": "^7.0.3",
|
|
92
92
|
"@octokit/rest": "^22.0.0",
|
|
93
|
-
"@probelabs/probe": "^0.6.0-
|
|
93
|
+
"@probelabs/probe": "^0.6.0-rc138",
|
|
94
94
|
"@types/commander": "^2.12.0",
|
|
95
95
|
"@types/uuid": "^10.0.0",
|
|
96
96
|
"ajv": "^8.17.1",
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// src/liquid-extensions.ts
|
|
2
|
-
import { Liquid, Tag, Value } from "liquidjs";
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
import path from "path";
|
|
5
|
-
var ReadFileTag = class extends Tag {
|
|
6
|
-
filepath;
|
|
7
|
-
constructor(token, remainTokens, liquid) {
|
|
8
|
-
super(token, remainTokens, liquid);
|
|
9
|
-
this.filepath = new Value(token.args, liquid);
|
|
10
|
-
}
|
|
11
|
-
*render(ctx, emitter) {
|
|
12
|
-
const filePath = yield this.filepath.value(ctx, false);
|
|
13
|
-
if (!filePath || typeof filePath !== "string") {
|
|
14
|
-
emitter.write("[Error: Invalid file path]");
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const projectRoot = process.cwd();
|
|
18
|
-
const resolvedPath = path.resolve(projectRoot, filePath.toString());
|
|
19
|
-
if (!resolvedPath.startsWith(projectRoot)) {
|
|
20
|
-
emitter.write("[Error: File path escapes project directory]");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const content = yield fs.readFile(resolvedPath, "utf-8");
|
|
25
|
-
emitter.write(content);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
const errorMessage = error instanceof Error ? error.message : error?.code || "Unknown error";
|
|
28
|
-
emitter.write(`[Error reading file: ${errorMessage}]`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
function configureLiquidWithExtensions(liquid) {
|
|
33
|
-
liquid.registerTag("readfile", ReadFileTag);
|
|
34
|
-
liquid.registerFilter("parse_json", (value) => {
|
|
35
|
-
if (typeof value !== "string") {
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
return JSON.parse(value);
|
|
40
|
-
} catch {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
liquid.registerFilter("to_json", (value) => {
|
|
45
|
-
try {
|
|
46
|
-
return JSON.stringify(value);
|
|
47
|
-
} catch {
|
|
48
|
-
return "[Error: Unable to serialize to JSON]";
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function createExtendedLiquid(options = {}) {
|
|
53
|
-
const liquid = new Liquid({
|
|
54
|
-
cache: false,
|
|
55
|
-
strictFilters: false,
|
|
56
|
-
strictVariables: false,
|
|
57
|
-
...options
|
|
58
|
-
});
|
|
59
|
-
configureLiquidWithExtensions(liquid);
|
|
60
|
-
return liquid;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
-
ReadFileTag,
|
|
65
|
-
configureLiquidWithExtensions,
|
|
66
|
-
createExtendedLiquid
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=chunk-FIL2OGF6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/liquid-extensions.ts"],"sourcesContent":["import { Liquid, TagToken, Context, TopLevelToken, Tag, Value, Emitter } from 'liquidjs';\nimport fs from 'fs/promises';\nimport path from 'path';\n\n/**\n * Custom ReadFile tag for Liquid templates\n * Usage: {% readfile \"path/to/file.txt\" %}\n * or with variable: {% readfile filename %}\n */\nexport class ReadFileTag extends Tag {\n private filepath: Value;\n\n constructor(token: TagToken, remainTokens: TopLevelToken[], liquid: Liquid) {\n super(token, remainTokens, liquid);\n this.filepath = new Value(token.args, liquid);\n }\n\n *render(ctx: Context, emitter: Emitter): Generator<unknown, void, unknown> {\n const filePath = yield this.filepath.value(ctx, false);\n\n // Validate the path\n if (!filePath || typeof filePath !== 'string') {\n emitter.write('[Error: Invalid file path]');\n return;\n }\n\n // Security: Resolve path relative to project root to prevent directory traversal\n const projectRoot = process.cwd();\n const resolvedPath = path.resolve(projectRoot, filePath.toString());\n\n // Ensure the resolved path is within the project directory\n if (!resolvedPath.startsWith(projectRoot)) {\n emitter.write('[Error: File path escapes project directory]');\n return;\n }\n\n // Read the file content\n try {\n const content = yield fs.readFile(resolvedPath, 'utf-8');\n emitter.write(content);\n } catch (error) {\n // Handle file read errors gracefully\n const errorMessage =\n error instanceof Error\n ? error.message\n : (error as NodeJS.ErrnoException)?.code || 'Unknown error';\n emitter.write(`[Error reading file: ${errorMessage}]`);\n }\n }\n}\n\n/**\n * Configure a Liquid instance with custom extensions\n */\nexport function configureLiquidWithExtensions(liquid: Liquid): void {\n // Register the readfile tag\n liquid.registerTag('readfile', ReadFileTag);\n\n // Register parse_json filter to parse JSON strings into objects\n liquid.registerFilter('parse_json', (value: string) => {\n if (typeof value !== 'string') {\n return value;\n }\n try {\n return JSON.parse(value);\n } catch {\n // Return original value if parsing fails\n return value;\n }\n });\n\n // Register to_json filter as alias for json (for consistency)\n liquid.registerFilter('to_json', (value: unknown) => {\n try {\n return JSON.stringify(value);\n } catch {\n return '[Error: Unable to serialize to JSON]';\n }\n });\n}\n\n/**\n * Create a new Liquid instance with custom extensions\n */\nexport function createExtendedLiquid(options: Record<string, unknown> = {}): Liquid {\n const liquid = new Liquid({\n cache: false,\n strictFilters: false,\n strictVariables: false,\n ...options,\n });\n\n configureLiquidWithExtensions(liquid);\n return liquid;\n}\n"],"mappings":";AAAA,SAAS,QAA0C,KAAK,aAAsB;AAC9E,OAAO,QAAQ;AACf,OAAO,UAAU;AAOV,IAAM,cAAN,cAA0B,IAAI;AAAA,EAC3B;AAAA,EAER,YAAY,OAAiB,cAA+B,QAAgB;AAC1E,UAAM,OAAO,cAAc,MAAM;AACjC,SAAK,WAAW,IAAI,MAAM,MAAM,MAAM,MAAM;AAAA,EAC9C;AAAA,EAEA,CAAC,OAAO,KAAc,SAAqD;AACzE,UAAM,WAAW,MAAM,KAAK,SAAS,MAAM,KAAK,KAAK;AAGrD,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,cAAQ,MAAM,4BAA4B;AAC1C;AAAA,IACF;AAGA,UAAM,cAAc,QAAQ,IAAI;AAChC,UAAM,eAAe,KAAK,QAAQ,aAAa,SAAS,SAAS,CAAC;AAGlE,QAAI,CAAC,aAAa,WAAW,WAAW,GAAG;AACzC,cAAQ,MAAM,8CAA8C;AAC5D;AAAA,IACF;AAGA,QAAI;AACF,YAAM,UAAU,MAAM,GAAG,SAAS,cAAc,OAAO;AACvD,cAAQ,MAAM,OAAO;AAAA,IACvB,SAAS,OAAO;AAEd,YAAM,eACJ,iBAAiB,QACb,MAAM,UACL,OAAiC,QAAQ;AAChD,cAAQ,MAAM,wBAAwB,YAAY,GAAG;AAAA,IACvD;AAAA,EACF;AACF;AAKO,SAAS,8BAA8B,QAAsB;AAElE,SAAO,YAAY,YAAY,WAAW;AAG1C,SAAO,eAAe,cAAc,CAAC,UAAkB;AACrD,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,IACT;AACA,QAAI;AACF,aAAO,KAAK,MAAM,KAAK;AAAA,IACzB,QAAQ;AAEN,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAGD,SAAO,eAAe,WAAW,CAAC,UAAmB;AACnD,QAAI;AACF,aAAO,KAAK,UAAU,KAAK;AAAA,IAC7B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAKO,SAAS,qBAAqB,UAAmC,CAAC,GAAW;AAClF,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB,OAAO;AAAA,IACP,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,GAAG;AAAA,EACL,CAAC;AAED,gCAA8B,MAAM;AACpC,SAAO;AACT;","names":[]}
|