Skip to content

Commit 90559fa

Browse files
authored
Add api, site, and database packages to OSS (#99)
1 parent 04ac21c commit 90559fa

File tree

463 files changed

+84039
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

463 files changed

+84039
-127
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist/
33
*.tgz
44
.env.*
55
.sonda
6+
.next

LICENSE

Lines changed: 661 additions & 20 deletions
Large diffs are not rendered by default.

bun.lock

Lines changed: 1754 additions & 96 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"format": "prettier --write --cache .",
77
"test": "bun test",
8-
"typecheck": "tsgo --noEmit"
8+
"typecheck": "bun run --filter='*' typecheck"
99
},
1010
"workspaces": [
1111
"packages/*"

packages/api/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This is required for the package to be published.
2+
!dist/package.json

packages/api/package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "@blink.so/api",
3+
"description": "The internal module for the Blink API.",
4+
"private": true,
5+
"type": "module",
6+
"main": "./src/client.node.ts",
7+
"browser": "./src/client.browser.ts",
8+
"exports": {
9+
".": {
10+
"browser": "./src/client.browser.ts",
11+
"default": "./src/client.node.ts"
12+
},
13+
"./react": {
14+
"browser": "./src/react/index.ts",
15+
"default": "./src/react/index.ts"
16+
},
17+
"./server": "./src/server.ts",
18+
"./test": "./src/test.ts",
19+
"./agents/me": "./src/routes/agents/me/me.client.ts",
20+
"./agents/me/server": "./src/routes/agents/me/me.server.ts",
21+
"./util/chat": "./src/util/chat.ts"
22+
},
23+
"scripts": {
24+
"build": "tsdown",
25+
"pack": "bun run build && cd dist && npm pack",
26+
"typecheck": "tsgo --noEmit",
27+
"publish": "bun run pack && cd dist && npm publish"
28+
},
29+
"devDependencies": {
30+
"@bufbuild/protobuf": "^2.9.0",
31+
"@testing-library/react": "^16.3.0",
32+
"eventsource-parser": "^3.0.6",
33+
"happy-dom": "^18.0.1",
34+
"hono": "^4.9.7",
35+
"msw": "^2.12.1",
36+
"react": "19.1.2",
37+
"react-dom": "19.1.2",
38+
"tsdown": "^0.15.1",
39+
"zod": "^4.1.9",
40+
"zod-validation-error": "^4.0.1"
41+
},
42+
"peerDependencies": {
43+
"ai": ">= 5",
44+
"zod": ">= 4",
45+
"react": ">= 18"
46+
},
47+
"peerDependenciesMeta": {
48+
"react": {
49+
"optional": true
50+
}
51+
},
52+
"optionalDependencies": {
53+
"@blink-sdk/compute-protocol": ">= 0.0.2"
54+
},
55+
"dependencies": {
56+
"bcrypt-ts": "^7.1.0",
57+
"next-auth": "5.0.0-beta.28"
58+
}
59+
}

packages/api/package.public.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@blink.so/api",
3+
"description": "The TypeScript SDK for the Blink API.",
4+
"version": "1.0.0",
5+
"author": "Coder",
6+
"type": "module",
7+
"license": "MIT",
8+
"homepage": "https://blink.so",
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/coder/blink.git"
12+
},
13+
"publishConfig": {
14+
"access": "public"
15+
},
16+
"files": ["dist"],
17+
"exports": {
18+
".": {
19+
"browser": "./dist/client.browser.js",
20+
"import": "./dist/client.node.js",
21+
"require": "./dist/client.node.cjs",
22+
"default": "./dist/client.node.js"
23+
},
24+
"./react": {
25+
"import": "./dist/react/index.js",
26+
"require": "./dist/react/index.cjs"
27+
},
28+
"./package.json": "./package.json"
29+
},
30+
"peerDependencies": {
31+
"ai": ">= 5",
32+
"react": ">= 18",
33+
"zod": ">= 4"
34+
},
35+
"peerDependenciesMeta": {
36+
"react": { "optional": true }
37+
},
38+
"optionalDependencies": {
39+
"@blink-sdk/compute-protocol": ">= 0.0.2"
40+
}
41+
}

packages/api/runtime/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@blink.so/runtime",
3+
"private": true,
4+
"type": "module",
5+
"exports": {
6+
"./server": "./src/server.ts",
7+
"./types": "./src/types.ts",
8+
"./node/wrapper": "./src/node/wrapper-node.generated.ts",
9+
"./lambda": "./src/lambda/runtime-lambda.ts"
10+
},
11+
"dependencies": {},
12+
"devDependencies": {
13+
"aws4fetch": "^1.0.20",
14+
"jszip": "^3.10.1"
15+
}
16+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bun
2+
import { join } from "node:path";
3+
4+
const wrapperNode = join(__dirname, "../src/node/wrapper-node.ts");
5+
6+
let result = await Bun.build({
7+
entrypoints: [wrapperNode],
8+
target: "node",
9+
format: "esm",
10+
minify: true,
11+
});
12+
13+
let output = result.outputs[0];
14+
if (!output) {
15+
throw new Error("No output generated");
16+
}
17+
18+
await Bun.write(
19+
join(__dirname, "../src/node/wrapper-node.generated.ts"),
20+
`
21+
// This file has been generated by the ${import.meta.filename} script.
22+
// Do not edit this file manually.
23+
24+
export default ${JSON.stringify(await output.text())}
25+
`.trim()
26+
);
27+
28+
const wrapperLambda = join(__dirname, "../src/lambda/wrapper-lambda.ts");
29+
30+
result = await Bun.build({
31+
entrypoints: [wrapperLambda],
32+
target: "node",
33+
format: "esm",
34+
});
35+
36+
output = result.outputs[0];
37+
if (!output) {
38+
throw new Error("No output generated");
39+
}
40+
41+
await Bun.write(
42+
join(__dirname, "../src/lambda/wrapper-lambda.generated.ts"),
43+
`
44+
// This file has been generated by the ${import.meta.filename} script.
45+
// Do not edit this file manually.
46+
47+
export default ${JSON.stringify(await output.text())}
48+
`.trim()
49+
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { APIServerURLEnvironmentVariable } from "blink/client";
2+
import { api } from "blink/control";
3+
import { hc } from "hono/client";
4+
import http from "http";
5+
6+
// Here we're going to make it actually attempt to request the Blink API.
7+
const client = hc<typeof api>(process.env[APIServerURLEnvironmentVariable]!);
8+
9+
http
10+
.createServer(async (req, res) => {
11+
await client.kv[":key"].$post({
12+
param: {
13+
key: "test",
14+
},
15+
json: {
16+
value: "Hello, world!",
17+
},
18+
});
19+
20+
const resp = await client.kv[":key"].$get({
21+
param: {
22+
key: "test",
23+
},
24+
});
25+
if (!resp.ok) {
26+
throw new Error(`Failed to get storage: ${await resp.text()}`);
27+
}
28+
const value = await resp.json();
29+
res.end(value.value);
30+
})
31+
.listen(parseInt(process.env.PORT as string))
32+
.unref();

0 commit comments

Comments
 (0)