@squadbase/vite-server 0.0.5 → 0.0.7
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/connectors/kintone.ts
|
|
1
|
+
// src/connectors/entries/kintone.ts
|
|
2
2
|
import { kintone } from "@squadbase/connectors/sdk";
|
|
3
3
|
import { kintoneConnector } from "@squadbase/connectors";
|
|
4
4
|
|
|
@@ -61,7 +61,7 @@ function createConnectorSdk(plugin, createClient) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// src/connectors/kintone.ts
|
|
64
|
+
// src/connectors/entries/kintone.ts
|
|
65
65
|
var connection = createConnectorSdk(kintoneConnector, kintone);
|
|
66
66
|
export {
|
|
67
67
|
connection
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/connectors/entries/openai.ts
|
|
2
|
+
import { openai } from "@squadbase/connectors/sdk";
|
|
3
|
+
import { openaiConnector } from "@squadbase/connectors";
|
|
4
|
+
|
|
5
|
+
// src/connectors/create-connector-sdk.ts
|
|
6
|
+
import { readFileSync } from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
|
|
9
|
+
// src/connector-client/env.ts
|
|
10
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
11
|
+
const envVarName = entry.envVars[key];
|
|
12
|
+
if (!envVarName) {
|
|
13
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
14
|
+
}
|
|
15
|
+
const value = process.env[envVarName];
|
|
16
|
+
if (!value) {
|
|
17
|
+
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function resolveEnvVarOptional(entry, key) {
|
|
22
|
+
const envVarName = entry.envVars[key];
|
|
23
|
+
if (!envVarName) return void 0;
|
|
24
|
+
return process.env[envVarName] || void 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/connectors/create-connector-sdk.ts
|
|
28
|
+
function loadConnectionsSync() {
|
|
29
|
+
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
30
|
+
try {
|
|
31
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
32
|
+
return JSON.parse(raw);
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function createConnectorSdk(plugin, createClient) {
|
|
38
|
+
return (connectionId) => {
|
|
39
|
+
const connections = loadConnectionsSync();
|
|
40
|
+
const entry = connections[connectionId];
|
|
41
|
+
if (!entry) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (entry.connector.slug !== plugin.slug) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const params = {};
|
|
52
|
+
for (const param of Object.values(plugin.parameters)) {
|
|
53
|
+
if (param.required) {
|
|
54
|
+
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
55
|
+
} else {
|
|
56
|
+
const val = resolveEnvVarOptional(entry, param.slug);
|
|
57
|
+
if (val !== void 0) params[param.slug] = val;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return createClient(params);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/connectors/entries/openai.ts
|
|
65
|
+
var connection = createConnectorSdk(openaiConnector, openai);
|
|
66
|
+
export {
|
|
67
|
+
connection
|
|
68
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/vite-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"./connectors/kintone": {
|
|
23
23
|
"import": "./dist/connectors/kintone.js",
|
|
24
24
|
"types": "./dist/connectors/kintone.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./connectors/openai": {
|
|
27
|
+
"import": "./dist/connectors/openai.js",
|
|
28
|
+
"types": "./dist/connectors/openai.d.ts"
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
"files": [
|
|
@@ -41,7 +45,7 @@
|
|
|
41
45
|
"build:cli": "tsup src/cli/index.ts --out-dir dist/cli --format esm --platform node --no-splitting --external pg --external snowflake-sdk --external @google-cloud/bigquery --external mysql2 --external @aws-sdk/client-athena --external @aws-sdk/client-redshift-data --external @databricks/sql --external @google-analytics/data --external @kintone/rest-api-client --external hono --external @clack/prompts"
|
|
42
46
|
},
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"@squadbase/connectors": "^0.0.
|
|
48
|
+
"@squadbase/connectors": "^0.0.11",
|
|
45
49
|
"@aws-sdk/client-athena": "^3.750.0",
|
|
46
50
|
"@aws-sdk/client-redshift-data": "^3.750.0",
|
|
47
51
|
"@databricks/sql": "^1.8.0",
|