@bizmap/sdk 0.0.66 → 0.0.67

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 CHANGED
@@ -98,7 +98,7 @@ declare const CompanyDetails: z.ZodObject<{
98
98
  }, z.core.$strip>;
99
99
  }, z.core.$strip>;
100
100
  notifications: z.ZodArray<z.ZodObject<{
101
- _id: z.ZodUUID;
101
+ _id: z.ZodString;
102
102
  code: z.ZodLiteral<"INVITE_RESPONSE" | "COMPANY_INVITE" | "DEV_MESSAGE" | "ALERT">;
103
103
  payload: z.ZodString;
104
104
  isArchived: z.ZodOptional<z.ZodBoolean>;
@@ -596,7 +596,7 @@ declare const MutableCompanyIdentity: z.ZodObject<{
596
596
  type MutableCompanyIdentity = z.infer<typeof MutableCompanyIdentity>;
597
597
 
598
598
  declare const CompanyNotifications: z.ZodArray<z.ZodObject<{
599
- _id: z.ZodUUID;
599
+ _id: z.ZodString;
600
600
  code: z.ZodLiteral<"INVITE_RESPONSE" | "COMPANY_INVITE" | "DEV_MESSAGE" | "ALERT">;
601
601
  payload: z.ZodString;
602
602
  isArchived: z.ZodOptional<z.ZodBoolean>;
@@ -851,7 +851,7 @@ declare const TierList: z.ZodRecord<z.ZodEnum<{
851
851
  }, z.core.$strip>>;
852
852
  type TierList = z.infer<typeof TierList>;
853
853
  declare const Notification: z.ZodObject<{
854
- _id: z.ZodUUID;
854
+ _id: z.ZodString;
855
855
  code: z.ZodLiteral<"INVITE_RESPONSE" | "COMPANY_INVITE" | "DEV_MESSAGE" | "ALERT">;
856
856
  payload: z.ZodString;
857
857
  isArchived: z.ZodOptional<z.ZodBoolean>;
@@ -943,9 +943,10 @@ declare const UserDetails: z.ZodObject<{
943
943
  email: z.ZodEmail;
944
944
  phoneNumber: z.ZodOptional<z.ZodString>;
945
945
  name: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
946
+ photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
946
947
  publicKey: z.ZodNullable<z.ZodString>;
947
948
  notifications: z.ZodArray<z.ZodObject<{
948
- _id: z.ZodUUID;
949
+ _id: z.ZodString;
949
950
  code: z.ZodLiteral<"INVITE_RESPONSE" | "COMPANY_INVITE" | "DEV_MESSAGE" | "ALERT">;
950
951
  payload: z.ZodString;
951
952
  isArchived: z.ZodOptional<z.ZodBoolean>;
@@ -957,7 +958,6 @@ declare const UserDetails: z.ZodObject<{
957
958
  }, z.core.$strip>;
958
959
  createdAt: z.ZodInt;
959
960
  }, z.core.$strip>>;
960
- photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
961
961
  linked: z.ZodBoolean;
962
962
  }, z.core.$strip>;
963
963
  type UserDetails = z.infer<typeof UserDetails>;
@@ -1769,4 +1769,9 @@ declare const findConflictingPartners: (...partners: (CompanyUser | MiniCompanyU
1769
1769
  * */
1770
1770
  declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
1771
1771
 
1772
- export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CreditCurrency, type EmployeeRole, type HealthcareProviderRole, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, UserDetails, Vitals, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyUserRoles, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
1772
+ declare function createNotifId(options?: {
1773
+ from: string;
1774
+ to: string;
1775
+ }): string;
1776
+
1777
+ export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CreditCurrency, type EmployeeRole, type HealthcareProviderRole, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MiniCompanyUser, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, UserDetails, Vitals, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyUserRoles, createNotifId, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
package/dist/main.js CHANGED
@@ -212,8 +212,13 @@ var MutableCompanyIdentity = CompanyIdentity.pick({
212
212
  import * as z11 from "zod";
213
213
 
214
214
  // src/schemas/Global.ts
215
- import * as z10 from "zod";
216
215
  import { currencies as currencies2 } from "@wavy/util";
216
+ import * as z10 from "zod";
217
+
218
+ // src/constants.ts
219
+ var NOTIF_ID_DELIM = "::";
220
+
221
+ // src/schemas/Global.ts
217
222
  var TierList = z10.record(
218
223
  tiers,
219
224
  z10.object({
@@ -226,7 +231,35 @@ var TierList = z10.record(
226
231
  }
227
232
  });
228
233
  var Notification = z10.object({
229
- _id: z10.uuidv4(),
234
+ _id: z10.string().superRefine((data, ctx) => {
235
+ const isUUidV4 = z10.uuidv4().safeParse(data).success;
236
+ if (isUUidV4) return;
237
+ let [from, to, nonce] = data.split(NOTIF_ID_DELIM);
238
+ nonce = nonce?.trim() || "";
239
+ const parsedFrom = z10.uuidv4().or(z10.uuidv7()).safeParse(from);
240
+ if (!parsedFrom.success) {
241
+ ctx.addIssue({
242
+ code: "custom",
243
+ message: "Invalid UUID",
244
+ path: ["from"]
245
+ });
246
+ }
247
+ const parsedTo = z10.uuidv4().safeParse(to);
248
+ if (!parsedTo.success) {
249
+ ctx.addIssue({
250
+ code: "custom",
251
+ message: "Invalid UUID",
252
+ path: ["to"]
253
+ });
254
+ }
255
+ if (nonce.length < 4 || nonce.length > 7) {
256
+ ctx.addIssue({
257
+ code: "custom",
258
+ message: "Invalid length",
259
+ path: ["nonce"]
260
+ });
261
+ }
262
+ }),
230
263
  code: z10.literal([
231
264
  "INVITE_RESPONSE",
232
265
  "COMPANY_INVITE",
@@ -855,6 +888,23 @@ async function scheduleAppointment(request) {
855
888
  appointment: MutableAppointmentDetails.parse(appointment)
856
889
  };
857
890
  }
891
+
892
+ // src/functions/createNotifId.ts
893
+ import { random } from "@wavy/fn";
894
+ import { v4 as v42 } from "uuid";
895
+ function createNotifId(options) {
896
+ let nid = v42();
897
+ if (options) {
898
+ nid = Notification.shape._id.parse(
899
+ [
900
+ options.from,
901
+ options.to,
902
+ nid.replace(/[^a-z0-9]/i, "").slice(0, random(7, 4))
903
+ ].join(NOTIF_ID_DELIM)
904
+ );
905
+ }
906
+ return nid;
907
+ }
858
908
  export {
859
909
  AppointmentDetails,
860
910
  ClientIdentity,
@@ -896,6 +946,7 @@ export {
896
946
  companyPartnerRoles,
897
947
  companyServiceSelectors,
898
948
  companyUserRoles,
949
+ createNotifId,
899
950
  employeeRoles,
900
951
  findAvailableStaff,
901
952
  findConflictingPartners,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bizmap/sdk",
3
- "version": "0.0.66",
3
+ "version": "0.0.67",
4
4
  "main": "./dist/main.js",
5
5
  "types": "./dist/main.d.ts",
6
6
  "type": "module",