@commandgarden/cli 1.1.0 → 1.1.2
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/main.js +12343 -101
- package/node_modules/@commandgarden/app/dist/client/assets/index-58UrF1aG.js +197 -0
- package/node_modules/@commandgarden/app/dist/client/assets/index-DErcb2Kp.css +1 -0
- package/node_modules/@commandgarden/app/dist/client/index.html +19 -0
- package/node_modules/@commandgarden/app/dist/server/daemon-client.js +61 -0
- package/node_modules/@commandgarden/app/dist/server/main.js +63 -0
- package/node_modules/@commandgarden/app/dist/server/routes/audit.js +20 -0
- package/node_modules/@commandgarden/app/dist/server/routes/config.js +13 -0
- package/node_modules/@commandgarden/app/dist/server/routes/connectors.js +35 -0
- package/node_modules/@commandgarden/app/dist/server/routes/index.js +14 -0
- package/node_modules/@commandgarden/app/dist/server/routes/preferences.js +32 -0
- package/node_modules/@commandgarden/app/dist/server/routes/run.js +46 -0
- package/node_modules/@commandgarden/app/dist/server/routes/status.js +11 -0
- package/node_modules/@commandgarden/app/dist/server/store.js +55 -0
- package/node_modules/@commandgarden/app/package.json +42 -0
- package/node_modules/@commandgarden/daemon/dist/audit-store.d.ts +18 -0
- package/node_modules/@commandgarden/daemon/dist/audit-store.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/audit-store.js +97 -0
- package/node_modules/@commandgarden/daemon/dist/audit-store.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/auth.d.ts +5 -0
- package/node_modules/@commandgarden/daemon/dist/auth.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/auth.js +27 -0
- package/node_modules/@commandgarden/daemon/dist/auth.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/config.d.ts +109 -0
- package/node_modules/@commandgarden/daemon/dist/config.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/config.js +45 -0
- package/node_modules/@commandgarden/daemon/dist/config.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/main.d.ts +2 -0
- package/node_modules/@commandgarden/daemon/dist/main.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/main.js +58 -0
- package/node_modules/@commandgarden/daemon/dist/main.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/registry.d.ts +21 -0
- package/node_modules/@commandgarden/daemon/dist/registry.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/registry.js +70 -0
- package/node_modules/@commandgarden/daemon/dist/registry.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/server.d.ts +15 -0
- package/node_modules/@commandgarden/daemon/dist/server.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/server.js +336 -0
- package/node_modules/@commandgarden/daemon/dist/server.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/sse-manager.d.ts +10 -0
- package/node_modules/@commandgarden/daemon/dist/sse-manager.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/sse-manager.js +37 -0
- package/node_modules/@commandgarden/daemon/dist/sse-manager.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/validator.d.ts +10 -0
- package/node_modules/@commandgarden/daemon/dist/validator.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/validator.js +19 -0
- package/node_modules/@commandgarden/daemon/dist/validator.js.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/ws-relay.d.ts +30 -0
- package/node_modules/@commandgarden/daemon/dist/ws-relay.d.ts.map +1 -0
- package/node_modules/@commandgarden/daemon/dist/ws-relay.js +111 -0
- package/node_modules/@commandgarden/daemon/dist/ws-relay.js.map +1 -0
- package/node_modules/@commandgarden/daemon/package.json +30 -0
- package/node_modules/@commandgarden/shared/dist/capabilities.d.ts +7 -0
- package/node_modules/@commandgarden/shared/dist/capabilities.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/capabilities.js +23 -0
- package/node_modules/@commandgarden/shared/dist/capabilities.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/connector.d.ts +377 -0
- package/node_modules/@commandgarden/shared/dist/connector.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/connector.js +29 -0
- package/node_modules/@commandgarden/shared/dist/connector.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/events.d.ts +33 -0
- package/node_modules/@commandgarden/shared/dist/events.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/events.js +34 -0
- package/node_modules/@commandgarden/shared/dist/events.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/evaluator.d.ts +8 -0
- package/node_modules/@commandgarden/shared/dist/expression/evaluator.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/evaluator.js +49 -0
- package/node_modules/@commandgarden/shared/dist/expression/evaluator.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/filters.d.ts +3 -0
- package/node_modules/@commandgarden/shared/dist/expression/filters.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/filters.js +8 -0
- package/node_modules/@commandgarden/shared/dist/expression/filters.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/index.d.ts +5 -0
- package/node_modules/@commandgarden/shared/dist/expression/index.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/index.js +5 -0
- package/node_modules/@commandgarden/shared/dist/expression/index.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/parser.d.ts +22 -0
- package/node_modules/@commandgarden/shared/dist/expression/parser.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/parser.js +85 -0
- package/node_modules/@commandgarden/shared/dist/expression/parser.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/tokenizer.d.ts +7 -0
- package/node_modules/@commandgarden/shared/dist/expression/tokenizer.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/expression/tokenizer.js +76 -0
- package/node_modules/@commandgarden/shared/dist/expression/tokenizer.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/index.d.ts +8 -0
- package/node_modules/@commandgarden/shared/dist/index.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/index.js +15 -0
- package/node_modules/@commandgarden/shared/dist/index.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/loader.d.ts +17 -0
- package/node_modules/@commandgarden/shared/dist/loader.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/loader.js +76 -0
- package/node_modules/@commandgarden/shared/dist/loader.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/pipeline.d.ts +339 -0
- package/node_modules/@commandgarden/shared/dist/pipeline.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/pipeline.js +97 -0
- package/node_modules/@commandgarden/shared/dist/pipeline.js.map +1 -0
- package/node_modules/@commandgarden/shared/dist/protocol.d.ts +58 -0
- package/node_modules/@commandgarden/shared/dist/protocol.d.ts.map +1 -0
- package/node_modules/@commandgarden/shared/dist/protocol.js +26 -0
- package/node_modules/@commandgarden/shared/dist/protocol.js.map +1 -0
- package/node_modules/@commandgarden/shared/package.json +32 -0
- package/package.json +55 -42
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CAPABILITIES: readonly ["navigate", "cookie_read", "cookie_write", "dom_read", "dom_write", "intercept_response", "js_evaluate"];
|
|
2
|
+
export type Capability = (typeof CAPABILITIES)[number];
|
|
3
|
+
export type RiskLevel = 'low' | 'medium' | 'high';
|
|
4
|
+
export declare const CAPABILITY_RISK: Record<Capability, RiskLevel>;
|
|
5
|
+
export declare const HIGH_RISK_CAPABILITIES: readonly Capability[];
|
|
6
|
+
export declare function isCapability(value: string): value is Capability;
|
|
7
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,oHAQf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAQzD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,SAAS,UAAU,EAEvD,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAE/D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const CAPABILITIES = [
|
|
2
|
+
'navigate',
|
|
3
|
+
'cookie_read',
|
|
4
|
+
'cookie_write',
|
|
5
|
+
'dom_read',
|
|
6
|
+
'dom_write',
|
|
7
|
+
'intercept_response',
|
|
8
|
+
'js_evaluate',
|
|
9
|
+
];
|
|
10
|
+
export const CAPABILITY_RISK = {
|
|
11
|
+
navigate: 'low',
|
|
12
|
+
cookie_read: 'medium',
|
|
13
|
+
cookie_write: 'high',
|
|
14
|
+
dom_read: 'low',
|
|
15
|
+
dom_write: 'medium',
|
|
16
|
+
intercept_response: 'medium',
|
|
17
|
+
js_evaluate: 'high',
|
|
18
|
+
};
|
|
19
|
+
export const HIGH_RISK_CAPABILITIES = CAPABILITIES.filter((c) => CAPABILITY_RISK[c] === 'high');
|
|
20
|
+
export function isCapability(value) {
|
|
21
|
+
return CAPABILITIES.includes(value);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU;IACV,aAAa;IACb,cAAc;IACd,UAAU;IACV,WAAW;IACX,oBAAoB;IACpB,aAAa;CACL,CAAC;AAMX,MAAM,CAAC,MAAM,eAAe,GAAkC;IAC5D,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,MAAM;IACpB,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,QAAQ;IACnB,kBAAkB,EAAE,QAAQ;IAC5B,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAA0B,YAAY,CAAC,MAAM,CAC9E,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,MAAM,CACrC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,YAAkC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const connectorArgSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
type: z.ZodEnum<["string", "number", "boolean"]>;
|
|
5
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
7
|
+
help: z.ZodOptional<z.ZodString>;
|
|
8
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
type: "string" | "number" | "boolean";
|
|
11
|
+
name: string;
|
|
12
|
+
required: boolean;
|
|
13
|
+
default?: string | number | boolean | undefined;
|
|
14
|
+
help?: string | undefined;
|
|
15
|
+
pattern?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
type: "string" | "number" | "boolean";
|
|
18
|
+
name: string;
|
|
19
|
+
required?: boolean | undefined;
|
|
20
|
+
default?: string | number | boolean | undefined;
|
|
21
|
+
help?: string | undefined;
|
|
22
|
+
pattern?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
declare const connectorColumnSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
type: z.ZodEnum<["string", "number", "boolean"]>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
type: "string" | "number" | "boolean";
|
|
29
|
+
name: string;
|
|
30
|
+
}, {
|
|
31
|
+
type: "string" | "number" | "boolean";
|
|
32
|
+
name: string;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const connectorSchema: z.ZodObject<{
|
|
35
|
+
site: z.ZodString;
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
version: z.ZodString;
|
|
38
|
+
description: z.ZodOptional<z.ZodString>;
|
|
39
|
+
access: z.ZodDefault<z.ZodEnum<["read", "write"]>>;
|
|
40
|
+
domains: z.ZodArray<z.ZodString, "many">;
|
|
41
|
+
capabilities: z.ZodArray<z.ZodEnum<["navigate", "cookie_read", "cookie_write", "dom_read", "dom_write", "intercept_response", "js_evaluate"]>, "many">;
|
|
42
|
+
args: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
type: z.ZodEnum<["string", "number", "boolean"]>;
|
|
45
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
47
|
+
help: z.ZodOptional<z.ZodString>;
|
|
48
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
type: "string" | "number" | "boolean";
|
|
51
|
+
name: string;
|
|
52
|
+
required: boolean;
|
|
53
|
+
default?: string | number | boolean | undefined;
|
|
54
|
+
help?: string | undefined;
|
|
55
|
+
pattern?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
type: "string" | "number" | "boolean";
|
|
58
|
+
name: string;
|
|
59
|
+
required?: boolean | undefined;
|
|
60
|
+
default?: string | number | boolean | undefined;
|
|
61
|
+
help?: string | undefined;
|
|
62
|
+
pattern?: string | undefined;
|
|
63
|
+
}>, "many">>>;
|
|
64
|
+
columns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
type: z.ZodEnum<["string", "number", "boolean"]>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
type: "string" | "number" | "boolean";
|
|
69
|
+
name: string;
|
|
70
|
+
}, {
|
|
71
|
+
type: "string" | "number" | "boolean";
|
|
72
|
+
name: string;
|
|
73
|
+
}>, "many">>>;
|
|
74
|
+
pipeline: z.ZodArray<z.ZodDiscriminatedUnion<"step", [z.ZodObject<{
|
|
75
|
+
step: z.ZodLiteral<"navigate">;
|
|
76
|
+
url: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
step: "navigate";
|
|
79
|
+
url: string;
|
|
80
|
+
}, {
|
|
81
|
+
step: "navigate";
|
|
82
|
+
url: string;
|
|
83
|
+
}>, z.ZodObject<{
|
|
84
|
+
step: z.ZodLiteral<"wait">;
|
|
85
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
86
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
step: "wait";
|
|
89
|
+
selector?: string | undefined;
|
|
90
|
+
timeout?: number | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
step: "wait";
|
|
93
|
+
selector?: string | undefined;
|
|
94
|
+
timeout?: number | undefined;
|
|
95
|
+
}>, z.ZodObject<{
|
|
96
|
+
step: z.ZodLiteral<"extract">;
|
|
97
|
+
selector: z.ZodString;
|
|
98
|
+
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
step: "extract";
|
|
101
|
+
selector: string;
|
|
102
|
+
fields: Record<string, string>;
|
|
103
|
+
}, {
|
|
104
|
+
step: "extract";
|
|
105
|
+
selector: string;
|
|
106
|
+
fields: Record<string, string>;
|
|
107
|
+
}>, z.ZodObject<{
|
|
108
|
+
step: z.ZodLiteral<"click">;
|
|
109
|
+
selector: z.ZodString;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
step: "click";
|
|
112
|
+
selector: string;
|
|
113
|
+
}, {
|
|
114
|
+
step: "click";
|
|
115
|
+
selector: string;
|
|
116
|
+
}>, z.ZodObject<{
|
|
117
|
+
step: z.ZodLiteral<"type">;
|
|
118
|
+
selector: z.ZodString;
|
|
119
|
+
value: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
step: "type";
|
|
122
|
+
value: string;
|
|
123
|
+
selector: string;
|
|
124
|
+
}, {
|
|
125
|
+
step: "type";
|
|
126
|
+
value: string;
|
|
127
|
+
selector: string;
|
|
128
|
+
}>, z.ZodObject<{
|
|
129
|
+
step: z.ZodLiteral<"intercept">;
|
|
130
|
+
urlPattern: z.ZodString;
|
|
131
|
+
as: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
step: "intercept";
|
|
134
|
+
urlPattern: string;
|
|
135
|
+
as?: string | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
step: "intercept";
|
|
138
|
+
urlPattern: string;
|
|
139
|
+
as?: string | undefined;
|
|
140
|
+
}>, z.ZodObject<{
|
|
141
|
+
step: z.ZodLiteral<"cookie">;
|
|
142
|
+
domain: z.ZodString;
|
|
143
|
+
name: z.ZodOptional<z.ZodString>;
|
|
144
|
+
as: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
step: "cookie";
|
|
147
|
+
domain: string;
|
|
148
|
+
as?: string | undefined;
|
|
149
|
+
name?: string | undefined;
|
|
150
|
+
}, {
|
|
151
|
+
step: "cookie";
|
|
152
|
+
domain: string;
|
|
153
|
+
as?: string | undefined;
|
|
154
|
+
name?: string | undefined;
|
|
155
|
+
}>, z.ZodObject<{
|
|
156
|
+
step: z.ZodLiteral<"fetch">;
|
|
157
|
+
url: z.ZodString;
|
|
158
|
+
method: z.ZodOptional<z.ZodString>;
|
|
159
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
160
|
+
body: z.ZodOptional<z.ZodString>;
|
|
161
|
+
as: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
step: "fetch";
|
|
164
|
+
url: string;
|
|
165
|
+
as?: string | undefined;
|
|
166
|
+
method?: string | undefined;
|
|
167
|
+
headers?: Record<string, string> | undefined;
|
|
168
|
+
body?: string | undefined;
|
|
169
|
+
}, {
|
|
170
|
+
step: "fetch";
|
|
171
|
+
url: string;
|
|
172
|
+
as?: string | undefined;
|
|
173
|
+
method?: string | undefined;
|
|
174
|
+
headers?: Record<string, string> | undefined;
|
|
175
|
+
body?: string | undefined;
|
|
176
|
+
}>, z.ZodObject<{
|
|
177
|
+
step: z.ZodLiteral<"map">;
|
|
178
|
+
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
179
|
+
}, "strip", z.ZodTypeAny, {
|
|
180
|
+
step: "map";
|
|
181
|
+
fields: Record<string, string>;
|
|
182
|
+
}, {
|
|
183
|
+
step: "map";
|
|
184
|
+
fields: Record<string, string>;
|
|
185
|
+
}>, z.ZodObject<{
|
|
186
|
+
step: z.ZodLiteral<"filter">;
|
|
187
|
+
field: z.ZodString;
|
|
188
|
+
operator: z.ZodEnum<["eq", "ne", "gt", "lt", "gte", "lte", "contains", "matches"]>;
|
|
189
|
+
value: z.ZodString;
|
|
190
|
+
}, "strip", z.ZodTypeAny, {
|
|
191
|
+
step: "filter";
|
|
192
|
+
value: string;
|
|
193
|
+
field: string;
|
|
194
|
+
operator: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "contains" | "matches";
|
|
195
|
+
}, {
|
|
196
|
+
step: "filter";
|
|
197
|
+
value: string;
|
|
198
|
+
field: string;
|
|
199
|
+
operator: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "contains" | "matches";
|
|
200
|
+
}>, z.ZodObject<{
|
|
201
|
+
step: z.ZodLiteral<"set">;
|
|
202
|
+
name: z.ZodString;
|
|
203
|
+
value: z.ZodString;
|
|
204
|
+
}, "strip", z.ZodTypeAny, {
|
|
205
|
+
step: "set";
|
|
206
|
+
value: string;
|
|
207
|
+
name: string;
|
|
208
|
+
}, {
|
|
209
|
+
step: "set";
|
|
210
|
+
value: string;
|
|
211
|
+
name: string;
|
|
212
|
+
}>, z.ZodObject<{
|
|
213
|
+
step: z.ZodLiteral<"js_evaluate">;
|
|
214
|
+
code: z.ZodOptional<z.ZodString>;
|
|
215
|
+
file: z.ZodOptional<z.ZodString>;
|
|
216
|
+
as: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
step: "js_evaluate";
|
|
219
|
+
code?: string | undefined;
|
|
220
|
+
as?: string | undefined;
|
|
221
|
+
file?: string | undefined;
|
|
222
|
+
}, {
|
|
223
|
+
step: "js_evaluate";
|
|
224
|
+
code?: string | undefined;
|
|
225
|
+
as?: string | undefined;
|
|
226
|
+
file?: string | undefined;
|
|
227
|
+
}>]>, "many">;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
name: string;
|
|
230
|
+
site: string;
|
|
231
|
+
version: string;
|
|
232
|
+
access: "read" | "write";
|
|
233
|
+
domains: string[];
|
|
234
|
+
capabilities: ("navigate" | "cookie_read" | "cookie_write" | "dom_read" | "dom_write" | "intercept_response" | "js_evaluate")[];
|
|
235
|
+
args: {
|
|
236
|
+
type: "string" | "number" | "boolean";
|
|
237
|
+
name: string;
|
|
238
|
+
required: boolean;
|
|
239
|
+
default?: string | number | boolean | undefined;
|
|
240
|
+
help?: string | undefined;
|
|
241
|
+
pattern?: string | undefined;
|
|
242
|
+
}[];
|
|
243
|
+
columns: {
|
|
244
|
+
type: "string" | "number" | "boolean";
|
|
245
|
+
name: string;
|
|
246
|
+
}[];
|
|
247
|
+
pipeline: ({
|
|
248
|
+
step: "navigate";
|
|
249
|
+
url: string;
|
|
250
|
+
} | {
|
|
251
|
+
step: "wait";
|
|
252
|
+
selector?: string | undefined;
|
|
253
|
+
timeout?: number | undefined;
|
|
254
|
+
} | {
|
|
255
|
+
step: "extract";
|
|
256
|
+
selector: string;
|
|
257
|
+
fields: Record<string, string>;
|
|
258
|
+
} | {
|
|
259
|
+
step: "click";
|
|
260
|
+
selector: string;
|
|
261
|
+
} | {
|
|
262
|
+
step: "type";
|
|
263
|
+
value: string;
|
|
264
|
+
selector: string;
|
|
265
|
+
} | {
|
|
266
|
+
step: "intercept";
|
|
267
|
+
urlPattern: string;
|
|
268
|
+
as?: string | undefined;
|
|
269
|
+
} | {
|
|
270
|
+
step: "cookie";
|
|
271
|
+
domain: string;
|
|
272
|
+
as?: string | undefined;
|
|
273
|
+
name?: string | undefined;
|
|
274
|
+
} | {
|
|
275
|
+
step: "fetch";
|
|
276
|
+
url: string;
|
|
277
|
+
as?: string | undefined;
|
|
278
|
+
method?: string | undefined;
|
|
279
|
+
headers?: Record<string, string> | undefined;
|
|
280
|
+
body?: string | undefined;
|
|
281
|
+
} | {
|
|
282
|
+
step: "map";
|
|
283
|
+
fields: Record<string, string>;
|
|
284
|
+
} | {
|
|
285
|
+
step: "filter";
|
|
286
|
+
value: string;
|
|
287
|
+
field: string;
|
|
288
|
+
operator: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "contains" | "matches";
|
|
289
|
+
} | {
|
|
290
|
+
step: "set";
|
|
291
|
+
value: string;
|
|
292
|
+
name: string;
|
|
293
|
+
} | {
|
|
294
|
+
step: "js_evaluate";
|
|
295
|
+
code?: string | undefined;
|
|
296
|
+
as?: string | undefined;
|
|
297
|
+
file?: string | undefined;
|
|
298
|
+
})[];
|
|
299
|
+
description?: string | undefined;
|
|
300
|
+
}, {
|
|
301
|
+
name: string;
|
|
302
|
+
site: string;
|
|
303
|
+
version: string;
|
|
304
|
+
domains: string[];
|
|
305
|
+
capabilities: ("navigate" | "cookie_read" | "cookie_write" | "dom_read" | "dom_write" | "intercept_response" | "js_evaluate")[];
|
|
306
|
+
pipeline: ({
|
|
307
|
+
step: "navigate";
|
|
308
|
+
url: string;
|
|
309
|
+
} | {
|
|
310
|
+
step: "wait";
|
|
311
|
+
selector?: string | undefined;
|
|
312
|
+
timeout?: number | undefined;
|
|
313
|
+
} | {
|
|
314
|
+
step: "extract";
|
|
315
|
+
selector: string;
|
|
316
|
+
fields: Record<string, string>;
|
|
317
|
+
} | {
|
|
318
|
+
step: "click";
|
|
319
|
+
selector: string;
|
|
320
|
+
} | {
|
|
321
|
+
step: "type";
|
|
322
|
+
value: string;
|
|
323
|
+
selector: string;
|
|
324
|
+
} | {
|
|
325
|
+
step: "intercept";
|
|
326
|
+
urlPattern: string;
|
|
327
|
+
as?: string | undefined;
|
|
328
|
+
} | {
|
|
329
|
+
step: "cookie";
|
|
330
|
+
domain: string;
|
|
331
|
+
as?: string | undefined;
|
|
332
|
+
name?: string | undefined;
|
|
333
|
+
} | {
|
|
334
|
+
step: "fetch";
|
|
335
|
+
url: string;
|
|
336
|
+
as?: string | undefined;
|
|
337
|
+
method?: string | undefined;
|
|
338
|
+
headers?: Record<string, string> | undefined;
|
|
339
|
+
body?: string | undefined;
|
|
340
|
+
} | {
|
|
341
|
+
step: "map";
|
|
342
|
+
fields: Record<string, string>;
|
|
343
|
+
} | {
|
|
344
|
+
step: "filter";
|
|
345
|
+
value: string;
|
|
346
|
+
field: string;
|
|
347
|
+
operator: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "contains" | "matches";
|
|
348
|
+
} | {
|
|
349
|
+
step: "set";
|
|
350
|
+
value: string;
|
|
351
|
+
name: string;
|
|
352
|
+
} | {
|
|
353
|
+
step: "js_evaluate";
|
|
354
|
+
code?: string | undefined;
|
|
355
|
+
as?: string | undefined;
|
|
356
|
+
file?: string | undefined;
|
|
357
|
+
})[];
|
|
358
|
+
description?: string | undefined;
|
|
359
|
+
access?: "read" | "write" | undefined;
|
|
360
|
+
args?: {
|
|
361
|
+
type: "string" | "number" | "boolean";
|
|
362
|
+
name: string;
|
|
363
|
+
required?: boolean | undefined;
|
|
364
|
+
default?: string | number | boolean | undefined;
|
|
365
|
+
help?: string | undefined;
|
|
366
|
+
pattern?: string | undefined;
|
|
367
|
+
}[] | undefined;
|
|
368
|
+
columns?: {
|
|
369
|
+
type: "string" | "number" | "boolean";
|
|
370
|
+
name: string;
|
|
371
|
+
}[] | undefined;
|
|
372
|
+
}>;
|
|
373
|
+
export type ConnectorDef = z.infer<typeof connectorSchema>;
|
|
374
|
+
export type ConnectorArg = z.infer<typeof connectorArgSchema>;
|
|
375
|
+
export type ConnectorColumn = z.infer<typeof connectorColumnSchema>;
|
|
376
|
+
export {};
|
|
377
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAOtB,CAAC;AAEH,QAAA,MAAM,qBAAqB;;;;;;;;;EAGzB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW1B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC3D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CAPABILITIES } from './capabilities.js';
|
|
3
|
+
import { pipelineStepSchema } from './pipeline.js';
|
|
4
|
+
const capabilityEnum = z.enum(CAPABILITIES);
|
|
5
|
+
const connectorArgSchema = z.object({
|
|
6
|
+
name: z.string(),
|
|
7
|
+
type: z.enum(['string', 'number', 'boolean']),
|
|
8
|
+
required: z.boolean().default(false),
|
|
9
|
+
default: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
10
|
+
help: z.string().optional(),
|
|
11
|
+
pattern: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const connectorColumnSchema = z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
type: z.enum(['string', 'number', 'boolean']),
|
|
16
|
+
});
|
|
17
|
+
export const connectorSchema = z.object({
|
|
18
|
+
site: z.string().min(1),
|
|
19
|
+
name: z.string().min(1),
|
|
20
|
+
version: z.string(),
|
|
21
|
+
description: z.string().optional(),
|
|
22
|
+
access: z.enum(['read', 'write']).default('read'),
|
|
23
|
+
domains: z.array(z.string()).min(1),
|
|
24
|
+
capabilities: z.array(capabilityEnum).min(1),
|
|
25
|
+
args: z.array(connectorArgSchema).optional().default([]),
|
|
26
|
+
columns: z.array(connectorColumnSchema).optional().default([]),
|
|
27
|
+
pipeline: z.array(pipelineStepSchema).min(1),
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAE5C,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;IAClE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7C,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const AUDIT_EVENT_TYPES: readonly ["command.start", "command.success", "command.error", "command.denied", "auth.failed", "approval.granted", "approval.rejected", "config.changed"];
|
|
2
|
+
export type AuditEventType = (typeof AUDIT_EVENT_TYPES)[number];
|
|
3
|
+
export interface StepSummary {
|
|
4
|
+
step: string;
|
|
5
|
+
index: number;
|
|
6
|
+
capability?: string;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AuditEvent {
|
|
11
|
+
id: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
type: AuditEventType;
|
|
14
|
+
user: string;
|
|
15
|
+
connector: string;
|
|
16
|
+
args: Record<string, string>;
|
|
17
|
+
domains: string[];
|
|
18
|
+
capabilities: string[];
|
|
19
|
+
rowCount?: number;
|
|
20
|
+
columns?: string[];
|
|
21
|
+
durationMs: number;
|
|
22
|
+
error?: string;
|
|
23
|
+
denialReason?: string;
|
|
24
|
+
correlationId?: string;
|
|
25
|
+
connectorHash?: string;
|
|
26
|
+
steps?: StepSummary[];
|
|
27
|
+
source?: string;
|
|
28
|
+
previousValue?: string;
|
|
29
|
+
newValue?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function redactArgs(args: Record<string, string>): Record<string, string>;
|
|
32
|
+
export declare function createAuditEvent(overrides: Partial<AuditEvent> & Pick<AuditEvent, 'type' | 'connector'>): AuditEvent;
|
|
33
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,4JASpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM/E;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAAC,GACtE,UAAU,CAaZ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export const AUDIT_EVENT_TYPES = [
|
|
3
|
+
'command.start',
|
|
4
|
+
'command.success',
|
|
5
|
+
'command.error',
|
|
6
|
+
'command.denied',
|
|
7
|
+
'auth.failed',
|
|
8
|
+
'approval.granted',
|
|
9
|
+
'approval.rejected',
|
|
10
|
+
'config.changed',
|
|
11
|
+
];
|
|
12
|
+
const SENSITIVE_PATTERN = /token|password|secret|api_key|credential|auth/i;
|
|
13
|
+
export function redactArgs(args) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const [k, v] of Object.entries(args)) {
|
|
16
|
+
result[k] = SENSITIVE_PATTERN.test(k) ? '[REDACTED]' : v;
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
export function createAuditEvent(overrides) {
|
|
21
|
+
const base = {
|
|
22
|
+
id: randomUUID(),
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
user: '',
|
|
25
|
+
args: {},
|
|
26
|
+
domains: [],
|
|
27
|
+
capabilities: [],
|
|
28
|
+
durationMs: 0,
|
|
29
|
+
...overrides,
|
|
30
|
+
};
|
|
31
|
+
base.args = redactArgs(base.args);
|
|
32
|
+
return base;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;CACR,CAAC;AAkCX,MAAM,iBAAiB,GAAG,gDAAgD,CAAC;AAE3E,MAAM,UAAU,UAAU,CAAC,IAA4B;IACrD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,SAAuE;IAEvE,MAAM,IAAI,GAAe;QACvB,EAAE,EAAE,UAAU,EAAE;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,CAAC;QACb,GAAG,SAAS;KACb,CAAC;IACF,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ExprContext {
|
|
2
|
+
args: Record<string, string | number | boolean>;
|
|
3
|
+
vars: Record<string, unknown>;
|
|
4
|
+
cookies: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function evaluate(expression: string, context: ExprContext): unknown;
|
|
7
|
+
export declare function interpolate(template: string, context: ExprContext): string;
|
|
8
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/expression/evaluator.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAqCD,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAI1E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAI1E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { tokenize } from './tokenizer.js';
|
|
2
|
+
import { parse } from './parser.js';
|
|
3
|
+
import { BUILT_IN_FILTERS } from './filters.js';
|
|
4
|
+
function resolvePath(obj, path) {
|
|
5
|
+
let current = obj;
|
|
6
|
+
for (const key of path) {
|
|
7
|
+
if (current == null || typeof current !== 'object')
|
|
8
|
+
return undefined;
|
|
9
|
+
current = current[key];
|
|
10
|
+
}
|
|
11
|
+
return current;
|
|
12
|
+
}
|
|
13
|
+
function exec(expr, context) {
|
|
14
|
+
switch (expr.type) {
|
|
15
|
+
case 'string':
|
|
16
|
+
return expr.value;
|
|
17
|
+
case 'number':
|
|
18
|
+
return expr.value;
|
|
19
|
+
case 'variable': {
|
|
20
|
+
const [root, ...rest] = expr.path;
|
|
21
|
+
const scope = context[root];
|
|
22
|
+
return rest.length === 0 ? scope : resolvePath(scope, rest);
|
|
23
|
+
}
|
|
24
|
+
case 'concat': {
|
|
25
|
+
const left = exec(expr.left, context);
|
|
26
|
+
const right = exec(expr.right, context);
|
|
27
|
+
return String(left) + String(right);
|
|
28
|
+
}
|
|
29
|
+
case 'pipe': {
|
|
30
|
+
const value = exec(expr.expr, context);
|
|
31
|
+
const filter = BUILT_IN_FILTERS[expr.filter];
|
|
32
|
+
if (!filter)
|
|
33
|
+
throw new Error(`Unknown filter: ${expr.filter}`);
|
|
34
|
+
const args = expr.args.map((a) => exec(a, context));
|
|
35
|
+
return filter(value, ...args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function evaluate(expression, context) {
|
|
40
|
+
const tokens = tokenize(expression);
|
|
41
|
+
const ast = parse(tokens);
|
|
42
|
+
return exec(ast, context);
|
|
43
|
+
}
|
|
44
|
+
export function interpolate(template, context) {
|
|
45
|
+
return template.replace(/\$\{\{\s*(.+?)\s*\}\}/g, (_, exprStr) => {
|
|
46
|
+
return String(evaluate(exprStr, context));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/expression/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,SAAS,WAAW,CAAC,GAAY,EAAE,IAAc;IAC/C,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACrE,OAAO,GAAI,OAAmC,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,IAAI,CAAC,IAAU,EAAE,OAAoB;IAC5C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;YAClC,MAAM,KAAK,GAAI,OAA8C,CAAC,IAAI,CAAC,CAAC;YACpE,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACxC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,UAAkB,EAAE,OAAoB;IAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,OAAoB;IAChE,OAAO,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC,EAAE,OAAe,EAAE,EAAE;QACvE,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/expression/filters.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAEvE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAMrD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const BUILT_IN_FILTERS = {
|
|
2
|
+
default: (value, fallback) => value ?? fallback,
|
|
3
|
+
number: (value) => Number(value),
|
|
4
|
+
trim: (value) => String(value).trim(),
|
|
5
|
+
upper: (value) => String(value).toUpperCase(),
|
|
6
|
+
lower: (value) => String(value).toLowerCase(),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/expression/filters.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACxD,OAAO,EAAE,CAAC,KAAc,EAAE,QAAiB,EAAE,EAAE,CAAC,KAAK,IAAI,QAAQ;IACjE,MAAM,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IACzC,IAAI,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;IAC9C,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE;IACtD,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE;CACvD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { tokenize, type Token, type TokenType } from './tokenizer.js';
|
|
2
|
+
export { parse, type Expr } from './parser.js';
|
|
3
|
+
export { evaluate, interpolate, type ExprContext } from './evaluator.js';
|
|
4
|
+
export { BUILT_IN_FILTERS, type FilterFn } from './filters.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expression/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expression/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA8B,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC"}
|