@sudobility/entity_service 1.0.4 → 1.0.6

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.
Files changed (36) hide show
  1. package/dist/helpers/EntityHelper.cjs +29 -21
  2. package/dist/helpers/EntityHelper.d.ts +12 -4
  3. package/dist/helpers/EntityHelper.d.ts.map +1 -1
  4. package/dist/helpers/EntityHelper.js +29 -21
  5. package/dist/helpers/EntityHelper.js.map +1 -1
  6. package/dist/helpers/EntityMemberHelper.cjs +86 -47
  7. package/dist/helpers/EntityMemberHelper.d.ts +11 -3
  8. package/dist/helpers/EntityMemberHelper.d.ts.map +1 -1
  9. package/dist/helpers/EntityMemberHelper.js +86 -47
  10. package/dist/helpers/EntityMemberHelper.js.map +1 -1
  11. package/dist/helpers/InvitationHelper.cjs +15 -10
  12. package/dist/helpers/InvitationHelper.d.ts +6 -2
  13. package/dist/helpers/InvitationHelper.d.ts.map +1 -1
  14. package/dist/helpers/InvitationHelper.js +15 -10
  15. package/dist/helpers/InvitationHelper.js.map +1 -1
  16. package/dist/helpers/PermissionHelper.cjs +8 -12
  17. package/dist/helpers/PermissionHelper.d.ts +3 -0
  18. package/dist/helpers/PermissionHelper.d.ts.map +1 -1
  19. package/dist/helpers/PermissionHelper.js +8 -12
  20. package/dist/helpers/PermissionHelper.js.map +1 -1
  21. package/dist/middleware/hono.cjs +6 -6
  22. package/dist/middleware/hono.d.ts +3 -3
  23. package/dist/middleware/hono.js +6 -6
  24. package/dist/middleware/hono.js.map +1 -1
  25. package/dist/migrations/001_add_entities.cjs +93 -32
  26. package/dist/migrations/001_add_entities.d.ts.map +1 -1
  27. package/dist/migrations/001_add_entities.js +93 -32
  28. package/dist/migrations/001_add_entities.js.map +1 -1
  29. package/dist/schema/entities.cjs +30 -23
  30. package/dist/schema/entities.d.ts +61 -46
  31. package/dist/schema/entities.d.ts.map +1 -1
  32. package/dist/schema/entities.js +30 -23
  33. package/dist/schema/entities.js.map +1 -1
  34. package/dist/types/index.d.ts +3 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/package.json +3 -3
@@ -23,6 +23,7 @@ const pg_core_1 = require("drizzle-orm/pg-core");
23
23
  // ========================================
24
24
  /**
25
25
  * Create an entities table for a specific PostgreSQL schema.
26
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
26
27
  *
27
28
  * @param schema - The Drizzle pgSchema object
28
29
  * @param indexPrefix - Prefix for index names to avoid conflicts
@@ -36,17 +37,16 @@ function createEntitiesTable(schema, indexPrefix) {
36
37
  display_name: (0, pg_core_1.varchar)('display_name', { length: 255 }).notNull(),
37
38
  description: (0, pg_core_1.text)('description'),
38
39
  avatar_url: (0, pg_core_1.text)('avatar_url'),
39
- owner_user_id: (0, pg_core_1.uuid)('owner_user_id').notNull(),
40
40
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
41
41
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
42
42
  }, (table) => ({
43
43
  slugIdx: (0, pg_core_1.uniqueIndex)(`${indexPrefix}_entities_slug_idx`).on(table.entity_slug),
44
- ownerIdx: (0, pg_core_1.index)(`${indexPrefix}_entities_owner_idx`).on(table.owner_user_id),
45
44
  typeIdx: (0, pg_core_1.index)(`${indexPrefix}_entities_type_idx`).on(table.entity_type),
46
45
  }));
47
46
  }
48
47
  /**
49
48
  * Create an entities table for the public schema.
49
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
50
50
  */
