@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.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/dist/actions/checkout.d.ts +6 -0
  3. package/dist/actions/checkout.js +9 -0
  4. package/dist/actions/checkout.js.map +1 -0
  5. package/dist/actions/claimed.d.ts +6 -0
  6. package/dist/actions/claimed.js +8 -0
  7. package/dist/actions/claimed.js.map +1 -0
  8. package/dist/actions/create-magic-link.d.ts +6 -0
  9. package/dist/actions/create-magic-link.js +9 -0
  10. package/dist/actions/create-magic-link.js.map +1 -0
  11. package/dist/actions/index.d.ts +11 -0
  12. package/dist/actions/index.js +18 -0
  13. package/dist/actions/index.js.map +1 -0
  14. package/dist/actions/prices-coupon-for-code.d.ts +6 -0
  15. package/dist/actions/prices-coupon-for-code.js +63 -0
  16. package/dist/actions/prices-coupon-for-code.js.map +1 -0
  17. package/dist/actions/prices-formatted.d.ts +6 -0
  18. package/dist/actions/prices-formatted.js +8 -0
  19. package/dist/actions/prices-formatted.js.map +1 -0
  20. package/dist/actions/process-refund.d.ts +1 -0
  21. package/dist/actions/process-refund.js +8 -0
  22. package/dist/actions/process-refund.js.map +1 -0
  23. package/dist/actions/redeem.d.ts +1 -0
  24. package/dist/actions/redeem.js +8 -0
  25. package/dist/actions/redeem.js.map +1 -0
  26. package/dist/actions/transfer-purchase.d.ts +1 -0
  27. package/dist/actions/transfer-purchase.js +8 -0
  28. package/dist/actions/transfer-purchase.js.map +1 -0
  29. package/dist/actions/user-lookup.d.ts +6 -0
  30. package/dist/actions/user-lookup.js +9 -0
  31. package/dist/actions/user-lookup.js.map +1 -0
  32. package/dist/adapter-BtDS6LDw.d.ts +9 -0
  33. package/dist/chunk-22AMOZYZ.js +67 -0
  34. package/dist/chunk-22AMOZYZ.js.map +1 -0
  35. package/dist/chunk-4EQQSW57.js +32 -0
  36. package/dist/chunk-4EQQSW57.js.map +1 -0
  37. package/dist/chunk-4LZZLN6T.js +52 -0
  38. package/dist/chunk-4LZZLN6T.js.map +1 -0
  39. package/dist/chunk-4QQA3TC2.js +29 -0
  40. package/dist/chunk-4QQA3TC2.js.map +1 -0
  41. package/dist/chunk-4TSEPUSC.js +160 -0
  42. package/dist/chunk-4TSEPUSC.js.map +1 -0
  43. package/dist/chunk-5O4UO4IR.js +93 -0
  44. package/dist/chunk-5O4UO4IR.js.map +1 -0
  45. package/dist/chunk-7FCQOLKL.js +26 -0
  46. package/dist/chunk-7FCQOLKL.js.map +1 -0
  47. package/dist/chunk-AZLUMIIF.js +8 -0
  48. package/dist/chunk-AZLUMIIF.js.map +1 -0
  49. package/dist/chunk-E6HV6TNI.js +38 -0
  50. package/dist/chunk-E6HV6TNI.js.map +1 -0
  51. package/dist/chunk-ECNJPNPU.js +54 -0
  52. package/dist/chunk-ECNJPNPU.js.map +1 -0
  53. package/dist/chunk-F3KUYN5I.js +111 -0
  54. package/dist/chunk-F3KUYN5I.js.map +1 -0
  55. package/dist/chunk-G63YAJF2.js +107 -0
  56. package/dist/chunk-G63YAJF2.js.map +1 -0
  57. package/dist/chunk-JFR7XO72.js +7 -0
  58. package/dist/chunk-JFR7XO72.js.map +1 -0
  59. package/dist/chunk-KNC7QVGZ.js +26 -0
  60. package/dist/chunk-KNC7QVGZ.js.map +1 -0
  61. package/dist/chunk-ODSSRMD2.js +270 -0
  62. package/dist/chunk-ODSSRMD2.js.map +1 -0
  63. package/dist/chunk-VEKYIR7I.js +26 -0
  64. package/dist/chunk-VEKYIR7I.js.map +1 -0
  65. package/dist/chunk-W7YAT4NR.js +12 -0
  66. package/dist/chunk-W7YAT4NR.js.map +1 -0
  67. package/dist/chunk-WGAPYIUP.js +56 -0
  68. package/dist/chunk-WGAPYIUP.js.map +1 -0
  69. package/dist/chunk-WYNH2AWD.js +7 -0
  70. package/dist/chunk-WYNH2AWD.js.map +1 -0
  71. package/dist/chunk-Y5X5J55Z.js +384 -0
  72. package/dist/chunk-Y5X5J55Z.js.map +1 -0
  73. package/dist/chunk-YFLGJIMA.js +216 -0
  74. package/dist/chunk-YFLGJIMA.js.map +1 -0
  75. package/dist/chunk-ZFZNN4E5.js +7 -0
  76. package/dist/chunk-ZFZNN4E5.js.map +1 -0
  77. package/dist/create-inngest-middleware.d.ts +635 -0
  78. package/dist/create-inngest-middleware.js +12 -0
  79. package/dist/create-inngest-middleware.js.map +1 -0
  80. package/dist/http-router.d.ts +20 -0
  81. package/dist/http-router.js +24 -0
  82. package/dist/http-router.js.map +1 -0
  83. package/dist/http.d.ts +38 -0
  84. package/dist/http.js +32 -0
  85. package/dist/http.js.map +1 -0
  86. package/dist/index.d.ts +34 -0
  87. package/dist/index.js +365 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/magic-string.es-ENO43NON.js +1389 -0
  90. package/dist/magic-string.es-ENO43NON.js.map +1 -0
  91. package/dist/runtime/actions.d.ts +5 -0
  92. package/dist/runtime/actions.js +8 -0
  93. package/dist/runtime/actions.js.map +1 -0
  94. package/dist/runtime/assert.d.ts +15 -0
  95. package/dist/runtime/assert.js +8 -0
  96. package/dist/runtime/assert.js.map +1 -0
  97. package/dist/runtime/cookie.d.ts +8 -0
  98. package/dist/runtime/cookie.js +8 -0
  99. package/dist/runtime/cookie.js.map +1 -0
  100. package/dist/runtime/env.d.ts +9 -0
  101. package/dist/runtime/env.js +11 -0
  102. package/dist/runtime/env.js.map +1 -0
  103. package/dist/runtime/env.test.d.ts +2 -0
  104. package/dist/runtime/env.test.js +14956 -0
  105. package/dist/runtime/env.test.js.map +1 -0
  106. package/dist/runtime/init.d.ts +26 -0
  107. package/dist/runtime/init.js +14 -0
  108. package/dist/runtime/init.js.map +1 -0
  109. package/dist/runtime/logger.d.ts +4 -0
  110. package/dist/runtime/logger.js +10 -0
  111. package/dist/runtime/logger.js.map +1 -0
  112. package/dist/runtime/merge.d.ts +4 -0
  113. package/dist/runtime/merge.js +8 -0
  114. package/dist/runtime/merge.js.map +1 -0
  115. package/dist/runtime/providers.d.ts +21 -0
  116. package/dist/runtime/providers.js +9 -0
  117. package/dist/runtime/providers.js.map +1 -0
  118. package/dist/runtime/web.d.ts +29 -0
  119. package/dist/runtime/web.js +16 -0
  120. package/dist/runtime/web.js.map +1 -0
  121. package/package.json +65 -0
  122. package/src/actions/actions.test.ts +232 -0
  123. package/src/actions/checkout.ts +160 -0
  124. package/src/actions/claimed.ts +40 -0
  125. package/src/actions/create-magic-link.ts +78 -0
  126. package/src/actions/index.ts +401 -0
  127. package/src/actions/prices-coupon-for-code.ts +91 -0
  128. package/src/actions/prices-formatted.ts +313 -0
  129. package/src/actions/process-refund.ts +2 -0
  130. package/src/actions/redeem.ts +2 -0
  131. package/src/actions/transfer-purchase.ts +2 -0
  132. package/src/actions/user-lookup.ts +37 -0
  133. package/src/adapter.ts +28 -0
  134. package/src/create-inngest-middleware.ts +157 -0
  135. package/src/http-actions.ts +29 -0
  136. package/src/http-router.ts +79 -0
  137. package/src/http.test.ts +46 -0
  138. package/src/http.ts +83 -0
  139. package/src/index.test.ts +21 -0
  140. package/src/index.ts +44 -0
  141. package/src/mock-adapter.ts +398 -0
  142. package/src/mock-payment-provider.ts +56 -0
  143. package/src/resource-chat.ts +371 -0
  144. package/src/runtime/actions.ts +25 -0
  145. package/src/runtime/assert.ts +55 -0
  146. package/src/runtime/cookie.ts +12 -0
  147. package/src/runtime/env.test.ts +49 -0
  148. package/src/runtime/env.ts +63 -0
  149. package/src/runtime/init.ts +112 -0
  150. package/src/runtime/logger.ts +6 -0
  151. package/src/runtime/merge.ts +25 -0
  152. package/src/runtime/providers.ts +38 -0
  153. package/src/runtime/web.ts +199 -0
  154. package/src/streaming-chat-prompt-executor.ts +43 -0
  155. package/src/type-contracts.test.ts +167 -0
  156. package/src/web-body-parse.test.ts +55 -0
