@coursebuilder/adapter-drizzle 0.0.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ICL7XZ2Y.js → chunk-27KREOQW.js} +4 -4
- package/dist/{chunk-KVN3JV7C.js → chunk-44VDBYFU.js} +6 -6
- package/dist/{chunk-VEFCDI73.js → chunk-75V6F7LZ.js} +12 -12
- package/dist/{chunk-SQR6UWVO.js → chunk-7LAAAEVE.js} +165 -11
- package/dist/{chunk-TA6VLEV5.js → chunk-AFQGYW7Z.js} +4 -4
- package/dist/{chunk-US2EXVMI.js → chunk-CPE4P26C.js} +4 -4
- package/dist/chunk-GVURJJRV.js +4679 -0
- package/dist/{chunk-VZABQCFH.js → chunk-IN6G6MTW.js} +4 -4
- package/dist/{chunk-4HDU7QIB.js → chunk-ISURSRBK.js} +345 -324
- package/dist/{chunk-AIDEJDKJ.js → chunk-JKRFXYAR.js} +4 -4
- package/dist/{chunk-KI47TR7F.js → chunk-L2TQQYG4.js} +4 -4
- package/dist/{chunk-UY3DVPP3.js → chunk-LSOPFMDB.js} +4 -4
- package/dist/{chunk-PFN4YUQZ.js → chunk-MYRB6GLJ.js} +4 -3
- package/dist/chunk-NZDLUQWP.js +44 -0
- package/dist/{chunk-22KIKVBY.js → chunk-O2KKII62.js} +163 -10
- package/dist/{chunk-MBQ3TMHH.js → chunk-OIUOQ3TT.js} +4 -4
- package/dist/chunk-QZOBGJSV.js +78 -0
- package/dist/chunk-RVYJDDZD.js +75 -0
- package/dist/chunk-V6QEDDFG.js +49 -0
- package/dist/{chunk-FRNVLW7N.js → chunk-Y34AIPU7.js} +34 -303
- package/dist/index.js +21 -17
- package/dist/lib/mysql/index.cjs +5896 -1367
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.ts +325 -129
- package/dist/lib/mysql/index.js +19 -15
- package/dist/lib/mysql/schemas/auth/accounts.cjs +73 -57
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +7 -1
- package/dist/lib/mysql/schemas/auth/permissions.cjs +9 -98
- package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +1 -3
- package/dist/lib/mysql/schemas/auth/permissions.js +1 -3
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +64 -43
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +8 -1
- package/dist/lib/mysql/schemas/auth/roles.cjs +63 -46
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +7 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs +63 -47
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +8 -2
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +97 -82
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +7 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +65 -48
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +7 -1
- package/dist/lib/mysql/schemas/auth/users.cjs +233 -132
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.ts +2 -1
- package/dist/lib/mysql/schemas/auth/users.js +7 -1
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -4
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +6 -6
- package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/price.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/product.cjs +2 -2
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.ts +3 -3
- package/dist/lib/mysql/schemas/commerce/product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +10 -10
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +15 -15
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +320 -21
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +12 -4
- package/dist/lib/mysql/schemas/commerce/purchase.js +11 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +130 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +101 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js.map +1 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +90 -72
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +7 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +94 -76
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +7 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +68 -53
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +7 -1
- package/dist/lib/mysql/schemas/content/content-resource.cjs +81 -103
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +0 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +7 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs +11 -102
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +1 -3
- package/dist/lib/mysql/schemas/content/contribution-types.js +1 -3
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +3 -3
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +9 -9
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/dist/lib/mysql/utils.cjs +51 -0
- package/dist/lib/mysql/utils.cjs.map +1 -0
- package/dist/lib/mysql/utils.d.ts +12 -0
- package/dist/lib/mysql/utils.js +29 -0
- package/dist/lib/mysql/utils.js.map +1 -0
- package/dist/lib/pg.cjs +4289 -9
- package/dist/lib/pg.cjs.map +1 -1
- package/dist/lib/pg.d.ts +91 -0
- package/dist/lib/pg.js +2 -1
- package/dist/lib/sqlite.cjs +4285 -8
- package/dist/lib/sqlite.cjs.map +1 -1
- package/dist/lib/sqlite.js +2 -1
- package/package.json +7 -5
- package/src/lib/mysql/index.ts +688 -34
- package/src/lib/mysql/schemas/auth/accounts.ts +5 -1
- package/src/lib/mysql/schemas/auth/permissions.ts +1 -3
- package/src/lib/mysql/schemas/auth/role-permissions.ts +2 -0
- package/src/lib/mysql/schemas/auth/roles.ts +1 -1
- package/src/lib/mysql/schemas/auth/sessions.ts +5 -1
- package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
- package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
- package/src/lib/mysql/schemas/auth/users.ts +23 -6
- package/src/lib/mysql/schemas/commerce/coupon.ts +3 -3
- package/src/lib/mysql/schemas/commerce/merchant-account.ts +2 -2
- package/src/lib/mysql/schemas/commerce/merchant-charge.ts +2 -2
- package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -2
- package/src/lib/mysql/schemas/commerce/merchant-price.ts +2 -2
- package/src/lib/mysql/schemas/commerce/merchant-product.ts +2 -2
- package/src/lib/mysql/schemas/commerce/price.ts +2 -2
- package/src/lib/mysql/schemas/commerce/product.ts +2 -2
- package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +6 -6
- package/src/lib/mysql/schemas/commerce/purchase.ts +49 -3
- package/src/lib/mysql/schemas/commerce/upgradable-products.ts +58 -0
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +3 -0
- package/src/lib/mysql/schemas/content/content-contributions.ts +3 -0
- package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
- package/src/lib/mysql/schemas/content/content-resource.ts +1 -2
- package/src/lib/mysql/schemas/content/contribution-types.ts +1 -4
- package/src/lib/mysql/schemas/content/resource-progress.ts +3 -3
- package/src/lib/mysql/utils.ts +23 -0
- package/src/lib/pg.ts +298 -16
- package/src/lib/sqlite.ts +290 -15
- package/dist/chunk-BRGTUNY2.js +0 -78
|
@@ -1,90 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getResourceProgressSchema
|
|
3
|
-
} from "./chunk-UY3DVPP3.js";
|
|
4
|
-
import {
|
|
5
|
-
getPurchaseUserTransferSchema
|
|
6
|
-
} from "./chunk-VEFCDI73.js";
|
|
7
|
-
import {
|
|
8
|
-
getPurchaseSchema
|
|
9
|
-
} from "./chunk-BRGTUNY2.js";
|
|
10
|
-
import {
|
|
11
|
-
getMerchantChargeSchema
|
|
12
|
-
} from "./chunk-ICL7XZ2Y.js";
|
|
13
|
-
import {
|
|
14
|
-
getMerchantCouponSchema
|
|
15
|
-
} from "./chunk-JD4KFACE.js";
|
|
16
|
-
import {
|
|
17
|
-
getMerchantCustomerSchema
|
|
18
|
-
} from "./chunk-MBQ3TMHH.js";
|
|
19
|
-
import {
|
|
20
|
-
getMerchantPriceSchema
|
|
21
|
-
} from "./chunk-KI47TR7F.js";
|
|
22
|
-
import {
|
|
23
|
-
getMerchantProductSchema
|
|
24
|
-
} from "./chunk-AIDEJDKJ.js";
|
|
25
|
-
import {
|
|
26
|
-
getMerchantSessionSchema
|
|
27
|
-
} from "./chunk-H4MXNDWO.js";
|
|
28
|
-
import {
|
|
29
|
-
getPriceSchema
|
|
30
|
-
} from "./chunk-TA6VLEV5.js";
|
|
31
|
-
import {
|
|
32
|
-
getProductSchema
|
|
33
|
-
} from "./chunk-US2EXVMI.js";
|
|
34
|
-
import {
|
|
35
|
-
getSessionRelationsSchema,
|
|
36
|
-
getSessionsSchema
|
|
37
|
-
} from "./chunk-PFN4YUQZ.js";
|
|
38
|
-
import {
|
|
39
|
-
getVerificationTokensSchema
|
|
40
|
-
} from "./chunk-TMQIGK3N.js";
|
|
41
|
-
import {
|
|
42
|
-
getCouponSchema
|
|
43
|
-
} from "./chunk-KVN3JV7C.js";
|
|
44
|
-
import {
|
|
45
|
-
getMerchantAccountSchema
|
|
46
|
-
} from "./chunk-VZABQCFH.js";
|
|
47
|
-
import {
|
|
48
|
-
getAccountsRelationsSchema,
|
|
49
|
-
getAccountsSchema,
|
|
50
|
-
getCommunicationPreferencesRelationsSchema,
|
|
51
|
-
getCommunicationPreferencesSchema,
|
|
52
|
-
getContentContributionRelationsSchema,
|
|
53
|
-
getContentContributionsSchema,
|
|
54
|
-
getContentResourceRelationsSchema,
|
|
55
|
-
getContentResourceResourceRelationsSchema,
|
|
56
|
-
getContentResourceResourceSchema,
|
|
57
|
-
getContentResourceSchema,
|
|
58
|
-
getContributionTypesRelationsSchema,
|
|
59
|
-
getContributionTypesSchema,
|
|
60
|
-
getPermissionsRelationsSchema,
|
|
61
|
-
getPermissionsSchema,
|
|
62
|
-
getRolePermissionsRelationsSchema,
|
|
63
|
-
getRolePermissionsSchema,
|
|
64
|
-
getRolesRelationsSchema,
|
|
65
|
-
getRolesSchema,
|
|
66
|
-
getUserPermissionsRelationsSchema,
|
|
67
|
-
getUserPermissionsSchema,
|
|
68
|
-
getUserRolesRelationsSchema,
|
|
69
|
-
getUserRolesSchema,
|
|
70
|
-
getUsersRelationsSchema,
|
|
71
|
-
getUsersSchema
|
|
72
|
-
} from "./chunk-4HDU7QIB.js";
|
|
73
|
-
import {
|
|
74
|
-
getCommunicationChannelSchema
|
|
75
|
-
} from "./chunk-6CBAFOL3.js";
|
|
76
|
-
import {
|
|
77
|
-
getCommunicationPreferenceTypesSchema
|
|
78
|
-
} from "./chunk-SFJM6FKE.js";
|
|
79
1
|
import {
|
|
80
2
|
__name
|
|
81
3
|
} from "./chunk-VNI36MMC.js";
|
|
82
4
|
|
|
83
|
-
// src/lib/mysql/index.ts
|
|
84
|
-
import { addSeconds, isAfter } from "date-fns";
|
|
85
|
-
import { and, eq, sql } from "drizzle-orm";
|
|
86
|
-
import { mysqlTable as defaultMySqlTableFn } from "drizzle-orm/mysql-core";
|
|
87
|
-
|
|
88
5
|
// ../core/dist/chunk-DFHEFTJZ.js
|
|
89
6
|
var __defProp = Object.defineProperty;
|
|
90
7
|
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", {
|
|
@@ -4179,228 +4096,42 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4179
4096
|
ZodError
|
|
4180
4097
|
});
|
|
4181
4098
|
|
|
4182
|
-
// ../core/dist/schemas/
|
|
4183
|
-
var
|
|
4099
|
+
// ../core/dist/schemas/content-resource-schema.js
|
|
4100
|
+
var ContentResourceResourceSchema = z.object({
|
|
4101
|
+
resourceId: z.string(),
|
|
4102
|
+
resourceOfId: z.string(),
|
|
4103
|
+
position: z.number().default(0),
|
|
4104
|
+
metadata: z.record(z.string(), z.any()).default({}).nullable(),
|
|
4105
|
+
createdAt: z.date().nullable(),
|
|
4106
|
+
updatedAt: z.date().nullable(),
|
|
4107
|
+
deletedAt: z.date().nullable(),
|
|
4108
|
+
resource: z.any()
|
|
4109
|
+
});
|
|
4110
|
+
var ContentResourceSchema = z.object({
|
|
4184
4111
|
id: z.string(),
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
transcriptWithScreenshots: z.string().optional().nullable(),
|
|
4193
|
-
srt: z.string().optional().nullable(),
|
|
4194
|
-
wordLevelSrt: z.string().optional().nullable(),
|
|
4195
|
-
state: z.enum([
|
|
4196
|
-
"new",
|
|
4197
|
-
"processing",
|
|
4198
|
-
"preparing",
|
|
4199
|
-
"ready",
|
|
4200
|
-
"errored"
|
|
4201
|
-
])
|
|
4112
|
+
type: z.string(),
|
|
4113
|
+
createdById: z.string(),
|
|
4114
|
+
fields: z.record(z.string(), z.any()).default({}).nullable().optional(),
|
|
4115
|
+
createdAt: z.date().nullable(),
|
|
4116
|
+
updatedAt: z.date().nullable(),
|
|
4117
|
+
deletedAt: z.date().nullable(),
|
|
4118
|
+
resources: z.array(ContentResourceResourceSchema).default([]).nullable()
|
|
4202
4119
|
});
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
rolesRelations: getRolesRelationsSchema(mysqlTable),
|
|
4215
|
-
sessions: getSessionsSchema(mysqlTable),
|
|
4216
|
-
sessionsRelations: getSessionRelationsSchema(mysqlTable),
|
|
4217
|
-
userPermissions: getUserPermissionsSchema(mysqlTable),
|
|
4218
|
-
userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable),
|
|
4219
|
-
userRoles: getUserRolesSchema(mysqlTable),
|
|
4220
|
-
userRolesRelations: getUserRolesRelationsSchema(mysqlTable),
|
|
4221
|
-
users: getUsersSchema(mysqlTable),
|
|
4222
|
-
usersRelations: getUsersRelationsSchema(mysqlTable),
|
|
4223
|
-
verificationTokens: getVerificationTokensSchema(mysqlTable),
|
|
4224
|
-
coupon: getCouponSchema(mysqlTable),
|
|
4225
|
-
merchantAccount: getMerchantAccountSchema(mysqlTable),
|
|
4226
|
-
merchantCharge: getMerchantChargeSchema(mysqlTable),
|
|
4227
|
-
merchantCoupon: getMerchantCouponSchema(mysqlTable),
|
|
4228
|
-
merchantCustomer: getMerchantCustomerSchema(mysqlTable),
|
|
4229
|
-
merchantPrice: getMerchantPriceSchema(mysqlTable),
|
|
4230
|
-
merchantProduct: getMerchantProductSchema(mysqlTable),
|
|
4231
|
-
merchantSession: getMerchantSessionSchema(mysqlTable),
|
|
4232
|
-
price: getPriceSchema(mysqlTable),
|
|
4233
|
-
product: getProductSchema(mysqlTable),
|
|
4234
|
-
purchase: getPurchaseSchema(mysqlTable),
|
|
4235
|
-
purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
|
|
4236
|
-
communicationChannel: getCommunicationChannelSchema(mysqlTable),
|
|
4237
|
-
communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
|
|
4238
|
-
communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
|
|
4239
|
-
communicationPreferencesRelations: getCommunicationPreferencesRelationsSchema(mysqlTable),
|
|
4240
|
-
contentContributions: getContentContributionsSchema(mysqlTable),
|
|
4241
|
-
contentContributionRelations: getContentContributionRelationsSchema(mysqlTable),
|
|
4242
|
-
contentResource: getContentResourceSchema(mysqlTable),
|
|
4243
|
-
contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
|
|
4244
|
-
contentResourceResource: getContentResourceResourceSchema(mysqlTable),
|
|
4245
|
-
contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
|
|
4246
|
-
contributionTypes: getContributionTypesSchema(mysqlTable),
|
|
4247
|
-
contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
|
|
4248
|
-
resourceProgress: getResourceProgressSchema(mysqlTable)
|
|
4249
|
-
};
|
|
4250
|
-
}
|
|
4251
|
-
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
4252
|
-
function createTables(mySqlTable) {
|
|
4253
|
-
return getCourseBuilderSchema(mySqlTable);
|
|
4254
|
-
}
|
|
4255
|
-
__name(createTables, "createTables");
|
|
4256
|
-
function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
|
|
4257
|
-
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchase, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, price, product } = createTables(tableFn);
|
|
4258
|
-
return {
|
|
4259
|
-
async updateContentResourceFields(options) {
|
|
4260
|
-
if (!options.id) {
|
|
4261
|
-
throw new Error("No content resource id.");
|
|
4262
|
-
}
|
|
4263
|
-
const currentResource = await client.select().from(contentResource).where(eq(contentResource.id, options.id)).then((res) => res[0]);
|
|
4264
|
-
await client.update(contentResource).set({
|
|
4265
|
-
fields: {
|
|
4266
|
-
...currentResource.fields,
|
|
4267
|
-
...options.fields
|
|
4268
|
-
}
|
|
4269
|
-
}).where(eq(contentResource.id, options.id));
|
|
4270
|
-
return await client.select().from(contentResource).where(eq(contentResource.id, options.id)).then((res) => res[0]);
|
|
4271
|
-
},
|
|
4272
|
-
async getVideoResource(id) {
|
|
4273
|
-
if (!id) {
|
|
4274
|
-
throw new Error("videoResourceId is required");
|
|
4275
|
-
}
|
|
4276
|
-
const query = sql`
|
|
4277
|
-
SELECT
|
|
4278
|
-
id as id,
|
|
4279
|
-
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
4280
|
-
CAST(createdAt AS DATETIME) as createdAt,
|
|
4281
|
-
JSON_EXTRACT (${contentResource.fields}, "$.state") AS state,
|
|
4282
|
-
JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
|
|
4283
|
-
JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
|
|
4284
|
-
JSON_EXTRACT (${contentResource.fields}, "$.muxAssetId") AS muxAssetId,
|
|
4285
|
-
JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript
|
|
4286
|
-
FROM
|
|
4287
|
-
${contentResource}
|
|
4288
|
-
WHERE
|
|
4289
|
-
type = 'videoResource'
|
|
4290
|
-
AND (id = ${id});
|
|
4291
|
-
|
|
4292
|
-
`;
|
|
4293
|
-
return client.execute(query).then((result) => {
|
|
4294
|
-
const parsedResource = VideoResourceSchema.safeParse(result.rows[0]);
|
|
4295
|
-
return parsedResource.success ? parsedResource.data : null;
|
|
4296
|
-
}).catch((error) => {
|
|
4297
|
-
console.error(error);
|
|
4298
|
-
return error;
|
|
4299
|
-
});
|
|
4300
|
-
},
|
|
4301
|
-
async createContentResource(data) {
|
|
4302
|
-
const id = data.id || crypto.randomUUID();
|
|
4303
|
-
await client.insert(contentResource).values({
|
|
4304
|
-
...data,
|
|
4305
|
-
id
|
|
4306
|
-
});
|
|
4307
|
-
return await client.select().from(contentResource).where(eq(contentResource.id, id)).then((res) => res[0]);
|
|
4308
|
-
},
|
|
4309
|
-
async getContentResource(data) {
|
|
4310
|
-
return await client.select().from(contentResource).where(eq(contentResource.id, data)).then((res) => res[0]) ?? null;
|
|
4311
|
-
},
|
|
4312
|
-
async createUser(data) {
|
|
4313
|
-
const id = crypto.randomUUID();
|
|
4314
|
-
await client.insert(users).values({
|
|
4315
|
-
...data,
|
|
4316
|
-
id
|
|
4317
|
-
});
|
|
4318
|
-
return await client.select().from(users).where(eq(users.id, id)).then((res) => res[0]);
|
|
4319
|
-
},
|
|
4320
|
-
async getUser(data) {
|
|
4321
|
-
return await client.select().from(users).where(eq(users.id, data)).then((res) => res[0]) ?? null;
|
|
4322
|
-
},
|
|
4323
|
-
async getUserByEmail(data) {
|
|
4324
|
-
return await client.select().from(users).where(eq(users.email, data)).then((res) => res[0]) ?? null;
|
|
4325
|
-
},
|
|
4326
|
-
async createSession(data) {
|
|
4327
|
-
await client.insert(sessions).values(data);
|
|
4328
|
-
return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
4329
|
-
},
|
|
4330
|
-
async getSessionAndUser(data) {
|
|
4331
|
-
return await client.select({
|
|
4332
|
-
session: sessions,
|
|
4333
|
-
user: users
|
|
4334
|
-
}).from(sessions).where(eq(sessions.sessionToken, data)).innerJoin(users, eq(users.id, sessions.userId)).then((res) => res[0]) ?? null;
|
|
4335
|
-
},
|
|
4336
|
-
async updateUser(data) {
|
|
4337
|
-
if (!data.id) {
|
|
4338
|
-
throw new Error("No user id.");
|
|
4339
|
-
}
|
|
4340
|
-
await client.update(users).set(data).where(eq(users.id, data.id));
|
|
4341
|
-
return await client.select().from(users).where(eq(users.id, data.id)).then((res) => res[0]);
|
|
4342
|
-
},
|
|
4343
|
-
async updateSession(data) {
|
|
4344
|
-
await client.update(sessions).set(data).where(eq(sessions.sessionToken, data.sessionToken));
|
|
4345
|
-
return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
4346
|
-
},
|
|
4347
|
-
async linkAccount(rawAccount) {
|
|
4348
|
-
await client.insert(accounts).values(rawAccount);
|
|
4349
|
-
},
|
|
4350
|
-
async getUserByAccount(account) {
|
|
4351
|
-
const dbAccount = await client.select().from(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider))).leftJoin(users, eq(accounts.userId, users.id)).then((res) => res[0]) ?? null;
|
|
4352
|
-
if (!dbAccount) {
|
|
4353
|
-
return null;
|
|
4354
|
-
}
|
|
4355
|
-
return dbAccount.user;
|
|
4356
|
-
},
|
|
4357
|
-
async deleteSession(sessionToken) {
|
|
4358
|
-
const session = await client.select().from(sessions).where(eq(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
|
|
4359
|
-
await client.delete(sessions).where(eq(sessions.sessionToken, sessionToken));
|
|
4360
|
-
return session;
|
|
4361
|
-
},
|
|
4362
|
-
async createVerificationToken(token) {
|
|
4363
|
-
await client.insert(verificationTokens).values(token);
|
|
4364
|
-
return await client.select().from(verificationTokens).where(eq(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
|
|
4365
|
-
},
|
|
4366
|
-
async useVerificationToken(token) {
|
|
4367
|
-
try {
|
|
4368
|
-
const deletedToken = await client.select().from(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
|
|
4369
|
-
if (deletedToken?.createdAt) {
|
|
4370
|
-
const TIMEOUT_IN_SECONDS = 90;
|
|
4371
|
-
const expireMultipleClicks = addSeconds(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
4372
|
-
const now = /* @__PURE__ */ new Date();
|
|
4373
|
-
if (isAfter(expireMultipleClicks, now)) {
|
|
4374
|
-
const { id: _, ...verificationToken } = token;
|
|
4375
|
-
return deletedToken;
|
|
4376
|
-
} else {
|
|
4377
|
-
await client.delete(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token)));
|
|
4378
|
-
return deletedToken;
|
|
4379
|
-
}
|
|
4380
|
-
}
|
|
4381
|
-
return deletedToken;
|
|
4382
|
-
} catch (err) {
|
|
4383
|
-
throw new Error("No verification token found.");
|
|
4384
|
-
}
|
|
4385
|
-
},
|
|
4386
|
-
async deleteUser(id) {
|
|
4387
|
-
const user = await client.select().from(users).where(eq(users.id, id)).then((res) => res[0] ?? null);
|
|
4388
|
-
await client.delete(users).where(eq(users.id, id));
|
|
4389
|
-
await client.delete(sessions).where(eq(sessions.userId, id));
|
|
4390
|
-
await client.delete(accounts).where(eq(accounts.userId, id));
|
|
4391
|
-
return user;
|
|
4392
|
-
},
|
|
4393
|
-
async unlinkAccount(account) {
|
|
4394
|
-
await client.delete(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));
|
|
4395
|
-
return void 0;
|
|
4396
|
-
}
|
|
4397
|
-
};
|
|
4398
|
-
}
|
|
4399
|
-
__name(mySqlDrizzleAdapter, "mySqlDrizzleAdapter");
|
|
4120
|
+
var ResourceStateSchema = z.union([
|
|
4121
|
+
z.literal("draft"),
|
|
4122
|
+
z.literal("published"),
|
|
4123
|
+
z.literal("archived"),
|
|
4124
|
+
z.literal("deleted")
|
|
4125
|
+
]);
|
|
4126
|
+
var ResourceVisibilitySchema = z.union([
|
|
4127
|
+
z.literal("public"),
|
|
4128
|
+
z.literal("private"),
|
|
4129
|
+
z.literal("unlisted")
|
|
4130
|
+
]);
|
|
4400
4131
|
|
|
4401
4132
|
export {
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4133
|
+
z,
|
|
4134
|
+
ContentResourceResourceSchema,
|
|
4135
|
+
ContentResourceSchema
|
|
4405
4136
|
};
|
|
4406
|
-
//# sourceMappingURL=chunk-
|
|
4137
|
+
//# sourceMappingURL=chunk-Y34AIPU7.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pgDrizzleAdapter
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7LAAAEVE.js";
|
|
4
4
|
import {
|
|
5
5
|
SQLiteDrizzleAdapter
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-O2KKII62.js";
|
|
7
7
|
import "./chunk-GFUUJRX7.js";
|
|
8
8
|
import {
|
|
9
9
|
createTables,
|
|
10
10
|
mySqlDrizzleAdapter
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-GVURJJRV.js";
|
|
12
|
+
import "./chunk-LSOPFMDB.js";
|
|
13
|
+
import "./chunk-75V6F7LZ.js";
|
|
14
|
+
import "./chunk-RVYJDDZD.js";
|
|
15
|
+
import "./chunk-IN6G6MTW.js";
|
|
16
16
|
import "./chunk-JD4KFACE.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-PFN4YUQZ.js";
|
|
17
|
+
import "./chunk-OIUOQ3TT.js";
|
|
18
|
+
import "./chunk-L2TQQYG4.js";
|
|
19
|
+
import "./chunk-JKRFXYAR.js";
|
|
20
|
+
import "./chunk-AFQGYW7Z.js";
|
|
21
|
+
import "./chunk-QZOBGJSV.js";
|
|
22
|
+
import "./chunk-MYRB6GLJ.js";
|
|
24
23
|
import "./chunk-TMQIGK3N.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-Y34AIPU7.js";
|
|
25
|
+
import "./chunk-ISURSRBK.js";
|
|
26
|
+
import "./chunk-V6QEDDFG.js";
|
|
27
|
+
import "./chunk-CPE4P26C.js";
|
|
28
28
|
import "./chunk-6CBAFOL3.js";
|
|
29
29
|
import "./chunk-SFJM6FKE.js";
|
|
30
|
+
import "./chunk-27KREOQW.js";
|
|
31
|
+
import "./chunk-H4MXNDWO.js";
|
|
32
|
+
import "./chunk-44VDBYFU.js";
|
|
33
|
+
import "./chunk-NZDLUQWP.js";
|
|
30
34
|
import {
|
|
31
35
|
__name
|
|
32
36
|
} from "./chunk-VNI36MMC.js";
|