shoal-web-sdk 1.0.88 → 1.0.89

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.
@@ -1,6 +1,6 @@
1
1
  import { type UseMutationOptions } from '@tanstack/react-query';
2
2
  import { type Options } from '../sdk.gen';
3
- import type { CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetInvoicesData, GetPlansData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
3
+ import type { CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetCustomerData, GetInvoicesData, GetPlansData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
4
4
  export type QueryKey<TOptions extends Options> = [
5
5
  Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
6
6
  _id: string;
@@ -8,6 +8,34 @@ export type QueryKey<TOptions extends Options> = [
8
8
  tags?: ReadonlyArray<string>;
9
9
  }
10
10
  ];
11
+ export declare const getCustomerQueryKey: (options: Options<GetCustomerData>) => [Pick<Options<GetCustomerData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
12
+ _id: string;
13
+ _infinite?: boolean;
14
+ tags?: ReadonlyArray<string>;
15
+ }];
16
+ /**
17
+ * Fetch all related customer information for a given org.
18
+ */
19
+ export declare const getCustomerOptions: (options: Options<GetCustomerData>) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../types.gen").CustomerResponse, Error, import("../types.gen").CustomerResponse, [Pick<Options<GetCustomerData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
20
+ _id: string;
21
+ _infinite?: boolean;
22
+ tags?: ReadonlyArray<string>;
23
+ }]>, "queryFn"> & {
24
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("../types.gen").CustomerResponse, [Pick<Options<GetCustomerData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
25
+ _id: string;
26
+ _infinite?: boolean;
27
+ tags?: ReadonlyArray<string>;
28
+ }], never> | undefined;
29
+ } & {
30
+ queryKey: [Pick<Options<GetCustomerData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
31
+ _id: string;
32
+ _infinite?: boolean;
33
+ tags?: ReadonlyArray<string>;
34
+ }] & {
35
+ [dataTagSymbol]: import("../types.gen").CustomerResponse;
36
+ [dataTagErrorSymbol]: Error;
37
+ };
38
+ };
11
39
  export declare const getPlansQueryKey: (options?: Options<GetPlansData>) => [Pick<Options<GetPlansData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
12
40
  _id: string;
13
41
  _infinite?: boolean;
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
  import { queryOptions } from '@tanstack/react-query';
3
3
  import { client } from '../client.gen';
4
- import { createSetupIntent, deletePaymentMethod, getInvoices, getPlans, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
4
+ import { createSetupIntent, deletePaymentMethod, getCustomer, getInvoices, getPlans, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
5
5
  const createQueryKey = (id, options, infinite, tags) => {
6
6
  const params = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl };
7
7
  if (infinite) {
@@ -26,6 +26,24 @@ const createQueryKey = (id, options, infinite, tags) => {
26
26
  params
27
27
  ];
28
28
  };
29
+ export const getCustomerQueryKey = (options) => createQueryKey('getCustomer', options);
30
+ /**
31
+ * Fetch all related customer information for a given org.
32
+ */
33
+ export const getCustomerOptions = (options) => {
34
+ return queryOptions({
35
+ queryFn: async ({ queryKey, signal }) => {
36
+ const { data } = await getCustomer({
37
+ ...options,
38
+ ...queryKey[0],
39
+ signal,
40
+ throwOnError: true
41
+ });
42
+ return data;
43
+ },
44
+ queryKey: getCustomerQueryKey(options)
45
+ });
46
+ };
29
47
  export const getPlansQueryKey = (options) => createQueryKey('getPlans', options);
30
48
  /**
31
49
  * Returns a list of available pricing plans.
@@ -1,5 +1,5 @@
1
1
  import type { Client, Options as Options2, TDataShape } from './client';
2
- import type { CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
2
+ import type { CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetCustomerData, GetCustomerErrors, GetCustomerResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -13,6 +13,10 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
13
13
  */
14
14
  meta?: Record<string, unknown>;
15
15
  };
16
+ /**
17
+ * Fetch all related customer information for a given org.
18
+ */
19
+ export declare const getCustomer: <ThrowOnError extends boolean = false>(options: Options<GetCustomerData, ThrowOnError>) => import("./client").RequestResult<GetCustomerResponses, GetCustomerErrors, ThrowOnError, "fields">;
16
20
  /**
17
21
  * Returns a list of available pricing plans.
18
22
  */
@@ -1,5 +1,20 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
  import { client } from './client.gen';
3
+ /**
4
+ * Fetch all related customer information for a given org.
5
+ */
6
+ export const getCustomer = (options) => {
7
+ return (options.client ?? client).get({
8
+ security: [
9
+ {
10
+ scheme: 'bearer',
11
+ type: 'http'
12
+ }
13
+ ],
14
+ url: '/api/v1/customer/{org}',
15
+ ...options
16
+ });
17
+ };
3
18
  /**
4
19
  * Returns a list of available pricing plans.
5
20
  */
@@ -171,6 +171,39 @@ export type PaymentMethodId = string;
171
171
  * Kinde organisation id.
172
172
  */
173
173
  export type OrganisationId = string;
174
+ export type GetCustomerData = {
175
+ body?: never;
176
+ path: {
177
+ /**
178
+ * Kinde organisation id.
179
+ */
180
+ org: string;
181
+ };
182
+ query?: never;
183
+ url: '/api/v1/customer/{org}';
184
+ };
185
+ export type GetCustomerErrors = {
186
+ /**
187
+ * Unauthorised
188
+ */
189
+ 401: _Error;
190
+ /**
191
+ * Account or subscription not found
192
+ */
193
+ 404: _Error;
194
+ /**
195
+ * Internal error
196
+ */
197
+ 500: _Error;
198
+ };
199
+ export type GetCustomerError = GetCustomerErrors[keyof GetCustomerErrors];
200
+ export type GetCustomerResponses = {
201
+ /**
202
+ * Customer billing state
203
+ */
204
+ 200: CustomerResponse;
205
+ };
206
+ export type GetCustomerResponse = GetCustomerResponses[keyof GetCustomerResponses];
174
207
  export type GetPlansData = {
175
208
  body?: never;
176
209
  path?: never;
@@ -700,6 +700,176 @@ export declare const zPaymentMethodId: z.ZodString;
700
700
  * Kinde organisation id.
701
701
  */
702
702
  export declare const zOrganisationId: z.ZodString;
703
+ export declare const zGetCustomerData: z.ZodObject<{
704
+ body: z.ZodOptional<z.ZodNever>;
705
+ path: z.ZodObject<{
706
+ org: z.ZodString;
707
+ }, z.core.$strip>;
708
+ query: z.ZodOptional<z.ZodNever>;
709
+ }, z.core.$strip>;
710
+ /**
711
+ * Customer billing state
712
+ */
713
+ export declare const zGetCustomerResponse: z.ZodObject<{
714
+ currentPlan: z.ZodObject<{
715
+ key: z.ZodReadonly<z.ZodString>;
716
+ displayName: z.ZodReadonly<z.ZodString>;
717
+ rank: z.ZodReadonly<z.ZodInt>;
718
+ interval: z.ZodOptional<z.ZodEnum<{
719
+ monthly: "monthly";
720
+ annual: "annual";
721
+ }>>;
722
+ currency: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
723
+ unitAmountCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
724
+ features: z.ZodReadonly<z.ZodObject<{
725
+ maximumSeats: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
726
+ type: z.ZodLiteral<"limited">;
727
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
728
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
729
+ displayName: z.ZodReadonly<z.ZodString>;
730
+ }, z.core.$strip>, z.ZodObject<{
731
+ type: z.ZodEnum<{
732
+ limited: "limited";
733
+ }>;
734
+ value: z.ZodInt;
735
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
736
+ type: z.ZodLiteral<"unlimited">;
737
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
738
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
739
+ displayName: z.ZodReadonly<z.ZodString>;
740
+ }, z.core.$strip>, z.ZodObject<{
741
+ type: z.ZodEnum<{
742
+ unlimited: "unlimited";
743
+ }>;
744
+ }, z.core.$strip>>>]>>;
745
+ maximumProjects: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
746
+ type: z.ZodLiteral<"limited">;
747
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
748
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
749
+ displayName: z.ZodReadonly<z.ZodString>;
750
+ }, z.core.$strip>, z.ZodObject<{
751
+ type: z.ZodEnum<{
752
+ limited: "limited";
753
+ }>;
754
+ value: z.ZodInt;
755
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
756
+ type: z.ZodLiteral<"unlimited">;
757
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
758
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
759
+ displayName: z.ZodReadonly<z.ZodString>;
760
+ }, z.core.$strip>, z.ZodObject<{
761
+ type: z.ZodEnum<{
762
+ unlimited: "unlimited";
763
+ }>;
764
+ }, z.core.$strip>>>]>>;
765
+ maximumEnvironments: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
766
+ type: z.ZodLiteral<"limited">;
767
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
768
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
769
+ displayName: z.ZodReadonly<z.ZodString>;
770
+ }, z.core.$strip>, z.ZodObject<{
771
+ type: z.ZodEnum<{
772
+ limited: "limited";
773
+ }>;
774
+ value: z.ZodInt;
775
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
776
+ type: z.ZodLiteral<"unlimited">;
777
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
778
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
779
+ displayName: z.ZodReadonly<z.ZodString>;
780
+ }, z.core.$strip>, z.ZodObject<{
781
+ type: z.ZodEnum<{
782
+ unlimited: "unlimited";
783
+ }>;
784
+ }, z.core.$strip>>>]>>;
785
+ }, z.core.$strip>>;
786
+ }, z.core.$strip>;
787
+ pendingPlan: z.ZodOptional<z.ZodObject<{
788
+ key: z.ZodReadonly<z.ZodString>;
789
+ displayName: z.ZodReadonly<z.ZodString>;
790
+ rank: z.ZodReadonly<z.ZodInt>;
791
+ interval: z.ZodOptional<z.ZodEnum<{
792
+ monthly: "monthly";
793
+ annual: "annual";
794
+ }>>;
795
+ currency: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
796
+ unitAmountCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
797
+ features: z.ZodReadonly<z.ZodObject<{
798
+ maximumSeats: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
799
+ type: z.ZodLiteral<"limited">;
800
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
801
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
802
+ displayName: z.ZodReadonly<z.ZodString>;
803
+ }, z.core.$strip>, z.ZodObject<{
804
+ type: z.ZodEnum<{
805
+ limited: "limited";
806
+ }>;
807
+ value: z.ZodInt;
808
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
809
+ type: z.ZodLiteral<"unlimited">;
810
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
811
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
812
+ displayName: z.ZodReadonly<z.ZodString>;
813
+ }, z.core.$strip>, z.ZodObject<{
814
+ type: z.ZodEnum<{
815
+ unlimited: "unlimited";
816
+ }>;
817
+ }, z.core.$strip>>>]>>;
818
+ maximumProjects: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
819
+ type: z.ZodLiteral<"limited">;
820
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
821
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
822
+ displayName: z.ZodReadonly<z.ZodString>;
823
+ }, z.core.$strip>, z.ZodObject<{
824
+ type: z.ZodEnum<{
825
+ limited: "limited";
826
+ }>;
827
+ value: z.ZodInt;
828
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
829
+ type: z.ZodLiteral<"unlimited">;
830
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
831
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
832
+ displayName: z.ZodReadonly<z.ZodString>;
833
+ }, z.core.$strip>, z.ZodObject<{
834
+ type: z.ZodEnum<{
835
+ unlimited: "unlimited";
836
+ }>;
837
+ }, z.core.$strip>>>]>>;
838
+ maximumEnvironments: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
839
+ type: z.ZodLiteral<"limited">;
840
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
841
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
842
+ displayName: z.ZodReadonly<z.ZodString>;
843
+ }, z.core.$strip>, z.ZodObject<{
844
+ type: z.ZodEnum<{
845
+ limited: "limited";
846
+ }>;
847
+ value: z.ZodInt;
848
+ }, z.core.$strip>>>, z.ZodIntersection<z.ZodObject<{
849
+ type: z.ZodLiteral<"unlimited">;
850
+ }, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
851
+ displayDescription: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
852
+ displayName: z.ZodReadonly<z.ZodString>;
853
+ }, z.core.$strip>, z.ZodObject<{
854
+ type: z.ZodEnum<{
855
+ unlimited: "unlimited";
856
+ }>;
857
+ }, z.core.$strip>>>]>>;
858
+ }, z.core.$strip>>;
859
+ }, z.core.$strip>>;
860
+ currentPeriodEnd: z.ZodReadonly<z.ZodInt>;
861
+ scheduledChangeAt: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
862
+ seats: z.ZodReadonly<z.ZodInt>;
863
+ paymentMethods: z.ZodReadonly<z.ZodArray<z.ZodObject<{
864
+ id: z.ZodReadonly<z.ZodString>;
865
+ brand: z.ZodReadonly<z.ZodString>;
866
+ last4: z.ZodReadonly<z.ZodString>;
867
+ expMonth: z.ZodReadonly<z.ZodInt>;
868
+ expYear: z.ZodReadonly<z.ZodInt>;
869
+ isDefault: z.ZodReadonly<z.ZodBoolean>;
870
+ }, z.core.$strip>>>;
871
+ upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
872
+ }, z.core.$strip>;
703
873
  export declare const zGetPlansData: z.ZodObject<{
704
874
  body: z.ZodOptional<z.ZodNever>;
705
875
  path: z.ZodOptional<z.ZodNever>;
@@ -187,6 +187,17 @@ export const zPaymentMethodId = z.string();
187
187
  * Kinde organisation id.
188
188
  */
189
189
  export const zOrganisationId = z.string();
190
+ export const zGetCustomerData = z.object({
191
+ body: z.optional(z.never()),
192
+ path: z.object({
193
+ org: z.string()
194
+ }),
195
+ query: z.optional(z.never())
196
+ });
197
+ /**
198
+ * Customer billing state
199
+ */
200
+ export const zGetCustomerResponse = zCustomerResponse;
190
201
  export const zGetPlansData = z.object({
191
202
  body: z.optional(z.never()),
192
203
  path: z.optional(z.never()),
@@ -1,6 +1,213 @@
1
1
  import { useMutation } from "@tanstack/react-query";
2
2
  import { GetSuccessResponse } from "../util";
3
- import { GetPlansData, UpdatePlanData, UpdatePlanResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
3
+ import { GetCustomerData, GetPlansData, UpdatePlanData, UpdatePlanResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
4
+ export declare const useGetCustomer: (options: Omit<GetCustomerData, "url"> & {
5
+ enabled?: boolean;
6
+ }) => {
7
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
8
+ headers: Record<string, string> | undefined;
9
+ error: Error;
10
+ isError: true;
11
+ isPending: false;
12
+ isLoading: false;
13
+ isLoadingError: false;
14
+ isRefetchError: true;
15
+ isSuccess: false;
16
+ isPlaceholderData: false;
17
+ status: "error";
18
+ dataUpdatedAt: number;
19
+ errorUpdatedAt: number;
20
+ failureCount: number;
21
+ failureReason: Error | null;
22
+ errorUpdateCount: number;
23
+ isFetched: boolean;
24
+ isFetchedAfterMount: boolean;
25
+ isFetching: boolean;
26
+ isInitialLoading: boolean;
27
+ isPaused: boolean;
28
+ isRefetching: boolean;
29
+ isStale: boolean;
30
+ isEnabled: boolean;
31
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
32
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
33
+ headers: Record<string, string>;
34
+ } | undefined, Error>>;
35
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
36
+ promise: Promise<{
37
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
38
+ headers: Record<string, string>;
39
+ } | undefined>;
40
+ } | {
41
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
42
+ headers: Record<string, string> | undefined;
43
+ error: null;
44
+ isError: false;
45
+ isPending: false;
46
+ isLoading: false;
47
+ isLoadingError: false;
48
+ isRefetchError: false;
49
+ isSuccess: true;
50
+ isPlaceholderData: false;
51
+ status: "success";
52
+ dataUpdatedAt: number;
53
+ errorUpdatedAt: number;
54
+ failureCount: number;
55
+ failureReason: Error | null;
56
+ errorUpdateCount: number;
57
+ isFetched: boolean;
58
+ isFetchedAfterMount: boolean;
59
+ isFetching: boolean;
60
+ isInitialLoading: boolean;
61
+ isPaused: boolean;
62
+ isRefetching: boolean;
63
+ isStale: boolean;
64
+ isEnabled: boolean;
65
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
66
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
67
+ headers: Record<string, string>;
68
+ } | undefined, Error>>;
69
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
70
+ promise: Promise<{
71
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
72
+ headers: Record<string, string>;
73
+ } | undefined>;
74
+ } | {
75
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
76
+ headers: Record<string, string> | undefined;
77
+ error: Error;
78
+ isError: true;
79
+ isPending: false;
80
+ isLoading: false;
81
+ isLoadingError: true;
82
+ isRefetchError: false;
83
+ isSuccess: false;
84
+ isPlaceholderData: false;
85
+ status: "error";
86
+ dataUpdatedAt: number;
87
+ errorUpdatedAt: number;
88
+ failureCount: number;
89
+ failureReason: Error | null;
90
+ errorUpdateCount: number;
91
+ isFetched: boolean;
92
+ isFetchedAfterMount: boolean;
93
+ isFetching: boolean;
94
+ isInitialLoading: boolean;
95
+ isPaused: boolean;
96
+ isRefetching: boolean;
97
+ isStale: boolean;
98
+ isEnabled: boolean;
99
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
100
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
101
+ headers: Record<string, string>;
102
+ } | undefined, Error>>;
103
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
104
+ promise: Promise<{
105
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
106
+ headers: Record<string, string>;
107
+ } | undefined>;
108
+ } | {
109
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
110
+ headers: Record<string, string> | undefined;
111
+ error: null;
112
+ isError: false;
113
+ isPending: true;
114
+ isLoading: true;
115
+ isLoadingError: false;
116
+ isRefetchError: false;
117
+ isSuccess: false;
118
+ isPlaceholderData: false;
119
+ status: "pending";
120
+ dataUpdatedAt: number;
121
+ errorUpdatedAt: number;
122
+ failureCount: number;
123
+ failureReason: Error | null;
124
+ errorUpdateCount: number;
125
+ isFetched: boolean;
126
+ isFetchedAfterMount: boolean;
127
+ isFetching: boolean;
128
+ isInitialLoading: boolean;
129
+ isPaused: boolean;
130
+ isRefetching: boolean;
131
+ isStale: boolean;
132
+ isEnabled: boolean;
133
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
134
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
135
+ headers: Record<string, string>;
136
+ } | undefined, Error>>;
137
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
138
+ promise: Promise<{
139
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
140
+ headers: Record<string, string>;
141
+ } | undefined>;
142
+ } | {
143
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
144
+ headers: Record<string, string> | undefined;
145
+ error: null;
146
+ isError: false;
147
+ isPending: true;
148
+ isLoadingError: false;
149
+ isRefetchError: false;
150
+ isSuccess: false;
151
+ isPlaceholderData: false;
152
+ status: "pending";
153
+ dataUpdatedAt: number;
154
+ errorUpdatedAt: number;
155
+ failureCount: number;
156
+ failureReason: Error | null;
157
+ errorUpdateCount: number;
158
+ isFetched: boolean;
159
+ isFetchedAfterMount: boolean;
160
+ isFetching: boolean;
161
+ isLoading: boolean;
162
+ isInitialLoading: boolean;
163
+ isPaused: boolean;
164
+ isRefetching: boolean;
165
+ isStale: boolean;
166
+ isEnabled: boolean;
167
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
168
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
169
+ headers: Record<string, string>;
170
+ } | undefined, Error>>;
171
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
172
+ promise: Promise<{
173
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
174
+ headers: Record<string, string>;
175
+ } | undefined>;
176
+ } | {
177
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
178
+ headers: Record<string, string> | undefined;
179
+ isError: false;
180
+ error: null;
181
+ isPending: false;
182
+ isLoading: false;
183
+ isLoadingError: false;
184
+ isRefetchError: false;
185
+ isSuccess: true;
186
+ isPlaceholderData: true;
187
+ status: "success";
188
+ dataUpdatedAt: number;
189
+ errorUpdatedAt: number;
190
+ failureCount: number;
191
+ failureReason: Error | null;
192
+ errorUpdateCount: number;
193
+ isFetched: boolean;
194
+ isFetchedAfterMount: boolean;
195
+ isFetching: boolean;
196
+ isInitialLoading: boolean;
197
+ isPaused: boolean;
198
+ isRefetching: boolean;
199
+ isStale: boolean;
200
+ isEnabled: boolean;
201
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
202
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
203
+ headers: Record<string, string>;
204
+ } | undefined, Error>>;
205
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
206
+ promise: Promise<{
207
+ data: import("../../sdk/billing/types.gen").CustomerResponse | undefined;
208
+ headers: Record<string, string>;
209
+ } | undefined>;
210
+ };
4
211
  export declare const useGetPlans: (options?: Omit<GetPlansData, "url"> & {
5
212
  enabled?: boolean;
6
213
  }) => {
@@ -2,7 +2,29 @@
2
2
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
3
  import { isPromise, headersToObject } from "../util";
4
4
  import { useToken } from "../../provider/token-provider";
5
- import { getPlans, updatePlan, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
5
+ import { getCustomer, getPlans, updatePlan, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
6
+ export const useGetCustomer = (options) => {
7
+ const token = useToken();
8
+ let { enabled, ...rest } = options || { enabled: true };
9
+ const opts = { throwOnError: true, url: "/api/v1/customer/{org}" };
10
+ const funcer = async () => {
11
+ const auth = isPromise(token) ? (await token) || "" : token || "";
12
+ if (isPromise(token) && !token)
13
+ return;
14
+ const res = await getCustomer({ ...opts, ...rest, auth });
15
+ return { data: res.data, headers: headersToObject(res.response.headers) };
16
+ };
17
+ if (!token)
18
+ enabled = false;
19
+ const query = useQuery({
20
+ queryKey: ["api", "v1", "customer", options?.path?.org, options.query ?? {}],
21
+ queryFn: funcer,
22
+ enabled,
23
+ retry: false,
24
+ staleTime: 600000
25
+ });
26
+ return { ...query, data: query.data?.data, headers: query.data?.headers };
27
+ };
6
28
  export const useGetPlans = (options) => {
7
29
  const token = useToken();
8
30
  let { enabled, ...rest } = options || { enabled: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoal-web-sdk",
3
- "version": "1.0.88",
3
+ "version": "1.0.89",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build-hooks": "npx tsx tanstack-codegen/generator.ts",