51
51
  function createEntitiesTablePublic(indexPrefix) {
52
52
  return (0, pg_core_1.pgTable)('entities', {
@@ -56,12 +56,10 @@ function createEntitiesTablePublic(indexPrefix) {
56
56
  display_name: (0, pg_core_1.varchar)('display_name', { length: 255 }).notNull(),
57
57
  description: (0, pg_core_1.text)('description'),
58
58
  avatar_url: (0, pg_core_1.text)('avatar_url'),
59
- owner_user_id: (0, pg_core_1.uuid)('owner_user_id').notNull(),
60
59
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
61
60
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
62
61
  }, (table) => ({
63
62
  slugIdx: (0, pg_core_1.uniqueIndex)(`${indexPrefix}_entities_slug_idx`).on(table.entity_slug),
64
- ownerIdx: (0, pg_core_1.index)(`${indexPrefix}_entities_owner_idx`).on(table.owner_user_id),
65
63
  typeIdx: (0, pg_core_1.index)(`${indexPrefix}_entities_type_idx`).on(table.entity_type),
66
64
  }));
67
65
  }
@@ -70,13 +68,16 @@ function createEntitiesTablePublic(indexPrefix) {
70
68
  // ========================================
71
69
  /**
72
70
  * Create an entity_members table for a specific PostgreSQL schema.
71
+ * This table manages all user-entity relationships including ownership.
72
+ * Role can be: owner, admin, manager, viewer
73
73
  */
74
74
  function createEntityMembersTable(schema, indexPrefix) {
75
75
  return schema.table('entity_members', {
76
76
  id: (0, pg_core_1.uuid)('id').primaryKey().defaultRandom(),
77
77
  entity_id: (0, pg_core_1.uuid)('entity_id').notNull(),
78
- user_id: (0, pg_core_1.uuid)('user_id').notNull(),
78
+ user_id: (0, pg_core_1.varchar)('user_id', { length: 128 }).notNull(), // firebase_uid
79
79
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
80
+ is_active: (0, pg_core_1.boolean)('is_active').notNull().default(true),
80
81
  joined_at: (0, pg_core_1.timestamp)('joined_at', { withTimezone: true }).defaultNow(),
81
82
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
82
83
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
@@ -84,17 +85,21 @@ function createEntityMembersTable(schema, indexPrefix) {
84
85
  entityUserUniqueIdx: (0, pg_core_1.uniqueIndex)(`${indexPrefix}_entity_members_entity_user_idx`).on(table.entity_id, table.user_id),
85
86
  entityIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_entity_idx`).on(table.entity_id),
86
87
  userIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_user_idx`).on(table.user_id),
88
+ activeIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_active_idx`).on(table.is_active),
87
89
  }));
88
90
  }
89
91
  /**
90
92
  * Create an entity_members table for the public schema.
93
+ * This table manages all user-entity relationships including ownership.
94
+ * Role can be: owner, admin, manager, viewer
91
95
  */
92
96
  function createEntityMembersTablePublic(indexPrefix) {
93
97
  return (0, pg_core_1.pgTable)('entity_members', {
94
98
  id: (0, pg_core_1.uuid)('id').primaryKey().defaultRandom(),
95
99
  entity_id: (0, pg_core_1.uuid)('entity_id').notNull(),
96
- user_id: (0, pg_core_1.uuid)('user_id').notNull(),
100
+ user_id: (0, pg_core_1.varchar)('user_id', { length: 128 }).notNull(), // firebase_uid
97
101
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
102
+ is_active: (0, pg_core_1.boolean)('is_active').notNull().default(true),
98
103
  joined_at: (0, pg_core_1.timestamp)('joined_at', { withTimezone: true }).defaultNow(),
99
104
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
100
105
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
@@ -102,6 +107,7 @@ function createEntityMembersTablePublic(indexPrefix) {
102
107
  entityUserUniqueIdx: (0, pg_core_1.uniqueIndex)(`${indexPrefix}_entity_members_entity_user_idx`).on(table.entity_id, table.user_id),
103
108
  entityIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_entity_idx`).on(table.entity_id),
104
109
  userIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_user_idx`).on(table.user_id),
110
+ activeIdx: (0, pg_core_1.index)(`${indexPrefix}_entity_members_active_idx`).on(table.is_active),
105
111
  }));
106
112
  }
107
113
  // ========================================
@@ -117,7 +123,7 @@ function createEntityInvitationsTable(schema, indexPrefix) {
117
123
  email: (0, pg_core_1.varchar)('email', { length: 255 }).notNull(),
118
124
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
119
125
  status: (0, pg_core_1.varchar)('status', { length: 20 }).notNull().default('pending'),
120
- invited_by_user_id: (0, pg_core_1.uuid)('invited_by_user_id').notNull(),
126
+ invited_by_user_id: (0, pg_core_1.varchar)('invited_by_user_id', { length: 128 }).notNull(), // firebase_uid
121
127
  token: (0, pg_core_1.varchar)('token', { length: 64 }).notNull().unique(),
122
128
  expires_at: (0, pg_core_1.timestamp)('expires_at', { withTimezone: true }).notNull(),
123
129
  accepted_at: (0, pg_core_1.timestamp)('accepted_at', { withTimezone: true }),
@@ -140,7 +146,7 @@ function createEntityInvitationsTablePublic(indexPrefix) {
140
146
  email: (0, pg_core_1.varchar)('email', { length: 255 }).notNull(),
141
147
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
142
148
  status: (0, pg_core_1.varchar)('status', { length: 20 }).notNull().default('pending'),
143
- invited_by_user_id: (0, pg_core_1.uuid)('invited_by_user_id').notNull(),
149
+ invited_by_user_id: (0, pg_core_1.varchar)('invited_by_user_id', { length: 128 }).notNull(), // firebase_uid
144
150
  token: (0, pg_core_1.varchar)('token', { length: 64 }).notNull().unique(),
145
151
  expires_at: (0, pg_core_1.timestamp)('expires_at', { withTimezone: true }).notNull(),
146
152
  accepted_at: (0, pg_core_1.timestamp)('accepted_at', { withTimezone: true }),
@@ -164,20 +170,19 @@ exports.entities = (0, pg_core_1.pgTable)('entities', {
164
170
  display_name: (0, pg_core_1.varchar)('display_name', { length: 255 }).notNull(),
165
171
  description: (0, pg_core_1.text)('description'),
166
172
  avatar_url: (0, pg_core_1.text)('avatar_url'),
167
- owner_user_id: (0, pg_core_1.uuid)('owner_user_id').notNull(),
168
173
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
169
174
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
170
175
  }, (table) => ({
171
176
  slugIdx: (0, pg_core_1.uniqueIndex)('entities_slug_idx').on(table.entity_slug),
172
- ownerIdx: (0, pg_core_1.index)('entities_owner_idx').on(table.owner_user_id),
173
177
  typeIdx: (0, pg_core_1.index)('entities_type_idx').on(table.entity_type),
174
178
  }));
175
179
  /** Default entity_members table for public schema */
176
180
  exports.entityMembers = (0, pg_core_1.pgTable)('entity_members', {
177
181
  id: (0, pg_core_1.uuid)('id').primaryKey().defaultRandom(),
178
182
  entity_id: (0, pg_core_1.uuid)('entity_id').notNull(),
179
- user_id: (0, pg_core_1.uuid)('user_id').notNull(),
183
+ user_id: (0, pg_core_1.varchar)('user_id', { length: 128 }).notNull(), // firebase_uid
180
184
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
185
+ is_active: (0, pg_core_1.boolean)('is_active').notNull().default(true),
181
186
  joined_at: (0, pg_core_1.timestamp)('joined_at', { withTimezone: true }).defaultNow(),
182
187
  created_at: (0, pg_core_1.timestamp)('created_at', { withTimezone: true }).defaultNow(),
183
188
  updated_at: (0, pg_core_1.timestamp)('updated_at', { withTimezone: true }).defaultNow(),
@@ -185,6 +190,7 @@ exports.entityMembers = (0, pg_core_1.pgTable)('entity_members', {
185
190
  entityUserUniqueIdx: (0, pg_core_1.uniqueIndex)('entity_members_entity_user_idx').on(table.entity_id, table.user_id),
186
191
  entityIdx: (0, pg_core_1.index)('entity_members_entity_idx').on(table.entity_id),
187
192
  userIdx: (0, pg_core_1.index)('entity_members_user_idx').on(table.user_id),
193
+ activeIdx: (0, pg_core_1.index)('entity_members_active_idx').on(table.is_active),
188
194
  }));
189
195
  /** Default entity_invitations table for public schema */
190
196
  exports.entityInvitations = (0, pg_core_1.pgTable)('entity_invitations', {
@@ -193,7 +199,7 @@ exports.entityInvitations = (0, pg_core_1.pgTable)('entity_invitations', {
193
199
  email: (0, pg_core_1.varchar)('email', { length: 255 }).notNull(),
194
200
  role: (0, pg_core_1.varchar)('role', { length: 20 }).notNull(),
195
201
  status: (0, pg_core_1.varchar)('status', { length: 20 }).notNull().default('pending'),
196
- invited_by_user_id: (0, pg_core_1.uuid)('invited_by_user_id').notNull(),
202
+ invited_by_user_id: (0, pg_core_1.varchar)('invited_by_user_id', { length: 128 }).notNull(), // firebase_uid
197
203
  token: (0, pg_core_1.varchar)('token', { length: 64 }).notNull().unique(),
198
204
  expires_at: (0, pg_core_1.timestamp)('expires_at', { withTimezone: true }).notNull(),
199
205
  accepted_at: (0, pg_core_1.timestamp)('accepted_at', { withTimezone: true }),
@@ -210,6 +216,7 @@ exports.entityInvitations = (0, pg_core_1.pgTable)('entity_invitations', {
210
216
  // ========================================
211
217
  /**
212
218
  * Initialize all entity tables in the database.
219
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
213
220
  *
214
221
  * @param client - postgres-js client instance
215
222
  * @param schemaName - PostgreSQL schema name (null for public)
@@ -217,7 +224,7 @@ exports.entityInvitations = (0, pg_core_1.pgTable)('entity_invitations', {
217
224
  */
218
225
  async function initEntityTables(client, schemaName, indexPrefix) {
219
226
  const prefix = schemaName ? `${schemaName}.` : '';
220
- // Create entities table
227
+ // Create entities table (ownership tracked via entity_members)
221
228
  await client.unsafe(`
222
229
  CREATE TABLE IF NOT EXISTS ${prefix}entities (
223
230
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@@ -226,7 +233,6 @@ async function initEntityTables(client, schemaName, indexPrefix) {
226
233
  display_name VARCHAR(255) NOT NULL,
227
234
  description TEXT,
228
235
  avatar_url TEXT,
229
- owner_user_id UUID NOT NULL,
230
236
  created_at TIMESTAMPTZ DEFAULT NOW(),
231
237
  updated_at TIMESTAMPTZ DEFAULT NOW()
232
238
  )
@@ -234,22 +240,19 @@ async function initEntityTables(client, schemaName, indexPrefix) {
234
240
  await client.unsafe(`
235
241
  CREATE UNIQUE INDEX IF NOT EXISTS ${indexPrefix}_entities_slug_idx
236
242
  ON ${prefix}entities (entity_slug)
237
- `);
238
- await client.unsafe(`
239
- CREATE INDEX IF NOT EXISTS ${indexPrefix}_entities_owner_idx
240
- ON ${prefix}entities (owner_user_id)
241
243
  `);
242
244
  await client.unsafe(`
243
245
  CREATE INDEX IF NOT EXISTS ${indexPrefix}_entities_type_idx
244
246
  ON ${prefix}entities (entity_type)
245
247
  `);
246
- // Create entity_members table
248
+ // Create entity_members table (tracks all user-entity relationships including ownership)
247
249
  await client.unsafe(`
248
250
  CREATE TABLE IF NOT EXISTS ${prefix}entity_members (
249
251
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
250
252
  entity_id UUID NOT NULL REFERENCES ${prefix}entities(id) ON DELETE CASCADE,
251
- user_id UUID NOT NULL,
252
- role VARCHAR(20) NOT NULL CHECK (role IN ('admin', 'manager', 'viewer')),
253
+ user_id VARCHAR(128) NOT NULL,
254
+ role VARCHAR(20) NOT NULL CHECK (role IN ('owner', 'admin', 'member')),
255
+ is_active BOOLEAN NOT NULL DEFAULT true,
253
256
  joined_at TIMESTAMPTZ DEFAULT NOW(),
254
257
  created_at TIMESTAMPTZ DEFAULT NOW(),
255
258
  updated_at TIMESTAMPTZ DEFAULT NOW(),
@@ -267,6 +270,10 @@ async function initEntityTables(client, schemaName, indexPrefix) {
267
270
  await client.unsafe(`
268
271
  CREATE INDEX IF NOT EXISTS ${indexPrefix}_entity_members_user_idx
269
272
  ON ${prefix}entity_members (user_id)
273
+ `);
274
+ await client.unsafe(`
275
+ CREATE INDEX IF NOT EXISTS ${indexPrefix}_entity_members_active_idx
276
+ ON ${prefix}entity_members (is_active)
270
277
  `);
271
278
  // Create entity_invitations table
272
279
  await client.unsafe(`
@@ -274,9 +281,9 @@ async function initEntityTables(client, schemaName, indexPrefix) {
274
281
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
275
282
  entity_id UUID NOT NULL REFERENCES ${prefix}entities(id) ON DELETE CASCADE,
276
283
  email VARCHAR(255) NOT NULL,
277
- role VARCHAR(20) NOT NULL CHECK (role IN ('admin', 'manager', 'viewer')),
284
+ role VARCHAR(20) NOT NULL CHECK (role IN ('admin', 'member')),
278
285
  status VARCHAR(20) NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'accepted', 'declined', 'expired')),
279
- invited_by_user_id UUID NOT NULL,
286
+ invited_by_user_id VARCHAR(128) NOT NULL,
280
287
  token VARCHAR(64) NOT NULL UNIQUE,
281
288
  expires_at TIMESTAMPTZ NOT NULL,
282
289
  accepted_at TIMESTAMPTZ,
@@ -9,6 +9,7 @@
9
9
  */
10
10
  /**
11
11
  * Create an entities table for a specific PostgreSQL schema.
12
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
12
13
  *
13
14
  * @param schema - The Drizzle pgSchema object
14
15
  * @param indexPrefix - Prefix for index names to avoid conflicts
@@ -17,6 +18,7 @@
17
18
  export declare function createEntitiesTable(schema: any, indexPrefix: string): any;
18
19
  /**
19
20
  * Create an entities table for the public schema.
21
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
20
22
  */
21
23
  export declare function createEntitiesTablePublic(indexPrefix: string): import("drizzle-orm/pg-core").PgTableWithColumns<{
22
24
  name: "entities";
@@ -130,23 +132,6 @@ export declare function createEntitiesTablePublic(indexPrefix: string): import("
130
132
  identity: undefined;
131
133
  generated: undefined;
132
134
  }, {}, {}>;
133
- owner_user_id: import("drizzle-orm/pg-core").PgColumn<{
134
- name: "owner_user_id";
135
- tableName: "entities";
136
- dataType: "string";
137
- columnType: "PgUUID";
138
- data: string;
139
- driverParam: string;
140
- notNull: true;
141
- hasDefault: false;
142
- isPrimaryKey: false;
143
- isAutoincrement: false;
144
- hasRuntimeDefault: false;
145
- enumValues: undefined;
146
- baseColumn: never;
147
- identity: undefined;
148
- generated: undefined;
149
- }, {}, {}>;
150
135
  created_at: import("drizzle-orm/pg-core").PgColumn<{
151
136
  name: "created_at";
152
137
  tableName: "entities";
@@ -186,10 +171,14 @@ export declare function createEntitiesTablePublic(indexPrefix: string): import("
186
171
  }>;
187
172
  /**
188
173
  * Create an entity_members table for a specific PostgreSQL schema.
174
+ * This table manages all user-entity relationships including ownership.
175
+ * Role can be: owner, admin, manager, viewer
189
176
  */
190
177
  export declare function createEntityMembersTable(schema: any, indexPrefix: string): any;
191
178
  /**
192
179
  * Create an entity_members table for the public schema.
180
+ * This table manages all user-entity relationships including ownership.
181
+ * Role can be: owner, admin, manager, viewer
193
182
  */
194
183
  export declare function createEntityMembersTablePublic(indexPrefix: string): import("drizzle-orm/pg-core").PgTableWithColumns<{
195
184
  name: "entity_members";
@@ -233,7 +222,7 @@ export declare function createEntityMembersTablePublic(indexPrefix: string): imp
233
222
  name: "user_id";
234
223
  tableName: "entity_members";
235
224
  dataType: "string";
236
- columnType: "PgUUID";
225
+ columnType: "PgVarchar";
237
226
  data: string;
238
227
  driverParam: string;
239
228
  notNull: true;
@@ -241,11 +230,13 @@ export declare function createEntityMembersTablePublic(indexPrefix: string): imp
241
230
  isPrimaryKey: false;
242
231
  isAutoincrement: false;
243
232
  hasRuntimeDefault: false;
244
- enumValues: undefined;
233
+ enumValues: [string, ...string[]];
245
234
  baseColumn: never;
246
235
  identity: undefined;
247
236
  generated: undefined;
248
- }, {}, {}>;
237
+ }, {}, {
238
+ length: 128;
239
+ }>;
249
240
  role: import("drizzle-orm/pg-core").PgColumn<{
250
241
  name: "role";
251
242
  tableName: "entity_members";
@@ -265,6 +256,23 @@ export declare function createEntityMembersTablePublic(indexPrefix: string): imp
265
256
  }, {}, {
266
257
  length: 20;
267
258
  }>;
259
+ is_active: import("drizzle-orm/pg-core").PgColumn<{
260
+ name: "is_active";
261
+ tableName: "entity_members";
262
+ dataType: "boolean";
263
+ columnType: "PgBoolean";
264
+ data: boolean;
265
+ driverParam: boolean;
266
+ notNull: true;
267
+ hasDefault: true;
268
+ isPrimaryKey: false;
269
+ isAutoincrement: false;
270
+ hasRuntimeDefault: false;
271
+ enumValues: undefined;
272
+ baseColumn: never;
273
+ identity: undefined;
274
+ generated: undefined;
275
+ }, {}, {}>;
268
276
  joined_at: import("drizzle-orm/pg-core").PgColumn<{
269
277
  name: "joined_at";
270
278
  tableName: "entity_members";
@@ -425,7 +433,7 @@ export declare function createEntityInvitationsTablePublic(indexPrefix: string):
425
433
  name: "invited_by_user_id";
426
434
  tableName: "entity_invitations";
427
435
  dataType: "string";
428
- columnType: "PgUUID";
436
+ columnType: "PgVarchar";
429
437
  data: string;
430
438
  driverParam: string;
431
439
  notNull: true;
@@ -433,11 +441,13 @@ export declare function createEntityInvitationsTablePublic(indexPrefix: string):
433
441
  isPrimaryKey: false;
434
442
  isAutoincrement: false;
435
443
  hasRuntimeDefault: false;
436
- enumValues: undefined;
444
+ enumValues: [string, ...string[]];
437
445
  baseColumn: never;
438
446
  identity: undefined;
439
447
  generated: undefined;
440
- }, {}, {}>;
448
+ }, {}, {
449
+ length: 128;
450
+ }>;
441
451
  token: import("drizzle-orm/pg-core").PgColumn<{
442
452
  name: "token";
443
453
  tableName: "entity_invitations";
@@ -641,23 +651,6 @@ export declare const entities: import("drizzle-orm/pg-core").PgTableWithColumns<
641
651
  identity: undefined;
642
652
  generated: undefined;
643
653
  }, {}, {}>;
644
- owner_user_id: import("drizzle-orm/pg-core").PgColumn<{
645
- name: "owner_user_id";
646
- tableName: "entities";
647
- dataType: "string";
648
- columnType: "PgUUID";
649
- data: string;
650
- driverParam: string;
651
- notNull: true;
652
- hasDefault: false;
653
- isPrimaryKey: false;
654
- isAutoincrement: false;
655
- hasRuntimeDefault: false;
656
- enumValues: undefined;
657
- baseColumn: never;
658
- identity: undefined;
659
- generated: undefined;
660
- }, {}, {}>;
661
654
  created_at: import("drizzle-orm/pg-core").PgColumn<{
662
655
  name: "created_at";
663
656
  tableName: "entities";
@@ -738,7 +731,7 @@ export declare const entityMembers: import("drizzle-orm/pg-core").PgTableWithCol
738
731
  name: "user_id";
739
732
  tableName: "entity_members";
740
733
  dataType: "string";
741
- columnType: "PgUUID";
734
+ columnType: "PgVarchar";
742
735
  data: string;
743
736
  driverParam: string;
744
737
  notNull: true;
@@ -746,11 +739,13 @@ export declare const entityMembers: import("drizzle-orm/pg-core").PgTableWithCol
746
739
  isPrimaryKey: false;
747
740
  isAutoincrement: false;
748
741
  hasRuntimeDefault: false;
749
- enumValues: undefined;
742
+ enumValues: [string, ...string[]];
750
743
  baseColumn: never;
751
744
  identity: undefined;
752
745
  generated: undefined;
753
- }, {}, {}>;
746
+ }, {}, {
747
+ length: 128;
748
+ }>;
754
749
  role: import("drizzle-orm/pg-core").PgColumn<{
755
750
  name: "role";
756
751
  tableName: "entity_members";
@@ -770,6 +765,23 @@ export declare const entityMembers: import("drizzle-orm/pg-core").PgTableWithCol
770
765
  }, {}, {
771
766
  length: 20;
772
767
  }>;
768
+ is_active: import("drizzle-orm/pg-core").PgColumn<{
769
+ name: "is_active";
770
+ tableName: "entity_members";
771
+ dataType: "boolean";
772
+ columnType: "PgBoolean";
773
+ data: boolean;
774
+ driverParam: boolean;
775
+ notNull: true;
776
+ hasDefault: true;
777
+ isPrimaryKey: false;
778
+ isAutoincrement: false;
779
+ hasRuntimeDefault: false;
780
+ enumValues: undefined;
781
+ baseColumn: never;
782
+ identity: undefined;
783
+ generated: undefined;
784
+ }, {}, {}>;
773
785
  joined_at: import("drizzle-orm/pg-core").PgColumn<{
774
786
  name: "joined_at";
775
787
  tableName: "entity_members";
@@ -924,7 +936,7 @@ export declare const entityInvitations: import("drizzle-orm/pg-core").PgTableWit
924
936
  name: "invited_by_user_id";
925
937
  tableName: "entity_invitations";
926
938
  dataType: "string";
927
- columnType: "PgUUID";
939
+ columnType: "PgVarchar";
928
940
  data: string;
929
941
  driverParam: string;
930
942
  notNull: true;
@@ -932,11 +944,13 @@ export declare const entityInvitations: import("drizzle-orm/pg-core").PgTableWit
932
944
  isPrimaryKey: false;
933
945
  isAutoincrement: false;
934
946
  hasRuntimeDefault: false;
935
- enumValues: undefined;
947
+ enumValues: [string, ...string[]];
936
948
  baseColumn: never;
937
949
  identity: undefined;
938
950
  generated: undefined;
939
- }, {}, {}>;
951
+ }, {}, {
952
+ length: 128;
953
+ }>;
940
954
  token: import("drizzle-orm/pg-core").PgColumn<{
941
955
  name: "token";
942
956
  tableName: "entity_invitations";
@@ -1038,6 +1052,7 @@ export type EntityInvitationRecord = typeof entityInvitations.$inferSelect;
1038
1052
  export type NewEntityInvitationRecord = typeof entityInvitations.$inferInsert;
1039
1053
  /**
1040
1054
  * Initialize all entity tables in the database.
1055
+ * Note: Ownership is tracked via entity_members table (role = 'owner').
1041
1056
  *
1042
1057
  * @param client - postgres-js client instance
1043
1058
  * @param schemaName - PostgreSQL schema name (null for public)
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/schema/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,OAwBnE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwB5D;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,OAsBxE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBjE;AAMD;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,OA+B5E;AAED;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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