@coursebuilder/server 0.1.0-canary.0.0c9beb2ae
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/LICENSE +21 -0
- package/dist/actions/checkout.d.ts +6 -0
- package/dist/actions/checkout.js +9 -0
- package/dist/actions/checkout.js.map +1 -0
- package/dist/actions/claimed.d.ts +6 -0
- package/dist/actions/claimed.js +8 -0
- package/dist/actions/claimed.js.map +1 -0
- package/dist/actions/create-magic-link.d.ts +6 -0
- package/dist/actions/create-magic-link.js +9 -0
- package/dist/actions/create-magic-link.js.map +1 -0
- package/dist/actions/index.d.ts +11 -0
- package/dist/actions/index.js +18 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/prices-coupon-for-code.d.ts +6 -0
- package/dist/actions/prices-coupon-for-code.js +63 -0
- package/dist/actions/prices-coupon-for-code.js.map +1 -0
- package/dist/actions/prices-formatted.d.ts +6 -0
- package/dist/actions/prices-formatted.js +8 -0
- package/dist/actions/prices-formatted.js.map +1 -0
- package/dist/actions/process-refund.d.ts +1 -0
- package/dist/actions/process-refund.js +8 -0
- package/dist/actions/process-refund.js.map +1 -0
- package/dist/actions/redeem.d.ts +1 -0
- package/dist/actions/redeem.js +8 -0
- package/dist/actions/redeem.js.map +1 -0
- package/dist/actions/transfer-purchase.d.ts +1 -0
- package/dist/actions/transfer-purchase.js +8 -0
- package/dist/actions/transfer-purchase.js.map +1 -0
- package/dist/actions/user-lookup.d.ts +6 -0
- package/dist/actions/user-lookup.js +9 -0
- package/dist/actions/user-lookup.js.map +1 -0
- package/dist/adapter-BtDS6LDw.d.ts +9 -0
- package/dist/chunk-22AMOZYZ.js +67 -0
- package/dist/chunk-22AMOZYZ.js.map +1 -0
- package/dist/chunk-4EQQSW57.js +32 -0
- package/dist/chunk-4EQQSW57.js.map +1 -0
- package/dist/chunk-4LZZLN6T.js +52 -0
- package/dist/chunk-4LZZLN6T.js.map +1 -0
- package/dist/chunk-4QQA3TC2.js +29 -0
- package/dist/chunk-4QQA3TC2.js.map +1 -0
- package/dist/chunk-4TSEPUSC.js +160 -0
- package/dist/chunk-4TSEPUSC.js.map +1 -0
- package/dist/chunk-5O4UO4IR.js +93 -0
- package/dist/chunk-5O4UO4IR.js.map +1 -0
- package/dist/chunk-7FCQOLKL.js +26 -0
- package/dist/chunk-7FCQOLKL.js.map +1 -0
- package/dist/chunk-AZLUMIIF.js +8 -0
- package/dist/chunk-AZLUMIIF.js.map +1 -0
- package/dist/chunk-E6HV6TNI.js +38 -0
- package/dist/chunk-E6HV6TNI.js.map +1 -0
- package/dist/chunk-ECNJPNPU.js +54 -0
- package/dist/chunk-ECNJPNPU.js.map +1 -0
- package/dist/chunk-F3KUYN5I.js +111 -0
- package/dist/chunk-F3KUYN5I.js.map +1 -0
- package/dist/chunk-G63YAJF2.js +107 -0
- package/dist/chunk-G63YAJF2.js.map +1 -0
- package/dist/chunk-JFR7XO72.js +7 -0
- package/dist/chunk-JFR7XO72.js.map +1 -0
- package/dist/chunk-KNC7QVGZ.js +26 -0
- package/dist/chunk-KNC7QVGZ.js.map +1 -0
- package/dist/chunk-ODSSRMD2.js +270 -0
- package/dist/chunk-ODSSRMD2.js.map +1 -0
- package/dist/chunk-VEKYIR7I.js +26 -0
- package/dist/chunk-VEKYIR7I.js.map +1 -0
- package/dist/chunk-W7YAT4NR.js +12 -0
- package/dist/chunk-W7YAT4NR.js.map +1 -0
- package/dist/chunk-WGAPYIUP.js +56 -0
- package/dist/chunk-WGAPYIUP.js.map +1 -0
- package/dist/chunk-WYNH2AWD.js +7 -0
- package/dist/chunk-WYNH2AWD.js.map +1 -0
- package/dist/chunk-Y5X5J55Z.js +384 -0
- package/dist/chunk-Y5X5J55Z.js.map +1 -0
- package/dist/chunk-YFLGJIMA.js +216 -0
- package/dist/chunk-YFLGJIMA.js.map +1 -0
- package/dist/chunk-ZFZNN4E5.js +7 -0
- package/dist/chunk-ZFZNN4E5.js.map +1 -0
- package/dist/create-inngest-middleware.d.ts +635 -0
- package/dist/create-inngest-middleware.js +12 -0
- package/dist/create-inngest-middleware.js.map +1 -0
- package/dist/http-router.d.ts +20 -0
- package/dist/http-router.js +24 -0
- package/dist/http-router.js.map +1 -0
- package/dist/http.d.ts +38 -0
- package/dist/http.js +32 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +365 -0
- package/dist/index.js.map +1 -0
- package/dist/magic-string.es-ENO43NON.js +1389 -0
- package/dist/magic-string.es-ENO43NON.js.map +1 -0
- package/dist/runtime/actions.d.ts +5 -0
- package/dist/runtime/actions.js +8 -0
- package/dist/runtime/actions.js.map +1 -0
- package/dist/runtime/assert.d.ts +15 -0
- package/dist/runtime/assert.js +8 -0
- package/dist/runtime/assert.js.map +1 -0
- package/dist/runtime/cookie.d.ts +8 -0
- package/dist/runtime/cookie.js +8 -0
- package/dist/runtime/cookie.js.map +1 -0
- package/dist/runtime/env.d.ts +9 -0
- package/dist/runtime/env.js +11 -0
- package/dist/runtime/env.js.map +1 -0
- package/dist/runtime/env.test.d.ts +2 -0
- package/dist/runtime/env.test.js +14956 -0
- package/dist/runtime/env.test.js.map +1 -0
- package/dist/runtime/init.d.ts +26 -0
- package/dist/runtime/init.js +14 -0
- package/dist/runtime/init.js.map +1 -0
- package/dist/runtime/logger.d.ts +4 -0
- package/dist/runtime/logger.js +10 -0
- package/dist/runtime/logger.js.map +1 -0
- package/dist/runtime/merge.d.ts +4 -0
- package/dist/runtime/merge.js +8 -0
- package/dist/runtime/merge.js.map +1 -0
- package/dist/runtime/providers.d.ts +21 -0
- package/dist/runtime/providers.js +9 -0
- package/dist/runtime/providers.js.map +1 -0
- package/dist/runtime/web.d.ts +29 -0
- package/dist/runtime/web.js +16 -0
- package/dist/runtime/web.js.map +1 -0
- package/package.json +65 -0
- package/src/actions/actions.test.ts +232 -0
- package/src/actions/checkout.ts +160 -0
- package/src/actions/claimed.ts +40 -0
- package/src/actions/create-magic-link.ts +78 -0
- package/src/actions/index.ts +401 -0
- package/src/actions/prices-coupon-for-code.ts +91 -0
- package/src/actions/prices-formatted.ts +313 -0
- package/src/actions/process-refund.ts +2 -0
- package/src/actions/redeem.ts +2 -0
- package/src/actions/transfer-purchase.ts +2 -0
- package/src/actions/user-lookup.ts +37 -0
- package/src/adapter.ts +28 -0
- package/src/create-inngest-middleware.ts +157 -0
- package/src/http-actions.ts +29 -0
- package/src/http-router.ts +79 -0
- package/src/http.test.ts +46 -0
- package/src/http.ts +83 -0
- package/src/index.test.ts +21 -0
- package/src/index.ts +44 -0
- package/src/mock-adapter.ts +398 -0
- package/src/mock-payment-provider.ts +56 -0
- package/src/resource-chat.ts +371 -0
- package/src/runtime/actions.ts +25 -0
- package/src/runtime/assert.ts +55 -0
- package/src/runtime/cookie.ts +12 -0
- package/src/runtime/env.test.ts +49 -0
- package/src/runtime/env.ts +63 -0
- package/src/runtime/init.ts +112 -0
- package/src/runtime/logger.ts +6 -0
- package/src/runtime/merge.ts +25 -0
- package/src/runtime/providers.ts +38 -0
- package/src/runtime/web.ts +199 -0
- package/src/streaming-chat-prompt-executor.ts +43 -0
- package/src/type-contracts.test.ts +167 -0
- package/src/web-body-parse.test.ts +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/prices-formatted.ts"],"sourcesContent":["import { isAfter } from 'date-fns'\nimport { z } from 'zod'\n\nimport { formatPricesForProduct } from '@coursebuilder/commerce/format-prices-for-product'\nimport type { ServerAdapter } from '../adapter'\nimport { Coupon, Purchase } from '@coursebuilder/core/schemas'\nimport { PricingFormattedInputSchema } from '@coursebuilder/core/schemas/pricing-formatted-input-schema'\nimport type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\nimport { find } from '@coursebuilder/nodash'\n\nimport type { Cookie } from '../runtime/cookie'\n\nconst checkForAnyAvailableUpgrades = async ({\n\tupgradeFromPurchaseId,\n\tproductId,\n\tpurchases,\n\tcourseBuilderAdapter,\n}: {\n\tupgradeFromPurchaseId: string | undefined\n\tproductId: string\n\tpurchases: Array<{ id: string; productId: string; status: string }>\n\tcountry: string\n\tcourseBuilderAdapter: ServerAdapter\n}) => {\n\tif (upgradeFromPurchaseId) return upgradeFromPurchaseId\n\n\tconst validPurchases = getValidPurchases(purchases)\n\tconst productIdsAlreadyPurchased = validPurchases.map(\n\t\t(purchase) => purchase.productId,\n\t)\n\n\tconst potentialUpgrades =\n\t\tawait courseBuilderAdapter.availableUpgradesForProduct(\n\t\t\tvalidPurchases,\n\t\t\tproductId,\n\t\t)\n\n\ttype AvailableUpgrade = Awaited<\n\t\tReturnType<typeof courseBuilderAdapter.availableUpgradesForProduct>\n\t>[0]\n\t// filter out potential upgrades that have already been purchased\n\tconst availableUpgrades = potentialUpgrades.filter<AvailableUpgrade>(\n\t\t(\n\t\t\tavailableUpgrade: AvailableUpgrade,\n\t\t): availableUpgrade is AvailableUpgrade => {\n\t\t\treturn !productIdsAlreadyPurchased.includes(\n\t\t\t\tavailableUpgrade.upgradableTo.id,\n\t\t\t)\n\t\t},\n\t)\n\n\treturn find(validPurchases, (purchase) => {\n\t\tconst upgradeProductIds = availableUpgrades.map(\n\t\t\t(upgrade) => upgrade.upgradableFrom.id,\n\t\t)\n\t\treturn upgradeProductIds.includes(purchase.productId)\n\t})?.id\n}\n\nconst getValidPurchases = (purchases: any[]): Purchase[] => {\n\treturn purchases.filter((purchase: Purchase) =>\n\t\t['Valid', 'Restricted'].includes(purchase.status),\n\t)\n}\n\nfunction couponIsValid(coupon?: Coupon | null) {\n\tif (coupon) {\n\t\tconst unlimitedUse = coupon.maxUses === -1\n\t\tconst now = new Date()\n\t\tif (!unlimitedUse && coupon.usedCount >= coupon.maxUses) return false\n\t\tif (coupon.expires && isAfter(now, coupon.expires)) return false\n\t} else {\n\t\treturn false\n\t}\n\treturn true\n}\n\nasync function getActiveMerchantCoupon({\n\tproductId,\n\tsiteCouponId,\n\tcode,\n\tcourseBuilderAdapter,\n}: {\n\tproductId: string | undefined\n\tsiteCouponId: string | null | undefined\n\tcode: string | undefined\n\tcourseBuilderAdapter: ServerAdapter\n}) {\n\tlet activeMerchantCoupon = null\n\tlet usedCouponId\n\n\tconst defaultCoupons = productId\n\t\t? await courseBuilderAdapter.getDefaultCoupon([productId])\n\t\t: undefined\n\n\tconst defaultMerchantCoupon = defaultCoupons\n\t\t? defaultCoupons.defaultMerchantCoupon\n\t\t: null\n\n\tconst incomingCoupon = await courseBuilderAdapter.couponForIdOrCode({\n\t\tcouponId: siteCouponId,\n\t\tcode,\n\t})\n\n\tif (\n\t\t// compare the discounts if there is a coupon and site/sale running\n\t\tincomingCoupon?.merchantCoupon &&\n\t\tcouponIsValid(incomingCoupon) &&\n\t\tdefaultMerchantCoupon\n\t) {\n\t\t// use whichever coupon provides the bigger discount\n\t\tconst { merchantCoupon: incomingMerchantCoupon } = incomingCoupon\n\n\t\t// Get product price to compare actual discount amounts\n\t\tconst product = productId\n\t\t\t? await courseBuilderAdapter.getProduct(productId)\n\t\t\t: null\n\t\tconst price = product\n\t\t\t? await courseBuilderAdapter.getPriceForProduct(productId!)\n\t\t\t: null\n\t\tconst unitPrice = price?.unitAmount || 0\n\n\t\t// Calculate actual discount amounts in dollars\n\t\tconst incomingDiscountAmount =\n\t\t\tincomingMerchantCoupon.amountDiscount !== null &&\n\t\t\tincomingMerchantCoupon.amountDiscount !== undefined &&\n\t\t\tincomingMerchantCoupon.amountDiscount > 0\n\t\t\t\t? incomingMerchantCoupon.amountDiscount / 100 // Convert cents to dollars\n\t\t\t\t: (incomingMerchantCoupon.percentageDiscount ?? 0) * unitPrice\n\n\t\tconst defaultDiscountAmount =\n\t\t\tdefaultMerchantCoupon.amountDiscount !== null &&\n\t\t\tdefaultMerchantCoupon.amountDiscount !== undefined &&\n\t\t\tdefaultMerchantCoupon.amountDiscount > 0\n\t\t\t\t? defaultMerchantCoupon.amountDiscount / 100 // Convert cents to dollars\n\t\t\t\t: (defaultMerchantCoupon.percentageDiscount ?? 0) * unitPrice\n\n\t\tif (incomingDiscountAmount >= defaultDiscountAmount) {\n\t\t\tactiveMerchantCoupon = incomingMerchantCoupon\n\t\t\tusedCouponId = incomingCoupon.id\n\t\t} else {\n\t\t\tactiveMerchantCoupon = defaultMerchantCoupon\n\t\t\tusedCouponId = defaultCoupons?.defaultCoupon?.id\n\t\t}\n\t} else if (\n\t\t// if it's a coupon, use it\n\t\tincomingCoupon?.merchantCoupon &&\n\t\tcouponIsValid(incomingCoupon)\n\t) {\n\t\tactiveMerchantCoupon = incomingCoupon.merchantCoupon\n\t\tusedCouponId = incomingCoupon.id\n\t} else if (\n\t\t// if a sale is running, use that\n\t\tdefaultMerchantCoupon\n\t) {\n\t\tactiveMerchantCoupon = defaultMerchantCoupon\n\t\tusedCouponId = defaultCoupons?.defaultCoupon?.id\n\t}\n\n\tconst defaultCoupon = defaultCoupons?.defaultCoupon\n\n\treturn {\n\t\tusedCouponId,\n\t\tactiveMerchantCoupon,\n\t\t...(defaultCoupon &&\n\t\t\tdefaultCoupon.merchantCouponId === activeMerchantCoupon?.id && {\n\t\t\t\tdefaultCoupon,\n\t\t\t}),\n\t}\n}\n\nconst CheckForAvailableCouponsSchema = PricingFormattedInputSchema.pick({\n\tmerchantCoupon: true,\n\tcouponId: true,\n\tcode: true,\n\tproductId: true,\n})\ntype CheckForAvailableCoupons = z.infer<typeof CheckForAvailableCouponsSchema>\n\nconst checkForAvailableCoupons = async ({\n\tmerchantCoupon,\n\tcouponId,\n\tproductId,\n\tcourseBuilderAdapter,\n}: CheckForAvailableCoupons & {\n\tcourseBuilderAdapter: ServerAdapter\n}) => {\n\t// explicit incoming merchant coupons are honored\n\t// without checking for other potential coupons\n\t// if there is no explicit incoming merchant coupon\n\t// we check for default/global coupon or an incoming code\n\tif (merchantCoupon?.id) {\n\t\treturn {\n\t\t\tactiveMerchantCoupon: merchantCoupon,\n\t\t\tdefaultCoupon: undefined,\n\t\t}\n\t} else {\n\t\tconst { activeMerchantCoupon, defaultCoupon, usedCouponId } =\n\t\t\tawait getActiveMerchantCoupon({\n\t\t\t\tsiteCouponId: couponId,\n\t\t\t\tproductId,\n\t\t\t\tcode: undefined,\n\t\t\t\tcourseBuilderAdapter,\n\t\t\t})\n\n\t\tconst minimalDefaultCoupon = defaultCoupon && {\n\t\t\texpires: defaultCoupon.expires?.toISOString(),\n\t\t\tpercentageDiscount: defaultCoupon.percentageDiscount?.toString() || '0',\n\t\t}\n\n\t\treturn {\n\t\t\tactiveMerchantCoupon,\n\t\t\tdefaultCoupon,\n\t\t\tusedCouponId,\n\t\t}\n\t}\n}\n\nexport async function getPricesFormatted(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tconst currentUser = options.getCurrentUser\n\t\t? await options.getCurrentUser()\n\t\t: null\n\tconst {\n\t\tproductId,\n\t\tquantity = 1,\n\t\tcouponId,\n\t\tmerchantCoupon,\n\t\tupgradeFromPurchaseId: _upgradeFromPurchaseId,\n\t\tautoApplyPPP,\n\t\tuserId = currentUser?.id,\n\t} = PricingFormattedInputSchema.parse(request.body)\n\n\tif (!productId) return { status: 400, body: 'productId is required' }\n\n\tif (!options.adapter) return { status: 400, body: 'Adapter not found' }\n\n\tconst purchases = getValidPurchases(\n\t\tawait options.adapter.getPurchasesForUser(userId),\n\t)\n\n\tconst country =\n\t\trequest.headers?.['x-vercel-ip-country'] ||\n\t\trequest.body?.country ||\n\t\tprocess.env.DEFAULT_COUNTRY ||\n\t\t'US'\n\n\tlet upgradeFromPurchaseId = await checkForAnyAvailableUpgrades({\n\t\tupgradeFromPurchaseId: _upgradeFromPurchaseId,\n\t\tproductId,\n\t\tpurchases,\n\t\tcountry,\n\t\tcourseBuilderAdapter: options.adapter,\n\t})\n\n\tconst restrictedPurchase = purchases.find((purchase) => {\n\t\treturn purchase.productId === productId && purchase.status === 'Restricted'\n\t})\n\n\tif (restrictedPurchase) {\n\t\tconst validPurchase = purchases.find((purchase) => {\n\t\t\treturn purchase.productId === productId && purchase.status === 'Valid'\n\t\t})\n\n\t\tif (!validPurchase) {\n\t\t\tupgradeFromPurchaseId = restrictedPurchase.id\n\t\t}\n\t}\n\n\tconst { activeMerchantCoupon, defaultCoupon, usedCouponId } =\n\t\tawait checkForAvailableCoupons({\n\t\t\tmerchantCoupon,\n\t\t\tcouponId,\n\t\t\tproductId,\n\t\t\tcourseBuilderAdapter: options.adapter,\n\t\t})\n\tconst usedCoupon = usedCouponId\n\t\t? await options.adapter.getCoupon(usedCouponId)\n\t\t: null\n\tconst productPrices = await formatPricesForProduct({\n\t\tproductId,\n\t\tcountry,\n\t\tquantity,\n\t\tmerchantCouponId: activeMerchantCoupon?.id,\n\t\t...(upgradeFromPurchaseId && { upgradeFromPurchaseId }),\n\t\tuserId,\n\t\tautoApplyPPP,\n\t\tusedCouponId,\n\t\tctx: options.adapter,\n\t})\n\n\treturn {\n\t\tbody: {\n\t\t\t...productPrices,\n\t\t\t...(defaultCoupon && { defaultCoupon }),\n\t\t\t...(usedCoupon && {\n\t\t\t\tusedCoupon,\n\t\t\t\tusedCouponId,\n\t\t\t}),\n\t\t},\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\tcookies,\n\t}\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAGxB,SAAS,8BAA8B;AAGvC,SAAS,mCAAmC;AAM5C,SAAS,YAAY;AAIrB,IAAM,+BAA+B,OAAO;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAMM;AACL,MAAI;AAAuB,WAAO;AAElC,QAAM,iBAAiB,kBAAkB,SAAS;AAClD,QAAM,6BAA6B,eAAe;AAAA,IACjD,CAAC,aAAa,SAAS;AAAA,EACxB;AAEA,QAAM,oBACL,MAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA;AAAA,EACD;AAMD,QAAM,oBAAoB,kBAAkB;AAAA,IAC3C,CACC,qBAC0C;AAC1C,aAAO,CAAC,2BAA2B;AAAA,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A,IACA;AAAA,IACA,sBAAsB,QAAQ;AAAA,EAC/B,CAAC;AACF,QAAM,aAAa,eAChB,MAAM,QAAQ,QAAQ,UAAU,YAAY,IAC5C;AACH,QAAM,gBAAgB,MAAM,uBAAuB;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB,sBAAsB;AAAA,IACxC,GAAI,yBAAyB,EAAE,sBAAsB;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,QAAQ;AAAA,EACd,CAAC;AAED,SAAO;AAAA,IACN,MAAM;AAAA,MACL,GAAG;AAAA,MACH,GAAI,iBAAiB,EAAE,cAAc;AAAA,MACrC,GAAI,cAAc;AAAA,QACjB;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR,gBAAgB;AAAA,IACjB;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/transfer-purchase.ts"],"sourcesContent":["/** HTTP-compatible purchase transfer operation owned by the commerce engine. */\nexport { transferPurchase } from '@coursebuilder/commerce/transfer-purchase'\n"],"mappings":";AACA,SAAS,wBAAwB;","names":[]}
|
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
import * as inngest from 'inngest';
|
|
3
|
+
import { Inngest, EventSchemas, InngestMiddleware, GetFunctionInput, Handler, InngestFunction, GetEvents } from 'inngest';
|
|
4
|
+
import { S as ServerAdapter } from './adapter-BtDS6LDw.js';
|
|
5
|
+
import { CourseBuilderEmailProvider, CourseBuilderAuthConfig } from '@coursebuilder/core/auth';
|
|
6
|
+
import { CourseBuilderCoreEvents } from '@coursebuilder/core/events';
|
|
7
|
+
import { TranscriptionConfig } from '@coursebuilder/core/providers';
|
|
8
|
+
import { LlmProviderConfig } from '@coursebuilder/core/providers/openai';
|
|
9
|
+
import { PartyProviderConfig } from '@coursebuilder/core/providers/partykit';
|
|
10
|
+
import { NotificationProviderConfig } from '@coursebuilder/core/providers/slack';
|
|
11
|
+
import { PaymentsProviderConfig } from '@coursebuilder/core/types';
|
|
12
|
+
import '@coursebuilder/core/ports';
|
|
13
|
+
|
|
14
|
+
interface CoreInngestContext {
|
|
15
|
+
db: ServerAdapter;
|
|
16
|
+
siteRootUrl: string;
|
|
17
|
+
transcriptProvider: TranscriptionConfig;
|
|
18
|
+
openaiProvider: LlmProviderConfig;
|
|
19
|
+
partyProvider: PartyProviderConfig;
|
|
20
|
+
paymentProvider?: PaymentsProviderConfig;
|
|
21
|
+
emailProvider?: CourseBuilderEmailProvider;
|
|
22
|
+
notificationProvider?: NotificationProviderConfig;
|
|
23
|
+
getAuthConfig: () => CourseBuilderAuthConfig;
|
|
24
|
+
mediaUploadProvider: {
|
|
25
|
+
deleteFiles: (fileKey: string) => Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
type CoreInngestFunctionInput = GetFunctionInput<CoreInngest>;
|
|
31
|
+
/** A server composition input with a statically limited context and event. */
|
|
32
|
+
type CourseBuilderHandlerInput<TContext extends Partial<CoreInngestContext>, TEventName extends Extract<keyof CourseBuilderCoreEvents, string>, TEvent extends CourseBuilderCoreEvents[TEventName] = CourseBuilderCoreEvents[TEventName]> = Omit<CoreInngestFunctionInput, keyof CoreInngestContext | 'event'> & TContext & {
|
|
33
|
+
event: TEvent;
|
|
34
|
+
};
|
|
35
|
+
type CoreInngestFunctionInputFor<TContext extends Partial<CoreInngestContext>, TEventName extends Extract<keyof CourseBuilderCoreEvents, string>, TEvent extends CourseBuilderCoreEvents[TEventName] = CourseBuilderCoreEvents[TEventName]> = CourseBuilderHandlerInput<TContext, TEventName, TEvent>;
|
|
36
|
+
type CoreInngestTrigger = InngestFunction.Trigger<keyof GetEvents<CoreInngest>>;
|
|
37
|
+
type CoreInngestHandler = Handler.Any;
|
|
38
|
+
type CourseBuilderFunctionDefinition = {
|
|
39
|
+
config: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
trigger: CoreInngestTrigger;
|
|
43
|
+
handler: CoreInngestHandler;
|
|
44
|
+
};
|
|
45
|
+
/** Validates function definitions without widening their inferred config types. */
|
|
46
|
+
declare const defineCourseBuilderFunctions: <TFunctions extends unknown[]>(functions: TFunctions & (TFunctions[number] extends CourseBuilderFunctionDefinition ? unknown : never)) => TFunctions;
|
|
47
|
+
declare const createInngestMiddleware: <TCourseBuilderContext extends CoreInngestContext = CoreInngestContext>(context: TCourseBuilderContext) => InngestMiddleware<{
|
|
48
|
+
name: string;
|
|
49
|
+
init(): {
|
|
50
|
+
onFunctionRun(): {
|
|
51
|
+
transformInput(): {
|
|
52
|
+
ctx: { [K in keyof TCourseBuilderContext]: TCourseBuilderContext[K]; };
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
declare const coreInngest: Inngest<{
|
|
58
|
+
id: string;
|
|
59
|
+
schemas: EventSchemas<{
|
|
60
|
+
"inngest/function.failed": {
|
|
61
|
+
data: {
|
|
62
|
+
function_id: string;
|
|
63
|
+
run_id: string;
|
|
64
|
+
error: inngest.JsonError;
|
|
65
|
+
event: inngest.EventPayload<any>;
|
|
66
|
+
};
|
|
67
|
+
name: "inngest/function.failed";
|
|
68
|
+
};
|
|
69
|
+
"inngest/function.finished": {
|
|
70
|
+
data: {
|
|
71
|
+
function_id: string;
|
|
72
|
+
run_id: string;
|
|
73
|
+
correlation_id?: string | undefined;
|
|
74
|
+
} & ({
|
|
75
|
+
error: inngest.JsonError;
|
|
76
|
+
} | {
|
|
77
|
+
result: unknown;
|
|
78
|
+
});
|
|
79
|
+
name: "inngest/function.finished";
|
|
80
|
+
};
|
|
81
|
+
"inngest/function.invoked": {
|
|
82
|
+
ts?: number | undefined;
|
|
83
|
+
id?: string | undefined;
|
|
84
|
+
data?: any;
|
|
85
|
+
user?: any;
|
|
86
|
+
v?: string | undefined;
|
|
87
|
+
name: "inngest/function.invoked";
|
|
88
|
+
};
|
|
89
|
+
"inngest/function.cancelled": {
|
|
90
|
+
data: {
|
|
91
|
+
function_id: string;
|
|
92
|
+
run_id: string;
|
|
93
|
+
correlation_id?: string | undefined;
|
|
94
|
+
};
|
|
95
|
+
name: "inngest/function.cancelled";
|
|
96
|
+
};
|
|
97
|
+
"inngest/scheduled.timer": {
|
|
98
|
+
ts?: number | undefined;
|
|
99
|
+
id: string;
|
|
100
|
+
data: {
|
|
101
|
+
cron: string;
|
|
102
|
+
};
|
|
103
|
+
user?: any;
|
|
104
|
+
v?: string | undefined;
|
|
105
|
+
name: "inngest/scheduled.timer";
|
|
106
|
+
};
|
|
107
|
+
"inngest/http.request": {
|
|
108
|
+
data: {
|
|
109
|
+
domain: string;
|
|
110
|
+
method: string;
|
|
111
|
+
path: string;
|
|
112
|
+
ip: string;
|
|
113
|
+
content_type: string;
|
|
114
|
+
query_params: string;
|
|
115
|
+
body?: string | undefined;
|
|
116
|
+
fn?: string | undefined;
|
|
117
|
+
};
|
|
118
|
+
name: "inngest/http.request";
|
|
119
|
+
};
|
|
120
|
+
"commerce/update-purchase-status": {
|
|
121
|
+
ts?: number | undefined;
|
|
122
|
+
id?: string | undefined;
|
|
123
|
+
user?: any;
|
|
124
|
+
v?: string | undefined;
|
|
125
|
+
name: "commerce/update-purchase-status";
|
|
126
|
+
data: {
|
|
127
|
+
stripeChargeId: string;
|
|
128
|
+
status: "Valid" | "Refunded" | "Disputed" | "Banned" | "Restricted";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
"commerce/new-purchase-created": {
|
|
132
|
+
ts?: number | undefined;
|
|
133
|
+
id?: string | undefined;
|
|
134
|
+
user?: any;
|
|
135
|
+
v?: string | undefined;
|
|
136
|
+
name: "commerce/new-purchase-created";
|
|
137
|
+
data: {
|
|
138
|
+
purchaseId: string;
|
|
139
|
+
checkoutSessionId?: string | null | undefined;
|
|
140
|
+
invoiceId?: string | undefined;
|
|
141
|
+
productType?: "live" | "self-paced" | "membership" | "cohort" | "cohort-archive" | "source-code-access" | undefined;
|
|
142
|
+
quantity?: number | undefined;
|
|
143
|
+
customerEmail?: string | null | undefined;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
"commerce/new-subscription-created": {
|
|
147
|
+
ts?: number | undefined;
|
|
148
|
+
id?: string | undefined;
|
|
149
|
+
user?: any;
|
|
150
|
+
v?: string | undefined;
|
|
151
|
+
name: "commerce/new-subscription-created";
|
|
152
|
+
data: {
|
|
153
|
+
subscriptionId: string;
|
|
154
|
+
checkoutSessionId: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
"commerce/full-price-coupon-redeemed": {
|
|
158
|
+
ts?: number | undefined;
|
|
159
|
+
id?: string | undefined;
|
|
160
|
+
user?: any;
|
|
161
|
+
v?: string | undefined;
|
|
162
|
+
name: "commerce/full-price-coupon-redeemed";
|
|
163
|
+
data: {
|
|
164
|
+
purchaseId: string;
|
|
165
|
+
checkoutSessionId: string;
|
|
166
|
+
productType?: "live" | "self-paced" | "membership" | "cohort" | "cohort-archive" | "source-code-access" | undefined;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
"team-seat-redemption/created": {
|
|
170
|
+
ts?: number | undefined;
|
|
171
|
+
id?: string | undefined;
|
|
172
|
+
v?: string | undefined;
|
|
173
|
+
name: "team-seat-redemption/created";
|
|
174
|
+
data: {
|
|
175
|
+
redeemedPurchaseId: string;
|
|
176
|
+
bulkCouponId: string;
|
|
177
|
+
userId: string;
|
|
178
|
+
userEmail: string;
|
|
179
|
+
productId: string;
|
|
180
|
+
};
|
|
181
|
+
user: {
|
|
182
|
+
id: string;
|
|
183
|
+
email?: string | null | undefined;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
"purchase/benefits-attached": {
|
|
187
|
+
ts?: number | undefined;
|
|
188
|
+
id?: string | undefined;
|
|
189
|
+
v?: string | undefined;
|
|
190
|
+
name: "purchase/benefits-attached";
|
|
191
|
+
data: {
|
|
192
|
+
purchaseId: string;
|
|
193
|
+
userId: string;
|
|
194
|
+
productId: string;
|
|
195
|
+
purchaseBenefitIds: string[];
|
|
196
|
+
checkoutSessionId?: string | null | undefined;
|
|
197
|
+
invoiceId?: string | undefined;
|
|
198
|
+
};
|
|
199
|
+
user: {
|
|
200
|
+
id: string;
|
|
201
|
+
email?: string | null | undefined;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
"commerce/refund-processed": {
|
|
205
|
+
ts?: number | undefined;
|
|
206
|
+
id?: string | undefined;
|
|
207
|
+
user?: any;
|
|
208
|
+
v?: string | undefined;
|
|
209
|
+
name: "commerce/refund-processed";
|
|
210
|
+
data: {
|
|
211
|
+
merchantChargeId?: string | undefined;
|
|
212
|
+
stripeChargeId?: string | undefined;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
"commerce/purchase_transferred": {
|
|
216
|
+
ts?: number | undefined;
|
|
217
|
+
id?: string | undefined;
|
|
218
|
+
user?: any;
|
|
219
|
+
v?: string | undefined;
|
|
220
|
+
name: "commerce/purchase_transferred";
|
|
221
|
+
data: {
|
|
222
|
+
purchaseId: string;
|
|
223
|
+
sourceUserId: string;
|
|
224
|
+
targetUserId: string;
|
|
225
|
+
purchaseUserTransferId?: string | undefined;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
"commerce/purchase_transferred_api": {
|
|
229
|
+
ts?: number | undefined;
|
|
230
|
+
id?: string | undefined;
|
|
231
|
+
user?: any;
|
|
232
|
+
v?: string | undefined;
|
|
233
|
+
name: "commerce/purchase_transferred_api";
|
|
234
|
+
data: {
|
|
235
|
+
purchaseId: string;
|
|
236
|
+
sourceUserId: string;
|
|
237
|
+
targetUserId: string;
|
|
238
|
+
purchaseUserTransferId?: string | undefined;
|
|
239
|
+
transferSource: "api-support-front";
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
"resource/chat-request-event": {
|
|
243
|
+
ts?: number | undefined;
|
|
244
|
+
id?: string | undefined;
|
|
245
|
+
v?: string | undefined;
|
|
246
|
+
name: "resource/chat-request-event";
|
|
247
|
+
data: {
|
|
248
|
+
resourceId: string;
|
|
249
|
+
messages: ai.ModelMessage[];
|
|
250
|
+
promptId?: string | undefined;
|
|
251
|
+
selectedWorkflow: string;
|
|
252
|
+
model?: string | undefined;
|
|
253
|
+
};
|
|
254
|
+
user: Record<string, any>;
|
|
255
|
+
};
|
|
256
|
+
"stripe/checkout-session-completed": {
|
|
257
|
+
ts?: number | undefined;
|
|
258
|
+
id?: string | undefined;
|
|
259
|
+
user?: any;
|
|
260
|
+
v?: string | undefined;
|
|
261
|
+
name: "stripe/checkout-session-completed";
|
|
262
|
+
data: {
|
|
263
|
+
txnId?: string | undefined;
|
|
264
|
+
stripeEvent: {
|
|
265
|
+
id: string;
|
|
266
|
+
created: number;
|
|
267
|
+
data: {
|
|
268
|
+
object: {
|
|
269
|
+
mode: "payment";
|
|
270
|
+
payment_intent: string;
|
|
271
|
+
subscription: null;
|
|
272
|
+
id: string;
|
|
273
|
+
object: "checkout.session";
|
|
274
|
+
amount_subtotal: number;
|
|
275
|
+
amount_total: number;
|
|
276
|
+
created: number;
|
|
277
|
+
currency: string;
|
|
278
|
+
custom_fields: unknown[];
|
|
279
|
+
customer: string;
|
|
280
|
+
customer_details: {
|
|
281
|
+
address: {
|
|
282
|
+
city: string | null;
|
|
283
|
+
country: string | null;
|
|
284
|
+
line1: string | null;
|
|
285
|
+
line2: string | null;
|
|
286
|
+
postal_code: string | null;
|
|
287
|
+
state: string | null;
|
|
288
|
+
};
|
|
289
|
+
email: string | null;
|
|
290
|
+
name: string | null;
|
|
291
|
+
};
|
|
292
|
+
livemode: boolean;
|
|
293
|
+
metadata: Record<string, string>;
|
|
294
|
+
payment_method_collection: string;
|
|
295
|
+
payment_status: string;
|
|
296
|
+
phone_number_collection: {
|
|
297
|
+
enabled: boolean;
|
|
298
|
+
};
|
|
299
|
+
status: string;
|
|
300
|
+
success_url: string;
|
|
301
|
+
total_details: {
|
|
302
|
+
amount_discount: number;
|
|
303
|
+
amount_shipping: number;
|
|
304
|
+
amount_tax: number;
|
|
305
|
+
};
|
|
306
|
+
} | {
|
|
307
|
+
mode: "subscription";
|
|
308
|
+
payment_intent: null;
|
|
309
|
+
subscription: string;
|
|
310
|
+
id: string;
|
|
311
|
+
object: "checkout.session";
|
|
312
|
+
amount_subtotal: number;
|
|
313
|
+
amount_total: number;
|
|
314
|
+
created: number;
|
|
315
|
+
currency: string;
|
|
316
|
+
custom_fields: unknown[];
|
|
317
|
+
customer: string;
|
|
318
|
+
customer_details: {
|
|
319
|
+
address: {
|
|
320
|
+
city: string | null;
|
|
321
|
+
country: string | null;
|
|
322
|
+
line1: string | null;
|
|
323
|
+
line2: string | null;
|
|
324
|
+
postal_code: string | null;
|
|
325
|
+
state: string | null;
|
|
326
|
+
};
|
|
327
|
+
email: string | null;
|
|
328
|
+
name: string | null;
|
|
329
|
+
};
|
|
330
|
+
livemode: boolean;
|
|
331
|
+
metadata: Record<string, string>;
|
|
332
|
+
payment_method_collection: string;
|
|
333
|
+
payment_status: string;
|
|
334
|
+
phone_number_collection: {
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
};
|
|
337
|
+
status: string;
|
|
338
|
+
success_url: string;
|
|
339
|
+
total_details: {
|
|
340
|
+
amount_discount: number;
|
|
341
|
+
amount_shipping: number;
|
|
342
|
+
amount_tax: number;
|
|
343
|
+
};
|
|
344
|
+
} | {
|
|
345
|
+
mode: "setup";
|
|
346
|
+
payment_intent: null;
|
|
347
|
+
subscription: null;
|
|
348
|
+
id: string;
|
|
349
|
+
object: "checkout.session";
|
|
350
|
+
amount_subtotal: number;
|
|
351
|
+
amount_total: number;
|
|
352
|
+
created: number;
|
|
353
|
+
currency: string;
|
|
354
|
+
custom_fields: unknown[];
|
|
355
|
+
customer: string;
|
|
356
|
+
customer_details: {
|
|
357
|
+
address: {
|
|
358
|
+
city: string | null;
|
|
359
|
+
country: string | null;
|
|
360
|
+
line1: string | null;
|
|
361
|
+
line2: string | null;
|
|
362
|
+
postal_code: string | null;
|
|
363
|
+
state: string | null;
|
|
364
|
+
};
|
|
365
|
+
email: string | null;
|
|
366
|
+
name: string | null;
|
|
367
|
+
};
|
|
368
|
+
livemode: boolean;
|
|
369
|
+
metadata: Record<string, string>;
|
|
370
|
+
payment_method_collection: string;
|
|
371
|
+
payment_status: string;
|
|
372
|
+
phone_number_collection: {
|
|
373
|
+
enabled: boolean;
|
|
374
|
+
};
|
|
375
|
+
status: string;
|
|
376
|
+
success_url: string;
|
|
377
|
+
total_details: {
|
|
378
|
+
amount_discount: number;
|
|
379
|
+
amount_shipping: number;
|
|
380
|
+
amount_tax: number;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
type: "checkout.session.completed";
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
"stripe/customer-subscription-created": {
|
|
389
|
+
ts?: number | undefined;
|
|
390
|
+
id?: string | undefined;
|
|
391
|
+
user?: any;
|
|
392
|
+
v?: string | undefined;
|
|
393
|
+
name: "stripe/customer-subscription-created";
|
|
394
|
+
data: {
|
|
395
|
+
stripeEvent: {
|
|
396
|
+
id: string;
|
|
397
|
+
object: "event";
|
|
398
|
+
type: "customer.subscription.created";
|
|
399
|
+
data: {
|
|
400
|
+
object: {
|
|
401
|
+
id: string;
|
|
402
|
+
object: "subscription";
|
|
403
|
+
status: "active" | "past_due" | "unpaid" | "canceled" | "incomplete" | "incomplete_expired" | "trialing" | "paused";
|
|
404
|
+
customer: string;
|
|
405
|
+
items: {
|
|
406
|
+
data: {
|
|
407
|
+
id: string;
|
|
408
|
+
price: {
|
|
409
|
+
id: string;
|
|
410
|
+
product: string;
|
|
411
|
+
};
|
|
412
|
+
}[];
|
|
413
|
+
};
|
|
414
|
+
current_period_end?: number | undefined;
|
|
415
|
+
cancel_at?: number | null | undefined;
|
|
416
|
+
cancel_at_period_end?: boolean | undefined;
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
"stripe/customer-subscription-updated": {
|
|
423
|
+
ts?: number | undefined;
|
|
424
|
+
id?: string | undefined;
|
|
425
|
+
user?: any;
|
|
426
|
+
v?: string | undefined;
|
|
427
|
+
name: "stripe/customer-subscription-updated";
|
|
428
|
+
data: {
|
|
429
|
+
stripeEvent: {
|
|
430
|
+
id: string;
|
|
431
|
+
object: "event";
|
|
432
|
+
type: "customer.subscription.updated";
|
|
433
|
+
data: {
|
|
434
|
+
object: {
|
|
435
|
+
id: string;
|
|
436
|
+
object: "subscription";
|
|
437
|
+
status: "active" | "past_due" | "unpaid" | "canceled" | "incomplete" | "incomplete_expired" | "trialing" | "paused";
|
|
438
|
+
customer: string;
|
|
439
|
+
items: {
|
|
440
|
+
data: {
|
|
441
|
+
id: string;
|
|
442
|
+
price: {
|
|
443
|
+
id: string;
|
|
444
|
+
product: string;
|
|
445
|
+
};
|
|
446
|
+
}[];
|
|
447
|
+
};
|
|
448
|
+
current_period_end?: number | undefined;
|
|
449
|
+
cancel_at?: number | null | undefined;
|
|
450
|
+
cancel_at_period_end?: boolean | undefined;
|
|
451
|
+
};
|
|
452
|
+
previous_attributes?: Record<string, unknown> | undefined;
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
"stripe/invoice-payment-succeeded": {
|
|
458
|
+
ts?: number | undefined;
|
|
459
|
+
id?: string | undefined;
|
|
460
|
+
user?: any;
|
|
461
|
+
v?: string | undefined;
|
|
462
|
+
name: "stripe/invoice-payment-succeeded";
|
|
463
|
+
data: {
|
|
464
|
+
txnId?: string | undefined;
|
|
465
|
+
stripeEvent: {
|
|
466
|
+
id: string;
|
|
467
|
+
object: "event";
|
|
468
|
+
type: "invoice.payment_succeeded";
|
|
469
|
+
data: {
|
|
470
|
+
object: {
|
|
471
|
+
id: string;
|
|
472
|
+
object: "invoice";
|
|
473
|
+
charge: string | {
|
|
474
|
+
id: string;
|
|
475
|
+
} | null;
|
|
476
|
+
customer: string | {
|
|
477
|
+
id: string;
|
|
478
|
+
email: string | null;
|
|
479
|
+
name: string | null;
|
|
480
|
+
};
|
|
481
|
+
amount_paid: number;
|
|
482
|
+
currency: string;
|
|
483
|
+
status: "draft" | "void" | "paid" | "open" | "uncollectible";
|
|
484
|
+
subscription?: string | null | undefined;
|
|
485
|
+
payment_intent?: string | {
|
|
486
|
+
id: string;
|
|
487
|
+
} | null | undefined;
|
|
488
|
+
customer_email?: string | null | undefined;
|
|
489
|
+
amount_due?: number | undefined;
|
|
490
|
+
metadata?: Record<string, string> | null | undefined;
|
|
491
|
+
billing_reason?: string | null | undefined;
|
|
492
|
+
lines?: {
|
|
493
|
+
data: {
|
|
494
|
+
id: string;
|
|
495
|
+
amount: number;
|
|
496
|
+
quantity: number | null;
|
|
497
|
+
description: string | null;
|
|
498
|
+
price: {
|
|
499
|
+
id: string;
|
|
500
|
+
product: string | {
|
|
501
|
+
id: string;
|
|
502
|
+
name: string | null;
|
|
503
|
+
};
|
|
504
|
+
} | null;
|
|
505
|
+
discounts?: string[] | undefined;
|
|
506
|
+
}[];
|
|
507
|
+
} | undefined;
|
|
508
|
+
discount?: {
|
|
509
|
+
coupon: {
|
|
510
|
+
id: string;
|
|
511
|
+
};
|
|
512
|
+
} | null | undefined;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
"video/status-check": {
|
|
519
|
+
ts?: number | undefined;
|
|
520
|
+
id?: string | undefined;
|
|
521
|
+
user?: any;
|
|
522
|
+
v?: string | undefined;
|
|
523
|
+
name: "video/status-check";
|
|
524
|
+
data: {
|
|
525
|
+
videoResourceId: string;
|
|
526
|
+
fileKey: string;
|
|
527
|
+
retryCount?: number | undefined;
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
"video/transcript-ready-event": {
|
|
531
|
+
ts?: number | undefined;
|
|
532
|
+
id?: string | undefined;
|
|
533
|
+
user?: any;
|
|
534
|
+
v?: string | undefined;
|
|
535
|
+
name: "video/transcript-ready-event";
|
|
536
|
+
data: {
|
|
537
|
+
videoResourceId: string | null;
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
"video/srt-ready": {
|
|
541
|
+
ts?: number | undefined;
|
|
542
|
+
id?: string | undefined;
|
|
543
|
+
user?: any;
|
|
544
|
+
v?: string | undefined;
|
|
545
|
+
name: "video/srt-ready";
|
|
546
|
+
data: {
|
|
547
|
+
videoResourceId: string;
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
"video/video-uploaded": {
|
|
551
|
+
ts?: number | undefined;
|
|
552
|
+
id?: string | undefined;
|
|
553
|
+
user?: any;
|
|
554
|
+
v?: string | undefined;
|
|
555
|
+
name: "video/video-uploaded";
|
|
556
|
+
data: {
|
|
557
|
+
originalMediaUrl: string;
|
|
558
|
+
fileName: string;
|
|
559
|
+
title?: string | undefined;
|
|
560
|
+
parentResourceId?: string | undefined;
|
|
561
|
+
resourceType?: string | undefined;
|
|
562
|
+
resourceId?: string | undefined;
|
|
563
|
+
fileKey?: string | undefined;
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
"video-resource/created": {
|
|
567
|
+
ts?: number | undefined;
|
|
568
|
+
id?: string | undefined;
|
|
569
|
+
user?: any;
|
|
570
|
+
v?: string | undefined;
|
|
571
|
+
name: "video-resource/created";
|
|
572
|
+
data: {
|
|
573
|
+
videoResourceId: string;
|
|
574
|
+
originalMediaUrl: string;
|
|
575
|
+
moduleSlug?: string | undefined;
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
"mux/web-hook-event": {
|
|
579
|
+
ts?: number | undefined;
|
|
580
|
+
id?: string | undefined;
|
|
581
|
+
user?: any;
|
|
582
|
+
v?: string | undefined;
|
|
583
|
+
name: "mux/web-hook-event";
|
|
584
|
+
data: {
|
|
585
|
+
muxWebhookEvent: {
|
|
586
|
+
type: string;
|
|
587
|
+
request_id: string | null;
|
|
588
|
+
object: {
|
|
589
|
+
type: string;
|
|
590
|
+
id: string;
|
|
591
|
+
};
|
|
592
|
+
id: string;
|
|
593
|
+
environment: {
|
|
594
|
+
name: string;
|
|
595
|
+
id: string;
|
|
596
|
+
};
|
|
597
|
+
data: any;
|
|
598
|
+
created_at: string;
|
|
599
|
+
attempts: any[];
|
|
600
|
+
accessor_source: string | null;
|
|
601
|
+
accessor: string | null;
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
}>;
|
|
606
|
+
middleware: [InngestMiddleware<{
|
|
607
|
+
name: string;
|
|
608
|
+
init(): {
|
|
609
|
+
onFunctionRun(): {
|
|
610
|
+
transformInput(): {
|
|
611
|
+
ctx: {
|
|
612
|
+
db: ServerAdapter;
|
|
613
|
+
siteRootUrl: string;
|
|
614
|
+
partyKitRootUrl: string;
|
|
615
|
+
transcriptProvider: TranscriptionConfig;
|
|
616
|
+
openaiProvider: LlmProviderConfig;
|
|
617
|
+
partyProvider: PartyProviderConfig;
|
|
618
|
+
paymentProvider: PaymentsProviderConfig;
|
|
619
|
+
emailProvider: CourseBuilderEmailProvider;
|
|
620
|
+
notificationProvider: NotificationProviderConfig;
|
|
621
|
+
getAuthConfig: () => CourseBuilderAuthConfig;
|
|
622
|
+
mediaUploadProvider: {
|
|
623
|
+
deleteFiles: (_: string) => Promise<{
|
|
624
|
+
success: true;
|
|
625
|
+
}>;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
}>];
|
|
632
|
+
}>;
|
|
633
|
+
type CoreInngest = typeof coreInngest;
|
|
634
|
+
|
|
635
|
+
export { type CoreInngest, type CoreInngestContext, type CoreInngestFunctionInput, type CoreInngestFunctionInputFor, type CoreInngestHandler, type CoreInngestTrigger, type CourseBuilderFunctionDefinition, type CourseBuilderHandlerInput, coreInngest, createInngestMiddleware, defineCourseBuilderFunctions };
|