or3-provider-sqlite 0.0.31 → 0.0.32

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 CHANGED
@@ -288,8 +288,10 @@ model execution there; ordinary sync and other D1 features are unchanged.
288
288
 
289
289
  ### Workspace store
290
290
 
291
+ Migration 037 adds a nonunique index on `workspace_members.user_id`. Workspace lists and default-workspace recovery can look up an individual user's memberships directly. Rolling back migration 037 removes the index and preserves membership rows.
292
+
291
293
  - `getOrCreateUser` — maps `(provider, provider_user_id)` to internal user (idempotent)
292
- - `getOrCreateDefaultWorkspace` — creates first workspace + owner membership on initial login
294
+ - `getOrCreateDefaultWorkspace` returns the active workspace when its membership is valid. It repairs a stale selection using the earliest live membership and creates a personal workspace on first login.
293
295
  - Full workspace CRUD with role-based access checks
294
296
 
295
297
  ## Backup
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "or3-provider-sqlite",
3
3
  "configKey": "or3-provider-sqlite",
4
- "version": "0.0.31",
4
+ "version": "0.0.32",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "3.6.1"
@@ -204,7 +204,7 @@ export class SqliteAuthWorkspaceStore {
204
204
  const membership = await db.selectFrom("workspace_members").innerJoin("workspaces", "workspaces.id", "workspace_members.workspace_id").select([
205
205
  "workspaces.id",
206
206
  "workspaces.name"
207
- ]).where("workspace_members.user_id", "=", userId).where("workspaces.deleted", "=", 0).orderBy("workspace_members.created_at", "asc").executeTakeFirst();
207
+ ]).where("workspace_members.user_id", "=", userId).where("workspaces.deleted", "=", 0).orderBy("workspace_members.created_at", "asc").limit(1).executeTakeFirst();
208
208
  if (membership) {
209
209
  await db.updateTable("users").set({ active_workspace_id: membership.id }).where("id", "=", userId).execute();
210
210
  return {
@@ -74,6 +74,7 @@ import * as m033 from "./migrations/033_tool_result_operation_ids.js";
74
74
  import * as m034 from "./migrations/034_sync_intent_fingerprint.js";
75
75
  import * as m035 from "./migrations/035_sync_unavailable_records.js";
76
76
  import * as m036 from "./migrations/036_sync_history_incarnation.js";
77
+ import * as m037 from "./migrations/037_workspace_members_by_user.js";
77
78
  import { readHistoryIncarnation } from "../sync/history-incarnation.js";
78
79
  const migrations = {
79
80
  "001_init": m001,
@@ -111,7 +112,8 @@ const migrations = {
111
112
  "033_tool_result_operation_ids": m033,
112
113
  "034_sync_intent_fingerprint": m034,
113
114
  "035_sync_unavailable_records": m035,
114
- "036_sync_history_incarnation": m036
115
+ "036_sync_history_incarnation": m036,
116
+ "037_workspace_members_by_user": m037
115
117
  };
116
118
  class StaticMigrationProvider {
117
119
  async getMigrations() {
@@ -0,0 +1,3 @@
1
+ import type { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<unknown>): Promise<void>;
3
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -0,0 +1,6 @@
1
+ export async function up(db) {
2
+ await db.schema.createIndex("idx_workspace_members_user").ifNotExists().on("workspace_members").column("user_id").execute();
3
+ }
4
+ export async function down(db) {
5
+ await db.schema.dropIndex("idx_workspace_members_user").ifExists().execute();
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "or3-provider-sqlite",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Saluana/or3-provider-sqlite.git"