@fayz-ai/plugin-agenda 0.3.0 → 0.8.0

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.
Files changed (36) hide show
  1. package/README.md +2 -0
  2. package/dist/bridges/create-financial-bridge.d.ts.map +1 -1
  3. package/dist/config.d.ts +2 -2
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/data/supabase.d.ts.map +1 -1
  6. package/dist/index.cjs +77 -65
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.js +77 -65
  9. package/dist/index.js.map +1 -1
  10. package/dist/migrations/index.d.ts +8 -1
  11. package/dist/migrations/index.d.ts.map +1 -1
  12. package/dist/public/createPublicBookingPlugin.d.ts.map +1 -1
  13. package/dist/public/index.cjs +16 -16
  14. package/dist/public/index.cjs.map +1 -1
  15. package/dist/public/index.js +17 -17
  16. package/dist/public/index.js.map +1 -1
  17. package/dist/registries.d.ts.map +1 -1
  18. package/dist/types.d.ts +3 -3
  19. package/dist/types.d.ts.map +1 -1
  20. package/package.json +20 -14
  21. package/src/bridges/create-financial-bridge.ts +6 -8
  22. package/src/components/AppointmentModal.tsx +4 -4
  23. package/src/config.ts +2 -2
  24. package/src/data/supabase.ts +26 -25
  25. package/src/index.ts +1 -1
  26. package/src/integrations/google-calendar/index.ts +1 -1
  27. package/src/integrations/google-calendar/migrations/001_google_calendar.sql +6 -6
  28. package/src/migrations/000b_v_bookings_rename.sql +21 -0
  29. package/src/migrations/000c_dedupe_customer_phones.sql +43 -0
  30. package/src/migrations/001_public_booking.sql +40 -27
  31. package/src/migrations/002_v_bookings_compat.sql +14 -0
  32. package/src/migrations/index.ts +134 -29
  33. package/src/public/createPublicBookingPlugin.ts +23 -20
  34. package/src/public/data.supabase.ts +4 -4
  35. package/src/registries.ts +1 -2
  36. package/src/types.ts +4 -4
@@ -1,7 +1,7 @@
1
1
  import { createMockAgendaProvider } from '../chunk-DRZF6CV2.js';
2
2
  import { createContext, useState, useEffect, useMemo, useContext, useRef, createElement } from 'react';
3
3
  import { ChevronLeft, ShieldCheck, Clock, ChevronRight, User, Check, Calendar, ChevronDown, Loader2, CreditCard, Plus, QrCode, CalendarCheck, Copy, Video } from 'lucide-react';
4
- import { DEFAULT_COUNTRY, getCountry, maskPhone, unmaskPhone, createSafeDataProvider, getSupabaseClientOptional, COUNTRIES } from '@fayz-ai/core';
4
+ import { DEFAULT_COUNTRY, getCountry, maskPhone, unmaskPhone, getSupabaseClientOptional, getFayzCloudClient, COUNTRIES } from '@fayz-ai/core';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
6
6
 
7
7
  // src/public/data.ts
@@ -48,9 +48,7 @@ function createMockPublicBookingProvider(options) {
48
48
  };
49
49
  }
50
50
  function getClient() {
51
- const client = getSupabaseClientOptional();
52
- if (!client) throw new Error("[plugin-agenda/public] Supabase client not initialized");
53
- return client;
51
+ return getSupabaseClientOptional() ?? getFayzCloudClient();
54
52
  }
55
53
  function toPhoneDigits(phone) {
56
54
  return (phone ?? "").replace(/\D/g, "");
@@ -1338,21 +1336,23 @@ function createPublicBookingPlugin(options) {
1338
1336
  schedules: buildSchedules(mockProfessionalId, hours),
1339
1337
  bookings: []
1340
1338
  };
1341
- const provider = options.dataProvider ?? createSafeDataProvider(
1342
- () => {
1343
- if (!options.tenantId) {
1344
- throw new Error(
1345
- "[plugin-agenda/public] `tenantId` is required when a Supabase client is configured (setGlobalSupabaseClient)."
1346
- );
1347
- }
1348
- return createSupabasePublicBookingProvider({ tenantId: options.tenantId });
1349
- },
1350
- () => createMockPublicBookingProvider({
1339
+ let provider;
1340
+ if (options.dataProvider) {
1341
+ provider = options.dataProvider;
1342
+ } else if (options.tenantId) {
1343
+ provider = createSupabasePublicBookingProvider({ tenantId: options.tenantId });
1344
+ } else {
1345
+ if (typeof console !== "undefined") {
1346
+ console.warn(
1347
+ "[plugin-agenda/public] no `tenantId` and no `dataProvider` \u2014 falling back to the seeded MOCK provider. Pass `tenantId` to book against Fayz Cloud, or inject a dataProvider."
1348
+ );
1349
+ }
1350
+ provider = createMockPublicBookingProvider({
1351
1351
  seed: mockSeed,
1352
1352
  services: staticServices ?? [],
1353
1353
  professionalId: mockProfessionalId
1354
- })
1355
- );
1354
+ });
1355
+ }
1356
1356
  const base = {
1357
1357
  provider,
1358
1358
  professionalId,
@@ -1384,7 +1384,7 @@ function createPublicBookingPlugin(options) {
1384
1384
  id: "booking",
1385
1385
  name: "Agendamento",
1386
1386
  icon: "CalendarCheck",
1387
- version: "0.3.0",
1387
+ version: "0.4.0",
1388
1388
  scope: options.scope ?? "universal",
1389
1389
  verticalId: options.verticalId,
1390
1390
  scaffolds: ["website", "landing_page"],