@seamapi/react 4.8.1 → 4.9.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 (84) hide show
  1. package/README.md +17 -2
  2. package/dist/elements.js +22003 -18123
  3. package/dist/elements.js.map +1 -1
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/seam/SeamProvider.d.ts +7 -16
  8. package/lib/seam/SeamProvider.js +12 -101
  9. package/lib/seam/SeamProvider.js.map +1 -1
  10. package/lib/seam/SeamQueryProvider.d.ts +32 -0
  11. package/lib/seam/SeamQueryProvider.js +127 -0
  12. package/lib/seam/SeamQueryProvider.js.map +1 -0
  13. package/lib/seam/access-codes/use-access-code.d.ts +2 -2
  14. package/lib/seam/access-codes/use-access-codes.d.ts +2 -2
  15. package/lib/seam/access-codes/use-create-access-code.d.ts +2 -7
  16. package/lib/seam/access-codes/use-create-access-code.js +3 -9
  17. package/lib/seam/access-codes/use-create-access-code.js.map +1 -1
  18. package/lib/seam/access-codes/use-generate-access-code-code.d.ts +2 -2
  19. package/lib/seam/client-sessions/use-client-session.d.ts +2 -2
  20. package/lib/seam/components/SupportedDeviceTable/use-device-model.d.ts +2 -2
  21. package/lib/seam/components/SupportedDeviceTable/use-device-models.d.ts +2 -2
  22. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.d.ts +2 -2
  23. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.d.ts +2 -2
  24. package/lib/seam/connected-accounts/use-connected-account.d.ts +2 -2
  25. package/lib/seam/devices/use-device-providers.d.ts +2 -2
  26. package/lib/seam/devices/use-device.d.ts +2 -2
  27. package/lib/seam/devices/use-devices.d.ts +2 -2
  28. package/lib/seam/events/use-events.d.ts +2 -2
  29. package/lib/seam/filters.js +3 -1
  30. package/lib/seam/filters.js.map +1 -1
  31. package/lib/seam/index.d.ts +2 -0
  32. package/lib/seam/index.js +2 -0
  33. package/lib/seam/index.js.map +1 -1
  34. package/lib/seam/noise-sensors/use-noise-thresholds.d.ts +2 -2
  35. package/lib/seam/thermostats/use-create-thermostat-climate-preset.js +1 -0
  36. package/lib/seam/thermostats/use-create-thermostat-climate-preset.js.map +1 -1
  37. package/lib/seam/thermostats/use-delete-thermostat-climate-preset.d.ts +2 -2
  38. package/lib/seam/thermostats/use-update-thermostat-climate-preset.js +1 -0
  39. package/lib/seam/thermostats/use-update-thermostat-climate-preset.js.map +1 -1
  40. package/lib/seam/use-seam-client.d.ts +2 -1
  41. package/lib/seam/use-seam-client.js +23 -9
  42. package/lib/seam/use-seam-client.js.map +1 -1
  43. package/lib/seam/use-seam-mutation.d.ts +8 -0
  44. package/lib/seam/use-seam-mutation.js +17 -0
  45. package/lib/seam/use-seam-mutation.js.map +1 -0
  46. package/lib/seam/use-seam-query-result.d.ts +1 -1
  47. package/lib/seam/use-seam-query.d.ts +8 -0
  48. package/lib/seam/use-seam-query.js +19 -0
  49. package/lib/seam/use-seam-query.js.map +1 -0
  50. package/lib/telemetry/hooks.js +2 -2
  51. package/lib/telemetry/hooks.js.map +1 -1
  52. package/lib/ui/DateTimePicker/DateTimePicker.d.ts +1 -1
  53. package/lib/version.d.ts +1 -1
  54. package/lib/version.js +1 -1
  55. package/package.json +5 -4
  56. package/src/lib/index.ts +1 -0
  57. package/src/lib/seam/SeamProvider.tsx +28 -183
  58. package/src/lib/seam/SeamQueryProvider.tsx +248 -0
  59. package/src/lib/seam/access-codes/use-access-code.ts +2 -2
  60. package/src/lib/seam/access-codes/use-access-codes.ts +2 -2
  61. package/src/lib/seam/access-codes/use-create-access-code.ts +7 -32
  62. package/src/lib/seam/access-codes/use-generate-access-code-code.ts +2 -2
  63. package/src/lib/seam/client-sessions/use-client-session.ts +2 -2
  64. package/src/lib/seam/components/SupportedDeviceTable/use-device-model.ts +2 -2
  65. package/src/lib/seam/components/SupportedDeviceTable/use-device-models.ts +2 -2
  66. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturer.ts +2 -2
  67. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturers.ts +2 -2
  68. package/src/lib/seam/connected-accounts/use-connected-account.ts +2 -2
  69. package/src/lib/seam/devices/use-device-providers.ts +2 -2
  70. package/src/lib/seam/devices/use-device.ts +2 -2
  71. package/src/lib/seam/devices/use-devices.ts +2 -2
  72. package/src/lib/seam/events/use-events.ts +2 -2
  73. package/src/lib/seam/filters.ts +3 -1
  74. package/src/lib/seam/index.ts +2 -0
  75. package/src/lib/seam/noise-sensors/use-noise-thresholds.ts +2 -2
  76. package/src/lib/seam/thermostats/use-create-thermostat-climate-preset.ts +1 -0
  77. package/src/lib/seam/thermostats/use-delete-thermostat-climate-preset.ts +2 -2
  78. package/src/lib/seam/thermostats/use-update-thermostat-climate-preset.ts +1 -0
  79. package/src/lib/seam/use-seam-client.ts +29 -10
  80. package/src/lib/seam/use-seam-mutation.ts +50 -0
  81. package/src/lib/seam/use-seam-query-result.ts +6 -4
  82. package/src/lib/seam/use-seam-query.ts +45 -0
  83. package/src/lib/telemetry/hooks.ts +2 -2
  84. package/src/lib/version.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { NoiseSensorsNoiseThresholdsListParams } from '@seamapi/http/connect';
