@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Skill Recordings Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function checkout(request: RequestInternal, cookies: Cookie[], options: InternalOptions<'payment'>): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { checkout };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function claimed(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { claimed };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function createMagicLink(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { createMagicLink };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InternalOptions, ResponseInternal, RequestInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function getUserPurchases(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
declare function getSubscriber(options: InternalOptions<'email-list'>, cookies: Cookie[]): Promise<ResponseInternal<any | null>>;
|
|
6
|
+
declare function subscribeToList(request: RequestInternal, cookies: Cookie[], options: InternalOptions<'email-list'>): Promise<ResponseInternal<any | null>>;
|
|
7
|
+
declare function session(options: InternalOptions, cookies: Cookie[]): Promise<ResponseInternal<any | null>>;
|
|
8
|
+
declare function srt(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
9
|
+
declare function webhook(request: RequestInternal, cookies: Cookie[], options: InternalOptions<'transcription' | 'payment'>): Promise<ResponseInternal>;
|
|
10
|
+
|
|
11
|
+
export { getSubscriber, getUserPurchases, session, srt, subscribeToList, webhook };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSubscriber,
|
|
3
|
+
getUserPurchases,
|
|
4
|
+
session,
|
|
5
|
+
srt,
|
|
6
|
+
subscribeToList,
|
|
7
|
+
webhook
|
|
8
|
+
} from "../chunk-ODSSRMD2.js";
|
|
9
|
+
import "../chunk-WGAPYIUP.js";
|
|
10
|
+
export {
|
|
11
|
+
getSubscriber,
|
|
12
|
+
getUserPurchases,
|
|
13
|
+
session,
|
|
14
|
+
srt,
|
|
15
|
+
subscribeToList,
|
|
16
|
+
webhook
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function getCouponForCode(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { getCouponForCode };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "../chunk-WGAPYIUP.js";
|
|
2
|
+
|
|
3
|
+
// src/actions/prices-coupon-for-code.ts
|
|
4
|
+
import { isBefore } from "date-fns";
|
|
5
|
+
var validateCoupon = (coupon, productIds = []) => {
|
|
6
|
+
if (!coupon) {
|
|
7
|
+
return {
|
|
8
|
+
isValid: false,
|
|
9
|
+
isRedeemable: false,
|
|
10
|
+
error: "coupon-not-found"
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const isUsedUp = coupon.maxUses > 0 ? coupon.usedCount >= coupon.maxUses : false;
|
|
14
|
+
const isExpired = coupon.expires ? isBefore(new Date(coupon.expires), /* @__PURE__ */ new Date()) : false;
|
|
15
|
+
if (coupon.restrictedToProductId && !productIds.includes(coupon.restrictedToProductId)) {
|
|
16
|
+
return {
|
|
17
|
+
isValid: false,
|
|
18
|
+
isRedeemable: false,
|
|
19
|
+
error: "coupon-not-valid-for-product"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const isValid = !isUsedUp && !isExpired;
|
|
23
|
+
return {
|
|
24
|
+
isExpired,
|
|
25
|
+
isUsedUp,
|
|
26
|
+
isRedeemable: isValid && Number(coupon.percentageDiscount) >= 1 && !coupon.default,
|
|
27
|
+
isValid
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
async function getCouponForCode(request, cookies, options) {
|
|
31
|
+
const { code, productIds } = request.body || {};
|
|
32
|
+
if (!code)
|
|
33
|
+
return {
|
|
34
|
+
body: null,
|
|
35
|
+
headers: { "Content-Type": "application/json" },
|
|
36
|
+
cookies
|
|
37
|
+
};
|
|
38
|
+
let couponFromCode = code && await options.adapter?.getCoupon(code);
|
|
39
|
+
if (couponFromCode) {
|
|
40
|
+
const is100Percent = productIds.length === 0 && couponFromCode.restrictedToProductId && couponFromCode.percentageDiscount === 1;
|
|
41
|
+
const validatedCoupon = validateCoupon(
|
|
42
|
+
couponFromCode,
|
|
43
|
+
is100Percent ? [couponFromCode?.restrictedToProductId] : productIds
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
body: {
|
|
47
|
+
...couponFromCode,
|
|
48
|
+
...validatedCoupon
|
|
49
|
+
},
|
|
50
|
+
headers: { "Content-Type": "application/json" },
|
|
51
|
+
cookies
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
body: null,
|
|
56
|
+
headers: { "Content-Type": "application/json" },
|
|
57
|
+
cookies
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
getCouponForCode
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=prices-coupon-for-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/actions/prices-coupon-for-code.ts"],"sourcesContent":["import { isBefore } from 'date-fns'\n\nimport type { Coupon } from '@coursebuilder/core/schemas'\nimport type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\n\nimport type { Cookie } from '../runtime/cookie'\n\nconst validateCoupon = (coupon: Coupon | null, productIds: string[] = []) => {\n\tif (!coupon) {\n\t\treturn {\n\t\t\tisValid: false,\n\t\t\tisRedeemable: false,\n\t\t\terror: 'coupon-not-found',\n\t\t}\n\t}\n\n\tconst isUsedUp =\n\t\tcoupon.maxUses > 0 ? coupon.usedCount >= coupon.maxUses : false\n\n\tconst isExpired = coupon.expires\n\t\t? isBefore(new Date(coupon.expires), new Date())\n\t\t: false\n\n\tif (\n\t\tcoupon.restrictedToProductId &&\n\t\t!productIds.includes(coupon.restrictedToProductId)\n\t) {\n\t\treturn {\n\t\t\tisValid: false,\n\t\t\tisRedeemable: false,\n\t\t\terror: 'coupon-not-valid-for-product',\n\t\t}\n\t}\n\n\tconst isValid = !isUsedUp && !isExpired\n\n\treturn {\n\t\tisExpired,\n\t\tisUsedUp,\n\t\tisRedeemable:\n\t\t\tisValid && Number(coupon.percentageDiscount) >= 1 && !coupon.default,\n\t\tisValid,\n\t}\n}\n\nexport async function getCouponForCode(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tconst { code, productIds } = request.body || {}\n\n\tif (!code)\n\t\treturn {\n\t\t\tbody: null,\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\n\tlet couponFromCode = code && (await options.adapter?.getCoupon(code))\n\n\tif (couponFromCode) {\n\t\tconst is100Percent =\n\t\t\tproductIds.length === 0 &&\n\t\t\tcouponFromCode.restrictedToProductId &&\n\t\t\tcouponFromCode.percentageDiscount === 1\n\n\t\tconst validatedCoupon = validateCoupon(\n\t\t\tcouponFromCode,\n\t\t\tis100Percent ? [couponFromCode?.restrictedToProductId] : productIds,\n\t\t)\n\t\treturn {\n\t\t\tbody: {\n\t\t\t\t...couponFromCode,\n\t\t\t\t...validatedCoupon,\n\t\t\t},\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\t}\n\n\treturn {\n\t\tbody: null,\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tcookies,\n\t}\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB;AAWzB,IAAM,iBAAiB,CAAC,QAAuB,aAAuB,CAAC,MAAM;AAC5E,MAAI,CAAC,QAAQ;AACZ,WAAO;AAAA,MACN,SAAS;AAAA,MACT,cAAc;AAAA,MACd,OAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,WACL,OAAO,UAAU,IAAI,OAAO,aAAa,OAAO,UAAU;AAE3D,QAAM,YAAY,OAAO,UACtB,SAAS,IAAI,KAAK,OAAO,OAAO,GAAG,oBAAI,KAAK,CAAC,IAC7C;AAEH,MACC,OAAO,yBACP,CAAC,WAAW,SAAS,OAAO,qBAAqB,GAChD;AACD,WAAO;AAAA,MACN,SAAS;AAAA,MACT,cAAc;AAAA,MACd,OAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,UAAU,CAAC,YAAY,CAAC;AAE9B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,cACC,WAAW,OAAO,OAAO,kBAAkB,KAAK,KAAK,CAAC,OAAO;AAAA,IAC9D;AAAA,EACD;AACD;AAEA,eAAsB,iBACrB,SACA,SACA,SAC4B;AAC5B,QAAM,EAAE,MAAM,WAAW,IAAI,QAAQ,QAAQ,CAAC;AAE9C,MAAI,CAAC;AACJ,WAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C;AAAA,IACD;AAED,MAAI,iBAAiB,QAAS,MAAM,QAAQ,SAAS,UAAU,IAAI;AAEnE,MAAI,gBAAgB;AACnB,UAAM,eACL,WAAW,WAAW,KACtB,eAAe,yBACf,eAAe,uBAAuB;AAEvC,UAAM,kBAAkB;AAAA,MACvB;AAAA,MACA,eAAe,CAAC,gBAAgB,qBAAqB,IAAI;AAAA,IAC1D;AACA,WAAO;AAAA,MACN,MAAM;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,MACJ;AAAA,MACA,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function getPricesFormatted(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { getPricesFormatted };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { processRefund } from '@coursebuilder/commerce/process-refund';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { redeem } from '@coursebuilder/commerce/redeem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { transferPurchase } from '@coursebuilder/commerce/transfer-purchase';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestInternal, InternalOptions, ResponseInternal } from '@coursebuilder/core/types';
|
|
2
|
+
import { Cookie } from '../runtime/cookie.js';
|
|
3
|
+
|
|
4
|
+
declare function userLookup(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>;
|
|
5
|
+
|
|
6
|
+
export { userLookup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthStoragePort } from '@coursebuilder/core/auth';
|
|
2
|
+
import { CatalogPort, ContentResourcePort, CouponPort, EntitlementPort, IdentityPort, MerchantPort, OrganizationPort, ProgressPort, PurchasePort, SubscriptionPort } from '@coursebuilder/core/ports';
|
|
3
|
+
|
|
4
|
+
/** Capability composition required by the Course Builder server facade. */
|
|
5
|
+
type ServerAdapter = AuthStoragePort & CatalogPort & ContentResourcePort & CouponPort & EntitlementPort & IdentityPort & MerchantPort & OrganizationPort & ProgressPort & PurchasePort & SubscriptionPort & {
|
|
6
|
+
client: unknown;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type { ServerAdapter as S };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-AZLUMIIF.js";
|
|
4
|
+
|
|
5
|
+
// src/actions/create-magic-link.ts
|
|
6
|
+
import { createVerificationUrl } from "@coursebuilder/email/send-server-email";
|
|
7
|
+
async function createMagicLink(request, cookies, options) {
|
|
8
|
+
if (!options.adapter)
|
|
9
|
+
throw new Error("Adapter not found");
|
|
10
|
+
if (request.headers?.["x-skill-secret"] !== process.env.SKILL_SECRET) {
|
|
11
|
+
return { status: 401, body: "unauthorized" };
|
|
12
|
+
}
|
|
13
|
+
const { email } = request.body || {};
|
|
14
|
+
if (!email) {
|
|
15
|
+
return { status: 400, body: "email is required" };
|
|
16
|
+
}
|
|
17
|
+
const emailProvider = options.providers.find((p) => p.type === "email");
|
|
18
|
+
if (!emailProvider) {
|
|
19
|
+
return { status: 400, body: "email provider not found" };
|
|
20
|
+
}
|
|
21
|
+
const expiresIn = request.body?.expiresIn || request.query?.expiresIn;
|
|
22
|
+
let expiresAt = void 0;
|
|
23
|
+
if (expiresIn) {
|
|
24
|
+
const durationInMilliseconds = expiresIn * 1e3;
|
|
25
|
+
expiresAt = new Date(Date.now() + durationInMilliseconds);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const verificationDetails = await createVerificationUrl({
|
|
29
|
+
email,
|
|
30
|
+
emailProvider,
|
|
31
|
+
authOptions: options.authConfig,
|
|
32
|
+
adapter: options.adapter,
|
|
33
|
+
baseUrl: options.baseUrl,
|
|
34
|
+
expiresAt
|
|
35
|
+
});
|
|
36
|
+
if (!verificationDetails?.url) {
|
|
37
|
+
return {
|
|
38
|
+
status: 500,
|
|
39
|
+
body: JSON.stringify({
|
|
40
|
+
error: "Could not create verification url"
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
status: 200,
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
url: verificationDetails.url
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
} catch (e) {
|
|
51
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
52
|
+
logger.error(error, {
|
|
53
|
+
context: "magic-link.create",
|
|
54
|
+
hasEmail: Boolean(email),
|
|
55
|
+
expiresIn: expiresIn ?? null
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
status: 500,
|
|
59
|
+
body: JSON.stringify({ error: error.message })
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
createMagicLink
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-22AMOZYZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/create-magic-link.ts"],"sourcesContent":["import type { CourseBuilderEmailProvider } from '@coursebuilder/core/auth'\nimport type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\nimport { createVerificationUrl } from '@coursebuilder/email/send-server-email'\n\nimport type { Cookie } from '../runtime/cookie'\nimport { logger } from '../runtime/logger'\n\nexport async function createMagicLink(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tif (!options.adapter) throw new Error('Adapter not found')\n\tif (request.headers?.['x-skill-secret'] !== process.env.SKILL_SECRET) {\n\t\treturn { status: 401, body: 'unauthorized' }\n\t}\n\n\tconst { email } = request.body || {}\n\n\tif (!email) {\n\t\treturn { status: 400, body: 'email is required' }\n\t}\n\n\tconst emailProvider = options.providers.find((p) => p.type === 'email')\n\n\tif (!emailProvider) {\n\t\treturn { status: 400, body: 'email provider not found' }\n\t}\n\n\tconst expiresIn = request.body?.expiresIn || request.query?.expiresIn\n\n\tlet expiresAt: Date | undefined = undefined\n\n\tif (expiresIn) {\n\t\tconst durationInMilliseconds = expiresIn * 1000\n\t\texpiresAt = new Date(Date.now() + durationInMilliseconds)\n\t}\n\n\ttry {\n\t\tconst verificationDetails = await createVerificationUrl({\n\t\t\temail,\n\t\t\temailProvider: emailProvider as CourseBuilderEmailProvider,\n\t\t\tauthOptions: options.authConfig,\n\t\t\tadapter: options.adapter,\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\texpiresAt,\n\t\t})\n\t\tif (!verificationDetails?.url) {\n\t\t\treturn {\n\t\t\t\tstatus: 500,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\terror: 'Could not create verification url',\n\t\t\t\t}),\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\tbody: JSON.stringify({\n\t\t\t\turl: verificationDetails.url,\n\t\t\t}),\n\t\t}\n\t} catch (e) {\n\t\tconst error = e instanceof Error ? e : new Error(String(e))\n\t\tlogger.error(error, {\n\t\t\tcontext: 'magic-link.create',\n\t\t\thasEmail: Boolean(email),\n\t\t\texpiresIn: expiresIn ?? null,\n\t\t})\n\t\treturn {\n\t\t\tstatus: 500,\n\t\t\tbody: JSON.stringify({ error: error.message }),\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAMA,SAAS,6BAA6B;AAKtC,eAAsB,gBACrB,SACA,SACA,SAC4B;AAC5B,MAAI,CAAC,QAAQ;AAAS,UAAM,IAAI,MAAM,mBAAmB;AACzD,MAAI,QAAQ,UAAU,gBAAgB,MAAM,QAAQ,IAAI,cAAc;AACrE,WAAO,EAAE,QAAQ,KAAK,MAAM,eAAe;AAAA,EAC5C;AAEA,QAAM,EAAE,MAAM,IAAI,QAAQ,QAAQ,CAAC;AAEnC,MAAI,CAAC,OAAO;AACX,WAAO,EAAE,QAAQ,KAAK,MAAM,oBAAoB;AAAA,EACjD;AAEA,QAAM,gBAAgB,QAAQ,UAAU,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO;AAEtE,MAAI,CAAC,eAAe;AACnB,WAAO,EAAE,QAAQ,KAAK,MAAM,2BAA2B;AAAA,EACxD;AAEA,QAAM,YAAY,QAAQ,MAAM,aAAa,QAAQ,OAAO;AAE5D,MAAI,YAA8B;AAElC,MAAI,WAAW;AACd,UAAM,yBAAyB,YAAY;AAC3C,gBAAY,IAAI,KAAK,KAAK,IAAI,IAAI,sBAAsB;AAAA,EACzD;AAEA,MAAI;AACH,UAAM,sBAAsB,MAAM,sBAAsB;AAAA,MACvD;AAAA,MACA;AAAA,MACA,aAAa,QAAQ;AAAA,MACrB,SAAS,QAAQ;AAAA,MACjB,SAAS,QAAQ;AAAA,MACjB;AAAA,IACD,CAAC;AACD,QAAI,CAAC,qBAAqB,KAAK;AAC9B,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACpB,OAAO;AAAA,QACR,CAAC;AAAA,MACF;AAAA,IACD;AACA,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU;AAAA,QACpB,KAAK,oBAAoB;AAAA,MAC1B,CAAC;AAAA,IACF;AAAA,EACD,SAAS,GAAG;AACX,UAAM,QAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AAC1D,WAAO,MAAM,OAAO;AAAA,MACnB,SAAS;AAAA,MACT,UAAU,QAAQ,KAAK;AAAA,MACvB,WAAW,aAAa;AAAA,IACzB,CAAC;AACD,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,EAAE,OAAO,MAAM,QAAQ,CAAC;AAAA,IAC9C;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-AZLUMIIF.js";
|
|
4
|
+
|
|
5
|
+
// src/actions/user-lookup.ts
|
|
6
|
+
async function userLookup(request, cookies, options) {
|
|
7
|
+
if (!options.adapter)
|
|
8
|
+
throw new Error("Adapter not found");
|
|
9
|
+
if (request.headers?.["x-skill-secret"] !== process.env.SKILL_SECRET) {
|
|
10
|
+
return { status: 401, body: "unauthorized" };
|
|
11
|
+
}
|
|
12
|
+
const email = request.query?.email || request.body?.email;
|
|
13
|
+
try {
|
|
14
|
+
const user = await options.adapter.getUserWithPurchasersByEmail(email);
|
|
15
|
+
return {
|
|
16
|
+
status: 200,
|
|
17
|
+
body: JSON.stringify(user)
|
|
18
|
+
};
|
|
19
|
+
} catch (e) {
|
|
20
|
+
logger.error(e instanceof Error ? e : new Error(String(e)), {
|
|
21
|
+
context: "user-lookup.by-email",
|
|
22
|
+
hasEmail: Boolean(email),
|
|
23
|
+
emailSource: request.query?.email ? "query" : "body"
|
|
24
|
+
});
|
|
25
|
+
throw new Error("unable-to-lookup-user");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
userLookup
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-4EQQSW57.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/user-lookup.ts"],"sourcesContent":["import type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\n\nimport type { Cookie } from '../runtime/cookie'\nimport { logger } from '../runtime/logger'\n\nexport async function userLookup(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tif (!options.adapter) throw new Error('Adapter not found')\n\tif (request.headers?.['x-skill-secret'] !== process.env.SKILL_SECRET) {\n\t\treturn { status: 401, body: 'unauthorized' }\n\t}\n\n\tconst email =\n\t\t(request.query?.email as string) || (request.body?.email as string)\n\n\ttry {\n\t\tconst user = await options.adapter.getUserWithPurchasersByEmail(email)\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\tbody: JSON.stringify(user),\n\t\t}\n\t} catch (e) {\n\t\tlogger.error(e instanceof Error ? e : new Error(String(e)), {\n\t\t\tcontext: 'user-lookup.by-email',\n\t\t\thasEmail: Boolean(email),\n\t\t\temailSource: request.query?.email ? 'query' : 'body',\n\t\t})\n\t\tthrow new Error('unable-to-lookup-user')\n\t}\n}\n"],"mappings":";;;;;AASA,eAAsB,WACrB,SACA,SACA,SAC4B;AAC5B,MAAI,CAAC,QAAQ;AAAS,UAAM,IAAI,MAAM,mBAAmB;AACzD,MAAI,QAAQ,UAAU,gBAAgB,MAAM,QAAQ,IAAI,cAAc;AACrE,WAAO,EAAE,QAAQ,KAAK,MAAM,eAAe;AAAA,EAC5C;AAEA,QAAM,QACJ,QAAQ,OAAO,SAAqB,QAAQ,MAAM;AAEpD,MAAI;AACH,UAAM,OAAO,MAAM,QAAQ,QAAQ,6BAA6B,KAAK;AACrE,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,IAAI;AAAA,IAC1B;AAAA,EACD,SAAS,GAAG;AACX,WAAO,MAAM,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA,MAC3D,SAAS;AAAA,MACT,UAAU,QAAQ,KAAK;AAAA,MACvB,aAAa,QAAQ,OAAO,QAAQ,UAAU;AAAA,IAC/C,CAAC;AACD,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACxC;AACD;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-AZLUMIIF.js";
|
|
4
|
+
|
|
5
|
+
// src/runtime/env.ts
|
|
6
|
+
function setEnvDefaults(envObject, config) {
|
|
7
|
+
try {
|
|
8
|
+
const url = envObject.COURSEBUILDER_URL;
|
|
9
|
+
if (url && !config.basePath)
|
|
10
|
+
config.basePath = new URL(url).pathname;
|
|
11
|
+
} catch {
|
|
12
|
+
} finally {
|
|
13
|
+
config.basePath ?? (config.basePath = `/coursebuilder`);
|
|
14
|
+
}
|
|
15
|
+
config.providers = config.providers.map((p) => {
|
|
16
|
+
const finalProvider = typeof p === "function" ? p({}) : p;
|
|
17
|
+
const ID = finalProvider.id.toUpperCase();
|
|
18
|
+
if (finalProvider.type === "transcription") {
|
|
19
|
+
finalProvider.apiKey ?? (finalProvider.apiKey = envObject[`COURSEBUILDER_${ID}_API_KEY`]);
|
|
20
|
+
}
|
|
21
|
+
return finalProvider;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function createActionURL(action, protocol, headers, envObject, basePath) {
|
|
25
|
+
let envUrl = envObject.COURSEBUILDER_URL;
|
|
26
|
+
let url;
|
|
27
|
+
if (envUrl) {
|
|
28
|
+
url = new URL(envUrl);
|
|
29
|
+
if (basePath && basePath !== "/" && url.pathname !== "/") {
|
|
30
|
+
logger.debug(
|
|
31
|
+
url.pathname === basePath ? "env-url-basepath-redundant" : "env-url-basepath-mismatch"
|
|
32
|
+
);
|
|
33
|
+
url.pathname = "/";
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
const detectedHost = headers.get("x-forwarded-host") ?? headers.get("host");
|
|
37
|
+
const detectedProtocol = headers.get("x-forwarded-proto") ?? protocol ?? "https";
|
|
38
|
+
url = new URL(`${detectedProtocol}://${detectedHost}`);
|
|
39
|
+
}
|
|
40
|
+
const sanitizedUrl = url.toString().replace(/\/$/, "");
|
|
41
|
+
if (basePath) {
|
|
42
|
+
const sanitizedBasePath = basePath?.replace(/(^\/|\/$)/g, "") ?? "";
|
|
43
|
+
return new URL(`${sanitizedUrl}/${sanitizedBasePath}/${action}`);
|
|
44
|
+
}
|
|
45
|
+
return new URL(`${sanitizedUrl}/${action}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
setEnvDefaults,
|
|
50
|
+
createActionURL
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-4LZZLN6T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/env.ts"],"sourcesContent":["import { CourseBuilderAction } from '@coursebuilder/core/types'\n\nimport { CourseBuilderConfig } from '../http'\nimport { logger } from './logger.js'\n\n/** Set default env variables on the config object */\nexport function setEnvDefaults(envObject: any, config: CourseBuilderConfig) {\n\ttry {\n\t\tconst url = envObject.COURSEBUILDER_URL\n\t\tif (url && !config.basePath) config.basePath = new URL(url).pathname\n\t} catch {\n\t} finally {\n\t\tconfig.basePath ??= `/coursebuilder`\n\t}\n\n\tconfig.providers = config.providers.map((p) => {\n\t\tconst finalProvider = typeof p === 'function' ? p({}) : p\n\t\tconst ID = finalProvider.id.toUpperCase()\n\t\tif (finalProvider.type === 'transcription') {\n\t\t\tfinalProvider.apiKey ??= envObject[`COURSEBUILDER_${ID}_API_KEY`]\n\t\t}\n\t\treturn finalProvider\n\t})\n}\n\nexport function createActionURL(\n\taction: CourseBuilderAction,\n\tprotocol: string,\n\theaders: Headers,\n\tenvObject: any,\n\tbasePath?: string,\n): URL {\n\tlet envUrl = envObject.COURSEBUILDER_URL\n\n\tlet url: URL\n\tif (envUrl) {\n\t\turl = new URL(envUrl)\n\t\tif (basePath && basePath !== '/' && url.pathname !== '/') {\n\t\t\tlogger.debug(\n\t\t\t\turl.pathname === basePath\n\t\t\t\t\t? 'env-url-basepath-redundant'\n\t\t\t\t\t: 'env-url-basepath-mismatch',\n\t\t\t)\n\t\t\turl.pathname = '/'\n\t\t}\n\t} else {\n\t\tconst detectedHost = headers.get('x-forwarded-host') ?? headers.get('host')\n\t\tconst detectedProtocol =\n\t\t\theaders.get('x-forwarded-proto') ?? protocol ?? 'https'\n\n\t\turl = new URL(`${detectedProtocol}://${detectedHost}`)\n\t}\n\n\t// remove trailing slash\n\tconst sanitizedUrl = url.toString().replace(/\\/$/, '')\n\n\tif (basePath) {\n\t\t// remove leading and trailing slash\n\t\tconst sanitizedBasePath = basePath?.replace(/(^\\/|\\/$)/g, '') ?? ''\n\t\treturn new URL(`${sanitizedUrl}/${sanitizedBasePath}/${action}`)\n\t}\n\treturn new URL(`${sanitizedUrl}/${action}`)\n}\n"],"mappings":";;;;;AAMO,SAAS,eAAe,WAAgB,QAA6B;AAC3E,MAAI;AACH,UAAM,MAAM,UAAU;AACtB,QAAI,OAAO,CAAC,OAAO;AAAU,aAAO,WAAW,IAAI,IAAI,GAAG,EAAE;AAAA,EAC7D,QAAQ;AAAA,EACR,UAAE;AACD,WAAO,aAAP,OAAO,WAAa;AAAA,EACrB;AAEA,SAAO,YAAY,OAAO,UAAU,IAAI,CAAC,MAAM;AAC9C,UAAM,gBAAgB,OAAO,MAAM,aAAa,EAAE,CAAC,CAAC,IAAI;AACxD,UAAM,KAAK,cAAc,GAAG,YAAY;AACxC,QAAI,cAAc,SAAS,iBAAiB;AAC3C,oBAAc,WAAd,cAAc,SAAW,UAAU,iBAAiB,EAAE,UAAU;AAAA,IACjE;AACA,WAAO;AAAA,EACR,CAAC;AACF;AAEO,SAAS,gBACf,QACA,UACA,SACA,WACA,UACM;AACN,MAAI,SAAS,UAAU;AAEvB,MAAI;AACJ,MAAI,QAAQ;AACX,UAAM,IAAI,IAAI,MAAM;AACpB,QAAI,YAAY,aAAa,OAAO,IAAI,aAAa,KAAK;AACzD,aAAO;AAAA,QACN,IAAI,aAAa,WACd,+BACA;AAAA,MACJ;AACA,UAAI,WAAW;AAAA,IAChB;AAAA,EACD,OAAO;AACN,UAAM,eAAe,QAAQ,IAAI,kBAAkB,KAAK,QAAQ,IAAI,MAAM;AAC1E,UAAM,mBACL,QAAQ,IAAI,mBAAmB,KAAK,YAAY;AAEjD,UAAM,IAAI,IAAI,GAAG,gBAAgB,MAAM,YAAY,EAAE;AAAA,EACtD;AAGA,QAAM,eAAe,IAAI,SAAS,EAAE,QAAQ,OAAO,EAAE;AAErD,MAAI,UAAU;AAEb,UAAM,oBAAoB,UAAU,QAAQ,cAAc,EAAE,KAAK;AACjE,WAAO,IAAI,IAAI,GAAG,YAAY,IAAI,iBAAiB,IAAI,MAAM,EAAE;AAAA,EAChE;AACA,SAAO,IAAI,IAAI,GAAG,YAAY,IAAI,MAAM,EAAE;AAC3C;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
merge
|
|
3
|
+
} from "./chunk-KNC7QVGZ.js";
|
|
4
|
+
|
|
5
|
+
// src/runtime/providers.ts
|
|
6
|
+
function parseProviders(params) {
|
|
7
|
+
const { providerId, options } = params;
|
|
8
|
+
const providers = params.providers.map((p) => {
|
|
9
|
+
const provider = typeof p === "function" ? p() : p;
|
|
10
|
+
const { options: userOptions, ...defaults } = provider;
|
|
11
|
+
if (!userOptions) {
|
|
12
|
+
throw new Error(`Provider ${provider.id} is missing options`);
|
|
13
|
+
}
|
|
14
|
+
const { paymentsAdapter, ...userOptionsWithPaymentsAdapter } = userOptions;
|
|
15
|
+
return {
|
|
16
|
+
...merge(defaults, userOptionsWithPaymentsAdapter),
|
|
17
|
+
...paymentsAdapter ? { options: paymentsAdapter } : {}
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
providers,
|
|
22
|
+
provider: providers.find(({ id }) => id === providerId)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
parseProviders
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-4QQA3TC2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/providers.ts"],"sourcesContent":["import { Provider } from '@coursebuilder/core/providers'\nimport { InternalProvider } from '@coursebuilder/core/types'\n\nimport { CourseBuilderConfig } from '../http'\nimport { merge } from './merge'\n\nexport default function parseProviders(params: {\n\tproviders: Provider[]\n\turl: URL\n\tproviderId?: string\n\toptions: CourseBuilderConfig\n}): {\n\tproviders: InternalProvider[]\n\tprovider?: InternalProvider\n} {\n\tconst { providerId, options } = params\n\n\tconst providers = params.providers.map((p) => {\n\t\tconst provider = typeof p === 'function' ? p() : p\n\t\tconst { options: userOptions, ...defaults } = provider\n\n\t\tif (!userOptions) {\n\t\t\tthrow new Error(`Provider ${provider.id} is missing options`)\n\t\t}\n\n\t\tconst { paymentsAdapter, ...userOptionsWithPaymentsAdapter } = userOptions\n\n\t\treturn {\n\t\t\t...merge(defaults, userOptionsWithPaymentsAdapter),\n\t\t\t...(paymentsAdapter ? { options: paymentsAdapter } : {}),\n\t\t}\n\t})\n\n\treturn {\n\t\tproviders,\n\t\tprovider: providers.find(({ id }) => id === providerId),\n\t}\n}\n"],"mappings":";;;;;AAMe,SAAR,eAAgC,QAQrC;AACD,QAAM,EAAE,YAAY,QAAQ,IAAI;AAEhC,QAAM,YAAY,OAAO,UAAU,IAAI,CAAC,MAAM;AAC7C,UAAM,WAAW,OAAO,MAAM,aAAa,EAAE,IAAI;AACjD,UAAM,EAAE,SAAS,aAAa,GAAG,SAAS,IAAI;AAE9C,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,YAAY,SAAS,EAAE,qBAAqB;AAAA,IAC7D;AAEA,UAAM,EAAE,iBAAiB,GAAG,+BAA+B,IAAI;AAE/D,WAAO;AAAA,MACN,GAAG,MAAM,UAAU,8BAA8B;AAAA,MACjD,GAAI,kBAAkB,EAAE,SAAS,gBAAgB,IAAI,CAAC;AAAA,IACvD;AAAA,EACD,CAAC;AAED,SAAO;AAAA,IACN;AAAA,IACA,UAAU,UAAU,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,UAAU;AAAA,EACvD;AACD;","names":[]}
|