@fayz-ai/courses 0.9.0-next.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/{mock-provider.d.ts → data/mock-provider.d.ts} +1 -1
  3. package/dist/data/mock-provider.d.ts.map +1 -0
  4. package/dist/{provider.d.ts → data/provider.d.ts} +1 -1
  5. package/dist/data/provider.d.ts.map +1 -0
  6. package/dist/data/safe-provider.d.ts.map +1 -0
  7. package/dist/{seed.d.ts → data/seed.d.ts} +1 -1
  8. package/dist/data/seed.d.ts.map +1 -0
  9. package/dist/data/supabase-provider.d.ts.map +1 -0
  10. package/dist/data/tables.d.ts.map +1 -0
  11. package/dist/data/tenant.d.ts.map +1 -0
  12. package/dist/{hooks.d.ts → hooks/index.d.ts} +2 -2
  13. package/dist/hooks/index.d.ts.map +1 -0
  14. package/dist/index.d.ts +10 -10
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +6 -6
  17. package/dist/index.js.map +1 -1
  18. package/package.json +3 -5
  19. package/dist/hooks.d.ts.map +0 -1
  20. package/dist/mock-provider.d.ts.map +0 -1
  21. package/dist/provider.d.ts.map +0 -1
  22. package/dist/safe-provider.d.ts.map +0 -1
  23. package/dist/seed.d.ts.map +0 -1
  24. package/dist/supabase-provider.d.ts.map +0 -1
  25. package/dist/tables.d.ts.map +0 -1
  26. package/dist/tenant.d.ts.map +0 -1
  27. package/src/hooks.ts +0 -125
  28. package/src/index.ts +0 -33
  29. package/src/mock-provider.ts +0 -369
  30. package/src/provider.ts +0 -85
  31. package/src/safe-provider.ts +0 -17
  32. package/src/seed.ts +0 -297
  33. package/src/supabase-provider.ts +0 -425
  34. package/src/tables.ts +0 -18
  35. package/src/tenant.ts +0 -21
  36. package/src/types.ts +0 -268
  37. /package/dist/{safe-provider.d.ts → data/safe-provider.d.ts} +0 -0
  38. /package/dist/{supabase-provider.d.ts → data/supabase-provider.d.ts} +0 -0
  39. /package/dist/{tables.d.ts → data/tables.d.ts} +0 -0
  40. /package/dist/{tenant.d.ts → data/tenant.d.ts} +0 -0
