@cedarjs/web 6.0.0-canary.2661 → 6.0.0-canary.2663

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 (41) hide show
  1. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +15 -0
  2. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -0
  3. package/dist/apollo/ApolloProviderWithFetchConfig.js +134 -0
  4. package/dist/apollo/CedarApolloProvider.d.ts +14 -0
  5. package/dist/apollo/CedarApolloProvider.d.ts.map +1 -0
  6. package/dist/apollo/CedarApolloProvider.js +35 -0
  7. package/dist/apollo/ErrorBoundary.d.ts +13 -0
  8. package/dist/apollo/ErrorBoundary.d.ts.map +1 -0
  9. package/dist/apollo/ErrorBoundary.js +13 -0
  10. package/dist/apollo/apolloLinkTypes.d.ts +60 -0
  11. package/dist/apollo/apolloLinkTypes.d.ts.map +1 -0
  12. package/dist/apollo/apolloLinkTypes.js +0 -0
  13. package/dist/apollo/index.d.ts +50 -69
  14. package/dist/apollo/index.d.ts.map +1 -1
  15. package/dist/apollo/index.js +2 -163
  16. package/dist/apollo/suspense.d.ts +16 -6
  17. package/dist/apollo/suspense.d.ts.map +1 -1
  18. package/dist/apollo/suspense.js +4 -2
  19. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts +15 -0
  20. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -0
  21. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.js +165 -0
  22. package/dist/cjs/apollo/CedarApolloProvider.d.ts +14 -0
  23. package/dist/cjs/apollo/CedarApolloProvider.d.ts.map +1 -0
  24. package/dist/cjs/apollo/CedarApolloProvider.js +69 -0
  25. package/dist/cjs/apollo/ErrorBoundary.d.ts +13 -0
  26. package/dist/cjs/apollo/ErrorBoundary.d.ts.map +1 -0
  27. package/dist/cjs/apollo/ErrorBoundary.js +47 -0
  28. package/dist/cjs/apollo/apolloLinkTypes.d.ts +60 -0
  29. package/dist/cjs/apollo/apolloLinkTypes.d.ts.map +1 -0
  30. package/dist/cjs/apollo/apolloLinkTypes.js +16 -0
  31. package/dist/cjs/apollo/index.d.ts +50 -69
  32. package/dist/cjs/apollo/index.d.ts.map +1 -1
  33. package/dist/cjs/apollo/index.js +2 -167
  34. package/dist/cjs/apollo/suspense.d.ts +16 -6
  35. package/dist/cjs/apollo/suspense.d.ts.map +1 -1
  36. package/dist/cjs/apollo/suspense.js +5 -2
  37. package/dist/cjs/components/FetchConfigProvider.d.ts +3 -2
  38. package/dist/cjs/components/FetchConfigProvider.d.ts.map +1 -1
  39. package/dist/components/FetchConfigProvider.d.ts +3 -2
  40. package/dist/components/FetchConfigProvider.d.ts.map +1 -1
  41. package/package.json +15 -5
@@ -19,28 +19,28 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
19
19
  * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains:
20
20
  *
21
21
  * ```js
22
- * <RedwoodApolloProvider graphQLClientConfig={{
22
+ * <CedarApolloProvider graphQLClientConfig={{
23
23
  * httpLinkConfig: { credentials: 'include' }
24
24
  * }}>
25
25
  * ```
26
26
  */
27
27
  httpLinkConfig?: HttpOptions;
28
28
  /**
29
- * Extend or overwrite `RedwoodApolloProvider`'s Apollo Link.
29
+ * Extend or overwrite `CedarApolloProvider`'s Apollo Link.
30
30
  *
31
- * To overwrite Redwood's Apollo Link, just provide your own `ApolloLink`.
31
+ * To overwrite Cedar's Apollo Link, just provide your own `ApolloLink`.
32
32
  *
33
- * To extend Redwood's Apollo Link, provide a function—it'll get passed an array of Redwood's Apollo Links
33
+ * To extend Cedar's Apollo Link, provide a function—it'll get passed an array of Cedar's Apollo Links
34
34
  * which are objects with a name and link property:
35
35
  *
36
36
  * ```js
37
- * const link = (redwoodApolloLinks) => {
37
+ * const link = (cedarApolloLinks) => {
38
38
  * const consoleLink = new ApolloLink((operation, forward) => {
39
39
  * console.log(operation.operationName)
40
40
  * return forward(operation)
41
41
  * })
42
42
  *
43
- * return ApolloLink.from([consoleLink, ...redwoodApolloLinks.map(({ link }) => link)])
43
+ * return ApolloLink.from([consoleLink, ...cedarApolloLinks.map(({ link }) => link)])
44
44
  * }
45
45
  * ```
46
46
  *
@@ -50,6 +50,16 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
50
50
  */
