@quiltt/core 4.3.3 → 4.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @quiltt/core
2
2
 
3
+ ## 4.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#386](https://github.com/quiltt/quiltt-js/pull/386) [`0bf706c`](https://github.com/quiltt/quiltt-js/commit/0bf706ce2ad926304d6eac739ee58971736f913e) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Update platform webview props
8
+
9
+ ### Patch Changes
10
+
11
+ - [#380](https://github.com/quiltt/quiltt-js/pull/380) [`31cd190`](https://github.com/quiltt/quiltt-js/commit/31cd1902618ebc2314d42dd7aca81b3ab94068ea) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Improve useQuilttResolvable error messaging
12
+
13
+ ## 4.4.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#378](https://github.com/quiltt/quiltt-js/pull/378) [`0af4e66`](https://github.com/quiltt/quiltt-js/commit/0af4e6622d1542e0c0c02ac7e897e3e4f9219cbd) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Add connector institution search and provider migration support.
18
+
19
+ ## New APIs
20
+
21
+ ### `useQuilttResolvable` Hook
22
+
23
+ Check if external provider institution IDs (e.g., Plaid) can be migrated to your connector.
24
+
25
+ ```typescript
26
+ import { useQuilttResolvable } from "@quiltt/react";
27
+ import { useEffect } from "react";
28
+
29
+ function ResolvableConnector({ plaidInstitutionId, children }) {
30
+ const { checkResolvable, isResolvable, isLoading } =
31
+ useQuilttResolvable("my-connector-id");
32
+
33
+ useEffect(() => {
34
+ checkResolvable({ plaid: plaidInstitutionId });
35
+ }, [plaidInstitutionId]);
36
+
37
+ if (isLoading) return <div>Checking...</div>;
38
+ if (!isResolvable) return null;
39
+
40
+ return <>{children}</>;
41
+ }
42
+
43
+ // Usage
44
+ <ResolvableConnector plaidInstitutionId="ins_3">
45
+ <QuilttButton connectorId="my-connector-id" />
46
+ </ResolvableConnector>;
47
+ ```
48
+
3
49
  ## 4.3.3
4
50
 
5
51
  ### Patch Changes
@@ -5,7 +5,7 @@ import { createConsumer } from '@rails/actioncable';
5
5
  import { print } from 'graphql';
6
6
 
7
7
  var name = "@quiltt/core";
8
- var version$1 = "4.3.3";
8
+ var version$1 = "4.5.0";
9
9
 
10
10
  const QUILTT_API_INSECURE = (()=>{
11
11
  try {
package/dist/index.d.ts CHANGED
@@ -283,9 +283,14 @@ type InstitutionData = {
283
283
  logoUrl: string;
284
284
  };
285
285
  type InstitutionsData = Array<InstitutionData>;
286
+ type ResolvableData = {
287
+ resolvable: boolean;
288
+ };
286
289
  type Search = InstitutionsData | ErrorData | UnauthorizedData;
290
+ type Resolvable = ResolvableData | ErrorData | UnauthorizedData;
287
291
  type SearchResponse = FetchResponse<InstitutionsData>;
288
- declare class InstitutionsAPI {
292
+ type ResolvableResponse = FetchResponse<ResolvableData>;
293
+ declare class ConnectorsAPI {
289
294
  clientId: string;
290
295
  agent: string;
291
296
  constructor(clientId: string, agent?: string);
@@ -293,9 +298,25 @@ declare class InstitutionsAPI {
293
298
  * Response Statuses:
294
299
  * - 200: OK -> Institutions Found
295
300
  * - 401: Unauthorized -> Invalid Token
301
+ * - 403: Forbidden -> Unsupported SDK
296
302
  * - 400: Bad Request -> Invalid Request
297
303
  */
298
- search: (token: string, connectorId: string, term: string, signal?: AbortSignal) => Promise<FetchResponse<Search>>;
304
+ searchInstitutions: (token: string, connectorId: string, term: string, signal?: AbortSignal) => Promise<FetchResponse<Search>>;
305
+ /**
306
+ * Response Statuses:
307
+ * - 200: OK -> Provider API ID is resolvable or not
308
+ * - 401: Unauthorized -> Invalid Token
309
+ * - 403: Forbidden -> Unsupported SDK
310
+ * - 400: Bad Request -> Missing provider API ID parameter
311
+ * - 404: Not Found -> Connector not found
312
+ */
313
+ checkResolvable: (token: string, connectorId: string, providerId: {
314
+ plaid?: string;
315
+ mock?: string;
316
+ mx?: string;
317
+ finicity?: string;
318
+ akoya?: string;
319
+ }, signal?: AbortSignal) => Promise<FetchResponse<Resolvable>>;
299
320
  private config;
300
321
  private validateStatus;
301
322
  }
@@ -475,5 +496,5 @@ declare class Timeoutable {
475
496
  private broadcast;
476
497
  }
477
498
 
478
- export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, InstitutionsAPI, JsonWebTokenParse, LocalStorage, MemoryStorage, Observable, QuilttClient, RetryLink, Storage, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointRest, endpointWebsockets, version };
479
- export type { BadRequestResponse, Claims, ConnectorSDK, ConnectorSDKCallbackMetadata, ConnectorSDKCallbacks, ConnectorSDKConnectOptions, ConnectorSDKConnector, ConnectorSDKConnectorOptions, ConnectorSDKOnEventCallback, ConnectorSDKOnEventExitCallback, ConnectorSDKOnExitAbortCallback, ConnectorSDKOnExitErrorCallback, ConnectorSDKOnExitSuccessCallback, ConnectorSDKOnLoadCallback, ConnectorSDKOnOpenCallback, ConnectorSDKReconnectOptions, DeepPartial, DeepReadonly, ErrorData, Exact, InputMaybe, InstitutionData, InstitutionsData, JsonWebToken, MakeMaybe, MakeOptional, Maybe, Mutable, NoContentData, Nullable, Observer, PasscodePayload, PrivateClaims, QuilttClientOptions, QuilttJWT, RegisteredClaims, SearchResponse, SessionResponse, UnauthorizedData, UnauthorizedResponse, UnprocessableData, UnprocessableResponse, UsernamePayload };
499
+ export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ConnectorsAPI, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, JsonWebTokenParse, LocalStorage, MemoryStorage, Observable, QuilttClient, RetryLink, Storage, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointRest, endpointWebsockets, version };
500
+ export type { BadRequestResponse, Claims, ConnectorSDK, ConnectorSDKCallbackMetadata, ConnectorSDKCallbacks, ConnectorSDKConnectOptions, ConnectorSDKConnector, ConnectorSDKConnectorOptions, ConnectorSDKOnEventCallback, ConnectorSDKOnEventExitCallback, ConnectorSDKOnExitAbortCallback, ConnectorSDKOnExitErrorCallback, ConnectorSDKOnExitSuccessCallback, ConnectorSDKOnLoadCallback, ConnectorSDKOnOpenCallback, ConnectorSDKReconnectOptions, DeepPartial, DeepReadonly, ErrorData, Exact, InputMaybe, InstitutionData, InstitutionsData, JsonWebToken, MakeMaybe, MakeOptional, Maybe, Mutable, NoContentData, Nullable, Observer, PasscodePayload, PrivateClaims, QuilttClientOptions, QuilttJWT, RegisteredClaims, ResolvableData, ResolvableResponse, SearchResponse, SessionResponse, UnauthorizedData, UnauthorizedResponse, UnprocessableData, UnprocessableResponse, UsernamePayload };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ApolloLink, ApolloClient } from '@apollo/client/core/index.js';
2
2
  export { gql } from '@apollo/client/core/index.js';
3
- import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth, b as endpointRest } from './SubscriptionLink-12s-TCM7KeHm.js';
4
- export { L as LocalStorage, M as MemoryStorage, O as Observable, g as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-12s-TCM7KeHm.js';
3
+ import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth, b as endpointRest } from './SubscriptionLink-12s-2Lc2oaGT.js';
4
+ export { L as LocalStorage, M as MemoryStorage, O as Observable, g as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-12s-2Lc2oaGT.js';
5
5
  import { BatchHttpLink as BatchHttpLink$1 } from '@apollo/client/link/batch-http/index.js';
6
6
  import crossfetch from 'cross-fetch';
7
7
  import { onError } from '@apollo/client/link/error/index.js';
@@ -52,16 +52,25 @@ const BatchHttpLink = new BatchHttpLink$1({
52
52
 
53
53
  const ErrorLink = onError(({ graphQLErrors, networkError })=>{
54
54
  if (graphQLErrors) {
55
- graphQLErrors.forEach(({ message, locations, path })=>{
56
- console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
55
+ graphQLErrors.forEach(({ message, path, extensions })=>{
56
+ const formattedPath = Array.isArray(path) ? path.join('.') : path ?? 'N/A';
57
+ const parts = [
58
+ `[Quiltt][GraphQL Error]: ${message}`,
59
+ `Path: ${formattedPath}`
60
+ ];
61
+ if (extensions) {
62
+ if (extensions.code) parts.push(`Code: ${extensions.code}`);
63
+ if (extensions.errorId) parts.push(`Error ID: ${extensions.errorId}`);
64
+ }
65
+ console.warn(parts.join(' | '));
57
66
  });
58
67
  }
59
68
  if (networkError) {
60
69
  if (networkError.statusCode === 401) {
61
- console.warn('[Authentication error]:', networkError);
70
+ console.warn('[Quiltt][Authentication Error]:', networkError);
62
71
  GlobalStorage.set('session', null);
63
72
  } else {
64
- console.warn('[Network error]:', networkError);
73
+ console.warn('[Quiltt][Network Error]:', networkError);
65
74
  }
66
75
  }
67
76
  });
@@ -258,18 +267,38 @@ class AuthAPI {
258
267
  }
259
268
  }
260
269
 
261
- class InstitutionsAPI {
270
+ class ConnectorsAPI {
262
271
  constructor(clientId, agent = 'web'){
263
272
  /**
264
273
  * Response Statuses:
265
274
  * - 200: OK -> Institutions Found
266
275
  * - 401: Unauthorized -> Invalid Token
276
+ * - 403: Forbidden -> Unsupported SDK
267
277
  * - 400: Bad Request -> Invalid Request
268
- */ this.search = async (token, connectorId, term, signal)=>{
278
+ */ this.searchInstitutions = async (token, connectorId, term, signal)=>{
269
279
  const params = new URLSearchParams();
270
- params.append('connectorId', connectorId);
271
280
  params.append('term', term);
272
- const response = await fetchWithRetry(`${endpointRest}/sdk/institutions?${params}`, {
281
+ const response = await fetchWithRetry(`${endpointRest}/sdk/connectors/${connectorId}/institutions?${params}`, {
282
+ method: 'GET',
283
+ signal,
284
+ ...this.config(token)
285
+ });
286
+ return response;
287
+ };
288
+ /**
289
+ * Response Statuses:
290
+ * - 200: OK -> Provider API ID is resolvable or not
291
+ * - 401: Unauthorized -> Invalid Token
292
+ * - 403: Forbidden -> Unsupported SDK
293
+ * - 400: Bad Request -> Missing provider API ID parameter
294
+ * - 404: Not Found -> Connector not found
295
+ */ this.checkResolvable = async (token, connectorId, providerId, signal)=>{
296
+ const params = new URLSearchParams();
297
+ const providerKey = Object.keys(providerId)[0];
298
+ if (providerKey && providerId[providerKey]) {
299
+ params.append(providerKey, providerId[providerKey]);
300
+ }
301
+ const response = await fetchWithRetry(`${endpointRest}/sdk/connectors/${connectorId}/resolvable?${params}`, {
273
302
  method: 'GET',
274
303
  signal,
275
304
  ...this.config(token)
@@ -339,4 +368,4 @@ const JsonWebTokenParse = (token)=>{
339
368
  }
340
369
  }
341
370
 
342
- export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, InstitutionsAPI, JsonWebTokenParse, QuilttClient, RetryLink, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, debugging, endpointAuth, endpointGraphQL, endpointRest, version };
371
+ export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ConnectorsAPI, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, JsonWebTokenParse, QuilttClient, RetryLink, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, debugging, endpointAuth, endpointGraphQL, endpointRest, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/core",
3
- "version": "4.3.3",
3
+ "version": "4.5.0",
4
4
  "description": "Javascript API client and utilities for Quiltt",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -5,17 +5,25 @@ import { GlobalStorage } from '@/storage'
5
5
 
6
6
  export const ErrorLink = onError(({ graphQLErrors, networkError }) => {
7
7
  if (graphQLErrors) {
8
- graphQLErrors.forEach(({ message, locations, path }) => {
9
- console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)
8
+ graphQLErrors.forEach(({ message, path, extensions }) => {
9
+ const formattedPath = Array.isArray(path) ? path.join('.') : (path ?? 'N/A')
10
+ const parts = [`[Quiltt][GraphQL Error]: ${message}`, `Path: ${formattedPath}`]
11
+
12
+ if (extensions) {
13
+ if (extensions.code) parts.push(`Code: ${extensions.code}`)
14
+ if (extensions.errorId) parts.push(`Error ID: ${extensions.errorId}`)
15
+ }
16
+
17
+ console.warn(parts.join(' | '))
10
18
  })
11
19
  }
12
20
 
13
21
  if (networkError) {
14
22
  if ((networkError as ServerError).statusCode === 401) {
15
- console.warn('[Authentication error]:', networkError)
23
+ console.warn('[Quiltt][Authentication Error]:', networkError)
16
24
  GlobalStorage.set('session', null)
17
25
  } else {
18
- console.warn('[Network error]:', networkError)
26
+ console.warn('[Quiltt][Network Error]:', networkError)
19
27
  }
20
28
  }
21
29
  })
@@ -0,0 +1,101 @@
1
+ import { endpointRest } from '@/configuration'
2
+
3
+ import type { FetchResponse } from './fetchWithRetry'
4
+ import { fetchWithRetry } from './fetchWithRetry'
5
+ import type { ErrorData, UnauthorizedData } from './types'
6
+
7
+ export type InstitutionData = { name: string; logoUrl: string }
8
+ export type InstitutionsData = Array<InstitutionData>
9
+
10
+ export type ResolvableData = { resolvable: boolean }
11
+
12
+ type Search = InstitutionsData | ErrorData | UnauthorizedData
13
+ type Resolvable = ResolvableData | ErrorData | UnauthorizedData
14
+
15
+ export type SearchResponse = FetchResponse<InstitutionsData>
16
+ export type ResolvableResponse = FetchResponse<ResolvableData>
17
+
18
+ export class ConnectorsAPI {
19
+ clientId: string
20
+ agent: string
21
+
22
+ constructor(clientId: string, agent = 'web') {
23
+ this.clientId = clientId
24
+ this.agent = agent
25
+ }
26
+
27
+ /**
28
+ * Response Statuses:
29
+ * - 200: OK -> Institutions Found
30
+ * - 401: Unauthorized -> Invalid Token
31
+ * - 403: Forbidden -> Unsupported SDK
32
+ * - 400: Bad Request -> Invalid Request
33
+ */
34
+ searchInstitutions = async (
35
+ token: string,
36
+ connectorId: string,
37
+ term: string,
38
+ signal?: AbortSignal
39
+ ) => {
40
+ const params = new URLSearchParams()
41
+ params.append('term', term)
42
+
43
+ const response = await fetchWithRetry<Search>(
44
+ `${endpointRest}/sdk/connectors/${connectorId}/institutions?${params}`,
45
+ {
46
+ method: 'GET',
47
+ signal,
48
+ ...this.config(token),
49
+ }
50
+ )
51
+ return response
52
+ }
53
+
54
+ /**
55
+ * Response Statuses:
56
+ * - 200: OK -> Provider API ID is resolvable or not
57
+ * - 401: Unauthorized -> Invalid Token
58
+ * - 403: Forbidden -> Unsupported SDK
59
+ * - 400: Bad Request -> Missing provider API ID parameter
60
+ * - 404: Not Found -> Connector not found
61
+ */
62
+ checkResolvable = async (
63
+ token: string,
64
+ connectorId: string,
65
+ providerId: { plaid?: string; mock?: string; mx?: string; finicity?: string; akoya?: string },
66
+ signal?: AbortSignal
67
+ ) => {
68
+ const params = new URLSearchParams()
69
+
70
+ const providerKey = Object.keys(providerId)[0] as keyof typeof providerId
71
+ if (providerKey && providerId[providerKey]) {
72
+ params.append(providerKey, providerId[providerKey])
73
+ }
74
+
75
+ const response = await fetchWithRetry<Resolvable>(
76
+ `${endpointRest}/sdk/connectors/${connectorId}/resolvable?${params}`,
77
+ {
78
+ method: 'GET',
79
+ signal,
80
+ ...this.config(token),
81
+ }
82
+ )
83
+ return response
84
+ }
85
+
86
+ private config = (token?: string) => {
87
+ const headers = new Headers()
88
+ headers.set('Content-Type', 'application/json')
89
+ headers.set('Accept', 'application/json')
90
+ headers.set('Quiltt-SDK-Agent', this.agent)
91
+ headers.set('Authorization', `Bearer ${token}`)
92
+
93
+ return {
94
+ headers,
95
+ validateStatus: this.validateStatus,
96
+ retry: true,
97
+ }
98
+ }
99
+
100
+ private validateStatus = (status: number) => status < 500 && status !== 429
101
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './auth'
2
- export * from './institutions'
2
+ export * from './connectors'
3
3
  export * from './types'
@@ -1,70 +0,0 @@
1
- import { endpointRest } from '@/configuration'
2
-
3
- import type { FetchResponse } from './fetchWithRetry'
4
- import { fetchWithRetry } from './fetchWithRetry'
5
- import type { ErrorData, UnauthorizedData } from './types'
6
-
7
- export type InstitutionData = { name: string; logoUrl: string }
8
- export type InstitutionsData = Array<InstitutionData>
9
-
10
- type Search = InstitutionsData | ErrorData | UnauthorizedData
11
-
12
- export type SearchResponse = FetchResponse<InstitutionsData>
13
-
14
- export class InstitutionsAPI {
15
- clientId: string
16
- agent: string
17
-
18
- constructor(clientId: string, agent = 'web') {
19
- this.clientId = clientId
20
- this.agent = agent
21
- }
22
-
23
- /**
24
- * Response Statuses:
25
- * - 200: OK -> Institutions Found
26
- * - 401: Unauthorized -> Invalid Token
27
- * - 400: Bad Request -> Invalid Request
28
- */
29
- search = async (token: string, connectorId: string, term: string, signal?: AbortSignal) => {
30
- const params = new URLSearchParams()
31
- params.append('connectorId', connectorId)
32
- params.append('term', term)
33
-
34
- const response = await fetchWithRetry<Search>(`${endpointRest}/sdk/institutions?${params}`, {
35
- method: 'GET',
36
- signal,
37
- ...this.config(token),
38
- })
39
- return response
40
- }
41
-
42
- private config = (token?: string) => {
43
- const headers = new Headers()
44
- headers.set('Content-Type', 'application/json')
45
- headers.set('Accept', 'application/json')
46
- headers.set('Quiltt-SDK-Agent', this.agent)
47
- headers.set('Authorization', `Bearer ${token}`)
48
-
49
- return {
50
- headers,
51
- validateStatus: this.validateStatus,
52
- retry: true,
53
- }
54
- }
55
-
56
- private validateStatus = (status: number) => status < 500 && status !== 429
57
-
58
- // private body = (payload: any) => {
59
- // if (!this.clientId) {
60
- // console.error('Quiltt Client ID is not set. Unable to identify & authenticate')
61
- // }
62
-
63
- // return {
64
- // session: {
65
- // clientId: this.clientId,
66
- // ...payload,
67
- // },
68
- // }
69
- // }
70
- }