@@ -0,0 +1,107 @@
1
+ import {
2
+ init
3
+ } from "./chunk-5O4UO4IR.js";
4
+ import {
5
+ UnknownAction
6
+ } from "./chunk-4TSEPUSC.js";
7
+ import {
8
+ getPricesFormatted
9
+ } from "./chunk-YFLGJIMA.js";
10
+ import {
11
+ processRefund
12
+ } from "./chunk-JFR7XO72.js";
13
+ import {
14
+ redeem
15
+ } from "./chunk-WYNH2AWD.js";
16
+ import {
17
+ transferPurchase
18
+ } from "./chunk-ZFZNN4E5.js";
19
+ import {
20
+ userLookup
21
+ } from "./chunk-4EQQSW57.js";
22
+ import {
23
+ checkout
24
+ } from "./chunk-F3KUYN5I.js";
25
+ import {
26
+ claimed
27
+ } from "./chunk-7FCQOLKL.js";
28
+ import {
29
+ createMagicLink
30
+ } from "./chunk-22AMOZYZ.js";
31
+ import {
32
+ getSubscriber,
33
+ getUserPurchases,
34
+ session,
35
+ subscribeToList,
36
+ webhook
37
+ } from "./chunk-ODSSRMD2.js";
38
+
39
+ // src/http-actions.ts
40
+ async function srt(request, cookies, options) {
41
+ const client = options.adapter;
42
+ const resource = await client?.getContentResource(
43
+ request.query?.videoResourceId
44
+ );
45
+ if (!resource)
46
+ throw new Error("Resource not found");
47
+ return {
48
+ status: 200,
49
+ body: resource.fields?.srt,
50
+ headers: { "Content-Type": "application/text" },
51
+ cookies
52
+ };
53
+ }
54
+
55
+ // src/http-router.ts
56
+ async function CourseBuilderInternal(request, courseBuilderOptions) {
57
+ const { action, providerId, method } = request;
58
+ const { options, cookies } = await init({
59
+ courseBuilderOptions,
60
+ action,
61
+ providerId,
62
+ url: request.url,
63
+ cookies: request.cookies,
64
+ isPost: method === "POST"
65
+ });
66
+ if (method === "GET") {
67
+ switch (action) {
68
+ case "srt":
69
+ return await srt(request, cookies, options);
70
+ case "session":
71
+ return await session(options, cookies);
72
+ case "subscriber":
73
+ return await getSubscriber(options, cookies);
74
+ case "purchases":
75
+ return await getUserPurchases(request, cookies, options);
76
+ }
77
+ } else {
78
+ switch (action) {
79
+ case "prices-formatted":
80
+ return await getPricesFormatted(request, cookies, options);
81
+ case "redeem":
82
+ return await redeem(request, cookies, options);
83
+ case "refund":
84
+ return await processRefund(request, cookies, options);
85
+ case "checkout":
86
+ return await checkout(request, cookies, options);
87
+ case "claimed":
88
+ return await claimed(request, cookies, options);
89
+ case "webhook":
90
+ return await webhook(request, cookies, options);
91
+ case "subscribe-to-list":
92
+ return await subscribeToList(request, cookies, options);
93
+ case "lookup":
94
+ return await userLookup(request, cookies, options);
95
+ case "create-magic-link":
96
+ return await createMagicLink(request, cookies, options);
97
+ case "transfer":
98
+ return await transferPurchase(request, cookies, options);
99
+ }
100
+ }
101
+ throw new UnknownAction(`Cannot handle action: ${action}`);
102
+ }
103
+
104
+ export {
105
+ CourseBuilderInternal
106
+ };
107
+ //# sourceMappingURL=chunk-G63YAJF2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/http-actions.ts","../src/http-router.ts"],"sourcesContent":["import type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\n\nimport type { Cookie } from './runtime/cookie'\n\n/** Serve the persisted SRT body for Mux's HTTP callback. */\nexport async function srt(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tconst client = options.adapter\n\n\tconst resource = await client?.getContentResource(\n\t\trequest.query?.videoResourceId,\n\t)\n\n\tif (!resource) throw new Error('Resource not found')\n\n\treturn {\n\t\tstatus: 200,\n\t\tbody: resource.fields?.srt,\n\t\theaders: { 'Content-Type': 'application/text' },\n\t\tcookies,\n\t}\n}\n","import type {\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\n\nimport { checkout } from './actions/checkout'\nimport { claimed } from './actions/claimed'\nimport { createMagicLink } from './actions/create-magic-link'\nimport * as actions from './actions/index'\nimport { getPricesFormatted } from './actions/prices-formatted'\nimport { processRefund } from './actions/process-refund'\nimport { redeem } from './actions/redeem'\nimport { transferPurchase } from './actions/transfer-purchase'\nimport { userLookup } from './actions/user-lookup'\nimport type { CourseBuilderConfig } from './http'\nimport { srt } from './http-actions'\nimport { init } from './runtime/init'\nimport { UnknownAction } from './runtime/web'\n\n/**\n * Route an internal Course Builder request to its runtime action.\n *\n * @param request - Parsed internal request.\n * @param courseBuilderOptions - Server runtime configuration.\n * @returns The internal response emitted by the selected action.\n */\nexport async function CourseBuilderInternal(\n\trequest: RequestInternal,\n\tcourseBuilderOptions: CourseBuilderConfig,\n): Promise<ResponseInternal> {\n\tconst { action, providerId, method } = request\n\n\tconst { options, cookies } = await init({\n\t\tcourseBuilderOptions,\n\t\taction,\n\t\tproviderId,\n\t\turl: request.url,\n\t\tcookies: request.cookies,\n\t\tisPost: method === 'POST',\n\t})\n\n\tif (method === 'GET') {\n\t\tswitch (action) {\n\t\t\tcase 'srt':\n\t\t\t\treturn await srt(request, cookies, options)\n\t\t\tcase 'session':\n\t\t\t\treturn await actions.session(options, cookies)\n\t\t\tcase 'subscriber':\n\t\t\t\treturn await actions.getSubscriber(options, cookies)\n\t\t\tcase 'purchases':\n\t\t\t\treturn await actions.getUserPurchases(request, cookies, options)\n\t\t}\n\t} else {\n\t\tswitch (action) {\n\t\t\tcase 'prices-formatted':\n\t\t\t\treturn await getPricesFormatted(request, cookies, options)\n\t\t\tcase 'redeem':\n\t\t\t\treturn await redeem(request, cookies, options)\n\t\t\tcase 'refund':\n\t\t\t\treturn await processRefund(request, cookies, options)\n\t\t\tcase 'checkout':\n\t\t\t\treturn await checkout(request, cookies, options)\n\t\t\tcase 'claimed':\n\t\t\t\treturn await claimed(request, cookies, options)\n\t\t\tcase 'webhook':\n\t\t\t\treturn await actions.webhook(request, cookies, options)\n\t\t\tcase 'subscribe-to-list':\n\t\t\t\treturn await actions.subscribeToList(request, cookies, options)\n\t\t\tcase 'lookup':\n\t\t\t\treturn await userLookup(request, cookies, options)\n\t\t\tcase 'create-magic-link':\n\t\t\t\treturn await createMagicLink(request, cookies, options)\n\t\t\tcase 'transfer':\n\t\t\t\treturn await transferPurchase(request, cookies, options)\n\t\t}\n\t}\n\n\tthrow new UnknownAction(`Cann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AACJ,eAAO,MAAM,QAAQ,SAAS,SAAS,OAAO;AAAA,MAC/C,KAAK;AACJ,eAAO,MAAc,QAAQ,SAAS,SAAS,OAAO;AAAA,MACvD,KAAK;AACJ,eAAO,MAAc,gBAAgB,SAAS,SAAS,OAAO;AAAA,MAC/D,KAAK;AACJ,eAAO,MAAM,WAAW,SAAS,SAAS,OAAO;AAAA,MAClD,KAAK;AACJ,eAAO,MAAM,gBAAgB,SAAS,SAAS,OAAO;AAAA,MACvD,KAAK;AACJ,eAAO,MAAM,iBAAiB,SAAS,SAAS,OAAO;AAAA,IACzD;AAAA,EACD;AAEA,QAAM,IAAI,cAAc,yBAAyB,MAAM,EAAE;AAC1D;","names":[]}
@@ -0,0 +1,7 @@
1
+ // src/actions/process-refund.ts
2
+ import { processRefund } from "@coursebuilder/commerce/process-refund";
3
+
4
+ export {
5
+ processRefund
6
+ };
7
+ //# sourceMappingURL=chunk-JFR7XO72.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/actions/process-refund.ts"],"sourcesContent":["/** HTTP-compatible refund operation owned by the commerce engine. */\nexport { processRefund } from '@coursebuilder/commerce/process-refund'\n"],"mappings":";AACA,SAAS,qBAAqB;","names":[]}
@@ -0,0 +1,26 @@
1
+ // src/runtime/merge.ts
2
+ function isObject(item) {
3
+ return item && typeof item === "object" && !Array.isArray(item);
4
+ }
5
+ function merge(target, ...sources) {
6
+ if (!sources.length)
7
+ return target;
8
+ const source = sources.shift();
9
+ if (isObject(target) && isObject(source)) {
10
+ for (const key in source) {
11
+ if (isObject(source[key])) {
12
+ if (!target[key])
13
+ Object.assign(target, { [key]: {} });
14
+ merge(target[key], source[key]);
15
+ } else {
16
+ Object.assign(target, { [key]: source[key] });
17
+ }
18
+ }
19
+ }
20
+ return merge(target, ...sources);
21
+ }
22
+
23
+ export {
24
+ merge
25
+ };
26
+ //# sourceMappingURL=chunk-KNC7QVGZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/merge.ts"],"sourcesContent":["// Source: https://stackoverflow.com/a/34749873/5364135\n\n/** Simple object check */\nfunction isObject(item: any): boolean {\n\treturn item && typeof item === 'object' && !Array.isArray(item)\n}\n\n/** Deep merge two objects */\nexport function merge(target: any, ...sources: any[]): any {\n\tif (!sources.length) return target\n\tconst source = sources.shift()\n\n\tif (isObject(target) && isObject(source)) {\n\t\tfor (const key in source) {\n\t\t\tif (isObject(source[key])) {\n\t\t\t\tif (!target[key]) Object.assign(target, { [key]: {} })\n\t\t\t\tmerge(target[key], source[key])\n\t\t\t} else {\n\t\t\t\tObject.assign(target, { [key]: source[key] })\n\t\t\t}\n\t\t}\n\t}\n\n\treturn merge(target, ...sources)\n}\n"],"mappings":";AAGA,SAAS,SAAS,MAAoB;AACrC,SAAO,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI;AAC/D;AAGO,SAAS,MAAM,WAAgB,SAAqB;AAC1D,MAAI,CAAC,QAAQ;AAAQ,WAAO;AAC5B,QAAM,SAAS,QAAQ,MAAM;AAE7B,MAAI,SAAS,MAAM,KAAK,SAAS,MAAM,GAAG;AACzC,eAAW,OAAO,QAAQ;AACzB,UAAI,SAAS,OAAO,GAAG,CAAC,GAAG;AAC1B,YAAI,CAAC,OAAO,GAAG;AAAG,iBAAO,OAAO,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;AACrD,cAAM,OAAO,GAAG,GAAG,OAAO,GAAG,CAAC;AAAA,MAC/B,OAAO;AACN,eAAO,OAAO,QAAQ,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,EAAE,CAAC;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AAEA,SAAO,MAAM,QAAQ,GAAG,OAAO;AAChC;","names":[]}
@@ -0,0 +1,270 @@
1
+ // src/actions/index.ts
2
+ import { z } from "zod";
3
+ import { processStripeWebhook } from "@coursebuilder/commerce/process-stripe-webhook";
4
+ import {
5
+ VIDEO_SRT_READY_EVENT,
6
+ VIDEO_TRANSCRIPT_READY_EVENT
7
+ } from "@coursebuilder/core/events/video";
8
+ import { sendServerEmail } from "@coursebuilder/email/send-server-email";
9
+ import {
10
+ srtFromTranscriptResult,
11
+ transcriptAsParagraphsWithTimestamps,
12
+ wordLevelSrtFromTranscriptResult
13
+ } from "@coursebuilder/video-processing/transcript-transforms";
14
+ var oneYear = 31556952;
15
+ function getConvertkitSubscriberCookie(subscriber) {
16
+ return subscriber ? [
17
+ {
18
+ name: "ck_subscriber",
19
+ value: JSON.stringify(subscriber),
20
+ options: {
21
+ secure: true,
22
+ httpOnly: true,
23
+ path: "/",
24
+ maxAge: oneYear,
25
+ sameSite: "lax"
26
+ }
27
+ },
28
+ {
29
+ name: process.env.NEXT_PUBLIC_CONVERTKIT_SUBSCRIBER_KEY || "ck_subscriber_id",
30
+ value: subscriber.id,
31
+ options: {
32
+ secure: true,
33
+ httpOnly: true,
34
+ path: "/",
35
+ maxAge: oneYear,
36
+ sameSite: "lax"
37
+ }
38
+ }
39
+ ] : [];
40
+ }
41
+ function filterNullFields(obj) {
42
+ const filteredObj = {};
43
+ for (const key in obj) {
44
+ if (obj[key] !== null) {
45
+ if (typeof obj[key] === "object" && !Array.isArray(obj[key])) {
46
+ filteredObj[key] = filterNullFields(obj[key]);
47
+ } else {
48
+ filteredObj[key] = obj[key];
49
+ }
50
+ }
51
+ }
52
+ return filteredObj;
53
+ }
54
+ async function getUserPurchases(request, cookies, options) {
55
+ const client = options.adapter;
56
+ const currentUser = await options.getCurrentUser?.();
57
+ if (!currentUser?.id || currentUser.id !== request.query?.userId) {
58
+ return {
59
+ status: 401,
60
+ body: [],
61
+ headers: { "Content-Type": "application/json" },
62
+ cookies
63
+ };
64
+ }
65
+ if (!request.query?.userId)
66
+ return {
67
+ status: 200,
68
+ body: [],
69
+ headers: { "Content-Type": "application/json" },
70
+ cookies
71
+ };
72
+ const purchases = await client?.getPurchasesForUser(request.query.userId);
73
+ if (!purchases) {
74
+ return {
75
+ status: 200,
76
+ body: [],
77
+ headers: { "Content-Type": "application/json" },
78
+ cookies
79
+ };
80
+ } else {
81
+ return {
82
+ status: 200,
83
+ body: purchases,
84
+ headers: { "Content-Type": "application/json" },
85
+ cookies
86
+ };
87
+ }
88
+ }
89
+ async function getSubscriber(options, cookies) {
90
+ switch (options.provider.type) {
91
+ case "email-list":
92
+ const subscriber = await options.provider.getSubscriber(
93
+ options.url.searchParams.get("subscriberId") || options.cookies.ck_subscriber_id || null
94
+ );
95
+ return {
96
+ status: 200,
97
+ body: subscriber,
98
+ headers: { "Content-Type": "application/json" },
99
+ cookies: getConvertkitSubscriberCookie(subscriber)
100
+ };
101
+ default:
102
+ throw new Error("Unsupported provider");
103
+ }
104
+ }
105
+ async function subscribeToList(request, cookies, options) {
106
+ const response = {
107
+ body: null,
108
+ headers: { "Content-Type": "application/json" },
109
+ cookies
110
+ };
111
+ switch (options.provider.type) {
112
+ case "email-list":
113
+ const subscribeOptions = z.object({
114
+ listId: z.union([z.number(), z.string()]).optional(),
115
+ listType: z.string().optional(),
116
+ fields: z.record(z.string(), z.any()).optional().nullable(),
117
+ email: z.string(),
118
+ name: z.string().optional().nullable()
119
+ }).parse(request.body);
120
+ let user = await options.adapter?.getUserByEmail(subscribeOptions.email);
121
+ if (!user) {
122
+ user = await options.adapter?.createUser({
123
+ id: crypto.randomUUID(),
124
+ email: subscribeOptions.email,
125
+ name: subscribeOptions.name,
126
+ emailVerified: null
127
+ });
128
+ if (!user)
129
+ throw new Error("Could not create user");
130
+ options.logger.debug(`created user ${user.id}`);
131
+ } else {
132
+ options.logger.debug(`found user ${user.id}`);
133
+ }
134
+ response.body = await options.provider.subscribeToList({
135
+ user,
136
+ listId: subscribeOptions.listId || options.provider.defaultListId,
137
+ fields: subscribeOptions.fields || {},
138
+ listType: subscribeOptions.listType || options.provider.defaultListType
139
+ });
140
+ response.cookies = getConvertkitSubscriberCookie(
141
+ filterNullFields(response.body)
142
+ );
143
+ if (!user.emailVerified) {
144
+ const emailProvider = options.providers.find(
145
+ (p) => p.type === "email"
146
+ );
147
+ if (emailProvider && options.adapter && options.provider.id === "coursebuilder") {
148
+ await sendServerEmail({
149
+ email: user.email,
150
+ type: "signup",
151
+ callbackUrl: `${options.baseUrl}/confirmed`,
152
+ emailProvider,
153
+ authOptions: options.authConfig,
154
+ adapter: options.adapter,
155
+ baseUrl: options.baseUrl
156
+ });
157
+ }
158
+ }
159
+ }
160
+ return response;
161
+ }
162
+ async function session(options, cookies) {
163
+ const { callbacks, logger } = options;
164
+ const response = {
165
+ body: null,
166
+ headers: { "Content-Type": "application/json" },
167
+ cookies
168
+ };
169
+ try {
170
+ response.body = await callbacks.session({});
171
+ } catch (e) {
172
+ logger.error(e);
173
+ }
174
+ return response;
175
+ }
176
+ async function srt(request, cookies, options) {
177
+ const client = options.adapter;
178
+ const resource = await client?.getContentResource(
179
+ request.query?.videoResourceId
180
+ );
181
+ if (!resource)
182
+ throw new Error("Resource not found");
183
+ return {
184
+ status: 200,
185
+ body: resource.fields?.srt,
186
+ headers: { "Content-Type": "application/text" },
187
+ cookies
188
+ };
189
+ }
190
+ async function webhook(request, cookies, options) {
191
+ if (!options.provider)
192
+ throw new Error("Provider not found");
193
+ switch (options.provider.type) {
194
+ case "payment":
195
+ if (options.provider.id === "stripe") {
196
+ await processStripeWebhook(request.body, options);
197
+ return Response.json("ok", { status: 200 });
198
+ } else {
199
+ throw new Error("Unsupported provider");
200
+ }
201
+ case "transcription":
202
+ if (!request.body)
203
+ throw new Error("No body");
204
+ const { results } = request.body;
205
+ const videoResourceId = options.url.searchParams.get("videoResourceId");
206
+ if (!videoResourceId)
207
+ throw new Error("No videoResourceId");
208
+ const videoResource = await options.adapter?.getContentResource(videoResourceId);
209
+ if (!videoResource)
210
+ throw new Error("No videoResource");
211
+ const rawTranscriptId = `raw-transcript-${videoResourceId}`;
212
+ const existingRawTranscript = await options.adapter?.getContentResource(rawTranscriptId);
213
+ if (!existingRawTranscript) {
214
+ await options.adapter?.createContentResource({
215
+ id: rawTranscriptId,
216
+ type: "raw-transcript",
217
+ fields: {
218
+ deepgramResults: results
219
+ },
220
+ createdById: videoResource.createdById
221
+ });
222
+ await options.adapter?.addResourceToResource({
223
+ childResourceId: rawTranscriptId,
224
+ parentResourceId: videoResourceId
225
+ });
226
+ }
227
+ const srt2 = srtFromTranscriptResult(results);
228
+ const wordLevelSrt = wordLevelSrtFromTranscriptResult(results);
229
+ const transcript = transcriptAsParagraphsWithTimestamps(results);
230
+ await options.adapter?.updateContentResourceFields({
231
+ id: videoResourceId,
232
+ fields: {
233
+ transcript,
234
+ srt: srt2,
235
+ wordLevelSrt
236
+ }
237
+ });
238
+ await options.inngest.send({
239
+ name: VIDEO_TRANSCRIPT_READY_EVENT,
240
+ data: {
241
+ videoResourceId
242
+ }
243
+ });
244
+ if (srt2 && wordLevelSrt && videoResourceId) {
245
+ await options.inngest.send({
246
+ name: VIDEO_SRT_READY_EVENT,
247
+ data: {
248
+ videoResourceId
249
+ }
250
+ });
251
+ }
252
+ return {
253
+ status: 200,
254
+ body: null,
255
+ headers: { "Content-Type": "application/json" },
256
+ cookies
257
+ };
258
+ }
259
+ throw new Error("Invalid provider type");
260
+ }
261
+
262
+ export {
263
+ getUserPurchases,
264
+ getSubscriber,
265
+ subscribeToList,
266
+ session,
267
+ srt,
268
+ webhook
269
+ };
270
+ //# sourceMappingURL=chunk-ODSSRMD2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/actions/index.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { processStripeWebhook } from '@coursebuilder/commerce/process-stripe-webhook'\nimport type { CourseBuilderEmailProvider } from '@coursebuilder/core/auth'\nimport {\n\tVIDEO_SRT_READY_EVENT,\n\tVIDEO_TRANSCRIPT_READY_EVENT,\n} from '@coursebuilder/core/events/video'\nimport type {\n\tInternalOptions,\n\tRequestInternal,\n\tResponseInternal,\n} from '@coursebuilder/core/types'\nimport { sendServerEmail } from '@coursebuilder/email/send-server-email'\nimport {\n\tsrtFromTranscriptResult,\n\ttranscriptAsParagraphsWithTimestamps,\n\twordLevelSrtFromTranscriptResult,\n} from '@coursebuilder/video-processing/transcript-transforms'\n\nimport type { Cookie } from '../runtime/cookie'\n\nconst oneYear = 31556952\n\nfunction getConvertkitSubscriberCookie(subscriber: any): Cookie[] {\n\treturn subscriber\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tname: 'ck_subscriber',\n\t\t\t\t\tvalue: JSON.stringify(subscriber),\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tsecure: true,\n\t\t\t\t\t\thttpOnly: true,\n\t\t\t\t\t\tpath: '/',\n\t\t\t\t\t\tmaxAge: oneYear,\n\t\t\t\t\t\tsameSite: 'lax',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname:\n\t\t\t\t\t\tprocess.env.NEXT_PUBLIC_CONVERTKIT_SUBSCRIBER_KEY ||\n\t\t\t\t\t\t'ck_subscriber_id',\n\t\t\t\t\tvalue: subscriber.id,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tsecure: true,\n\t\t\t\t\t\thttpOnly: true,\n\t\t\t\t\t\tpath: '/',\n\t\t\t\t\t\tmaxAge: oneYear,\n\t\t\t\t\t\tsameSite: 'lax',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]\n\t\t: []\n}\n\ntype Subscriber = Record<string, any>\n\nfunction filterNullFields(obj: Subscriber): Subscriber {\n\tconst filteredObj: Subscriber = {}\n\n\tfor (const key in obj) {\n\t\tif (obj[key] !== null) {\n\t\t\tif (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {\n\t\t\t\tfilteredObj[key] = filterNullFields(obj[key] as Subscriber)\n\t\t\t} else {\n\t\t\t\tfilteredObj[key] = obj[key]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn filteredObj\n}\n\nexport async function getUserPurchases(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tconst client = options.adapter\n\n\tconst currentUser = await options.getCurrentUser?.()\n\n\tif (!currentUser?.id || currentUser.id !== request.query?.userId) {\n\t\treturn {\n\t\t\tstatus: 401,\n\t\t\tbody: [],\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\t}\n\n\tif (!request.query?.userId)\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\tbody: [],\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\n\tconst purchases = await client?.getPurchasesForUser(request.query.userId)\n\n\tif (!purchases) {\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\tbody: [],\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\t} else {\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\tbody: purchases,\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tcookies,\n\t\t}\n\t}\n}\n\nexport async function getSubscriber(\n\toptions: InternalOptions<'email-list'>,\n\tcookies: Cookie[],\n): Promise<ResponseInternal<any | null>> {\n\tswitch (options.provider.type) {\n\t\tcase 'email-list':\n\t\t\tconst subscriber = await options.provider.getSubscriber(\n\t\t\t\toptions.url.searchParams.get('subscriberId') ||\n\t\t\t\t\toptions.cookies.ck_subscriber_id ||\n\t\t\t\t\tnull,\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tstatus: 200,\n\t\t\t\tbody: subscriber,\n\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\tcookies: getConvertkitSubscriberCookie(subscriber),\n\t\t\t}\n\t\tdefault:\n\t\t\tthrow new Error('Unsupported provider')\n\t}\n}\n\nexport async function subscribeToList(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions<'email-list'>,\n): Promise<ResponseInternal<any | null>> {\n\tconst response: ResponseInternal<any | null> = {\n\t\tbody: null,\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tcookies,\n\t}\n\n\tswitch (options.provider.type) {\n\t\tcase 'email-list':\n\t\t\tconst subscribeOptions = z\n\t\t\t\t.object({\n\t\t\t\t\tlistId: z.union([z.number(), z.string()]).optional(),\n\t\t\t\t\tlistType: z.string().optional(),\n\t\t\t\t\tfields: z.record(z.string(), z.any()).optional().nullable(),\n\t\t\t\t\temail: z.string(),\n\t\t\t\t\tname: z.string().optional().nullable(),\n\t\t\t\t})\n\t\t\t\t.parse(request.body)\n\n\t\t\tlet user = await options.adapter?.getUserByEmail(subscribeOptions.email)\n\n\t\t\tif (!user) {\n\t\t\t\tuser = await options.adapter?.createUser({\n\t\t\t\t\tid: crypto.randomUUID(),\n\t\t\t\t\temail: subscribeOptions.email,\n\t\t\t\t\tname: subscribeOptions.name,\n\t\t\t\t\temailVerified: null,\n\t\t\t\t})\n\t\t\t\tif (!user) throw new Error('Could not create user')\n\t\t\t\toptions.logger.debug(`created user ${user.id}`)\n\t\t\t} else {\n\t\t\t\toptions.logger.debug(`found user ${user.id}`)\n\t\t\t}\n\n\t\t\tresponse.body = await options.provider.subscribeToList({\n\t\t\t\tuser,\n\t\t\t\tlistId: subscribeOptions.listId || options.provider.defaultListId,\n\t\t\t\tfields: subscribeOptions.fields || {},\n\t\t\t\tlistType: subscribeOptions.listType || options.provider.defaultListType,\n\t\t\t})\n\n\t\t\tresponse.cookies = getConvertkitSubscriberCookie(\n\t\t\t\tfilterNullFields(response.body),\n\t\t\t)\n\n\t\t\tif (!user.emailVerified) {\n\t\t\t\tconst emailProvider = options.providers.find(\n\t\t\t\t\t(p) => p.type === 'email',\n\t\t\t\t) as CourseBuilderEmailProvider\n\n\t\t\t\tif (\n\t\t\t\t\temailProvider &&\n\t\t\t\t\toptions.adapter &&\n\t\t\t\t\toptions.provider.id === 'coursebuilder'\n\t\t\t\t) {\n\t\t\t\t\tawait sendServerEmail({\n\t\t\t\t\t\temail: user.email,\n\t\t\t\t\t\ttype: 'signup',\n\t\t\t\t\t\tcallbackUrl: `${options.baseUrl}/confirmed`,\n\t\t\t\t\t\temailProvider,\n\t\t\t\t\t\tauthOptions: options.authConfig,\n\t\t\t\t\t\tadapter: options.adapter,\n\t\t\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t}\n\n\treturn response\n}\n\nexport async function session(\n\toptions: InternalOptions,\n\tcookies: Cookie[],\n): Promise<ResponseInternal<any | null>> {\n\tconst { callbacks, logger } = options\n\n\tconst response: ResponseInternal<any | null> = {\n\t\tbody: null,\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tcookies,\n\t}\n\n\ttry {\n\t\tresponse.body = await callbacks.session({})\n\t} catch (e) {\n\t\tlogger.error(e as Error)\n\t}\n\n\treturn response\n}\n\nexport async function srt(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions,\n): Promise<ResponseInternal> {\n\tconst client = options.adapter\n\n\tconst resource = await client?.getContentResource(\n\t\trequest.query?.videoResourceId,\n\t)\n\n\tif (!resource) throw new Error('Resource not found')\n\n\treturn {\n\t\tstatus: 200,\n\t\tbody: resource.fields?.srt,\n\t\theaders: { 'Content-Type': 'application/text' },\n\t\tcookies,\n\t}\n}\n\nexport async function webhook(\n\trequest: RequestInternal,\n\tcookies: Cookie[],\n\toptions: InternalOptions<'transcription' | 'payment'>,\n): Promise<ResponseInternal> {\n\tif (!options.provider) throw new Error('Provider not found')\n\n\tswitch (options.provider.type) {\n\t\tcase 'payment':\n\t\t\tif (options.provider.id === 'stripe') {\n\t\t\t\tawait processStripeWebhook(request.body, options)\n\t\t\t\treturn Response.json('ok', { status: 200 })\n\t\t\t} else {\n\t\t\t\tthrow new Error('Unsupported provider')\n\t\t\t}\n\n\t\tcase 'transcription':\n\t\t\tif (!request.body) throw new Error('No body')\n\n\t\t\tconst { results } = request.body\n\n\t\t\tconst videoResourceId = options.url.searchParams.get('videoResourceId')\n\n\t\t\tif (!videoResourceId) throw new Error('No videoResourceId')\n\n\t\t\tconst videoResource =\n\t\t\t\tawait options.adapter?.getContentResource(videoResourceId)\n\n\t\t\tif (!videoResource) throw new Error('No videoResource')\n\n\t\t\tconst rawTranscriptId = `raw-transcript-${videoResourceId}`\n\n\t\t\tconst existingRawTranscript =\n\t\t\t\tawait options.adapter?.getContentResource(rawTranscriptId)\n\n\t\t\tif (!existingRawTranscript) {\n\t\t\t\tawait options.adapter?.createContentResource({\n\t\t\t\t\tid: rawTranscriptId,\n\t\t\t\t\ttype: 'raw-transcript',\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tdeepgramResults: results,\n\t\t\t\t\t},\n\t\t\t\t\tcreatedById: videoResource.createdById,\n\t\t\t\t})\n\t\t\t\tawait options.adapter?.addResourceToResource({\n\t\t\t\t\tchildResourceId: rawTranscriptId,\n\t\t\t\t\tparentResourceId: videoResourceId,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst srt = srtFromTranscriptResult(results)\n\t\t\tconst wordLevelSrt = wordLevelSrtFromTranscriptResult(results)\n\t\t\tconst transcript = transcriptAsParagraphsWithTimestamps(results)\n\n\t\t\t// await options.adapter?.createContentResource({\n\t\t\t// \tid: `raw-transcript-${videoResourceId}`,\n\t\t\t// \ttype: 'raw-transcript',\n\t\t\t// \tfields: {\n\t\t\t// \t\trawTranscript: results,\n\t\t\t// \t},\n\t\t\t// \tcreatedById: videoResource.createdById,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.addResourceToResource({\n\t\t\t// \tchildResourceId: `transcript-${videoResourceId}`,\n\t\t\t// \tparentResourceId: videoResourceId,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.createContentResource({\n\t\t\t// \tid: `transcript-${videoResourceId}`,\n\t\t\t// \ttype: 'transcript',\n\t\t\t// \tfields: {\n\t\t\t// \t\ttranscript,\n\t\t\t// \t},\n\t\t\t// \tcreatedById: videoResource.createdById,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.addResourceToResource({\n\t\t\t// \tchildResourceId: `transcript-${videoResourceId}`,\n\t\t\t// \tparentResourceId: videoResourceId,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.createContentResource({\n\t\t\t// \tid: `srt-${videoResourceId}`,\n\t\t\t// \ttype: 'srt',\n\t\t\t// \tfields: {\n\t\t\t// \t\tsrt,\n\t\t\t// \t},\n\t\t\t// \tcreatedById: videoResource.createdById,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.addResourceToResource({\n\t\t\t// \tchildResourceId: `srt-${videoResourceId}`,\n\t\t\t// \tparentResourceId: videoResourceId,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.createContentResource({\n\t\t\t// \tid: `word-level-srt-${videoResourceId}`,\n\t\t\t// \ttype: 'word-level-srt',\n\t\t\t// \tfields: {\n\t\t\t// \t\twordLevelSrt,\n\t\t\t// \t},\n\t\t\t// \tcreatedById: videoResource.createdById,\n\t\t\t// })\n\t\t\t//\n\t\t\t// await options.adapter?.addResourceToResource({\n\t\t\t// \tchildResourceId: `word-level-srt-${videoResourceId}`,\n\t\t\t// \tparentResourceId: videoResourceId,\n\t\t\t// })\n\n\t\t\tawait options.adapter?.updateContentResourceFields({\n\t\t\t\tid: videoResourceId as string,\n\t\t\t\tfields: {\n\t\t\t\t\ttranscript,\n\t\t\t\t\tsrt,\n\t\t\t\t\twordLevelSrt,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tawait options.inngest.send({\n\t\t\t\tname: VIDEO_TRANSCRIPT_READY_EVENT,\n\t\t\t\tdata: {\n\t\t\t\t\tvideoResourceId,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tif (srt && wordLevelSrt && videoResourceId) {\n\t\t\t\tawait options.inngest.send({\n\t\t\t\t\tname: VIDEO_SRT_READY_EVENT,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tvideoResourceId: videoResourceId,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: 200,\n\t\t\t\tbody: null,\n\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t\tcookies,\n\t\t\t}\n\t}\n\n\tthrow new Error('Invalid provider type')\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAElB,SAAS,4BAA4B;AAErC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAMP,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAIP,IAAM,UAAU;AAEhB,SAAS,8BAA8B,YAA2B;AACjE,SAAO,aACJ;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO,KAAK,UAAU,UAAU;AAAA,MAChC,SAAS;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,UAAU;AAAA,MACX;AAAA,IACD;AAAA,IACA;AAAA,MACC,MACC,QAAQ,IAAI,yCACZ;AAAA,MACD,OAAO,WAAW;AAAA,MAClB,SAAS;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,UAAU;AAAA,MACX;AAAA,IACD;AAAA,EACD,IACC,CAAC;AACL;AAIA,SAAS,iBAAiB,KAA6B;AACtD,QAAM,cAA0B,CAAC;AAEjC,aAAW,OAAO,KAAK;AACtB,QAAI,IAAI,GAAG,MAAM,MAAM;AACtB,UAAI,OAAO,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG,CAAC,GAAG;AAC7D,oBAAY,GAAG,IAAI,iBAAiB,IAAI,GAAG,CAAe;AAAA,MAC3D,OAAO;AACN,oBAAY,GAAG,IAAI,IAAI,GAAG;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,iBACrB,SACA,SACA,SAC4B;AAC5B,QAAM,SAAS,QAAQ;AAEvB,QAAM,cAAc,MAAM,QAAQ,iBAAiB;AAEnD,MAAI,CAAC,aAAa,MAAM,YAAY,O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AAA,QACR,MAAM;AAAA,QACN,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C;AAAA,MACD;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,uBAAuB;AACxC;","names":["srt"]}
@@ -0,0 +1,26 @@
1
+ // src/runtime/actions.ts
2
+ var actions = [
3
+ "webhook",
4
+ "srt",
5
+ "session",
6
+ "subscribe-to-list",
7
+ "checkout",
8
+ "redeem",
9
+ "prices-formatted",
10
+ "subscriber",
11
+ "purchases",
12
+ "lookup",
13
+ "claimed",
14
+ "nameUpdate",
15
+ "transfer",
16
+ "refund",
17
+ "create-magic-link"
18
+ ];
19
+ function isCourseBuilderAction(action) {
20
+ return actions.includes(action);
21
+ }
22
+
23
+ export {
24
+ isCourseBuilderAction
25
+ };
26
+ //# sourceMappingURL=chunk-VEKYIR7I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/actions.ts"],"sourcesContent":["import { CourseBuilderAction } from '@coursebuilder/core/types'\n\nconst actions: CourseBuilderAction[] = [\n\t'webhook',\n\t'srt',\n\t'session',\n\t'subscribe-to-list',\n\t'checkout',\n\t'redeem',\n\t'prices-formatted',\n\t'subscriber',\n\t'purchases',\n\t'lookup',\n\t'claimed',\n\t'nameUpdate',\n\t'transfer',\n\t'refund',\n\t'create-magic-link',\n]\n\nexport function isCourseBuilderAction(\n\taction: string,\n): action is CourseBuilderAction {\n\treturn actions.includes(action as CourseBuilderAction)\n}\n"],"mappings":";AAEA,IAAM,UAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,sBACf,QACgC;AAChC,SAAO,QAAQ,SAAS,MAA6B;AACtD;","names":[]}
@@ -0,0 +1,12 @@
1
+ // src/runtime/cookie.ts
2
+ function defaultCookies(useSecureCookies) {
3
+ const cookiePrefix = useSecureCookies ? "__Secure-" : "";
4
+ return {
5
+ // default cookie options
6
+ };
7
+ }
8
+
9
+ export {
10
+ defaultCookies
11
+ };
12
+ //# sourceMappingURL=chunk-W7YAT4NR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/cookie.ts"],"sourcesContent":["import { CookieOption, CookiesOptions } from '@coursebuilder/core/types'\n\nexport interface Cookie extends CookieOption {\n\tvalue: string\n}\n\nexport function defaultCookies(useSecureCookies: boolean) {\n\tconst cookiePrefix = useSecureCookies ? '__Secure-' : ''\n\treturn {\n\t\t// default cookie options\n\t} as const satisfies CookiesOptions\n}\n"],"mappings":";AAMO,SAAS,eAAe,kBAA2B;AACzD,QAAM,eAAe,mBAAmB,cAAc;AACtD,SAAO;AAAA;AAAA,EAEP;AACD;","names":[]}
@@ -0,0 +1,56 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __esm = (fn, res) => function __init() {
16
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
+ };
18
+ var __commonJS = (cb, mod) => function __require2() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
+ var __publicField = (obj, key, value) => {
43
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
44
+ return value;
45
+ };
46
+
47
+ export {
48
+ __require,
49
+ __esm,
50
+ __commonJS,
51
+ __export,
52
+ __toESM,
53
+ __toCommonJS,
54
+ __publicField
55
+ };
56
+ //# sourceMappingURL=chunk-WGAPYIUP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ // src/actions/redeem.ts
2
+ import { redeem } from "@coursebuilder/commerce/redeem";
3
+
4
+ export {
5
+ redeem
6
+ };
7
+ //# sourceMappingURL=chunk-WYNH2AWD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/actions/redeem.ts"],"sourcesContent":["/** HTTP-compatible redemption operation owned by the commerce engine. */\nexport { redeem } from '@coursebuilder/commerce/redeem'\n"],"mappings":";AACA,SAAS,cAAc;","names":[]}