51
51
  link?: ApolloLink | RedwoodApolloLinkFactory;
52
52
  };
53
+ export declare const CedarApolloProvider: React.FunctionComponent<{
54
+ graphQLClientConfig?: GraphQLClientConfigProp;
55
+ useAuth?: UseAuth;
56
+ logLevel?: ReturnType<typeof setLogVerbosity>;
57
+ children: React.ReactNode;
58
+ }>;
59
+ /**
60
+ * @deprecated Use `CedarApolloProvider` instead. `RedwoodApolloProvider` will
61
+ * be removed in a future release.
62
+ */
53
63
  export declare const RedwoodApolloProvider: React.FunctionComponent<{
54
64
  graphQLClientConfig?: GraphQLClientConfigProp;
55
65
  useAuth?: UseAuth;
@@ -1 +1 @@
1
- {"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../../src/apollo/suspense.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAEL,aAAa,EAEd,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAW5C,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;CAC7C,CAAA;AAkFD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC1D,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CA4BA,CAAA"}
1
+ {"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../../src/apollo/suspense.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAEL,aAAa,EAEd,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAW5C,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;CAC7C,CAAA;AAkFD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACxD,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CA4BA,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;0BAtCV,uBAAuB;cACnC,OAAO;eACN,UAAU,CAAC,OAAO,eAAe,CAAC;cACnC,KAAK,CAAC,SAAS;EAmC6B,CAAA"}
@@ -68,7 +68,7 @@ const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = u
68
68
  }
69
69
  return /* @__PURE__ */ React.createElement(WrappedApolloProvider, { makeClient }, children);
70
70
  };
