Skip to content
Merged

NPM #84

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ jobs:
node <<'EOF' >> "$GITHUB_OUTPUT"
const { execSync } = require('child_process');
const packages = [
{ name: '@frostbase/auth', dir: 'agents/auth', prefix: 'auth-v' },
{ name: '@frostbase/db', dir: 'agents/db', prefix: 'db-v' },
{ name: '@frostbase/storage', dir: 'agents/storage', prefix: 'storage-v' },
{ name: '@frostbase/cli', dir: 'cli', prefix: 'cli-v' },
{ name: '@frostbase-dev/auth', dir: 'agents/auth', prefix: 'auth-v' },
{ name: '@frostbase-dev/db', dir: 'agents/db', prefix: 'db-v' },
{ name: '@frostbase-dev/storage', dir: 'agents/storage', prefix: 'storage-v' },
{ name: '@frostbase-dev/cli', dir: 'cli', prefix: 'cli-v' },
];
const refType = process.env.GITHUB_REF_TYPE;
const refName = process.env.GITHUB_REF_NAME;
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ types.
| `agents/auth` | `auth-agent` | `AuthAgent` |
| `agents/db` | `db-agent` | `DbAgent` `DbCollection` `DbTable` `DbGateway` `DbView` |
| `agents/storage` | `storage-agent` | `StorageAgent` `StorageBucket` |
| `cli` | none | `@frostbase/cli`, runs on a consumer's machine |
| `cli` | none | `@frostbase-dev/cli`, runs on a consumer's machine |

**Never import runtime code or generated Worker types across those
boundaries.** Shared DTOs are deliberately copied — `src/lib/agents.ts` mirrors
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ cd agents/db && npx tsc --noEmit && npm run test:unit
Separate npm projects with separate Wrangler configs and separate generated
`Env` types:

| Path | Worker | What it is |
| ------------- | ------------ | ---------------------------------------------- |
| `/` | web | SvelteKit dashboard and marketing site |
| `agents/auth` | `auth-agent` | `AuthAgent` DO - Better Auth per project |
| `agents/db` | `db-agent` | `DbAgent` + `DbCollection` DOs - documents |
| `cli` | none | `@frostbase/cli`, runs on a consumer's machine |
| Path | Worker | What it is |
| ------------- | ------------ | -------------------------------------------------- |
| `/` | web | SvelteKit dashboard and marketing site |
| `agents/auth` | `auth-agent` | `AuthAgent` DO - Better Auth per project |
| `agents/db` | `db-agent` | `DbAgent` + `DbCollection` DOs - documents |
| `cli` | none | `@frostbase-dev/cli`, runs on a consumer's machine |

**Never import runtime code or generated Worker types across those
boundaries.** Shared DTOs are deliberately copied - `src/lib/agents.ts`
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ allowlist, and an unlisted origin gets a 403.
For a server credential, from the CLI:

```bash
npm install -g @frostbase/cli
npm install -g @frostbase-dev/cli
frostbase login
frostbase init # links this directory to a project
frostbase key create server --env-file # writes a service key to .env.local
Expand Down Expand Up @@ -178,7 +178,7 @@ if (!config.get('signupsOpen')) {
Buckets of files with per-bucket access modes:

```ts
import { createStorageClient } from '@frostbase/storage/client';
import { createStorageClient } from '@frostbase-dev/storage/client';

const storage = createStorageClient({
baseUrl: 'https://frostbase.dev/agents/storage-agent/<project-id>',
Expand All @@ -200,9 +200,9 @@ With no user to relay — a cron, queue consumer, or webhook — mint a
page). Each agent ships an `./admin` client over it:

```ts
import { createDbAdmin } from '@frostbase/db/admin';
import { createAuthAdmin } from '@frostbase/auth/admin';
import { createStorageAdmin } from '@frostbase/storage/admin';
import { createDbAdmin } from '@frostbase-dev/db/admin';
import { createAuthAdmin } from '@frostbase-dev/auth/admin';
import { createStorageAdmin } from '@frostbase-dev/storage/admin';

const db = createDbAdmin(); // url, project, and key from the environment
const post = await db.collection('posts').get(id);
Expand Down
2 changes: 1 addition & 1 deletion agents/auth/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @frostbase/auth
# @frostbase-dev/auth

Better Auth on a Durable Object. One `AuthAgent` per project, addressed by
project id, each with its own embedded SQLite and its own signing keypair.
Expand Down
10 changes: 5 additions & 5 deletions agents/auth/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @frostbase/auth
# @frostbase-dev/auth

Better Auth on a Cloudflare Durable Object. One isolated instance per project,
each with its own embedded SQLite database, in your account. This is the auth
Expand All @@ -14,7 +14,7 @@ dashboards; and opt-in auth events into Workers Analytics Engine.
The easy way is the CLI, which does all of the wiring below:

```bash
npx @frostbase/cli add auth
npx @frostbase-dev/cli add auth
```

By hand: install the package, re-export the agent from your Worker entrypoint
Expand All @@ -24,11 +24,11 @@ your `wrangler.jsonc`, and regenerate types.

```ts
// src/index.ts
export { AuthAgent, default } from '@frostbase/auth';
export { AuthAgent, default } from '@frostbase-dev/auth';
```

```bash
npm install @frostbase/auth
npm install @frostbase-dev/auth
npx wrangler types
npx wrangler deploy
```
Expand All @@ -43,7 +43,7 @@ catch a missing binding at compile time instead of on the first request, add
one line anywhere in your Worker:

```ts
import type { AssertAuthAgentEnv } from '@frostbase/auth';
import type { AssertAuthAgentEnv } from '@frostbase-dev/auth';
export type _AuthAgentBindings = AssertAuthAgentEnv<Env>;
```

Expand Down
2 changes: 1 addition & 1 deletion agents/auth/frostbase.agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "auth",
"title": "Authentication",
"description": "Users, sessions, and RBAC on Durable Object SQLite.",
"packageName": "@frostbase/auth",
"packageName": "@frostbase-dev/auth",
"worker": "auth-agent",
"durableObjects": [{ "class": "AuthAgent", "scope": "perProject" }],
"entrypoint": { "assertEnvType": "AssertAuthAgentEnv" },
Expand Down
4 changes: 2 additions & 2 deletions agents/auth/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@frostbase/auth",
"name": "@frostbase-dev/auth",
"version": "0.7.4",
"description": "Better Auth on a Cloudflare Durable Object, one instance per project - the auth primitive behind Frostbase.",
"license": "Apache-2.0",
Expand Down
10 changes: 5 additions & 5 deletions agents/auth/src/admin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* The ADMIN client for `@frostbase/auth` - user and session management
* The ADMIN client for `@frostbase-dev/auth` - user and session management
* from a server.
*
* The twin of `@frostbase/db/admin`, and the same three properties hold:
* The twin of `@frostbase-dev/db/admin`, and the same three properties hold:
* it targets the CONSOLE (a `cfbs_` service key is verified in the console
* guard and never reaches this agent as a bearer), it is admin-grade, and it
* is server-only.
Expand Down Expand Up @@ -51,7 +51,7 @@ export class AuthAdminError extends Error {
export class AuthAgentTooOldError extends Error {
constructor(path: string) {
super(
`the auth agent did not recognise ${path}. Deploy @frostbase/auth 0.7.0 or newer ` +
`the auth agent did not recognise ${path}. Deploy @frostbase-dev/auth 0.7.0 or newer ` +
`before calling this - an older agent answers a 404 that looks like a missing user.`,
);
this.name = 'AuthAgentTooOldError';
Expand All @@ -74,7 +74,7 @@ function assertServerOnly(): void {
// which declare no DOM, and a Worker has no document either.
if (typeof (globalThis as { document?: unknown }).document !== 'undefined') {
throw new Error(
'@frostbase/auth/admin is server-only: it carries a service key, which can read and ' +
'@frostbase-dev/auth/admin is server-only: it carries a service key, which can read and ' +
'delete every account in your project. Never import it into browser code. Use ' +
'better-auth/client with the signed-in user’s own session instead.',
);
Expand All @@ -98,7 +98,7 @@ function resolve(
if (value) return value;
}
throw new Error(
`@frostbase/auth/admin needs ${label}: pass it explicitly, or set ${names.join(' or ')}. ` +
`@frostbase-dev/auth/admin needs ${label}: pass it explicitly, or set ${names.join(' or ')}. ` +
`Inside a Worker, secrets live on \`env\` rather than a global process - pass \`{ env }\`.`,
);
}
Expand Down
4 changes: 2 additions & 2 deletions agents/auth/src/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* The binding contract for consumers of `@frostbase/auth`.
* The binding contract for consumers of `@frostbase-dev/auth`.
*
* The Agents SDK constrains `Agent<Env, State>` against `Cloudflare.Env`, which
* is an empty declaration-merge target that `wrangler types` fills in from your
Expand Down Expand Up @@ -144,7 +144,7 @@ export interface AuthAgentBindings {
* on first request. Use it once, anywhere in your Worker:
*
* ```ts
* import type { AssertAuthAgentEnv } from '@frostbase/auth';
* import type { AssertAuthAgentEnv } from '@frostbase-dev/auth';
* type _AuthBindings = AssertAuthAgentEnv<Env>;
* ```
*/
Expand Down
6 changes: 3 additions & 3 deletions agents/auth/template/worker-entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Worker entrypoint for a Worker that hosts `@frostbase/auth`.
* Worker entrypoint for a Worker that hosts `@frostbase-dev/auth`.
*
* Copy this to the file your `wrangler.jsonc` names as `main`.
*
Expand All @@ -8,7 +8,7 @@
* the binding resolves. The default export is the fetch handler that routes
* `/agents/auth-agent/<projectId>/...` to the right instance.
*/
export { AuthAgent, default } from '@frostbase/auth';
export { AuthAgent, default } from '@frostbase-dev/auth';

/**
* Compile-time check that your generated `Env` carries the bindings the agent
Expand All @@ -17,5 +17,5 @@ export { AuthAgent, default } from '@frostbase/auth';
*
* Run `npx wrangler types` after editing `wrangler.jsonc` to regenerate `Env`.
*/
import type { AssertAuthAgentEnv } from '@frostbase/auth';
import type { AssertAuthAgentEnv } from '@frostbase-dev/auth';
export type _AuthAgentBindings = AssertAuthAgentEnv<Env>;
2 changes: 1 addition & 1 deletion agents/auth/template/wrangler-fragment.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Wrangler configuration for a Worker that hosts `@frostbase/auth`.
* Wrangler configuration for a Worker that hosts `@frostbase-dev/auth`.
*
* Merge this into your own `wrangler.jsonc`, then run `npx wrangler types` so
* the generated `Env` carries these bindings. The agent reads `Env` from your
Expand Down
2 changes: 1 addition & 1 deletion agents/auth/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Publish build for `@frostbase/auth`.
* Publish build for `@frostbase-dev/auth`.
*
* Emits `dist/` from `src/` only. Two things are deliberately left out of the
* published package:
Expand Down
2 changes: 1 addition & 1 deletion agents/auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* `dist` is this project's own build output - with allowJs on it would be
* typechecked alongside the sources it was emitted from. `template` holds
* files meant to be copied into a consumer's project, so they import
* `@frostbase/auth` by package name, which does not resolve from
* `@frostbase-dev/auth` by package name, which does not resolve from
* inside the package itself.
*/
"exclude": ["dist", "template", "node_modules"]
Expand Down
2 changes: 1 addition & 1 deletion agents/db/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @frostbase/db
# @frostbase-dev/db

Documents with live queries and schema-first SQL tables, one Durable Object per
collection or table. The largest agent in the repo and the one with the most
Expand Down
12 changes: 6 additions & 6 deletions agents/db/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @frostbase/db
# @frostbase-dev/db

Firestore-style JSON documents with live queries, running on Cloudflare
Durable Objects - one isolated instance per collection. The database
primitive behind [Frostbase](https://github.com/frostbase-dev/frostbase).

```bash
npx @frostbase/cli add db
npx @frostbase-dev/cli add db
```

The CLI installs this package, merges `template/wrangler-fragment.jsonc` into
Expand All @@ -23,7 +23,7 @@ steps; both templates ship in the package.
`added` / `modified` / `removed` deltas as writes happen. Subscriptions
survive hibernation; you pay nothing while idle.
- **Access modes per collection** - `public`, `auth`, or `owner`, verified
against `@frostbase/auth` project JWTs. `owner` scopes every read and
against `@frostbase-dev/auth` project JWTs. `owner` scopes every read and
write to the token's subject. Optional permission keys additionally require
that claim on the JWT (granted via auth roles; the admin role's `*` always
passes).
Expand All @@ -37,12 +37,12 @@ steps; both templates ship in the package.
SDK), operator NDJSON import that round-trips exports exactly, and
point-in-time restore of a single collection to any moment in the past 30
days (deployed stacks; local development has no durable change log).
- **A typed client** - `@frostbase/db/client` wraps REST, aggregates,
- **A typed client** - `@frostbase-dev/db/client` wraps REST, aggregates,
export, and the subscribe protocol with the same zod schemas the server
validates with.

```ts
import { createDbClient } from '@frostbase/db/client';
import { createDbClient } from '@frostbase-dev/db/client';

const db = createDbClient({
baseUrl: 'https://your-worker.workers.dev/agents/db-agent/my-app',
Expand All @@ -65,7 +65,7 @@ const unsubscribe = posts.subscribe(
Required: the `DbAgent` and `DbCollection` Durable Object bindings and the
`DB_EVENTS` Analytics Engine dataset (auto-creates on first write). Optional:
an `AUTH_AGENT` service binding for multi-worker deployments - in the normal
single-worker install, having `@frostbase/auth` in the same Worker is
single-worker install, having `@frostbase-dev/auth` in the same Worker is
enough for token verification. No secret is required for a working deploy.

## What your Worker serves
Expand Down
2 changes: 1 addition & 1 deletion agents/db/frostbase.agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "db",
"title": "Database",
"description": "Documents with live queries and SQL tables with typed columns - one Durable Object per collection or table.",
"packageName": "@frostbase/db",
"packageName": "@frostbase-dev/db",
"worker": "db-agent",
"durableObjects": [
{ "class": "DbAgent", "scope": "perProject" },
Expand Down
4 changes: 2 additions & 2 deletions agents/db/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/db/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@frostbase/db",
"name": "@frostbase-dev/db",
"version": "0.7.0",
"description": "Documents with live queries and schema-first SQL tables on Cloudflare Durable Objects, one isolated instance per collection or table - the database primitive behind Frostbase.",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions agents/db/src/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function resolve(
if (value) return value;
}
throw new Error(
`@frostbase/db/admin needs ${label}: pass it explicitly, or set ${names.join(' or ')}. ` +
`@frostbase-dev/db/admin needs ${label}: pass it explicitly, or set ${names.join(' or ')}. ` +
`Inside a Worker, secrets live on \`env\` rather than a global process - pass \`{ env }\`.`,
);
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export class DbAdminError extends Error {
export class DbAgentTooOldError extends Error {
constructor(path: string) {
super(
`the db agent did not recognise ${path}. Deploy @frostbase/db 0.6.0 or newer ` +
`the db agent did not recognise ${path}. Deploy @frostbase-dev/db 0.6.0 or newer ` +
`before calling this - an older agent answers a 404 that looks like a missing record.`,
);
this.name = 'DbAgentTooOldError';
Expand All @@ -119,8 +119,8 @@ function assertServerOnly(): void {
// test anyway, since a Worker has neither.
if (typeof (globalThis as { document?: unknown }).document !== 'undefined') {
throw new Error(
'@frostbase/db/admin is server-only: it carries a service key, which is admin-grade ' +
'over your whole project. Never import it into browser code. Use @frostbase/db/client ' +
'@frostbase-dev/db/admin is server-only: it carries a service key, which is admin-grade ' +
'over your whole project. Never import it into browser code. Use @frostbase-dev/db/client ' +
'with the signed-in user’s project JWT instead.',
);
}
Expand Down
2 changes: 1 addition & 1 deletion agents/db/src/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { TableSqlResponse, TableSqlResult } from './schemas';
* SQL), so `getToken` is effectively mandatory outside operator tooling.
*
* ```ts
* import { drizzleTable } from '@frostbase/db/drizzle';
* import { drizzleTable } from '@frostbase-dev/db/drizzle';
* import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
*
* const todos = sqliteTable('todos', {
Expand Down
10 changes: 5 additions & 5 deletions agents/db/template/worker-entry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Worker entrypoint for a Worker that hosts `@frostbase/db`.
* Worker entrypoint for a Worker that hosts `@frostbase-dev/db`.
*
* Copy this to the file your `wrangler.jsonc` names as `main`.
*
Expand All @@ -8,13 +8,13 @@
* how the bindings resolve. The default export is the fetch handler that
* routes `/agents/db-agent/<projectId>/...` to the right instances.
*
* Already have a default export (for example from `@frostbase/auth`)?
* Already have a default export (for example from `@frostbase-dev/auth`)?
* Re-export only the classes - the existing agent handler routes to any
* Durable Object binding by name:
*
* export { DbAgent, DbCollection } from '@frostbase/db';
* export { DbAgent, DbCollection } from '@frostbase-dev/db';
*/
export { DbAgent, DbCollection, default } from '@frostbase/db';
export { DbAgent, DbCollection, default } from '@frostbase-dev/db';

/**
* Compile-time check that your generated `Env` carries the bindings the agent
Expand All @@ -23,5 +23,5 @@ export { DbAgent, DbCollection, default } from '@frostbase/db';
*
* Run `npx wrangler types` after editing `wrangler.jsonc` to regenerate `Env`.
*/
import type { AssertDbAgentEnv } from '@frostbase/db';
import type { AssertDbAgentEnv } from '@frostbase-dev/db';
export type _DbAgentBindings = AssertDbAgentEnv<Env>;
Loading
Loading