2
2
  import type { NoiseThreshold } from '@seamapi/types/connect';
3
- import type { UseSeamQueryResult } from '../../../lib/seam/use-seam-query-result.js';
3
+ import type { UseSeamQueryResultLegacy } from '../../../lib/seam/use-seam-query-result.js';
4
4
  export type UseNoiseThresholdsParams = NoiseSensorsNoiseThresholdsListParams;
5
5
  export type UseNoiseThresholdsData = NoiseThreshold[];
6
- export declare function useNoiseThresholds(params: UseNoiseThresholdsParams): UseSeamQueryResult<'noiseThresholds', UseNoiseThresholdsData>;
6
+ export declare function useNoiseThresholds(params: UseNoiseThresholdsParams): UseSeamQueryResultLegacy<'noiseThresholds', UseNoiseThresholdsData>;
@@ -39,6 +39,7 @@ const getUpdatedDevice = (device, variables) => {
39
39
  display_name: variables.name ?? variables.climate_preset_key,
40
40
  can_delete: true,
41
41
  can_edit: true,
42
+ can_program: true,
42
43
  manual_override_allowed: false,
43
44
  };
44
45
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"use-create-thermostat-climate-preset.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-create-thermostat-climate-preset.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQhF,MAAM,UAAU,gCAAgC;IAK9C,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YACpD,MAAM,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAA;QACzD,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACtD,CAAC,MAAM,EAAE,EAAE;gBACT,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;oBACnB,OAAM;gBACR,CAAC;gBAED,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;YAC5C,CAAC,CACF,CAAA;YAED,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACvD,CAAC,OAAO,EAAsB,EAAE;gBAC9B,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;oBACpB,OAAO,EAAE,CAAA;gBACX,CAAC;gBAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC5B,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,EAAE,CAAC;wBAC7C,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;oBAC5C,CAAC;oBAED,OAAO,MAAM,CAAA;gBACf,CAAC,CAAC,CAAA;YACJ,CAAC,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,CACvB,MAAwB,EACxB,SAAoD,EAClC,EAAE;IACpB,MAAM,MAAM,GAA4B;QACtC,GAAG,SAAS;QACZ,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,YAAY,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,kBAAkB;QAC5D,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,uBAAuB,EAAE,KAAK;KAC/B,CAAA;IAED,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,UAAU;YACpB,yBAAyB,EAAE;gBACzB,MAAM;gBACN,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,IAAI,EAAE,CAAC;aACvD;SACF;KACF,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"use-create-thermostat-climate-preset.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-create-thermostat-climate-preset.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,mBAAmB,E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KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,CACvB,MAAwB,EACxB,SAAoD,EAClC,EAAE;IACpB,MAAM,MAAM,GAA4B;QACtC,GAAG,SAAS;QACZ,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,YAAY,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,kBAAkB;QAC5D,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,IAAI;QACjB,uBAAuB,EAAE,KAAK;KAC/B,CAAA;IAED,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,UAAU;YACpB,yBAAyB,EAAE;gBACzB,MAAM;gBACN,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,IAAI,EAAE,CAAC;aACvD;SACF;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import type { SeamHttpApiError, ThermostatsDeleteClimatePresetBody } from '@seamapi/http/connect';
1
+ import type { SeamHttpApiError, ThermostatsDeleteClimatePresetParams } from '@seamapi/http/connect';
2
2
  import { type UseMutationResult } from '@tanstack/react-query';
