naystack 1.5.16 → 1.5.18

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,8 +31,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/auth/email/client.tsx
32
32
  var client_exports = {};
33
33
  __export(client_exports, {
34
+ AuthApply: () => AuthApply,
34
35
  AuthWrapper: () => AuthWrapper,
35
36
  TokenContext: () => TokenContext,
37
+ useAuthFetch: () => useAuthFetch,
36
38
  useLogin: () => useLogin,
37
39
  useLogout: () => useLogout,
38
40
  useSetToken: () => useSetToken,
@@ -98,13 +100,25 @@ var TokenContext = (0, import_react.createContext)({
98
100
  });
99
101
  var AuthWrapper = ({ children }) => {
100
102
  const [token, setToken] = (0, import_react.useState)(null);
103
+ return /* @__PURE__ */ import_react.default.createElement(TokenContext.Provider, { value: { token, setToken } }, children);
104
+ };
105
+ function useAuthFetch() {
106
+ const setToken = useSetToken();
101
107
  (0, import_react.useEffect)(() => {
102
108
  fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
103
109
  credentials: "include"
104
110
  }).then((res) => res.json()).then((data) => setToken(data.accessToken));
105
111
  }, []);
106
- return /* @__PURE__ */ import_react.default.createElement(TokenContext.Provider, { value: { token, setToken } }, children);
107
- };
112
+ }
113
+ function AuthApply({ data }) {
114
+ const setToken = useSetToken();
115
+ (0, import_react.useEffect)(() => {
116
+ if (data) {
117
+ setToken(data);
118
+ }
119
+ }, [data]);
120
+ return null;
121
+ }
108
122
  function useToken() {
109
123
  const { token } = (0, import_react.useContext)(TokenContext);
110
124
  return token;
@@ -173,8 +187,10 @@ function useLogout() {
173
187
  }
174
188
  // Annotate the CommonJS export names for ESM import in node:
175
189
  0 && (module.exports = {
190
+ AuthApply,
176
191
  AuthWrapper,
177
192
  TokenContext,
193
+ useAuthFetch,
178
194
  useLogin,
179
195
  useLogout,
180
196
  useSetToken,
@@ -42,6 +42,10 @@ declare const TokenContext: React__default.Context<{
42
42
  declare const AuthWrapper: ({ children }: {
43
43
  children: React__default.ReactNode;
44
44
  }) => React__default.JSX.Element;
45
+ declare function useAuthFetch(): void;
46
+ declare function AuthApply({ data }: {
47
+ data?: string | null;
48
+ }): null;
45
49
  /**
46
50
  * Returns the current JWT access token from TokenContext. Must be used inside `AuthWrapper`.
47
51
  *
@@ -162,4 +166,4 @@ declare function useLogin(): (data: object) => Promise<string | null>;
162
166
  */
163
167
  declare function useLogout(): (data?: object) => Promise<void>;
164
168
 
165
- export { AuthWrapper, TokenContext, useLogin, useLogout, useSetToken, useSignUp, useToken };
169
+ export { AuthApply, AuthWrapper, TokenContext, useAuthFetch, useLogin, useLogout, useSetToken, useSignUp, useToken };
@@ -42,6 +42,10 @@ declare const TokenContext: React__default.Context<{
42
42
  declare const AuthWrapper: ({ children }: {
43
43
  children: React__default.ReactNode;
44
44
  }) => React__default.JSX.Element;
45
+ declare function useAuthFetch(): void;
46
+ declare function AuthApply({ data }: {
47
+ data?: string | null;
48
+ }): null;
45
49
  /**
46
50
  * Returns the current JWT access token from TokenContext. Must be used inside `AuthWrapper`.
47
51
  *
@@ -162,4 +166,4 @@ declare function useLogin(): (data: object) => Promise<string | null>;
162
166
  */
163
167
  declare function useLogout(): (data?: object) => Promise<void>;
164
168
 
165
- export { AuthWrapper, TokenContext, useLogin, useLogout, useSetToken, useSignUp, useToken };
169
+ export { AuthApply, AuthWrapper, TokenContext, useAuthFetch, useLogin, useLogout, useSetToken, useSignUp, useToken };
@@ -65,13 +65,25 @@ var TokenContext = createContext({
65
65
  });
66
66
  var AuthWrapper = ({ children }) => {
67
67
  const [token, setToken] = useState(null);
68
+ return /* @__PURE__ */ React.createElement(TokenContext.Provider, { value: { token, setToken } }, children);
69
+ };
70
+ function useAuthFetch() {
71
+ const setToken = useSetToken();
68
72
  useEffect(() => {
69
73
  fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
70
74
  credentials: "include"
71
75
  }).then((res) => res.json()).then((data) => setToken(data.accessToken));
72
76
  }, []);
73
- return /* @__PURE__ */ React.createElement(TokenContext.Provider, { value: { token, setToken } }, children);
74
- };
77
+ }
78
+ function AuthApply({ data }) {
79
+ const setToken = useSetToken();
80
+ useEffect(() => {
81
+ if (data) {
82
+ setToken(data);
83
+ }
84
+ }, [data]);
85
+ return null;
86
+ }
75
87
  function useToken() {
76
88
  const { token } = useContext(TokenContext);
77
89
  return token;
@@ -139,8 +151,10 @@ function useLogout() {
139
151
  );
140
152
  }
141
153
  export {
154
+ AuthApply,
142
155
  AuthWrapper,
143
156
  TokenContext,
157
+ useAuthFetch,
144
158
  useLogin,
145
159
  useLogout,
146
160
  useSetToken,
@@ -0,0 +1,158 @@
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
+
30
+ // src/auth/email/server.tsx
31
+ var server_exports = {};
32
+ __export(server_exports, {
33
+ default: () => AuthFetch
34
+ });
35
+ module.exports = __toCommonJS(server_exports);
36
+ var import_headers2 = require("next/headers");
37
+
38
+ // src/auth/email/client.tsx
39
+ var import_react = __toESM(require("react"));
40
+
41
+ // src/env.ts
42
+ var getEnvValue = (key) => {
43
+ switch (key) {
44
+ case "NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */:
45
+ return process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT;
46
+ case "NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */:
47
+ return process.env.NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT;
48
+ case "NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT" /* NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT */:
49
+ return process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT;
50
+ case "NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */:
51
+ return process.env.NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT;
52
+ case "NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */:
53
+ return process.env.NEXT_PUBLIC_FILE_ENDPOINT;
54
+ case "NEXT_PUBLIC_BASE_URL" /* NEXT_PUBLIC_BASE_URL */:
55
+ return process.env.NEXT_PUBLIC_BASE_URL;
56
+ case "REFRESH_KEY" /* REFRESH_KEY */:
57
+ return process.env.REFRESH_KEY;
58
+ case "SIGNING_KEY" /* SIGNING_KEY */:
59
+ return process.env.SIGNING_KEY;
60
+ case "INSTAGRAM_CLIENT_SECRET" /* INSTAGRAM_CLIENT_SECRET */:
61
+ return process.env.INSTAGRAM_CLIENT_SECRET;
62
+ case "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */:
63
+ return process.env.INSTAGRAM_CLIENT_ID;
64
+ case "GOOGLE_CLIENT_SECRET" /* GOOGLE_CLIENT_SECRET */:
65
+ return process.env.GOOGLE_CLIENT_SECRET;
66
+ case "GOOGLE_CLIENT_ID" /* GOOGLE_CLIENT_ID */:
67
+ return process.env.GOOGLE_CLIENT_ID;
68
+ case "TURNSTILE_KEY" /* TURNSTILE_KEY */:
69
+ return process.env.TURNSTILE_KEY;
70
+ case "AWS_ACCESS_KEY_ID" /* AWS_ACCESS_KEY_ID */:
71
+ return process.env.AWS_ACCESS_KEY_ID;
72
+ case "AWS_ACCESS_KEY_SECRET" /* AWS_ACCESS_KEY_SECRET */:
73
+ return process.env.AWS_ACCESS_KEY_SECRET;
74
+ case "AWS_REGION" /* AWS_REGION */:
75
+ return process.env.AWS_REGION;
76
+ case "AWS_BUCKET" /* AWS_BUCKET */:
77
+ return process.env.AWS_BUCKET;
78
+ case "NODE_ENV" /* NODE_ENV */:
79
+ return process.env.NODE_ENV;
80
+ default:
81
+ return process.env[key];
82
+ }
83
+ };
84
+ function getEnv(key, skipCheck) {
85
+ const value = getEnvValue(key);
86
+ if (!skipCheck && !value) throw new Error(`${key} is not defined`);
87
+ return value;
88
+ }
89
+
90
+ // src/auth/email/client.tsx
91
+ var TokenContext = (0, import_react.createContext)({
92
+ token: null,
93
+ setToken: () => null
94
+ });
95
+ function AuthApply({ data }) {
96
+ const setToken = useSetToken();
97
+ (0, import_react.useEffect)(() => {
98
+ if (data) {
99
+ setToken(data);
100
+ }
101
+ }, [data]);
102
+ return null;
103
+ }
104
+ function useSetToken() {
105
+ const { setToken } = (0, import_react.useContext)(TokenContext);
106
+ return setToken;
107
+ }
108
+
109
+ // src/graphql/server.tsx
110
+ var import_client = require("@apollo/client");
111
+ var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
112
+ var import_headers = require("next/headers");
113
+ var import_react2 = __toESM(require("react"));
114
+ var import_react3 = require("react");
115
+ function Injector({
116
+ fetch: fetch2,
117
+ Component,
118
+ props
119
+ }) {
120
+ return /* @__PURE__ */ import_react2.default.createElement(import_react3.Suspense, { fallback: /* @__PURE__ */ import_react2.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react2.default.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
121
+ }
122
+ async function InjectorSuspensed({
123
+ fetch: fetch2,
124
+ Component,
125
+ props
126
+ }) {
127
+ const data = await fetch2();
128
+ return /* @__PURE__ */ import_react2.default.createElement(Component, { loading: false, ...props || {}, data });
129
+ }
130
+ var { query: gqlQuery } = (0, import_client_integration_nextjs.registerApolloClient)(() => {
131
+ return new import_client.ApolloClient({
132
+ cache: new import_client.InMemoryCache(),
133
+ link: new import_client.HttpLink({
134
+ uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
135
+ })
136
+ });
137
+ });
138
+
139
+ // src/auth/email/server.tsx
140
+ function AuthFetch() {
141
+ return /* @__PURE__ */ React.createElement(
142
+ Injector,
143
+ {
144
+ fetch: async () => {
145
+ const cookie = await (0, import_headers2.cookies)();
146
+ const token = cookie.get("refresh");
147
+ if (!token) return null;
148
+ return fetch(process.env.NEXT_PUBLIC_BACKEND_BASE_URL + `/email`, {
149
+ credentials: "include",
150
+ headers: {
151
+ Cookie: cookie.toString()
152
+ }
153
+ }).then((res) => res.json()).then((data) => data.accessToken).catch(() => null);
154
+ },
155
+ Component: AuthApply
156
+ }
157
+ );
158
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+
3
+ declare function AuthFetch(): React.JSX.Element;
4
+
5
+ export { AuthFetch as default };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+
3
+ declare function AuthFetch(): React.JSX.Element;
4
+
5
+ export { AuthFetch as default };
@@ -0,0 +1,137 @@
1
+ // src/auth/email/server.tsx
2
+ import { cookies as cookies2 } from "next/headers";
3
+
4
+ // src/auth/email/client.tsx
5
+ import React2, {
6
+ createContext,
7
+ useCallback,
8
+ useContext,
9
+ useEffect,
10
+ useState
11
+ } from "react";
12
+
13
+ // src/env.ts
14
+ var getEnvValue = (key) => {
15
+ switch (key) {
16
+ case "NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */:
17
+ return process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT;
18
+ case "NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */:
19
+ return process.env.NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT;
20
+ case "NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT" /* NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT */:
21
+ return process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT;
22
+ case "NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */:
23
+ return process.env.NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT;
24
+ case "NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */:
25
+ return process.env.NEXT_PUBLIC_FILE_ENDPOINT;
26
+ case "NEXT_PUBLIC_BASE_URL" /* NEXT_PUBLIC_BASE_URL */:
27
+ return process.env.NEXT_PUBLIC_BASE_URL;
28
+ case "REFRESH_KEY" /* REFRESH_KEY */:
29
+ return process.env.REFRESH_KEY;
30
+ case "SIGNING_KEY" /* SIGNING_KEY */:
31
+ return process.env.SIGNING_KEY;
32
+ case "INSTAGRAM_CLIENT_SECRET" /* INSTAGRAM_CLIENT_SECRET */:
33
+ return process.env.INSTAGRAM_CLIENT_SECRET;
34
+ case "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */:
35
+ return process.env.INSTAGRAM_CLIENT_ID;
36
+ case "GOOGLE_CLIENT_SECRET" /* GOOGLE_CLIENT_SECRET */:
37
+ return process.env.GOOGLE_CLIENT_SECRET;
38
+ case "GOOGLE_CLIENT_ID" /* GOOGLE_CLIENT_ID */:
39
+ return process.env.GOOGLE_CLIENT_ID;
40
+ case "TURNSTILE_KEY" /* TURNSTILE_KEY */:
41
+ return process.env.TURNSTILE_KEY;
42
+ case "AWS_ACCESS_KEY_ID" /* AWS_ACCESS_KEY_ID */:
43
+ return process.env.AWS_ACCESS_KEY_ID;
44
+ case "AWS_ACCESS_KEY_SECRET" /* AWS_ACCESS_KEY_SECRET */:
45
+ return process.env.AWS_ACCESS_KEY_SECRET;
46
+ case "AWS_REGION" /* AWS_REGION */:
47
+ return process.env.AWS_REGION;
48
+ case "AWS_BUCKET" /* AWS_BUCKET */:
49
+ return process.env.AWS_BUCKET;
50
+ case "NODE_ENV" /* NODE_ENV */:
51
+ return process.env.NODE_ENV;
52
+ default:
53
+ return process.env[key];
54
+ }
55
+ };
56
+ function getEnv(key, skipCheck) {
57
+ const value = getEnvValue(key);
58
+ if (!skipCheck && !value) throw new Error(`${key} is not defined`);
59
+ return value;
60
+ }
61
+
62
+ // src/auth/email/client.tsx
63
+ var TokenContext = createContext({
64
+ token: null,
65
+ setToken: () => null
66
+ });
67
+ function AuthApply({ data }) {
68
+ const setToken = useSetToken();
69
+ useEffect(() => {
70
+ if (data) {
71
+ setToken(data);
72
+ }
73
+ }, [data]);
74
+ return null;
75
+ }
76
+ function useSetToken() {
77
+ const { setToken } = useContext(TokenContext);
78
+ return setToken;
79
+ }
80
+
81
+ // src/graphql/server.tsx
82
+ import {
83
+ ApolloClient,
84
+ HttpLink,
85
+ InMemoryCache
86
+ } from "@apollo/client";
87
+ import { registerApolloClient } from "@apollo/client-integration-nextjs";
88
+ import { cookies } from "next/headers";
89
+ import React3 from "react";
90
+ import { Suspense } from "react";
91
+ function Injector({
92
+ fetch: fetch2,
93
+ Component,
94
+ props
95
+ }) {
96
+ return /* @__PURE__ */ React3.createElement(Suspense, { fallback: /* @__PURE__ */ React3.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React3.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
97
+ }
98
+ async function InjectorSuspensed({
99
+ fetch: fetch2,
100
+ Component,
101
+ props
102
+ }) {
103
+ const data = await fetch2();
104
+ return /* @__PURE__ */ React3.createElement(Component, { loading: false, ...props || {}, data });
105
+ }
106
+ var { query: gqlQuery } = registerApolloClient(() => {
107
+ return new ApolloClient({
108
+ cache: new InMemoryCache(),
109
+ link: new HttpLink({
110
+ uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
111
+ })
112
+ });
113
+ });
114
+
115
+ // src/auth/email/server.tsx
116
+ function AuthFetch() {
117
+ return /* @__PURE__ */ React.createElement(
118
+ Injector,
119
+ {
120
+ fetch: async () => {
121
+ const cookie = await cookies2();
122
+ const token = cookie.get("refresh");
123
+ if (!token) return null;
124
+ return fetch(process.env.NEXT_PUBLIC_BACKEND_BASE_URL + `/email`, {
125
+ credentials: "include",
126
+ headers: {
127
+ Cookie: cookie.toString()
128
+ }
129
+ }).then((res) => res.json()).then((data) => data.accessToken).catch(() => null);
130
+ },
131
+ Component: AuthApply
132
+ }
133
+ );
134
+ }
135
+ export {
136
+ AuthFetch as default
137
+ };
@@ -123,16 +123,17 @@ function useAuthQuery(query, variables) {
123
123
  if (token && variables && calledVars !== JSON.stringify(variables)) {
124
124
  setCalledVars(JSON.stringify(variables));
125
125
  void fetch({
126
- variables,
126
+ // @ts-expect-error -- to allow dynamic props
127
+ variables: { input },
127
128
  context: tokenContext(token),
128
129
  fetchPolicy: "no-cache"
129
130
  });
130
131
  }
131
132
  }, [fetch, token, variables, calledVars]);
132
133
  const reFetch = (0, import_react.useCallback)(
133
- (input) => fetch({
134
+ (input2) => fetch({
134
135
  // @ts-expect-error -- to allow dynamic props
135
- variables: { input },
136
+ variables: { input: input2 },
136
137
  context: tokenContext(token),
137
138
  fetchPolicy: "no-cache"
138
139
  }),
@@ -144,9 +145,9 @@ function useAuthMutation(mutation, options) {
144
145
  const token = (0, import_client2.useToken)();
145
146
  const [mutate, result] = (0, import_client.useMutation)(mutation, options);
146
147
  const method = (0, import_react.useCallback)(
147
- (input) => mutate({
148
+ (input2) => mutate({
148
149
  // @ts-expect-error -- to allow dynamic props
149
- variables: { input },
150
+ variables: { input: input2 },
150
151
  context: tokenContext(token)
151
152
  }),
152
153
  [token]
@@ -90,7 +90,7 @@ declare const tokenContext: (token?: string | null) => {
90
90
  *
91
91
  * @category GraphQL
92
92
  */
93
- declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(input: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
93
+ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V["input"]): readonly [(input?: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
94
94
  /**
95
95
  * Hook to run a GraphQL mutation with the current user's token. Returns a function you call with the mutation input.
96
96
  *
@@ -126,6 +126,6 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
126
126
  *
127
127
  * @category GraphQL
128
128
  */
129
- declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
129
+ declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
130
130
 
131
131
  export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -90,7 +90,7 @@ declare const tokenContext: (token?: string | null) => {
90
90
  *
91
91
  * @category GraphQL
92
92
  */
93
- declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(input: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
93
+ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V["input"]): readonly [(input?: V["input"]) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
94
94
  /**
95
95
  * Hook to run a GraphQL mutation with the current user's token. Returns a function you call with the mutation input.
96
96
  *
@@ -126,6 +126,6 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
126
126
  *
127
127
  * @category GraphQL
128
128
  */
129
- declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
129
+ declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
130
130
 
131
131
  export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -99,16 +99,17 @@ function useAuthQuery(query, variables) {
99
99
  if (token && variables && calledVars !== JSON.stringify(variables)) {
100
100
  setCalledVars(JSON.stringify(variables));
101
101
  void fetch({
102
- variables,
102
+ // @ts-expect-error -- to allow dynamic props
103
+ variables: { input },
103
104
  context: tokenContext(token),
104
105
  fetchPolicy: "no-cache"
105
106
  });
106
107
  }
107
108
  }, [fetch, token, variables, calledVars]);
108
109
  const reFetch = useCallback(
109
- (input) => fetch({
110
+ (input2) => fetch({
110
111
  // @ts-expect-error -- to allow dynamic props
111
- variables: { input },
112
+ variables: { input: input2 },
112
113
  context: tokenContext(token),
113
114
  fetchPolicy: "no-cache"
114
115
  }),
@@ -120,9 +121,9 @@ function useAuthMutation(mutation, options) {
120
121
  const token = useToken();
121
122
  const [mutate, result] = useMutation(mutation, options);
122
123
  const method = useCallback(
123
- (input) => mutate({
124
+ (input2) => mutate({
124
125
  // @ts-expect-error -- to allow dynamic props
125
- variables: { input },
126
+ variables: { input: input2 },
126
127
  context: tokenContext(token)
127
128
  }),
128
129
  [token]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.5.16",
3
+ "version": "1.5.18",
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",