@fayz-ai/courses 0.8.0 → 0.9.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -1
- package/dist/mock-provider.d.ts +3 -1
- package/dist/mock-provider.d.ts.map +1 -1
- package/dist/provider.d.ts +8 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/seed.d.ts.map +1 -1
- package/dist/supabase-provider.d.ts.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/mock-provider.ts +14 -1
- package/src/provider.ts +8 -1
- package/src/seed.ts +1 -0
- package/src/supabase-provider.ts +82 -2
- package/src/types.ts +29 -0
- package/dist/index.cjs +0 -1092
- package/dist/index.cjs.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type CourseStatus = 'draft' | 'published' | 'archived';
|
|
2
|
+
/** How the course is delivered — drives scheduling/logistics and the storefront copy. */
|
|
3
|
+
export type CourseDeliveryType = 'online' | 'in_person' | 'hybrid';
|
|
2
4
|
export interface Course {
|
|
3
5
|
id: string;
|
|
4
6
|
slug: string;
|
|
@@ -9,6 +11,8 @@ export interface Course {
|
|
|
9
11
|
price: number;
|
|
10
12
|
currency: string;
|
|
11
13
|
status: CourseStatus;
|
|
14
|
+
/** online (default), presencial, or híbrido. */
|
|
15
|
+
deliveryType: CourseDeliveryType;
|
|
12
16
|
sortOrder: number;
|
|
13
17
|
createdAt: string;
|
|
14
18
|
updatedAt: string;
|
|
@@ -54,6 +58,7 @@ export interface CreateCourseInput {
|
|
|
54
58
|
price?: number;
|
|
55
59
|
currency?: string;
|
|
56
60
|
status?: CourseStatus;
|
|
61
|
+
deliveryType?: CourseDeliveryType;
|
|
57
62
|
sortOrder?: number;
|
|
58
63
|
}
|
|
59
64
|
export type UpdateCourseInput = Partial<CreateCourseInput>;
|
|
@@ -137,6 +142,27 @@ export interface Order {
|
|
|
137
142
|
financialStatus: FinancialStatus;
|
|
138
143
|
stripePaymentIntentId: string | null;
|
|
139
144
|
createdAt: string;
|
|
145
|
+
/** Number of installments (parcelas), from the receivable. Defaults to 1. */
|
|
146
|
+
installmentCount?: number;
|
|
147
|
+
}
|
|
148
|
+
/** One installment (bill) of an order's receivable, with its settlement. */
|
|
149
|
+
export interface OrderInstallment {
|
|
150
|
+
installmentNumber: number;
|
|
151
|
+
amount: number;
|
|
152
|
+
paidAmount: number;
|
|
153
|
+
status: string;
|
|
154
|
+
dueDate: string | null;
|
|
155
|
+
paymentDate: string | null;
|
|
156
|
+
cardBrand: string | null;
|
|
157
|
+
cardInstallments: number | null;
|
|
158
|
+
}
|
|
159
|
+
/** Full order for the detail page — order + course/offer + receivable schedule. */
|
|
160
|
+
export interface OrderDetail extends Order {
|
|
161
|
+
courseTitle: string | null;
|
|
162
|
+
offerName: string | null;
|
|
163
|
+
paidAmount: number;
|
|
164
|
+
balance: number;
|
|
165
|
+
installments: OrderInstallment[];
|
|
140
166
|
}
|
|
141
167
|
export type SubscriptionStatus = 'active' | 'canceled' | 'past_due';
|
|
142
168
|
export interface Subscription {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAA;AAE7D,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;I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,CAAA;IACjB,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAC5B"}
|
package/package.json
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
"fayz": {
|
|
4
4
|
"status": "beta"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.9.0-next.0",
|
|
7
7
|
"description": "Fayz SDK education domain — courses, modules, lessons, enrollments, progress",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"main": "./dist/index.js",
|
|
10
11
|
"module": "./dist/index.js",
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
15
|
"source": "./src/index.ts",
|
|
15
16
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"import": "./dist/index.js"
|
|
17
|
-
"require": "./dist/index.cjs"
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@fayz-ai/core": "^0.
|
|
25
|
+
"@fayz-ai/core": "^0.9.0-next.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^18.0.0 || ^19.0.0"
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type {
|
|
|
7
7
|
ListCoursesOptions,
|
|
8
8
|
// Commerce layer
|
|
9
9
|
Offer, OfferKind, RecurringInterval, CreateOfferInput, UpdateOfferInput,
|
|
10
|
-
Order, PaymentMethod, FinancialStatus, ListOrdersOptions,
|
|
10
|
+
Order, OrderDetail, OrderInstallment, PaymentMethod, FinancialStatus, ListOrdersOptions,
|
|
11
11
|
Subscription, SubscriptionStatus, ListSubscriptionsOptions,
|
|
12
12
|
Payout, PayoutStatus, CreatorAccount, FinancialSummary,
|
|
13
13
|
} from './types'
|
package/src/mock-provider.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
CreateLessonInput, UpdateLessonInput,
|
|
7
7
|
ListCoursesOptions,
|
|
8
8
|
Offer, CreateOfferInput, UpdateOfferInput,
|
|
9
|
-
Order, ListOrdersOptions,
|
|
9
|
+
Order, OrderDetail, ListOrdersOptions,
|
|
10
10
|
Subscription, ListSubscriptionsOptions,
|
|
11
11
|
Payout, CreatorAccount, FinancialSummary,
|
|
12
12
|
} from './types'
|
|
@@ -134,6 +134,7 @@ export class MockCoursesProvider implements CoursesProvider {
|
|
|
134
134
|
price: input.price ?? 0,
|
|
135
135
|
currency: input.currency ?? 'BRL',
|
|
136
136
|
status: input.status ?? 'draft',
|
|
137
|
+
deliveryType: input.deliveryType ?? 'online',
|
|
137
138
|
sortOrder: input.sortOrder ?? list.length,
|
|
138
139
|
createdAt: now(),
|
|
139
140
|
updatedAt: now(),
|
|
@@ -299,6 +300,18 @@ export class MockCoursesProvider implements CoursesProvider {
|
|
|
299
300
|
return list.slice().sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))
|
|
300
301
|
}
|
|
301
302
|
|
|
303
|
+
// Core-commerce course sales don't exist in the mock layer (no orders/financial).
|
|
304
|
+
async listCoreSales(): Promise<Order[]> {
|
|
305
|
+
return []
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async getOrder(id: string): Promise<OrderDetail | null> {
|
|
309
|
+
const o = this.orders().find((x) => x.id === id)
|
|
310
|
+
if (!o) return null
|
|
311
|
+
const paid = o.financialStatus === 'paid' ? o.total : 0
|
|
312
|
+
return { ...o, courseTitle: null, offerName: null, paidAmount: paid, balance: o.total - paid, installments: [] }
|
|
313
|
+
}
|
|
314
|
+
|
|
302
315
|
// Subscriptions -----------------------------------------------------------
|
|
303
316
|
async listSubscriptions(opts?: ListSubscriptionsOptions): Promise<Subscription[]> {
|
|
304
317
|
let list = this.subscriptions()
|
package/src/provider.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
CreateLessonInput, UpdateLessonInput,
|
|
6
6
|
ListCoursesOptions,
|
|
7
7
|
Offer, CreateOfferInput, UpdateOfferInput,
|
|
8
|
-
Order, ListOrdersOptions,
|
|
8
|
+
Order, OrderDetail, ListOrdersOptions,
|
|
9
9
|
Subscription, ListSubscriptionsOptions,
|
|
10
10
|
Payout, CreatorAccount, FinancialSummary,
|
|
11
11
|
} from './types'
|
|
@@ -49,6 +49,13 @@ export interface CoursesProvider {
|
|
|
49
49
|
|
|
50
50
|
// Sales ledger
|
|
51
51
|
listOrders(options?: ListOrdersOptions): Promise<Order[]>
|
|
52
|
+
/** Course sales made through the CORE commerce (approved CRM quotes + direct
|
|
53
|
+
* financial receivables that reference a course). Mapped into the Order shape
|
|
54
|
+
* so the Sales screen shows the same money as Financeiro > Receber. */
|
|
55
|
+
listCoreSales(): Promise<Order[]>
|
|
56
|
+
/** Full detail for one order (canonical public.orders) + course/offer +
|
|
57
|
+
* the receivable's installment schedule. Powers the order-detail page. */
|
|
58
|
+
getOrder(id: string): Promise<OrderDetail | null>
|
|
52
59
|
|
|
53
60
|
// Recurring subscriptions
|
|
54
61
|
listSubscriptions(options?: ListSubscriptionsOptions): Promise<Subscription[]>
|
package/src/seed.ts
CHANGED
package/src/supabase-provider.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
CreateLessonInput, UpdateLessonInput,
|
|
10
10
|
ListCoursesOptions,
|
|
11
11
|
Offer, CreateOfferInput, UpdateOfferInput,
|
|
12
|
-
Order, ListOrdersOptions,
|
|
12
|
+
Order, OrderDetail, OrderInstallment, PaymentMethod, ListOrdersOptions, FinancialStatus,
|
|
13
13
|
Subscription, ListSubscriptionsOptions,
|
|
14
14
|
Payout, CreatorAccount, FinancialSummary,
|
|
15
15
|
} from './types'
|
|
@@ -39,6 +39,7 @@ function rowToCourse(r: any): Course {
|
|
|
39
39
|
id: r.id, slug: r.slug, title: r.title, subtitle: r.subtitle ?? null,
|
|
40
40
|
description: r.description ?? null, thumbnailUrl: r.thumbnail_url ?? null,
|
|
41
41
|
price: r.price ?? 0, currency: r.currency ?? 'BRL', status: r.status ?? 'draft',
|
|
42
|
+
deliveryType: r.delivery_type ?? 'online',
|
|
42
43
|
sortOrder: r.sort_order ?? 0, createdAt: r.created_at, updatedAt: r.updated_at,
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -124,7 +125,8 @@ export function createSupabaseCoursesProvider(): CoursesProvider {
|
|
|
124
125
|
slug: input.slug ?? slugify(input.title),
|
|
125
126
|
title: input.title, subtitle: input.subtitle ?? null, description: input.description ?? null,
|
|
126
127
|
thumbnail_url: input.thumbnailUrl ?? null, price: input.price ?? 0,
|
|
127
|
-
currency: input.currency ?? 'BRL', status: input.status ?? 'draft',
|
|
128
|
+
currency: input.currency ?? 'BRL', status: input.status ?? 'draft',
|
|
129
|
+
delivery_type: input.deliveryType ?? 'online', sort_order: input.sortOrder ?? 0,
|
|
128
130
|
}).select('*').single()
|
|
129
131
|
if (error) throw error
|
|
130
132
|
return rowToCourse(data)
|
|
@@ -139,6 +141,7 @@ export function createSupabaseCoursesProvider(): CoursesProvider {
|
|
|
139
141
|
if (input.price !== undefined) patch.price = input.price
|
|
140
142
|
if (input.currency !== undefined) patch.currency = input.currency
|
|
141
143
|
if (input.status !== undefined) patch.status = input.status
|
|
144
|
+
if (input.deliveryType !== undefined) patch.delivery_type = input.deliveryType
|
|
142
145
|
if (input.sortOrder !== undefined) patch.sort_order = input.sortOrder
|
|
143
146
|
const { data, error } = await scoped(getDb().from(T.courses).update(patch).eq('id', id)).select('*').single()
|
|
144
147
|
if (error) throw error
|
|
@@ -285,6 +288,83 @@ export function createSupabaseCoursesProvider(): CoursesProvider {
|
|
|
285
288
|
if (error) throw error
|
|
286
289
|
return (data ?? []).map(rowToOrder)
|
|
287
290
|
},
|
|
291
|
+
async listCoreSales(): Promise<Order[]> {
|
|
292
|
+
const { data, error } = await scoped(getDb().from('v_plg_course_sales').select('*'))
|
|
293
|
+
.order('created_at', { ascending: false })
|
|
294
|
+
if (error) throw error
|
|
295
|
+
return (data ?? []).map((r: any): Order => ({
|
|
296
|
+
id: r.id,
|
|
297
|
+
courseId: r.course_id ?? '',
|
|
298
|
+
offerId: r.offer_id ?? null,
|
|
299
|
+
customerId: r.party_id ?? null,
|
|
300
|
+
customerName: r.customer_name ?? null,
|
|
301
|
+
customerEmail: r.customer_email ?? null,
|
|
302
|
+
currency: r.currency ?? 'BRL',
|
|
303
|
+
total: Number(r.total ?? 0),
|
|
304
|
+
platformFee: Number(r.platform_fee ?? 0),
|
|
305
|
+
netValue: Number(r.net_value ?? r.total ?? 0),
|
|
306
|
+
paymentMethod: (r.payment_method ?? null) as PaymentMethod | null,
|
|
307
|
+
financialStatus: (r.financial_status ?? 'pending') as FinancialStatus,
|
|
308
|
+
stripePaymentIntentId: null,
|
|
309
|
+
createdAt: r.created_at,
|
|
310
|
+
installmentCount: Number(r.installment_count ?? 1),
|
|
311
|
+
}))
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
async getOrder(id: string): Promise<OrderDetail | null> {
|
|
315
|
+
const db = getDb()
|
|
316
|
+
const { data: v } = await scoped(db.from('v_plg_course_sales').select('*')).eq('id', id).maybeSingle()
|
|
317
|
+
if (!v) return null
|
|
318
|
+
const [{ data: course }, { data: bills }, { data: pays }] = await Promise.all([
|
|
319
|
+
db.from(T.courses).select('title').eq('id', v.course_id).maybeSingle(),
|
|
320
|
+
db.from('plg_financial_movements').select('*').eq('invoice_id', id).eq('movement_kind', 'bill').order('installment_number'),
|
|
321
|
+
db.from('plg_financial_movements').select('*').eq('invoice_id', id).eq('movement_kind', 'payment'),
|
|
322
|
+
])
|
|
323
|
+
let offerName: string | null = null
|
|
324
|
+
if (v.offer_id) {
|
|
325
|
+
const { data: off } = await db.from(T.offers).select('name').eq('id', v.offer_id).maybeSingle()
|
|
326
|
+
offerName = off?.name ?? null
|
|
327
|
+
}
|
|
328
|
+
const paymentsByInst = new Map<number, any>()
|
|
329
|
+
for (const p of pays ?? []) paymentsByInst.set(p.installment_number ?? 0, p)
|
|
330
|
+
const installments: OrderInstallment[] = (bills ?? []).map((b: any) => {
|
|
331
|
+
const p = paymentsByInst.get(b.installment_number ?? 0)
|
|
332
|
+
return {
|
|
333
|
+
installmentNumber: b.installment_number ?? 1,
|
|
334
|
+
amount: Number(b.amount ?? 0),
|
|
335
|
+
paidAmount: Number(b.paid_amount ?? 0),
|
|
336
|
+
status: b.status ?? 'pending',
|
|
337
|
+
dueDate: b.due_date ?? null,
|
|
338
|
+
paymentDate: p?.payment_date ?? b.payment_date ?? null,
|
|
339
|
+
cardBrand: p?.card_brand ?? null,
|
|
340
|
+
cardInstallments: p?.card_installments ?? null,
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
const paid = (bills ?? []).reduce((s: number, b: any) => s + Number(b.paid_amount ?? 0), 0)
|
|
344
|
+
const total = Number(v.total ?? 0)
|
|
345
|
+
return {
|
|
346
|
+
id: v.id,
|
|
347
|
+
courseId: v.course_id ?? '',
|
|
348
|
+
offerId: v.offer_id ?? null,
|
|
349
|
+
customerId: v.party_id ?? null,
|
|
350
|
+
customerName: v.customer_name ?? null,
|
|
351
|
+
customerEmail: v.customer_email ?? null,
|
|
352
|
+
currency: v.currency ?? 'BRL',
|
|
353
|
+
total,
|
|
354
|
+
platformFee: Number(v.platform_fee ?? 0),
|
|
355
|
+
netValue: Number(v.net_value ?? total),
|
|
356
|
+
paymentMethod: (v.payment_method ?? null) as PaymentMethod | null,
|
|
357
|
+
financialStatus: (v.financial_status ?? 'pending') as FinancialStatus,
|
|
358
|
+
stripePaymentIntentId: null,
|
|
359
|
+
createdAt: v.created_at,
|
|
360
|
+
installmentCount: Number(v.installment_count ?? installments.length ?? 1),
|
|
361
|
+
courseTitle: course?.title ?? null,
|
|
362
|
+
offerName,
|
|
363
|
+
paidAmount: paid,
|
|
364
|
+
balance: Math.max(0, total - paid),
|
|
365
|
+
installments,
|
|
366
|
+
}
|
|
367
|
+
},
|
|
288
368
|
|
|
289
369
|
// Subscriptions ---------------------------------------------------------
|
|
290
370
|
async listSubscriptions(opts?: ListSubscriptionsOptions): Promise<Subscription[]> {
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
export type CourseStatus = 'draft' | 'published' | 'archived'
|
|
9
9
|
|
|
10
|
+
/** How the course is delivered — drives scheduling/logistics and the storefront copy. */
|
|
11
|
+
export type CourseDeliveryType = 'online' | 'in_person' | 'hybrid'
|
|
12
|
+
|
|
10
13
|
export interface Course {
|
|
11
14
|
id: string
|
|
12
15
|
slug: string
|
|
@@ -17,6 +20,8 @@ export interface Course {
|
|
|
17
20
|
price: number
|
|
18
21
|
currency: string
|
|
19
22
|
status: CourseStatus
|
|
23
|
+
/** online (default), presencial, or híbrido. */
|
|
24
|
+
deliveryType: CourseDeliveryType
|
|
20
25
|
sortOrder: number
|
|
21
26
|
createdAt: string
|
|
22
27
|
updatedAt: string
|
|
@@ -69,6 +74,7 @@ export interface CreateCourseInput {
|
|
|
69
74
|
price?: number
|
|
70
75
|
currency?: string
|
|
71
76
|
status?: CourseStatus
|
|
77
|
+
deliveryType?: CourseDeliveryType
|
|
72
78
|
sortOrder?: number
|
|
73
79
|
}
|
|
74
80
|
export type UpdateCourseInput = Partial<CreateCourseInput>
|
|
@@ -168,6 +174,29 @@ export interface Order {
|
|
|
168
174
|
financialStatus: FinancialStatus
|
|
169
175
|
stripePaymentIntentId: string | null
|
|
170
176
|
createdAt: string
|
|
177
|
+
/** Number of installments (parcelas), from the receivable. Defaults to 1. */
|
|
178
|
+
installmentCount?: number
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** One installment (bill) of an order's receivable, with its settlement. */
|
|
182
|
+
export interface OrderInstallment {
|
|
183
|
+
installmentNumber: number
|
|
184
|
+
amount: number
|
|
185
|
+
paidAmount: number
|
|
186
|
+
status: string
|
|
187
|
+
dueDate: string | null
|
|
188
|
+
paymentDate: string | null
|
|
189
|
+
cardBrand: string | null
|
|
190
|
+
cardInstallments: number | null
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Full order for the detail page — order + course/offer + receivable schedule. */
|
|
194
|
+
export interface OrderDetail extends Order {
|
|
195
|
+
courseTitle: string | null
|
|
196
|
+
offerName: string | null
|
|
197
|
+
paidAmount: number
|
|
198
|
+
balance: number
|
|
199
|
+
installments: OrderInstallment[]
|
|
171
200
|
}
|
|
172
201
|
|
|
173
202
|
export type SubscriptionStatus = 'active' | 'canceled' | 'past_due'
|