@quiltt/core 4.3.0 → 4.3.2

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,18 @@
1
1
  # @quiltt/core
2
2
 
3
+ ## 4.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#372](https://github.com/quiltt/quiltt-js/pull/372) [`c022ebe`](https://github.com/quiltt/quiltt-js/commit/c022ebed0c82404a1bdbf5abbaf6e60b49f2d07a) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Hardened React SDK against unstable prop references by implementing ref-based callback wrappers and deep equality checks, eliminating unnecessary re-renders, event handler churn, and API calls without requiring customers to use useCallback.
8
+
9
+ ## 4.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#366](https://github.com/quiltt/quiltt-js/pull/366) [`dc376b5`](https://github.com/quiltt/quiltt-js/commit/dc376b52dd824d7867ca74677bbfd5c54eff5cdc) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Warn if useQuilttConnector is unmounted while in use
14
+ - [#365](https://github.com/quiltt/quiltt-js/pull/365) [`5f6b8af`](https://github.com/quiltt/quiltt-js/commit/5f6b8af153086c77bb2227d43ae7023fb0c47985) Thanks [@rubendinho](https://github.com/rubendinho)! - Standardize SDK agent tracking header to `Quiltt-SDK-Agent` and add support for custom Apollo Links injection
15
+
3
16
  ## 4.3.0
4
17
 
5
18
  ### Minor 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.0";
8
+ var version$1 = "4.3.2";
9
9
 
10
10
  const QUILTT_API_INSECURE = (()=>{
11
11
  try {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _apollo_client_core from '@apollo/client/core';
2
2
  import { ApolloClientOptions, NormalizedCacheObject, Operation, NextLink, FetchResult } from '@apollo/client/core';
3
3
  export { ApolloError, OperationVariables } from '@apollo/client/core';
4
- import { ApolloClient, ApolloLink } from '@apollo/client/core/index.js';
4
+ import { ApolloLink, ApolloClient } from '@apollo/client/core/index.js';
5
5
  export { gql } from '@apollo/client/core/index.js';
6
6
  import { Observable as Observable$1 } from '@apollo/client/utilities';
7
7
  import { BatchHttpLink as BatchHttpLink$1 } from '@apollo/client/link/batch-http/index.js';
@@ -140,7 +140,10 @@ type ConnectorSDKConnectorOptions = ConnectorSDKCallbacks & {
140
140
  nonce?: string;
141
141
  };
142
142
 
143
- type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'>;
143
+ type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'> & {
144
+ /** An array of initial links to inject before the default Quiltt Links */
145
+ customLinks?: ApolloLink[];
146
+ };
144
147
  declare class QuilttClient extends ApolloClient<NormalizedCacheObject> {
145
148
  constructor(options: QuilttClientOptions<NormalizedCacheObject>);
146
149
  }
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-DyFWSZbW.js';
4
- export { L as LocalStorage, M as MemoryStorage, O as Observable, g as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-12s-DyFWSZbW.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-BTrDDGH7.js';
4
+ export { L as LocalStorage, M as MemoryStorage, O as Observable, g as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-12s-BTrDDGH7.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';
@@ -101,6 +101,9 @@ class QuilttClient extends ApolloClient {
101
101
  enabled: options.devtools?.enabled ?? debugging
102
102
  }
103
103
  };
104
+ const initialLinks = options.customLinks ? [
105
+ ...options.customLinks
106
+ ] : [];
104
107
  const isOperationDefinition = (def)=>def.kind === 'OperationDefinition';
105
108
  const isSubscriptionOperation = (operation)=>{
106
109
  return operation.query.definitions.some((definition)=>isOperationDefinition(definition) && definition.operation === 'subscription');
@@ -111,6 +114,7 @@ class QuilttClient extends ApolloClient {
111
114
  const authLink = new AuthLink();
112
115
  const subscriptionsLink = new SubscriptionLink();
113
116
  const quilttLink = ApolloLink.from([
117
+ ...initialLinks,
114
118
  VersionLink,
115
119
  authLink,
116
120
  ErrorLink,
@@ -276,7 +280,7 @@ class InstitutionsAPI {
276
280
  const headers = new Headers();
277
281
  headers.set('Content-Type', 'application/json');
278
282
  headers.set('Accept', 'application/json');
279
- headers.set('X-Quiltt-SDK-Agent', this.agent);
283
+ headers.set('Quiltt-SDK-Agent', this.agent);
280
284
  headers.set('Authorization', `Bearer ${token}`);
281
285
  return {
282
286
  headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/core",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Javascript API client and utilities for Quiltt",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -15,7 +15,10 @@ import {
15
15
  VersionLink,
16
16
  } from './links'
17
17
 
18
- export type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'>
18
+ export type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'> & {
19
+ /** An array of initial links to inject before the default Quiltt Links */
20
+ customLinks?: ApolloLink[]
21
+ }
19
22
 
20
23
  export class QuilttClient extends ApolloClient<NormalizedCacheObject> {
21
24
  constructor(options: QuilttClientOptions<NormalizedCacheObject>) {
@@ -26,6 +29,8 @@ export class QuilttClient extends ApolloClient<NormalizedCacheObject> {
26
29
  },
27
30
  }
28
31
 
32
+ const initialLinks = options.customLinks ? [...options.customLinks] : []
33
+
29
34
  const isOperationDefinition = (def: DefinitionNode): def is OperationDefinitionNode =>
30
35
  def.kind === 'OperationDefinition'
31
36
 
@@ -42,7 +47,13 @@ export class QuilttClient extends ApolloClient<NormalizedCacheObject> {
42
47
  const authLink = new AuthLink()
43
48
  const subscriptionsLink = new SubscriptionLink()
44
49
 
45
- const quilttLink = ApolloLink.from([VersionLink, authLink, ErrorLink, RetryLink])
50
+ const quilttLink = ApolloLink.from([
51
+ ...initialLinks,
52
+ VersionLink,
53
+ authLink,
54
+ ErrorLink,
55
+ RetryLink,
56
+ ])
46
57
  .split(isSubscriptionOperation, subscriptionsLink, ForwardableLink)
47
58
  .split(isBatchable, BatchHttpLink, HttpLink)
48
59
 
@@ -1,4 +1,4 @@
1
- import { BatchHttpLink as ApolloHttpLink } from '@apollo/client/link/batch-http/index.js'
1
+ import { BatchHttpLink as ApolloBatchHttpLink } from '@apollo/client/link/batch-http/index.js'
2
2
  import crossfetch from 'cross-fetch'
3
3
 
4
4
  import { endpointGraphQL } from '@/configuration'
@@ -6,7 +6,7 @@ import { endpointGraphQL } from '@/configuration'
6
6
  // Use `cross-fetch` only if `fetch` is not available on the `globalThis` object
7
7
  const effectiveFetch = typeof fetch === 'undefined' ? crossfetch : fetch
8
8
 
9
- export const BatchHttpLink = new ApolloHttpLink({
9
+ export const BatchHttpLink = new ApolloBatchHttpLink({
10
10
  uri: endpointGraphQL,
11
11
  fetch: effectiveFetch,
12
12
  })
@@ -43,7 +43,7 @@ export class InstitutionsAPI {
43
43
  const headers = new Headers()
44
44
  headers.set('Content-Type', 'application/json')
45
45
  headers.set('Accept', 'application/json')
46
- headers.set('X-Quiltt-SDK-Agent', this.agent)
46
+ headers.set('Quiltt-SDK-Agent', this.agent)
47
47
  headers.set('Authorization', `Bearer ${token}`)
48
48
 
49
49
  return {