naystack 1.7.11 → 1.7.13

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.
@@ -31,16 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/graphql/client.tsx
32
32
  var client_exports = {};
33
33
  __export(client_exports, {
34
- ApolloWrapperClient: () => ApolloWrapperClient,
35
- ApolloWrapperNext: () => ApolloWrapper,
34
+ ApolloWrapper: () => ApolloWrapper,
36
35
  tokenContext: () => tokenContext,
37
36
  useAuthMutation: () => useAuthMutation,
38
37
  useAuthQuery: () => useAuthQuery
39
38
  });
40
39
  module.exports = __toCommonJS(client_exports);
41
- var import_client2 = require("@apollo/client");
42
- var import_client3 = require("naystack/auth/client");
43
- var import_react2 = __toESM(require("react"));
40
+ var import_client = require("@apollo/client");
41
+ var import_client2 = require("naystack/auth/client");
42
+ var import_react = __toESM(require("react"));
44
43
 
45
44
  // src/env.ts
46
45
  var EXTRA_ENV = globalThis.__NAYSTACK_ENV__ || (globalThis.__NAYSTACK_ENV__ = {});
@@ -92,13 +91,10 @@ function getEnv(key, skipCheck) {
92
91
  return value;
93
92
  }
94
93
 
95
- // src/graphql/next.tsx
96
- var import_client = require("@apollo/client");
97
- var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
98
- var import_react = __toESM(require("react"));
94
+ // src/graphql/client.tsx
99
95
  function makeClient(cacheConfig) {
100
- return new import_client_integration_nextjs.ApolloClient({
101
- cache: new import_client_integration_nextjs.InMemoryCache(cacheConfig),
96
+ return new import_client.ApolloClient({
97
+ cache: new import_client.InMemoryCache(cacheConfig),
102
98
  link: new import_client.HttpLink({
103
99
  uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
104
100
  })
@@ -108,23 +104,7 @@ var ApolloWrapper = ({
108
104
  children,
109
105
  cacheConfig
110
106
  }) => {
111
- return /* @__PURE__ */ import_react.default.createElement(import_client_integration_nextjs.ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
112
- };
113
-
114
- // src/graphql/client.tsx
115
- function makeClient2(cacheConfig) {
116
- return new import_client2.ApolloClient({
117
- cache: new import_client2.InMemoryCache(cacheConfig),
118
- link: new import_client2.HttpLink({
119
- uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
120
- })
121
- });
122
- }
123
- var ApolloWrapperClient = ({
124
- children,
125
- cacheConfig
126
- }) => {
127
- return /* @__PURE__ */ import_react2.default.createElement(import_client2.ApolloProvider, { client: makeClient2(cacheConfig) }, children);
107
+ return /* @__PURE__ */ import_react.default.createElement(import_client.ApolloProvider, { client: makeClient(cacheConfig) }, children);
128
108
  };
129
109
  var tokenContext = (token) => {
130
110
  if (!token) return void 0;
@@ -136,12 +116,12 @@ var tokenContext = (token) => {
136
116
  };
137
117
  };
138
118
  function useAuthQuery(query, variables) {
139
- const token = (0, import_client3.useToken)();
140
- const [fetch, result] = (0, import_client2.useLazyQuery)(query, {
119
+ const token = (0, import_client2.useToken)();
120
+ const [fetch, result] = (0, import_client.useLazyQuery)(query, {
141
121
  fetchPolicy: "no-cache"
142
122
  });
143
- const prevVarsRef = (0, import_react2.useRef)(null);
144
- (0, import_react2.useEffect)(() => {
123
+ const prevVarsRef = (0, import_react.useRef)(null);
124
+ (0, import_react.useEffect)(() => {
145
125
  const serialized = JSON.stringify(variables);
146
126
  if (token && variables && prevVarsRef.current !== serialized) {
147
127
  prevVarsRef.current = serialized;
@@ -152,7 +132,7 @@ function useAuthQuery(query, variables) {
152
132
  });
153
133
  }
154
134
  }, [fetch, token, variables]);
155
- const reFetch = (0, import_react2.useCallback)(
135
+ const reFetch = (0, import_react.useCallback)(
156
136
  (input) => fetch({
157
137
  // @ts-expect-error -- to allow dynamic props
158
138
  variables: { input },
@@ -163,9 +143,9 @@ function useAuthQuery(query, variables) {
163
143
  return [reFetch, { ...result, hasAuth: !!token }];
164
144
  }
165
145
  function useAuthMutation(mutation, options) {
166
- const token = (0, import_client3.useToken)();
167
- const [mutate, result] = (0, import_client2.useMutation)(mutation, options);
168
- const method = (0, import_react2.useCallback)(
146
+ const token = (0, import_client2.useToken)();
147
+ const [mutate, result] = (0, import_client.useMutation)(mutation, options);
148
+ const method = (0, import_react.useCallback)(
169
149
  (input) => mutate({
170
150
  // @ts-expect-error -- to allow dynamic props
171
151
  variables: { input },
@@ -177,8 +157,7 @@ function useAuthMutation(mutation, options) {
177
157
  }
178
158
  // Annotate the CommonJS export names for ESM import in node:
179
159
  0 && (module.exports = {
180
- ApolloWrapperClient,
181
- ApolloWrapperNext,
160
+ ApolloWrapper,
182
161
  tokenContext,
183
162
  useAuthMutation,
184
163
  useAuthQuery
@@ -3,9 +3,8 @@ import * as _apollo_client from '@apollo/client';
3
3
  import { InMemoryCacheConfig, OperationVariables, ApolloClient, MutationHookOptions } from '@apollo/client';
4
4
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
5
5
  import React__default, { PropsWithChildren } from 'react';
6
- export { ApolloWrapper as ApolloWrapperNext } from './next.mjs';
7
6
 
8
- declare const ApolloWrapperClient: ({ children, cacheConfig, }: PropsWithChildren<{
7
+ declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
9
8
  cacheConfig?: InMemoryCacheConfig;
10
9
  }>) => React__default.JSX.Element;
11
10
  /**
@@ -130,4 +129,4 @@ declare function useAuthMutation<T, V extends OperationVariables>(mutation: Type
130
129
  readonly reset: () => void;
131
130
  }];
132
131
 
133
- export { ApolloWrapperClient, tokenContext, useAuthMutation, useAuthQuery };
132
+ export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -3,9 +3,8 @@ import * as _apollo_client from '@apollo/client';
3
3
  import { InMemoryCacheConfig, OperationVariables, ApolloClient, MutationHookOptions } from '@apollo/client';
4
4
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
5
5
  import React__default, { PropsWithChildren } from 'react';
6
- export { ApolloWrapper as ApolloWrapperNext } from './next.js';
7
6
 
8
- declare const ApolloWrapperClient: ({ children, cacheConfig, }: PropsWithChildren<{
7
+ declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
9
8
  cacheConfig?: InMemoryCacheConfig;
10
9
  }>) => React__default.JSX.Element;
11
10
  /**
@@ -130,4 +129,4 @@ declare function useAuthMutation<T, V extends OperationVariables>(mutation: Type
130
129
  readonly reset: () => void;
131
130
  }];
132
131
 
133
- export { ApolloWrapperClient, tokenContext, useAuthMutation, useAuthQuery };
132
+ export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -2,15 +2,15 @@
2
2
 
3
3
  // src/graphql/client.tsx
4
4
  import {
5
- ApolloClient as ApolloClient2,
5
+ ApolloClient,
6
6
  ApolloProvider,
7
- HttpLink as HttpLink2,
8
- InMemoryCache as InMemoryCache2,
7
+ HttpLink,
8
+ InMemoryCache,
9
9
  useLazyQuery,
10
10
  useMutation
11
11
  } from "@apollo/client";
12
12
  import { useToken } from "naystack/auth/client";
13
- import React2, {
13
+ import React, {
14
14
  useCallback,
15
15
  useEffect,
16
16
  useRef
@@ -66,14 +66,7 @@ function getEnv(key, skipCheck) {
66
66
  return value;
67
67
  }
68
68
 
69
- // src/graphql/next.tsx
70
- import { HttpLink } from "@apollo/client";
71
- import {
72
- ApolloClient,
73
- ApolloNextAppProvider,
74
- InMemoryCache
75
- } from "@apollo/client-integration-nextjs";
76
- import React from "react";
69
+ // src/graphql/client.tsx
77
70
  function makeClient(cacheConfig) {
78
71
  return new ApolloClient({
79
72
  cache: new InMemoryCache(cacheConfig),
@@ -86,23 +79,7 @@ var ApolloWrapper = ({
86
79
  children,
87
80
  cacheConfig
88
81
  }) => {
89
- return /* @__PURE__ */ React.createElement(ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
90
- };
91
-
92
- // src/graphql/client.tsx
93
- function makeClient2(cacheConfig) {
94
- return new ApolloClient2({
95
- cache: new InMemoryCache2(cacheConfig),
96
- link: new HttpLink2({
97
- uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
98
- })
99
- });
100
- }
101
- var ApolloWrapperClient = ({
102
- children,
103
- cacheConfig
104
- }) => {
105
- return /* @__PURE__ */ React2.createElement(ApolloProvider, { client: makeClient2(cacheConfig) }, children);
82
+ return /* @__PURE__ */ React.createElement(ApolloProvider, { client: makeClient(cacheConfig) }, children);
106
83
  };
107
84
  var tokenContext = (token) => {
108
85
  if (!token) return void 0;
@@ -154,8 +131,7 @@ function useAuthMutation(mutation, options) {
154
131
  return [method, { ...result, hasAuth: !!token }];
155
132
  }
156
133
  export {
157
- ApolloWrapperClient,
158
- ApolloWrapper as ApolloWrapperNext,
134
+ ApolloWrapper,
159
135
  tokenContext,
160
136
  useAuthMutation,
161
137
  useAuthQuery
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.7.11",
3
+ "version": "1.7.13",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -33,6 +33,11 @@
33
33
  "import": "./dist/graphql/client.esm.js",
34
34
  "require": "./dist/graphql/client.cjs.js"
35
35
  },
36
+ "./graphql/next": {
37
+ "types": "./dist/graphql/next.d.ts",
38
+ "import": "./dist/graphql/next.esm.js",
39
+ "require": "./dist/graphql/next.cjs.js"
40
+ },
36
41
  "./file": {
37
42
  "types": "./dist/file/index.d.ts",
38
43
  "import": "./dist/file/index.esm.js",