@rio.js/enterprise 1.4.3 → 1.4.5

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.
@@ -1,18 +1,18 @@
1
- import { $ as teamRole, A as oauthAccessTokenRelations, B as organizationRoleRelations, C as memberAssetRoleRelations, D as memberTeamRole, E as memberRelations, F as object, G as schemaDefinition, H as platformRole, I as objectRelations, J as sessionRelations, K as schemaDefinitionRelations, L as organization$1, M as oauthApplicationRelations, N as oauthConsent, O as memberTeamRoleRelations, P as oauthConsentRelations, Q as teamRelations, R as organizationRelations, S as memberAssetRole, T as memberOrganizationRoleRelations, U as relationship, V as person, W as relationshipRelations, X as teamMember, Y as team, Z as teamMemberRelations, _ as assetType, a as agent, at as verification, b as invitationRelations, c as apikeyRelations, d as assetRole, et as teamRoleRelations, f as assetRoleRelations, g as assetShareRelations, h as assetShareLinkRelations, i as accountRelations, it as userRelations, j as oauthApplication, k as oauthAccessToken, l as asset, m as assetShareLink, n as db, nt as twoFactorRelations, o as agentRelations, ot as enterpriseSchema, p as assetShare, q as session, r as account, rt as user, s as apikey, st as __export, tt as twoFactor$1, u as assetRelations, v as assetTypeRelations, w as memberOrganizationRole, x as member, y as invitation, z as organizationRole } from "./db-Bd2Dgk3D.mjs";
1
+ import { $ as teamRoleRelations, A as oauthApplication, B as person, C as memberOrganizationRole, D as memberTeamRoleRelations, E as memberTeamRole, F as objectRelations, G as schemaDefinitionRelations, H as relationship, I as organization$1, J as team, K as session, L as organizationRelations, M as oauthConsent, N as oauthConsentRelations, O as oauthAccessToken, P as object, Q as teamRole, R as organizationRole, S as memberAssetRoleRelations, T as memberRelations, U as relationshipRelations, V as platformRole, W as schemaDefinition, X as teamMemberRelations, Y as teamMember, Z as teamRelations, a as apikey, at as enterpriseSchema, b as member, c as assetRelations, d as assetShare, et as twoFactor$1, f as assetShareLink, g as assetTypeRelations, h as assetType, i as agentRelations, it as verification, j as oauthApplicationRelations, k as oauthAccessTokenRelations, l as assetRole, m as assetShareRelations, n as accountRelations, nt as user, o as apikeyRelations, ot as __export, p as assetShareLinkRelations, q as sessionRelations, r as agent, rt as userRelations, s as asset, t as account, tt as twoFactorRelations, u as assetRoleRelations, v as invitation, w as memberOrganizationRoleRelations, x as memberAssetRole, y as invitationRelations, z as organizationRoleRelations } from "./db-schema.generated-D2dEC1DO.mjs";
2
2
  import { G as getCurrentTransactionAdapter, W as getCurrentGraphContext } from "./json-oFuWgANh-CZSe35mm.mjs";
3
3
  import { f as logger, g as BetterAuthError, v as invariant } from "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
- import { A as apiKey, E as admin, K as graph, R as lastLoginMethod, U as organization, a as openAPI, it as APIError$1, j as assets, k as agents, rt as twoFactor, z as mcp } from "./plugins-C_-kHHzW.mjs";
5
- import { t as betterAuth } from "./dist-DGeBMuXr.mjs";
4
+ import { A as apiKey, E as admin, K as graph, R as lastLoginMethod, U as organization, a as openAPI, it as APIError$1, j as assets, k as agents, rt as twoFactor, z as mcp } from "./plugins-4UnCRez7.mjs";
5
+ import { t as betterAuth } from "./dist-Dt0ifDbX.mjs";
6
6
  import { t as createAdapterFactory } from "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
7
7
  import { and, asc, count, desc, eq, gt, gte, inArray, like, lt, lte, ne, notInArray, or, sql } from "drizzle-orm";
8
8
  import cuid from "cuid";
9
9
 
10
10
  //#region ../better-auth/dist/adapters/drizzle-adapter/index.mjs
11
- const drizzleAdapter = (db$1, config) => {
11
+ const drizzleAdapter = (db, config) => {
12
12
  let lazyOptions = null;
13
- const createCustomAdapter = (db$1$1) => ({ getFieldName, options }) => {
13
+ const createCustomAdapter = (db$1) => ({ getFieldName, options }) => {
14
14
  function getSchema(model) {
15
- const schema = config.schema || db$1$1._.fullSchema;
15
+ const schema = config.schema || db$1._.fullSchema;
16
16
  if (!schema) throw new BetterAuthError("Drizzle adapter failed to initialize. Schema not found. Please provide a schema object in the adapter options object.");
17
17
  const schemaModel = schema[model];
18
18
  if (!schemaModel) throw new BetterAuthError(`[# Drizzle Adapter]: The model "${model}" was not found in the schema object. Please pass the schema directly to the adapter options.`);
@@ -31,15 +31,15 @@ const drizzleAdapter = (db$1, config) => {
31
31
  };
32
32
  return w;
33
33
  }), model);
34
- return (await db$1$1.select().from(schemaModel).where(...clause))[0];
34
+ return (await db$1.select().from(schemaModel).where(...clause))[0];
35
35
  } else if (builderVal && builderVal[0]?.id?.value) {
36
36
  let tId = builderVal[0]?.id?.value;
37
- if (!tId) tId = (await db$1$1.select({ id: sql`LAST_INSERT_ID()` }).from(schemaModel).orderBy(desc(schemaModel.id)).limit(1))[0].id;
38
- return (await db$1$1.select().from(schemaModel).where(eq(schemaModel.id, tId)).limit(1).execute())[0];
39
- } else if (data.id) return (await db$1$1.select().from(schemaModel).where(eq(schemaModel.id, data.id)).limit(1).execute())[0];
37
+ if (!tId) tId = (await db$1.select({ id: sql`LAST_INSERT_ID()` }).from(schemaModel).orderBy(desc(schemaModel.id)).limit(1))[0].id;
38
+ return (await db$1.select().from(schemaModel).where(eq(schemaModel.id, tId)).limit(1).execute())[0];
39
+ } else if (data.id) return (await db$1.select().from(schemaModel).where(eq(schemaModel.id, data.id)).limit(1).execute())[0];
40
40
  else {
41
41
  if (!("id" in schemaModel)) throw new BetterAuthError(`The model "${model}" does not have an "id" field. Please use the "id" field as your primary key.`);
42
- return (await db$1$1.select().from(schemaModel).orderBy(desc(schemaModel.id)).limit(1).execute())[0];
42
+ return (await db$1.select().from(schemaModel).orderBy(desc(schemaModel.id)).limit(1).execute())[0];
43
43
  }
