@blackcode_sa/metaestetics-api 1.15.17-staging.3 → 1.15.17-staging.5
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/admin/index.d.mts +3 -1
- package/dist/admin/index.d.ts +3 -1
- package/dist/index.d.mts +84 -4
- package/dist/index.d.ts +84 -4
- package/dist/index.js +111 -143
- package/dist/index.mjs +250 -283
- package/package.json +1 -1
- package/src/config/tiers.config.ts +3 -27
- package/src/services/auth/auth.service.ts +14 -48
- package/src/services/clinic/clinic-group.service.ts +13 -6
- package/src/services/clinic/utils/clinic-group.utils.ts +95 -87
- package/src/types/clinic/index.ts +8 -1
- package/src/types/clinic/rbac.types.ts +0 -1
- package/src/types/concern/index.ts +66 -0
- package/src/types/index.ts +3 -0
- package/src/validations/clinic.schema.ts +9 -3
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
CLINIC_ADMINS_COLLECTION: () => CLINIC_ADMINS_COLLECTION,
|
|
54
54
|
CLINIC_ANALYTICS_SUBCOLLECTION: () => CLINIC_ANALYTICS_SUBCOLLECTION,
|
|
55
55
|
CLINIC_GROUPS_COLLECTION: () => CLINIC_GROUPS_COLLECTION,
|
|
56
|
+
CONCERNS_COLLECTION: () => CONCERNS_COLLECTION,
|
|
56
57
|
CalendarEventStatus: () => CalendarEventStatus,
|
|
57
58
|
CalendarEventType: () => CalendarEventType,
|
|
58
59
|
CalendarServiceV2: () => CalendarServiceV2,
|
|
@@ -650,7 +651,6 @@ var PractitionerInviteStatus = /* @__PURE__ */ ((PractitionerInviteStatus2) => {
|
|
|
650
651
|
var ClinicRole = /* @__PURE__ */ ((ClinicRole2) => {
|
|
651
652
|
ClinicRole2["OWNER"] = "owner";
|
|
652
653
|
ClinicRole2["ADMIN"] = "admin";
|
|
653
|
-
ClinicRole2["DOCTOR"] = "doctor";
|
|
654
654
|
ClinicRole2["RECEPTIONIST"] = "receptionist";
|
|
655
655
|
ClinicRole2["ASSISTANT"] = "assistant";
|
|
656
656
|
return ClinicRole2;
|
|
@@ -667,11 +667,11 @@ var StaffInviteStatus = /* @__PURE__ */ ((StaffInviteStatus2) => {
|
|
|
667
667
|
var CLINIC_GROUPS_COLLECTION = "clinic_groups";
|
|
668
668
|
var CLINIC_ADMINS_COLLECTION = "clinic_admins";
|
|
669
669
|
var CLINICS_COLLECTION = "clinics";
|
|
670
|
-
var AdminTokenStatus = /* @__PURE__ */ ((
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
return
|
|
670
|
+
var AdminTokenStatus = /* @__PURE__ */ ((AdminTokenStatus3) => {
|
|
671
|
+
AdminTokenStatus3["ACTIVE"] = "active";
|
|
672
|
+
AdminTokenStatus3["USED"] = "used";
|
|
673
|
+
AdminTokenStatus3["EXPIRED"] = "expired";
|
|
674
|
+
return AdminTokenStatus3;
|
|
675
675
|
})(AdminTokenStatus || {});
|
|
676
676
|
var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
|
|
677
677
|
SubscriptionModel2["NO_SUBSCRIPTION"] = "no_subscription";
|
|
@@ -2189,7 +2189,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2189
2189
|
* @param limit - Number of top procedures to return
|
|
2190
2190
|
* @returns Array of procedure popularity metrics
|
|
2191
2191
|
*/
|
|
2192
|
-
async getProcedurePopularity(dateRange,
|
|
2192
|
+
async getProcedurePopularity(dateRange, limit23 = 10) {
|
|
2193
2193
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2194
2194
|
const completed = getCompletedAppointments(appointments);
|
|
2195
2195
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2218,7 +2218,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2218
2218
|
completedCount: data.count,
|
|
2219
2219
|
rank: 0
|
|
2220
2220
|
// Will be set after sorting
|
|
2221
|
-
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0,
|
|
2221
|
+
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2222
2222
|
}
|
|
2223
2223
|
/**
|
|
2224
2224
|
* Get procedure profitability metrics
|
|
@@ -2227,7 +2227,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2227
2227
|
* @param limit - Number of top procedures to return
|
|
2228
2228
|
* @returns Array of procedure profitability metrics
|
|
2229
2229
|
*/
|
|
2230
|
-
async getProcedureProfitability(dateRange,
|
|
2230
|
+
async getProcedureProfitability(dateRange, limit23 = 10) {
|
|
2231
2231
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2232
2232
|
const completed = getCompletedAppointments(appointments);
|
|
2233
2233
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2261,7 +2261,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2261
2261
|
appointmentCount: data.count,
|
|
2262
2262
|
rank: 0
|
|
2263
2263
|
// Will be set after sorting
|
|
2264
|
-
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0,
|
|
2264
|
+
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2265
2265
|
}
|
|
2266
2266
|
// ==========================================
|
|
2267
2267
|
// Time Efficiency Analytics
|
|
@@ -4797,6 +4797,9 @@ var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
|
|
|
4797
4797
|
return ResourceStatus2;
|
|
4798
4798
|
})(ResourceStatus || {});
|
|
4799
4799
|
|
|
4800
|
+
// src/types/concern/index.ts
|
|
4801
|
+
var CONCERNS_COLLECTION = "concerns";
|
|
4802
|
+
|
|
4800
4803
|
// src/types/system/planConfig.types.ts
|
|
4801
4804
|
var PLAN_CONFIG_PATH = "system/planConfig";
|
|
4802
4805
|
var PLAN_CONFIG_HISTORY_PATH = "system/planConfig/history";
|
|
@@ -5712,6 +5715,8 @@ var clinicAdminSchema = import_zod9.z.object({
|
|
|
5712
5715
|
clinicsManagedInfo: import_zod9.z.array(clinicInfoSchema),
|
|
5713
5716
|
contactInfo: contactPersonSchema,
|
|
5714
5717
|
roleTitle: import_zod9.z.string(),
|
|
5718
|
+
role: import_zod9.z.nativeEnum(ClinicRole).optional(),
|
|
5719
|
+
permissions: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.boolean()).optional(),
|
|
5715
5720
|
createdAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
|
|
5716
5721
|
updatedAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
|
|
5717
5722
|
isActive: import_zod9.z.boolean()
|
|
@@ -5722,10 +5727,9 @@ var adminTokenSchema = import_zod9.z.object({
|
|
|
5722
5727
|
email: import_zod9.z.string().email().optional().nullable(),
|
|
5723
5728
|
status: import_zod9.z.nativeEnum(AdminTokenStatus),
|
|
5724
5729
|
usedByUserRef: import_zod9.z.string().optional(),
|
|
5730
|
+
clinicGroupId: import_zod9.z.string(),
|
|
5725
5731
|
createdAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
|
|
5726
|
-
// Timestamp
|
|
5727
5732
|
expiresAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp))
|
|
5728
|
-
// Timestamp
|
|
5729
5733
|
});
|
|
5730
5734
|
var stripeTransactionDataSchema = import_zod9.z.object({
|
|
5731
5735
|
sessionId: import_zod9.z.string().optional(),
|
|
@@ -5786,7 +5790,7 @@ var clinicGroupSchema = import_zod9.z.object({
|
|
|
5786
5790
|
clinicsInfo: import_zod9.z.array(clinicInfoSchema),
|
|
5787
5791
|
admins: import_zod9.z.array(import_zod9.z.string()),
|
|
5788
5792
|
adminsInfo: import_zod9.z.array(adminInfoSchema),
|
|
5789
|
-
adminTokens: import_zod9.z.array(adminTokenSchema),
|
|
5793
|
+
adminTokens: import_zod9.z.array(adminTokenSchema).optional(),
|
|
5790
5794
|
ownerId: import_zod9.z.string().nullable(),
|
|
5791
5795
|
createdAt: import_zod9.z.instanceof(Date).or(import_zod9.z.instanceof(import_firestore9.Timestamp)),
|
|
5792
5796
|
// Timestamp
|
|
@@ -5848,6 +5852,8 @@ var createClinicAdminSchema = import_zod9.z.object({
|
|
|
5848
5852
|
clinicsManaged: import_zod9.z.array(import_zod9.z.string()),
|
|
5849
5853
|
contactInfo: contactPersonSchema,
|
|
5850
5854
|
roleTitle: import_zod9.z.string(),
|
|
5855
|
+
role: import_zod9.z.nativeEnum(ClinicRole).optional(),
|
|
5856
|
+
permissions: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.boolean()).optional(),
|
|
5851
5857
|
isActive: import_zod9.z.boolean()
|
|
5852
5858
|
// clinicsManagedInfo is aggregated, not provided on creation
|
|
5853
5859
|
});
|
|
@@ -12862,32 +12868,6 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12862
12868
|
"settings.manage": true,
|
|
12863
12869
|
"billing.manage": false
|
|
12864
12870
|
},
|
|
12865
|
-
["doctor" /* DOCTOR */]: {
|
|
12866
|
-
"clinic.view": true,
|
|
12867
|
-
"clinic.edit": false,
|
|
12868
|
-
"reviews.view": true,
|
|
12869
|
-
"calendar.view": true,
|
|
12870
|
-
"appointments.view": true,
|
|
12871
|
-
"appointments.confirm": true,
|
|
12872
|
-
"appointments.cancel": true,
|
|
12873
|
-
"messaging": true,
|
|
12874
|
-
"procedures.view": true,
|
|
12875
|
-
"procedures.create": false,
|
|
12876
|
-
"procedures.edit": false,
|
|
12877
|
-
"procedures.delete": false,
|
|
12878
|
-
"resources.view": true,
|
|
12879
|
-
"resources.create": false,
|
|
12880
|
-
"resources.edit": false,
|
|
12881
|
-
"resources.delete": false,
|
|
12882
|
-
"patients.view": true,
|
|
12883
|
-
"patients.edit": true,
|
|
12884
|
-
"providers.view": true,
|
|
12885
|
-
"providers.manage": false,
|
|
12886
|
-
"analytics.view": true,
|
|
12887
|
-
"staff.manage": false,
|
|
12888
|
-
"settings.manage": false,
|
|
12889
|
-
"billing.manage": false
|
|
12890
|
-
},
|
|
12891
12871
|
["receptionist" /* RECEPTIONIST */]: {
|
|
12892
12872
|
"clinic.view": true,
|
|
12893
12873
|
"clinic.edit": false,
|
|
@@ -15749,6 +15729,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
15749
15729
|
admins: [ownerId],
|
|
15750
15730
|
adminsInfo: [],
|
|
15751
15731
|
adminTokens: [],
|
|
15732
|
+
// @deprecated — tokens now in subcollection, kept for backward compat
|
|
15752
15733
|
ownerId,
|
|
15753
15734
|
createdAt: now,
|
|
15754
15735
|
updatedAt: now,
|
|
@@ -15933,6 +15914,10 @@ async function deactivateClinicGroup(db, groupId, app) {
|
|
|
15933
15914
|
app
|
|
15934
15915
|
);
|
|
15935
15916
|
}
|
|
15917
|
+
var ADMIN_TOKENS_SUBCOLLECTION = "adminTokens";
|
|
15918
|
+
function adminTokensRef(db, groupId) {
|
|
15919
|
+
return (0, import_firestore41.collection)(db, CLINIC_GROUPS_COLLECTION, groupId, ADMIN_TOKENS_SUBCOLLECTION);
|
|
15920
|
+
}
|
|
15936
15921
|
async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
15937
15922
|
const group = await getClinicGroup(db, groupId);
|
|
15938
15923
|
if (!group) {
|
|
@@ -15948,68 +15933,60 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
|
15948
15933
|
now.seconds + expiresInDays * 24 * 60 * 60,
|
|
15949
15934
|
now.nanoseconds
|
|
15950
15935
|
);
|
|
15936
|
+
const tokenRef = (0, import_firestore41.doc)(adminTokensRef(db, groupId));
|
|
15951
15937
|
const token = {
|
|
15952
|
-
id:
|
|
15938
|
+
id: tokenRef.id,
|
|
15953
15939
|
token: generateId(),
|
|
15954
15940
|
status: "active" /* ACTIVE */,
|
|
15955
15941
|
email,
|
|
15942
|
+
clinicGroupId: groupId,
|
|
15956
15943
|
createdAt: now,
|
|
15957
15944
|
expiresAt
|
|
15958
15945
|
};
|
|
15959
|
-
await
|
|
15960
|
-
db,
|
|
15961
|
-
groupId,
|
|
15962
|
-
{
|
|
15963
|
-
adminTokens: [...group.adminTokens, token]
|
|
15964
|
-
},
|
|
15965
|
-
app
|
|
15966
|
-
);
|
|
15946
|
+
await (0, import_firestore41.setDoc)(tokenRef, token);
|
|
15967
15947
|
return token;
|
|
15968
15948
|
}
|
|
15969
|
-
async function verifyAndUseAdminToken(db, groupId,
|
|
15970
|
-
const
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15949
|
+
async function verifyAndUseAdminToken(db, groupId, tokenValue, userRef, app) {
|
|
15950
|
+
const tokensQuery = (0, import_firestore41.query)(
|
|
15951
|
+
adminTokensRef(db, groupId),
|
|
15952
|
+
(0, import_firestore41.where)("token", "==", tokenValue),
|
|
15953
|
+
(0, import_firestore41.limit)(1)
|
|
15954
|
+
);
|
|
15955
|
+
const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
|
|
15956
|
+
if (snapshot.empty) {
|
|
15976
15957
|
throw new Error("Admin token not found");
|
|
15977
15958
|
}
|
|
15959
|
+
const tokenDoc = snapshot.docs[0];
|
|
15960
|
+
const adminToken = tokenDoc.data();
|
|
15978
15961
|
if (adminToken.status !== "active" /* ACTIVE */) {
|
|
15979
15962
|
throw new Error("Admin token is not active");
|
|
15980
15963
|
}
|
|
15981
15964
|
const now = import_firestore41.Timestamp.now();
|
|
15982
15965
|
if (adminToken.expiresAt.seconds < now.seconds) {
|
|
15983
|
-
|
|
15984
|
-
(t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
|
|
15985
|
-
);
|
|
15986
|
-
await updateClinicGroup(
|
|
15987
|
-
db,
|
|
15988
|
-
groupId,
|
|
15989
|
-
{
|
|
15990
|
-
adminTokens: updatedTokens2
|
|
15991
|
-
},
|
|
15992
|
-
app
|
|
15993
|
-
);
|
|
15966
|
+
await (0, import_firestore41.updateDoc)(tokenDoc.ref, { status: "expired" /* EXPIRED */ });
|
|
15994
15967
|
throw new Error("Admin token has expired");
|
|
15995
15968
|
}
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15999
|
-
|
|
16000
|
-
usedByUserRef: userRef
|
|
16001
|
-
} : t
|
|
16002
|
-
);
|
|
16003
|
-
await updateClinicGroup(
|
|
16004
|
-
db,
|
|
16005
|
-
groupId,
|
|
16006
|
-
{
|
|
16007
|
-
adminTokens: updatedTokens
|
|
16008
|
-
},
|
|
16009
|
-
app
|
|
16010
|
-
);
|
|
15969
|
+
await (0, import_firestore41.updateDoc)(tokenDoc.ref, {
|
|
15970
|
+
status: "used" /* USED */,
|
|
15971
|
+
usedByUserRef: userRef
|
|
15972
|
+
});
|
|
16011
15973
|
return true;
|
|
16012
15974
|
}
|
|
15975
|
+
async function findAdminTokenByValue(db, tokenValue) {
|
|
15976
|
+
const tokensQuery = (0, import_firestore41.query)(
|
|
15977
|
+
(0, import_firestore41.collectionGroup)(db, ADMIN_TOKENS_SUBCOLLECTION),
|
|
15978
|
+
(0, import_firestore41.where)("token", "==", tokenValue),
|
|
15979
|
+
(0, import_firestore41.where)("status", "==", "active" /* ACTIVE */),
|
|
15980
|
+
(0, import_firestore41.limit)(1)
|
|
15981
|
+
);
|
|
15982
|
+
const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
|
|
15983
|
+
if (snapshot.empty) return null;
|
|
15984
|
+
const tokenData = snapshot.docs[0].data();
|
|
15985
|
+
return {
|
|
15986
|
+
token: tokenData,
|
|
15987
|
+
clinicGroupId: tokenData.clinicGroupId
|
|
15988
|
+
};
|
|
15989
|
+
}
|
|
16013
15990
|
async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
16014
15991
|
const group = await getClinicGroup(db, groupId);
|
|
16015
15992
|
if (!group) {
|
|
@@ -16018,15 +15995,7 @@ async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
|
16018
15995
|
if (!group.admins.includes(adminId)) {
|
|
16019
15996
|
throw new Error("Admin does not belong to this clinic group");
|
|
16020
15997
|
}
|
|
16021
|
-
|
|
16022
|
-
await updateClinicGroup(
|
|
16023
|
-
db,
|
|
16024
|
-
groupId,
|
|
16025
|
-
{
|
|
16026
|
-
adminTokens: updatedTokens
|
|
16027
|
-
},
|
|
16028
|
-
app
|
|
16029
|
-
);
|
|
15998
|
+
await (0, import_firestore41.deleteDoc)((0, import_firestore41.doc)(adminTokensRef(db, groupId), tokenId));
|
|
16030
15999
|
}
|
|
16031
16000
|
async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
16032
16001
|
const group = await getClinicGroup(db, groupId);
|
|
@@ -16036,7 +16005,23 @@ async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
|
16036
16005
|
if (!group.admins.includes(adminId)) {
|
|
16037
16006
|
throw new Error("Admin does not belong to this clinic group");
|
|
16038
16007
|
}
|
|
16039
|
-
|
|
16008
|
+
const tokensQuery = (0, import_firestore41.query)(
|
|
16009
|
+
adminTokensRef(db, groupId),
|
|
16010
|
+
(0, import_firestore41.where)("status", "==", "active" /* ACTIVE */)
|
|
16011
|
+
);
|
|
16012
|
+
const snapshot = await (0, import_firestore41.getDocs)(tokensQuery);
|
|
16013
|
+
return snapshot.docs.map((d) => d.data());
|
|
16014
|
+
}
|
|
16015
|
+
async function getAllAdminTokens(db, groupId, adminId, app) {
|
|
16016
|
+
const group = await getClinicGroup(db, groupId);
|
|
16017
|
+
if (!group) {
|
|
16018
|
+
throw new Error("Clinic group not found");
|
|
16019
|
+
}
|
|
16020
|
+
if (!group.admins.includes(adminId)) {
|
|
16021
|
+
throw new Error("Admin does not belong to this clinic group");
|
|
16022
|
+
}
|
|
16023
|
+
const snapshot = await (0, import_firestore41.getDocs)(adminTokensRef(db, groupId));
|
|
16024
|
+
return snapshot.docs.map((d) => d.data());
|
|
16040
16025
|
}
|
|
16041
16026
|
|
|
16042
16027
|
// src/services/clinic/clinic-group.service.ts
|
|
@@ -16166,11 +16151,19 @@ var ClinicGroupService = class extends BaseService {
|
|
|
16166
16151
|
async getActiveAdminTokens(groupId, adminId) {
|
|
16167
16152
|
return getActiveAdminTokens(this.db, groupId, adminId, this.app);
|
|
16168
16153
|
}
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16154
|
+
/**
|
|
16155
|
+
* Gets ALL admin tokens for a clinic group (all statuses)
|
|
16156
|
+
*/
|
|
16157
|
+
async getAllAdminTokens(groupId, adminId) {
|
|
16158
|
+
return getAllAdminTokens(this.db, groupId, adminId, this.app);
|
|
16159
|
+
}
|
|
16160
|
+
/**
|
|
16161
|
+
* Finds an admin token by its value across all clinic groups.
|
|
16162
|
+
* Uses a collection group query for O(1) lookup.
|
|
16163
|
+
*/
|
|
16164
|
+
async findAdminTokenByValue(tokenValue) {
|
|
16165
|
+
return findAdminTokenByValue(this.db, tokenValue);
|
|
16166
|
+
}
|
|
16174
16167
|
/**
|
|
16175
16168
|
* Updates the onboarding status for a clinic group
|
|
16176
16169
|
*
|
|
@@ -17824,46 +17817,20 @@ var AuthService = class extends BaseService {
|
|
|
17824
17817
|
console.log("[AUTH] Invite token provided", {
|
|
17825
17818
|
token: data.inviteToken
|
|
17826
17819
|
});
|
|
17827
|
-
console.log("[AUTH] Searching for token
|
|
17828
|
-
const
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
let foundGroup = null;
|
|
17832
|
-
let foundToken = null;
|
|
17833
|
-
console.log("[AUTH] Found", querySnapshot.size, "clinic groups to check");
|
|
17834
|
-
for (const docSnapshot of querySnapshot.docs) {
|
|
17835
|
-
const group = docSnapshot.data();
|
|
17836
|
-
console.log("[AUTH] Checking group", {
|
|
17837
|
-
groupId: group.id,
|
|
17838
|
-
groupName: group.name
|
|
17839
|
-
});
|
|
17840
|
-
const token = group.adminTokens.find((t) => {
|
|
17841
|
-
const isMatch = t.token === data.inviteToken && t.status === "active" /* ACTIVE */ && new Date(t.expiresAt.toDate()) > /* @__PURE__ */ new Date();
|
|
17842
|
-
console.log("[AUTH] Checking token", {
|
|
17843
|
-
tokenId: t.id,
|
|
17844
|
-
tokenMatch: t.token === data.inviteToken,
|
|
17845
|
-
tokenStatus: t.status,
|
|
17846
|
-
tokenActive: t.status === "active" /* ACTIVE */,
|
|
17847
|
-
tokenExpiry: new Date(t.expiresAt.toDate()),
|
|
17848
|
-
tokenExpired: new Date(t.expiresAt.toDate()) <= /* @__PURE__ */ new Date(),
|
|
17849
|
-
isMatch
|
|
17850
|
-
});
|
|
17851
|
-
return isMatch;
|
|
17852
|
-
});
|
|
17853
|
-
if (token) {
|
|
17854
|
-
foundGroup = group;
|
|
17855
|
-
foundToken = token;
|
|
17856
|
-
console.log("[AUTH] Found matching token in group", {
|
|
17857
|
-
groupId: group.id,
|
|
17858
|
-
tokenId: token.id
|
|
17859
|
-
});
|
|
17860
|
-
break;
|
|
17861
|
-
}
|
|
17862
|
-
}
|
|
17863
|
-
if (!foundGroup || !foundToken) {
|
|
17864
|
-
console.error("[AUTH] No valid token found in any clinic group");
|
|
17820
|
+
console.log("[AUTH] Searching for token via collection group query");
|
|
17821
|
+
const tokenResult = await clinicGroupService.findAdminTokenByValue(data.inviteToken);
|
|
17822
|
+
if (!tokenResult) {
|
|
17823
|
+
console.error("[AUTH] No valid active token found");
|
|
17865
17824
|
throw new Error("Invalid or expired invite token");
|
|
17866
17825
|
}
|
|
17826
|
+
console.log("[AUTH] Found matching token", {
|
|
17827
|
+
tokenId: tokenResult.token.id,
|
|
17828
|
+
clinicGroupId: tokenResult.clinicGroupId
|
|
17829
|
+
});
|
|
17830
|
+
const foundGroup = await clinicGroupService.getClinicGroup(tokenResult.clinicGroupId);
|
|
17831
|
+
if (!foundGroup) {
|
|
17832
|
+
throw new Error("Clinic group not found for token");
|
|
17833
|
+
}
|
|
17867
17834
|
clinicGroup = foundGroup;
|
|
17868
17835
|
console.log("[AUTH] Creating clinic admin");
|
|
17869
17836
|
const createClinicAdminData = {
|
|
@@ -24221,17 +24188,17 @@ var ProcedureService = class extends BaseService {
|
|
|
24221
24188
|
const proceduresCollection = (0, import_firestore64.collection)(this.db, PROCEDURES_COLLECTION);
|
|
24222
24189
|
let proceduresQuery = (0, import_firestore64.query)(proceduresCollection);
|
|
24223
24190
|
if (pagination && pagination > 0) {
|
|
24224
|
-
const { limit:
|
|
24191
|
+
const { limit: limit23, startAfter: startAfter20 } = await import("firebase/firestore");
|
|
24225
24192
|
if (lastDoc) {
|
|
24226
24193
|
proceduresQuery = (0, import_firestore64.query)(
|
|
24227
24194
|
proceduresCollection,
|
|
24228
24195
|
(0, import_firestore64.orderBy)("name"),
|
|
24229
24196
|
// Use imported orderBy
|
|
24230
24197
|
startAfter20(lastDoc),
|
|
24231
|
-
|
|
24198
|
+
limit23(pagination)
|
|
24232
24199
|
);
|
|
24233
24200
|
} else {
|
|
24234
|
-
proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"),
|
|
24201
|
+
proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"), limit23(pagination));
|
|
24235
24202
|
}
|
|
24236
24203
|
} else {
|
|
24237
24204
|
proceduresQuery = (0, import_firestore64.query)(proceduresCollection, (0, import_firestore64.orderBy)("name"));
|
|
@@ -28271,9 +28238,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28271
28238
|
*/
|
|
28272
28239
|
async getAllBenefits(options) {
|
|
28273
28240
|
const allBenefits = await this.getAllBenefitsForFilter();
|
|
28274
|
-
const { page, limit:
|
|
28275
|
-
const startIndex = page *
|
|
28276
|
-
const endIndex = startIndex +
|
|
28241
|
+
const { page, limit: limit23 } = options;
|
|
28242
|
+
const startIndex = page * limit23;
|
|
28243
|
+
const endIndex = startIndex + limit23;
|
|
28277
28244
|
const paginatedBenefits = allBenefits.slice(startIndex, endIndex);
|
|
28278
28245
|
return { benefits: paginatedBenefits, total: allBenefits.length };
|
|
28279
28246
|
}
|
|
@@ -28370,9 +28337,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28370
28337
|
*/
|
|
28371
28338
|
async getAllContraindications(options) {
|
|
28372
28339
|
const allContraindications = await this.getAllContraindicationsForFilter();
|
|
28373
|
-
const { page, limit:
|
|
28374
|
-
const startIndex = page *
|
|
28375
|
-
const endIndex = startIndex +
|
|
28340
|
+
const { page, limit: limit23 } = options;
|
|
28341
|
+
const startIndex = page * limit23;
|
|
28342
|
+
const endIndex = startIndex + limit23;
|
|
28376
28343
|
const paginatedContraindications = allContraindications.slice(
|
|
28377
28344
|
startIndex,
|
|
28378
28345
|
endIndex
|
|
@@ -28593,6 +28560,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
28593
28560
|
CLINIC_ADMINS_COLLECTION,
|
|
28594
28561
|
CLINIC_ANALYTICS_SUBCOLLECTION,
|
|
28595
28562
|
CLINIC_GROUPS_COLLECTION,
|
|
28563
|
+
CONCERNS_COLLECTION,
|
|
28596
28564
|
CalendarEventStatus,
|
|
28597
28565
|
CalendarEventType,
|
|
28598
28566
|
CalendarServiceV2,
|