@surf-ai/sdk 0.1.6-beta → 1.0.0-alpha.1
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 +86 -375
- package/dist/db/index.cjs +216 -39
- package/dist/db/index.d.cts +37 -3
- package/dist/db/index.d.ts +37 -3
- package/dist/db/index.js +210 -38
- package/dist/server/index.cjs +250 -268
- package/dist/server/index.d.cts +9 -15
- package/dist/server/index.d.ts +9 -15
- package/dist/server/index.js +269 -195
- package/package.json +6 -29
- package/dist/chunk-J4OMYO3F.js +0 -70
- package/dist/client-3YMIRPDV.js +0 -8
- package/dist/react/index.d.ts +0 -3650
- package/dist/react/index.js +0 -1175
- package/src/theme/index.css +0 -314
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surf-ai/sdk",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Surf platform SDK — data API client, server runtime,
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"description": "Surf platform SDK — data API client, server runtime, and database helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./server": {
|
|
@@ -9,20 +9,14 @@
|
|
|
9
9
|
"import": "./dist/server/index.js",
|
|
10
10
|
"require": "./dist/server/index.cjs"
|
|
11
11
|
},
|
|
12
|
-
"./react": {
|
|
13
|
-
"types": "./dist/react/index.d.ts",
|
|
14
|
-
"import": "./dist/react/index.js"
|
|
15
|
-
},
|
|
16
12
|
"./db": {
|
|
17
13
|
"types": "./dist/db/index.d.ts",
|
|
18
14
|
"import": "./dist/db/index.js",
|
|
19
15
|
"require": "./dist/db/index.cjs"
|
|
20
|
-
}
|
|
21
|
-
"./theme.css": "./src/theme/index.css"
|
|
16
|
+
}
|
|
22
17
|
},
|
|
23
18
|
"files": [
|
|
24
|
-
"dist"
|
|
25
|
-
"src/theme"
|
|
19
|
+
"dist"
|
|
26
20
|
],
|
|
27
21
|
"scripts": {
|
|
28
22
|
"build": "tsup",
|
|
@@ -33,30 +27,13 @@
|
|
|
33
27
|
"dependencies": {
|
|
34
28
|
"express": "^4.22.0",
|
|
35
29
|
"cors": "^2.8.5",
|
|
36
|
-
"http-proxy-middleware": "^3.0.0",
|
|
37
30
|
"croner": "^9.0.0",
|
|
38
|
-
"drizzle-orm": "^0.44.0"
|
|
39
|
-
"@tanstack/react-query": "^5.94.0",
|
|
40
|
-
"clsx": "^2.1.0",
|
|
41
|
-
"tailwind-merge": "^2.6.0"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"react": "^19.0.0",
|
|
45
|
-
"react-dom": "^19.0.0"
|
|
46
|
-
},
|
|
47
|
-
"peerDependenciesMeta": {
|
|
48
|
-
"react": {
|
|
49
|
-
"optional": true
|
|
50
|
-
},
|
|
51
|
-
"react-dom": {
|
|
52
|
-
"optional": true
|
|
53
|
-
}
|
|
31
|
+
"drizzle-orm": "^0.44.0"
|
|
54
32
|
},
|
|
55
33
|
"devDependencies": {
|
|
56
34
|
"tsup": "^8.0.0",
|
|
57
35
|
"typescript": "^5.9.0",
|
|
58
36
|
"@types/express": "^5.0.0",
|
|
59
|
-
"@types/cors": "^2.8.0"
|
|
60
|
-
"@types/react": "^19.0.0"
|
|
37
|
+
"@types/cors": "^2.8.0"
|
|
61
38
|
}
|
|
62
39
|
}
|
package/dist/chunk-J4OMYO3F.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/data/client.ts
|
|
9
|
-
var DEFAULT_PUBLIC_URL = "https://api.ask.surf/gateway/v1";
|
|
10
|
-
function env(surfName, legacyName) {
|
|
11
|
-
return process.env[surfName] || process.env[legacyName];
|
|
12
|
-
}
|
|
13
|
-
function resolveConfig() {
|
|
14
|
-
const proxyBase = env("SURF_SANDBOX_PROXY_BASE", "DATA_PROXY_BASE");
|
|
15
|
-
if (proxyBase) {
|
|
16
|
-
return { baseUrl: proxyBase, headers: {} };
|
|
17
|
-
}
|
|
18
|
-
const gatewayUrl = env("SURF_DEPLOYED_GATEWAY_URL", "GATEWAY_URL");
|
|
19
|
-
const appToken = env("SURF_DEPLOYED_APP_TOKEN", "APP_TOKEN");
|
|
20
|
-
if (gatewayUrl && appToken) {
|
|
21
|
-
return {
|
|
22
|
-
baseUrl: `${gatewayUrl.replace(/\/$/, "")}/gateway/v1`,
|
|
23
|
-
headers: { Authorization: `Bearer ${appToken}` }
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return { baseUrl: DEFAULT_PUBLIC_URL, headers: {} };
|
|
27
|
-
}
|
|
28
|
-
function normalizePath(path) {
|
|
29
|
-
return String(path || "").replace(/^\/+/, "").replace(/^(?:proxy\/)+/, "");
|
|
30
|
-
}
|
|
31
|
-
async function fetchJson(url, init, retries = 1) {
|
|
32
|
-
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
33
|
-
const res = await fetch(url, init);
|
|
34
|
-
if (!res.ok) {
|
|
35
|
-
const text2 = await res.text();
|
|
36
|
-
throw new Error(`API error ${res.status}: ${text2.slice(0, 200)}`);
|
|
37
|
-
}
|
|
38
|
-
const text = await res.text();
|
|
39
|
-
if (text) return JSON.parse(text);
|
|
40
|
-
if (attempt < retries) await new Promise((r) => setTimeout(r, 1e3));
|
|
41
|
-
}
|
|
42
|
-
throw new Error(`Empty response from ${url}`);
|
|
43
|
-
}
|
|
44
|
-
async function get(path, params) {
|
|
45
|
-
const config = resolveConfig();
|
|
46
|
-
const cleaned = {};
|
|
47
|
-
if (params) {
|
|
48
|
-
for (const [k, v] of Object.entries(params)) {
|
|
49
|
-
if (v != null) cleaned[k] = String(v);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const qs = Object.keys(cleaned).length ? "?" + new URLSearchParams(cleaned).toString() : "";
|
|
53
|
-
return fetchJson(`${config.baseUrl}/${normalizePath(path)}${qs}`, {
|
|
54
|
-
headers: config.headers
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async function post(path, body) {
|
|
58
|
-
const config = resolveConfig();
|
|
59
|
-
return fetchJson(`${config.baseUrl}/${normalizePath(path)}`, {
|
|
60
|
-
method: "POST",
|
|
61
|
-
headers: { ...config.headers, "Content-Type": "application/json" },
|
|
62
|
-
body: body ? JSON.stringify(body) : void 0
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export {
|
|
67
|
-
__require,
|
|
68
|
-
get,
|
|
69
|
-
post
|
|
70
|
-
};
|