44
44
  };
45
45
  function convertWhereClause(where, model) {
@@ -132,20 +132,20 @@ const drizzleAdapter = (db$1, config) => {
132
132
  async create({ model, data: values }) {
133
133
  const schemaModel = getSchema(model);
134
134
  checkMissingFields(schemaModel, model, values);
135
- return await withReturning(model, db$1$1.insert(schemaModel).values(values), values);
135
+ return await withReturning(model, db$1.insert(schemaModel).values(values), values);
136
136
  },
137
137
  async createMany({ model, data: rows }) {
138
138
  const schemaModel = getSchema(model);
139
139
  rows.forEach((row) => {
140
140
  checkMissingFields(schemaModel, model, row);
141
141
  });
142
- await db$1$1.insert(schemaModel).values(rows).execute();
142
+ await db$1.insert(schemaModel).values(rows).execute();
143
143
  return rows;
144
144
  },
145
145
  async findOne({ model, where, join }) {
146
146
  const schemaModel = getSchema(model);
147
147
  const clause = convertWhereClause(where, model);
148
- if (options.experimental?.joins) if (!db$1$1.query || !db$1$1.query[model]) {
148
+ if (options.experimental?.joins) if (!db$1.query || !db$1.query[model]) {
149
149
  logger.error(`[# Drizzle Adapter]: The model "${model}" was not found in the query object. Please update your Drizzle schema to include relations or re-generate using "npx @better-auth/cli@latest generate".`);
150
150
  logger.info("Falling back to regular query");
151
151
  } else {
@@ -162,7 +162,7 @@ const drizzleAdapter = (db$1, config) => {
162
162
  if (!isUnique) pluralJoinResults.push(`${model$1}${pluralSuffix}`);
163
163
  }
164
164
  }
165
- const res$1 = await db$1$1.query[model].findFirst({
165
+ const res$1 = await db$1.query[model].findFirst({
166
166
  where: clause[0],
167
167
  with: includes
168
168
  });
@@ -173,7 +173,7 @@ const drizzleAdapter = (db$1, config) => {
173
173
  }
174
174
  return res$1;
175
175
  }
176
- const res = await db$1$1.select().from(schemaModel).where(...clause);
176
+ const res = await db$1.select().from(schemaModel).where(...clause);
177
177
  if (!res.length) return null;
178
178
  return res[0];
179
179
  },
@@ -181,7 +181,7 @@ const drizzleAdapter = (db$1, config) => {
181
181
  const schemaModel = getSchema(model);
182
182
  const clause = where ? convertWhereClause(where, model) : [];
183
183
  const sortFn = sortBy?.direction === "desc" ? desc : asc;
184
- if (options.experimental?.joins) if (!db$1$1.query[model]) {
184
+ if (options.experimental?.joins) if (!db$1.query[model]) {
185
185
  logger.error(`[# Drizzle Adapter]: The model "${model}" was not found in the query object. Please update your Drizzle schema to include relations or re-generate using "npx @better-auth/cli@latest generate".`);
186
186
  logger.info("Falling back to regular query");
187
187
  } else {
@@ -203,7 +203,7 @@ const drizzleAdapter = (db$1, config) => {
203
203
  model,
204
204
  field: sortBy?.field
205
205
  })])];
206
- let res = await db$1$1.query[model].findMany({
206
+ let res = await db$1.query[model].findMany({
207
207
  where: clause[0],
208
208
  with: includes,
209
209
  limit: limit ?? 100,
@@ -218,7 +218,7 @@ const drizzleAdapter = (db$1, config) => {
218
218
  }
219
219
  return res;
220
220
  }
221
- let builder = db$1$1.select().from(schemaModel);
221
+ let builder = db$1.select().from(schemaModel);
222
222
  const effectiveLimit = limit;
223
223
  const effectiveOffset = offset;
224
224
  if (typeof effectiveLimit !== "undefined") builder = builder.limit(effectiveLimit);
@@ -232,27 +232,27 @@ const drizzleAdapter = (db$1, config) => {
232
232
  async count({ model, where }) {
233
233
  const schemaModel = getSchema(model);
234
234
  const clause = where ? convertWhereClause(where, model) : [];
235
- return (await db$1$1.select({ count: count() }).from(schemaModel).where(...clause))[0].count;
235
+ return (await db$1.select({ count: count() }).from(schemaModel).where(...clause))[0].count;
236
236
  },
237
237
  async update({ model, where, update: values }) {
238
238
  const schemaModel = getSchema(model);
239
239
  const clause = convertWhereClause(where, model);
240
- return await withReturning(model, db$1$1.update(schemaModel).set(values).where(...clause), values, where);
240
+ return await withReturning(model, db$1.update(schemaModel).set(values).where(...clause), values, where);
241
241
  },
242
242
  async updateMany({ model, where, update: values }) {
243
243
  const schemaModel = getSchema(model);
244
244
  const clause = convertWhereClause(where, model);
245
- return await db$1$1.update(schemaModel).set(values).where(...clause);
245
+ return await db$1.update(schemaModel).set(values).where(...clause);
246
246
  },
247
247
  async delete({ model, where }) {
248
248
  const schemaModel = getSchema(model);
249
249
  const clause = convertWhereClause(where, model);
250
- return await db$1$1.delete(schemaModel).where(...clause);
250
+ return await db$1.delete(schemaModel).where(...clause);
251
251
  },
252
252
  async deleteMany({ model, where }) {
253
253
  const schemaModel = getSchema(model);
254
254
  const clause = convertWhereClause(where, model);
255
- const res = await db$1$1.delete(schemaModel).where(...clause);
255
+ const res = await db$1.delete(schemaModel).where(...clause);
256
256
  let count$1 = 0;
257
257
  if (res && "rowCount" in res) count$1 = res.rowCount;
258
258
  else if (Array.isArray(res)) count$1 = res.length;
@@ -275,7 +275,7 @@ const drizzleAdapter = (db$1, config) => {
275
275
  usePlural: config.usePlural ?? false,
276
276
  debugLogs: config.debugLogs ?? false,
277
277
  supportsUUIDs: config.provider === "pg" ? true : false,
278
- transaction: config.transaction ?? false ? (cb) => db$1.transaction((tx) => {
278
+ transaction: config.transaction ?? false ? (cb) => db.transaction((tx) => {
279
279
  return cb(createAdapterFactory({
280
280
  config: {
281
281
  ...adapterOptions.config,
@@ -286,7 +286,7 @@ const drizzleAdapter = (db$1, config) => {
286
286
  })(lazyOptions));
287
287
  }) : false
288
288
  },
289
- adapter: createCustomAdapter(db$1)
289
+ adapter: createCustomAdapter(db)
290
290
  };
291
291
  const adapter = createAdapterFactory(adapterOptions);
292
292
  return (options) => {
@@ -610,7 +610,7 @@ function createAuthSystem(options) {
610
610
  });
611
611
  }
612
612
  },
613
- database: drizzleAdapter(options.db ?? db, {
613
+ database: drizzleAdapter(options.db, {
614
614
  provider: "pg",
615
615
  schema: db_schema_final_exports,
616
616
  usePlural: false,
@@ -620,7 +620,6 @@ function createAuthSystem(options) {
620
620
  graph: { enabled: true }
621
621
  });
622
622
  }
623
- const auth = createAuthSystem({});
624
623
 
625
624
  //#endregion
626
- export { createAuthSystem as n, auth as t };
625
+ export { createAuthSystem as t };
@@ -0,0 +1,10 @@
1
+ import { t as Connection } from "./db-CXaQH2-a.mjs";
2
+ import { BetterAuthPlugin, betterAuth } from "better-auth";
3
+
4
+ //#region src/better-auth.d.ts
5
+ declare function createAuthSystem(options: {
6
+ plugins?: BetterAuthPlugin[];
7
+ db: Connection;
8
+ }): ReturnType<typeof betterAuth>;
9
+ //#endregion
10
+ export { createAuthSystem as t };
@@ -1,3 +1,3 @@
1
- import "./db-D5eWeSOf.mjs";
2
- import { n as createAuthSystem, t as auth } from "./better-auth-RunrSBmw.mjs";
3
- export { auth, createAuthSystem };
1
+ import "./db-CXaQH2-a.mjs";
2
+ import { t as createAuthSystem } from "./better-auth-DNCc730p.mjs";
3
+ export { createAuthSystem };
@@ -1,17 +1,17 @@
1
- import "./db-Bd2Dgk3D.mjs";
1
+ import "./db-schema.generated-D2dEC1DO.mjs";
2
2
  import "./json-oFuWgANh-CZSe35mm.mjs";
3
3
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
4
  import "./verify-BmFXks5a.mjs";
5
5
  import "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
6
- import "./plugins-C_-kHHzW.mjs";
6
+ import "./plugins-4UnCRez7.mjs";
7
7
  import "./esm-UlqE2SXT.mjs";
8
- import "./dialect-C6_pK3V9-CnxpsNGP.mjs";
8
+ import "./dialect-C6_pK3V9-CwYiGC9t.mjs";
9
9
  import "./dist-BidhxJQx.mjs";
10
10
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import "./dist-DGeBMuXr.mjs";
13
+ import "./dist-Dt0ifDbX.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { n as createAuthSystem, t as auth } from "./better-auth-C0GYWCr8.mjs";
15
+ import { t as createAuthSystem } from "./better-auth-BPBF8tkn.mjs";
16
16
 
17
- export { auth, createAuthSystem };
17
+ export { createAuthSystem };
package/dist/client.mjs CHANGED
@@ -3,7 +3,7 @@ import "./dist-BidhxJQx.mjs";
3
3
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
4
4
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
5
5
  import { i as hasPermission, n as adminAc, o as userAc, t as twoFactorClient } from "./client--1_AEBPu-Dl2Y0Yen.mjs";
6
- import { i as useAuthQuery, n as createAuthClient } from "./react-BZlUztTq.mjs";
6
+ import { i as useAuthQuery, n as createAuthClient } from "./react-DkVozQEM.mjs";
7
7
  import { atom } from "nanostores";
8
8
 
9
9
  //#region ../better-auth/dist/client/plugins/index.mjs
@@ -0,0 +1,15 @@
1
+ import { _ as db_schema_generated_exports, ot as __export, st as __reExport } from "./db-schema.generated-D2dEC1DO.mjs";
2
+ import { drizzle } from "drizzle-orm/node-postgres";
3
+
4
+ //#region src/db.ts
5
+ var db_exports = /* @__PURE__ */ __export({
6
+ connection: () => connection,
7
+ schema: () => schema
8
+ });
9
+ import * as import_drizzle_orm_node_postgres from "drizzle-orm/node-postgres";
10
+ __reExport(db_exports, import_drizzle_orm_node_postgres);
11
+ const schema = { ...db_schema_generated_exports };
12
+ const connection = (url) => drizzle(url + "?options=-c search_path=enterprise", { schema });
13
+
14
+ //#endregion
15
+ export { db_exports as n, schema as r, connection as t };
@@ -4,7 +4,7 @@ import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
4
4
  import * as pg0 from "pg";
5
5
 
6
6
  //#region src/db.d.ts
7
- declare const databaseSchema: {
7
+ declare const schema: {
8
8
  user: drizzle_orm_pg_core0.PgTableWithColumns<{
9
9
  name: "user";
10
10
  schema: "enterprise";
@@ -4770,7 +4770,7 @@ declare const databaseSchema: {
4770
4770
  user: drizzle_orm0.One<"user", false>;
4771
4771
  }>;
4772
4772
  };
4773
- declare const db: drizzle_orm_node_postgres0.NodePgDatabase<{
4773
+ declare const connection: (url: string) => drizzle_orm_node_postgres0.NodePgDatabase<{
4774
4774
  user: drizzle_orm_pg_core0.PgTableWithColumns<{
4775
4775
  name: "user";
4776
4776
  schema: "enterprise";
@@ -9538,5 +9538,6 @@ declare const db: drizzle_orm_node_postgres0.NodePgDatabase<{
9538
9538
  }> & {
9539
9539
  $client: pg0.Pool;
9540
9540
  };
9541
+ type Connection = ReturnType<typeof connection>;
9541
9542
  //#endregion
9542
- export { db as n, databaseSchema as t };
9543
+ export { connection as n, schema as r, Connection as t };
@@ -1,9 +1,11 @@
1
- import { createRequire } from "node:module";
2
1
  import { relations } from "drizzle-orm";
3
2
  import { boolean, index, integer, jsonb, pgSchema, text, timestamp } from "drizzle-orm/pg-core";
4
3
 
5
4
  //#region rolldown:runtime
6
5
  var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (all, symbols) => {
8
10
  let target = {};
9
11
  for (var name in all) {
@@ -17,7 +19,27 @@ var __export = (all, symbols) => {
17
19
  }
18
20
  return target;
19
21
  };
20
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
22
+ var __copyProps = (to, from, except, desc$1) => {
23
+ if (from && typeof from === "object" || typeof from === "function") {
24
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
+ key = keys[i];
26
+ if (!__hasOwnProp.call(to, key) && key !== except) {
27
+ __defProp(to, key, {
28
+ get: ((k) => from[k]).bind(null, key),
29
+ enumerable: !(desc$1 = __getOwnPropDesc(from, key)) || desc$1.enumerable
30
+ });
31
+ }
32
+ }
33
+ }
34
+ return to;
35
+ };
36
+ var __reExport = (target, mod, secondTarget, symbols) => {
37
+ if (symbols) {
38
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
39
+ secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
40
+ }
41
+ __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
42
+ };
21
43
 
22
44
  //#endregion
23
45
  //#region src/db-schema.default.ts
@@ -669,13 +691,4 @@ const schemaDefinitionRelations = relations(schemaDefinition, ({ one }) => ({ us
669
691
  }) }));
670
692
 
671
693
  //#endregion
672
- //#region src/db.ts
673
- const schema = { ...db_schema_generated_exports };
674
- const databaseSchema = schema;
675
- let drizzle;
676
- if (process.env.BUN) drizzle = __require("drizzle-orm/bun-sql").drizzle;
677
- else drizzle = __require("drizzle-orm/node-postgres").drizzle;
678
- const db = drizzle(process.env.DATABASE_URL + "?options=-c search_path=enterprise", { schema });
679
-
680
- //#endregion
681
- export { teamRole as $, oauthAccessTokenRelations as A, organizationRoleRelations as B, memberAssetRoleRelations as C, memberTeamRole as D, memberRelations as E, object as F, schemaDefinition as G, platformRole as H, objectRelations as I, sessionRelations as J, schemaDefinitionRelations as K, organization as L, oauthApplicationRelations as M, oauthConsent as N, memberTeamRoleRelations as O, oauthConsentRelations as P, teamRelations as Q, organizationRelations as R, memberAssetRole as S, memberOrganizationRoleRelations as T, relationship as U, person as V, relationshipRelations as W, teamMember as X, team as Y, teamMemberRelations as Z, assetType as _, agent as a, verification as at, invitationRelations as b, apikeyRelations as c, assetRole as d, teamRoleRelations as et, assetRoleRelations as f, assetShareRelations as g, assetShareLinkRelations as h, accountRelations as i, userRelations as it, oauthApplication as j, oauthAccessToken as k, asset as l, assetShareLink as m, db as n, twoFactorRelations as nt, agentRelations as o, enterpriseSchema as ot, assetShare as p, session as q, account as r, user as rt, apikey as s, __export as st, databaseSchema as t, twoFactor as tt, assetRelations as u, assetTypeRelations as v, memberOrganizationRole as w, member as x, invitation as y, organizationRole as z };
694
+ export { teamRoleRelations as $, oauthApplication as A, person as B, memberOrganizationRole as C, memberTeamRoleRelations as D, memberTeamRole as E, objectRelations as F, schemaDefinitionRelations as G, relationship as H, organization as I, team as J, session as K, organizationRelations as L, oauthConsent as M, oauthConsentRelations as N, oauthAccessToken as O, object as P, teamRole as Q, organizationRole as R, memberAssetRoleRelations as S, memberRelations as T, relationshipRelations as U, platformRole as V, schemaDefinition as W, teamMemberRelations as X, teamMember as Y, teamRelations as Z, db_schema_generated_exports as _, apikey as a, enterpriseSchema as at, member as b, assetRelations as c, assetShare as d, twoFactor as et, assetShareLink as f, assetTypeRelations as g, assetType as h, agentRelations as i, verification as it, oauthApplicationRelations as j, oauthAccessTokenRelations as k, assetRole as l, assetShareRelations as m, accountRelations as n, user as nt, apikeyRelations as o, __export as ot, assetShareLinkRelations as p, sessionRelations as q, agent as r, userRelations as rt, asset as s, __reExport as st, account as t, twoFactorRelations as tt, assetRoleRelations as u, invitation as v, memberOrganizationRoleRelations as w, memberAssetRole as x, invitationRelations as y, organizationRoleRelations as z };
package/dist/db.d.mts CHANGED
@@ -1,2 +1,3 @@
1
- import { n as db, t as databaseSchema } from "./db-D5eWeSOf.mjs";
2
- export { databaseSchema, db };
1
+ import { n as connection, r as schema, t as Connection } from "./db-CXaQH2-a.mjs";
2
+ export * from "drizzle-orm/node-postgres";
3
+ export { Connection, connection, schema };
package/dist/db.mjs CHANGED
@@ -1,3 +1,6 @@
1
- import { n as db, t as databaseSchema } from "./db-Bd2Dgk3D.mjs";
1
+ import "./db-schema.generated-D2dEC1DO.mjs";
2
+ import { r as schema, t as connection } from "./db-Bv5KZYeF.mjs";
2
3
 
3
- export { databaseSchema, db };
4
+ export * from "drizzle-orm/node-postgres"
5
+
6
+ export { connection, schema };
@@ -41,7 +41,7 @@ const createKyselyAdapter = async (config) => {
41
41
  if ("getConnection" in db) dialect = new MysqlDialect(db);
42
42
  if ("connect" in db) dialect = new PostgresDialect({ pool: db });
43
43
  if ("fileControl" in db) {
44
- const { BunSqliteDialect } = await import("./bun-sqlite-dialect-2R9nCsVF-Bnna8w0Z.mjs");
44
+ const { BunSqliteDialect } = await import("./bun-sqlite-dialect-2R9nCsVF-CnQcwp5D.mjs");
45
45
  dialect = new BunSqliteDialect({ database: db });
46
46
  }
47
47
  if ("createSession" in db && typeof window === "undefined") {
@@ -57,7 +57,7 @@ const createKyselyAdapter = async (config) => {
57
57
  if (error !== null && typeof error === "object" && "code" in error && error.code !== "ERR_UNKNOWN_BUILTIN_MODULE") throw error;
58
58
  }
59
59
  if (DatabaseSync && db instanceof DatabaseSync) {
60
- const { NodeSqliteDialect } = await import("./node-sqlite-dialect-CdC7L-ji-CIdCw4_X.mjs");
60
+ const { NodeSqliteDialect } = await import("./node-sqlite-dialect-CdC7L-ji-Q1IU8C2u.mjs");
61
61
  dialect = new NodeSqliteDialect({ database: db });
62
62
  }
63
63
  }
@@ -2,8 +2,8 @@ import { c as generateId, f as createHash, h as hashPassword, n as getAuthTables
2
2
  import { a as getBooleanEnvVar, f as logger, g as BetterAuthError, h as BASE_ERROR_CODES, i as env, l as isProduction, r as createLogger, s as getEnvVar, t as ENV, u as isTest } from "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
3
3
  import { H as base64 } from "./verify-BmFXks5a.mjs";
4
4
  import { z as socialProviders } from "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
5
- import { N as createGraphAdapter, _t as createInternalAdapter, at as checkEndpointConflicts, ct as defu, lt as createCookieGetter, nt as checkPassword, ot as getEndpoints, st as router, ut as getCookies, vt as getAdapter, yt as getMigrations } from "./plugins-C_-kHHzW.mjs";
6
- import { n as getKyselyDatabaseType } from "./dialect-C6_pK3V9-CnxpsNGP.mjs";
5
+ import { N as createGraphAdapter, _t as createInternalAdapter, at as checkEndpointConflicts, ct as defu, lt as createCookieGetter, nt as checkPassword, ot as getEndpoints, st as router, ut as getCookies, vt as getAdapter, yt as getMigrations } from "./plugins-4UnCRez7.mjs";
6
+ import { n as getKyselyDatabaseType } from "./dialect-C6_pK3V9-CwYiGC9t.mjs";
7
7
  import { t as betterFetch } from "./dist-BidhxJQx.mjs";
8
8
  import { a as getOrigin, r as getBaseURL } from "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
9
9
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as db } from "./db-D5eWeSOf.mjs";
2
- import { n as createAuthSystem } from "./better-auth-RunrSBmw.mjs";
1
+ import "./db-CXaQH2-a.mjs";
2
+ import { t as createAuthSystem } from "./better-auth-DNCc730p.mjs";
3
3
  import { parseSetCookieHeader } from "better-auth/cookies";
4
4
  export * from "better-auth";
5
5
  export * from "better-auth/crypto";
6
- export { createAuthSystem, db as enterpriseDB, parseSetCookieHeader };
6
+ export { createAuthSystem, parseSetCookieHeader };
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { n as db } from "./db-Bd2Dgk3D.mjs";
1
+ import "./db-schema.generated-D2dEC1DO.mjs";
2
2
  import { C as symmetricEncodeJWT, G as getCurrentTransactionAdapter, H as getCurrentAdapter, S as symmetricDecodeJWT, W as getCurrentGraphContext, _ as symmetricEncrypt, c as generateId, d as constantTimeEqual, g as symmetricDecrypt, h as hashPassword, l as generateState, m as generateRandomString, s as HIDE_METADATA, u as parseState, v as verifyPassword, w as verifyJWT, x as signJWT } from "./json-oFuWgANh-CZSe35mm.mjs";
3
3
  import { _ as defineErrorCodes, a as getBooleanEnvVar, c as isDevelopment, d as levels, f as logger, g as BetterAuthError, h as BASE_ERROR_CODES, i as env, l as isProduction, m as shouldPublishLog, n as TTY_COLORS, o as getColorDepth, p as nodeENV, r as createLogger, s as getEnvVar, t as ENV, u as isTest, v as invariant } from "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
4
  import "./verify-BmFXks5a.mjs";
5
5
  import { G as validateToken, P as refreshAccessToken, W as validateAuthorizationCode, _ as getOAuth2Tokens, c as createClientCredentialsTokenRequest, i as clientCredentialsToken, l as createRefreshAccessTokenRequest, m as generateCodeChallenge, o as createAuthorizationCodeRequest, s as createAuthorizationURL } from "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
6
- import { Ct as verificationSchema, L as initializeGraph, St as userSchema, bt as rateLimitSchema, dt as parseSetCookieHeader, gt as coreSchema, ht as accountSchema, it as APIError$1, xt as sessionSchema } from "./plugins-C_-kHHzW.mjs";
6
+ import { Ct as verificationSchema, L as initializeGraph, St as userSchema, bt as rateLimitSchema, dt as parseSetCookieHeader, gt as coreSchema, ht as accountSchema, it as APIError$1, xt as sessionSchema } from "./plugins-4UnCRez7.mjs";
7
7
  import "./esm-UlqE2SXT.mjs";
8
- import "./dialect-C6_pK3V9-CnxpsNGP.mjs";
8
+ import "./dialect-C6_pK3V9-CwYiGC9t.mjs";
9
9
  import "./dist-BidhxJQx.mjs";
10
10
  import { t as capitalizeFirstLetter } from "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import { n as createTelemetry, r as getTelemetryAuthConfig, t as betterAuth } from "./dist-DGeBMuXr.mjs";
13
+ import { n as createTelemetry, r as getTelemetryAuthConfig, t as betterAuth } from "./dist-Dt0ifDbX.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { n as createAuthSystem } from "./better-auth-C0GYWCr8.mjs";
15
+ import { t as createAuthSystem } from "./better-auth-BPBF8tkn.mjs";
16
16
 
17
- export { APIError$1 as APIError, BASE_ERROR_CODES, BetterAuthError, ENV, HIDE_METADATA, TTY_COLORS, accountSchema, betterAuth, capitalizeFirstLetter, clientCredentialsToken, constantTimeEqual, coreSchema, createAuthSystem, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createLogger, createRefreshAccessTokenRequest, createTelemetry, defineErrorCodes, db as enterpriseDB, env, generateCodeChallenge, generateId, generateRandomString, generateState, getBooleanEnvVar, getColorDepth, getCurrentAdapter, getCurrentGraphContext, getCurrentTransactionAdapter, getEnvVar, getOAuth2Tokens, getTelemetryAuthConfig, hashPassword, initializeGraph, invariant, isDevelopment, isProduction, isTest, levels, logger, nodeENV, parseSetCookieHeader, parseState, rateLimitSchema, refreshAccessToken, sessionSchema, shouldPublishLog, signJWT, symmetricDecodeJWT, symmetricDecrypt, symmetricEncodeJWT, symmetricEncrypt, userSchema, validateAuthorizationCode, validateToken, verificationSchema, verifyJWT, verifyPassword };
17
+ export { APIError$1 as APIError, BASE_ERROR_CODES, BetterAuthError, ENV, HIDE_METADATA, TTY_COLORS, accountSchema, betterAuth, capitalizeFirstLetter, clientCredentialsToken, constantTimeEqual, coreSchema, createAuthSystem, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createLogger, createRefreshAccessTokenRequest, createTelemetry, defineErrorCodes, env, generateCodeChallenge, generateId, generateRandomString, generateState, getBooleanEnvVar, getColorDepth, getCurrentAdapter, getCurrentGraphContext, getCurrentTransactionAdapter, getEnvVar, getOAuth2Tokens, getTelemetryAuthConfig, hashPassword, initializeGraph, invariant, isDevelopment, isProduction, isTest, levels, logger, nodeENV, parseSetCookieHeader, parseState, rateLimitSchema, refreshAccessToken, sessionSchema, shouldPublishLog, signJWT, symmetricDecodeJWT, symmetricDecrypt, symmetricEncodeJWT, symmetricEncrypt, userSchema, validateAuthorizationCode, validateToken, verificationSchema, verifyJWT, verifyPassword };
package/dist/init.mjs CHANGED
@@ -2,14 +2,14 @@ import "./json-oFuWgANh-CZSe35mm.mjs";
2
2
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
3
3
  import "./verify-BmFXks5a.mjs";
4
4
  import "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
5
- import { G as AuthzedSyncClient, L as initializeGraph } from "./plugins-C_-kHHzW.mjs";
5
+ import { G as AuthzedSyncClient, L as initializeGraph } from "./plugins-4UnCRez7.mjs";
6
6
  import "./esm-UlqE2SXT.mjs";
7
- import "./dialect-C6_pK3V9-CnxpsNGP.mjs";
7
+ import "./dialect-C6_pK3V9-CwYiGC9t.mjs";
8
8
  import "./dist-BidhxJQx.mjs";
9
9
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
10
10
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
11
11
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
12
- import "./dist-DGeBMuXr.mjs";
12
+ import "./dist-Dt0ifDbX.mjs";
13
13
  import { readFile } from "fs/promises";
14
14
 
15
15
  //#region src/init.ts
@@ -2,7 +2,7 @@ import "./json-oFuWgANh-CZSe35mm.mjs";
2
2
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
3
3
  import "./verify-BmFXks5a.mjs";
4
4
  import { l as sql } from "./esm-UlqE2SXT.mjs";
5
- import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "./dialect-C6_pK3V9-CnxpsNGP.mjs";
5
+ import { n as getKyselyDatabaseType, t as createKyselyAdapter } from "./dialect-C6_pK3V9-CwYiGC9t.mjs";
6
6
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
7
7
  import { t as createAdapterFactory } from "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
8
8
 
@@ -3,7 +3,7 @@ import { _ as defineErrorCodes, c as isDevelopment, f as logger, g as BetterAuth
3
3
  import { C as JOSENotSupported, H as base64, N as JWTExpired, U as base64Url, d as importJWK, t as jwtVerify } from "./verify-BmFXks5a.mjs";
4
4
  import { J as decodeJwt, P as refreshAccessToken, W as validateAuthorizationCode, Y as createRemoteJWKSet, s as createAuthorizationURL, t as SocialProviderListEnum } from "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
5
5
  import { l as sql$1 } from "./esm-UlqE2SXT.mjs";
6
- import { t as createKyselyAdapter } from "./dialect-C6_pK3V9-CnxpsNGP.mjs";
6
+ import { t as createKyselyAdapter } from "./dialect-C6_pK3V9-CwYiGC9t.mjs";
7
7
  import { t as betterFetch } from "./dist-BidhxJQx.mjs";
8
8
  import { a as getOrigin, i as getHost, n as parser_default, o as getProtocol, r as getBaseURL, t as parseJSON } from "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
9
9
  import { a as role, i as hasPermission } from "./client--1_AEBPu-Dl2Y0Yen.mjs";
@@ -294,7 +294,7 @@ async function getBaseAdapter(options, handleDirectDatabase) {
294
294
  acc[key] = [];
295
295
  return acc;
296
296
  }, {});
297
- const { memoryAdapter } = await import("./memory-adapter-Cqp5pNDz.mjs");
297
+ const { memoryAdapter } = await import("./memory-adapter-DBNi0Kds.mjs");
298
298
  adapter = memoryAdapter(memoryDB)(options);
299
299
  } else if (typeof options.database === "function") adapter = options.database(options);
300
300
  else adapter = await handleDirectDatabase(options);
@@ -308,10 +308,10 @@ async function getBaseAdapter(options, handleDirectDatabase) {
308
308
  }
309
309
  async function getAdapter(options) {
310
310
  return getBaseAdapter(options, async (opts) => {
311
- const { createKyselyAdapter: createKyselyAdapter$1 } = await import("./kysely-adapter-BJCvIqXV.mjs");
311
+ const { createKyselyAdapter: createKyselyAdapter$1 } = await import("./kysely-adapter-uZQ9e2n3.mjs");
312
312
  const { kysely, databaseType, transaction } = await createKyselyAdapter$1(opts);
313
313
  if (!kysely) throw new BetterAuthError("Failed to initialize database adapter");
314
- const { kyselyAdapter } = await import("./kysely-adapter-BJCvIqXV.mjs");
314
+ const { kyselyAdapter } = await import("./kysely-adapter-uZQ9e2n3.mjs");
315
315
  return kyselyAdapter(kysely, {
316
316
  type: databaseType || "sqlite",
317
317
  debugLogs: opts.database && "debugLogs" in opts.database ? opts.database.debugLogs : false,
package/dist/plugins.mjs CHANGED
@@ -2,9 +2,9 @@ import { s as HIDE_METADATA } from "./json-oFuWgANh-CZSe35mm.mjs";
2
2
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
3
3
  import "./verify-BmFXks5a.mjs";
4
4
  import "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
5
- import { $ as jwt, A as apiKey, B as oAuthDiscoveryMetadata, C as captcha, D as API_KEY_TABLE_NAME, E as admin, F as getMCPProtectedResourceMetadata, G as AuthzedSyncClient, H as oneTimeToken, I as getMCPProviderMetadata, J as getMetadata, K as graph, M as assetsClient, O as ERROR_CODES, P as defaultKeyHasher, Q as getJwtToken, R as lastLoginMethod, S as customSession, T as anonymous, U as organization, V as oAuthProtectedResourceMetadata, W as withMcpAuth, X as createJwk, Y as oidcProvider, Z as generateExportedKeyPair, _ as okta, a as openAPI, b as deviceAuthorization, c as multiSession, d as auth0, et as verifyJWT, f as genericOAuth, ft as createAuthEndpoint, g as microsoftEntraId, h as line, i as phoneNumber, j as assets, k as agents, l as magicLink, m as keycloak, mt as optionsMiddleware, n as username, o as oneTap, p as hubspot, pt as createAuthMiddleware, q as getClient, r as siwe, rt as twoFactor, s as oAuthProxy, t as USERNAME_ERROR_CODES, tt as TWO_FACTOR_ERROR_CODES, u as haveIBeenPwned, v as slack, w as bearer, x as deviceAuthorizationOptionsSchema, y as emailOTP, z as mcp } from "./plugins-C_-kHHzW.mjs";
5
+ import { $ as jwt, A as apiKey, B as oAuthDiscoveryMetadata, C as captcha, D as API_KEY_TABLE_NAME, E as admin, F as getMCPProtectedResourceMetadata, G as AuthzedSyncClient, H as oneTimeToken, I as getMCPProviderMetadata, J as getMetadata, K as graph, M as assetsClient, O as ERROR_CODES, P as defaultKeyHasher, Q as getJwtToken, R as lastLoginMethod, S as customSession, T as anonymous, U as organization, V as oAuthProtectedResourceMetadata, W as withMcpAuth, X as createJwk, Y as oidcProvider, Z as generateExportedKeyPair, _ as okta, a as openAPI, b as deviceAuthorization, c as multiSession, d as auth0, et as verifyJWT, f as genericOAuth, ft as createAuthEndpoint, g as microsoftEntraId, h as line, i as phoneNumber, j as assets, k as agents, l as magicLink, m as keycloak, mt as optionsMiddleware, n as username, o as oneTap, p as hubspot, pt as createAuthMiddleware, q as getClient, r as siwe, rt as twoFactor, s as oAuthProxy, t as USERNAME_ERROR_CODES, tt as TWO_FACTOR_ERROR_CODES, u as haveIBeenPwned, v as slack, w as bearer, x as deviceAuthorizationOptionsSchema, y as emailOTP, z as mcp } from "./plugins-4UnCRez7.mjs";
6
6
  import "./esm-UlqE2SXT.mjs";
7
- import "./dialect-C6_pK3V9-CnxpsNGP.mjs";
7
+ import "./dialect-C6_pK3V9-CwYiGC9t.mjs";
8
8
  import "./dist-BidhxJQx.mjs";
9
9
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
10
10
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
2
2
  import "./dist-BidhxJQx.mjs";
3
3
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
4
- import { n as createAuthClient, r as useStore, t as capitalizeFirstLetter } from "./react-BZlUztTq.mjs";
4
+ import { n as createAuthClient, r as useStore, t as capitalizeFirstLetter } from "./react-DkVozQEM.mjs";
5
5
 
6
6
  export { capitalizeFirstLetter, createAuthClient, useStore };
package/dist/server.mjs CHANGED
@@ -1,18 +1,19 @@
1
- import { n as db } from "./db-Bd2Dgk3D.mjs";
1
+ import "./db-schema.generated-D2dEC1DO.mjs";
2
2
  import "./json-oFuWgANh-CZSe35mm.mjs";
3
3
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
4
  import "./verify-BmFXks5a.mjs";
5
5
  import "./social-providers-DNfE9Ak7-DHuA3WFT.mjs";
6
- import "./plugins-C_-kHHzW.mjs";
6
+ import "./plugins-4UnCRez7.mjs";
7
7
  import "./esm-UlqE2SXT.mjs";
8
- import "./dialect-C6_pK3V9-CnxpsNGP.mjs";
8
+ import "./dialect-C6_pK3V9-CwYiGC9t.mjs";
9
9
  import "./dist-BidhxJQx.mjs";
10
10
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import "./dist-DGeBMuXr.mjs";
13
+ import "./dist-Dt0ifDbX.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { t as auth } from "./better-auth-C0GYWCr8.mjs";
15
+ import { t as createAuthSystem } from "./better-auth-BPBF8tkn.mjs";
16
+ import { n as db_exports, r as schema } from "./db-Bv5KZYeF.mjs";
16
17
  import "dotenv/config";
17
18
  import { cors } from "@elysiajs/cors";
18
19
  import { jwt } from "@elysiajs/jwt";
@@ -21,6 +22,8 @@ import { migrate } from "drizzle-orm/node-postgres/migrator";
21
22
  import { Elysia } from "elysia";
22
23
 
23
24
  //#region src/server.ts
25
+ const db = (0, db_exports.drizzle)(process.env.DATABASE_URL + "?options=-c search_path=enterprise", { schema });
26
+ const auth = createAuthSystem({ db });
24
27
  await migrate(db, {
25
28
  migrationsFolder: "./drizzle",
26
29
  migrationsSchema: "enterprise",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio.js/enterprise",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "srvx --import=jiti/register --port 3001",
@@ -1,12 +0,0 @@
1
- import { n as db } from "./db-D5eWeSOf.mjs";
2
- import * as better_auth0 from "better-auth";
3
- import { BetterAuthPlugin, betterAuth } from "better-auth";
4
-
5
- //#region src/better-auth.d.ts
6
- declare function createAuthSystem(options: {
7
- plugins?: BetterAuthPlugin[];
8
- db?: typeof db;
9
- }): ReturnType<typeof betterAuth>;
10
- declare const auth: better_auth0.Auth<better_auth0.BetterAuthOptions>;
11
- //#endregion
12
- export { createAuthSystem as n, auth as t };
File without changes