@compilot/react-sdk 2.0.48-dev

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 (28) hide show
  1. package/dist/compilot-react-sdk.cjs.d.ts +2 -0
  2. package/dist/compilot-react-sdk.cjs.dev.js +1021 -0
  3. package/dist/compilot-react-sdk.cjs.js +7 -0
  4. package/dist/compilot-react-sdk.cjs.prod.js +1021 -0
  5. package/dist/compilot-react-sdk.esm.js +1006 -0
  6. package/dist/declarations/src/configuration/ComPilotProvider.d.ts +67 -0
  7. package/dist/declarations/src/configuration/ComPilotProvider.d.ts.map +1 -0
  8. package/dist/declarations/src/hooks/index.d.ts +6 -0
  9. package/dist/declarations/src/hooks/index.d.ts.map +1 -0
  10. package/dist/declarations/src/hooks/useCustomerStatus.d.ts +42 -0
  11. package/dist/declarations/src/hooks/useCustomerStatus.d.ts.map +1 -0
  12. package/dist/declarations/src/hooks/useDisconnect.d.ts +28 -0
  13. package/dist/declarations/src/hooks/useDisconnect.d.ts.map +1 -0
  14. package/dist/declarations/src/hooks/useGetTxAuthDataSignature.d.ts +168 -0
  15. package/dist/declarations/src/hooks/useGetTxAuthDataSignature.d.ts.map +1 -0
  16. package/dist/declarations/src/hooks/useIsAuthenticated.d.ts +10 -0
  17. package/dist/declarations/src/hooks/useIsAuthenticated.d.ts.map +1 -0
  18. package/dist/declarations/src/hooks/useOpenWidget.d.ts +51 -0
  19. package/dist/declarations/src/hooks/useOpenWidget.d.ts.map +1 -0
  20. package/dist/declarations/src/index.d.ts +4 -0
  21. package/dist/declarations/src/index.d.ts.map +1 -0
  22. package/dist/declarations/src/utils/useAsyncMutationState.d.ts +43 -0
  23. package/dist/declarations/src/utils/useAsyncMutationState.d.ts.map +1 -0
  24. package/dist/declarations/src/utils/useAsyncQueryState.d.ts +36 -0
  25. package/dist/declarations/src/utils/useAsyncQueryState.d.ts.map +1 -0
  26. package/dist/package.json +63 -0
  27. package/package.json +62 -0
  28. package/readme.md +15 -0
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ import type { Config } from "@compilot/web-sdk";
3
+ /**
4
+ * The props type of {@link ComPilotProvider}.
5
+ *
6
+ * @category PropTypes
7
+ */
8
+ export type ComPilotProviderProps = {
9
+ /**
10
+ * The ComPilot configuration object.
11
+ * @see {@link Config}
12
+ */
13
+ config: Config;
14
+ /**
15
+ * Whether to automatically load the ComPilot SDK resources.
16
+ * @default true
17
+ */
18
+ autoLoad?: boolean;
19
+ /**
20
+ * The children components to render.
21
+ */
22
+ children: React.ReactNode;
23
+ };
24
+ /**
25
+ * ComPilotProvider is a React Context Provider that provides the ComPilot configuration to the rest of the application.
26
+ *
27
+ * @param props - The props of the ComPilotProvider component.
28
+ *
29
+ * @category Component
30
+ *
31
+ * @example
32
+ *
33
+ * Basic
34
+ * ```tsx
35
+ * import { ComPilotProvider } from "@compilot/react-sdk";
36
+ * import { config } from "./config";
37
+ *
38
+ * const App = () => {
39
+ * return (
40
+ * <ComPilotProvider config={config}>
41
+ * <MyApp />
42
+ * </ComPilotProvider>
43
+ * );
44
+ * };
45
+ * ```
46
+ *
47
+ * With AutoLoader disabled
48
+ * ```tsx
49
+ * import { ComPilotProvider } from "@compilot/react-sdk";
50
+ * import { config } from "./config";
51
+ *
52
+ * const App = () => {
53
+ * return (
54
+ * <ComPilotProvider config={config} autoLoad={false}>
55
+ * <MyApp />
56
+ * </ComPilotProvider>
57
+ * );
58
+ * };
59
+ * ```
60
+ */
61
+ export declare const ComPilotProvider: ({ config, autoLoad: autoLoad, children, }: ComPilotProviderProps) => React.JSX.Element;
62
+ /**
63
+ * A hook to access the ComPilot configuration object.
64
+ * @private This hook is intended for internal use only.
65
+ */
66
+ export declare const useComPilotConfig: () => Config;
67
+ //# sourceMappingURL=ComPilotProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComPilotProvider.d.ts","sourceRoot":"../../../../src/configuration","sources":["ComPilotProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAMhD;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,8CAI1B,qBAAqB,sBAMvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAMpC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./useOpenWidget.js";
2
+ export * from "./useGetTxAuthDataSignature.js";
3
+ export * from "./useIsAuthenticated.js";
4
+ export * from "./useCustomerStatus.js";
5
+ export * from "./useDisconnect.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/hooks","sources":["index.ts"],"names":[],"mappings":"AAAA,mCAAgC;AAChC,+CAA4C;AAC5C,wCAAqC;AACrC,uCAAoC;AACpC,mCAAgC"}
@@ -0,0 +1,42 @@
1
+ import type { CustomerStatus } from "@nexeraid/identity-schemas";
2
+ import type { AsyncQueryState } from "../utils/useAsyncQueryState.js";
3
+ /**
4
+ * The parameters of the {@link useCustomerStatus} hook.
5
+ *
6
+ * @category Parameter Types
7
+ */
8
+ export type UseCustomerStatusParams = {
9
+ /**
10
+ * The interval in milliseconds to refresh the customer status.
11
+ * @default 10000
12
+ */
13
+ refreshInterval: number;
14
+ };
15
+ /**
16
+ * A hook that returns the current customer status.
17
+ *
18
+ * @param params {@link UseCustomerStatusParams}
19
+ *
20
+ * @returns The async query state of the customer status.
21
+ *
22
+ * @category Hook
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * import { useCustomerStatus } from "@compilot/react-sdk";
27
+ *
28
+ * const MyComponent = () => {
29
+ * const { data: status } = useCustomerStatus();
30
+ * const isVerified = status === "Active";
31
+ *
32
+ * return <div>User is verified: {isVerified}</div>;
33
+ * };
34
+ * ```
35
+ *
36
+ * Output:
37
+ * ```tsx
38
+ * <div>User is verified: true</div>
39
+ * ```
40
+ */
41
+ export declare const useCustomerStatus: ({ refreshInterval }?: UseCustomerStatusParams) => AsyncQueryState<CustomerStatus | null>;
42
+ //# sourceMappingURL=useCustomerStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCustomerStatus.d.ts","sourceRoot":"../../../../src/hooks","sources":["useCustomerStatus.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAoC;AAGnE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,yBACP,uBAAuB,KAG3C,eAAe,CAAC,cAAc,GAAG,IAAI,CA2CvC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
2
+ /**
3
+ * A hook that returns a function that disconnects the ComPilot SDK.
4
+ *
5
+ * @returns The async mutation state of the disconnect function.
6
+ *
7
+ * @category Hook
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { useDisconnect } from "@compilot/react-sdk";
12
+ *
13
+ * const Logout = () => {
14
+ * const { mutateAsync: disconnect, isLoading } = useDisconnect();
15
+ *
16
+ * return (
17
+ * <button
18
+ * disabled={isLoading}
19
+ * onClick={disconnect}
20
+ * >
21
+ * Logout
22
+ * </button>;
23
+ * );
24
+ * };
25
+ * ```
26
+ */
27
+ export declare const useDisconnect: () => AsyncMutationState<() => Promise<boolean>>;
28
+ //# sourceMappingURL=useDisconnect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDisconnect.d.ts","sourceRoot":"../../../../src/hooks","sources":["useDisconnect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,0CAAuC;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,QAAO,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAQzE,CAAC"}
@@ -0,0 +1,168 @@
1
+ import type { ExtendedTezosTxAuthDataSignatureResponse, ExtendedTezosTxAuthInput, ExtendedTxAuthDataSignatureResponse, ExtendedTxAuthInput } from "@nexeraid/identity-schemas";
2
+ import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
3
+ /**
4
+ * A callback that returns a transaction authorization data signature.
5
+ *
6
+ * @category Callback
7
+ */
8
+ export type TxAuthDataSignatureCallback = {
9
+ /**
10
+ * Returns a transaction authorization data signature for eip155 transactions.
11
+ */
12
+ (input: ExtendedTxAuthInput): Promise<ExtendedTxAuthDataSignatureResponse>;
13
+ /**
14
+ * Returns a transaction authorization data signature for Tezos transactions.
15
+ */
16
+ (input: ExtendedTezosTxAuthInput): Promise<ExtendedTezosTxAuthDataSignatureResponse>;
17
+ };
18
+ /**
19
+ * A hook that returns a function that returns a transaction authorization data signature.
20
+ *
21
+ * @returns A function that returns a transaction authorization data signature.
22
+ *
23
+ * @category Hook
24
+ *
25
+ * @example
26
+ *
27
+ * ### EIP-155 Transaction Wagmi Example
28
+ * ```tsx
29
+ * import { useGetTxAuthDataSignature } from "@compilot/react-sdk";
30
+ * import { waitForTransactionReceipt } from "viem/actions";
31
+ * import { encodeFunctionData } from "viem";
32
+ * import { usePublicClient, useWalletClient } from "wagmi";
33
+ *
34
+ * const MyComponent = () => {
35
+ *
36
+ * const { mutateAsync: getTxAuthDataSignature } = useGetTxAuthDataSignature();
37
+ * const walletClient = useWalletClient();
38
+ * const publicClient = usePublicClient();
39
+ *
40
+ * const gatedNftMint = async () => {
41
+ *
42
+ * // Get signature for the given parameters
43
+ * const signatureResponse = await getTxAuthDataSignature({
44
+ * namespace: "eip155",
45
+ * contractAbi,
46
+ * contractAddress,
47
+ * functionName: "mintNFTGated",
48
+ * args: [account.address],
49
+ * userAddress: account.address,
50
+ * chainId: EvmChainId.parse(chainId),
51
+ * });
52
+ *
53
+ * if (!signatureResponse.isAuthorized) {
54
+ * throw new Error("User is not authorized");
55
+ * }
56
+ *
57
+ * // Mint Gated Nft with signature
58
+ * const unsignedTx = encodeFunctionData({
59
+ * abi: contractAbi,
60
+ * functionName: "mintNFTGated",
61
+ * args: [account.address],
62
+ * });
63
+ *
64
+ * // Build the raw transaction data with the signature
65
+ * const txData = (unsignedTx + signatureResponse.payload) as `0x${string}`;
66
+ *
67
+ * // try to mint nft
68
+ * const tx = await walletClient.data.sendTransaction({
69
+ * to: contractAddress,
70
+ * data: txData,
71
+ * });
72
+ *
73
+ * const receipt = await waitForTransactionReceipt(publicClient, {
74
+ * hash: tx,
75
+ * });
76
+ *
77
+ * return receipt;
78
+ * };
79
+ *
80
+ * return <button onClick={gatedNftMint}>Mint Gated NFT</button>;
81
+ * };
82
+ * ```
83
+ *
84
+ * ### Tezos Transaction Example
85
+ *
86
+ * ```tsx
87
+ * import { useGetTxAuthDataSignature } from "@compilot/react-sdk";
88
+ * import { packDataBytes, Parser } from "@taquito/michel-codec";
89
+ * import type { MichelsonData, MichelsonType } from "@taquito/michel-codec";
90
+ * import { RpcClient } from "@taquito/rpc";
91
+ *
92
+ * const MyComponent = () => {
93
+ * const { mutateAsync: getTxAuthDataSignature } = useGetTxAuthDataSignature();
94
+ * const wallet = useWallet();
95
+ *
96
+ * const signAndSend = async () => {
97
+ *
98
+ * // prepare the mint function call
99
+ * const storage: any = await claimerContract.storage();
100
+ * const lastAssetId = storage.siggated_extension.extension.lastMinted.toNumber() as number;
101
+ * const functionCallArgs = {
102
+ * owner: userAddress,
103
+ * token_id: (lastAssetId + 1).toString(), //"1",
104
+ * };
105
+ * const functionCallArgsBytes = convertMint(
106
+ * functionCallArgs.owner,
107
+ * functionCallArgs.token_id,
108
+ * );
109
+ *
110
+ * // Get signature for the given parameters
111
+ * const signatureResponse = await getTxAuthDataSignature({
112
+ * namespace: "tezos",
113
+ * contractAddress: "KT1JN7a2es4Ne8SuePZU7YrHKG49hfgCCyBK",
114
+ * functionName: "%mint_gated%",
115
+ * args: functionCallArgsBytes,
116
+ * chainID: TezosChainId.parse(currentChainId),
117
+ * userAddress: userAddress as TezosImplicitAddress,
118
+ * });
119
+ *
120
+ * // Check if the user is authorized
121
+ * if (!signatureResponse.isAuthorized) {
122
+ * return {
123
+ * signatureResponse: {
124
+ * isAuthorized: false,
125
+ * signature: "None",
126
+ * },
127
+ * };
128
+ * }
129
+ *
130
+ * // Mint Gated Nft with signature
131
+ * const op = await claimerContract.methodsObject
132
+ * .mint_gated({
133
+ * userAddress,
134
+ * expirationBlock: signatureResponse.blockExpiration,
135
+ * functionName,
136
+ * functionArgs: functionCallArgsBytes,
137
+ * signerPublicKey: COMPILOT_SIGNER_PK,
138
+ * signature: signatureResponse.signature,
139
+ * })
140
+ * .send();
141
+ * await op.confirmation(2);
142
+ * };
143
+ * return <button onClick={signAndSend}>Sign and Send</button>;
144
+ * };
145
+ *
146
+ *
147
+ * // Helper function to convert mint function to bytes
148
+ * function convertMint(owner_str: string, token_id: string) {
149
+ * const data = `(Pair "${owner_str}" ${token_id})`;
150
+ * const type = `(pair address nat)`;
151
+ * const p = new Parser();
152
+ * const dataJSON = p.parseMichelineExpression(data);
153
+ * const typeJSON = p.parseMichelineExpression(type);
154
+ * const packed = packDataBytes(
155
+ * dataJSON as MichelsonData,
156
+ * typeJSON as MichelsonType,
157
+ * );
158
+ * return packed.bytes;
159
+ * }
160
+ *
161
+ * // Tezos signer public key
162
+ * const COMPILOT_SIGNER_PK = "edpkurPsQ8eUApnLUJ9ZPDvu98E8VNj4KtJa1aZr16Cr5ow5VHKnz4";
163
+ * const client = new RpcClient("https://rpc.ghostnet.teztnets.com/");
164
+ * ```
165
+ *
166
+ */
167
+ export declare const useGetTxAuthDataSignature: () => AsyncMutationState<TxAuthDataSignatureCallback>;
168
+ //# sourceMappingURL=useGetTxAuthDataSignature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetTxAuthDataSignature.d.ts","sourceRoot":"../../../../src/hooks","sources":["useGetTxAuthDataSignature.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wCAAwC,EACxC,wBAAwB,EACxB,mCAAmC,EACnC,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,0CAAuC;AAGzE;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC3E;;OAEG;IACH,CACE,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,wCAAwC,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AACH,eAAO,MAAM,yBAAyB,QAChC,kBAAkB,CAAC,2BAA2B,CAcjD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AsyncQueryState } from "../utils/useAsyncQueryState.js";
2
+ /**
3
+ * A hook that returns whether the user is authenticated.
4
+ *
5
+ * @returns Whether the user is authenticated or not.
6
+ *
7
+ * @category Hook
8
+ */
9
+ export declare const useIsAuthenticated: () => AsyncQueryState<boolean>;
10
+ //# sourceMappingURL=useIsAuthenticated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsAuthenticated.d.ts","sourceRoot":"../../../../src/hooks","sources":["useIsAuthenticated.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAoC;AAGnE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAAe,CAAC,OAAO,CAyB5D,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { LoginParams } from "@compilot/web-sdk";
2
+ /**
3
+ * A hook that returns a function that opens the ComPilot ID widget.
4
+ *
5
+ * @param loginParams - The login parameters to use when opening the widget.
6
+ * @returns The async mutation state of the widget opening.
7
+ *
8
+ * @category Hook
9
+ */
10
+ export declare const useOpenWidget: (loginParams?: LoginParams) => {
11
+ mutateAsync: () => Promise<void>;
12
+ data: undefined;
13
+ isIdle: true;
14
+ isPending: false;
15
+ isError: false;
16
+ isSuccess: false;
17
+ error: null;
18
+ } | {
19
+ mutateAsync: () => Promise<void>;
20
+ data: void;
21
+ isIdle: false;
22
+ isPending: false;
23
+ isError: false;
24
+ isSuccess: true;
25
+ error: null;
26
+ } | {
27
+ mutateAsync: () => Promise<void>;
28
+ data: undefined;
29
+ isIdle: false;
30
+ isPending: true;
31
+ isError: false;
32
+ isSuccess: false;
33
+ error: null;
34
+ } | {
35
+ mutateAsync: () => Promise<void>;
36
+ data: void | undefined;
37
+ isIdle: false;
38
+ isPending: false;
39
+ isError: true;
40
+ isSuccess: false;
41
+ error: Error;
42
+ } | {
43
+ mutateAsync: () => Promise<void>;
44
+ error: null;
45
+ isPending: false;
46
+ isSuccess: true;
47
+ isError: false;
48
+ isIdle: false;
49
+ data: boolean;
50
+ };
51
+ //# sourceMappingURL=useOpenWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOpenWidget.d.ts","sourceRoot":"../../../../src/hooks","sources":["useOpenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iBAAkB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDtD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./configuration/ComPilotProvider.js";
2
+ export * from "./hooks/index.js";
3
+ export * from "@compilot/web-sdk";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,oDAAiD;AACjD,iCAAwB;AACxB,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,43 @@
1
+ type AnyMutation = (...args: any[]) => Promise<any>;
2
+ export type IdleAsyncMutationState<T extends AnyMutation> = {
3
+ data: undefined;
4
+ isIdle: true;
5
+ isPending: false;
6
+ isError: false;
7
+ isSuccess: false;
8
+ error: null;
9
+ mutateAsync: T;
10
+ };
11
+ export type SuccessAsyncMutationState<T extends AnyMutation> = {
12
+ data: Awaited<ReturnType<T>>;
13
+ isIdle: false;
14
+ isPending: false;
15
+ isError: false;
16
+ isSuccess: true;
17
+ error: null;
18
+ mutateAsync: T;
19
+ };
20
+ export type LoadingAsyncMutationState<T extends AnyMutation> = {
21
+ data: undefined;
22
+ isIdle: false;
23
+ isPending: true;
24
+ isError: false;
25
+ isSuccess: false;
26
+ error: null;
27
+ mutateAsync: T;
28
+ };
29
+ export type ErrorAsyncMutationState<T extends AnyMutation> = {
30
+ data: Awaited<ReturnType<T>> | undefined;
31
+ isIdle: false;
32
+ isPending: false;
33
+ isError: true;
34
+ isSuccess: false;
35
+ error: Error;
36
+ mutateAsync: T;
37
+ };
38
+ export type AsyncMutationState<T extends AnyMutation> = IdleAsyncMutationState<T> | SuccessAsyncMutationState<T> | LoadingAsyncMutationState<T> | ErrorAsyncMutationState<T>;
39
+ export declare const useAsyncMutationState: <T extends AnyMutation>({ mutationFn, }: {
40
+ mutationFn: T;
41
+ }) => AsyncMutationState<T>;
42
+ export {};
43
+ //# sourceMappingURL=useAsyncMutationState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsyncMutationState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncMutationState.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpD,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC1D,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC7D,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC7D,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC3D,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACzC,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAChD,sBAAsB,CAAC,CAAC,CAAC,GACzB,yBAAyB,CAAC,CAAC,CAAC,GAC5B,yBAAyB,CAAC,CAAC,CAAC,GAC5B,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAE/B,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,WAAW,mBAExD;IACD,UAAU,EAAE,CAAC,CAAC;CACf,KAAG,kBAAkB,CAAC,CAAC,CAuDvB,CAAC"}
@@ -0,0 +1,36 @@
1
+ export type InitialAsyncQueryState = {
2
+ isLoading: false;
3
+ isError: false;
4
+ isSuccess: false;
5
+ error: null;
6
+ data: undefined;
7
+ };
8
+ export type SuccessAsyncQueryState<T> = {
9
+ isLoading: false;
10
+ isError: false;
11
+ isSuccess: true;
12
+ error: null;
13
+ data: T;
14
+ };
15
+ export type LoadingAsyncQueryState = {
16
+ isLoading: true;
17
+ isError: false;
18
+ isSuccess: false;
19
+ error: null;
20
+ data: undefined;
21
+ };
22
+ export type ErrorAsyncQueryState = {
23
+ isLoading: false;
24
+ isError: true;
25
+ isSuccess: false;
26
+ error: Error;
27
+ data: undefined;
28
+ };
29
+ export type AsyncQueryState<T> = InitialAsyncQueryState | SuccessAsyncQueryState<T> | LoadingAsyncQueryState | ErrorAsyncQueryState;
30
+ export declare const useAsyncQueryState: <T>(defaultValue?: T) => {
31
+ state: AsyncQueryState<T>;
32
+ setResult: (result: T) => void;
33
+ setError: (error: Error) => void;
34
+ startLoading: () => void;
35
+ };
36
+ //# sourceMappingURL=useAsyncQueryState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsyncQueryState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncQueryState.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB,sBAAsB,GACtB,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,GACtB,oBAAoB,CAAC;AAEzB,eAAO,MAAM,kBAAkB,GAAI,CAAC,iBAAiB,CAAC;;wBAoBzC,CAAC;sBAaF,KAAK;;CA4BhB,CAAC"}
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@compilot/react-sdk",
3
+ "version": "2.0.48",
4
+ "description": "ComPilot React SDK",
5
+ "keywords": [],
6
+ "license": "ISC",
7
+ "author": "",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/compilot-react-sdk.esm.js",
11
+ "require": "./dist/compilot-react-sdk.cjs.js"
12
+ }
13
+ },
14
+ "main": "dist/compilot-react-sdk.cjs.js",
15
+ "module": "dist/compilot-react-sdk.esm.js",
16
+ "types": "dist/compilot-react-sdk.cjs.d.ts",
17
+ "files": [
18
+ "/dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "preconstruct build && npm run copy-package-json-to-dist",
22
+ "copy-package-json-to-dist": "copyfiles package.json dist/",
23
+ "postinstall": "if [ \"$BUILDING_IN_DOCKER\" != \"true\" ]; then preconstruct dev; fi",
24
+ "lint": "eslint .",
25
+ "lint:fix": "pnpm lint --fix",
26
+ "prepare:release": "sed -i 's/.*\"postinstall\":.*//' package.json",
27
+ "prepare:release:mac": "sed -i '' 's/.*\"postinstall\":.*//' package.json",
28
+ "prettier": "prettier 'src/' --check",
29
+ "prettier:fix": "prettier 'src/' --write",
30
+ "publish:public": "pnpm run prepare:release && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
31
+ "publish:public:mac": "pnpm run prepare:release:mac && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
32
+ "test": "vitest --config ./vitest.config.ts",
33
+ "type-check": "tsc --noEmit"
34
+ },
35
+ "eslintConfig": {
36
+ "extends": [
37
+ "@unblokttechnology/eslint-config/base"
38
+ ],
39
+ "root": true
40
+ },
41
+ "dependencies": {
42
+ "@compilot/web-sdk": "workspace:*",
43
+ "@nexeraid/identity-api-client": "workspace:*",
44
+ "@nexeraid/identity-schemas": "workspace:*",
45
+ "@nexeraid/logger": "workspace:*",
46
+ "pino": "^9.4.0",
47
+ "zod": "^3.23.8"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=17.0.0 <20.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/react": "^18.3.7",
54
+ "@unblokttechnology/eslint-config": "workspace:*",
55
+ "prettier": "^3.3.3",
56
+ "typescript": "^5.6.2"
57
+ },
58
+ "preconstruct": {
59
+ "entrypoints": [
60
+ "index.ts"
61
+ ]
62
+ }
63
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@compilot/react-sdk",
3
+ "version": "2.0.48-dev",
4
+ "description": "ComPilot React SDK",
5
+ "keywords": [],
6
+ "license": "ISC",
7
+ "author": "",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/compilot-react-sdk.esm.js",
11
+ "require": "./dist/compilot-react-sdk.cjs.js"
12
+ }
13
+ },
14
+ "main": "dist/compilot-react-sdk.cjs.js",
15
+ "module": "dist/compilot-react-sdk.esm.js",
16
+ "types": "dist/compilot-react-sdk.cjs.d.ts",
17
+ "files": [
18
+ "/dist"
19
+ ],
20
+ "eslintConfig": {
21
+ "extends": [
22
+ "@unblokttechnology/eslint-config/base"
23
+ ],
24
+ "root": true
25
+ },
26
+ "dependencies": {
27
+ "pino": "^9.4.0",
28
+ "zod": "^3.23.8",
29
+ "@compilot/web-sdk": "2.0.41-dev",
30
+ "@nexeraid/identity-api-client": "1.3.215-dev",
31
+ "@nexeraid/identity-schemas": "1.12.38-dev",
32
+ "@nexeraid/logger": "0.1.2-dev"
33
+ },
34
+ "peerDependencies": {
35
+ "react": ">=17.0.0 <20.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "^18.3.7",
39
+ "prettier": "^3.3.3",
40
+ "typescript": "^5.6.2",
41
+ "@unblokttechnology/eslint-config": "0.1.1"
42
+ },
43
+ "preconstruct": {
44
+ "entrypoints": [
45
+ "index.ts"
46
+ ]
47
+ },
48
+ "scripts": {
49
+ "build": "preconstruct build && npm run copy-package-json-to-dist",
50
+ "copy-package-json-to-dist": "copyfiles package.json dist/",
51
+ "lint": "eslint .",
52
+ "lint:fix": "pnpm lint --fix",
53
+ "prepare:release": "sed -i 's/.*\"postinstall\":.*//' package.json",
54
+ "prepare:release:mac": "sed -i '' 's/.*\"postinstall\":.*//' package.json",
55
+ "prettier": "prettier 'src/' --check",
56
+ "prettier:fix": "prettier 'src/' --write",
57
+ "publish:public": "pnpm run prepare:release && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
58
+ "publish:public:mac": "pnpm run prepare:release:mac && publish --access=public --no-git-checks --registry https://registry.npmjs.org/",
59
+ "test": "vitest --config ./vitest.config.ts",
60
+ "type-check": "tsc --noEmit"
61
+ }
62
+ }
package/readme.md ADDED
@@ -0,0 +1,15 @@
1
+ # ComPilot React SDK
2
+
3
+ ComPilot React SDK, use anywhere React runs.
4
+
5
+ This is a collection of React bindings for @compilot/web-sdk.
6
+
7
+ ## How to install
8
+
9
+ ```bash
10
+ npm install @compilot/react-sdk
11
+ ```
12
+
13
+ ### First steps
14
+
15
+ Please refer to the [ComPilot SDKs](../index.md) documentation for more information on how to get started.