@bizmap/sdk 0.0.137 → 0.0.139
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/main.d.ts +60 -22
- package/dist/main.js +83 -21
- package/package.json +3 -3
package/dist/main.d.ts
CHANGED
|
@@ -1301,6 +1301,17 @@ declare const Reason: z.ZodObject<{
|
|
|
1301
1301
|
lastModified: z.ZodISODateTime;
|
|
1302
1302
|
}, z.core.$strip>;
|
|
1303
1303
|
declare const AlphaNumeric: z.ZodString;
|
|
1304
|
+
declare const Storage: z.ZodObject<{
|
|
1305
|
+
usedBytes: z.ZodNumber;
|
|
1306
|
+
class: z.ZodString;
|
|
1307
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1308
|
+
}, z.core.$strip>;
|
|
1309
|
+
type Storage = z.infer<typeof Storage>;
|
|
1310
|
+
declare const NestedStorage: z.ZodObject<{
|
|
1311
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1312
|
+
usedBytes: z.ZodNumber;
|
|
1313
|
+
}, z.core.$strip>;
|
|
1314
|
+
type NestedStorage = z.infer<typeof NestedStorage>;
|
|
1304
1315
|
|
|
1305
1316
|
declare const PriceMod: z.ZodObject<{
|
|
1306
1317
|
createdAt: z.ZodReadonly<z.ZodISODateTime>;
|
|
@@ -1367,29 +1378,56 @@ declare const UserDetails: z.ZodObject<{
|
|
|
1367
1378
|
}, z.core.$strip>;
|
|
1368
1379
|
type UserDetails = z.infer<typeof UserDetails>;
|
|
1369
1380
|
|
|
1370
|
-
declare const UserStorage:
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
class: z.ZodString;
|
|
1375
|
-
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1376
|
-
}, z.core.$strip>;
|
|
1377
|
-
company: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodObject<{
|
|
1378
|
-
class: z.ZodString;
|
|
1379
|
-
items: z.ZodRecord<z.ZodEnum<{
|
|
1380
|
-
state: "state";
|
|
1381
|
-
identity: "identity";
|
|
1382
|
-
preference: "preference";
|
|
1383
|
-
billing: "billing";
|
|
1384
|
-
staff: "staff";
|
|
1385
|
-
}>, z.ZodObject<{
|
|
1381
|
+
declare const UserStorage: {
|
|
1382
|
+
$schema: z.ZodObject<{
|
|
1383
|
+
_id: z.ZodUUID;
|
|
1384
|
+
_root: z.ZodObject<{
|
|
1386
1385
|
usedBytes: z.ZodNumber;
|
|
1386
|
+
class: z.ZodString;
|
|
1387
1387
|
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1388
|
-
}, z.core.$strip
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1388
|
+
}, z.core.$strip>;
|
|
1389
|
+
profile: z.ZodObject<{
|
|
1390
|
+
usedBytes: z.ZodNumber;
|
|
1391
|
+
class: z.ZodString;
|
|
1392
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1393
|
+
}, z.core.$strip>;
|
|
1394
|
+
company: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodObject<{
|
|
1395
|
+
class: z.ZodString;
|
|
1396
|
+
items: z.ZodObject<{
|
|
1397
|
+
state: z.ZodObject<{
|
|
1398
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1399
|
+
usedBytes: z.ZodNumber;
|
|
1400
|
+
}, z.core.$strip>;
|
|
1401
|
+
identity: z.ZodObject<{
|
|
1402
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1403
|
+
usedBytes: z.ZodNumber;
|
|
1404
|
+
}, z.core.$strip>;
|
|
1405
|
+
preference: z.ZodObject<{
|
|
1406
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1407
|
+
usedBytes: z.ZodNumber;
|
|
1408
|
+
}, z.core.$strip>;
|
|
1409
|
+
billing: z.ZodObject<{
|
|
1410
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1411
|
+
usedBytes: z.ZodNumber;
|
|
1412
|
+
}, z.core.$strip>;
|
|
1413
|
+
staff: z.ZodObject<{
|
|
1414
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1415
|
+
usedBytes: z.ZodNumber;
|
|
1416
|
+
}, z.core.$strip>;
|
|
1417
|
+
assets: z.ZodOptional<z.ZodObject<{
|
|
1418
|
+
logo: z.ZodOptional<z.ZodObject<{
|
|
1419
|
+
lastModified: z.ZodOptional<z.ZodISODateTime>;
|
|
1420
|
+
usedBytes: z.ZodNumber;
|
|
1421
|
+
}, z.core.$strip>>;
|
|
1422
|
+
}, z.core.$strip>>;
|
|
1423
|
+
}, z.core.$strip>;
|
|
1424
|
+
}, z.core.$strip>>>;
|
|
1425
|
+
createdAt: z.ZodISODateTime;
|
|
1426
|
+
}, z.core.$strip>;
|
|
1427
|
+
calcSumOfUsedBytes: (data: any) => number;
|
|
1428
|
+
readonly calcUsedBytesByClass: (storage: UserStorage, className: string) => number;
|
|
1429
|
+
};
|
|
1430
|
+
type UserStorage = z.infer<typeof UserStorage.$schema>;
|
|
1393
1431
|
|
|
1394
1432
|
/** @disclaimer This doesn't handle currency conversion */
|
|
1395
1433
|
declare function calcBalance(components: Prettify<Partial<Pick<ServiceDetails, "charges" | "discounts" | "additionalFees" | "prepayments" | "payments">>>, options?: {
|
|
@@ -1412,4 +1450,4 @@ declare function createNotifId(options?: {
|
|
|
1412
1450
|
to: string;
|
|
1413
1451
|
}): string;
|
|
1414
1452
|
|
|
1415
|
-
export { type AcceptedCurrency, AlphaNumeric, COMPANY_USER_RELATIONSHIP, ClientDetails, ClientForm, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyIndustry, CompanyMemberRoles, CompanyNotifications, CompanyPreference, type CompanyServiceSelector, CompanySession, CompanyStaff, CompanyState, type CompanyUserRole, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, MutableCompanyStaff, MutableServiceDetails, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, ServiceDetails, type ServiceDistAlg, ServiceSeverity, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, UserStorage, Vitals, _CompanyDetails, acceptedCurrencies, adminRoles, calcBalance, calcPriceMod, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, genders, getCompatibleRoles, getIncompatibleRoles, healthcareProviderRoles, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, safeParseSector, serviceDistAlgs, tiers, vitalKeys };
|
|
1453
|
+
export { type AcceptedCurrency, AlphaNumeric, COMPANY_USER_RELATIONSHIP, ClientDetails, ClientForm, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyIndustry, CompanyMemberRoles, CompanyNotifications, CompanyPreference, type CompanyServiceSelector, CompanySession, CompanyStaff, CompanyState, type CompanyUserRole, CreateCompanyForm, CreditCurrency, type EmployeeRole, type Gender, type HealthcareProviderRole, InviteResponse, InvoiceNo, MAX_COMPANY_PRICE_MODS, MedicalDetails, Medicine, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, MutableCompanyStaff, MutableServiceDetails, NestedStorage, Notification, PaymentDetails, type PaymentMethod, PriceMod, PriceModList, PriceTag, Reason, Receipts, ServiceDetails, type ServiceDistAlg, ServiceSeverity, StandardTime, Storage, TicketNo, type Tier, TierList, TimeLog, Timestamp, Trn, UserDetails, UserStorage, Vitals, _CompanyDetails, acceptedCurrencies, adminRoles, calcBalance, calcPriceMod, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, genders, getCompatibleRoles, getIncompatibleRoles, healthcareProviderRoles, normalizeCompanyId, normalizeNidKey, parseClientName, paymentMethods, safeParseSector, serviceDistAlgs, tiers, vitalKeys };
|
package/dist/main.js
CHANGED
|
@@ -108,6 +108,15 @@ var AlphaNumeric = z5.string().trim().superRefine((data, ctx) => {
|
|
|
108
108
|
ctx.addIssue(`${char} is not an alpha-numeric character.`);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
+
var Storage = z5.object({
|
|
112
|
+
usedBytes: z5.number().min(0),
|
|
113
|
+
class: z5.string().trim(),
|
|
114
|
+
lastModified: Timestamp.optional()
|
|
115
|
+
});
|
|
116
|
+
var NestedStorage = Storage.pick({
|
|
117
|
+
usedBytes: true,
|
|
118
|
+
lastModified: true
|
|
119
|
+
});
|
|
111
120
|
|
|
112
121
|
// src/schemas/user/Details.ts
|
|
113
122
|
var UserDetails = z6.object({
|
|
@@ -817,28 +826,79 @@ var MutableServiceDetails = ServiceDetails.safeExtend(
|
|
|
817
826
|
|
|
818
827
|
// src/schemas/user/Storage.ts
|
|
819
828
|
import * as z22 from "zod";
|
|
820
|
-
var
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
829
|
+
var CompanyDocs = Object.fromEntries(
|
|
830
|
+
_CompanyDetails.keyof().options.map((key) => [key, NestedStorage])
|
|
831
|
+
);
|
|
832
|
+
var UserStorage = {
|
|
833
|
+
// Maintain this type of hierarchy for the sake of uniformity to ensure that
|
|
834
|
+
// its dependents work correctly (e.g: calcUsedBytesByClass)
|
|
835
|
+
// Hierarchy =
|
|
836
|
+
// | { <label>: `Storage` }
|
|
837
|
+
// | {
|
|
838
|
+
// <groupName>: {
|
|
839
|
+
// <itemId>: {
|
|
840
|
+
// class: string,
|
|
841
|
+
// /**
|
|
842
|
+
// * The depth doesn't matter, just ensure that at the end of each path
|
|
843
|
+
// * is a `NestedStorage`
|
|
844
|
+
// */
|
|
845
|
+
// items: {
|
|
846
|
+
// <subLabel>: `NestedStorage`,
|
|
847
|
+
// <nested.key>: `NestedStorage`,
|
|
848
|
+
// <x.y.z>: `NestedStorage`,
|
|
849
|
+
// }
|
|
850
|
+
// }
|
|
851
|
+
// }
|
|
852
|
+
// }
|
|
853
|
+
$schema: z22.object({
|
|
854
|
+
_id: UserDetails.shape._id,
|
|
855
|
+
_root: Storage,
|
|
856
|
+
profile: Storage,
|
|
857
|
+
company: z22.record(
|
|
858
|
+
CompanyId,
|
|
859
|
+
z22.object({
|
|
860
|
+
class: z22.string().trim(),
|
|
861
|
+
items: z22.object({
|
|
862
|
+
assets: z22.object({ logo: NestedStorage }).partial().optional(),
|
|
863
|
+
...CompanyDocs
|
|
836
864
|
})
|
|
837
|
-
)
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
865
|
+
})
|
|
866
|
+
).optional(),
|
|
867
|
+
createdAt: Timestamp
|
|
868
|
+
}),
|
|
869
|
+
calcSumOfUsedBytes: (data) => {
|
|
870
|
+
let total = 0;
|
|
871
|
+
JSON.parse(JSON.stringify(data), (key, value) => {
|
|
872
|
+
if (key === "usedBytes") {
|
|
873
|
+
total += parseFloat(value);
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
return total;
|
|
877
|
+
},
|
|
878
|
+
get calcUsedBytesByClass() {
|
|
879
|
+
return (storage, className) => {
|
|
880
|
+
storage = this.$schema.parse(storage);
|
|
881
|
+
if (!className || typeof className !== "string") {
|
|
882
|
+
throw new Error(
|
|
883
|
+
`Expected className, but received ${className} @ UserStorage.${this.calcUsedBytesByClass.name}`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
let total = 0;
|
|
887
|
+
for (const item of Object.values(storage)) {
|
|
888
|
+
if (typeof item !== "object") continue;
|
|
889
|
+
if ("class" in item && item.class === className && typeof item.usedBytes === "number") {
|
|
890
|
+
total += item.usedBytes;
|
|
891
|
+
} else if (!("class" in item) && typeof item === "object") {
|
|
892
|
+
for (const nestedItem of Object.values(item)) {
|
|
893
|
+
if (nestedItem.class !== className) continue;
|
|
894
|
+
total += this.calcSumOfUsedBytes(nestedItem.items);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return total;
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
};
|
|
842
902
|
|
|
843
903
|
// src/functions/calc.ts
|
|
844
904
|
import { sumOf } from "@wavy/fn";
|
|
@@ -910,6 +970,7 @@ export {
|
|
|
910
970
|
MutableCompanyPreferences,
|
|
911
971
|
MutableCompanyStaff,
|
|
912
972
|
MutableServiceDetails,
|
|
973
|
+
NestedStorage,
|
|
913
974
|
Notification,
|
|
914
975
|
PaymentDetails,
|
|
915
976
|
PriceMod,
|
|
@@ -920,6 +981,7 @@ export {
|
|
|
920
981
|
ServiceDetails,
|
|
921
982
|
ServiceSeverity,
|
|
922
983
|
StandardTime,
|
|
984
|
+
Storage,
|
|
923
985
|
TicketNo,
|
|
924
986
|
TierList,
|
|
925
987
|
TimeLog,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bizmap/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.139",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"types": "./dist/main.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@wavy/fn": "^0.0.
|
|
19
|
+
"@wavy/fn": "^0.0.48",
|
|
20
20
|
"@wavy/util": ">=0.0.12",
|
|
21
21
|
"zod": "^4.2.1"
|
|
22
22
|
},
|
|
23
23
|
"description": "",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@wavy/fn": "^0.0.
|
|
25
|
+
"@wavy/fn": "^0.0.48",
|
|
26
26
|
"@wavy/util": "^0.0.20",
|
|
27
27
|
"tsup": "^8.5.0",
|
|
28
28
|
"typescript": "^5.9.2",
|