@blackcode_sa/metaestetics-api 1.12.2 → 1.12.4
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/backoffice/index.d.mts +64 -14
- package/dist/backoffice/index.d.ts +64 -14
- package/dist/backoffice/index.js +72 -53
- package/dist/backoffice/index.mjs +72 -53
- package/dist/index.d.mts +212 -18
- package/dist/index.d.ts +212 -18
- package/dist/index.js +139 -53
- package/dist/index.mjs +137 -53
- package/package.json +1 -1
- package/src/backoffice/services/FIXES_README.md +102 -0
- package/src/backoffice/services/category.service.ts +46 -27
- package/src/backoffice/services/product.service.ts +52 -74
- package/src/backoffice/services/technology.service.ts +99 -116
- package/src/backoffice/types/category.types.ts +28 -2
- package/src/backoffice/types/product.types.ts +10 -9
- package/src/backoffice/types/technology.types.ts +31 -59
- package/src/types/clinic/index.ts +89 -0
- package/src/validations/clinic.schema.ts +68 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Requirement } from
|
|
2
|
-
import { BlockingCondition } from
|
|
3
|
-
import { CertificationRequirement } from
|
|
4
|
-
import { DocumentTemplate } from
|
|
5
|
-
import { ProcedureFamily } from
|
|
6
|
-
import { ContraindicationDynamic } from
|
|
7
|
-
import { TreatmentBenefitDynamic } from
|
|
1
|
+
import { Requirement } from './requirement.types';
|
|
2
|
+
import { BlockingCondition } from './static/blocking-condition.types';
|
|
3
|
+
import { CertificationRequirement } from './static/certification.types';
|
|
4
|
+
import { DocumentTemplate } from '../../types/documentation-templates';
|
|
5
|
+
import { ProcedureFamily } from './static/procedure-family.types';
|
|
6
|
+
import { ContraindicationDynamic } from './admin-constants.types';
|
|
7
|
+
import { TreatmentBenefitDynamic } from './admin-constants.types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Reference to a documentation template with metadata
|
|
@@ -77,19 +77,15 @@ export interface Technology {
|
|
|
77
77
|
/**
|
|
78
78
|
* Collection in Firestore database where technologies are stored
|
|
79
79
|
*/
|
|
80
|
-
export const TECHNOLOGIES_COLLECTION =
|
|
80
|
+
export const TECHNOLOGIES_COLLECTION = 'technologies';
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Interface for the TechnologyService class
|
|
84
84
|
*/
|
|
85
85
|
export interface ITechnologyService {
|
|
86
|
-
create(
|
|
87
|
-
technology: Omit<Technology, "id" | "createdAt" | "updatedAt">
|
|
88
|
-
): Promise<Technology>;
|
|
86
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<Technology>;
|
|
89
87
|
getTechnologyCounts(active?: boolean): Promise<Record<string, number>>;
|
|
90
|
-
getTechnologyCountsByCategory(
|
|
91
|
-
active?: boolean
|
|
92
|
-
): Promise<Record<string, number>>;
|
|
88
|
+
getTechnologyCountsByCategory(active?: boolean): Promise<Record<string, number>>;
|
|
93
89
|
getAll(options?: {
|
|
94
90
|
active?: boolean;
|
|
95
91
|
limit?: number;
|
|
@@ -97,83 +93,61 @@ export interface ITechnologyService {
|
|
|
97
93
|
}): Promise<{ technologies: Technology[]; lastVisible: any }>;
|
|
98
94
|
getAllByCategoryId(
|
|
99
95
|
categoryId: string,
|
|
100
|
-
options?: { active?: boolean; limit?: number; lastVisible?: any }
|
|
96
|
+
options?: { active?: boolean; limit?: number; lastVisible?: any },
|
|
101
97
|
): Promise<{ technologies: Technology[]; lastVisible: any }>;
|
|
102
98
|
getAllBySubcategoryId(
|
|
103
99
|
subcategoryId: string,
|
|
104
|
-
options?: { active?: boolean; limit?: number; lastVisible?: any }
|
|
100
|
+
options?: { active?: boolean; limit?: number; lastVisible?: any },
|
|
105
101
|
): Promise<{ technologies: Technology[]; lastVisible: any }>;
|
|
106
102
|
update(
|
|
107
103
|
id: string,
|
|
108
|
-
technology: Partial<Omit<Technology,
|
|
104
|
+
technology: Partial<Omit<Technology, 'id' | 'createdAt'>>,
|
|
109
105
|
): Promise<Technology | null>;
|
|
110
106
|
delete(id: string): Promise<void>;
|
|
111
107
|
reactivate(id: string): Promise<void>;
|
|
112
108
|
getById(id: string): Promise<Technology | null>;
|
|
113
|
-
addRequirement(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
): Promise<Technology | null>;
|
|
117
|
-
removeRequirement(
|
|
118
|
-
technologyId: string,
|
|
119
|
-
requirement: Requirement
|
|
120
|
-
): Promise<Technology | null>;
|
|
121
|
-
getRequirements(
|
|
122
|
-
technologyId: string,
|
|
123
|
-
type?: "pre" | "post"
|
|
124
|
-
): Promise<Requirement[]>;
|
|
109
|
+
addRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
110
|
+
removeRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
111
|
+
getRequirements(technologyId: string, type?: 'pre' | 'post'): Promise<Requirement[]>;
|
|
125
112
|
updateRequirement(
|
|
126
113
|
technologyId: string,
|
|
127
114
|
oldRequirement: Requirement,
|
|
128
|
-
newRequirement: Requirement
|
|
115
|
+
newRequirement: Requirement,
|
|
129
116
|
): Promise<Technology | null>;
|
|
130
117
|
addBlockingCondition(
|
|
131
118
|
technologyId: string,
|
|
132
|
-
condition: BlockingCondition
|
|
119
|
+
condition: BlockingCondition,
|
|
133
120
|
): Promise<Technology | null>;
|
|
134
121
|
removeBlockingCondition(
|
|
135
122
|
technologyId: string,
|
|
136
|
-
condition: BlockingCondition
|
|
123
|
+
condition: BlockingCondition,
|
|
137
124
|
): Promise<Technology | null>;
|
|
138
125
|
addContraindication(
|
|
139
126
|
technologyId: string,
|
|
140
|
-
contraindication: ContraindicationDynamic
|
|
127
|
+
contraindication: ContraindicationDynamic,
|
|
141
128
|
): Promise<Technology | null>;
|
|
142
129
|
removeContraindication(
|
|
143
130
|
technologyId: string,
|
|
144
|
-
contraindication: ContraindicationDynamic
|
|
131
|
+
contraindication: ContraindicationDynamic,
|
|
145
132
|
): Promise<Technology | null>;
|
|
146
133
|
updateContraindication(
|
|
147
134
|
technologyId: string,
|
|
148
|
-
contraindication: ContraindicationDynamic
|
|
149
|
-
): Promise<Technology | null>;
|
|
150
|
-
addBenefit(
|
|
151
|
-
technologyId: string,
|
|
152
|
-
benefit: TreatmentBenefitDynamic
|
|
153
|
-
): Promise<Technology | null>;
|
|
154
|
-
removeBenefit(
|
|
155
|
-
technologyId: string,
|
|
156
|
-
benefit: TreatmentBenefitDynamic
|
|
157
|
-
): Promise<Technology | null>;
|
|
158
|
-
updateBenefit(
|
|
159
|
-
technologyId: string,
|
|
160
|
-
benefit: TreatmentBenefitDynamic
|
|
135
|
+
contraindication: ContraindicationDynamic,
|
|
161
136
|
): Promise<Technology | null>;
|
|
137
|
+
addBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
138
|
+
removeBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
139
|
+
updateBenefit(technologyId: string, benefit: TreatmentBenefitDynamic): Promise<Technology | null>;
|
|
162
140
|
getBlockingConditions(technologyId: string): Promise<BlockingCondition[]>;
|
|
163
|
-
getContraindications(
|
|
164
|
-
technologyId: string
|
|
165
|
-
): Promise<ContraindicationDynamic[]>;
|
|
141
|
+
getContraindications(technologyId: string): Promise<ContraindicationDynamic[]>;
|
|
166
142
|
getBenefits(technologyId: string): Promise<TreatmentBenefitDynamic[]>;
|
|
167
143
|
updateCertificationRequirement(
|
|
168
144
|
technologyId: string,
|
|
169
|
-
certificationRequirement: CertificationRequirement
|
|
145
|
+
certificationRequirement: CertificationRequirement,
|
|
170
146
|
): Promise<Technology | null>;
|
|
171
|
-
getCertificationRequirement(
|
|
172
|
-
technologyId: string
|
|
173
|
-
): Promise<CertificationRequirement | null>;
|
|
147
|
+
getCertificationRequirement(technologyId: string): Promise<CertificationRequirement | null>;
|
|
174
148
|
validateCertification(
|
|
175
149
|
requiredCertification: CertificationRequirement,
|
|
176
|
-
practitionerCertification: any
|
|
150
|
+
practitionerCertification: any,
|
|
177
151
|
): boolean;
|
|
178
152
|
getAllowedTechnologies(practitioner: any): Promise<{
|
|
179
153
|
technologies: Technology[];
|
|
@@ -181,9 +155,7 @@ export interface ITechnologyService {
|
|
|
181
155
|
categories: string[];
|
|
182
156
|
subcategories: string[];
|
|
183
157
|
}>;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
subcategoryId: string
|
|
187
|
-
): Promise<Technology[]>;
|
|
158
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
159
|
+
getAllForFilterBySubcategoryId(categoryId: string, subcategoryId: string): Promise<Technology[]>;
|
|
188
160
|
getAllForFilter(): Promise<Technology[]>;
|
|
189
161
|
}
|
|
@@ -174,6 +174,93 @@ export enum SubscriptionModel {
|
|
|
174
174
|
ENTERPRISE = "enterprise",
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Enum for subscription status
|
|
179
|
+
*/
|
|
180
|
+
export enum SubscriptionStatus {
|
|
181
|
+
ACTIVE = "active",
|
|
182
|
+
PENDING_CANCELLATION = "pending_cancellation",
|
|
183
|
+
CANCELED = "canceled",
|
|
184
|
+
PAST_DUE = "past_due",
|
|
185
|
+
TRIALING = "trialing",
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Interface for billing information
|
|
190
|
+
*/
|
|
191
|
+
export interface BillingInfo {
|
|
192
|
+
stripeCustomerId: string;
|
|
193
|
+
subscriptionStatus: SubscriptionStatus;
|
|
194
|
+
planType: string;
|
|
195
|
+
stripeSubscriptionId: string | null;
|
|
196
|
+
stripePriceId: string | null;
|
|
197
|
+
currentPeriodStart: Timestamp | null;
|
|
198
|
+
currentPeriodEnd: Timestamp | null;
|
|
199
|
+
updatedAt: Timestamp;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Enum for billing transaction types
|
|
204
|
+
*/
|
|
205
|
+
export enum BillingTransactionType {
|
|
206
|
+
SUBSCRIPTION_ACTIVATED = "subscription_activated",
|
|
207
|
+
SUBSCRIPTION_RENEWED = "subscription_renewed",
|
|
208
|
+
SUBSCRIPTION_UPDATED = "subscription_updated",
|
|
209
|
+
SUBSCRIPTION_CANCELED = "subscription_canceled",
|
|
210
|
+
SUBSCRIPTION_REACTIVATED = "subscription_reactivated",
|
|
211
|
+
SUBSCRIPTION_DELETED = "subscription_deleted",
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Interface for Stripe data in billing transactions
|
|
216
|
+
*/
|
|
217
|
+
export interface StripeTransactionData {
|
|
218
|
+
sessionId?: string;
|
|
219
|
+
subscriptionId?: string;
|
|
220
|
+
invoiceId?: string;
|
|
221
|
+
priceId: string;
|
|
222
|
+
customerId: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Interface for plan details in billing transactions
|
|
227
|
+
*/
|
|
228
|
+
export interface PlanDetails {
|
|
229
|
+
planName: string;
|
|
230
|
+
planPeriod: string;
|
|
231
|
+
planDisplayName: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Interface for billing transactions
|
|
236
|
+
*/
|
|
237
|
+
export interface BillingTransaction {
|
|
238
|
+
id: string;
|
|
239
|
+
clinicGroupId: string;
|
|
240
|
+
type: BillingTransactionType;
|
|
241
|
+
description: string;
|
|
242
|
+
amount: number;
|
|
243
|
+
currency: string;
|
|
244
|
+
stripeData: StripeTransactionData;
|
|
245
|
+
planDetails: PlanDetails;
|
|
246
|
+
metadata?: Record<string, any>;
|
|
247
|
+
timestamp: Timestamp;
|
|
248
|
+
createdAt: Timestamp;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Interface for creating a billing transaction
|
|
253
|
+
*/
|
|
254
|
+
export interface CreateBillingTransactionData {
|
|
255
|
+
type: BillingTransactionType;
|
|
256
|
+
description: string;
|
|
257
|
+
amount: number;
|
|
258
|
+
currency: string;
|
|
259
|
+
stripeData: StripeTransactionData;
|
|
260
|
+
planDetails: PlanDetails;
|
|
261
|
+
metadata?: Record<string, any>;
|
|
262
|
+
}
|
|
263
|
+
|
|
177
264
|
/**
|
|
178
265
|
* Interface for clinic group
|
|
179
266
|
*/
|
|
@@ -197,6 +284,7 @@ export interface ClinicGroup {
|
|
|
197
284
|
practiceType?: PracticeType;
|
|
198
285
|
languages?: Language[];
|
|
199
286
|
subscriptionModel: SubscriptionModel;
|
|
287
|
+
billing?: BillingInfo;
|
|
200
288
|
calendarSyncEnabled?: boolean;
|
|
201
289
|
autoConfirmAppointments?: boolean;
|
|
202
290
|
businessIdentificationNumber?: string | null;
|
|
@@ -221,6 +309,7 @@ export interface CreateClinicGroupData {
|
|
|
221
309
|
practiceType?: PracticeType;
|
|
222
310
|
languages?: Language[];
|
|
223
311
|
subscriptionModel?: SubscriptionModel;
|
|
312
|
+
billing?: BillingInfo;
|
|
224
313
|
calendarSyncEnabled?: boolean;
|
|
225
314
|
autoConfirmAppointments?: boolean;
|
|
226
315
|
businessIdentificationNumber?: string | null;
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
ClinicTag,
|
|
5
5
|
AdminTokenStatus,
|
|
6
6
|
SubscriptionModel,
|
|
7
|
+
SubscriptionStatus,
|
|
8
|
+
BillingTransactionType,
|
|
7
9
|
PracticeType,
|
|
8
10
|
Language,
|
|
9
11
|
} from "../types/clinic";
|
|
@@ -145,6 +147,70 @@ export const adminTokenSchema = z.object({
|
|
|
145
147
|
expiresAt: z.instanceof(Date).or(z.instanceof(Timestamp)), // Timestamp
|
|
146
148
|
});
|
|
147
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Validation schema for Stripe transaction data
|
|
152
|
+
*/
|
|
153
|
+
export const stripeTransactionDataSchema = z.object({
|
|
154
|
+
sessionId: z.string().optional(),
|
|
155
|
+
subscriptionId: z.string().optional(),
|
|
156
|
+
invoiceId: z.string().optional(),
|
|
157
|
+
priceId: z.string(),
|
|
158
|
+
customerId: z.string(),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Validation schema for plan details
|
|
163
|
+
*/
|
|
164
|
+
export const planDetailsSchema = z.object({
|
|
165
|
+
planName: z.string(),
|
|
166
|
+
planPeriod: z.string(),
|
|
167
|
+
planDisplayName: z.string(),
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Validation schema for billing information
|
|
172
|
+
*/
|
|
173
|
+
export const billingInfoSchema = z.object({
|
|
174
|
+
stripeCustomerId: z.string(),
|
|
175
|
+
subscriptionStatus: z.nativeEnum(SubscriptionStatus),
|
|
176
|
+
planType: z.string(),
|
|
177
|
+
stripeSubscriptionId: z.string().nullable(),
|
|
178
|
+
stripePriceId: z.string().nullable(),
|
|
179
|
+
currentPeriodStart: z.instanceof(Date).or(z.instanceof(Timestamp)).nullable(),
|
|
180
|
+
currentPeriodEnd: z.instanceof(Date).or(z.instanceof(Timestamp)).nullable(),
|
|
181
|
+
updatedAt: z.instanceof(Date).or(z.instanceof(Timestamp)),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Validation schema for billing transactions
|
|
186
|
+
*/
|
|
187
|
+
export const billingTransactionSchema = z.object({
|
|
188
|
+
id: z.string(),
|
|
189
|
+
clinicGroupId: z.string(),
|
|
190
|
+
type: z.nativeEnum(BillingTransactionType),
|
|
191
|
+
description: z.string(),
|
|
192
|
+
amount: z.number(),
|
|
193
|
+
currency: z.string(),
|
|
194
|
+
stripeData: stripeTransactionDataSchema,
|
|
195
|
+
planDetails: planDetailsSchema,
|
|
196
|
+
metadata: z.record(z.any()).optional(),
|
|
197
|
+
timestamp: z.instanceof(Date).or(z.instanceof(Timestamp)),
|
|
198
|
+
createdAt: z.instanceof(Date).or(z.instanceof(Timestamp)),
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Validation schema for creating billing transactions
|
|
203
|
+
*/
|
|
204
|
+
export const createBillingTransactionSchema = z.object({
|
|
205
|
+
type: z.nativeEnum(BillingTransactionType),
|
|
206
|
+
description: z.string(),
|
|
207
|
+
amount: z.number(),
|
|
208
|
+
currency: z.string(),
|
|
209
|
+
stripeData: stripeTransactionDataSchema,
|
|
210
|
+
planDetails: planDetailsSchema,
|
|
211
|
+
metadata: z.record(z.any()).optional(),
|
|
212
|
+
});
|
|
213
|
+
|
|
148
214
|
/**
|
|
149
215
|
* Validaciona šema za kreiranje admin tokena
|
|
150
216
|
*/
|
|
@@ -176,6 +242,7 @@ export const clinicGroupSchema = z.object({
|
|
|
176
242
|
practiceType: z.nativeEnum(PracticeType).optional(),
|
|
177
243
|
languages: z.array(z.nativeEnum(Language)).optional(),
|
|
178
244
|
subscriptionModel: z.nativeEnum(SubscriptionModel),
|
|
245
|
+
billing: billingInfoSchema.optional(),
|
|
179
246
|
calendarSyncEnabled: z.boolean().optional(),
|
|
180
247
|
autoConfirmAppointments: z.boolean().optional(),
|
|
181
248
|
businessIdentificationNumber: z.string().optional().nullable(),
|
|
@@ -254,6 +321,7 @@ export const createClinicGroupSchema = z.object({
|
|
|
254
321
|
.nativeEnum(SubscriptionModel)
|
|
255
322
|
.optional()
|
|
256
323
|
.default(SubscriptionModel.NO_SUBSCRIPTION),
|
|
324
|
+
billing: billingInfoSchema.optional(),
|
|
257
325
|
calendarSyncEnabled: z.boolean().optional(),
|
|
258
326
|
autoConfirmAppointments: z.boolean().optional(),
|
|
259
327
|
businessIdentificationNumber: z.string().optional().nullable(),
|