patchwork-os 0.2.0-beta.6.canary.21 → 0.2.0-beta.6.canary.23
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/connectorRoutes.js +384 -0
- package/dist/connectorRoutes.js.map +1 -1
- package/dist/connectors/airtable.d.ts +108 -0
- package/dist/connectors/airtable.js +396 -0
- package/dist/connectors/airtable.js.map +1 -0
- package/dist/connectors/connectorRegistry.js +63 -0
- package/dist/connectors/connectorRegistry.js.map +1 -1
- package/dist/connectors/elasticsearch.d.ts +141 -0
- package/dist/connectors/elasticsearch.js +601 -0
- package/dist/connectors/elasticsearch.js.map +1 -0
- package/dist/connectors/figma.d.ts +130 -0
- package/dist/connectors/figma.js +387 -0
- package/dist/connectors/figma.js.map +1 -0
- package/dist/connectors/gmail.js +9 -0
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleDrive.d.ts +12 -0
- package/dist/connectors/googleDrive.js +27 -0
- package/dist/connectors/googleDrive.js.map +1 -1
- package/dist/connectors/mongodb.d.ts +139 -0
- package/dist/connectors/mongodb.js +455 -0
- package/dist/connectors/mongodb.js.map +1 -0
- package/dist/connectors/postgres.d.ts +127 -0
- package/dist/connectors/postgres.js +512 -0
- package/dist/connectors/postgres.js.map +1 -0
- package/dist/connectors/redis.d.ts +140 -0
- package/dist/connectors/redis.js +571 -0
- package/dist/connectors/redis.js.map +1 -0
- package/dist/connectors/sendgrid.d.ts +102 -0
- package/dist/connectors/sendgrid.js +423 -0
- package/dist/connectors/sendgrid.js.map +1 -0
- package/dist/connectors/twilio.d.ts +118 -0
- package/dist/connectors/twilio.js +475 -0
- package/dist/connectors/twilio.js.map +1 -0
- package/dist/connectors/webflow.d.ts +118 -0
- package/dist/connectors/webflow.js +393 -0
- package/dist/connectors/webflow.js.map +1 -0
- package/dist/recipes/tools/gmail.js +27 -5
- package/dist/recipes/tools/gmail.js.map +1 -1
- package/dist/recipes/tools/googleDrive.js +64 -0
- package/dist/recipes/tools/googleDrive.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elasticsearch connector — read-only access to ES clusters via @elastic/elasticsearch.
|
|
3
|
+
*
|
|
4
|
+
* Auth precedence:
|
|
5
|
+
* 1. cloudId + apiKey (Elastic Cloud)
|
|
6
|
+
* 2. node + apiKey (self-hosted with API key)
|
|
7
|
+
* 3. node + username + password (basic auth)
|
|
8
|
+
*
|
|
9
|
+
* Tools (READ-ONLY): listIndices, describeIndex, search, count, aggregate, clusterHealth.
|
|
10
|
+
*
|
|
11
|
+
* Query guard: every search/aggregate body is walked and rejected if it contains
|
|
12
|
+
* `script`, `script_fields`, or `script_score` keys at any depth, or top-level
|
|
13
|
+
* keys outside a strict allowlist. Defense against arbitrary code execution
|
|
14
|
+
* via Painless scripting.
|
|
15
|
+
*
|
|
16
|
+
* Driver is loaded lazily so the bridge boots even when `@elastic/elasticsearch`
|
|
17
|
+
* is not installed. Use `__setEsModuleForTest` in tests to inject a stub.
|
|
18
|
+
*/
|
|
19
|
+
import { type AuthContext, BaseConnector, type ConnectorError, type ConnectorStatus } from "./baseConnector.js";
|
|
20
|
+
export interface ElasticsearchTokens {
|
|
21
|
+
node?: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
password?: string;
|
|
25
|
+
cloudId?: string;
|
|
26
|
+
connected_at: string;
|
|
27
|
+
}
|
|
28
|
+
export interface EsClientLike {
|
|
29
|
+
ping(): Promise<unknown>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
cat: {
|
|
32
|
+
indices(params: {
|
|
33
|
+
format: string;
|
|
34
|
+
h?: string;
|
|
35
|
+
}): Promise<unknown>;
|
|
36
|
+
};
|
|
37
|
+
indices: {
|
|
38
|
+
getMapping(params: {
|
|
39
|
+
index: string;
|
|
40
|
+
}): Promise<unknown>;
|
|
41
|
+
getSettings(params: {
|
|
42
|
+
index: string;
|
|
43
|
+
}): Promise<unknown>;
|
|
44
|
+
};
|
|
45
|
+
search(params: Record<string, unknown>): Promise<unknown>;
|
|
46
|
+
count(params: Record<string, unknown>): Promise<unknown>;
|
|
47
|
+
cluster: {
|
|
48
|
+
health(): Promise<unknown>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface EsModuleLike {
|
|
52
|
+
Client: new (opts: Record<string, unknown>) => EsClientLike;
|
|
53
|
+
errors?: {
|
|
54
|
+
ResponseError?: new (...args: unknown[]) => Error;
|
|
55
|
+
ConnectionError?: new (...args: unknown[]) => Error;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Test hook — inject a stub `@elastic/elasticsearch` module so tests don't
|
|
60
|
+
* need the real driver installed. Pass `null` to reset.
|
|
61
|
+
*/
|
|
62
|
+
export declare function __setEsModuleForTest(mod: EsModuleLike | null): void;
|
|
63
|
+
export declare function loadTokens(): ElasticsearchTokens | null;
|
|
64
|
+
export declare function saveTokens(tokens: ElasticsearchTokens): void;
|
|
65
|
+
export declare function clearTokens(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Recursive walker — returns null when safe, error string when rejected.
|
|
68
|
+
* Rejects any object containing keys matching `script`, `script_fields`, or
|
|
69
|
+
* `script_score` (case-insensitive) at any depth, including inside arrays.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isReadOnlyEsQuery(obj: unknown): {
|
|
72
|
+
ok: true;
|
|
73
|
+
} | {
|
|
74
|
+
ok: false;
|
|
75
|
+
reason: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Validate a full search body — checks top-level allowlist + script walker.
|
|
79
|
+
*/
|
|
80
|
+
export declare function validateSearchBody(body: Record<string, unknown>): {
|
|
81
|
+
ok: true;
|
|
82
|
+
} | {
|
|
83
|
+
ok: false;
|
|
84
|
+
reason: string;
|
|
85
|
+
};
|
|
86
|
+
export declare class ElasticsearchConnector extends BaseConnector {
|
|
87
|
+
readonly providerName = "elasticsearch";
|
|
88
|
+
protected cachedTokens: ElasticsearchTokens | null;
|
|
89
|
+
private client;
|
|
90
|
+
protected getOAuthConfig(): null;
|
|
91
|
+
authenticate(): Promise<AuthContext>;
|
|
92
|
+
/**
|
|
93
|
+
* Build (or return cached) ES client based on stored credentials.
|
|
94
|
+
* Auth precedence: cloudId+apiKey > node+apiKey > node+username+password.
|
|
95
|
+
*/
|
|
96
|
+
private getClient;
|
|
97
|
+
disconnect(): Promise<void>;
|
|
98
|
+
healthCheck(): Promise<{
|
|
99
|
+
ok: boolean;
|
|
100
|
+
error?: ConnectorError;
|
|
101
|
+
}>;
|
|
102
|
+
normalizeError(error: unknown): ConnectorError;
|
|
103
|
+
getStatus(): ConnectorStatus;
|
|
104
|
+
listIndices(): Promise<unknown>;
|
|
105
|
+
describeIndex(index: string): Promise<{
|
|
106
|
+
mapping: unknown;
|
|
107
|
+
settings: unknown;
|
|
108
|
+
}>;
|
|
109
|
+
search(index: string, query: Record<string, unknown>, size?: number, from?: number, sort?: unknown, _source?: unknown): Promise<unknown>;
|
|
110
|
+
count(index: string, query?: Record<string, unknown>): Promise<unknown>;
|
|
111
|
+
aggregate(index: string, aggs: Record<string, unknown>, query?: Record<string, unknown>): Promise<unknown>;
|
|
112
|
+
clusterHealth(): Promise<unknown>;
|
|
113
|
+
}
|
|
114
|
+
export declare function getElasticsearchConnector(): ElasticsearchConnector;
|
|
115
|
+
export declare function resetElasticsearchConnector(): Promise<void>;
|
|
116
|
+
export { loadTokens as isConnected };
|
|
117
|
+
export declare const __testing: {
|
|
118
|
+
ALLOWED_TOP_LEVEL_KEYS: Set<string>;
|
|
119
|
+
MAX_SIZE: number;
|
|
120
|
+
MAX_AGG_SIZE: number;
|
|
121
|
+
};
|
|
122
|
+
export interface ConnectorHandlerResult {
|
|
123
|
+
status: number;
|
|
124
|
+
body: string;
|
|
125
|
+
contentType?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* POST /connections/elasticsearch/connect
|
|
129
|
+
* Body: { cloudId?, node?, apiKey?, username?, password? }
|
|
130
|
+
* Validates credential combo + pings the cluster, then stores the tokens.
|
|
131
|
+
*/
|
|
132
|
+
export declare function handleElasticsearchConnect(body: string): Promise<ConnectorHandlerResult>;
|
|
133
|
+
/**
|
|
134
|
+
* POST /connections/elasticsearch/test
|
|
135
|
+
* Verifies stored credentials with ping().
|
|
136
|
+
*/
|
|
137
|
+
export declare function handleElasticsearchTest(): Promise<ConnectorHandlerResult>;
|
|
138
|
+
/**
|
|
139
|
+
* DELETE /connections/elasticsearch
|
|
140
|
+
*/
|
|
141
|
+
export declare function handleElasticsearchDisconnect(): Promise<ConnectorHandlerResult>;
|