package/src/seed.ts DELETED
@@ -1,297 +0,0 @@
1
- import type {
2
- Course, Module, Lesson,
3
- Offer, Order, Subscription, Payout, PaymentMethod,
4
- } from './types'
5
-
6
- // Deterministic placeholder thumbnail (gradient SVG data-URI, no network).
7
- function thumb(label: string, hue: number): string {
8
- const svg =
9
- `<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360">` +
10
- `<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">` +
11
- `<stop offset="0" stop-color="hsl(${hue},65%,55%)"/>` +
12
- `<stop offset="1" stop-color="hsl(${(hue + 40) % 360},65%,40%)"/>` +
13
- `</linearGradient></defs><rect width="640" height="360" fill="url(#g)"/>` +
14
- `<text x="32" y="320" fill="white" font-family="system-ui" font-size="40" font-weight="700">${label}</text>` +
15
- `</svg>`
16
- return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`
17
- }
18
-
19
- const YT = (id: string) => `https://www.youtube.com/embed/${id}`
20
- const t0 = '2026-01-01T00:00:00.000Z'
21
-
22
- // ---------------------------------------------------------------------------
23
- // Course seed — a tiny education catalog the admin manages and the member area
24
- // plays. Both apps start from this so admin↔member look consistent.
25
- // ---------------------------------------------------------------------------
26
-
27
- export interface CourseSeedInput {
28
- slug: string
29
- title: string
30
- subtitle?: string
31
- description?: string
32
- price?: number
33
- hue?: number
34
- modules: Array<{
35
- title: string
36
- lessons: Array<{ title: string; description?: string; youtubeId: string; durationSec?: number }>
37
- }>
38
- }
39
-
40
- export interface CourseCatalog {
41
- courses: Course[]
42
- modules: Module[]
43
- lessons: Lesson[]
44
- /** One default one-time offer per course, plus a recurring "club" offer on the first. */
45
- offers: Offer[]
46
- }
47
-
48
- /** Build a deterministic CourseCatalog from a terse declarative seed. */
49
- export function buildCourseCatalog(input: CourseSeedInput[]): CourseCatalog {
50
- const courses: Course[] = []
51
- const modules: Module[] = []
52
- const lessons: Lesson[] = []
53
- const offers: Offer[] = []
54
-
55
- input.forEach((c, ci) => {
56
- const courseId = `course-${String(ci + 1).padStart(2, '0')}`
57
- const price = c.price ?? 197
58
- // Default one-time offer (the course's headline price).
59
- offers.push({
60
- id: `${courseId}-offer-01`,
61
- courseId,
62
- name: c.title,
63
- price,
64
- currency: 'BRL',
65
- kind: 'one_time',
66
- recurringInterval: null,
67
- isDefault: true,
68
- isOrderBump: false,
69
- sortOrder: 0,
70
- })
71
- // The first course also ships a recurring "club" offer + an order-bump, to
72
- // exercise subscriptions and bumps (mirrors Kiwify's multi-offer product).
73
- if (ci === 0) {
74
- offers.push({
75
- id: `${courseId}-offer-02`,
76
- courseId,
77
- name: `${c.title} + Club (mensal)`,
78
- price: Math.round(price * 0.24 * 100) / 100,
79
- currency: 'BRL',
80
- kind: 'subscription',
81
- recurringInterval: 'month',
82
- isDefault: false,
83
- isOrderBump: false,
84
- sortOrder: 1,
85
- })
86
- offers.push({
87
- id: `${courseId}-offer-03`,
88
- courseId,
89
- name: 'Templates & Bônus (order-bump)',
90
- price: 47,
91
- currency: 'BRL',
92
- kind: 'one_time',
93
- recurringInterval: null,
94
- isDefault: false,
95
- isOrderBump: true,
96
- sortOrder: 2,
97
- })
98
- }
99
- courses.push({
100
- id: courseId,
101
- slug: c.slug,
102
- title: c.title,
103
- subtitle: c.subtitle ?? null,
104
- description: c.description ?? null,
105
- thumbnailUrl: thumb(c.title, c.hue ?? (ci * 70) % 360),
106
- price: c.price ?? 197,
107
- currency: 'BRL',
108
- status: 'published',
109
- deliveryType: 'online',
110
- sortOrder: ci,
111
- createdAt: t0,
112
- updatedAt: t0,
113
- })
114
- c.modules.forEach((m, mi) => {
115
- const moduleId = `${courseId}-m${String(mi + 1).padStart(2, '0')}`
116
- modules.push({ id: moduleId, courseId, title: m.title, sortOrder: mi })
117
- m.lessons.forEach((l, li) => {
118
- lessons.push({
119
- id: `${moduleId}-l${String(li + 1).padStart(2, '0')}`,
120
- courseId,
121
- moduleId,
122
- title: l.title,
123
- description: l.description ?? null,
124
- videoUrl: YT(l.youtubeId),
125
- durationSec: l.durationSec ?? 600,
126
- sortOrder: li,
127
- })
128
- })
129
- })
130
- })
131
-
132
- return { courses, modules, lessons, offers }
133
- }
134
-
135
- // ---------------------------------------------------------------------------
136
- // Demo commerce ledger — deterministic sample orders/subscriptions/payouts so
137
- // the Sales, Subscriptions, Financial and dashboard surfaces have data on first
138
- // run (mock layer only; a real backend fills these from Stripe webhooks).
139
- // ---------------------------------------------------------------------------
140
-
141
- export interface DemoLedger {
142
- orders: Order[]
143
- subscriptions: Subscription[]
144
- payouts: Payout[]
145
- }
146
-
147
- /** Platform markup applied to demo sales (5% = 500 bps). Mirrors CreatorAccount. */
148
- export const DEMO_PLATFORM_FEE_BPS = 500
149
-
150
- // Days offset from t0, so dates are deterministic (no Date.now()).
151
- function daysFromBase(days: number): string {
152
- return new Date(Date.parse(t0) + days * 86_400_000).toISOString()
153
- }
154
-
155
- const DEMO_BUYERS: Array<{ name: string; email: string }> = [
156
- { name: 'William Ribeiro', email: 'william@example.com' },
157
- { name: 'Alan Brancalhão', email: 'alan@example.com' },
158
- { name: 'Luciano Rufatto', email: 'luciano@example.com' },
159
- { name: 'Gabriel Boni', email: 'gabriel@example.com' },
160
- { name: 'Leonardo Lorenzoni', email: 'leonardo@example.com' },
161
- ]
162
- const DEMO_METHODS: PaymentMethod[] = ['pix', 'card', 'boleto']
163
-
164
- function feeFor(total: number): number {
165
- return Math.round((total * DEMO_PLATFORM_FEE_BPS) / 10000 * 100) / 100
166
- }
167
-
168
- /** Build a deterministic ledger from a catalog's default (one-time) offers. */
169
- export function buildDemoLedger(catalog: CourseCatalog): DemoLedger {
170
- const orders: Order[] = []
171
- const subscriptions: Subscription[] = []
172
- const oneTime = catalog.offers.filter((o) => o.kind === 'one_time' && !o.isOrderBump)
173
-
174
- oneTime.forEach((offer, oi) => {
175
- // 3 paid sales per course, spread across buyers/methods/dates.
176
- for (let i = 0; i < 3; i++) {
177
- const buyer = DEMO_BUYERS[(oi * 3 + i) % DEMO_BUYERS.length]
178
- const total = offer.price
179
- const platformFee = feeFor(total)
180
- orders.push({
181
- id: `order-${offer.courseId}-${String(i + 1).padStart(2, '0')}`,
182
- courseId: offer.courseId,
183
- offerId: offer.id,
184
- customerId: `cust-${buyer.email}`,
185
- customerName: buyer.name,
186
- customerEmail: buyer.email,
187
- currency: offer.currency,
188
- total,
189
- platformFee,
190
- netValue: Math.round((total - platformFee) * 100) / 100,
191
- paymentMethod: DEMO_METHODS[(oi + i) % DEMO_METHODS.length],
192
- financialStatus: 'paid',
193
- stripePaymentIntentId: null,
194
- createdAt: daysFromBase(160 + oi * 7 + i * 2),
195
- })
196
- }
197
- })
198
-
199
- // Two active subscriptions on the first course's recurring offer.
200
- const sub = catalog.offers.find((o) => o.kind === 'subscription')
201
- if (sub) {
202
- for (let i = 0; i < 2; i++) {
203
- const buyer = DEMO_BUYERS[(3 + i) % DEMO_BUYERS.length]
204
- subscriptions.push({
205
- id: `sub-${sub.courseId}-${String(i + 1).padStart(2, '0')}`,
206
- courseId: sub.courseId,
207
- offerId: sub.id,
208
- customerId: `cust-${buyer.email}`,
209
- customerName: buyer.name,
210
- customerEmail: buyer.email,
211
- currency: sub.currency,
212
- netValue: Math.round((sub.price - feeFor(sub.price)) * 100) / 100,
213
- interval: sub.recurringInterval ?? 'month',
214
- status: 'active',
215
- stripeSubscriptionId: null,
216
- startedAt: daysFromBase(150 + i * 2),
217
- canceledAt: null,
218
- })
219
- }
220
- }
221
-
222
- // A few successful payouts.
223
- const payouts: Payout[] = [200, 216.33, 196.33, 801.33].map((amount, i) => ({
224
- id: `payout-${String(i + 1).padStart(2, '0')}`,
225
- amount,
226
- currency: 'BRL',
227
- status: 'paid',
228
- createdAt: daysFromBase(120 + i * 20),
229
- }))
230
-
231
- return { orders, subscriptions, payouts }
232
- }
233
-
234
- /** Default seed shared by both example apps. */
235
- export const DEFAULT_COURSE_CATALOG: CourseCatalog = buildCourseCatalog([
236
- {
237
- slug: 'react-do-zero',
238
- title: 'React do Zero ao Profissional',
239
- subtitle: 'Construa interfaces modernas com React',
240
- description: 'Do básico de componentes a hooks avançados e padrões de produção.',
241
- price: 297,
242
- hue: 210,
243
- modules: [
244
- {
245
- title: 'Fundamentos',
246
- lessons: [
247
- { title: 'Boas-vindas e setup', youtubeId: 'aqz-KE-bpKQ', durationSec: 420 },
248
- { title: 'JSX e componentes', youtubeId: 'LXb3EKWsInQ', durationSec: 720 },
249
- ],
250
- },
251
- {
252
- title: 'Hooks',
253
- lessons: [
254
- { title: 'useState e useEffect', youtubeId: 'jNQXAC9IVRw', durationSec: 900 },
255
- { title: 'Hooks customizados', youtubeId: 'aqz-KE-bpKQ', durationSec: 840 },
256
- ],
257
- },
258
- ],
259
- },
260
- {
261
- slug: 'design-de-produto',
262
- title: 'Design de Produto na Prática',
263
- subtitle: 'Do problema ao protótipo validado',
264
- description: 'Pesquisa, fluxos, wireframes e testes de usabilidade.',
265
- price: 247,
266
- hue: 320,
267
- modules: [
268
- {
269
- title: 'Descoberta',
270
- lessons: [
271
- { title: 'Entrevistas com usuários', youtubeId: 'LXb3EKWsInQ', durationSec: 660 },
272
- { title: 'Mapeando jornadas', youtubeId: 'jNQXAC9IVRw', durationSec: 540 },
273
- ],
274
- },
275
- ],
276
- },
277
- {
278
- slug: 'marketing-digital',
279
- title: 'Marketing Digital para Criadores',
280
- subtitle: 'Audiência, conteúdo e conversão',
281
- description: 'Estratégias de tráfego, funil e lançamentos.',
282
- price: 197,
283
- hue: 30,
284
- modules: [
285
- {
286
- title: 'Fundamentos',
287
- lessons: [
288
- { title: 'Posicionamento', youtubeId: 'aqz-KE-bpKQ', durationSec: 480 },
289
- { title: 'Criando conteúdo que converte', youtubeId: 'LXb3EKWsInQ', durationSec: 600 },
290
- ],
291
- },
292
- ],
293
- },
294
- ])
295
-
296
- /** Default demo ledger shared by the mock provider (sales/subscriptions/payouts). */
297
- export const DEFAULT_DEMO_LEDGER: DemoLedger = buildDemoLedger(DEFAULT_COURSE_CATALOG)