@23blocks/angular 1.0.2 → 1.1.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/lib/assets/assets.service.js +43 -30
- package/dist/lib/assets/assets.service.js.map +1 -1
- package/dist/lib/authentication/authentication.service.js +49 -32
- package/dist/lib/authentication/authentication.service.js.map +1 -1
- package/dist/lib/campaigns/campaigns.service.js +51 -38
- package/dist/lib/campaigns/campaigns.service.js.map +1 -1
- package/dist/lib/company/company.service.js +50 -37
- package/dist/lib/company/company.service.js.map +1 -1
- package/dist/lib/content/content.service.js +52 -39
- package/dist/lib/content/content.service.js.map +1 -1
- package/dist/lib/conversations/conversations.service.js +59 -46
- package/dist/lib/conversations/conversations.service.js.map +1 -1
- package/dist/lib/crm/crm.service.js +69 -56
- package/dist/lib/crm/crm.service.js.map +1 -1
- package/dist/lib/files/files.service.js +42 -29
- package/dist/lib/files/files.service.js.map +1 -1
- package/dist/lib/forms/forms.service.js +45 -32
- package/dist/lib/forms/forms.service.js.map +1 -1
- package/dist/lib/geolocation/geolocation.service.js +78 -65
- package/dist/lib/geolocation/geolocation.service.js.map +1 -1
- package/dist/lib/index.js +4 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/jarvis/jarvis.service.js +54 -41
- package/dist/lib/jarvis/jarvis.service.js.map +1 -1
- package/dist/lib/onboarding/onboarding.service.js +45 -32
- package/dist/lib/onboarding/onboarding.service.js.map +1 -1
- package/dist/lib/products/products.service.js +80 -67
- package/dist/lib/products/products.service.js.map +1 -1
- package/dist/lib/rewards/rewards.service.js +47 -34
- package/dist/lib/rewards/rewards.service.js.map +1 -1
- package/dist/lib/sales/sales.service.js +47 -34
- package/dist/lib/sales/sales.service.js.map +1 -1
- package/dist/lib/search/search.service.js +31 -18
- package/dist/lib/search/search.service.js.map +1 -1
- package/dist/lib/simple-providers.js +109 -12
- package/dist/lib/simple-providers.js.map +1 -1
- package/dist/lib/tokens.js +26 -1
- package/dist/lib/tokens.js.map +1 -1
- package/dist/lib/university/university.service.js +58 -45
- package/dist/lib/university/university.service.js.map +1 -1
- package/dist/lib/wallet/wallet.service.js +39 -26
- package/dist/lib/wallet/wallet.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,136 +1,144 @@
|
|
|
1
1
|
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
|
|
2
2
|
import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata";
|
|
3
3
|
import { _ as _ts_param } from "@swc/helpers/_/_ts_param";
|
|
4
|
-
import { Injectable, Inject } from '@angular/core';
|
|
4
|
+
import { Injectable, Inject, Optional } from '@angular/core';
|
|
5
5
|
import { from } from 'rxjs';
|
|
6
6
|
import { createUniversityBlock } from '@23blocks/block-university';
|
|
7
|
-
import { TRANSPORT, UNIVERSITY_CONFIG } from '../tokens.js';
|
|
7
|
+
import { TRANSPORT, UNIVERSITY_TRANSPORT, UNIVERSITY_CONFIG } from '../tokens.js';
|
|
8
8
|
export class UniversityService {
|
|
9
|
+
/**
|
|
10
|
+
* Ensure the service is configured, throw helpful error if not
|
|
11
|
+
*/ ensureConfigured() {
|
|
12
|
+
if (!this.block) {
|
|
13
|
+
throw new Error('[23blocks] UniversityService is not configured. ' + "Add 'urls.university' to your provideBlocks23() configuration.");
|
|
14
|
+
}
|
|
15
|
+
return this.block;
|
|
16
|
+
}
|
|
9
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
18
|
// Courses Service
|
|
11
19
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
20
|
listCourses(params) {
|
|
13
|
-
return from(this.
|
|
21
|
+
return from(this.ensureConfigured().courses.list(params));
|
|
14
22
|
}
|
|
15
23
|
getCourse(uniqueId) {
|
|
16
|
-
return from(this.
|
|
24
|
+
return from(this.ensureConfigured().courses.get(uniqueId));
|
|
17
25
|
}
|
|
18
26
|
createCourse(data) {
|
|
19
|
-
return from(this.
|
|
27
|
+
return from(this.ensureConfigured().courses.create(data));
|
|
20
28
|
}
|
|
21
29
|
updateCourse(uniqueId, data) {
|
|
22
|
-
return from(this.
|
|
30
|
+
return from(this.ensureConfigured().courses.update(uniqueId, data));
|
|
23
31
|
}
|
|
24
32
|
deleteCourse(uniqueId) {
|
|
25
|
-
return from(this.
|
|
33
|
+
return from(this.ensureConfigured().courses.delete(uniqueId));
|
|
26
34
|
}
|
|
27
35
|
publishCourse(uniqueId) {
|
|
28
|
-
return from(this.
|
|
36
|
+
return from(this.ensureConfigured().courses.publish(uniqueId));
|
|
29
37
|
}
|
|
30
38
|
unpublishCourse(uniqueId) {
|
|
31
|
-
return from(this.
|
|
39
|
+
return from(this.ensureConfigured().courses.unpublish(uniqueId));
|
|
32
40
|
}
|
|
33
41
|
listCoursesByInstructor(instructorUniqueId, params) {
|
|
34
|
-
return from(this.
|
|
42
|
+
return from(this.ensureConfigured().courses.listByInstructor(instructorUniqueId, params));
|
|
35
43
|
}
|
|
36
44
|
listCoursesByCategory(categoryUniqueId, params) {
|
|
37
|
-
return from(this.
|
|
45
|
+
return from(this.ensureConfigured().courses.listByCategory(categoryUniqueId, params));
|
|
38
46
|
}
|
|
39
47
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
40
48
|
// Lessons Service
|
|
41
49
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
42
50
|
listLessons(params) {
|
|
43
|
-
return from(this.
|
|
51
|
+
return from(this.ensureConfigured().lessons.list(params));
|
|
44
52
|
}
|
|
45
53
|
getLesson(uniqueId) {
|
|
46
|
-
return from(this.
|
|
54
|
+
return from(this.ensureConfigured().lessons.get(uniqueId));
|
|
47
55
|
}
|
|
48
56
|
createLesson(data) {
|
|
49
|
-
return from(this.
|
|
57
|
+
return from(this.ensureConfigured().lessons.create(data));
|
|
50
58
|
}
|
|
51
59
|
updateLesson(uniqueId, data) {
|
|
52
|
-
return from(this.
|
|
60
|
+
return from(this.ensureConfigured().lessons.update(uniqueId, data));
|
|
53
61
|
}
|
|
54
62
|
deleteLesson(uniqueId) {
|
|
55
|
-
return from(this.
|
|
63
|
+
return from(this.ensureConfigured().lessons.delete(uniqueId));
|
|
56
64
|
}
|
|
57
65
|
reorderLessons(courseUniqueId, data) {
|
|
58
|
-
return from(this.
|
|
66
|
+
return from(this.ensureConfigured().lessons.reorder(courseUniqueId, data));
|
|
59
67
|
}
|
|
60
68
|
listLessonsByCourse(courseUniqueId, params) {
|
|
61
|
-
return from(this.
|
|
69
|
+
return from(this.ensureConfigured().lessons.listByCourse(courseUniqueId, params));
|
|
62
70
|
}
|
|
63
71
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
64
72
|
// Enrollments Service
|
|
65
73
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
66
74
|
listEnrollments(params) {
|
|
67
|
-
return from(this.
|
|
75
|
+
return from(this.ensureConfigured().enrollments.list(params));
|
|
68
76
|
}
|
|
69
77
|
getEnrollment(uniqueId) {
|
|
70
|
-
return from(this.
|
|
78
|
+
return from(this.ensureConfigured().enrollments.get(uniqueId));
|
|
71
79
|
}
|
|
72
80
|
enroll(data) {
|
|
73
|
-
return from(this.
|
|
81
|
+
return from(this.ensureConfigured().enrollments.enroll(data));
|
|
74
82
|
}
|
|
75
83
|
updateEnrollmentProgress(uniqueId, data) {
|
|
76
|
-
return from(this.
|
|
84
|
+
return from(this.ensureConfigured().enrollments.updateProgress(uniqueId, data));
|
|
77
85
|
}
|
|
78
86
|
completeEnrollment(uniqueId) {
|
|
79
|
-
return from(this.
|
|
87
|
+
return from(this.ensureConfigured().enrollments.complete(uniqueId));
|
|
80
88
|
}
|
|
81
89
|
dropEnrollment(uniqueId) {
|
|
82
|
-
return from(this.
|
|
90
|
+
return from(this.ensureConfigured().enrollments.drop(uniqueId));
|
|
83
91
|
}
|
|
84
92
|
listEnrollmentsByCourse(courseUniqueId, params) {
|
|
85
|
-
return from(this.
|
|
93
|
+
return from(this.ensureConfigured().enrollments.listByCourse(courseUniqueId, params));
|
|
86
94
|
}
|
|
87
95
|
listEnrollmentsByUser(userUniqueId, params) {
|
|
88
|
-
return from(this.
|
|
96
|
+
return from(this.ensureConfigured().enrollments.listByUser(userUniqueId, params));
|
|
89
97
|
}
|
|
90
98
|
getCertificate(uniqueId) {
|
|
91
|
-
return from(this.
|
|
99
|
+
return from(this.ensureConfigured().enrollments.getCertificate(uniqueId));
|
|
92
100
|
}
|
|
93
101
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
94
102
|
// Assignments Service
|
|
95
103
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
96
104
|
listAssignments(params) {
|
|
97
|
-
return from(this.
|
|
105
|
+
return from(this.ensureConfigured().assignments.list(params));
|
|
98
106
|
}
|
|
99
107
|
getAssignment(uniqueId) {
|
|
100
|
-
return from(this.
|
|
108
|
+
return from(this.ensureConfigured().assignments.get(uniqueId));
|
|
101
109
|
}
|
|
102
110
|
createAssignment(data) {
|
|
103
|
-
return from(this.
|
|
111
|
+
return from(this.ensureConfigured().assignments.create(data));
|
|
104
112
|
}
|
|
105
113
|
updateAssignment(uniqueId, data) {
|
|
106
|
-
return from(this.
|
|
114
|
+
return from(this.ensureConfigured().assignments.update(uniqueId, data));
|
|
107
115
|
}
|
|
108
116
|
deleteAssignment(uniqueId) {
|
|
109
|
-
return from(this.
|
|
117
|
+
return from(this.ensureConfigured().assignments.delete(uniqueId));
|
|
110
118
|
}
|
|
111
119
|
listAssignmentsByLesson(lessonUniqueId, params) {
|
|
112
|
-
return from(this.
|
|
120
|
+
return from(this.ensureConfigured().assignments.listByLesson(lessonUniqueId, params));
|
|
113
121
|
}
|
|
114
122
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
115
123
|
// Submissions Service
|
|
116
124
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
117
125
|
listSubmissions(params) {
|
|
118
|
-
return from(this.
|
|
126
|
+
return from(this.ensureConfigured().submissions.list(params));
|
|
119
127
|
}
|
|
120
128
|
getSubmission(uniqueId) {
|
|
121
|
-
return from(this.
|
|
129
|
+
return from(this.ensureConfigured().submissions.get(uniqueId));
|
|
122
130
|
}
|
|
123
131
|
submitAssignment(data) {
|
|
124
|
-
return from(this.
|
|
132
|
+
return from(this.ensureConfigured().submissions.submit(data));
|
|
125
133
|
}
|
|
126
134
|
gradeSubmission(uniqueId, data) {
|
|
127
|
-
return from(this.
|
|
135
|
+
return from(this.ensureConfigured().submissions.grade(uniqueId, data));
|
|
128
136
|
}
|
|
129
137
|
listSubmissionsByAssignment(assignmentUniqueId, params) {
|
|
130
|
-
return from(this.
|
|
138
|
+
return from(this.ensureConfigured().submissions.listByAssignment(assignmentUniqueId, params));
|
|
131
139
|
}
|
|
132
140
|
listSubmissionsByUser(userUniqueId, params) {
|
|
133
|
-
return from(this.
|
|
141
|
+
return from(this.ensureConfigured().submissions.listByUser(userUniqueId, params));
|
|
134
142
|
}
|
|
135
143
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
136
144
|
// Direct Block Access (for advanced usage)
|
|
@@ -139,21 +147,26 @@ export class UniversityService {
|
|
|
139
147
|
* Access the underlying block for advanced operations
|
|
140
148
|
* Use this when you need access to services not wrapped by this Angular service
|
|
141
149
|
*/ get rawBlock() {
|
|
142
|
-
return this.
|
|
150
|
+
return this.ensureConfigured();
|
|
143
151
|
}
|
|
144
|
-
constructor(
|
|
145
|
-
|
|
152
|
+
constructor(serviceTransport, legacyTransport, config){
|
|
153
|
+
const transport = serviceTransport != null ? serviceTransport : legacyTransport;
|
|
154
|
+
this.block = transport ? createUniversityBlock(transport, config) : null;
|
|
146
155
|
}
|
|
147
156
|
}
|
|
148
157
|
UniversityService = _ts_decorate([
|
|
149
158
|
Injectable({
|
|
150
159
|
providedIn: 'root'
|
|
151
160
|
}),
|
|
152
|
-
_ts_param(0,
|
|
153
|
-
_ts_param(
|
|
161
|
+
_ts_param(0, Optional()),
|
|
162
|
+
_ts_param(0, Inject(UNIVERSITY_TRANSPORT)),
|
|
163
|
+
_ts_param(1, Optional()),
|
|
164
|
+
_ts_param(1, Inject(TRANSPORT)),
|
|
165
|
+
_ts_param(2, Inject(UNIVERSITY_CONFIG)),
|
|
154
166
|
_ts_metadata("design:type", Function),
|
|
155
167
|
_ts_metadata("design:paramtypes", [
|
|
156
|
-
|
|
168
|
+
Object,
|
|
169
|
+
Object,
|
|
157
170
|
typeof UniversityBlockConfig === "undefined" ? Object : UniversityBlockConfig
|
|
158
171
|
])
|
|
159
172
|
], UniversityService);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/university/university.service.ts"],"sourcesContent":["import { Injectable, Inject } from '@angular/core';\nimport { Observable, from } from 'rxjs';\nimport type { Transport, PageResult } from '@23blocks/contracts';\nimport {\n createUniversityBlock,\n type UniversityBlock,\n type UniversityBlockConfig,\n type Course,\n type CreateCourseRequest,\n type UpdateCourseRequest,\n type ListCoursesParams,\n type Lesson,\n type CreateLessonRequest,\n type UpdateLessonRequest,\n type ListLessonsParams,\n type ReorderLessonsRequest,\n type Enrollment,\n type EnrollRequest,\n type UpdateEnrollmentProgressRequest,\n type ListEnrollmentsParams,\n type Assignment,\n type CreateAssignmentRequest,\n type UpdateAssignmentRequest,\n type ListAssignmentsParams,\n type Submission,\n type SubmitAssignmentRequest,\n type GradeSubmissionRequest,\n type ListSubmissionsParams,\n} from '@23blocks/block-university';\nimport { TRANSPORT, UNIVERSITY_CONFIG } from '../tokens.js';\n\n/**\n * Angular service wrapping the University block.\n * Converts Promise-based APIs to RxJS Observables.\n *\n * @example\n * ```typescript\n * @Component({...})\n * export class CourseListComponent {\n * constructor(private university: UniversityService) {}\n *\n * loadCourses() {\n * this.university.listCourses({ page: 1, perPage: 10 }).subscribe({\n * next: (result) => console.log('Courses:', result.data),\n * error: (err) => console.error('Failed:', err),\n * });\n * }\n * }\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class UniversityService {\n private readonly block: UniversityBlock;\n\n constructor(\n @Inject(TRANSPORT) transport: Transport,\n @Inject(UNIVERSITY_CONFIG) config: UniversityBlockConfig\n ) {\n this.block = createUniversityBlock(transport, config);\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Courses Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listCourses(params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.block.courses.list(params));\n }\n\n getCourse(uniqueId: string): Observable<Course> {\n return from(this.block.courses.get(uniqueId));\n }\n\n createCourse(data: CreateCourseRequest): Observable<Course> {\n return from(this.block.courses.create(data));\n }\n\n updateCourse(uniqueId: string, data: UpdateCourseRequest): Observable<Course> {\n return from(this.block.courses.update(uniqueId, data));\n }\n\n deleteCourse(uniqueId: string): Observable<void> {\n return from(this.block.courses.delete(uniqueId));\n }\n\n publishCourse(uniqueId: string): Observable<Course> {\n return from(this.block.courses.publish(uniqueId));\n }\n\n unpublishCourse(uniqueId: string): Observable<Course> {\n return from(this.block.courses.unpublish(uniqueId));\n }\n\n listCoursesByInstructor(instructorUniqueId: string, params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.block.courses.listByInstructor(instructorUniqueId, params));\n }\n\n listCoursesByCategory(categoryUniqueId: string, params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.block.courses.listByCategory(categoryUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Lessons Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listLessons(params?: ListLessonsParams): Observable<PageResult<Lesson>> {\n return from(this.block.lessons.list(params));\n }\n\n getLesson(uniqueId: string): Observable<Lesson> {\n return from(this.block.lessons.get(uniqueId));\n }\n\n createLesson(data: CreateLessonRequest): Observable<Lesson> {\n return from(this.block.lessons.create(data));\n }\n\n updateLesson(uniqueId: string, data: UpdateLessonRequest): Observable<Lesson> {\n return from(this.block.lessons.update(uniqueId, data));\n }\n\n deleteLesson(uniqueId: string): Observable<void> {\n return from(this.block.lessons.delete(uniqueId));\n }\n\n reorderLessons(courseUniqueId: string, data: ReorderLessonsRequest): Observable<Lesson[]> {\n return from(this.block.lessons.reorder(courseUniqueId, data));\n }\n\n listLessonsByCourse(courseUniqueId: string, params?: ListLessonsParams): Observable<PageResult<Lesson>> {\n return from(this.block.lessons.listByCourse(courseUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Enrollments Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listEnrollments(params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.block.enrollments.list(params));\n }\n\n getEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.block.enrollments.get(uniqueId));\n }\n\n enroll(data: EnrollRequest): Observable<Enrollment> {\n return from(this.block.enrollments.enroll(data));\n }\n\n updateEnrollmentProgress(uniqueId: string, data: UpdateEnrollmentProgressRequest): Observable<Enrollment> {\n return from(this.block.enrollments.updateProgress(uniqueId, data));\n }\n\n completeEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.block.enrollments.complete(uniqueId));\n }\n\n dropEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.block.enrollments.drop(uniqueId));\n }\n\n listEnrollmentsByCourse(courseUniqueId: string, params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.block.enrollments.listByCourse(courseUniqueId, params));\n }\n\n listEnrollmentsByUser(userUniqueId: string, params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.block.enrollments.listByUser(userUniqueId, params));\n }\n\n getCertificate(uniqueId: string): Observable<{ certificateUrl: string }> {\n return from(this.block.enrollments.getCertificate(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Assignments Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listAssignments(params?: ListAssignmentsParams): Observable<PageResult<Assignment>> {\n return from(this.block.assignments.list(params));\n }\n\n getAssignment(uniqueId: string): Observable<Assignment> {\n return from(this.block.assignments.get(uniqueId));\n }\n\n createAssignment(data: CreateAssignmentRequest): Observable<Assignment> {\n return from(this.block.assignments.create(data));\n }\n\n updateAssignment(uniqueId: string, data: UpdateAssignmentRequest): Observable<Assignment> {\n return from(this.block.assignments.update(uniqueId, data));\n }\n\n deleteAssignment(uniqueId: string): Observable<void> {\n return from(this.block.assignments.delete(uniqueId));\n }\n\n listAssignmentsByLesson(lessonUniqueId: string, params?: ListAssignmentsParams): Observable<PageResult<Assignment>> {\n return from(this.block.assignments.listByLesson(lessonUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Submissions Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listSubmissions(params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.block.submissions.list(params));\n }\n\n getSubmission(uniqueId: string): Observable<Submission> {\n return from(this.block.submissions.get(uniqueId));\n }\n\n submitAssignment(data: SubmitAssignmentRequest): Observable<Submission> {\n return from(this.block.submissions.submit(data));\n }\n\n gradeSubmission(uniqueId: string, data: GradeSubmissionRequest): Observable<Submission> {\n return from(this.block.submissions.grade(uniqueId, data));\n }\n\n listSubmissionsByAssignment(assignmentUniqueId: string, params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.block.submissions.listByAssignment(assignmentUniqueId, params));\n }\n\n listSubmissionsByUser(userUniqueId: string, params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.block.submissions.listByUser(userUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Direct Block Access (for advanced usage)\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Access the underlying block for advanced operations\n * Use this when you need access to services not wrapped by this Angular service\n */\n get rawBlock(): UniversityBlock {\n return this.block;\n }\n}\n"],"names":["Injectable","Inject","from","createUniversityBlock","TRANSPORT","UNIVERSITY_CONFIG","UniversityService","listCourses","params","block","courses","list","getCourse","uniqueId","get","createCourse","data","create","updateCourse","update","deleteCourse","delete","publishCourse","publish","unpublishCourse","unpublish","listCoursesByInstructor","instructorUniqueId","listByInstructor","listCoursesByCategory","categoryUniqueId","listByCategory","listLessons","lessons","getLesson","createLesson","updateLesson","deleteLesson","reorderLessons","courseUniqueId","reorder","listLessonsByCourse","listByCourse","listEnrollments","enrollments","getEnrollment","enroll","updateEnrollmentProgress","updateProgress","completeEnrollment","complete","dropEnrollment","drop","listEnrollmentsByCourse","listEnrollmentsByUser","userUniqueId","listByUser","getCertificate","listAssignments","assignments","getAssignment","createAssignment","updateAssignment","deleteAssignment","listAssignmentsByLesson","lessonUniqueId","listByLesson","listSubmissions","submissions","getSubmission","submitAssignment","submit","gradeSubmission","grade","listSubmissionsByAssignment","assignmentUniqueId","listByAssignment","listSubmissionsByUser","rawBlock","constructor","transport","config","providedIn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,gBAAgB;AACnD,SAAqBC,IAAI,QAAQ,OAAO;AAExC,SACEC,qBAAqB,QAwBhB,6BAA6B;AACpC,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,eAAe;AAsB5D,OAAO,MAAMC;IAUX,gFAAgF;IAChF,kBAAkB;IAClB,gFAAgF;IAEhFC,YAAYC,MAA0B,EAAkC;QACtE,OAAON,KAAK,IAAI,CAACO,KAAK,CAACC,OAAO,CAACC,IAAI,CAACH;IACtC;IAEAI,UAAUC,QAAgB,EAAsB;QAC9C,OAAOX,KAAK,IAAI,CAACO,KAAK,CAACC,OAAO,CAACI,GAAG,CAACD;IACrC;IAEAE,aAAaC,IAAyB,EAAsB;QAC1D,OAAOd,KAAK,IAAI,CAACO,KAAK,CAACC,OAAO,CAACO,MAAM,CAACD;IACxC;IAEAE,aAAaL,QAAgB,EAAEG,IAAyB,EAAsB;QAC5E,OAAOd,KAAK,IAAI,CAACO,KAAK,CAACC,OAAO,CAACS,MAAM,CAACN,UAAUG;IAClD;IAEAI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G,IAA4B,EAA0B;QACtF,OAAOd,KAAK,IAAI,CAACO,KAAK,CAAC2D,WAAW,CAACK,KAAK,CAAC5D,UAAUG;IACrD;IAEA0D,4BAA4BC,kBAA0B,EAAEnE,MAA8B,EAAsC;QAC1H,OAAON,KAAK,IAAI,CAACO,KAAK,CAAC2D,WAAW,CAACQ,gBAAgB,CAACD,oBAAoBnE;IAC1E;IAEAqE,sBAAsBtB,YAAoB,EAAE/C,MAA8B,EAAsC;QAC9G,OAAON,KAAK,IAAI,CAACO,KAAK,CAAC2D,WAAW,CAACZ,UAAU,CAACD,cAAc/C;IAC9D;IAEA,gFAAgF;IAChF,2CAA2C;IAC3C,gFAAgF;IAEhF;;;GAGC,GACD,IAAIsE,WAA4B;QAC9B,OAAO,IAAI,CAACrE,KAAK;IACnB;IAzLAsE,YACE,AAAmBC,SAAoB,EACvC,AAA2BC,MAA6B,CACxD;QACA,IAAI,CAACxE,KAAK,GAAGN,sBAAsB6E,WAAWC;IAChD;AAqLF;AA7La3E;IADZN,WAAW;QAAEkF,YAAY;IAAO;IAK5BjF,aAAAA,OAAOG;IACPH,aAAAA,OAAOI;;;eADsB,qCAAA;eACK,iDAAA;;GAL1BC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/university/university.service.ts"],"sourcesContent":["import { Injectable, Inject, Optional } from '@angular/core';\nimport { Observable, from } from 'rxjs';\nimport type { Transport, PageResult } from '@23blocks/contracts';\nimport {\n createUniversityBlock,\n type UniversityBlock,\n type UniversityBlockConfig,\n type Course,\n type CreateCourseRequest,\n type UpdateCourseRequest,\n type ListCoursesParams,\n type Lesson,\n type CreateLessonRequest,\n type UpdateLessonRequest,\n type ListLessonsParams,\n type ReorderLessonsRequest,\n type Enrollment,\n type EnrollRequest,\n type UpdateEnrollmentProgressRequest,\n type ListEnrollmentsParams,\n type Assignment,\n type CreateAssignmentRequest,\n type UpdateAssignmentRequest,\n type ListAssignmentsParams,\n type Submission,\n type SubmitAssignmentRequest,\n type GradeSubmissionRequest,\n type ListSubmissionsParams,\n} from '@23blocks/block-university';\nimport { TRANSPORT, UNIVERSITY_TRANSPORT, UNIVERSITY_CONFIG } from '../tokens.js';\n\n/**\n * Angular service wrapping the University block.\n * Converts Promise-based APIs to RxJS Observables.\n *\n * @example\n * ```typescript\n * @Component({...})\n * export class CourseListComponent {\n * constructor(private university: UniversityService) {}\n *\n * loadCourses() {\n * this.university.listCourses({ page: 1, perPage: 10 }).subscribe({\n * next: (result) => console.log('Courses:', result.data),\n * error: (err) => console.error('Failed:', err),\n * });\n * }\n * }\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class UniversityService {\n private readonly block: UniversityBlock | null;\n\n constructor(\n @Optional() @Inject(UNIVERSITY_TRANSPORT) serviceTransport: Transport | null,\n @Optional() @Inject(TRANSPORT) legacyTransport: Transport | null,\n @Inject(UNIVERSITY_CONFIG) config: UniversityBlockConfig\n ) {\n const transport = serviceTransport ?? legacyTransport;\n this.block = transport ? createUniversityBlock(transport, config) : null;\n }\n\n /**\n * Ensure the service is configured, throw helpful error if not\n */\n private ensureConfigured(): UniversityBlock {\n if (!this.block) {\n throw new Error(\n '[23blocks] UniversityService is not configured. ' +\n \"Add 'urls.university' to your provideBlocks23() configuration.\"\n );\n }\n return this.block;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Courses Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listCourses(params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.ensureConfigured().courses.list(params));\n }\n\n getCourse(uniqueId: string): Observable<Course> {\n return from(this.ensureConfigured().courses.get(uniqueId));\n }\n\n createCourse(data: CreateCourseRequest): Observable<Course> {\n return from(this.ensureConfigured().courses.create(data));\n }\n\n updateCourse(uniqueId: string, data: UpdateCourseRequest): Observable<Course> {\n return from(this.ensureConfigured().courses.update(uniqueId, data));\n }\n\n deleteCourse(uniqueId: string): Observable<void> {\n return from(this.ensureConfigured().courses.delete(uniqueId));\n }\n\n publishCourse(uniqueId: string): Observable<Course> {\n return from(this.ensureConfigured().courses.publish(uniqueId));\n }\n\n unpublishCourse(uniqueId: string): Observable<Course> {\n return from(this.ensureConfigured().courses.unpublish(uniqueId));\n }\n\n listCoursesByInstructor(instructorUniqueId: string, params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.ensureConfigured().courses.listByInstructor(instructorUniqueId, params));\n }\n\n listCoursesByCategory(categoryUniqueId: string, params?: ListCoursesParams): Observable<PageResult<Course>> {\n return from(this.ensureConfigured().courses.listByCategory(categoryUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Lessons Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listLessons(params?: ListLessonsParams): Observable<PageResult<Lesson>> {\n return from(this.ensureConfigured().lessons.list(params));\n }\n\n getLesson(uniqueId: string): Observable<Lesson> {\n return from(this.ensureConfigured().lessons.get(uniqueId));\n }\n\n createLesson(data: CreateLessonRequest): Observable<Lesson> {\n return from(this.ensureConfigured().lessons.create(data));\n }\n\n updateLesson(uniqueId: string, data: UpdateLessonRequest): Observable<Lesson> {\n return from(this.ensureConfigured().lessons.update(uniqueId, data));\n }\n\n deleteLesson(uniqueId: string): Observable<void> {\n return from(this.ensureConfigured().lessons.delete(uniqueId));\n }\n\n reorderLessons(courseUniqueId: string, data: ReorderLessonsRequest): Observable<Lesson[]> {\n return from(this.ensureConfigured().lessons.reorder(courseUniqueId, data));\n }\n\n listLessonsByCourse(courseUniqueId: string, params?: ListLessonsParams): Observable<PageResult<Lesson>> {\n return from(this.ensureConfigured().lessons.listByCourse(courseUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Enrollments Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listEnrollments(params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.ensureConfigured().enrollments.list(params));\n }\n\n getEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.ensureConfigured().enrollments.get(uniqueId));\n }\n\n enroll(data: EnrollRequest): Observable<Enrollment> {\n return from(this.ensureConfigured().enrollments.enroll(data));\n }\n\n updateEnrollmentProgress(uniqueId: string, data: UpdateEnrollmentProgressRequest): Observable<Enrollment> {\n return from(this.ensureConfigured().enrollments.updateProgress(uniqueId, data));\n }\n\n completeEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.ensureConfigured().enrollments.complete(uniqueId));\n }\n\n dropEnrollment(uniqueId: string): Observable<Enrollment> {\n return from(this.ensureConfigured().enrollments.drop(uniqueId));\n }\n\n listEnrollmentsByCourse(courseUniqueId: string, params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.ensureConfigured().enrollments.listByCourse(courseUniqueId, params));\n }\n\n listEnrollmentsByUser(userUniqueId: string, params?: ListEnrollmentsParams): Observable<PageResult<Enrollment>> {\n return from(this.ensureConfigured().enrollments.listByUser(userUniqueId, params));\n }\n\n getCertificate(uniqueId: string): Observable<{ certificateUrl: string }> {\n return from(this.ensureConfigured().enrollments.getCertificate(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Assignments Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listAssignments(params?: ListAssignmentsParams): Observable<PageResult<Assignment>> {\n return from(this.ensureConfigured().assignments.list(params));\n }\n\n getAssignment(uniqueId: string): Observable<Assignment> {\n return from(this.ensureConfigured().assignments.get(uniqueId));\n }\n\n createAssignment(data: CreateAssignmentRequest): Observable<Assignment> {\n return from(this.ensureConfigured().assignments.create(data));\n }\n\n updateAssignment(uniqueId: string, data: UpdateAssignmentRequest): Observable<Assignment> {\n return from(this.ensureConfigured().assignments.update(uniqueId, data));\n }\n\n deleteAssignment(uniqueId: string): Observable<void> {\n return from(this.ensureConfigured().assignments.delete(uniqueId));\n }\n\n listAssignmentsByLesson(lessonUniqueId: string, params?: ListAssignmentsParams): Observable<PageResult<Assignment>> {\n return from(this.ensureConfigured().assignments.listByLesson(lessonUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Submissions Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listSubmissions(params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.ensureConfigured().submissions.list(params));\n }\n\n getSubmission(uniqueId: string): Observable<Submission> {\n return from(this.ensureConfigured().submissions.get(uniqueId));\n }\n\n submitAssignment(data: SubmitAssignmentRequest): Observable<Submission> {\n return from(this.ensureConfigured().submissions.submit(data));\n }\n\n gradeSubmission(uniqueId: string, data: GradeSubmissionRequest): Observable<Submission> {\n return from(this.ensureConfigured().submissions.grade(uniqueId, data));\n }\n\n listSubmissionsByAssignment(assignmentUniqueId: string, params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.ensureConfigured().submissions.listByAssignment(assignmentUniqueId, params));\n }\n\n listSubmissionsByUser(userUniqueId: string, params?: ListSubmissionsParams): Observable<PageResult<Submission>> {\n return from(this.ensureConfigured().submissions.listByUser(userUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Direct Block Access (for advanced usage)\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Access the underlying block for advanced operations\n * Use this when you need access to services not wrapped by this Angular service\n */\n get rawBlock(): UniversityBlock {\n return this.ensureConfigured();\n }\n}\n"],"names":["Injectable","Inject","Optional","from","createUniversityBlock","TRANSPORT","UNIVERSITY_TRANSPORT","UNIVERSITY_CONFIG","UniversityService","ensureConfigured","block","Error","listCourses","params","courses","list","getCourse","uniqueId","get","createCourse","data","create","updateCourse","update","deleteCourse","delete","publishCourse","publish","unpublishCourse","unpublish","listCoursesByInstructor","instructorUniqueId","listByInstructor","listCoursesByCategory","categoryUniqueId","listByCategory","listLessons","lessons","getLesson","createLesson","updateLesson","deleteLesson","reorderLessons","courseUniqueId","reorder","listLessonsByCourse","listByCourse","listEnrollments","enrollments","getEnrollment","enroll","updateEnrollmentProgress","updateProgress","completeEnrollment","complete","dropEnrollment","drop","listEnrollmentsByCourse","listEnrollmentsByUser","userUniqueId","listByUser","getCertificate","listAssignments","assignments","getAssignment","createAssignment","updateAssignment","deleteAssignment","listAssignmentsByLesson","lessonUniqueId","listByLesson","listSubmissions","submissions","getSubmission","submitAssignment","submit","gradeSubmission","grade","listSubmissionsByAssignment","assignmentUniqueId","listByAssignment","listSubmissionsByUser","rawBlock","constructor","serviceTransport","legacyTransport","config","transport","providedIn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;AAAA,SAASA,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AAC7D,SAAqBC,IAAI,QAAQ,OAAO;AAExC,SACEC,qBAAqB,QAwBhB,6BAA6B;AACpC,SAASC,SAAS,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ,eAAe;AAsBlF,OAAO,MAAMC;IAYX;;GAEC,GACD,AAAQC,mBAAoC;QAC1C,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;YACf,MAAM,IAAIC,MACR,qDACA;QAEJ;QACA,OAAO,IAAI,CAACD,KAAK;IACnB;IAEA,gFAAgF;IAChF,kBAAkB;IAClB,gFAAgF;IAEhFE,YAAYC,MAA0B,EAAkC;QACtE,OAAOV,KAAK,IAAI,CAACM,gBAAgB,GAAGK,OAAO,CAACC,IAAI,CAACF;IACnD;IAEAG,UAAUC,QAAgB,EAAsB;QAC9C,OAAOd,KAAK,IAAI,CAACM,gBAAgB,GAAGK,OAAO,CAACI,GAAG,CAACD;IAClD;IAEAE,aAAaC,IAAyB,EAAsB;QAC1D,OAAOjB,KAAK,IAAI,CAACM,gBAAgB,GAAGK,OAAO,CAACO,MAAM,CAACD;IACrD;IAEAE,aAAaL,QAAgB,EAAEG,IAAyB,EAAsB;QAC5E,OAAOjB,KAAK,IA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,GAAG+D,WAAW,CAACtD,GAAG,CAACD;IACtD;IAEAyD,iBAAiBtD,IAA6B,EAA0B;QACtE,OAAOjB,KAAK,IAAI,CAACM,gBAAgB,GAAG+D,WAAW,CAACG,MAAM,CAACvD;IACzD;IAEAwD,gBAAgB3D,QAAgB,EAAEG,IAA4B,EAA0B;QACtF,OAAOjB,KAAK,IAAI,CAACM,gBAAgB,GAAG+D,WAAW,CAACK,KAAK,CAAC5D,UAAUG;IAClE;IAEA0D,4BAA4BC,kBAA0B,EAAElE,MAA8B,EAAsC;QAC1H,OAAOV,KAAK,IAAI,CAACM,gBAAgB,GAAG+D,WAAW,CAACQ,gBAAgB,CAACD,oBAAoBlE;IACvF;IAEAoE,sBAAsBtB,YAAoB,EAAE9C,MAA8B,EAAsC;QAC9G,OAAOV,KAAK,IAAI,CAACM,gBAAgB,GAAG+D,WAAW,CAACZ,UAAU,CAACD,cAAc9C;IAC3E;IAEA,gFAAgF;IAChF,2CAA2C;IAC3C,gFAAgF;IAEhF;;;GAGC,GACD,IAAIqE,WAA4B;QAC9B,OAAO,IAAI,CAACzE,gBAAgB;IAC9B;IAxMA0E,YACE,AAA0CC,gBAAkC,EAC5E,AAA+BC,eAAiC,EAChE,AAA2BC,MAA6B,CACxD;QACA,MAAMC,YAAYH,2BAAAA,mBAAoBC;QACtC,IAAI,CAAC3E,KAAK,GAAG6E,YAAYnF,sBAAsBmF,WAAWD,UAAU;IACtE;AAkMF;AA5Ma9E;IADZR,WAAW;QAAEwF,YAAY;IAAO;IAK5BtF,aAAAA;IAAYD,aAAAA,OAAOK;IACnBJ,aAAAA;IAAYD,aAAAA,OAAOI;IACnBJ,aAAAA,OAAOM;;;;;eAA2B,iDAAA;;GAN1BC"}
|
|
@@ -1,73 +1,81 @@
|
|
|
1
1
|
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
|
|
2
2
|
import { _ as _ts_metadata } from "@swc/helpers/_/_ts_metadata";
|
|
3
3
|
import { _ as _ts_param } from "@swc/helpers/_/_ts_param";
|
|
4
|
-
import { Injectable, Inject } from '@angular/core';
|
|
4
|
+
import { Injectable, Inject, Optional } from '@angular/core';
|
|
5
5
|
import { from } from 'rxjs';
|
|
6
6
|
import { createWalletBlock } from '@23blocks/block-wallet';
|
|
7
|
-
import { TRANSPORT, WALLET_CONFIG } from '../tokens.js';
|
|
7
|
+
import { TRANSPORT, WALLET_TRANSPORT, WALLET_CONFIG } from '../tokens.js';
|
|
8
8
|
export class WalletService {
|
|
9
|
+
/**
|
|
10
|
+
* Ensure the service is configured, throw helpful error if not
|
|
11
|
+
*/ ensureConfigured() {
|
|
12
|
+
if (!this.block) {
|
|
13
|
+
throw new Error('[23blocks] WalletService is not configured. ' + "Add 'urls.wallet' to your provideBlocks23() configuration.");
|
|
14
|
+
}
|
|
15
|
+
return this.block;
|
|
16
|
+
}
|
|
9
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
18
|
// Wallets Service
|
|
11
19
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
20
|
listWallets(params) {
|
|
13
|
-
return from(this.
|
|
21
|
+
return from(this.ensureConfigured().wallets.list(params));
|
|
14
22
|
}
|
|
15
23
|
getWallet(uniqueId) {
|
|
16
|
-
return from(this.
|
|
24
|
+
return from(this.ensureConfigured().wallets.get(uniqueId));
|
|
17
25
|
}
|
|
18
26
|
getWalletByUser(userUniqueId) {
|
|
19
|
-
return from(this.
|
|
27
|
+
return from(this.ensureConfigured().wallets.getByUser(userUniqueId));
|
|
20
28
|
}
|
|
21
29
|
createWallet(data) {
|
|
22
|
-
return from(this.
|
|
30
|
+
return from(this.ensureConfigured().wallets.create(data));
|
|
23
31
|
}
|
|
24
32
|
updateWallet(uniqueId, data) {
|
|
25
|
-
return from(this.
|
|
33
|
+
return from(this.ensureConfigured().wallets.update(uniqueId, data));
|
|
26
34
|
}
|
|
27
35
|
creditWallet(uniqueId, data) {
|
|
28
|
-
return from(this.
|
|
36
|
+
return from(this.ensureConfigured().wallets.credit(uniqueId, data));
|
|
29
37
|
}
|
|
30
38
|
debitWallet(uniqueId, data) {
|
|
31
|
-
return from(this.
|
|
39
|
+
return from(this.ensureConfigured().wallets.debit(uniqueId, data));
|
|
32
40
|
}
|
|
33
41
|
getWalletBalance(uniqueId) {
|
|
34
|
-
return from(this.
|
|
42
|
+
return from(this.ensureConfigured().wallets.getBalance(uniqueId));
|
|
35
43
|
}
|
|
36
44
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
45
|
// Transactions Service
|
|
38
46
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
39
47
|
listTransactions(params) {
|
|
40
|
-
return from(this.
|
|
48
|
+
return from(this.ensureConfigured().transactions.list(params));
|
|
41
49
|
}
|
|
42
50
|
getTransaction(uniqueId) {
|
|
43
|
-
return from(this.
|
|
51
|
+
return from(this.ensureConfigured().transactions.get(uniqueId));
|
|
44
52
|
}
|
|
45
53
|
listTransactionsByWallet(walletUniqueId, params) {
|
|
46
|
-
return from(this.
|
|
54
|
+
return from(this.ensureConfigured().transactions.listByWallet(walletUniqueId, params));
|
|
47
55
|
}
|
|
48
56
|
listTransactionsByReference(referenceType, referenceUniqueId, params) {
|
|
49
|
-
return from(this.
|
|
57
|
+
return from(this.ensureConfigured().transactions.listByReference(referenceType, referenceUniqueId, params));
|
|
50
58
|
}
|
|
51
59
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
52
60
|
// Authorization Codes Service
|
|
53
61
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
54
62
|
listAuthorizationCodes(params) {
|
|
55
|
-
return from(this.
|
|
63
|
+
return from(this.ensureConfigured().authorizationCodes.list(params));
|
|
56
64
|
}
|
|
57
65
|
getAuthorizationCode(uniqueId) {
|
|
58
|
-
return from(this.
|
|
66
|
+
return from(this.ensureConfigured().authorizationCodes.get(uniqueId));
|
|
59
67
|
}
|
|
60
68
|
createAuthorizationCode(data) {
|
|
61
|
-
return from(this.
|
|
69
|
+
return from(this.ensureConfigured().authorizationCodes.create(data));
|
|
62
70
|
}
|
|
63
71
|
validateAuthorizationCode(data) {
|
|
64
|
-
return from(this.
|
|
72
|
+
return from(this.ensureConfigured().authorizationCodes.validate(data));
|
|
65
73
|
}
|
|
66
74
|
useAuthorizationCode(data) {
|
|
67
|
-
return from(this.
|
|
75
|
+
return from(this.ensureConfigured().authorizationCodes.use(data));
|
|
68
76
|
}
|
|
69
77
|
invalidateAuthorizationCode(uniqueId) {
|
|
70
|
-
return from(this.
|
|
78
|
+
return from(this.ensureConfigured().authorizationCodes.invalidate(uniqueId));
|
|
71
79
|
}
|
|
72
80
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
73
81
|
// Direct Block Access (for advanced usage)
|
|
@@ -76,21 +84,26 @@ export class WalletService {
|
|
|
76
84
|
* Access the underlying block for advanced operations
|
|
77
85
|
* Use this when you need access to services not wrapped by this Angular service
|
|
78
86
|
*/ get rawBlock() {
|
|
79
|
-
return this.
|
|
87
|
+
return this.ensureConfigured();
|
|
80
88
|
}
|
|
81
|
-
constructor(
|
|
82
|
-
|
|
89
|
+
constructor(serviceTransport, legacyTransport, config){
|
|
90
|
+
const transport = serviceTransport != null ? serviceTransport : legacyTransport;
|
|
91
|
+
this.block = transport ? createWalletBlock(transport, config) : null;
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
WalletService = _ts_decorate([
|
|
86
95
|
Injectable({
|
|
87
96
|
providedIn: 'root'
|
|
88
97
|
}),
|
|
89
|
-
_ts_param(0,
|
|
90
|
-
_ts_param(
|
|
98
|
+
_ts_param(0, Optional()),
|
|
99
|
+
_ts_param(0, Inject(WALLET_TRANSPORT)),
|
|
100
|
+
_ts_param(1, Optional()),
|
|
101
|
+
_ts_param(1, Inject(TRANSPORT)),
|
|
102
|
+
_ts_param(2, Inject(WALLET_CONFIG)),
|
|
91
103
|
_ts_metadata("design:type", Function),
|
|
92
104
|
_ts_metadata("design:paramtypes", [
|
|
93
|
-
|
|
105
|
+
Object,
|
|
106
|
+
Object,
|
|
94
107
|
typeof WalletBlockConfig === "undefined" ? Object : WalletBlockConfig
|
|
95
108
|
])
|
|
96
109
|
], WalletService);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/wallet/wallet.service.ts"],"sourcesContent":["import { Injectable, Inject } from '@angular/core';\nimport { Observable, from } from 'rxjs';\nimport type { Transport, PageResult } from '@23blocks/contracts';\nimport {\n createWalletBlock,\n type WalletBlock,\n type WalletBlockConfig,\n type Wallet,\n type CreateWalletRequest,\n type UpdateWalletRequest,\n type ListWalletsParams,\n type CreditWalletRequest,\n type DebitWalletRequest,\n type Transaction,\n type ListTransactionsParams,\n type AuthorizationCode,\n type CreateAuthorizationCodeRequest,\n type ValidateAuthorizationCodeRequest,\n type UseAuthorizationCodeRequest,\n type ListAuthorizationCodesParams,\n} from '@23blocks/block-wallet';\nimport { TRANSPORT, WALLET_CONFIG } from '../tokens.js';\n\n/**\n * Angular service wrapping the Wallet block.\n * Converts Promise-based APIs to RxJS Observables.\n *\n * @example\n * ```typescript\n * @Component({...})\n * export class WalletComponent {\n * constructor(private wallet: WalletService) {}\n *\n * createWallet(userUniqueId: string) {\n * this.wallet.createWallet({ userUniqueId }).subscribe({\n * next: (wallet) => console.log('Created:', wallet),\n * error: (err) => console.error('Failed:', err),\n * });\n * }\n * }\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class WalletService {\n private readonly block: WalletBlock;\n\n constructor(\n @Inject(TRANSPORT) transport: Transport,\n @Inject(WALLET_CONFIG) config: WalletBlockConfig\n ) {\n this.block = createWalletBlock(transport, config);\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Wallets Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listWallets(params?: ListWalletsParams): Observable<PageResult<Wallet>> {\n return from(this.block.wallets.list(params));\n }\n\n getWallet(uniqueId: string): Observable<Wallet> {\n return from(this.block.wallets.get(uniqueId));\n }\n\n getWalletByUser(userUniqueId: string): Observable<Wallet> {\n return from(this.block.wallets.getByUser(userUniqueId));\n }\n\n createWallet(data: CreateWalletRequest): Observable<Wallet> {\n return from(this.block.wallets.create(data));\n }\n\n updateWallet(uniqueId: string, data: UpdateWalletRequest): Observable<Wallet> {\n return from(this.block.wallets.update(uniqueId, data));\n }\n\n creditWallet(uniqueId: string, data: CreditWalletRequest): Observable<Transaction> {\n return from(this.block.wallets.credit(uniqueId, data));\n }\n\n debitWallet(uniqueId: string, data: DebitWalletRequest): Observable<Transaction> {\n return from(this.block.wallets.debit(uniqueId, data));\n }\n\n getWalletBalance(uniqueId: string): Observable<{ balance: number; currency: string }> {\n return from(this.block.wallets.getBalance(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Transactions Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listTransactions(params?: ListTransactionsParams): Observable<PageResult<Transaction>> {\n return from(this.block.transactions.list(params));\n }\n\n getTransaction(uniqueId: string): Observable<Transaction> {\n return from(this.block.transactions.get(uniqueId));\n }\n\n listTransactionsByWallet(\n walletUniqueId: string,\n params?: ListTransactionsParams\n ): Observable<PageResult<Transaction>> {\n return from(this.block.transactions.listByWallet(walletUniqueId, params));\n }\n\n listTransactionsByReference(\n referenceType: string,\n referenceUniqueId: string,\n params?: ListTransactionsParams\n ): Observable<PageResult<Transaction>> {\n return from(this.block.transactions.listByReference(referenceType, referenceUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Authorization Codes Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listAuthorizationCodes(params?: ListAuthorizationCodesParams): Observable<PageResult<AuthorizationCode>> {\n return from(this.block.authorizationCodes.list(params));\n }\n\n getAuthorizationCode(uniqueId: string): Observable<AuthorizationCode> {\n return from(this.block.authorizationCodes.get(uniqueId));\n }\n\n createAuthorizationCode(data: CreateAuthorizationCodeRequest): Observable<AuthorizationCode> {\n return from(this.block.authorizationCodes.create(data));\n }\n\n validateAuthorizationCode(\n data: ValidateAuthorizationCodeRequest\n ): Observable<{ valid: boolean; authorizationCode?: AuthorizationCode }> {\n return from(this.block.authorizationCodes.validate(data));\n }\n\n useAuthorizationCode(data: UseAuthorizationCodeRequest): Observable<Transaction> {\n return from(this.block.authorizationCodes.use(data));\n }\n\n invalidateAuthorizationCode(uniqueId: string): Observable<AuthorizationCode> {\n return from(this.block.authorizationCodes.invalidate(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Direct Block Access (for advanced usage)\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Access the underlying block for advanced operations\n * Use this when you need access to services not wrapped by this Angular service\n */\n get rawBlock(): WalletBlock {\n return this.block;\n }\n}\n"],"names":["Injectable","Inject","from","createWalletBlock","TRANSPORT","WALLET_CONFIG","WalletService","listWallets","params","block","wallets","list","getWallet","uniqueId","get","getWalletByUser","userUniqueId","getByUser","createWallet","data","create","updateWallet","update","creditWallet","credit","debitWallet","debit","getWalletBalance","getBalance","listTransactions","transactions","getTransaction","listTransactionsByWallet","walletUniqueId","listByWallet","listTransactionsByReference","referenceType","referenceUniqueId","listByReference","listAuthorizationCodes","authorizationCodes","getAuthorizationCode","createAuthorizationCode","validateAuthorizationCode","validate","useAuthorizationCode","use","invalidateAuthorizationCode","invalidate","rawBlock","constructor","transport","config","providedIn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,gBAAgB;AACnD,SAAqBC,IAAI,QAAQ,OAAO;AAExC,SACEC,iBAAiB,QAgBZ,yBAAyB;AAChC,SAASC,SAAS,EAAEC,aAAa,QAAQ,eAAe;AAsBxD,OAAO,MAAMC;IAUX,gFAAgF;IAChF,kBAAkB;IAClB,gFAAgF;IAEhFC,YAAYC,MAA0B,EAAkC;QACtE,OAAON,KAAK,IAAI,CAACO,KAAK,CAACC,OAAO,CAACC,IAA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
+
{"version":3,"sources":["../../../src/lib/wallet/wallet.service.ts"],"sourcesContent":["import { Injectable, Inject, Optional } from '@angular/core';\nimport { Observable, from } from 'rxjs';\nimport type { Transport, PageResult } from '@23blocks/contracts';\nimport {\n createWalletBlock,\n type WalletBlock,\n type WalletBlockConfig,\n type Wallet,\n type CreateWalletRequest,\n type UpdateWalletRequest,\n type ListWalletsParams,\n type CreditWalletRequest,\n type DebitWalletRequest,\n type Transaction,\n type ListTransactionsParams,\n type AuthorizationCode,\n type CreateAuthorizationCodeRequest,\n type ValidateAuthorizationCodeRequest,\n type UseAuthorizationCodeRequest,\n type ListAuthorizationCodesParams,\n} from '@23blocks/block-wallet';\nimport { TRANSPORT, WALLET_TRANSPORT, WALLET_CONFIG } from '../tokens.js';\n\n/**\n * Angular service wrapping the Wallet block.\n * Converts Promise-based APIs to RxJS Observables.\n *\n * @example\n * ```typescript\n * @Component({...})\n * export class WalletComponent {\n * constructor(private wallet: WalletService) {}\n *\n * createWallet(userUniqueId: string) {\n * this.wallet.createWallet({ userUniqueId }).subscribe({\n * next: (wallet) => console.log('Created:', wallet),\n * error: (err) => console.error('Failed:', err),\n * });\n * }\n * }\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class WalletService {\n private readonly block: WalletBlock | null;\n\n constructor(\n @Optional() @Inject(WALLET_TRANSPORT) serviceTransport: Transport | null,\n @Optional() @Inject(TRANSPORT) legacyTransport: Transport | null,\n @Inject(WALLET_CONFIG) config: WalletBlockConfig\n ) {\n const transport = serviceTransport ?? legacyTransport;\n this.block = transport ? createWalletBlock(transport, config) : null;\n }\n\n /**\n * Ensure the service is configured, throw helpful error if not\n */\n private ensureConfigured(): WalletBlock {\n if (!this.block) {\n throw new Error(\n '[23blocks] WalletService is not configured. ' +\n \"Add 'urls.wallet' to your provideBlocks23() configuration.\"\n );\n }\n return this.block;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Wallets Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listWallets(params?: ListWalletsParams): Observable<PageResult<Wallet>> {\n return from(this.ensureConfigured().wallets.list(params));\n }\n\n getWallet(uniqueId: string): Observable<Wallet> {\n return from(this.ensureConfigured().wallets.get(uniqueId));\n }\n\n getWalletByUser(userUniqueId: string): Observable<Wallet> {\n return from(this.ensureConfigured().wallets.getByUser(userUniqueId));\n }\n\n createWallet(data: CreateWalletRequest): Observable<Wallet> {\n return from(this.ensureConfigured().wallets.create(data));\n }\n\n updateWallet(uniqueId: string, data: UpdateWalletRequest): Observable<Wallet> {\n return from(this.ensureConfigured().wallets.update(uniqueId, data));\n }\n\n creditWallet(uniqueId: string, data: CreditWalletRequest): Observable<Transaction> {\n return from(this.ensureConfigured().wallets.credit(uniqueId, data));\n }\n\n debitWallet(uniqueId: string, data: DebitWalletRequest): Observable<Transaction> {\n return from(this.ensureConfigured().wallets.debit(uniqueId, data));\n }\n\n getWalletBalance(uniqueId: string): Observable<{ balance: number; currency: string }> {\n return from(this.ensureConfigured().wallets.getBalance(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Transactions Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listTransactions(params?: ListTransactionsParams): Observable<PageResult<Transaction>> {\n return from(this.ensureConfigured().transactions.list(params));\n }\n\n getTransaction(uniqueId: string): Observable<Transaction> {\n return from(this.ensureConfigured().transactions.get(uniqueId));\n }\n\n listTransactionsByWallet(\n walletUniqueId: string,\n params?: ListTransactionsParams\n ): Observable<PageResult<Transaction>> {\n return from(this.ensureConfigured().transactions.listByWallet(walletUniqueId, params));\n }\n\n listTransactionsByReference(\n referenceType: string,\n referenceUniqueId: string,\n params?: ListTransactionsParams\n ): Observable<PageResult<Transaction>> {\n return from(this.ensureConfigured().transactions.listByReference(referenceType, referenceUniqueId, params));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Authorization Codes Service\n // ─────────────────────────────────────────────────────────────────────────────\n\n listAuthorizationCodes(params?: ListAuthorizationCodesParams): Observable<PageResult<AuthorizationCode>> {\n return from(this.ensureConfigured().authorizationCodes.list(params));\n }\n\n getAuthorizationCode(uniqueId: string): Observable<AuthorizationCode> {\n return from(this.ensureConfigured().authorizationCodes.get(uniqueId));\n }\n\n createAuthorizationCode(data: CreateAuthorizationCodeRequest): Observable<AuthorizationCode> {\n return from(this.ensureConfigured().authorizationCodes.create(data));\n }\n\n validateAuthorizationCode(\n data: ValidateAuthorizationCodeRequest\n ): Observable<{ valid: boolean; authorizationCode?: AuthorizationCode }> {\n return from(this.ensureConfigured().authorizationCodes.validate(data));\n }\n\n useAuthorizationCode(data: UseAuthorizationCodeRequest): Observable<Transaction> {\n return from(this.ensureConfigured().authorizationCodes.use(data));\n }\n\n invalidateAuthorizationCode(uniqueId: string): Observable<AuthorizationCode> {\n return from(this.ensureConfigured().authorizationCodes.invalidate(uniqueId));\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Direct Block Access (for advanced usage)\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Access the underlying block for advanced operations\n * Use this when you need access to services not wrapped by this Angular service\n */\n get rawBlock(): WalletBlock {\n return this.ensureConfigured();\n }\n}\n"],"names":["Injectable","Inject","Optional","from","createWalletBlock","TRANSPORT","WALLET_TRANSPORT","WALLET_CONFIG","WalletService","ensureConfigured","block","Error","listWallets","params","wallets","list","getWallet","uniqueId","get","getWalletByUser","userUniqueId","getByUser","createWallet","data","create","updateWallet","update","creditWallet","credit","debitWallet","debit","getWalletBalance","getBalance","listTransactions","transactions","getTransaction","listTransactionsByWallet","walletUniqueId","listByWallet","listTransactionsByReference","referenceType","referenceUniqueId","listByReference","listAuthorizationCodes","authorizationCodes","getAuthorizationCode","createAuthorizationCode","validateAuthorizationCode","validate","useAuthorizationCode","use","invalidateAuthorizationCode","invalidate","rawBlock","constructor","serviceTransport","legacyTransport","config","transport","providedIn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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