3
3
  export type UseDeleteThermostatClimatePresetParams = never;
4
4
  export type UseDeleteThermostatClimatePresetData = undefined;
5
- export type UseDeleteThermostatClimatePresetVariables = ThermostatsDeleteClimatePresetBody;
5
+ export type UseDeleteThermostatClimatePresetVariables = ThermostatsDeleteClimatePresetParams;
6
6
  export declare function useDeleteThermostatClimatePreset(): UseMutationResult<UseDeleteThermostatClimatePresetData, SeamHttpApiError, UseDeleteThermostatClimatePresetVariables>;
@@ -39,6 +39,7 @@ function getUpdatedDevice(device, variables) {
39
39
  display_name: variables.name ?? variables.climate_preset_key,
40
40
  can_delete: true,
41
41
  can_edit: true,
42
+ can_program: true,
42
43
  manual_override_allowed: true,
43
44
  };
44
45
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"use-update-thermostat-climate-preset.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-update-thermostat-climate-preset.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQhF,MAAM,UAAU,gCAAgC;IAK9C,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YACpD,MAAM,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAA;QACzD,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACtD,CAAC,MAAM,EAAE,EAAE;gBACT,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;oBACnB,OAAM;gBACR,CAAC;gBAED,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;YAC5C,CAAC,CACF,CAAA;YAED,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACvD,CAAC,OAAO,EAAsB,EAAE;gBAC9B,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;oBACpB,OAAO,EAAE,CAAA;gBACX,CAAC;gBAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC5B,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,EAAE,CAAC;wBAC7C,OAAO,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;oBAC5C,CAAC;oBAED,OAAO,MAAM,CAAA;gBACf,CAAC,CAAC,CAAA;YACJ,CAAC,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAwB,EACxB,SAAoD;IAEpD,MAAM,MAAM,GAA4B;QACtC,GAAG,SAAS;QACZ,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,YAAY,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,kBAAkB;QAC5D,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,uBAAuB,EAAE,IAAI;KAC9B,CAAA;IAED,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,UAAU;YACpB,yBAAyB,EAAE;gBACzB,MAAM;gBACN,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,IAAI,EAAE,CAAC;aACvD;SACF;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"use-update-thermostat-climate-preset.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-update-thermostat-climate-preset.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQhF,MAAM,UAAU,gCAAgC;IAK9C,MAAM,EA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,MAAM,MAAM,GAA4B;QACtC,GAAG,SAAS;QACZ,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,yBAAyB,EAAE,mBAAmB,CAC5C,SAAS,CAAC,4BAA4B,CACvC;QACD,YAAY,EAAE,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,kBAAkB;QAC5D,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,IAAI;QACjB,uBAAuB,EAAE,IAAI;KAC9B,CAAA;IAED,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,UAAU;YACpB,yBAAyB,EAAE;gBACzB,MAAM;gBACN,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,IAAI,EAAE,CAAC;aACvD;SACF;KACF,CAAA;AACH,CAAC"}
@@ -1,6 +1,7 @@
1
- import { SeamHttp } from '@seamapi/http/connect';
1
+ import { SeamHttp, SeamHttpEndpoints } from '@seamapi/http/connect';
2
2
  export declare function useSeamClient(): {
3
3
  client: SeamHttp | null;
4
+ endpointClient: SeamHttpEndpoints | null;
4
5
  isPending: boolean;
5
6
  isError: boolean;
6
7
  error: unknown;
@@ -1,10 +1,10 @@
1
- import { SeamHttp } from '@seamapi/http/connect';
1
+ import { SeamHttp, SeamHttpEndpoints } from '@seamapi/http/connect';
2
2
  import { useQuery } from '@tanstack/react-query';
3
3
  import { useEffect } from 'react';
4
4
  import { v4 as uuidv4 } from 'uuid';
5
- import { useSeamContext } from '../../lib/seam/SeamProvider.js';
5
+ import { useSeamQueryContext } from './SeamQueryProvider.js';
6
6
  export function useSeamClient() {
7
- const { client, clientOptions, publishableKey, clientSessionToken, ...context } = useSeamContext();
7
+ const { client, clientOptions, publishableKey, clientSessionToken, ...context } = useSeamQueryContext();
8
8
  const userIdentifierKey = useUserIdentifierKeyOrFingerprint(clientSessionToken != null ? '' : context.userIdentifierKey);
9
9
  const { isPending, isError, error, data } = useQuery({
10
10
  queryKey: [
@@ -19,23 +19,37 @@ export function useSeamClient() {
19
19
  ],
20
20
  queryFn: async () => {
21
21
  if (client != null)
22
- return client;
22
+ return [client, SeamHttpEndpoints.fromClient(client.client)];
23
23
  if (clientSessionToken != null) {
24
- return SeamHttp.fromClientSessionToken(clientSessionToken, clientOptions);
24
+ const clientSessionTokenClient = SeamHttp.fromClientSessionToken(clientSessionToken, clientOptions);
25
+ return [
26
+ clientSessionTokenClient,
27
+ SeamHttpEndpoints.fromClient(clientSessionTokenClient.client),
28
+ ];
25
29
  }
26
30
  if (publishableKey == null) {
27
31
  throw new Error('Missing either a client, publishableKey, or clientSessionToken');
28
32
  }
29
- return await SeamHttp.fromPublishableKey(publishableKey, userIdentifierKey, clientOptions);
33
+ const publishableKeyClient = await SeamHttp.fromPublishableKey(publishableKey, userIdentifierKey, clientOptions);
34
+ return [
35
+ publishableKeyClient,
36
+ SeamHttpEndpoints.fromClient(publishableKeyClient.client),
37
+ ];
30
38
  },
31
39
  });
32
- return { client: data ?? null, isPending, isError, error };
40
+ return {
41
+ client: data?.[0] ?? null,
42
+ endpointClient: data?.[1] ?? null,
43
+ isPending,
44
+ isError,
45
+ error,
46
+ };
33
47
  }
34
48
  export class NullSeamClientError extends Error {
35
49
  constructor() {
36
50
  super([
37
51
  'Attempted to use a null Seam client.',
38
- 'Either a hook using useSeamClient was called outside of a SeamProvider,',
52
+ 'Either a hook using useSeamClient was called outside of a SeamProvider or SeamQueryProvider,',
39
53
  'or there was an error when creating the Seam client in useSeamClient,',
40
54
  'or useSeamClient is still loading the client.',
41
55
  ].join(' '));
@@ -48,7 +62,7 @@ function useUserIdentifierKeyOrFingerprint(userIdentifierKey) {
48
62
  if (userIdentifierKey != null)
49
63
  return;
50
64
  // eslint-disable-next-line no-console
51
- console.warn(`Using an automatically generated fingerprint for the SeamProvider userIdentifierKey!
65
+ console.warn(`Using an automatically generated fingerprint for the Seam userIdentifierKey!
52
66
  The user interface will show warnings when using a fingerprint.
53
67
  This is not recommended because the client session is now bound to this machine and is effectively ephemeral.`);
54
68
  }, [userIdentifierKey]);
@@ -1 +1 @@
1
- {"version":3,"file":"use-seam-client.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,MAAM,UAAU,aAAa;IAM3B,MAAM,EACJ,MAAM,EACN,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,GAAG,OAAO,EACX,GAAG,cAAc,EAAE,CAAA;IACpB,MAAM,iBAAiB,GAAG,iCAAiC,CACzD,kBAAkB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAC5D,CAAA;IAED,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAW;QAC7D,QAAQ,EAAE;YACR,QAAQ;YACR;gBACE,MAAM;gBACN,aAAa;gBACb,cAAc;gBACd,iBAAiB;gBACjB,kBAAkB;aACnB;SACF;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,MAAM,CAAA;YAEjC,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC/B,OAAO,QAAQ,CAAC,sBAAsB,CACpC,kBAAkB,EAClB,aAAa,CACd,CAAA;YACH,CAAC;YAED,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;YACH,CAAC;YAED,OAA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+1,8 @@
1
+ import type { SeamHttpApiError, SeamHttpEndpointMutationPaths, SeamHttpEndpoints } from '@seamapi/http/connect';
2
+ import { type UseMutationOptions, type UseMutationResult } from '@tanstack/react-query';
3
+ export type UseSeamMutationVariables<T extends SeamHttpEndpointMutationPaths> = Parameters<SeamHttpEndpoints[T]>[0];
4
+ export type UseSeamMutationResult<T extends SeamHttpEndpointMutationPaths> = UseMutationResult<MutationData<T>, SeamHttpApiError, UseSeamMutationVariables<T>>;
5
+ export declare function useSeamMutation<T extends SeamHttpEndpointMutationPaths>(endpointPath: T, options?: Parameters<SeamHttpEndpoints[T]>[1] & MutationOptions<MutationData<T>, SeamHttpApiError, UseSeamMutationVariables<T>>): UseSeamMutationResult<T>;
6
+ type MutationData<T extends SeamHttpEndpointMutationPaths> = Awaited<ReturnType<SeamHttpEndpoints[T]>>;
7
+ type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
8
+ export {};
@@ -0,0 +1,17 @@
1
+ import { useMutation, } from '@tanstack/react-query';
2
+ import { NullSeamClientError, useSeamClient } from '../../lib/seam/use-seam-client.js';
3
+ export function useSeamMutation(endpointPath, options = {}) {
4
+ const { endpointClient: client } = useSeamClient();
5
+ return useMutation({
6
+ ...options,
7
+ mutationFn: async (variables) => {
8
+ if (client === null)
9
+ throw new NullSeamClientError();
10
+ // Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
11
+ // Type assertion is needed here for performance reasons. The types are correct at runtime.
12
+ const endpoint = client[endpointPath];
13
+ return await endpoint(variables, options);
14
+ },
15
+ });
16
+ }
17
+ //# sourceMappingURL=use-seam-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-seam-mutation.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAYhF,MAAM,UAAU,eAAe,CAC7B,YAAe,EACf,UAKM,EAAE;IAER,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClD,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YACpD,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { SeamHttpApiError } from '@seamapi/http/connect';
2
2
  import type { UseQueryResult } from '@tanstack/react-query';
3
- export type UseSeamQueryResult<Field extends string, ResponsePayload> = Omit<UseQueryResult<ResponsePayload, SeamHttpApiError>, 'data'> & {
3
+ export type UseSeamQueryResultLegacy<Field extends string, ResponsePayload> = Omit<UseQueryResult<ResponsePayload, SeamHttpApiError>, 'data'> & {
4
4
  [key in Field]?: ResponsePayload;
5
5
  };
@@ -0,0 +1,8 @@
1
+ import type { SeamHttpApiError, SeamHttpEndpointQueryPaths, SeamHttpEndpoints } from '@seamapi/http/connect';
2
+ import { type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
3
+ export type UseSeamQueryParameters<T extends SeamHttpEndpointQueryPaths> = Parameters<SeamHttpEndpoints[T]>[0];
4
+ export type UseSeamQueryResult<T extends SeamHttpEndpointQueryPaths> = UseQueryResult<QueryData<T>, SeamHttpApiError>;
5
+ export declare function useSeamQuery<T extends SeamHttpEndpointQueryPaths>(endpointPath: T, parameters?: UseSeamQueryParameters<T>, options?: Parameters<SeamHttpEndpoints[T]>[1] & QueryOptions<QueryData<T>, SeamHttpApiError>): UseSeamQueryResult<T>;
6
+ type QueryData<T extends SeamHttpEndpointQueryPaths> = Awaited<ReturnType<SeamHttpEndpoints[T]>>;
7
+ type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
8
+ export {};
@@ -0,0 +1,19 @@
1
+ import { useQuery, } from '@tanstack/react-query';
2
+ import { useSeamClient } from '../../lib/seam/use-seam-client.js';
3
+ export function useSeamQuery(endpointPath, parameters, options = {}) {
4
+ const { endpointClient: client } = useSeamClient();
5
+ return useQuery({
6
+ enabled: client != null,
7
+ ...options,
8
+ queryKey: [endpointPath, parameters],
9
+ queryFn: async () => {
10
+ if (client == null)
11
+ return null;
12
+ // Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
13
+ // Type assertion is needed here for performance reasons. The types are correct at runtime.
14
+ const endpoint = client[endpointPath];
15
+ return await endpoint(parameters, options);
16
+ },
17
+ });
18
+ }
19
+ //# sourceMappingURL=use-seam-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-seam-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQ3D,MAAM,UAAU,YAAY,CAC1B,YAAe,EACf,UAAsC,EACtC,UACiD,EAAE;IAEnD,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClD,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,IAAI;QACvB,GAAG,OAAO;QACV,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;QACpC,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAA;YAC/B,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useLayoutEffect } from 'react';
2
2
  import { useClientSession } from '../../lib/seam/client-sessions/use-client-session.js';
3
- import { useSeamContext } from '../../lib/seam/SeamProvider.js';
3
+ import { useSeamQueryContext } from '../../lib/seam/SeamQueryProvider.js';
4
4
  import { useTelemetryContext } from './TelemetryProvider.js';
5
5
  export function useTelemetryClient() {
6
6
  const { client } = useTelemetryContext();
@@ -18,7 +18,7 @@ export function useComponentTelemetry(name) {
18
18
  }
19
19
  export function useUserTelemetry() {
20
20
  const telemetry = useTelemetryClient();
21
- const { publishableKey } = useSeamContext();
21
+ const { publishableKey } = useSeamQueryContext();
22
22
  const { clientSession } = useClientSession();
23
23
  // Ensure identify runs earlier than other effects to avoid anonymous telemetry data.
24
24
  useLayoutEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/lib/telemetry/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,MAAM,UAAU,kBAAkB;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAA;IACxC,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAC5C,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAA;IACtC,SAAS,CAAC,GAAG,EAAE;QACb,sEAAsE;Q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;SACzC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,CAAA;AAChD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { type TextFieldProps } from '../../../lib/ui/TextField/TextField.js';
3
- export declare const DateTimePicker: import("react").ForwardRefExoticComponent<Pick<TextFieldProps, "value" | "className" | "size"> & {
3
+ export declare const DateTimePicker: import("react").ForwardRefExoticComponent<Pick<TextFieldProps, "value" | "size" | "className"> & {
4
4
  onChange: (value: string) => void;
5
5
  } & import("react").RefAttributes<HTMLInputElement | undefined>>;
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiReactVersion = "4.8.1";
1
+ declare const seamapiReactVersion = "4.9.0";
2
2
  export default seamapiReactVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '4.8.1';
1
+ const seamapiReactVersion = '4.9.0';
2
2
  export default seamapiReactVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/react",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "description": "Seam Components.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -109,7 +109,8 @@
109
109
  "npm": ">= 9.0.0"
110
110
  },
111
111
  "peerDependencies": {
112
- "@seamapi/types": "^1.344.3",
112
+ "@seamapi/http": "^1.37.0",
113
+ "@seamapi/types": "^1.395.3",
113
114
  "@types/react": "^18.0.0",
114
115
  "@types/react-dom": "^18.0.0",
115
116
  "react": "^18.0.0",
@@ -128,7 +129,6 @@
128
129
  },
129
130
  "dependencies": {
130
131
  "@floating-ui/react": "^0.27.5",
131
- "@seamapi/http": "^1.20.0",
132
132
  "@tanstack/react-query": "^5.27.5",
133
133
  "classnames": "^2.3.2",
134
134
  "luxon": "^3.3.0",
@@ -145,7 +145,8 @@
145
145
  "@rxfork/r2wc-react-to-web-component": "^2.4.0",
146
146
  "@seamapi/fake-devicedb": "^1.6.1",
147
147
  "@seamapi/fake-seam-connect": "^1.76.0",
148
- "@seamapi/types": "^1.344.3",
148
+ "@seamapi/http": "^1.38.3",
149
+ "@seamapi/types": "^1.395.3",
149
150
  "@storybook/addon-designs": "^7.0.1",
150
151
  "@storybook/addon-essentials": "^7.0.2",
151
152
  "@storybook/addon-links": "^7.0.2",
package/src/lib/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './seam/components/index.js'
2
2
  export * from './seam/index.js'
3
3
  export * from './seam/SeamProvider.js'
4
+ export * from './seam/SeamQueryProvider.js'
@@ -1,16 +1,13 @@
1
- import type {
2
- SeamHttp,
3
- SeamHttpOptionsWithClientSessionToken,
4
- } from '@seamapi/http/connect'
5
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
6
- import {
7
- createContext,
8
- type PropsWithChildren,
9
- useContext,
10
- useEffect,
11
- useMemo,
12
- } from 'react'
1
+ import type { SeamHttp } from '@seamapi/http/connect'
2
+ import type { QueryClient } from '@tanstack/react-query'
3
+ import { createContext, type PropsWithChildren, useMemo } from 'react'
13
4
 
5
+ import {
6
+ SeamQueryProvider,
7
+ type SeamQueryProviderPropsWithClient,
8
+ type SeamQueryProviderPropsWithClientSessionToken,
9
+ type SeamQueryProviderPropsWithPublishableKey,
10
+ } from 'lib/seam/SeamQueryProvider.js'
14
11
  import { useSeamFont } from 'lib/seam/use-seam-font.js'
15
12
  import { useSeamStyles } from 'lib/seam/use-seam-styles.js'
16
13
  import {
@@ -19,8 +16,6 @@ import {
19
16
  useUserTelemetry,
20
17
  } from 'lib/telemetry/index.js'
21
18
 
22
- import { useSeamClient } from './use-seam-client.js'
23
-
24
19
  declare global {
25
20
  // eslint-disable-next-line no-var
26
21
  var seam: SeamProviderProps | undefined
@@ -30,33 +25,28 @@ declare global {
30
25
  var seamTelemetryClient: TelemetryClient | undefined
31
26
  }
32
27
 
33
- export interface SeamContext {
34
- client: SeamHttp | null
35
- clientOptions?: SeamProviderClientOptions | undefined
36
- publishableKey?: string | undefined
37
- userIdentifierKey?: string | undefined
38
- clientSessionToken?: string | undefined
39
- }
28
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
29
+ export interface SeamContext {}
40
30
 
41
31
  export type SeamProviderProps =
42
32
  | SeamProviderPropsWithClient
43
33
  | SeamProviderPropsWithPublishableKey
44
34
  | SeamProviderPropsWithClientSessionToken
45
35
 
46
- export interface SeamProviderPropsWithClient extends SeamProviderBaseProps {
47
- client: SeamHttp
48
- }
36
+ export interface SeamProviderPropsWithClient
37
+ extends SeamQueryProviderPropsWithClient,
38
+ SeamProviderBaseProps {}
49
39
 
50
40
  export interface SeamProviderPropsWithPublishableKey
51
41
  extends SeamProviderBaseProps,
52
- SeamProviderClientOptions {
42
+ SeamQueryProviderPropsWithPublishableKey {
53
43
  publishableKey: string
54
44
  userIdentifierKey?: string
55
45
  }
56
46
 
57
47
  export interface SeamProviderPropsWithClientSessionToken
58
48
  extends SeamProviderBaseProps,
59
- SeamProviderClientOptions {
49
+ SeamQueryProviderPropsWithClientSessionToken {
60
50
  clientSessionToken: string
61
51
  }
62
52
 
@@ -70,12 +60,6 @@ interface SeamProviderBaseProps extends PropsWithChildren {
70
60
  onSessionUpdate?: (client: SeamHttp) => void
71
61
  }
72
62
 
73
- type SeamClientOptions = SeamHttpOptionsWithClientSessionToken
74
-
75
- export type SeamProviderClientOptions = Pick<SeamClientOptions, 'endpoint'>
76
-
77
- const defaultQueryClient = new QueryClient()
78
-
79
63
  export const seamComponentsClassName = 'seam-components'
80
64
 
81
65
  export function SeamProvider({
@@ -84,40 +68,20 @@ export function SeamProvider({
84
68
  disableCssInjection = false,
85
69
  disableFontInjection = false,
86
70
  unminifiyCss = false,
87
- onSessionUpdate = () => {},
88
- queryClient,
89
71
  telemetryClient,
90
72
  ...props
91
73
  }: SeamProviderProps): JSX.Element {
92
74
  useSeamStyles({ disabled: disableCssInjection, unminified: unminifiyCss })
93
75
  useSeamFont({ disabled: disableFontInjection })
94
76
 
77
+ const { Provider } = seamContext
78
+
79
+ const endpoint = 'endpoint' in props ? props.endpoint : undefined
95
80
  const value = useMemo(() => {
96
81
  const context = createSeamContextValue(props)
97
- if (
98
- context.client == null &&
99
- context.publishableKey == null &&
100
- context.clientSessionToken == null
101
- ) {
102
- return defaultSeamContextValue
103
- }
104
82
  return context
105
83
  }, [props])
106
84
 
107
- if (
108
- value.client == null &&
109
- value.publishableKey == null &&
110
- value.clientSessionToken == null
111
- ) {
112
- throw new Error(
113
- `Must provide either a Seam client, clientSessionToken, or a publishableKey.`
114
- )
115
- }
116
-
117
- const { Provider } = seamContext
118
-
119
- const endpoint = 'endpoint' in props ? props.endpoint : undefined
120
-
121
85
  return (
122
86
  <div className={seamComponentsClassName}>
123
87
  <TelemetryProvider
@@ -125,157 +89,38 @@ export function SeamProvider({
125
89
  disabled={disableTelemetry}
126
90
  endpoint={endpoint}
127
91
  >
128
- <QueryClientProvider
129
- client={
130
- queryClient ?? globalThis.seamQueryClient ?? defaultQueryClient
131
- }
132
- >
92
+ <SeamQueryProvider {...props}>
133
93
  <Provider value={value}>
134
- <Wrapper onSessionUpdate={onSessionUpdate}>{children}</Wrapper>
94
+ <Telemetry>{children}</Telemetry>
135
95
  </Provider>
136
- </QueryClientProvider>
96
+ </SeamQueryProvider>
137
97
  </TelemetryProvider>
138
98
  </div>
139
99
  )
140
100
  }
141
101
 
142
- function Wrapper({
143
- onSessionUpdate,
144
- children,
145
- }: Required<Pick<SeamProviderProps, 'onSessionUpdate'>> &
146
- PropsWithChildren): JSX.Element | null {
102
+ function Telemetry({ children }: PropsWithChildren): JSX.Element | null {
147
103
  useUserTelemetry()
148
-
149
- const { client } = useSeamClient()
150
- useEffect(() => {
151
- if (client != null) onSessionUpdate(client)
152
- }, [onSessionUpdate, client])
153
-
154
104
  return <>{children}</>
155
105
  }
156
106
 
157
107
  const createDefaultSeamContextValue = (): SeamContext => {
158
108
  try {
159
109
  if (globalThis.seam == null) {
160
- return { client: null }
110
+ return {}
161
111
  }
162
112
  return createSeamContextValue(globalThis.seam)
163
113
  } catch (err) {
164
114
  // eslint-disable-next-line no-console
165
115
  console.warn(err)
166
- return { client: null }
116
+ return {}
167
117
  }
168
118
  }
169
119
 
170
- const createSeamContextValue = (options: SeamProviderProps): SeamContext => {
171
- if (isSeamProviderPropsWithClient(options)) {
172
- return options
173
- }
174
-
175
- if (isSeamProviderPropsWithClientSessionToken(options)) {
176
- const { clientSessionToken, ...clientOptions } = options
177
- return {
178
- clientSessionToken,
179
- clientOptions,
180
- client: null,
181
- }
182
- }
183
-
184
- if (isSeamProviderPropsWithPublishableKey(options)) {
185
- const { publishableKey, userIdentifierKey, ...clientOptions } = options
186
- return {
187
- publishableKey,
188
- userIdentifierKey,
189
- clientOptions,
190
- client: null,
191
- }
192
- }
193
-
194
- return { client: null }
120
+ const createSeamContextValue = (_options: SeamProviderProps): SeamContext => {
121
+ return {}
195
122
  }
196
123
 
197
124
  const defaultSeamContextValue = createDefaultSeamContextValue()
198
125
 
199
- export const seamContext = createContext<SeamContext>(defaultSeamContextValue)
200
-
201
- export function useSeamContext(): SeamContext {
202
- return useContext(seamContext)
203
- }
204
-
205
- const isSeamProviderPropsWithClient = (
206
- props: SeamProviderProps
207
- ): props is SeamProviderPropsWithClient => {
208
- if (!('client' in props)) return false
209
-
210
- const { client, ...otherProps } = props
211
- if (client == null) return false
212
-
213
- const otherNonNullProps = Object.values(otherProps).filter((v) => v != null)
214
- if (otherNonNullProps.length > 0) {
215
- throw new InvalidSeamProviderProps(
216
- `The client prop cannot be used with ${otherNonNullProps.join(' or ')}.`
217
- )
218
- }
219
-
220
- return true
221
- }
222
-
223
- const isSeamProviderPropsWithPublishableKey = (
224
- props: SeamProviderProps
225
- ): props is SeamProviderPropsWithPublishableKey & SeamProviderClientOptions => {
226
- if (!('publishableKey' in props)) return false
227
-
228
- const { publishableKey } = props
229
- if (publishableKey == null) return false
230
-
231
- if ('client' in props && props.client != null) {
232
- throw new InvalidSeamProviderProps(
233
- 'The client prop cannot be used with the publishableKey prop.'
234
- )
235
- }
236
-
237
- if ('clientSessionToken' in props && props.clientSessionToken != null) {
238
- throw new InvalidSeamProviderProps(
239
- 'The clientSessionToken prop cannot be used with the publishableKey prop.'
240
- )
241
- }
242
-
243
- return true
244
- }
245
-
246
- const isSeamProviderPropsWithClientSessionToken = (
247
- props: SeamProviderProps
248
- ): props is SeamProviderPropsWithClientSessionToken &
249
- SeamProviderClientOptions => {
250
- if (!('clientSessionToken' in props)) return false
251
-
252
- const { clientSessionToken } = props
253
- if (clientSessionToken == null) return false
254
-
255
- if ('client' in props && props.client != null) {
256
- throw new InvalidSeamProviderProps(
257
- 'The client prop cannot be used with the clientSessionToken prop.'
258
- )
259
- }
260
-
261
- if ('publishableKey' in props && props.publishableKey != null) {
262
- throw new InvalidSeamProviderProps(
263
- 'The publishableKey prop cannot be used with the clientSessionToken prop.'
264
- )
265
- }
266
-
267
- if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
268
- throw new InvalidSeamProviderProps(
269
- 'The userIdentifierKey prop cannot be used with the clientSessionToken prop.'
270
- )
271
- }
272
-
273
- return true
274
- }
275
-
276
- class InvalidSeamProviderProps extends Error {
277
- constructor(message: string) {
278
- super(`SeamProvider received invalid props: ${message}`)
279
- this.name = this.constructor.name
280
- }
281
- }
126
+ const seamContext = createContext<SeamContext>(defaultSeamContextValue)