naystack 1.7.0 → 1.7.3
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/README.md +45 -28
- package/dist/auth/client.cjs.js +230 -0
- package/dist/auth/client.d.mts +3 -0
- package/dist/auth/client.d.ts +3 -0
- package/dist/auth/client.esm.js +190 -0
- package/dist/auth/email/client.cjs.js +6 -2
- package/dist/auth/email/client.d.mts +34 -12
- package/dist/auth/email/client.d.ts +34 -12
- package/dist/auth/email/client.esm.js +6 -2
- package/dist/auth/email/index.cjs.js +11 -6
- package/dist/auth/email/index.d.mts +8 -7
- package/dist/auth/email/index.d.ts +8 -7
- package/dist/auth/email/index.esm.js +9 -5
- package/dist/auth/email/{server.cjs.js → next.cjs.js} +16 -7
- package/dist/auth/email/next.d.mts +7 -0
- package/dist/auth/email/next.d.ts +7 -0
- package/dist/auth/email/{server.esm.js → next.esm.js} +8 -4
- package/dist/auth/email/routes/delete.d.mts +3 -3
- package/dist/auth/email/routes/delete.d.ts +3 -3
- package/dist/auth/email/routes/get.d.mts +3 -3
- package/dist/auth/email/routes/get.d.ts +3 -3
- package/dist/auth/email/routes/post.d.mts +3 -3
- package/dist/auth/email/routes/post.d.ts +3 -3
- package/dist/auth/email/routes/put.d.mts +3 -3
- package/dist/auth/email/routes/put.d.ts +3 -3
- package/dist/auth/email/token.cjs.js +3 -3
- package/dist/auth/email/token.d.mts +2 -2
- package/dist/auth/email/token.d.ts +2 -2
- package/dist/auth/email/token.esm.js +3 -3
- package/dist/auth/email/types.d.mts +5 -4
- package/dist/auth/email/types.d.ts +5 -4
- package/dist/auth/email/utils.d.mts +3 -3
- package/dist/auth/email/utils.d.ts +3 -3
- package/dist/auth/google/get.d.mts +3 -3
- package/dist/auth/google/get.d.ts +3 -3
- package/dist/auth/google/index.cjs.js +3 -3
- package/dist/auth/google/index.d.mts +7 -7
- package/dist/auth/google/index.d.ts +7 -7
- package/dist/auth/google/index.esm.js +2 -2
- package/dist/auth/index.cjs.js +25 -25
- package/dist/auth/index.d.mts +5 -4
- package/dist/auth/index.d.ts +5 -4
- package/dist/auth/index.esm.js +12 -12
- package/dist/auth/instagram/index.cjs.js +6 -6
- package/dist/auth/instagram/index.d.mts +8 -9
- package/dist/auth/instagram/index.d.ts +8 -9
- package/dist/auth/instagram/index.esm.js +5 -5
- package/dist/auth/instagram/route.cjs.js +3 -3
- package/dist/auth/instagram/route.d.mts +3 -3
- package/dist/auth/instagram/route.d.ts +3 -3
- package/dist/auth/instagram/route.esm.js +3 -3
- package/dist/file/client.cjs.js +1 -1
- package/dist/file/client.d.mts +7 -7
- package/dist/file/client.d.ts +7 -7
- package/dist/file/client.esm.js +1 -1
- package/dist/graphql/client.cjs.js +1 -1
- package/dist/graphql/client.d.mts +5 -5
- package/dist/graphql/client.d.ts +5 -5
- package/dist/graphql/client.esm.js +1 -1
- package/dist/graphql/index.cjs.js +94 -6
- package/dist/graphql/index.d.mts +7 -2
- package/dist/graphql/index.d.ts +7 -2
- package/dist/graphql/index.esm.js +97 -4
- package/dist/graphql/init.cjs.js +3 -3
- package/dist/graphql/init.d.mts +4 -4
- package/dist/graphql/init.d.ts +4 -4
- package/dist/graphql/init.esm.js +2 -2
- package/dist/graphql/utils.cjs.js +17 -3
- package/dist/graphql/utils.d.mts +16 -16
- package/dist/graphql/utils.d.ts +16 -16
- package/dist/graphql/utils.esm.js +16 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/socials/instagram/webhook.d.mts +2 -2
- package/dist/socials/instagram/webhook.d.ts +2 -2
- package/dist/{client → utils/client}/hooks.cjs.js +1 -1
- package/dist/{client → utils/client}/hooks.esm.js +1 -1
- package/dist/{client → utils/client}/index.cjs.js +3 -3
- package/dist/{client → utils/client}/index.esm.js +2 -2
- package/dist/{client → utils/client}/seo.cjs.js +2 -2
- package/dist/{client → utils/client}/seo.esm.js +1 -1
- package/dist/utils/route.d.mts +20 -0
- package/dist/utils/route.d.ts +20 -0
- package/package.json +17 -32
- package/dist/auth/email/server.d.mts +0 -5
- package/dist/auth/email/server.d.ts +0 -5
- /package/dist/{client → utils/client}/hooks.d.mts +0 -0
- /package/dist/{client → utils/client}/hooks.d.ts +0 -0
- /package/dist/{client → utils/client}/index.d.mts +0 -0
- /package/dist/{client → utils/client}/index.d.ts +0 -0
- /package/dist/{client → utils/client}/seo.d.mts +0 -0
- /package/dist/{client → utils/client}/seo.d.ts +0 -0
|
@@ -21,7 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var instagram_exports = {};
|
|
22
22
|
__export(instagram_exports, {
|
|
23
23
|
getRefreshedInstagramAccessToken: () => getRefreshedInstagramAccessToken,
|
|
24
|
-
|
|
24
|
+
setupInstagramAuth: () => setupInstagramAuth
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(instagram_exports);
|
|
27
27
|
|
|
@@ -86,10 +86,10 @@ function getEnv(key, skipCheck) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// src/auth/email/token.ts
|
|
89
|
-
function getUserIdFromAccessToken(
|
|
90
|
-
if (
|
|
89
|
+
function getUserIdFromAccessToken(accessToken) {
|
|
90
|
+
if (accessToken)
|
|
91
91
|
try {
|
|
92
|
-
const decoded = (0, import_jsonwebtoken.verify)(
|
|
92
|
+
const decoded = (0, import_jsonwebtoken.verify)(accessToken, getEnv("SIGNING_KEY" /* SIGNING_KEY */));
|
|
93
93
|
if (typeof decoded !== "string" && typeof decoded.id === "number")
|
|
94
94
|
return decoded.id;
|
|
95
95
|
} catch (e) {
|
|
@@ -196,7 +196,7 @@ var getInstagramRoute = ({
|
|
|
196
196
|
};
|
|
197
197
|
|
|
198
198
|
// src/auth/instagram/index.ts
|
|
199
|
-
function
|
|
199
|
+
function setupInstagramAuth(props) {
|
|
200
200
|
return {
|
|
201
201
|
GET: getInstagramRoute(props)
|
|
202
202
|
};
|
|
@@ -204,5 +204,5 @@ function initInstagramAuth(props) {
|
|
|
204
204
|
// Annotate the CommonJS export names for ESM import in node:
|
|
205
205
|
0 && (module.exports = {
|
|
206
206
|
getRefreshedInstagramAccessToken,
|
|
207
|
-
|
|
207
|
+
setupInstagramAuth
|
|
208
208
|
});
|
|
@@ -3,7 +3,7 @@ export { getRefreshedInstagramAccessToken } from './utils.mjs';
|
|
|
3
3
|
import { InstagramUser } from '../../socials/instagram/types.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Options for initializing Instagram OAuth via {@link
|
|
6
|
+
* Options for initializing Instagram OAuth via {@link setupInstagramAuth}.
|
|
7
7
|
*
|
|
8
8
|
* @property onUser - Called with `(instagramUser, appUserId, accessToken)` after successful OAuth. Return a string to show as error (redirects to `errorRedirectURL`); return `void` on success.
|
|
9
9
|
* @property redirectURL - Where to redirect after successful Instagram auth.
|
|
@@ -11,7 +11,7 @@ import { InstagramUser } from '../../socials/instagram/types.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* @category Auth
|
|
13
13
|
*/
|
|
14
|
-
interface
|
|
14
|
+
interface SetupInstagramAuthOptions {
|
|
15
15
|
onUser: (data: InstagramUser, id: number | null, accessToken: string) => Promise<string | void>;
|
|
16
16
|
redirectURL: string;
|
|
17
17
|
errorRedirectURL: string;
|
|
@@ -23,28 +23,27 @@ interface InitInstagramAuthOptions {
|
|
|
23
23
|
*
|
|
24
24
|
* Requires env vars: `INSTAGRAM_CLIENT_ID`, `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
|
|
25
25
|
*
|
|
26
|
-
* @param props - Options. See {@link
|
|
26
|
+
* @param props - Options. See {@link SetupInstagramAuthOptions}.
|
|
27
27
|
* @returns Object with `GET` (route handler) and `getRefreshedAccessToken` (refreshes a long-lived token).
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
31
|
* // app/api/(auth)/instagram/route.ts
|
|
32
|
-
* import {
|
|
32
|
+
* import { setupInstagramAuth } from "naystack/auth";
|
|
33
33
|
*
|
|
34
|
-
* export const { GET
|
|
34
|
+
* export const { GET } = setupInstagramAuth({
|
|
35
35
|
* onUser: async (igUser, appUserId, accessToken) => {
|
|
36
36
|
* await saveInstagramUser(appUserId, igUser, accessToken);
|
|
37
37
|
* },
|
|
38
|
-
*
|
|
38
|
+
* redirectURL: "/dashboard",
|
|
39
39
|
* errorRedirectURL: "/login",
|
|
40
|
-
* refreshKey: process.env.REFRESH_KEY!,
|
|
41
40
|
* });
|
|
42
41
|
* ```
|
|
43
42
|
*
|
|
44
43
|
* @category Auth
|
|
45
44
|
*/
|
|
46
|
-
declare function
|
|
45
|
+
declare function setupInstagramAuth(props: SetupInstagramAuthOptions): {
|
|
47
46
|
GET: (req: next_server.NextRequest) => Promise<next_server.NextResponse<unknown>>;
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
export { type
|
|
49
|
+
export { type SetupInstagramAuthOptions, setupInstagramAuth };
|
|
@@ -3,7 +3,7 @@ export { getRefreshedInstagramAccessToken } from './utils.js';
|
|
|
3
3
|
import { InstagramUser } from '../../socials/instagram/types.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Options for initializing Instagram OAuth via {@link
|
|
6
|
+
* Options for initializing Instagram OAuth via {@link setupInstagramAuth}.
|
|
7
7
|
*
|
|
8
8
|
* @property onUser - Called with `(instagramUser, appUserId, accessToken)` after successful OAuth. Return a string to show as error (redirects to `errorRedirectURL`); return `void` on success.
|
|
9
9
|
* @property redirectURL - Where to redirect after successful Instagram auth.
|
|
@@ -11,7 +11,7 @@ import { InstagramUser } from '../../socials/instagram/types.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @category Auth
|
|
13
13
|
*/
|
|
14
|
-
interface
|
|
14
|
+
interface SetupInstagramAuthOptions {
|
|
15
15
|
onUser: (data: InstagramUser, id: number | null, accessToken: string) => Promise<string | void>;
|
|
16
16
|
redirectURL: string;
|
|
17
17
|
errorRedirectURL: string;
|
|
@@ -23,28 +23,27 @@ interface InitInstagramAuthOptions {
|
|
|
23
23
|
*
|
|
24
24
|
* Requires env vars: `INSTAGRAM_CLIENT_ID`, `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
|
|
25
25
|
*
|
|
26
|
-
* @param props - Options. See {@link
|
|
26
|
+
* @param props - Options. See {@link SetupInstagramAuthOptions}.
|
|
27
27
|
* @returns Object with `GET` (route handler) and `getRefreshedAccessToken` (refreshes a long-lived token).
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
31
|
* // app/api/(auth)/instagram/route.ts
|
|
32
|
-
* import {
|
|
32
|
+
* import { setupInstagramAuth } from "naystack/auth";
|
|
33
33
|
*
|
|
34
|
-
* export const { GET
|
|
34
|
+
* export const { GET } = setupInstagramAuth({
|
|
35
35
|
* onUser: async (igUser, appUserId, accessToken) => {
|
|
36
36
|
* await saveInstagramUser(appUserId, igUser, accessToken);
|
|
37
37
|
* },
|
|
38
|
-
*
|
|
38
|
+
* redirectURL: "/dashboard",
|
|
39
39
|
* errorRedirectURL: "/login",
|
|
40
|
-
* refreshKey: process.env.REFRESH_KEY!,
|
|
41
40
|
* });
|
|
42
41
|
* ```
|
|
43
42
|
*
|
|
44
43
|
* @category Auth
|
|
45
44
|
*/
|
|
46
|
-
declare function
|
|
45
|
+
declare function setupInstagramAuth(props: SetupInstagramAuthOptions): {
|
|
47
46
|
GET: (req: next_server.NextRequest) => Promise<next_server.NextResponse<unknown>>;
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
export { type
|
|
49
|
+
export { type SetupInstagramAuthOptions, setupInstagramAuth };
|
|
@@ -59,10 +59,10 @@ function getEnv(key, skipCheck) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// src/auth/email/token.ts
|
|
62
|
-
function getUserIdFromAccessToken(
|
|
63
|
-
if (
|
|
62
|
+
function getUserIdFromAccessToken(accessToken) {
|
|
63
|
+
if (accessToken)
|
|
64
64
|
try {
|
|
65
|
-
const decoded = verify(
|
|
65
|
+
const decoded = verify(accessToken, getEnv("SIGNING_KEY" /* SIGNING_KEY */));
|
|
66
66
|
if (typeof decoded !== "string" && typeof decoded.id === "number")
|
|
67
67
|
return decoded.id;
|
|
68
68
|
} catch (e) {
|
|
@@ -169,12 +169,12 @@ var getInstagramRoute = ({
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
// src/auth/instagram/index.ts
|
|
172
|
-
function
|
|
172
|
+
function setupInstagramAuth(props) {
|
|
173
173
|
return {
|
|
174
174
|
GET: getInstagramRoute(props)
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
export {
|
|
178
178
|
getRefreshedInstagramAccessToken,
|
|
179
|
-
|
|
179
|
+
setupInstagramAuth
|
|
180
180
|
};
|
|
@@ -83,10 +83,10 @@ function getEnv(key, skipCheck) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// src/auth/email/token.ts
|
|
86
|
-
function getUserIdFromAccessToken(
|
|
87
|
-
if (
|
|
86
|
+
function getUserIdFromAccessToken(accessToken) {
|
|
87
|
+
if (accessToken)
|
|
88
88
|
try {
|
|
89
|
-
const decoded = (0, import_jsonwebtoken.verify)(
|
|
89
|
+
const decoded = (0, import_jsonwebtoken.verify)(accessToken, getEnv("SIGNING_KEY" /* SIGNING_KEY */));
|
|
90
90
|
if (typeof decoded !== "string" && typeof decoded.id === "number")
|
|
91
91
|
return decoded.id;
|
|
92
92
|
} catch (e) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { SetupInstagramAuthOptions } from './index.mjs';
|
|
3
3
|
import './utils.mjs';
|
|
4
4
|
import '../../socials/instagram/types.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns the GET route handler for Instagram OAuth callback.
|
|
8
|
-
* @param options -
|
|
8
|
+
* @param options - SetupInstagramAuthOptions (onUser, redirect URLs)
|
|
9
9
|
* @returns Async route handler for the OAuth callback
|
|
10
10
|
*/
|
|
11
|
-
declare const getInstagramRoute: ({ redirectURL, errorRedirectURL, onUser, }:
|
|
11
|
+
declare const getInstagramRoute: ({ redirectURL, errorRedirectURL, onUser, }: SetupInstagramAuthOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
|
|
12
12
|
|
|
13
13
|
export { getInstagramRoute };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { SetupInstagramAuthOptions } from './index.js';
|
|
3
3
|
import './utils.js';
|
|
4
4
|
import '../../socials/instagram/types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns the GET route handler for Instagram OAuth callback.
|
|
8
|
-
* @param options -
|
|
8
|
+
* @param options - SetupInstagramAuthOptions (onUser, redirect URLs)
|
|
9
9
|
* @returns Async route handler for the OAuth callback
|
|
10
10
|
*/
|
|
11
|
-
declare const getInstagramRoute: ({ redirectURL, errorRedirectURL, onUser, }:
|
|
11
|
+
declare const getInstagramRoute: ({ redirectURL, errorRedirectURL, onUser, }: SetupInstagramAuthOptions) => (req: NextRequest) => Promise<NextResponse<unknown>>;
|
|
12
12
|
|
|
13
13
|
export { getInstagramRoute };
|
|
@@ -59,10 +59,10 @@ function getEnv(key, skipCheck) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// src/auth/email/token.ts
|
|
62
|
-
function getUserIdFromAccessToken(
|
|
63
|
-
if (
|
|
62
|
+
function getUserIdFromAccessToken(accessToken) {
|
|
63
|
+
if (accessToken)
|
|
64
64
|
try {
|
|
65
|
-
const decoded = verify(
|
|
65
|
+
const decoded = verify(accessToken, getEnv("SIGNING_KEY" /* SIGNING_KEY */));
|
|
66
66
|
if (typeof decoded !== "string" && typeof decoded.id === "number")
|
|
67
67
|
return decoded.id;
|
|
68
68
|
} catch (e) {
|
package/dist/file/client.cjs.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(client_exports, {
|
|
|
23
23
|
useFileUpload: () => useFileUpload
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(client_exports);
|
|
26
|
-
var import_client = require("naystack/auth/
|
|
26
|
+
var import_client = require("naystack/auth/client");
|
|
27
27
|
|
|
28
28
|
// src/env.ts
|
|
29
29
|
var EXTRA_ENV = globalThis.__NAYSTACK_ENV__ || (globalThis.__NAYSTACK_ENV__ = {});
|
package/dist/file/client.d.mts
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* The endpoint is read from `NEXT_PUBLIC_FILE_ENDPOINT` env var. The file is sent as multipart form data
|
|
6
6
|
* along with a `type` string and optional JSON `data` for metadata.
|
|
7
7
|
*
|
|
8
|
-
* @returns A function `(file, type,
|
|
8
|
+
* @returns A function `(file, type, config?) => Promise<FileUploadResponseType | null>`.
|
|
9
9
|
* - `file` — `File` or `Blob` to upload.
|
|
10
10
|
* - `type` — String category (e.g. `"avatar"`, `"DealDocument"`); sent as form field `type`.
|
|
11
|
-
* - `
|
|
12
|
-
*
|
|
11
|
+
* - `config` — Optional object with:
|
|
12
|
+
* - `data` — JSON-serializable metadata object; sent as form field `data`.
|
|
13
|
+
* - `async` — If `true`, the upload is processed asynchronously on the server.
|
|
14
|
+
* Resolves to the JSON response `{ url, data }` or `null`.
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* ```tsx
|
|
@@ -23,9 +25,7 @@
|
|
|
23
25
|
* setUploading(true);
|
|
24
26
|
* try {
|
|
25
27
|
* const result = await uploadFile(file, "DealDocument", {
|
|
26
|
-
* dealId,
|
|
27
|
-
* fileName: file.name,
|
|
28
|
-
* category: "Contract",
|
|
28
|
+
* data: { dealId, fileName: file.name, category: "Contract" },
|
|
29
29
|
* });
|
|
30
30
|
* if (result?.url) {
|
|
31
31
|
* console.log("Uploaded:", result.url);
|
|
@@ -50,7 +50,7 @@ declare const useFileUpload: () => (file: File | Blob, type: string, config?: {
|
|
|
50
50
|
* Shape of the JSON response from the file upload PUT endpoint.
|
|
51
51
|
*
|
|
52
52
|
* @property url - The public S3 URL of the uploaded file.
|
|
53
|
-
* @property
|
|
53
|
+
* @property data - The return value from the `onUpload` callback in `setupFileUpload`.
|
|
54
54
|
*
|
|
55
55
|
* @category File
|
|
56
56
|
*/
|
package/dist/file/client.d.ts
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* The endpoint is read from `NEXT_PUBLIC_FILE_ENDPOINT` env var. The file is sent as multipart form data
|
|
6
6
|
* along with a `type` string and optional JSON `data` for metadata.
|
|
7
7
|
*
|
|
8
|
-
* @returns A function `(file, type,
|
|
8
|
+
* @returns A function `(file, type, config?) => Promise<FileUploadResponseType | null>`.
|
|
9
9
|
* - `file` — `File` or `Blob` to upload.
|
|
10
10
|
* - `type` — String category (e.g. `"avatar"`, `"DealDocument"`); sent as form field `type`.
|
|
11
|
-
* - `
|
|
12
|
-
*
|
|
11
|
+
* - `config` — Optional object with:
|
|
12
|
+
* - `data` — JSON-serializable metadata object; sent as form field `data`.
|
|
13
|
+
* - `async` — If `true`, the upload is processed asynchronously on the server.
|
|
14
|
+
* Resolves to the JSON response `{ url, data }` or `null`.
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* ```tsx
|
|
@@ -23,9 +25,7 @@
|
|
|
23
25
|
* setUploading(true);
|
|
24
26
|
* try {
|
|
25
27
|
* const result = await uploadFile(file, "DealDocument", {
|
|
26
|
-
* dealId,
|
|
27
|
-
* fileName: file.name,
|
|
28
|
-
* category: "Contract",
|
|
28
|
+
* data: { dealId, fileName: file.name, category: "Contract" },
|
|
29
29
|
* });
|
|
30
30
|
* if (result?.url) {
|
|
31
31
|
* console.log("Uploaded:", result.url);
|
|
@@ -50,7 +50,7 @@ declare const useFileUpload: () => (file: File | Blob, type: string, config?: {
|
|
|
50
50
|
* Shape of the JSON response from the file upload PUT endpoint.
|
|
51
51
|
*
|
|
52
52
|
* @property url - The public S3 URL of the uploaded file.
|
|
53
|
-
* @property
|
|
53
|
+
* @property data - The return value from the `onUpload` callback in `setupFileUpload`.
|
|
54
54
|
*
|
|
55
55
|
* @category File
|
|
56
56
|
*/
|
package/dist/file/client.esm.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(client_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(client_exports);
|
|
40
40
|
var import_client = require("@apollo/client");
|
|
41
|
-
var import_client2 = require("naystack/auth/
|
|
41
|
+
var import_client2 = require("naystack/auth/client");
|
|
42
42
|
var import_react = __toESM(require("react"));
|
|
43
43
|
|
|
44
44
|
// src/env.ts
|
|
@@ -29,10 +29,10 @@ declare const tokenContext: (token?: string | null) => {
|
|
|
29
29
|
* Uses `fetchPolicy: "no-cache"` by default to always get fresh data.
|
|
30
30
|
*
|
|
31
31
|
* @param query - A `TypedDocumentNode` for the query (e.g. from codegen or a `gql` template).
|
|
32
|
-
* @param variables - Optional initial variables. Query fires automatically when this and token are set; change to refetch.
|
|
32
|
+
* @param variables - Optional initial variables (the `input` value). Automatically wrapped as `{ input: variables }` before sending. Query fires automatically when this and token are set; change to refetch.
|
|
33
33
|
* @returns Tuple: `[refetch, result]`.
|
|
34
|
-
* - `refetch(input)` — runs the query again with the given input (
|
|
35
|
-
* - `result` — `{ data, loading, error }` from Apollo.
|
|
34
|
+
* - `refetch(input)` — runs the query again with the given input (wrapped as `variables.input`).
|
|
35
|
+
* - `result` — `{ data, loading, error, hasAuth }` from Apollo. `hasAuth` is `true` when an auth token is available.
|
|
36
36
|
*
|
|
37
37
|
* @example Lazy query (no initial variables, manually triggered):
|
|
38
38
|
* ```tsx
|
|
@@ -92,8 +92,8 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
|
|
|
92
92
|
* @param mutation - A `TypedDocumentNode` for the mutation (e.g. from codegen or a `gql` template).
|
|
93
93
|
* @param options - Optional Apollo `MutationHookOptions` (e.g. `onCompleted`, `onError`, `refetchQueries`).
|
|
94
94
|
* @returns Tuple: `[mutate, result]`.
|
|
95
|
-
* - `mutate(input)` — runs the mutation with the given input. Returns a Promise with `{ data }`.
|
|
96
|
-
* - `result` — `{ data, loading, error }` from Apollo.
|
|
95
|
+
* - `mutate(input)` — runs the mutation with the given input (wrapped as `variables.input`). Returns a Promise with `{ data }`.
|
|
96
|
+
* - `result` — `{ data, loading, error, hasAuth }` from Apollo. `hasAuth` is `true` when an auth token is available.
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```tsx
|
package/dist/graphql/client.d.ts
CHANGED
|
@@ -29,10 +29,10 @@ declare const tokenContext: (token?: string | null) => {
|
|
|
29
29
|
* Uses `fetchPolicy: "no-cache"` by default to always get fresh data.
|
|
30
30
|
*
|
|
31
31
|
* @param query - A `TypedDocumentNode` for the query (e.g. from codegen or a `gql` template).
|
|
32
|
-
* @param variables - Optional initial variables. Query fires automatically when this and token are set; change to refetch.
|
|
32
|
+
* @param variables - Optional initial variables (the `input` value). Automatically wrapped as `{ input: variables }` before sending. Query fires automatically when this and token are set; change to refetch.
|
|
33
33
|
* @returns Tuple: `[refetch, result]`.
|
|
34
|
-
* - `refetch(input)` — runs the query again with the given input (
|
|
35
|
-
* - `result` — `{ data, loading, error }` from Apollo.
|
|
34
|
+
* - `refetch(input)` — runs the query again with the given input (wrapped as `variables.input`).
|
|
35
|
+
* - `result` — `{ data, loading, error, hasAuth }` from Apollo. `hasAuth` is `true` when an auth token is available.
|
|
36
36
|
*
|
|
37
37
|
* @example Lazy query (no initial variables, manually triggered):
|
|
38
38
|
* ```tsx
|
|
@@ -92,8 +92,8 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
|
|
|
92
92
|
* @param mutation - A `TypedDocumentNode` for the mutation (e.g. from codegen or a `gql` template).
|
|
93
93
|
* @param options - Optional Apollo `MutationHookOptions` (e.g. `onCompleted`, `onError`, `refetchQueries`).
|
|
94
94
|
* @returns Tuple: `[mutate, result]`.
|
|
95
|
-
* - `mutate(input)` — runs the mutation with the given input. Returns a Promise with `{ data }`.
|
|
96
|
-
* - `result` — `{ data, loading, error }` from Apollo.
|
|
95
|
+
* - `mutate(input)` — runs the mutation with the given input (wrapped as `variables.input`). Returns a Promise with `{ data }`.
|
|
96
|
+
* - `result` — `{ data, loading, error, hasAuth }` from Apollo. `hasAuth` is `true` when an auth token is available.
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```tsx
|
|
@@ -538,12 +538,15 @@ var require_error = __commonJS({
|
|
|
538
538
|
// src/graphql/index.ts
|
|
539
539
|
var graphql_exports = {};
|
|
540
540
|
__export(graphql_exports, {
|
|
541
|
+
ApolloWrapper: () => ApolloWrapper,
|
|
541
542
|
FieldLibrary: () => FieldLibrary,
|
|
542
543
|
GQLError: () => GQLError,
|
|
544
|
+
Injector: () => Injector,
|
|
543
545
|
QueryLibrary: () => QueryLibrary,
|
|
544
546
|
field: () => field,
|
|
545
|
-
|
|
546
|
-
|
|
547
|
+
query: () => query,
|
|
548
|
+
resolver: () => resolver,
|
|
549
|
+
setupGraphQL: () => setupGraphQL
|
|
547
550
|
});
|
|
548
551
|
module.exports = __toCommonJS(graphql_exports);
|
|
549
552
|
|
|
@@ -711,7 +714,7 @@ var getContext = (req) => {
|
|
|
711
714
|
};
|
|
712
715
|
|
|
713
716
|
// src/graphql/init.ts
|
|
714
|
-
async function
|
|
717
|
+
async function setupGraphQL({
|
|
715
718
|
authChecker,
|
|
716
719
|
resolvers,
|
|
717
720
|
plugins,
|
|
@@ -756,7 +759,7 @@ async function initGraphQLServer({
|
|
|
756
759
|
var import_headers2 = require("next/headers");
|
|
757
760
|
var import_react = require("react");
|
|
758
761
|
var import_type_graphql2 = require("type-graphql");
|
|
759
|
-
function
|
|
762
|
+
function resolver(fn, options) {
|
|
760
763
|
return {
|
|
761
764
|
...options,
|
|
762
765
|
fn,
|
|
@@ -829,6 +832,20 @@ function QueryLibrary(queries) {
|
|
|
829
832
|
GeneratedResolver = __decorateClass([
|
|
830
833
|
(0, import_type_graphql2.Resolver)()
|
|
831
834
|
], GeneratedResolver);
|
|
835
|
+
const hasQuery = Object.values(queries).some((def) => !def.mutation);
|
|
836
|
+
if (!hasQuery) {
|
|
837
|
+
Object.defineProperty(GeneratedResolver.prototype, "_health", {
|
|
838
|
+
value: async function() {
|
|
839
|
+
return true;
|
|
840
|
+
},
|
|
841
|
+
writable: false
|
|
842
|
+
});
|
|
843
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
844
|
+
GeneratedResolver.prototype,
|
|
845
|
+
"_health"
|
|
846
|
+
);
|
|
847
|
+
(0, import_type_graphql2.Query)(() => Boolean)(GeneratedResolver.prototype, "_health", descriptor);
|
|
848
|
+
}
|
|
832
849
|
for (const key in queries) {
|
|
833
850
|
const def = queries[key];
|
|
834
851
|
if (!def) continue;
|
|
@@ -909,12 +926,83 @@ function FieldLibrary(type, queries) {
|
|
|
909
926
|
}
|
|
910
927
|
return GeneratedResolver;
|
|
911
928
|
}
|
|
929
|
+
|
|
930
|
+
// src/graphql/server.tsx
|
|
931
|
+
var import_client = require("@apollo/client");
|
|
932
|
+
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
933
|
+
var import_headers3 = require("next/headers");
|
|
934
|
+
var import_react2 = __toESM(require("react"));
|
|
935
|
+
var import_react3 = require("react");
|
|
936
|
+
function Injector({
|
|
937
|
+
fetch: fetch2,
|
|
938
|
+
Component,
|
|
939
|
+
props
|
|
940
|
+
}) {
|
|
941
|
+
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 }));
|
|
942
|
+
}
|
|
943
|
+
async function InjectorSuspensed({
|
|
944
|
+
fetch: fetch2,
|
|
945
|
+
Component,
|
|
946
|
+
props
|
|
947
|
+
}) {
|
|
948
|
+
const data = await fetch2();
|
|
949
|
+
return /* @__PURE__ */ import_react2.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
950
|
+
}
|
|
951
|
+
var { query: gqlQuery } = (0, import_client_integration_nextjs.registerApolloClient)(() => {
|
|
952
|
+
return new import_client.ApolloClient({
|
|
953
|
+
cache: new import_client.InMemoryCache(),
|
|
954
|
+
link: new import_client.HttpLink({
|
|
955
|
+
uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
|
|
956
|
+
})
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
var query = async (_query, options) => {
|
|
960
|
+
const res = await gqlQuery({
|
|
961
|
+
query: _query,
|
|
962
|
+
variables: options?.variables,
|
|
963
|
+
context: {
|
|
964
|
+
headers: {
|
|
965
|
+
Cookie: options?.noCookie ? void 0 : await (0, import_headers3.cookies)()
|
|
966
|
+
},
|
|
967
|
+
fetchOptions: {
|
|
968
|
+
cache: options?.revalidate ? "force-cache" : void 0,
|
|
969
|
+
next: {
|
|
970
|
+
revalidate: options?.revalidate || 0,
|
|
971
|
+
tags: options?.tags
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
return res.data;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
// src/graphql/next.tsx
|
|
980
|
+
var import_client2 = require("@apollo/client");
|
|
981
|
+
var import_client_integration_nextjs2 = require("@apollo/client-integration-nextjs");
|
|
982
|
+
var import_react4 = __toESM(require("react"));
|
|
983
|
+
function makeClient(cacheConfig) {
|
|
984
|
+
return new import_client_integration_nextjs2.ApolloClient({
|
|
985
|
+
cache: new import_client_integration_nextjs2.InMemoryCache(cacheConfig),
|
|
986
|
+
link: new import_client2.HttpLink({
|
|
987
|
+
uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
|
|
988
|
+
})
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
var ApolloWrapper = ({
|
|
992
|
+
children,
|
|
993
|
+
cacheConfig
|
|
994
|
+
}) => {
|
|
995
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_client_integration_nextjs2.ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
|
|
996
|
+
};
|
|
912
997
|
// Annotate the CommonJS export names for ESM import in node:
|
|
913
998
|
0 && (module.exports = {
|
|
999
|
+
ApolloWrapper,
|
|
914
1000
|
FieldLibrary,
|
|
915
1001
|
GQLError,
|
|
1002
|
+
Injector,
|
|
916
1003
|
QueryLibrary,
|
|
917
1004
|
field,
|
|
918
|
-
|
|
919
|
-
|
|
1005
|
+
query,
|
|
1006
|
+
resolver,
|
|
1007
|
+
setupGraphQL
|
|
920
1008
|
});
|
package/dist/graphql/index.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export { GQLError } from './errors.mjs';
|
|
2
|
-
export {
|
|
2
|
+
export { setupGraphQL } from './init.mjs';
|
|
3
3
|
export { AuthorizedContext, Context } from './types.mjs';
|
|
4
|
-
export { FieldLibrary, FieldResolverDefinition, FieldResponseType, QueryDefinition, QueryLibrary, QueryResponseType, field,
|
|
4
|
+
export { FieldLibrary, FieldResolverDefinition, FieldResponseType, QueryDefinition, QueryLibrary, QueryResponseType, field, resolver } from './utils.mjs';
|
|
5
|
+
export { Injector, query } from './server.mjs';
|
|
6
|
+
export { ApolloWrapper } from './next.mjs';
|
|
5
7
|
import 'graphql/error';
|
|
6
8
|
import '@apollo/server';
|
|
7
9
|
import 'next/server';
|
|
8
10
|
import 'type-graphql';
|
|
9
11
|
import 'graphql';
|
|
12
|
+
import '@apollo/client';
|
|
13
|
+
import '@graphql-typed-document-node/core';
|
|
14
|
+
import 'react';
|
package/dist/graphql/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export { GQLError } from './errors.js';
|
|
2
|
-
export {
|
|
2
|
+
export { setupGraphQL } from './init.js';
|
|
3
3
|
export { AuthorizedContext, Context } from './types.js';
|
|
4
|
-
export { FieldLibrary, FieldResolverDefinition, FieldResponseType, QueryDefinition, QueryLibrary, QueryResponseType, field,
|
|
4
|
+
export { FieldLibrary, FieldResolverDefinition, FieldResponseType, QueryDefinition, QueryLibrary, QueryResponseType, field, resolver } from './utils.js';
|
|
5
|
+
export { Injector, query } from './server.js';
|
|
6
|
+
export { ApolloWrapper } from './next.js';
|
|
5
7
|
import 'graphql/error';
|
|
6
8
|
import '@apollo/server';
|
|
7
9
|
import 'next/server';
|
|
8
10
|
import 'type-graphql';
|
|
9
11
|
import 'graphql';
|
|
12
|
+
import '@apollo/client';
|
|
13
|
+
import '@graphql-typed-document-node/core';
|
|
14
|
+
import 'react';
|