@blazeo.com/calendar-client 1.0.30 → 1.0.32

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/README.md CHANGED
@@ -72,7 +72,7 @@ await LeadModel.requestExport('company-key');
72
72
  - **CalendarModel (static):** `get`, `getByCompany`, `getTimeZones`, `getTimeZone`, `getParticipants`, `getMonth`, `getEvents`, etc.
73
73
  - **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
74
74
  - **FlowModel:** Same pattern as Calendar — `FlowModel.create({}, { env })` with no fields; static `get`, `getRaw`, `list`, `createFlow`, `updateFlow`, `delete`, `duplicate`, appearance/embed/public/preview helpers; instance methods mirror those using `flowId` on the snapshot
75
- - **LeadModel:** `LeadModel.create({}, { env })`; static `get`, `getRaw`, `getByEmail`, `getByCompany`; instance `get`, `getByEmail`, `getByCompany` (uses `leadId` / `email` / `companyKey` on the snapshot)
75
+ - **LeadModel:** `LeadModel.create({}, { env })`; static `get`, `getRaw`, `getByEmail`, `getByPhone`, `getByCompany`, `saveColumnSelection`, `getColumnSelection`, `allowedColumns`; instance `get`, `getByEmail`, `getByPhone`, `getByCompany`, `saveColumnSelection`, `getColumnSelection`. Pass `userId` in `getByCompany(companyKey, { userId })` to return only columns saved for that user.
76
76
  - **ParticipantModel:** static `get`, `getByEmail`, `getByIds`, `getAll`, …; instance `getByEmail` uses `email` + `companyKey` on the snapshot (see `GET /participant/getbyemail`)
