js-bao 0.2.10 → 0.3.0-alpha.0
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 +26 -0
- package/dist/browser.cjs +2 -2
- package/dist/browser.js +2 -2
- package/dist/client.cjs +766 -0
- package/dist/client.d.cts +1084 -0
- package/dist/client.d.ts +1084 -0
- package/dist/client.js +733 -0
- package/dist/cloudflare-do.cjs +3168 -0
- package/dist/cloudflare-do.d.cts +1303 -0
- package/dist/cloudflare-do.d.ts +1303 -0
- package/dist/cloudflare-do.js +3145 -0
- package/dist/cloudflare.cjs +977 -0
- package/dist/cloudflare.d.cts +1349 -0
- package/dist/cloudflare.d.ts +1349 -0
- package/dist/cloudflare.js +944 -0
- package/dist/codegen.cjs +258 -17
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +2 -2
- package/dist/node.js +2 -2
- package/package.json +40 -11
package/README.md
CHANGED
|
@@ -1229,6 +1229,32 @@ const user = new User({ name: "John Doe", email: "john@example.com" });
|
|
|
1229
1229
|
await user.save({ targetDocument: "main-doc" });
|
|
1230
1230
|
```
|
|
1231
1231
|
|
|
1232
|
+
## Client-Only Import (`js-bao/client`)
|
|
1233
|
+
|
|
1234
|
+
If you only need the HTTP client engine (e.g., for browser apps, React/Vue frontends, or Node.js clients that talk to a DO backend over HTTP), use `js-bao/client` instead of `js-bao/cloudflare`. This avoids pulling in server-side Durable Object code and its dependencies.
|
|
1235
|
+
|
|
1236
|
+
```typescript
|
|
1237
|
+
import { connectDoDb } from "js-bao/client";
|
|
1238
|
+
|
|
1239
|
+
const db = connectDoDb({
|
|
1240
|
+
endpoint: "https://my-app.workers.dev",
|
|
1241
|
+
id: "my-document",
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
// Save a record (schemaless)
|
|
1245
|
+
await db.engine.saveModel("todos", "todo-1", { title: "Buy milk", done: false });
|
|
1246
|
+
|
|
1247
|
+
// Query records
|
|
1248
|
+
const result = await db.engine.queryModel("todos", { done: false });
|
|
1249
|
+
console.log(result.data);
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
**When to use `js-bao/client`:** Browser apps, frontend builds, Node.js HTTP clients — any context where you don't need `createDatabaseDO` or `initJsBaoDO` server setup.
|
|
1253
|
+
|
|
1254
|
+
**When to use `js-bao/cloudflare`:** When building the Cloudflare Worker that hosts the Durable Object.
|
|
1255
|
+
|
|
1256
|
+
Key exports: `connectDoDb`, `DOClientEngine`, and types (`DoDb`, `DocumentFilter`, `QueryOptions`, `PaginatedResult`, `AggregationOptions`, etc.). This import has no dependencies on Cloudflare Workers APIs, better-sqlite3, sql.js, or Yjs — it's pure fetch-based HTTP.
|
|
1257
|
+
|
|
1232
1258
|
## Database Configuration
|
|
1233
1259
|
|
|
1234
1260
|
### SQLite (Node.js)
|
package/dist/browser.cjs
CHANGED
|
@@ -349,7 +349,7 @@ var init_CursorManager = __esm({
|
|
|
349
349
|
conditions.push(`(${levelCondition})`);
|
|
350
350
|
params.push(...fieldParams);
|
|
351
351
|
}
|
|
352
|
-
const sql = conditions.join(" OR ")
|
|
352
|
+
const sql = `(${conditions.join(" OR ")})`;
|
|
353
353
|
return { sql, params };
|
|
354
354
|
}
|
|
355
355
|
/**
|
|
@@ -1310,7 +1310,7 @@ var init_BaseModel = __esm({
|
|
|
1310
1310
|
Object.setPrototypeOf(this, _RecordNotFoundError.prototype);
|
|
1311
1311
|
}
|
|
1312
1312
|
};
|
|
1313
|
-
SCHEMA_ACCESSORS_KEY = Symbol("jsBaoSchemaAccessors");
|
|
1313
|
+
SCHEMA_ACCESSORS_KEY = /* @__PURE__ */ Symbol("jsBaoSchemaAccessors");
|
|
1314
1314
|
BaseModel = class _BaseModel {
|
|
1315
1315
|
static modelName;
|
|
1316
1316
|
static listenersMap = /* @__PURE__ */ new Map();
|
package/dist/browser.js
CHANGED
|
@@ -327,7 +327,7 @@ var init_CursorManager = __esm({
|
|
|
327
327
|
conditions.push(`(${levelCondition})`);
|
|
328
328
|
params.push(...fieldParams);
|
|
329
329
|
}
|
|
330
|
-
const sql = conditions.join(" OR ")
|
|
330
|
+
const sql = `(${conditions.join(" OR ")})`;
|
|
331
331
|
return { sql, params };
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
@@ -1288,7 +1288,7 @@ var init_BaseModel = __esm({
|
|
|
1288
1288
|
Object.setPrototypeOf(this, _RecordNotFoundError.prototype);
|
|
1289
1289
|
}
|
|
1290
1290
|
};
|
|
1291
|
-
SCHEMA_ACCESSORS_KEY = Symbol("jsBaoSchemaAccessors");
|
|
1291
|
+
SCHEMA_ACCESSORS_KEY = /* @__PURE__ */ Symbol("jsBaoSchemaAccessors");
|
|
1292
1292
|
BaseModel = class _BaseModel {
|
|
1293
1293
|
static modelName;
|
|
1294
1294
|
static listenersMap = /* @__PURE__ */ new Map();
|