71
- const RedwoodApolloProvider = ({
71
+ const CedarApolloProvider = ({
72
72
  graphQLClientConfig,
73
73
  useAuth = useNoAuth,
74
74
  logLevel = "debug",
@@ -78,7 +78,7 @@ const RedwoodApolloProvider = ({
78
78
  const cache = new InMemoryCache({
79
79
  fragments: fragmentRegistry,
80
80
  ...cacheConfig
81
- }).restore(globalThis?.__REDWOOD__APOLLO_STATE ?? {});
81
+ }).restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
82
82
  return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
83
83
  ApolloProviderWithFetchConfig,
84
84
  {
@@ -89,6 +89,8 @@ const RedwoodApolloProvider = ({
89
89
  children
90
90
  ));
91
91
  };
92
+ const RedwoodApolloProvider = CedarApolloProvider;
92
93
  export {
94
+ CedarApolloProvider,
93
95
  RedwoodApolloProvider
94
96
  };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { ApolloCache, setLogVerbosity } from '@apollo/client';
3
+ import type { UseAuth } from '@cedarjs/auth';
4
+ import type { GraphQLClientConfigProp } from './apolloLinkTypes.js';
5
+ interface Props {
6
+ config: Omit<GraphQLClientConfigProp, 'cacheConfig' | 'cache'> & {
7
+ cache: ApolloCache<unknown>;
8
+ };
9
+ useAuth?: UseAuth;
10
+ logLevel: ReturnType<typeof setLogVerbosity>;
11
+ children: React.ReactNode;
12
+ }
13
+ export declare function ApolloProviderWithFetchConfig({ config, children, useAuth, logLevel, }: Props): React.JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=ApolloProviderWithFetchConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAYhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAM5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAoC7B,UAAU,KAAK;IACb,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG;QAC/D,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;KAC5B,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,MAAM,EACN,QAAQ,EACR,OAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,qBAgKP"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ApolloProviderWithFetchConfig_exports = {};
30
+ __export(ApolloProviderWithFetchConfig_exports, {
31
+ ApolloProviderWithFetchConfig: () => ApolloProviderWithFetchConfig
32
+ });
33
+ module.exports = __toCommonJS(ApolloProviderWithFetchConfig_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ var import_core = require("@apollo/client/core/core.cjs");
36
+ var import_context = require("@apollo/client/link/context/context.cjs");
37
+ var import_core2 = require("@apollo/client/link/core/core.cjs");
38
+ var import_persisted_queries = require("@apollo/client/link/persisted-queries/persisted-queries.cjs");
39
+ var import_react2 = require("@apollo/client/react/react.cjs");
40
+ var import_utilities = require("@apollo/client/utilities/utilities.cjs");
41
+ var import_printer = require("graphql/language/printer.js");
42
+ var import_auth = require("@cedarjs/auth");
43
+ var import_apollo_upload_client = require("../bundled/apollo-upload-client.js");
44
+ var import_FetchConfigProvider = require("../components/FetchConfigProvider.js");
45
+ var import_ErrorBoundary = require("./ErrorBoundary.js");
46
+ var SSELinkExports = __toESM(require("./sseLink.js"), 1);
47
+ const { SSELink, isSubscription, isLiveQuery } = SSELinkExports;
48
+ function ApolloProviderWithFetchConfig({
49
+ config,
50
+ children,
51
+ useAuth = import_auth.useNoAuth,
52
+ logLevel
53
+ }) {
54
+ (0, import_core.setLogVerbosity)(logLevel);
55
+ const { getToken, type: authProviderType } = useAuth();
56
+ const data = {
57
+ mostRecentRequest: void 0,
58
+ mostRecentResponse: void 0
59
+ };
60
+ const updateDataApolloLink = new import_core2.ApolloLink((operation, forward) => {
61
+ const { operationName, query, variables } = operation;
62
+ data.mostRecentRequest = {};
63
+ data.mostRecentRequest.operationName = operationName;
64
+ data.mostRecentRequest.operationKind = query?.kind.toString();
65
+ data.mostRecentRequest.variables = variables;
66
+ data.mostRecentRequest.query = query && (0, import_printer.print)(operation.query);
67
+ return forward(operation).map((result) => {
68
+ data.mostRecentResponse = result;
69
+ return result;
70
+ });
71
+ });
72
+ const withToken = (0, import_context.setContext)(async () => {
73
+ const token = await getToken();
74
+ return { token };
75
+ });
76
+ const { headers, uri } = (0, import_FetchConfigProvider.useFetchConfig)();
77
+ const authMiddleware = new import_core2.ApolloLink((operation, forward) => {
78
+ const { token } = operation.getContext();
79
+ const authHeaders = token ? {
80
+ "auth-provider": authProviderType,
81
+ authorization: `Bearer ${token}`
82
+ } : {};
83
+ operation.setContext(() => ({
84
+ headers: {
85
+ ...operation.getContext().headers,
86
+ ...headers,
87
+ // Duped auth headers, because we may remove the `FetchConfigProvider` at a later date.
88
+ ...authHeaders
89
+ }
90
+ }));
91
+ return forward(operation);
92
+ });
93
+ const { httpLinkConfig, link: cedarApolloLink, ...rest } = config ?? {};
94
+ const uploadLink = (0, import_apollo_upload_client.createUploadLink)({
95
+ uri,
96
+ ...httpLinkConfig
97
+ });
98
+ const uploadOrSSELink = typeof SSELink !== "undefined" ? (0, import_core2.split)(
99
+ ({ query }) => {
100
+ const definition = (0, import_utilities.getMainDefinition)(query);
101
+ return isSubscription(definition) || isLiveQuery(definition);
102
+ },
103
+ new SSELink({
104
+ url: uri,
105
+ auth: { authProviderType, tokenFn: getToken },
106
+ httpLinkConfig,
107
+ headers
108
+ }),
109
+ uploadLink
110
+ ) : uploadLink;
111
+ const terminatingLink = (0, import_core2.split)(
112
+ ({ query }) => {
113
+ const documentQuery = query;
114
+ return documentQuery?.["__meta__"]?.["hash"] !== void 0;
115
+ },
116
+ (0, import_persisted_queries.createPersistedQueryLink)({
117
+ generateHash: (document) => document["__meta__"]["hash"]
118
+ }).concat(uploadOrSSELink),
119
+ uploadOrSSELink
120
+ );
121
+ const cedarApolloLinks = [
122
+ { name: "withToken", link: withToken },
123
+ { name: "authMiddleware", link: authMiddleware },
124
+ { name: "updateDataApolloLink", link: updateDataApolloLink },
125
+ { name: "httpLink", link: terminatingLink }
126
+ ];
127
+ let link = cedarApolloLink;
128
+ link ??= import_core2.ApolloLink.from(cedarApolloLinks.map((l) => l.link));
129
+ if (typeof link === "function") {
130
+ link = link(cedarApolloLinks);
131
+ }
132
+ const client = new import_core.ApolloClient({
133
+ // Default options for every Cell. Better to specify them here than in
134
+ // `beforeQuery` where it's too easy to overwrite them.
135
+ // See https://www.apollographql.com/docs/react/api/core/ApolloClient/#example-defaultoptions-object.
136
+ defaultOptions: {
137
+ watchQuery: {
138
+ // The `fetchPolicy` we expect:
139
+ //
140
+ // > Apollo Client executes the full query against both the cache and
141
+ // > your GraphQL server.
142
+ // > The query automatically updates if the result of the server-side
143
+ // > query modifies cached fields.
144
+ //
145
+ // See https://www.apollographql.com/docs/react/data/queries/#cache-and-network.
146
+ fetchPolicy: "cache-and-network",
147
+ // So that Cells rerender when refetching.
148
+ // See https://www.apollographql.com/docs/react/data/queries/#inspecting-loading-states.
149
+ notifyOnNetworkStatusChange: true
150
+ }
151
+ },
152
+ link,
153
+ ...rest
154
+ });
155
+ const extendErrorAndRethrow = (error, _errorInfo) => {
156
+ error["mostRecentRequest"] = data.mostRecentRequest;
157
+ error["mostRecentResponse"] = data.mostRecentResponse;
158
+ throw error;
159
+ };
160
+ return /* @__PURE__ */ import_react.default.createElement(import_react2.ApolloProvider, { client }, /* @__PURE__ */ import_react.default.createElement(import_ErrorBoundary.ErrorBoundary, { onError: extendErrorAndRethrow }, children));
161
+ }
162
+ // Annotate the CommonJS export names for ESM import in node:
163
+ 0 && (module.exports = {
164
+ ApolloProviderWithFetchConfig
165
+ });
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { DocumentNode, setLogVerbosity } from '@apollo/client';
3
+ import type { UseAuth } from '@cedarjs/auth';
4
+ import type { GraphQLClientConfigProp } from './apolloLinkTypes.js';
5
+ export type { ApolloClientCacheConfig, CedarApolloLink, CedarApolloLinkFactory, CedarApolloLinkName, CedarApolloLinks, GraphQLClientConfigProp, } from './apolloLinkTypes.js';
6
+ interface Props {
7
+ graphQLClientConfig?: GraphQLClientConfigProp;
8
+ fragments?: DocumentNode[];
9
+ useAuth?: UseAuth;
10
+ logLevel?: ReturnType<typeof setLogVerbosity>;
11
+ children: React.ReactNode;
12
+ }
13
+ export declare function CedarApolloProvider({ graphQLClientConfig, fragments, useAuth, logLevel, children, }: Props): React.JSX.Element;
14
+ //# sourceMappingURL=CedarApolloProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CedarApolloProvider.d.ts","sourceRoot":"","sources":["../../../src/apollo/CedarApolloProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAK5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAInE,YAAY,EACV,uBAAuB,EACvB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,sBAAsB,CAAA;AAE7B,UAAU,KAAK;IACb,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,SAAS,CAAC,EAAE,YAAY,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,mBAAmB,EACnB,SAAS,EACT,OAAmB,EACnB,QAAkB,EAClB,QAAQ,GACT,EAAE,KAAK,qBA4BP"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var CedarApolloProvider_exports = {};
30
+ __export(CedarApolloProvider_exports, {
31
+ CedarApolloProvider: () => CedarApolloProvider
32
+ });
33
+ module.exports = __toCommonJS(CedarApolloProvider_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ var import_cache = require("@apollo/client/cache/cache.cjs");
36
+ var import_auth = require("@cedarjs/auth");
37
+ var import_FetchConfigProvider = require("../components/FetchConfigProvider.js");
38
+ var import_ApolloProviderWithFetchConfig = require("./ApolloProviderWithFetchConfig.js");
39
+ var import_fragmentRegistry = require("./fragmentRegistry.js");
40
+ function CedarApolloProvider({
41
+ graphQLClientConfig,
42
+ fragments,
43
+ useAuth = import_auth.useNoAuth,
44
+ logLevel = "debug",
45
+ children
46
+ }) {
47
+ const { cacheConfig, ...config } = graphQLClientConfig ?? {};
48
+ if (fragments) {
49
+ import_fragmentRegistry.fragmentRegistry.register(...fragments);
50
+ }
51
+ const cache = new import_cache.InMemoryCache({
52
+ fragments: import_fragmentRegistry.fragmentRegistry,
53
+ possibleTypes: cacheConfig?.possibleTypes,
54
+ ...cacheConfig
55
+ }).restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
56
+ return /* @__PURE__ */ import_react.default.createElement(import_FetchConfigProvider.FetchConfigProvider, { useAuth }, /* @__PURE__ */ import_react.default.createElement(
57
+ import_ApolloProviderWithFetchConfig.ApolloProviderWithFetchConfig,
58
+ {
59
+ config: { cache, ...config },
60
+ useAuth,
61
+ logLevel
62
+ },
63
+ children
64
+ ));
65
+ }
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ CedarApolloProvider
69
+ });
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ type ComponentDidCatch = React.ComponentLifecycle<any, any>['componentDidCatch'];
3
+ interface ErrorBoundaryProps {
4
+ error?: unknown;
5
+ onError: NonNullable<ComponentDidCatch>;
6
+ children: React.ReactNode;
7
+ }
8
+ export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps> {
9
+ componentDidCatch(...args: Parameters<NonNullable<ComponentDidCatch>>): void;
10
+ render(): React.ReactNode;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/apollo/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,iBAAiB,GAAG,KAAK,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAA;AAEhF,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAA;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC;IACpE,iBAAiB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAKrE,MAAM;CAGP"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ErrorBoundary_exports = {};
30
+ __export(ErrorBoundary_exports, {
31
+ ErrorBoundary: () => ErrorBoundary
32
+ });
33
+ module.exports = __toCommonJS(ErrorBoundary_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ class ErrorBoundary extends import_react.default.Component {
36
+ componentDidCatch(...args) {
37
+ this.setState({});
38
+ this.props.onError(...args);
39
+ }
40
+ render() {
41
+ return this.props.children;
42
+ }
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ ErrorBoundary
47
+ });
@@ -0,0 +1,60 @@
1
+ import type { ApolloCache, ApolloClientOptions, ApolloLink, HttpLink, HttpOptions, InMemoryCacheConfig } from '@apollo/client';
2
+ export type ApolloClientCacheConfig = InMemoryCacheConfig;
3
+ export type CedarApolloLinkName = 'withToken' | 'authMiddleware' | 'updateDataApolloLink' | 'httpLink';
4
+ export type CedarApolloLink<Name extends CedarApolloLinkName, Link extends ApolloLink = ApolloLink> = {
5
+ name: Name;
6
+ link: Link;
7
+ };
8
+ export type CedarApolloLinks = [
9
+ CedarApolloLink<'withToken'>,
10
+ CedarApolloLink<'authMiddleware'>,
11
+ CedarApolloLink<'updateDataApolloLink'>,
12
+ CedarApolloLink<'httpLink', ApolloLink | HttpLink>
13
+ ];
14
+ export type CedarApolloLinkFactory = (links: CedarApolloLinks) => ApolloLink;
15
+ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
16
+ cache?: ApolloCache<unknown>;
17
+ /**
18
+ * Configuration for Apollo Client's `InMemoryCache`.
19
+ * See https://www.apollographql.com/docs/react/caching/cache-configuration/.
20
+ */
21
+ cacheConfig?: ApolloClientCacheConfig;
22
+ /**
23
+ * Configuration for the terminating `HttpLink`.
24
+ * See https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options.
25
+ *
26
+ * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains:
27
+ *
28
+ * ```js
29
+ * <CedarApolloProvider graphQLClientConfig={{
30
+ * httpLinkConfig: { credentials: 'include' }
31
+ * }}>
32
+ * ```
33
+ */
34
+ httpLinkConfig?: HttpOptions;
35
+ /**
36
+ * Extend or overwrite `CedarApolloProvider`'s Apollo Link.
37
+ *
38
+ * To overwrite Cedar's Apollo Link, just provide your own `ApolloLink`.
39
+ *
40
+ * To extend Cedar's Apollo Link, provide a function—it'll get passed an array of Cedar's Apollo Links
41
+ * which are objects with a name and link property:
42
+ *
43
+ * ```js
44
+ * const link = (cedarApolloLinks) => {
45
+ * const consoleLink = new ApolloLink((operation, forward) => {
46
+ * console.log(operation.operationName)
47
+ * return forward(operation)
48
+ * })
49
+ *
50
+ * return ApolloLink.from([consoleLink, ...cedarApolloLinks.map(({ link }) => link)])
51
+ * }
52
+ * ```
53
+ *
54
+ * If you do this, there's a few things you should keep in mind:
55
+ * - your function should return a single link (e.g., using `ApolloLink.from`; see https://www.apollographql.com/docs/react/api/link/introduction/#additive-composition)
56
+ * - the `HttpLink` should come last (https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)
57
+ */
58
+ link?: ApolloLink | CedarApolloLinkFactory;
59
+ };
60
+ //# sourceMappingURL=apolloLinkTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apolloLinkTypes.d.ts","sourceRoot":"","sources":["../../../src/apollo/apolloLinkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,WAAW,EACX,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAC3B,WAAW,GACX,gBAAgB,GAChB,sBAAsB,GACtB,UAAU,CAAA;AAEd,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,mBAAmB,EAChC,IAAI,SAAS,UAAU,GAAG,UAAU,IAClC;IACF,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,CAAC,WAAW,CAAC;IAC5B,eAAe,CAAC,gBAAgB,CAAC;IACjC,eAAe,CAAC,sBAAsB,CAAC;IACvC,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,CAAC;CACnD,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,UAAU,CAAA;AAE5E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,sBAAsB,CAAA;CAC3C,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var apolloLinkTypes_exports = {};
16
+ module.exports = __toCommonJS(apolloLinkTypes_exports);
@@ -1,75 +1,56 @@
1
- import React from 'react';
2
- import type { ApolloClientOptions, setLogVerbosity, ApolloCache, InMemoryCacheConfig, HttpOptions, DocumentNode, HttpLink } from '@apollo/client';
3
- import { ApolloLink } from '@apollo/client/link/core/core.cjs';
4
- import type { UseAuth } from '@cedarjs/auth';
1
+ import type { ApolloLink } from '@apollo/client';
2
+ import { CedarApolloProvider } from './CedarApolloProvider.js';
3
+ import type { ApolloClientCacheConfig as CedarApolloClientCacheConfig, CedarApolloLink, CedarApolloLinkFactory, CedarApolloLinkName, CedarApolloLinks, GraphQLClientConfigProp as CedarGraphQLClientConfigProp } from './CedarApolloProvider.js';
5
4
  import { fragmentRegistry, registerFragment, registerFragments } from './fragmentRegistry.js';
6
5
  import { useCache } from './useCache.js';
7
6
  export type { CacheKey, FragmentIdentifier, RegisterFragmentResult, } from './fragmentRegistry.js';
8
7
  export { useCache };
9
8
  export { fragmentRegistry, registerFragment, registerFragments };
10
- export type ApolloClientCacheConfig = InMemoryCacheConfig;
11
- export type RedwoodApolloLinkName = 'withToken' | 'authMiddleware' | 'updateDataApolloLink' | 'httpLink';
12
- export type RedwoodApolloLink<Name extends RedwoodApolloLinkName, Link extends ApolloLink = ApolloLink> = {
13
- name: Name;
14
- link: Link;
15
- };
16
- export type RedwoodApolloLinks = [
17
- RedwoodApolloLink<'withToken'>,
18
- RedwoodApolloLink<'authMiddleware'>,
19
- RedwoodApolloLink<'updateDataApolloLink'>,
20
- RedwoodApolloLink<'httpLink', ApolloLink | HttpLink>
21
- ];
22
- export type RedwoodApolloLinkFactory = (links: RedwoodApolloLinks) => ApolloLink;
23
- export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
24
- cache?: ApolloCache<unknown>;
25
- /**
26
- * Configuration for Apollo Client's `InMemoryCache`.
27
- * See https://www.apollographql.com/docs/react/caching/cache-configuration/.
28
- */
29
- cacheConfig?: ApolloClientCacheConfig;
30
- /**
31
- * Configuration for the terminating `HttpLink`.
32
- * See https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options.
33
- *
34
- * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains:
35
- *
36
- * ```js
37
- * <RedwoodApolloProvider graphQLClientConfig={{
38
- * httpLinkConfig: { credentials: 'include' }
39
- * }}>
40
- * ```
41
- */
42
- httpLinkConfig?: HttpOptions;
43
- /**
44
- * Extend or overwrite `RedwoodApolloProvider`'s Apollo Link.
45
- *
46
- * To overwrite Redwood's Apollo Link, just provide your own `ApolloLink`.
47
- *
48
- * To extend Redwood's Apollo Link, provide a function—it'll get passed an array of Redwood's Apollo Links
49
- * which are objects with a name and link property:
50
- *
51
- * ```js
52
- * const link = (redwoodApolloLinks) => {
53
- * const consoleLink = new ApolloLink((operation, forward) => {
54
- * console.log(operation.operationName)
55
- * return forward(operation)
56
- * })
57
- *
58
- * return ApolloLink.from([consoleLink, ...redwoodApolloLinks.map(({ link }) => link)])
59
- * }
60
- * ```
61
- *
62
- * If you do this, there's a few things you should keep in mind:
63
- * - your function should return a single link (e.g., using `ApolloLink.from`; see https://www.apollographql.com/docs/react/api/link/introduction/#additive-composition)
64
- * - the `HttpLink` should come last (https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)
65
- */
66
- link?: ApolloLink | RedwoodApolloLinkFactory;
67
- };
68
- export declare const RedwoodApolloProvider: React.FunctionComponent<{
69
- graphQLClientConfig?: GraphQLClientConfigProp;
70
- fragments?: DocumentNode[];
71
- useAuth?: UseAuth;
72
- logLevel?: ReturnType<typeof setLogVerbosity>;
73
- children: React.ReactNode;
74
- }>;
9
+ /**
10
+ * @deprecated Import from `@cedarjs/web/apollo/CedarApolloProvider` instead.
11
+ * This re-export will be removed in a future release.
12
+ *
13
+ * ```js
14
+ * import type { ApolloClientCacheConfig } from '@cedarjs/web/apollo/CedarApolloProvider'
15
+ * ```
16
+ */
17
+ export type ApolloClientCacheConfig = CedarApolloClientCacheConfig;
18
+ /**
19
+ * @deprecated Import from `@cedarjs/web/apollo/CedarApolloProvider` instead.
20
+ * This re-export will be removed in a future release.
21
+ *
22
+ * ```js
23
+ * import type { GraphQLClientConfigProp } from '@cedarjs/web/apollo/CedarApolloProvider'
24
+ * ```
25
+ */
26
+ export type GraphQLClientConfigProp = CedarGraphQLClientConfigProp;
27
+ /**
28
+ * @deprecated Use `CedarApolloLinkName` instead. `RedwoodApolloLinkName` will
29
+ * be removed in a future release.
30
+ */
31
+ export type RedwoodApolloLinkName = CedarApolloLinkName;
32
+ /**
33
+ * @deprecated Use `CedarApolloLink` instead. `RedwoodApolloLink` will be
34
+ * removed in a future release.
35
+ */
36
+ export type RedwoodApolloLink<Name extends CedarApolloLinkName, Link extends ApolloLink = ApolloLink> = CedarApolloLink<Name, Link>;
37
+ /**
38
+ * @deprecated Use `CedarApolloLinks` instead. `RedwoodApolloLinks` will be
39
+ * removed in a future release.
40
+ */
41
+ export type RedwoodApolloLinks = CedarApolloLinks;
42
+ /**
43
+ * @deprecated Use `CedarApolloLinkFactory` instead. `RedwoodApolloLinkFactory`
44
+ * will be removed in a future release.
45
+ */
46
+ export type RedwoodApolloLinkFactory = CedarApolloLinkFactory;
47
+ /**
48
+ * @deprecated Use `CedarApolloProvider` instead. `RedwoodApolloProvider` will
49
+ * be removed in a future release.
50
+ *
51
+ * ```js
52
+ * import { CedarApolloProvider } from '@cedarjs/web/apollo/CedarApolloProvider'
53
+ * ```
54
+ */
55
+ export declare const RedwoodApolloProvider: typeof CedarApolloProvider;
75
56
  //# sourceMappingURL=index.d.ts.map