77
77
  - **AuthModel (calendar OAuth / Connect Calendar):** `getCalendarProviders`, `getAuthorizationUrl`, `getAuthorizationStatus`, `openOAuthPopup`, `onCalendarAuthMessage` — see [Calendar authorization flow](#calendar-authorization-direct-ui)
78
78
  - **RootStore:** `addCalendar`, `addEvent`
package/dist/index.d.ts CHANGED
@@ -231,6 +231,16 @@ export const LeadModel: {
231
231
  get(leadId: string): Promise<unknown>;
232
232
  getByEmail(email: string, companyKey: string): Promise<unknown>;
233
233
  getByPhone(phone: string, companyKey: string): Promise<unknown>;
234
+ allowedColumns: string[];
235
+ saveColumnSelection(
236
+ userId: string,
237
+ columns: string[]
238
+ ): Promise<{ status: string; data?: unknown; message?: string }>;
239
+ getColumnSelection(userId: string): Promise<{
240
+ status: string;
241
+ data?: { userId?: string; columns?: string[]; isDefault?: boolean };
242
+ message?: string;
243
+ }>;
234
244
  createLead(payload: {
235
245
  email: string;
236
246
  companyKey: string;
@@ -263,6 +273,8 @@ export const LeadModel: {
263
273
  getByCompany(
264
274
  companyKey: string,
265
275
  opts?: {
276
+ userId?: string;
277
+ user_id?: string;
266
278
  skip?: number;
267
279
  take?: number;
268
280
  /** Maps to API query `sort`. */
package/dist/index.js CHANGED
@@ -1962,6 +1962,12 @@ var CalendarLocationModel = import_mobx_state_tree16.types.model("CalendarLocati
1962
1962
  if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
1963
1963
  return reqGet("/Calendar/Location/Get", { calendar_id: resolvedCalendarId });
1964
1964
  },
1965
+ /** GET Calendar/Location/GetById – fetch a single location by calendar_location_id */
1966
+ async getById(calendarLocationId) {
1967
+ const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
1968
+ if (!resolvedCalendarLocationId) return { status: "failure", message: "calendarLocationId required" };
1969
+ return reqGet("/Calendar/Location/GetById", { calendar_location_id: resolvedCalendarLocationId });
1970
+ },
1965
1971
  /** POST Calendar/Location/Save – create or update location */
1966
1972
  async save() {
1967
1973
  const res = await reqPost("/Calendar/Location/Save", toPayload4(self));
@@ -1998,6 +2004,14 @@ CalendarLocationModel.getByCalendar = async (calendarId) => {
1998
2004
  }
1999
2005
  return null;
2000
2006
  };
2007
+ CalendarLocationModel.getById = async (calendarLocationId) => {
2008
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2009
+ const res = await reqGet("/Calendar/Location/GetById", { calendar_location_id: calendarLocationId });
2010
+ if (res.status === "success" && res.data) {
2011
+ return CalendarLocationModel.create(mapCalendarLocationFromApi(res.data), { env: getConfig() });
2012
+ }
2013
+ return null;
2014
+ };
2001
2015
  CalendarLocationModel.save = async (payload) => {
2002
2016
  const { reqPost } = createRequestHelpersFromEnv(getConfig());
2003
2017
  const res = await reqPost("/Calendar/Location/Save", payload);
@@ -2026,9 +2040,11 @@ var PreferenceScope = {
2026
2040
  Consumer: 1,
2027
2041
  Company: 2,
2028
2042
  Calendar: 3,
2029
- Event: 4
2043
+ Event: 4,
2044
+ Participant: 5,
2045
+ User: 6
2030
2046
  };
2031
- var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
2047
+ var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event", "Participant", "User"];
2032
2048
  var PreferenceModel = import_mobx_state_tree17.types.model("Preference", {
2033
2049
  id: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number), null),
2034
2050
  preferenceId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
@@ -2426,6 +2442,14 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
2426
2442
  if (!self.companyKey) return null;
2427
2443
  return LeadModel.getByCompany(self.companyKey, opts);
2428
2444
  },
2445
+ /** POST /lead/columns/save – saves user column selection to Preference (scope User). */
2446
+ async saveColumnSelection(userId, columns) {
2447
+ return LeadModel.saveColumnSelection(userId, columns);
2448
+ },
2449
+ /** GET /lead/columns/get – reads saved column selection for a user. */
2450
+ async getColumnSelection(userId) {
2451
+ return LeadModel.getColumnSelection(userId);
2452
+ },
2429
2453
  /** POST /lead/create – create this lead */
2430
2454
  async createLead() {
2431
2455
  const payload = {
@@ -2514,10 +2538,41 @@ LeadModel.getByPhone = async (phone, companyKey) => {
2514
2538
  }
2515
2539
  return null;
2516
2540
  };
2541
+ LeadModel.allowedColumns = [
2542
+ "id",
2543
+ "lead_id",
2544
+ "email",
2545
+ "name",
2546
+ "phone",
2547
+ "company_key",
2548
+ "source",
2549
+ "lead_type",
2550
+ "referrer_link",
2551
+ "created_on",
2552
+ "modified_on"
2553
+ ];
2554
+ LeadModel.saveColumnSelection = async (userId, columns) => {
2555
+ const uid = userId != null ? String(userId).trim() : "";
2556
+ if (!uid) return { status: "failure", message: "userId required" };
2557
+ const cols = Array.isArray(columns) ? columns.map((c) => String(c).trim()).filter(Boolean) : [];
2558
+ if (!cols.length) return { status: "failure", message: "columns required" };
2559
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
2560
+ return reqPost("/lead/columns/save", { user_id: uid, columns: cols });
2561
+ };
2562
+ LeadModel.getColumnSelection = async (userId) => {
2563
+ const uid = userId != null ? String(userId).trim() : "";
2564
+ if (!uid) return { status: "failure", message: "userId required" };
2565
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2566
+ return reqGet("/lead/columns/get", { user_id: uid });
2567
+ };
2517
2568
  LeadModel.getByCompany = async (companyKey, opts = {}) => {
2518
2569
  var _a, _b;
2519
2570
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
2520
2571
  const query = { company_key: companyKey };
2572
+ const userId = opts.userId ?? opts.user_id;
2573
+ if (userId != null && String(userId).trim() !== "") {
2574
+ query.user_id = String(userId).trim();
2575
+ }
2521
2576
  const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
2522
2577
  if (sortBy != null && sortBy !== "") query.sort = sortBy;
2523
2578
  const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
package/dist/index.mjs CHANGED
@@ -1891,6 +1891,12 @@ var CalendarLocationModel = types16.model("CalendarLocation", {
1891
1891
  if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
1892
1892
  return reqGet("/Calendar/Location/Get", { calendar_id: resolvedCalendarId });
1893
1893
  },
1894
+ /** GET Calendar/Location/GetById – fetch a single location by calendar_location_id */
1895
+ async getById(calendarLocationId) {
1896
+ const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
1897
+ if (!resolvedCalendarLocationId) return { status: "failure", message: "calendarLocationId required" };
1898
+ return reqGet("/Calendar/Location/GetById", { calendar_location_id: resolvedCalendarLocationId });
1899
+ },
1894
1900
  /** POST Calendar/Location/Save – create or update location */
1895
1901
  async save() {
1896
1902
  const res = await reqPost("/Calendar/Location/Save", toPayload4(self));
@@ -1927,6 +1933,14 @@ CalendarLocationModel.getByCalendar = async (calendarId) => {
1927
1933
  }
1928
1934
  return null;
1929
1935
  };
1936
+ CalendarLocationModel.getById = async (calendarLocationId) => {
1937
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1938
+ const res = await reqGet("/Calendar/Location/GetById", { calendar_location_id: calendarLocationId });
1939
+ if (res.status === "success" && res.data) {
1940
+ return CalendarLocationModel.create(mapCalendarLocationFromApi(res.data), { env: getConfig() });
1941
+ }
1942
+ return null;
1943
+ };
1930
1944
  CalendarLocationModel.save = async (payload) => {
1931
1945
  const { reqPost } = createRequestHelpersFromEnv(getConfig());
1932
1946
  const res = await reqPost("/Calendar/Location/Save", payload);
@@ -1955,9 +1969,11 @@ var PreferenceScope = {
1955
1969
  Consumer: 1,
1956
1970
  Company: 2,
1957
1971
  Calendar: 3,
1958
- Event: 4
1972
+ Event: 4,
1973
+ Participant: 5,
1974
+ User: 6
1959
1975
  };
1960
- var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
1976
+ var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event", "Participant", "User"];
1961
1977
  var PreferenceModel = types17.model("Preference", {
1962
1978
  id: types17.optional(types17.maybeNull(types17.number), null),
1963
1979
  preferenceId: types17.optional(types17.maybeNull(types17.string), null),
@@ -2355,6 +2371,14 @@ var LeadModel = types19.model("Lead", {
2355
2371
  if (!self.companyKey) return null;
2356
2372
  return LeadModel.getByCompany(self.companyKey, opts);
2357
2373
  },
2374
+ /** POST /lead/columns/save – saves user column selection to Preference (scope User). */
2375
+ async saveColumnSelection(userId, columns) {
2376
+ return LeadModel.saveColumnSelection(userId, columns);
2377
+ },
2378
+ /** GET /lead/columns/get – reads saved column selection for a user. */
2379
+ async getColumnSelection(userId) {
2380
+ return LeadModel.getColumnSelection(userId);
2381
+ },
2358
2382
  /** POST /lead/create – create this lead */
2359
2383
  async createLead() {
2360
2384
  const payload = {
@@ -2443,10 +2467,41 @@ LeadModel.getByPhone = async (phone, companyKey) => {
2443
2467
  }
2444
2468
  return null;
2445
2469
  };
2470
+ LeadModel.allowedColumns = [
2471
+ "id",
2472
+ "lead_id",
2473
+ "email",
2474
+ "name",
2475
+ "phone",
2476
+ "company_key",
2477
+ "source",
2478
+ "lead_type",
2479
+ "referrer_link",
2480
+ "created_on",
2481
+ "modified_on"
2482
+ ];
2483
+ LeadModel.saveColumnSelection = async (userId, columns) => {
2484
+ const uid = userId != null ? String(userId).trim() : "";
2485
+ if (!uid) return { status: "failure", message: "userId required" };
2486
+ const cols = Array.isArray(columns) ? columns.map((c) => String(c).trim()).filter(Boolean) : [];
2487
+ if (!cols.length) return { status: "failure", message: "columns required" };
2488
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
2489
+ return reqPost("/lead/columns/save", { user_id: uid, columns: cols });
2490
+ };
2491
+ LeadModel.getColumnSelection = async (userId) => {
2492
+ const uid = userId != null ? String(userId).trim() : "";
2493
+ if (!uid) return { status: "failure", message: "userId required" };
2494
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2495
+ return reqGet("/lead/columns/get", { user_id: uid });
2496
+ };
2446
2497
  LeadModel.getByCompany = async (companyKey, opts = {}) => {
2447
2498
  var _a, _b;
2448
2499
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
2449
2500
  const query = { company_key: companyKey };
2501
+ const userId = opts.userId ?? opts.user_id;
2502
+ if (userId != null && String(userId).trim() !== "") {
2503
+ query.user_id = String(userId).trim();
2504
+ }
2450
2505
  const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
2451
2506
  if (sortBy != null && sortBy !== "") query.sort = sortBy;
2452
2507
  const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {