@coursebuilder/adapter-drizzle 0.0.4 → 0.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.
- package/dist/{chunk-RMRO5TA7.js → chunk-22KIKVBY.js} +2 -2
- package/dist/chunk-4HDU7QIB.js +747 -0
- package/dist/{chunk-QM6AYTGN.js → chunk-6CBAFOL3.js} +5 -7
- package/dist/{chunk-NCDVIRG4.js → chunk-AIDEJDKJ.js} +5 -7
- package/dist/{chunk-34QNODEZ.js → chunk-BRGTUNY2.js} +5 -7
- package/dist/{chunk-VID6JINS.js → chunk-FRNVLW7N.js} +690 -330
- package/dist/{chunk-LLWSIKQV.js → chunk-GFUUJRX7.js} +1 -1
- package/dist/{chunk-WULUGMHP.js → chunk-H4MXNDWO.js} +5 -7
- package/dist/{chunk-JWWIIUV3.js → chunk-ICL7XZ2Y.js} +5 -7
- package/dist/{chunk-SBGLYMAH.js → chunk-JD4KFACE.js} +5 -7
- package/dist/{chunk-ZUKX3WXB.js → chunk-KI47TR7F.js} +5 -7
- package/dist/{chunk-FZHAOQVB.js → chunk-KVN3JV7C.js} +5 -7
- package/dist/{chunk-H7XEMCP4.js → chunk-MBQ3TMHH.js} +5 -7
- package/dist/chunk-PFN4YUQZ.js +47 -0
- package/dist/{chunk-ABVLEWR5.js → chunk-SFJM6FKE.js} +5 -7
- package/dist/{chunk-QRRP7Y2V.js → chunk-TA6VLEV5.js} +5 -7
- package/dist/{chunk-BZPXYS6A.js → chunk-TMQIGK3N.js} +5 -7
- package/dist/{chunk-VWMY6XV7.js → chunk-US2EXVMI.js} +5 -7
- package/dist/{chunk-KFQAWBFP.js → chunk-UY3DVPP3.js} +5 -7
- package/dist/{chunk-M5NL4CY4.js → chunk-VEFCDI73.js} +5 -7
- package/dist/{chunk-EFO2N6T7.js → chunk-VZABQCFH.js} +5 -7
- package/dist/index.d.ts +1 -31
- package/dist/index.js +21 -32
- package/dist/lib/mysql/index.cjs +1606 -1100
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.ts +4649 -745
- package/dist/lib/mysql/index.js +21 -117
- package/dist/lib/mysql/schemas/auth/accounts.cjs +125 -22
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +180 -178
- package/dist/lib/mysql/schemas/auth/accounts.js +5 -1
- package/dist/lib/mysql/schemas/auth/permissions.cjs +108 -14
- package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +96 -94
- package/dist/lib/mysql/schemas/auth/permissions.js +5 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +146 -13
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +85 -82
- package/dist/lib/mysql/schemas/auth/role-permissions.js +5 -1
- package/dist/lib/mysql/schemas/auth/roles.cjs +110 -14
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.ts +96 -94
- package/dist/lib/mysql/schemas/auth/roles.js +5 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs +117 -10
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +48 -46
- package/dist/lib/mysql/schemas/auth/sessions.js +6 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +156 -15
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +85 -82
- package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +152 -13
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +85 -82
- package/dist/lib/mysql/schemas/auth/user-roles.js +5 -1
- package/dist/lib/mysql/schemas/auth/users.cjs +311 -14
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.ts +101 -94
- package/dist/lib/mysql/schemas/auth/users.js +5 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.cjs +4 -6
- package/dist/lib/mysql/schemas/auth/verification-tokens.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +55 -57
- package/dist/lib/mysql/schemas/auth/verification-tokens.js +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +163 -165
- package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +67 -69
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +103 -105
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +79 -81
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +79 -81
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +91 -93
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +79 -81
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +43 -45
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
- package/dist/lib/mysql/schemas/commerce/price.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.ts +91 -93
- package/dist/lib/mysql/schemas/commerce/price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/product.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.ts +91 -93
- package/dist/lib/mysql/schemas/commerce/product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +127 -129
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +4 -6
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +211 -213
- package/dist/lib/mysql/schemas/commerce/purchase.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs +4 -6
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +91 -93
- package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +4 -6
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +91 -93
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +193 -20
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +146 -142
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +202 -17
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +110 -106
- package/dist/lib/mysql/schemas/content/content-contributions.js +5 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +128 -18
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +97 -94
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -1
- package/dist/lib/mysql/schemas/content/content-resource.cjs +199 -18
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +99 -94
- package/dist/lib/mysql/schemas/content/content-resource.js +5 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs +113 -16
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +108 -106
- package/dist/lib/mysql/schemas/content/contribution-types.js +5 -1
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +4 -6
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +79 -81
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/dist/lib/pg.d.ts +1 -1
- package/dist/lib/sqlite.cjs.map +1 -1
- package/dist/lib/sqlite.d.ts +45 -46
- package/dist/lib/sqlite.js +2 -2
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.d.ts +1 -31
- package/dist/lib/utils.js +1 -1
- package/package.json +9 -5
- package/src/index.ts +1 -1
- package/src/lib/mysql/index.ts +115 -77
- package/src/lib/mysql/schemas/auth/accounts.ts +12 -3
- package/src/lib/mysql/schemas/auth/permissions.ts +10 -3
- package/src/lib/mysql/schemas/auth/role-permissions.ts +21 -3
- package/src/lib/mysql/schemas/auth/roles.ts +12 -3
- package/src/lib/mysql/schemas/auth/sessions.ts +12 -3
- package/src/lib/mysql/schemas/auth/user-permissions.ts +21 -3
- package/src/lib/mysql/schemas/auth/user-roles.ts +21 -3
- package/src/lib/mysql/schemas/auth/users.ts +27 -3
- package/src/lib/mysql/schemas/auth/verification-tokens.ts +2 -4
- package/src/lib/mysql/schemas/commerce/coupon.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-account.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-charge.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-price.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-product.ts +2 -4
- package/src/lib/mysql/schemas/commerce/merchant-session.ts +2 -4
- package/src/lib/mysql/schemas/commerce/price.ts +2 -4
- package/src/lib/mysql/schemas/commerce/product.ts +2 -4
- package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +2 -4
- package/src/lib/mysql/schemas/commerce/purchase.ts +2 -4
- package/src/lib/mysql/schemas/communication/communication-channel.ts +2 -4
- package/src/lib/mysql/schemas/communication/communication-preference-types.ts +20 -25
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +30 -3
- package/src/lib/mysql/schemas/content/content-contributions.ts +31 -3
- package/src/lib/mysql/schemas/content/content-resource-resource.ts +23 -4
- package/src/lib/mysql/schemas/content/content-resource.ts +22 -4
- package/src/lib/mysql/schemas/content/contribution-types.ts +13 -3
- package/src/lib/mysql/schemas/content/resource-progress.ts +2 -4
- package/src/lib/utils.ts +1 -1
- package/dist/chunk-7Z72PW3G.js +0 -60
- package/dist/chunk-C2G2KMWQ.js +0 -48
- package/dist/chunk-GJZCLS2Y.js +0 -29
- package/dist/chunk-HHQK736S.js +0 -40
- package/dist/chunk-I4NIW2NF.js +0 -46
- package/dist/chunk-IHQ3ARH4.js +0 -44
- package/dist/chunk-KEJBPPZC.js +0 -45
- package/dist/chunk-L3XBKPYA.js +0 -47
- package/dist/chunk-MHZHMZ5C.js +0 -47
- package/dist/chunk-MOO56C62.js +0 -46
- package/dist/chunk-RLTOQRJB.js +0 -40
- package/dist/chunk-SWOTLIQI.js +0 -46
- package/dist/chunk-XM4CEU6B.js +0 -54
package/dist/lib/sqlite.js
CHANGED
package/dist/lib/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["import { type MySqlDatabase } from 'drizzle-orm/mysql-core'\nimport type { AnyMySqlTable, MySqlTableFn } from 'drizzle-orm/mysql-core'\nimport { type PgDatabase } from 'drizzle-orm/pg-core'\nimport type { AnyPgTable, PgTableFn } from 'drizzle-orm/pg-core'\nimport { type BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core'\nimport type { AnySQLiteTable, SQLiteTableFn } from 'drizzle-orm/sqlite-core'\n\nimport type { DefaultSchema as MySqlSchema } from './mysql'\nimport type { DefaultSchema as PgSchema } from './pg.js'\nimport type { DefaultSchema as SQLiteSchema } from './sqlite.js'\n\nexport type AnyMySqlDatabase = MySqlDatabase<any, any>\nexport type AnyPgDatabase = PgDatabase<any, any, any>\nexport type AnySQLiteDatabase = BaseSQLiteDatabase<any, any, any, any>\n\nexport interface MinimumSchema {\n\tmysql: MySqlSchema & Record<string, AnyMySqlTable>\n\tpg: PgSchema & Record<string, AnyPgTable>\n\tsqlite: SQLiteSchema & Record<string, AnySQLiteTable>\n}\n\nexport type SqlFlavorOptions =\n\t| AnyMySqlDatabase\n\t| AnyPgDatabase\n\t| AnySQLiteDatabase\n\nexport type ClientFlavors<Flavor> = Flavor extends AnyMySqlDatabase\n\t? MinimumSchema['mysql']\n\t: Flavor extends AnyPgDatabase\n\t\t? MinimumSchema['pg']\n\t\t: Flavor extends AnySQLiteDatabase\n\t\t\t? MinimumSchema['sqlite']\n\t\t\t: never\n\nexport type TableFn<Flavor> = Flavor extends AnyMySqlDatabase\n\t? MySqlTableFn\n\t: Flavor extends AnyPgDatabase\n\t\t? PgTableFn\n\t\t: Flavor extends AnySQLiteDatabase\n\t\t\t? SQLiteTableFn\n\t\t\t: AnySQLiteTable\n\ntype NonNullableProps<T> = {\n\t[P in keyof T]: null extends T[P] ? never : P\n}[keyof T]\n\nexport function stripUndefined<T>(obj: T): Pick<T, NonNullableProps<T>> {\n\tconst result = {} as T\n\tfor (const key in obj) if (obj[key] !== undefined) result[key] = obj[key]\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA;;;;;AAAO,SAASA,eAAkBC,KAAM;AACvC,QAAMC,SAAS,CAAC;AAChB,aAAWC,OAAOF;AAAK,QAAIA,IAAIE,GAAAA,MAASC;AAAWF,aAAOC,GAAAA,IAAOF,IAAIE,GAAAA;AACrE,SAAOD;AACR;AAJgBF;","names":["stripUndefined","obj","result","key","undefined"]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["import { type MySqlDatabase } from 'drizzle-orm/mysql-core'\nimport type { AnyMySqlTable, MySqlTableFn } from 'drizzle-orm/mysql-core'\nimport { type PgDatabase } from 'drizzle-orm/pg-core'\nimport type { AnyPgTable, PgTableFn } from 'drizzle-orm/pg-core'\nimport { type BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core'\nimport type { AnySQLiteTable, SQLiteTableFn } from 'drizzle-orm/sqlite-core'\n\nimport type { DefaultSchema as MySqlSchema } from './mysql/index.js'\nimport type { DefaultSchema as PgSchema } from './pg.js'\nimport type { DefaultSchema as SQLiteSchema } from './sqlite.js'\n\nexport type AnyMySqlDatabase = MySqlDatabase<any, any>\nexport type AnyPgDatabase = PgDatabase<any, any, any>\nexport type AnySQLiteDatabase = BaseSQLiteDatabase<any, any, any, any>\n\nexport interface MinimumSchema {\n\tmysql: MySqlSchema & Record<string, AnyMySqlTable>\n\tpg: PgSchema & Record<string, AnyPgTable>\n\tsqlite: SQLiteSchema & Record<string, AnySQLiteTable>\n}\n\nexport type SqlFlavorOptions =\n\t| AnyMySqlDatabase\n\t| AnyPgDatabase\n\t| AnySQLiteDatabase\n\nexport type ClientFlavors<Flavor> = Flavor extends AnyMySqlDatabase\n\t? MinimumSchema['mysql']\n\t: Flavor extends AnyPgDatabase\n\t\t? MinimumSchema['pg']\n\t\t: Flavor extends AnySQLiteDatabase\n\t\t\t? MinimumSchema['sqlite']\n\t\t\t: never\n\nexport type TableFn<Flavor> = Flavor extends AnyMySqlDatabase\n\t? MySqlTableFn\n\t: Flavor extends AnyPgDatabase\n\t\t? PgTableFn\n\t\t: Flavor extends AnySQLiteDatabase\n\t\t\t? SQLiteTableFn\n\t\t\t: AnySQLiteTable\n\ntype NonNullableProps<T> = {\n\t[P in keyof T]: null extends T[P] ? never : P\n}[keyof T]\n\nexport function stripUndefined<T>(obj: T): Pick<T, NonNullableProps<T>> {\n\tconst result = {} as T\n\tfor (const key in obj) if (obj[key] !== undefined) result[key] = obj[key]\n\treturn result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA;;;;;AAAO,SAASA,eAAkBC,KAAM;AACvC,QAAMC,SAAS,CAAC;AAChB,aAAWC,OAAOF;AAAK,QAAIA,IAAIE,GAAAA,MAASC;AAAWF,aAAOC,GAAAA,IAAOF,IAAIE,GAAAA;AACrE,SAAOD;AACR;AAJgBF;","names":["stripUndefined","obj","result","key","undefined"]}
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -4,38 +4,8 @@ import { BaseSQLiteDatabase, AnySQLiteTable, SQLiteTableFn } from 'drizzle-orm/s
|
|
|
4
4
|
import { DefaultSchema } from './mysql/index.js';
|
|
5
5
|
import { DefaultSchema as DefaultSchema$1 } from './pg.js';
|
|
6
6
|
import { DefaultSchema as DefaultSchema$2 } from './sqlite.js';
|
|
7
|
+
import 'drizzle-orm';
|
|
7
8
|
import '@coursebuilder/core/adapters';
|
|
8
|
-
import './mysql/schemas/auth/accounts.js';
|
|
9
|
-
import './mysql/schemas/auth/permissions.js';
|
|
10
|
-
import './mysql/schemas/auth/role-permissions.js';
|
|
11
|
-
import './mysql/schemas/auth/roles.js';
|
|
12
|
-
import './mysql/schemas/auth/sessions.js';
|
|
13
|
-
import './mysql/schemas/auth/user-permissions.js';
|
|
14
|
-
import './mysql/schemas/auth/user-roles.js';
|
|
15
|
-
import './mysql/schemas/auth/users.js';
|
|
16
|
-
import './mysql/schemas/auth/verification-tokens.js';
|
|
17
|
-
import './mysql/schemas/commerce/coupon.js';
|
|
18
|
-
import './mysql/schemas/commerce/merchant-account.js';
|
|
19
|
-
import './mysql/schemas/commerce/merchant-charge.js';
|
|
20
|
-
import './mysql/schemas/commerce/merchant-coupon.js';
|
|
21
|
-
import './mysql/schemas/commerce/merchant-customer.js';
|
|
22
|
-
import './mysql/schemas/commerce/merchant-price.js';
|
|
23
|
-
import './mysql/schemas/commerce/merchant-product.js';
|
|
24
|
-
import './mysql/schemas/commerce/merchant-session.js';
|
|
25
|
-
import './mysql/schemas/commerce/price.js';
|
|
26
|
-
import './mysql/schemas/commerce/product.js';
|
|
27
|
-
import './mysql/schemas/commerce/purchase.js';
|
|
28
|
-
import './mysql/schemas/commerce/purchase-user-transfer.js';
|
|
29
|
-
import './mysql/schemas/communication/communication-channel.js';
|
|
30
|
-
import './mysql/schemas/communication/communication-preference-types.js';
|
|
31
|
-
import './mysql/schemas/communication/communication-preferences.js';
|
|
32
|
-
import './mysql/schemas/content/content-contributions.js';
|
|
33
|
-
import './mysql/schemas/content/content-resource.js';
|
|
34
|
-
import './mysql/schemas/content/content-resource-resource.js';
|
|
35
|
-
import './mysql/schemas/content/contribution-types.js';
|
|
36
|
-
import './mysql/schemas/content/resource-progress.js';
|
|
37
|
-
import 'drizzle-orm/sqlite-core/table.js';
|
|
38
|
-
import 'drizzle-orm/sqlite-core/index.js';
|
|
39
9
|
|
|
40
10
|
type AnyMySqlDatabase = MySqlDatabase<any, any>;
|
|
41
11
|
type AnyPgDatabase = PgDatabase<any, any, any>;
|
package/dist/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coursebuilder/adapter-drizzle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Drizzle adapter for Course Builder.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coursebuilder",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@auth/core": "^0.28.0",
|
|
42
|
-
"@coursebuilder/core": "0.0.
|
|
42
|
+
"@coursebuilder/core": "0.0.8",
|
|
43
43
|
"@libsql/client": "0.5.6",
|
|
44
44
|
"@types/better-sqlite3": "7.6.9",
|
|
45
45
|
"@types/uuid": "9.0.8",
|
|
@@ -48,14 +48,18 @@
|
|
|
48
48
|
"drizzle-orm": "0.30.2",
|
|
49
49
|
"mysql2": "^3.6.1",
|
|
50
50
|
"postgres": "^3.3.4",
|
|
51
|
-
"tsup": "6.7.0"
|
|
51
|
+
"tsup": "6.7.0",
|
|
52
|
+
"tsx": "^4.7.1"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"drizzle-orm": "0.30.x"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
|
-
"clean": "rm -rf
|
|
58
|
+
"clean": "find . -type d -name \".drizzle\" | xargs rm -rf",
|
|
58
59
|
"build": "tsup",
|
|
59
|
-
"dev": "tsup --watch"
|
|
60
|
+
"dev": "tsup --watch",
|
|
61
|
+
"test": "pnpm test:mysql",
|
|
62
|
+
"test:mysql": "pnpm clean && ./test/mysql/test.sh",
|
|
63
|
+
"test:mysql:watch": "pnpm clean && ./test/mysql/test.sh watch"
|
|
60
64
|
}
|
|
61
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { type CourseBuilderAdapter } from '@coursebuilder/core/adapters'
|
|
|
8
8
|
import {
|
|
9
9
|
createTables as createMySqlTables,
|
|
10
10
|
mySqlDrizzleAdapter,
|
|
11
|
-
} from './lib/mysql'
|
|
11
|
+
} from './lib/mysql/index.js'
|
|
12
12
|
import { pgDrizzleAdapter } from './lib/pg.js'
|
|
13
13
|
import { SQLiteDrizzleAdapter } from './lib/sqlite.js'
|
|
14
14
|
import { type SqlFlavorOptions, type TableFn } from './lib/utils.js'
|
package/src/lib/mysql/index.ts
CHANGED
|
@@ -10,92 +10,128 @@ import {
|
|
|
10
10
|
import { type CourseBuilderAdapter } from '@coursebuilder/core/adapters'
|
|
11
11
|
import { VideoResourceSchema } from '@coursebuilder/core/schemas/video-resource'
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import { getRolePermissionsSchema } from './schemas/auth/role-permissions'
|
|
16
|
-
import { getRolesSchema } from './schemas/auth/roles'
|
|
17
|
-
import { getSessionsSchema } from './schemas/auth/sessions'
|
|
18
|
-
import { getUserPermissionsSchema } from './schemas/auth/user-permissions'
|
|
19
|
-
import { getUserRolesSchema } from './schemas/auth/user-roles'
|
|
20
|
-
import { getUsersSchema } from './schemas/auth/users'
|
|
21
|
-
import { getVerificationTokensSchema } from './schemas/auth/verification-tokens'
|
|
22
|
-
import { getCouponSchema } from './schemas/commerce/coupon'
|
|
23
|
-
import { getMerchantAccountSchema } from './schemas/commerce/merchant-account'
|
|
24
|
-
import { getMerchantChargeSchema } from './schemas/commerce/merchant-charge'
|
|
25
|
-
import { getMerchantCouponSchema } from './schemas/commerce/merchant-coupon'
|
|
26
|
-
import { getMerchantCustomerSchema } from './schemas/commerce/merchant-customer'
|
|
27
|
-
import { getMerchantPriceSchema } from './schemas/commerce/merchant-price'
|
|
28
|
-
import { getMerchantProductSchema } from './schemas/commerce/merchant-product'
|
|
29
|
-
import { getMerchantSessionSchema } from './schemas/commerce/merchant-session'
|
|
30
|
-
import { getPriceSchema } from './schemas/commerce/price'
|
|
31
|
-
import { getProductSchema } from './schemas/commerce/product'
|
|
32
|
-
import { getPurchaseSchema } from './schemas/commerce/purchase'
|
|
33
|
-
import { getPurchaseUserTransferSchema } from './schemas/commerce/purchase-user-transfer'
|
|
34
|
-
import { getCommunicationChannelSchema } from './schemas/communication/communication-channel'
|
|
35
|
-
import { getCommunicationPreferenceTypesSchema } from './schemas/communication/communication-preference-types'
|
|
36
|
-
import { getCommunicationPreferencesSchema } from './schemas/communication/communication-preferences'
|
|
37
|
-
import { getContentContributionsSchema } from './schemas/content/content-contributions'
|
|
38
|
-
import { getContentResourceSchema } from './schemas/content/content-resource'
|
|
39
|
-
import { getContentResourceResourceSchema } from './schemas/content/content-resource-resource'
|
|
40
|
-
import { getContributionTypesSchema } from './schemas/content/contribution-types'
|
|
41
|
-
import { getResourceProgressSchema } from './schemas/content/resource-progress'
|
|
42
|
-
|
|
43
|
-
export {
|
|
13
|
+
import {
|
|
14
|
+
getAccountsRelationsSchema,
|
|
44
15
|
getAccountsSchema,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
getCouponSchema,
|
|
49
|
-
getMerchantAccountSchema,
|
|
50
|
-
getMerchantChargeSchema,
|
|
51
|
-
getMerchantCouponSchema,
|
|
52
|
-
getMerchantCustomerSchema,
|
|
53
|
-
getMerchantPriceSchema,
|
|
54
|
-
getMerchantProductSchema,
|
|
55
|
-
getMerchantSessionSchema,
|
|
56
|
-
getPriceSchema,
|
|
57
|
-
getProductSchema,
|
|
58
|
-
getPurchaseSchema,
|
|
59
|
-
getPurchaseUserTransferSchema,
|
|
60
|
-
getContentResourceSchema,
|
|
61
|
-
getContentResourceResourceSchema,
|
|
16
|
+
} from './schemas/auth/accounts.js'
|
|
17
|
+
import {
|
|
18
|
+
getPermissionsRelationsSchema,
|
|
62
19
|
getPermissionsSchema,
|
|
20
|
+
} from './schemas/auth/permissions.js'
|
|
21
|
+
import {
|
|
22
|
+
getRolePermissionsRelationsSchema,
|
|
63
23
|
getRolePermissionsSchema,
|
|
24
|
+
} from './schemas/auth/role-permissions.js'
|
|
25
|
+
import {
|
|
26
|
+
getRolesRelationsSchema,
|
|
64
27
|
getRolesSchema,
|
|
28
|
+
} from './schemas/auth/roles.js'
|
|
29
|
+
import {
|
|
30
|
+
getSessionRelationsSchema,
|
|
31
|
+
getSessionsSchema,
|
|
32
|
+
} from './schemas/auth/sessions.js'
|
|
33
|
+
import {
|
|
34
|
+
getUserPermissionsRelationsSchema,
|
|
65
35
|
getUserPermissionsSchema,
|
|
36
|
+
} from './schemas/auth/user-permissions.js'
|
|
37
|
+
import {
|
|
38
|
+
getUserRolesRelationsSchema,
|
|
66
39
|
getUserRolesSchema,
|
|
67
|
-
|
|
68
|
-
|
|
40
|
+
} from './schemas/auth/user-roles.js'
|
|
41
|
+
import {
|
|
42
|
+
getUsersRelationsSchema,
|
|
43
|
+
getUsersSchema,
|
|
44
|
+
} from './schemas/auth/users.js'
|
|
45
|
+
import { getVerificationTokensSchema } from './schemas/auth/verification-tokens.js'
|
|
46
|
+
import { getCouponSchema } from './schemas/commerce/coupon.js'
|
|
47
|
+
import { getMerchantAccountSchema } from './schemas/commerce/merchant-account.js'
|
|
48
|
+
import { getMerchantChargeSchema } from './schemas/commerce/merchant-charge.js'
|
|
49
|
+
import { getMerchantCouponSchema } from './schemas/commerce/merchant-coupon.js'
|
|
50
|
+
import { getMerchantCustomerSchema } from './schemas/commerce/merchant-customer.js'
|
|
51
|
+
import { getMerchantPriceSchema } from './schemas/commerce/merchant-price.js'
|
|
52
|
+
import { getMerchantProductSchema } from './schemas/commerce/merchant-product.js'
|
|
53
|
+
import { getMerchantSessionSchema } from './schemas/commerce/merchant-session.js'
|
|
54
|
+
import { getPriceSchema } from './schemas/commerce/price.js'
|
|
55
|
+
import { getProductSchema } from './schemas/commerce/product.js'
|
|
56
|
+
import { getPurchaseUserTransferSchema } from './schemas/commerce/purchase-user-transfer.js'
|
|
57
|
+
import { getPurchaseSchema } from './schemas/commerce/purchase.js'
|
|
58
|
+
import { getCommunicationChannelSchema } from './schemas/communication/communication-channel.js'
|
|
59
|
+
import { getCommunicationPreferenceTypesSchema } from './schemas/communication/communication-preference-types.js'
|
|
60
|
+
import {
|
|
61
|
+
getCommunicationPreferencesRelationsSchema,
|
|
69
62
|
getCommunicationPreferencesSchema,
|
|
63
|
+
} from './schemas/communication/communication-preferences.js'
|
|
64
|
+
import {
|
|
65
|
+
getContentContributionRelationsSchema,
|
|
70
66
|
getContentContributionsSchema,
|
|
67
|
+
} from './schemas/content/content-contributions.js'
|
|
68
|
+
import {
|
|
69
|
+
getContentResourceResourceRelationsSchema,
|
|
70
|
+
getContentResourceResourceSchema,
|
|
71
|
+
} from './schemas/content/content-resource-resource.js'
|
|
72
|
+
import {
|
|
73
|
+
getContentResourceRelationsSchema,
|
|
74
|
+
getContentResourceSchema,
|
|
75
|
+
} from './schemas/content/content-resource.js'
|
|
76
|
+
import {
|
|
77
|
+
getContributionTypesRelationsSchema,
|
|
71
78
|
getContributionTypesSchema,
|
|
72
|
-
|
|
79
|
+
} from './schemas/content/contribution-types.js'
|
|
80
|
+
import { getResourceProgressSchema } from './schemas/content/resource-progress.js'
|
|
81
|
+
|
|
82
|
+
export function getCourseBuilderSchema(mysqlTable: MySqlTableFn) {
|
|
83
|
+
return {
|
|
84
|
+
accounts: getAccountsSchema(mysqlTable),
|
|
85
|
+
accountsRelations: getAccountsRelationsSchema(mysqlTable),
|
|
86
|
+
permissions: getPermissionsSchema(mysqlTable),
|
|
87
|
+
permissionsRelations: getPermissionsRelationsSchema(mysqlTable),
|
|
88
|
+
rolePermissions: getRolePermissionsSchema(mysqlTable),
|
|
89
|
+
rolePermissionsRelations: getRolePermissionsRelationsSchema(mysqlTable),
|
|
90
|
+
roles: getRolesSchema(mysqlTable),
|
|
91
|
+
rolesRelations: getRolesRelationsSchema(mysqlTable),
|
|
92
|
+
sessions: getSessionsSchema(mysqlTable),
|
|
93
|
+
sessionsRelations: getSessionRelationsSchema(mysqlTable),
|
|
94
|
+
userPermissions: getUserPermissionsSchema(mysqlTable),
|
|
95
|
+
userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable),
|
|
96
|
+
userRoles: getUserRolesSchema(mysqlTable),
|
|
97
|
+
userRolesRelations: getUserRolesRelationsSchema(mysqlTable),
|
|
98
|
+
users: getUsersSchema(mysqlTable),
|
|
99
|
+
usersRelations: getUsersRelationsSchema(mysqlTable),
|
|
100
|
+
verificationTokens: getVerificationTokensSchema(mysqlTable),
|
|
101
|
+
coupon: getCouponSchema(mysqlTable),
|
|
102
|
+
merchantAccount: getMerchantAccountSchema(mysqlTable),
|
|
103
|
+
merchantCharge: getMerchantChargeSchema(mysqlTable),
|
|
104
|
+
merchantCoupon: getMerchantCouponSchema(mysqlTable),
|
|
105
|
+
merchantCustomer: getMerchantCustomerSchema(mysqlTable),
|
|
106
|
+
merchantPrice: getMerchantPriceSchema(mysqlTable),
|
|
107
|
+
merchantProduct: getMerchantProductSchema(mysqlTable),
|
|
108
|
+
merchantSession: getMerchantSessionSchema(mysqlTable),
|
|
109
|
+
price: getPriceSchema(mysqlTable),
|
|
110
|
+
product: getProductSchema(mysqlTable),
|
|
111
|
+
purchase: getPurchaseSchema(mysqlTable),
|
|
112
|
+
purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
|
|
113
|
+
communicationChannel: getCommunicationChannelSchema(mysqlTable),
|
|
114
|
+
communicationPreferenceTypes:
|
|
115
|
+
getCommunicationPreferenceTypesSchema(mysqlTable),
|
|
116
|
+
communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
|
|
117
|
+
communicationPreferencesRelations:
|
|
118
|
+
getCommunicationPreferencesRelationsSchema(mysqlTable),
|
|
119
|
+
contentContributions: getContentContributionsSchema(mysqlTable),
|
|
120
|
+
contentContributionRelations:
|
|
121
|
+
getContentContributionRelationsSchema(mysqlTable),
|
|
122
|
+
contentResource: getContentResourceSchema(mysqlTable),
|
|
123
|
+
contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
|
|
124
|
+
contentResourceResource: getContentResourceResourceSchema(mysqlTable),
|
|
125
|
+
contentResourceResourceRelations:
|
|
126
|
+
getContentResourceResourceRelationsSchema(mysqlTable),
|
|
127
|
+
contributionTypes: getContributionTypesSchema(mysqlTable),
|
|
128
|
+
contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
|
|
129
|
+
resourceProgress: getResourceProgressSchema(mysqlTable),
|
|
130
|
+
} as const
|
|
73
131
|
}
|
|
74
132
|
|
|
75
133
|
export function createTables(mySqlTable: MySqlTableFn) {
|
|
76
|
-
return
|
|
77
|
-
users: getUsersSchema(mySqlTable).users,
|
|
78
|
-
accounts: getAccountsSchema(mySqlTable).accounts,
|
|
79
|
-
sessions: getSessionsSchema(mySqlTable).sessions,
|
|
80
|
-
verificationTokens:
|
|
81
|
-
getVerificationTokensSchema(mySqlTable).verificationTokens,
|
|
82
|
-
contentResource: getContentResourceSchema(mySqlTable).contentResource,
|
|
83
|
-
contentResourceResource:
|
|
84
|
-
getContentResourceResourceSchema(mySqlTable).contentResourceResource,
|
|
85
|
-
purchase: getPurchaseSchema(mySqlTable).purchase,
|
|
86
|
-
price: getPriceSchema(mySqlTable).price,
|
|
87
|
-
product: getProductSchema(mySqlTable).product,
|
|
88
|
-
purchaseUserTransfer:
|
|
89
|
-
getPurchaseUserTransferSchema(mySqlTable).purchaseUserTransfer,
|
|
90
|
-
merchantSession: getMerchantSessionSchema(mySqlTable).merchantSession,
|
|
91
|
-
merchantProduct: getMerchantProductSchema(mySqlTable).merchantProduct,
|
|
92
|
-
merchantPrice: getMerchantPriceSchema(mySqlTable).merchantPrice,
|
|
93
|
-
merchantCustomer: getMerchantCustomerSchema(mySqlTable).merchantCustomer,
|
|
94
|
-
merchantCoupon: getMerchantCouponSchema(mySqlTable).merchantCoupon,
|
|
95
|
-
merchantCharge: getMerchantChargeSchema(mySqlTable).merchantCharge,
|
|
96
|
-
merchantAccount: getMerchantAccountSchema(mySqlTable).merchantAccount,
|
|
97
|
-
coupon: getCouponSchema(mySqlTable).coupon,
|
|
98
|
-
}
|
|
134
|
+
return getCourseBuilderSchema(mySqlTable)
|
|
99
135
|
}
|
|
100
136
|
|
|
101
137
|
export type DefaultSchema = ReturnType<typeof createTables>
|
|
@@ -155,9 +191,9 @@ export function mySqlDrizzleAdapter(
|
|
|
155
191
|
|
|
156
192
|
const query = sql`
|
|
157
193
|
SELECT
|
|
158
|
-
id as
|
|
159
|
-
CAST(updatedAt AS DATETIME) as
|
|
160
|
-
CAST(createdAt AS DATETIME) as
|
|
194
|
+
id as id,
|
|
195
|
+
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
196
|
+
CAST(createdAt AS DATETIME) as createdAt,
|
|
161
197
|
JSON_EXTRACT (${contentResource.fields}, "$.state") AS state,
|
|
162
198
|
JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
|
|
163
199
|
JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
|
|
@@ -375,6 +411,8 @@ export function mySqlDrizzleAdapter(
|
|
|
375
411
|
.then((res) => res[0] ?? null)
|
|
376
412
|
|
|
377
413
|
await client.delete(users).where(eq(users.id, id))
|
|
414
|
+
await client.delete(sessions).where(eq(sessions.userId, id))
|
|
415
|
+
await client.delete(accounts).where(eq(accounts.userId, id))
|
|
378
416
|
|
|
379
417
|
return user
|
|
380
418
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AdapterAccount } from '@auth/core/adapters'
|
|
2
|
+
import { relations } from 'drizzle-orm'
|
|
2
3
|
import {
|
|
3
4
|
index,
|
|
4
5
|
int,
|
|
@@ -8,8 +9,10 @@ import {
|
|
|
8
9
|
varchar,
|
|
9
10
|
} from 'drizzle-orm/mysql-core'
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
import { getUsersSchema } from './users.js'
|
|
13
|
+
|
|
14
|
+
export function getAccountsSchema(mysqlTable: MySqlTableFn) {
|
|
15
|
+
return mysqlTable(
|
|
13
16
|
'account',
|
|
14
17
|
{
|
|
15
18
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
@@ -38,6 +41,12 @@ export const getAccountsSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
38
41
|
userIdIdx: index('userId_idx').on(account.userId),
|
|
39
42
|
}),
|
|
40
43
|
)
|
|
44
|
+
}
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
export function getAccountsRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
47
|
+
const accounts = getAccountsSchema(mysqlTable)
|
|
48
|
+
const users = getUsersSchema(mysqlTable)
|
|
49
|
+
return relations(accounts, ({ one }) => ({
|
|
50
|
+
user: one(users, { fields: [accounts.userId], references: [users.id] }),
|
|
51
|
+
}))
|
|
43
52
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import {
|
|
2
3
|
boolean,
|
|
3
4
|
index,
|
|
@@ -7,8 +8,10 @@ import {
|
|
|
7
8
|
varchar,
|
|
8
9
|
} from 'drizzle-orm/mysql-core'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { getRolePermissionsSchema } from './role-permissions.js'
|
|
12
|
+
|
|
13
|
+
export function getPermissionsSchema(mysqlTable: MySqlTableFn) {
|
|
14
|
+
return mysqlTable(
|
|
12
15
|
'permission',
|
|
13
16
|
{
|
|
14
17
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
@@ -32,6 +35,10 @@ export const getPermissionsSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
32
35
|
nameIdx: index('name_idx').on(permission.name),
|
|
33
36
|
}),
|
|
34
37
|
)
|
|
38
|
+
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
export function getPermissionsRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
41
|
+
return relations(getPermissionsSchema(mysqlTable), ({ many }) => ({
|
|
42
|
+
rolePermissions: many(getRolePermissionsSchema(mysqlTable)),
|
|
43
|
+
}))
|
|
37
44
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import {
|
|
2
3
|
boolean,
|
|
3
4
|
index,
|
|
@@ -7,8 +8,11 @@ import {
|
|
|
7
8
|
varchar,
|
|
8
9
|
} from 'drizzle-orm/mysql-core'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { getPermissionsSchema } from './permissions.js'
|
|
12
|
+
import { getRolesSchema } from './roles.js'
|
|
13
|
+
|
|
14
|
+
export function getRolePermissionsSchema(mysqlTable: MySqlTableFn) {
|
|
15
|
+
return mysqlTable(
|
|
12
16
|
'rolePermission',
|
|
13
17
|
{
|
|
14
18
|
roleId: varchar('roleId', { length: 255 }).notNull(),
|
|
@@ -33,6 +37,20 @@ export const getRolePermissionsSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
33
37
|
permissionIdIdx: index('permissionId_idx').on(rp.permissionId),
|
|
34
38
|
}),
|
|
35
39
|
)
|
|
40
|
+
}
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
export function getRolePermissionsRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
43
|
+
const permissions = getPermissionsSchema(mysqlTable)
|
|
44
|
+
const roles = getRolesSchema(mysqlTable)
|
|
45
|
+
const rolePermissions = getRolePermissionsSchema(mysqlTable)
|
|
46
|
+
return relations(rolePermissions, ({ one }) => ({
|
|
47
|
+
role: one(roles, {
|
|
48
|
+
fields: [rolePermissions.roleId],
|
|
49
|
+
references: [roles.id],
|
|
50
|
+
}),
|
|
51
|
+
permission: one(permissions, {
|
|
52
|
+
fields: [rolePermissions.permissionId],
|
|
53
|
+
references: [permissions.id],
|
|
54
|
+
}),
|
|
55
|
+
}))
|
|
38
56
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import {
|
|
2
3
|
boolean,
|
|
3
4
|
index,
|
|
@@ -7,8 +8,10 @@ import {
|
|
|
7
8
|
varchar,
|
|
8
9
|
} from 'drizzle-orm/mysql-core'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { getUserRolesSchema } from './user-roles.js'
|
|
12
|
+
|
|
13
|
+
export function getRolesSchema(mysqlTable: MySqlTableFn) {
|
|
14
|
+
return mysqlTable(
|
|
12
15
|
'role',
|
|
13
16
|
{
|
|
14
17
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
@@ -32,6 +35,12 @@ export const getRolesSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
32
35
|
nameIdx: index('name_idx').on(role.name),
|
|
33
36
|
}),
|
|
34
37
|
)
|
|
38
|
+
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
export function getRolesRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
41
|
+
const roles = getRolesSchema(mysqlTable)
|
|
42
|
+
const userRoles = getUserRolesSchema(mysqlTable)
|
|
43
|
+
return relations(roles, ({ many }) => ({
|
|
44
|
+
userRoles: many(userRoles),
|
|
45
|
+
}))
|
|
37
46
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import { index, MySqlTableFn, timestamp, varchar } from 'drizzle-orm/mysql-core'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { getUsersSchema } from './users.js'
|
|
5
|
+
|
|
6
|
+
export function getSessionsSchema(mysqlTable: MySqlTableFn) {
|
|
7
|
+
return mysqlTable(
|
|
5
8
|
'session',
|
|
6
9
|
{
|
|
7
10
|
sessionToken: varchar('sessionToken', { length: 255 })
|
|
@@ -14,6 +17,12 @@ export const getSessionsSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
14
17
|
userIdIdx: index('userId_idx').on(session.userId),
|
|
15
18
|
}),
|
|
16
19
|
)
|
|
20
|
+
}
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
export function getSessionRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
23
|
+
const sessions = getSessionsSchema(mysqlTable)
|
|
24
|
+
const users = getUsersSchema(mysqlTable)
|
|
25
|
+
return relations(sessions, ({ one }) => ({
|
|
26
|
+
user: one(users, { fields: [sessions.userId], references: [users.id] }),
|
|
27
|
+
}))
|
|
19
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import {
|
|
2
3
|
boolean,
|
|
3
4
|
index,
|
|
@@ -7,8 +8,11 @@ import {
|
|
|
7
8
|
varchar,
|
|
8
9
|
} from 'drizzle-orm/mysql-core'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { getPermissionsSchema } from './permissions.js'
|
|
12
|
+
import { getUsersSchema } from './users.js'
|
|
13
|
+
|
|
14
|
+
export function getUserPermissionsSchema(mysqlTable: MySqlTableFn) {
|
|
15
|
+
return mysqlTable(
|
|
12
16
|
'userPermission',
|
|
13
17
|
{
|
|
14
18
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
@@ -33,6 +37,20 @@ export const getUserPermissionsSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
33
37
|
permissionIdIdx: index('permissionId_idx').on(up.permissionId),
|
|
34
38
|
}),
|
|
35
39
|
)
|
|
40
|
+
}
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
export function getUserPermissionsRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
43
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable)
|
|
44
|
+
const users = getUsersSchema(mysqlTable)
|
|
45
|
+
const permissions = getPermissionsSchema(mysqlTable)
|
|
46
|
+
return relations(userPermissions, ({ one }) => ({
|
|
47
|
+
user: one(users, {
|
|
48
|
+
fields: [userPermissions.userId],
|
|
49
|
+
references: [users.id],
|
|
50
|
+
}),
|
|
51
|
+
permission: one(permissions, {
|
|
52
|
+
fields: [userPermissions.permissionId],
|
|
53
|
+
references: [permissions.id],
|
|
54
|
+
}),
|
|
55
|
+
}))
|
|
38
56
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm'
|
|
1
2
|
import {
|
|
2
3
|
boolean,
|
|
3
4
|
index,
|
|
@@ -7,8 +8,11 @@ import {
|
|
|
7
8
|
varchar,
|
|
8
9
|
} from 'drizzle-orm/mysql-core'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import { getRolesSchema } from './roles.js'
|
|
12
|
+
import { getUsersSchema } from './users.js'
|
|
13
|
+
|
|
14
|
+
export function getUserRolesSchema(mysqlTable: MySqlTableFn) {
|
|
15
|
+
return mysqlTable(
|
|
12
16
|
'userRole',
|
|
13
17
|
{
|
|
14
18
|
userId: varchar('userId', { length: 255 }).notNull(),
|
|
@@ -33,6 +37,20 @@ export const getUserRolesSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
33
37
|
roleIdIdx: index('roleId_idx').on(ur.roleId),
|
|
34
38
|
}),
|
|
35
39
|
)
|
|
40
|
+
}
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
export function getUserRolesRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
43
|
+
const userRoles = getUserRolesSchema(mysqlTable)
|
|
44
|
+
const users = getUsersSchema(mysqlTable)
|
|
45
|
+
const roles = getRolesSchema(mysqlTable)
|
|
46
|
+
return relations(userRoles, ({ one }) => ({
|
|
47
|
+
user: one(users, {
|
|
48
|
+
fields: [userRoles.userId],
|
|
49
|
+
references: [users.id],
|
|
50
|
+
}),
|
|
51
|
+
role: one(roles, {
|
|
52
|
+
fields: [userRoles.roleId],
|
|
53
|
+
references: [roles.id],
|
|
54
|
+
}),
|
|
55
|
+
}))
|
|
38
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql } from 'drizzle-orm'
|
|
1
|
+
import { relations, sql } from 'drizzle-orm'
|
|
2
2
|
import {
|
|
3
3
|
index,
|
|
4
4
|
mysqlEnum,
|
|
@@ -7,8 +7,15 @@ import {
|
|
|
7
7
|
varchar,
|
|
8
8
|
} from 'drizzle-orm/mysql-core'
|
|
9
9
|
|
|
10
|
+
import { getCommunicationPreferencesSchema } from '../communication/communication-preferences.js'
|
|
11
|
+
import { getContentContributionsSchema } from '../content/content-contributions.js'
|
|
12
|
+
import { getContentResourceSchema } from '../content/content-resource.js'
|
|
13
|
+
import { getAccountsSchema } from './accounts.js'
|
|
14
|
+
import { getUserPermissionsSchema } from './user-permissions.js'
|
|
15
|
+
import { getUserRolesSchema } from './user-roles.js'
|
|
16
|
+
|
|
10
17
|
export function getUsersSchema(mysqlTable: MySqlTableFn) {
|
|
11
|
-
|
|
18
|
+
return mysqlTable(
|
|
12
19
|
'user',
|
|
13
20
|
{
|
|
14
21
|
id: varchar('id', { length: 255 }).notNull().primaryKey(),
|
|
@@ -28,8 +35,25 @@ export function getUsersSchema(mysqlTable: MySqlTableFn) {
|
|
|
28
35
|
(user) => ({
|
|
29
36
|
emailIdx: index('email_idx').on(user.email),
|
|
30
37
|
roleIdx: index('role_idx').on(user.role),
|
|
38
|
+
createdAtIdx: index('created_at_idx').on(user.createdAt),
|
|
31
39
|
}),
|
|
32
40
|
)
|
|
41
|
+
}
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
export function getUsersRelationsSchema(mysqlTable: MySqlTableFn) {
|
|
44
|
+
const users = getUsersSchema(mysqlTable)
|
|
45
|
+
const accounts = getAccountsSchema(mysqlTable)
|
|
46
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable)
|
|
47
|
+
const userRoles = getUserRolesSchema(mysqlTable)
|
|
48
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable)
|
|
49
|
+
const contentContributions = getContentContributionsSchema(mysqlTable)
|
|
50
|
+
const contentResource = getContentResourceSchema(mysqlTable)
|
|
51
|
+
return relations(users, ({ many }) => ({
|
|
52
|
+
accounts: many(accounts),
|
|
53
|
+
communicationPreferences: many(communicationPreferences),
|
|
54
|
+
userRoles: many(userRoles),
|
|
55
|
+
userPermissions: many(userPermissions),
|
|
56
|
+
contributions: many(contentContributions),
|
|
57
|
+
createdContent: many(contentResource),
|
|
58
|
+
}))
|
|
35
59
|
}
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
varchar,
|
|
6
6
|
} from 'drizzle-orm/mysql-core'
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export function getVerificationTokensSchema(mysqlTable: MySqlTableFn) {
|
|
9
|
+
return mysqlTable(
|
|
10
10
|
'verificationToken',
|
|
11
11
|
{
|
|
12
12
|
identifier: varchar('identifier', { length: 255 }).notNull(),
|
|
@@ -21,6 +21,4 @@ export const getVerificationTokensSchema = (mysqlTable: MySqlTableFn) => {
|
|
|
21
21
|
pk: primaryKey({ columns: [vt.identifier, vt.token] }),
|
|
22
22
|
}),
|
|
23
23
|
)
|
|
24
|
-
|
|
25
|
-
return { verificationTokens }
|
|
26
24
|
}
|