naystack 1.7.28 → 1.7.29
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/dist/auth/email/index.cjs.js +19 -5
- package/dist/auth/email/index.esm.js +17 -3
- package/dist/auth/email/next.cjs.js +17 -3
- package/dist/auth/email/next.esm.js +17 -3
- package/dist/auth/index.cjs.js +29 -15
- package/dist/auth/index.esm.js +17 -3
- package/dist/graphql/index.cjs.js +17 -3
- package/dist/graphql/index.esm.js +17 -3
- package/dist/graphql/server.cjs.js +17 -3
- package/dist/graphql/server.d.mts +10 -1
- package/dist/graphql/server.d.ts +10 -1
- package/dist/graphql/server.esm.js +17 -3
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ __export(email_exports, {
|
|
|
38
38
|
setupEmailAuth: () => setupEmailAuth
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(email_exports);
|
|
41
|
-
var
|
|
41
|
+
var import_server6 = require("next/server");
|
|
42
42
|
|
|
43
43
|
// src/utils/route.ts
|
|
44
44
|
var import_server = require("next/server");
|
|
@@ -372,20 +372,34 @@ var import_react3 = __toESM(require("react"));
|
|
|
372
372
|
var import_client = require("@apollo/client");
|
|
373
373
|
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
374
374
|
var import_headers2 = require("next/headers");
|
|
375
|
+
var import_server4 = require("next/server");
|
|
375
376
|
var import_react = __toESM(require("react"));
|
|
376
377
|
var import_react2 = require("react");
|
|
377
378
|
function Injector({
|
|
378
379
|
fetch: fetch2,
|
|
379
380
|
Component,
|
|
380
|
-
props
|
|
381
|
+
props,
|
|
382
|
+
isStatic
|
|
381
383
|
}) {
|
|
382
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
384
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
385
|
+
InjectorSuspensed,
|
|
386
|
+
{
|
|
387
|
+
Component,
|
|
388
|
+
fetch: fetch2,
|
|
389
|
+
props,
|
|
390
|
+
isStatic
|
|
391
|
+
}
|
|
392
|
+
));
|
|
383
393
|
}
|
|
384
394
|
async function InjectorSuspensed({
|
|
385
395
|
fetch: fetch2,
|
|
386
396
|
Component,
|
|
387
|
-
props
|
|
397
|
+
props,
|
|
398
|
+
isStatic
|
|
388
399
|
}) {
|
|
400
|
+
if (!isStatic) {
|
|
401
|
+
await (0, import_server4.connection)();
|
|
402
|
+
}
|
|
389
403
|
const data = await fetch2();
|
|
390
404
|
return /* @__PURE__ */ import_react.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
391
405
|
}
|
|
@@ -436,7 +450,7 @@ function setupEmailAuth(options) {
|
|
|
436
450
|
req.headers.get("origin"),
|
|
437
451
|
allowedOrigins
|
|
438
452
|
);
|
|
439
|
-
return new
|
|
453
|
+
return new import_server6.NextResponse(null, {
|
|
440
454
|
status: 204,
|
|
441
455
|
headers: corsHeaders ?? void 0
|
|
442
456
|
});
|
|
@@ -337,20 +337,34 @@ import {
|
|
|
337
337
|
} from "@apollo/client";
|
|
338
338
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
339
339
|
import { cookies as cookies2 } from "next/headers";
|
|
340
|
+
import { connection } from "next/server";
|
|
340
341
|
import React from "react";
|
|
341
342
|
import { Suspense } from "react";
|
|
342
343
|
function Injector({
|
|
343
344
|
fetch: fetch2,
|
|
344
345
|
Component,
|
|
345
|
-
props
|
|
346
|
+
props,
|
|
347
|
+
isStatic
|
|
346
348
|
}) {
|
|
347
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
349
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
350
|
+
InjectorSuspensed,
|
|
351
|
+
{
|
|
352
|
+
Component,
|
|
353
|
+
fetch: fetch2,
|
|
354
|
+
props,
|
|
355
|
+
isStatic
|
|
356
|
+
}
|
|
357
|
+
));
|
|
348
358
|
}
|
|
349
359
|
async function InjectorSuspensed({
|
|
350
360
|
fetch: fetch2,
|
|
351
361
|
Component,
|
|
352
|
-
props
|
|
362
|
+
props,
|
|
363
|
+
isStatic
|
|
353
364
|
}) {
|
|
365
|
+
if (!isStatic) {
|
|
366
|
+
await connection();
|
|
367
|
+
}
|
|
354
368
|
const data = await fetch2();
|
|
355
369
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
356
370
|
}
|
|
@@ -95,20 +95,34 @@ function getEnv(key, skipCheck) {
|
|
|
95
95
|
var import_client = require("@apollo/client");
|
|
96
96
|
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
97
97
|
var import_headers = require("next/headers");
|
|
98
|
+
var import_server = require("next/server");
|
|
98
99
|
var import_react = __toESM(require("react"));
|
|
99
100
|
var import_react2 = require("react");
|
|
100
101
|
function Injector({
|
|
101
102
|
fetch: fetch2,
|
|
102
103
|
Component,
|
|
103
|
-
props
|
|
104
|
+
props,
|
|
105
|
+
isStatic
|
|
104
106
|
}) {
|
|
105
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
107
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
108
|
+
InjectorSuspensed,
|
|
109
|
+
{
|
|
110
|
+
Component,
|
|
111
|
+
fetch: fetch2,
|
|
112
|
+
props,
|
|
113
|
+
isStatic
|
|
114
|
+
}
|
|
115
|
+
));
|
|
106
116
|
}
|
|
107
117
|
async function InjectorSuspensed({
|
|
108
118
|
fetch: fetch2,
|
|
109
119
|
Component,
|
|
110
|
-
props
|
|
120
|
+
props,
|
|
121
|
+
isStatic
|
|
111
122
|
}) {
|
|
123
|
+
if (!isStatic) {
|
|
124
|
+
await (0, import_server.connection)();
|
|
125
|
+
}
|
|
112
126
|
const data = await fetch2();
|
|
113
127
|
return /* @__PURE__ */ import_react.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
114
128
|
}
|
|
@@ -64,20 +64,34 @@ import {
|
|
|
64
64
|
} from "@apollo/client";
|
|
65
65
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
66
66
|
import { cookies } from "next/headers";
|
|
67
|
+
import { connection } from "next/server";
|
|
67
68
|
import React from "react";
|
|
68
69
|
import { Suspense } from "react";
|
|
69
70
|
function Injector({
|
|
70
71
|
fetch: fetch2,
|
|
71
72
|
Component,
|
|
72
|
-
props
|
|
73
|
+
props,
|
|
74
|
+
isStatic
|
|
73
75
|
}) {
|
|
74
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
76
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
77
|
+
InjectorSuspensed,
|
|
78
|
+
{
|
|
79
|
+
Component,
|
|
80
|
+
fetch: fetch2,
|
|
81
|
+
props,
|
|
82
|
+
isStatic
|
|
83
|
+
}
|
|
84
|
+
));
|
|
75
85
|
}
|
|
76
86
|
async function InjectorSuspensed({
|
|
77
87
|
fetch: fetch2,
|
|
78
88
|
Component,
|
|
79
|
-
props
|
|
89
|
+
props,
|
|
90
|
+
isStatic
|
|
80
91
|
}) {
|
|
92
|
+
if (!isStatic) {
|
|
93
|
+
await connection();
|
|
94
|
+
}
|
|
81
95
|
const data = await fetch2();
|
|
82
96
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
83
97
|
}
|
package/dist/auth/index.cjs.js
CHANGED
|
@@ -44,7 +44,7 @@ __export(auth_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(auth_exports);
|
|
45
45
|
|
|
46
46
|
// src/auth/email/index.ts
|
|
47
|
-
var
|
|
47
|
+
var import_server6 = require("next/server");
|
|
48
48
|
|
|
49
49
|
// src/utils/route.ts
|
|
50
50
|
var import_server = require("next/server");
|
|
@@ -390,20 +390,34 @@ var import_react3 = __toESM(require("react"));
|
|
|
390
390
|
var import_client = require("@apollo/client");
|
|
391
391
|
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
392
392
|
var import_headers2 = require("next/headers");
|
|
393
|
+
var import_server4 = require("next/server");
|
|
393
394
|
var import_react = __toESM(require("react"));
|
|
394
395
|
var import_react2 = require("react");
|
|
395
396
|
function Injector({
|
|
396
397
|
fetch: fetch2,
|
|
397
398
|
Component,
|
|
398
|
-
props
|
|
399
|
+
props,
|
|
400
|
+
isStatic
|
|
399
401
|
}) {
|
|
400
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
402
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
403
|
+
InjectorSuspensed,
|
|
404
|
+
{
|
|
405
|
+
Component,
|
|
406
|
+
fetch: fetch2,
|
|
407
|
+
props,
|
|
408
|
+
isStatic
|
|
409
|
+
}
|
|
410
|
+
));
|
|
401
411
|
}
|
|
402
412
|
async function InjectorSuspensed({
|
|
403
413
|
fetch: fetch2,
|
|
404
414
|
Component,
|
|
405
|
-
props
|
|
415
|
+
props,
|
|
416
|
+
isStatic
|
|
406
417
|
}) {
|
|
418
|
+
if (!isStatic) {
|
|
419
|
+
await (0, import_server4.connection)();
|
|
420
|
+
}
|
|
407
421
|
const data = await fetch2();
|
|
408
422
|
return /* @__PURE__ */ import_react.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
409
423
|
}
|
|
@@ -454,7 +468,7 @@ function setupEmailAuth(options) {
|
|
|
454
468
|
req.headers.get("origin"),
|
|
455
469
|
allowedOrigins
|
|
456
470
|
);
|
|
457
|
-
return new
|
|
471
|
+
return new import_server6.NextResponse(null, {
|
|
458
472
|
status: 204,
|
|
459
473
|
headers: corsHeaders ?? void 0
|
|
460
474
|
});
|
|
@@ -465,7 +479,7 @@ function setupEmailAuth(options) {
|
|
|
465
479
|
|
|
466
480
|
// src/auth/google/get.ts
|
|
467
481
|
var import_googleapis = require("googleapis");
|
|
468
|
-
var
|
|
482
|
+
var import_server7 = require("next/server");
|
|
469
483
|
var import_uuid = require("uuid");
|
|
470
484
|
var getGoogleGetRoute = ({
|
|
471
485
|
getUserIdFromEmail,
|
|
@@ -502,7 +516,7 @@ var getGoogleGetRoute = ({
|
|
|
502
516
|
prompt: "consent",
|
|
503
517
|
redirect_uri: url
|
|
504
518
|
});
|
|
505
|
-
const res =
|
|
519
|
+
const res = import_server7.NextResponse.redirect(authorizationUrl);
|
|
506
520
|
res.cookies.set("state", state2, {
|
|
507
521
|
httpOnly: true,
|
|
508
522
|
secure: true
|
|
@@ -523,11 +537,11 @@ var getGoogleGetRoute = ({
|
|
|
523
537
|
const finalRedirectURL = stateRedirectURL || redirectURL;
|
|
524
538
|
const finalErrorURL = stateErrorRedirectURL || errorRedirectURL || finalRedirectURL;
|
|
525
539
|
if (error) {
|
|
526
|
-
return
|
|
540
|
+
return import_server7.NextResponse.redirect(finalErrorURL);
|
|
527
541
|
}
|
|
528
542
|
const state = req.nextUrl.searchParams.get("state") || void 0;
|
|
529
543
|
if (code && state) {
|
|
530
|
-
if (localState !== state) return
|
|
544
|
+
if (localState !== state) return import_server7.NextResponse.redirect(finalErrorURL);
|
|
531
545
|
const { tokens } = await oauth2Client.getToken(code);
|
|
532
546
|
oauth2Client.setCredentials(tokens);
|
|
533
547
|
const userInfoRequest = await import_googleapis.google.oauth2({
|
|
@@ -540,7 +554,7 @@ var getGoogleGetRoute = ({
|
|
|
540
554
|
const id = await getUserIdFromEmail(user, data);
|
|
541
555
|
if (id) {
|
|
542
556
|
const targetUrl = new URL(finalRedirectURL, req.nextUrl.origin);
|
|
543
|
-
const res =
|
|
557
|
+
const res = import_server7.NextResponse.redirect(targetUrl);
|
|
544
558
|
res.cookies.set(
|
|
545
559
|
REFRESH_COOKIE_NAME,
|
|
546
560
|
generateRefreshToken(id),
|
|
@@ -558,7 +572,7 @@ var getGoogleGetRoute = ({
|
|
|
558
572
|
}
|
|
559
573
|
}
|
|
560
574
|
}
|
|
561
|
-
return
|
|
575
|
+
return import_server7.NextResponse.redirect(finalErrorURL);
|
|
562
576
|
};
|
|
563
577
|
};
|
|
564
578
|
|
|
@@ -570,7 +584,7 @@ function setupGoogleAuth(props) {
|
|
|
570
584
|
}
|
|
571
585
|
|
|
572
586
|
// src/auth/instagram/route.ts
|
|
573
|
-
var
|
|
587
|
+
var import_server9 = require("next/server");
|
|
574
588
|
|
|
575
589
|
// src/auth/instagram/utils.ts
|
|
576
590
|
async function getRefreshedInstagramAccessToken(token) {
|
|
@@ -632,7 +646,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
632
646
|
};
|
|
633
647
|
|
|
634
648
|
// src/socials/meta-webhook.ts
|
|
635
|
-
var
|
|
649
|
+
var import_server8 = require("next/server");
|
|
636
650
|
|
|
637
651
|
// src/auth/instagram/route.ts
|
|
638
652
|
var getInstagramRoute = ({
|
|
@@ -640,7 +654,7 @@ var getInstagramRoute = ({
|
|
|
640
654
|
errorRedirectURL,
|
|
641
655
|
onUser
|
|
642
656
|
}) => {
|
|
643
|
-
const handleError2 = (message) =>
|
|
657
|
+
const handleError2 = (message) => import_server9.NextResponse.redirect(`${errorRedirectURL}?error=${message}`);
|
|
644
658
|
return async (req) => {
|
|
645
659
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
646
660
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -664,7 +678,7 @@ var getInstagramRoute = ({
|
|
|
664
678
|
instagramData.accessToken
|
|
665
679
|
);
|
|
666
680
|
if (errorMessage) return handleError2(errorMessage);
|
|
667
|
-
return
|
|
681
|
+
return import_server9.NextResponse.redirect(redirectURL);
|
|
668
682
|
};
|
|
669
683
|
};
|
|
670
684
|
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -349,20 +349,34 @@ import {
|
|
|
349
349
|
} from "@apollo/client";
|
|
350
350
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
351
351
|
import { cookies as cookies2 } from "next/headers";
|
|
352
|
+
import { connection } from "next/server";
|
|
352
353
|
import React from "react";
|
|
353
354
|
import { Suspense } from "react";
|
|
354
355
|
function Injector({
|
|
355
356
|
fetch: fetch2,
|
|
356
357
|
Component,
|
|
357
|
-
props
|
|
358
|
+
props,
|
|
359
|
+
isStatic
|
|
358
360
|
}) {
|
|
359
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
361
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
362
|
+
InjectorSuspensed,
|
|
363
|
+
{
|
|
364
|
+
Component,
|
|
365
|
+
fetch: fetch2,
|
|
366
|
+
props,
|
|
367
|
+
isStatic
|
|
368
|
+
}
|
|
369
|
+
));
|
|
360
370
|
}
|
|
361
371
|
async function InjectorSuspensed({
|
|
362
372
|
fetch: fetch2,
|
|
363
373
|
Component,
|
|
364
|
-
props
|
|
374
|
+
props,
|
|
375
|
+
isStatic
|
|
365
376
|
}) {
|
|
377
|
+
if (!isStatic) {
|
|
378
|
+
await connection();
|
|
379
|
+
}
|
|
366
380
|
const data = await fetch2();
|
|
367
381
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
368
382
|
}
|
|
@@ -938,20 +938,34 @@ function FieldLibrary(type, queries) {
|
|
|
938
938
|
var import_client = require("@apollo/client");
|
|
939
939
|
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
940
940
|
var import_headers3 = require("next/headers");
|
|
941
|
+
var import_server6 = require("next/server");
|
|
941
942
|
var import_react2 = __toESM(require("react"));
|
|
942
943
|
var import_react3 = require("react");
|
|
943
944
|
function Injector({
|
|
944
945
|
fetch: fetch2,
|
|
945
946
|
Component,
|
|
946
|
-
props
|
|
947
|
+
props,
|
|
948
|
+
isStatic
|
|
947
949
|
}) {
|
|
948
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react3.Suspense, { fallback: /* @__PURE__ */ import_react2.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react2.default.createElement(
|
|
950
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react3.Suspense, { fallback: /* @__PURE__ */ import_react2.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react2.default.createElement(
|
|
951
|
+
InjectorSuspensed,
|
|
952
|
+
{
|
|
953
|
+
Component,
|
|
954
|
+
fetch: fetch2,
|
|
955
|
+
props,
|
|
956
|
+
isStatic
|
|
957
|
+
}
|
|
958
|
+
));
|
|
949
959
|
}
|
|
950
960
|
async function InjectorSuspensed({
|
|
951
961
|
fetch: fetch2,
|
|
952
962
|
Component,
|
|
953
|
-
props
|
|
963
|
+
props,
|
|
964
|
+
isStatic
|
|
954
965
|
}) {
|
|
966
|
+
if (!isStatic) {
|
|
967
|
+
await (0, import_server6.connection)();
|
|
968
|
+
}
|
|
955
969
|
const data = await fetch2();
|
|
956
970
|
return /* @__PURE__ */ import_react2.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
957
971
|
}
|
|
@@ -936,20 +936,34 @@ import {
|
|
|
936
936
|
} from "@apollo/client";
|
|
937
937
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
938
938
|
import { cookies as cookies3 } from "next/headers";
|
|
939
|
+
import { connection } from "next/server";
|
|
939
940
|
import React from "react";
|
|
940
941
|
import { Suspense } from "react";
|
|
941
942
|
function Injector({
|
|
942
943
|
fetch: fetch2,
|
|
943
944
|
Component,
|
|
944
|
-
props
|
|
945
|
+
props,
|
|
946
|
+
isStatic
|
|
945
947
|
}) {
|
|
946
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
948
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
949
|
+
InjectorSuspensed,
|
|
950
|
+
{
|
|
951
|
+
Component,
|
|
952
|
+
fetch: fetch2,
|
|
953
|
+
props,
|
|
954
|
+
isStatic
|
|
955
|
+
}
|
|
956
|
+
));
|
|
947
957
|
}
|
|
948
958
|
async function InjectorSuspensed({
|
|
949
959
|
fetch: fetch2,
|
|
950
960
|
Component,
|
|
951
|
-
props
|
|
961
|
+
props,
|
|
962
|
+
isStatic
|
|
952
963
|
}) {
|
|
964
|
+
if (!isStatic) {
|
|
965
|
+
await connection();
|
|
966
|
+
}
|
|
953
967
|
const data = await fetch2();
|
|
954
968
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
955
969
|
}
|
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
37
37
|
var import_client = require("@apollo/client");
|
|
38
38
|
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
39
39
|
var import_headers = require("next/headers");
|
|
40
|
+
var import_server = require("next/server");
|
|
40
41
|
var import_react = __toESM(require("react"));
|
|
41
42
|
var import_react2 = require("react");
|
|
42
43
|
|
|
@@ -94,15 +95,28 @@ function getEnv(key, skipCheck) {
|
|
|
94
95
|
function Injector({
|
|
95
96
|
fetch,
|
|
96
97
|
Component,
|
|
97
|
-
props
|
|
98
|
+
props,
|
|
99
|
+
isStatic
|
|
98
100
|
}) {
|
|
99
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
101
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react2.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ import_react.default.createElement(
|
|
102
|
+
InjectorSuspensed,
|
|
103
|
+
{
|
|
104
|
+
Component,
|
|
105
|
+
fetch,
|
|
106
|
+
props,
|
|
107
|
+
isStatic
|
|
108
|
+
}
|
|
109
|
+
));
|
|
100
110
|
}
|
|
101
111
|
async function InjectorSuspensed({
|
|
102
112
|
fetch,
|
|
103
113
|
Component,
|
|
104
|
-
props
|
|
114
|
+
props,
|
|
115
|
+
isStatic
|
|
105
116
|
}) {
|
|
117
|
+
if (!isStatic) {
|
|
118
|
+
await (0, import_server.connection)();
|
|
119
|
+
}
|
|
106
120
|
const data = await fetch();
|
|
107
121
|
return /* @__PURE__ */ import_react.default.createElement(Component, { loading: false, ...props || {}, data });
|
|
108
122
|
}
|
|
@@ -19,10 +19,18 @@ type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
|
19
19
|
* This is the primary way to inject server-side data into client components in naystack.
|
|
20
20
|
* Use `.authCall()` or `.call()` from your query definitions inside the `fetch` function.
|
|
21
21
|
*
|
|
22
|
+
* By default, `Injector` calls `connection()` from `next/server` before
|
|
23
|
+
* running `fetch`, marking the surrounding route segment as dynamic. This
|
|
24
|
+
* is what consumers almost always want: data fetched at request time
|
|
25
|
+
* should not be statically prerendered. Pass `isStatic` when you
|
|
26
|
+
* are intentionally rendering inside a cached/static segment (e.g. the
|
|
27
|
+
* `fetch` is wrapped in `"use cache"`).
|
|
28
|
+
*
|
|
22
29
|
* @param injectorProps - Configuration object.
|
|
23
30
|
* @param injectorProps.fetch - Async function that returns the data to pass to the component. Runs on the server.
|
|
24
31
|
* @param injectorProps.Component - React component that receives `{ data?: T; loading: boolean }` plus any extra props.
|
|
25
32
|
* @param injectorProps.props - Optional. Any additional props to pass to `Component`. Required if the Component has props other than `data` and `loading`.
|
|
33
|
+
* @param injectorProps.isStatic - Optional. When true, suppresses the implicit `connection()` call. Default: false.
|
|
26
34
|
* @returns A React element that suspends until `fetch()` completes, then renders `Component` with the data.
|
|
27
35
|
*
|
|
28
36
|
* @example Simple usage:
|
|
@@ -63,12 +71,13 @@ type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
|
63
71
|
*
|
|
64
72
|
* @category GraphQL
|
|
65
73
|
*/
|
|
66
|
-
declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
74
|
+
declare function Injector<T, Y>({ fetch, Component, props, isStatic, }: {
|
|
67
75
|
fetch: () => Promise<T>;
|
|
68
76
|
Component: FC<{
|
|
69
77
|
data?: T;
|
|
70
78
|
loading: boolean;
|
|
71
79
|
} & Y>;
|
|
80
|
+
isStatic?: boolean;
|
|
72
81
|
} & ComponentProps<Y>): React__default.JSX.Element;
|
|
73
82
|
/**
|
|
74
83
|
* Runs a raw GraphQL query on the server using the registered Apollo client.
|
package/dist/graphql/server.d.ts
CHANGED
|
@@ -19,10 +19,18 @@ type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
|
19
19
|
* This is the primary way to inject server-side data into client components in naystack.
|
|
20
20
|
* Use `.authCall()` or `.call()` from your query definitions inside the `fetch` function.
|
|
21
21
|
*
|
|
22
|
+
* By default, `Injector` calls `connection()` from `next/server` before
|
|
23
|
+
* running `fetch`, marking the surrounding route segment as dynamic. This
|
|
24
|
+
* is what consumers almost always want: data fetched at request time
|
|
25
|
+
* should not be statically prerendered. Pass `isStatic` when you
|
|
26
|
+
* are intentionally rendering inside a cached/static segment (e.g. the
|
|
27
|
+
* `fetch` is wrapped in `"use cache"`).
|
|
28
|
+
*
|
|
22
29
|
* @param injectorProps - Configuration object.
|
|
23
30
|
* @param injectorProps.fetch - Async function that returns the data to pass to the component. Runs on the server.
|
|
24
31
|
* @param injectorProps.Component - React component that receives `{ data?: T; loading: boolean }` plus any extra props.
|
|
25
32
|
* @param injectorProps.props - Optional. Any additional props to pass to `Component`. Required if the Component has props other than `data` and `loading`.
|
|
33
|
+
* @param injectorProps.isStatic - Optional. When true, suppresses the implicit `connection()` call. Default: false.
|
|
26
34
|
* @returns A React element that suspends until `fetch()` completes, then renders `Component` with the data.
|
|
27
35
|
*
|
|
28
36
|
* @example Simple usage:
|
|
@@ -63,12 +71,13 @@ type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
|
63
71
|
*
|
|
64
72
|
* @category GraphQL
|
|
65
73
|
*/
|
|
66
|
-
declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
74
|
+
declare function Injector<T, Y>({ fetch, Component, props, isStatic, }: {
|
|
67
75
|
fetch: () => Promise<T>;
|
|
68
76
|
Component: FC<{
|
|
69
77
|
data?: T;
|
|
70
78
|
loading: boolean;
|
|
71
79
|
} & Y>;
|
|
80
|
+
isStatic?: boolean;
|
|
72
81
|
} & ComponentProps<Y>): React__default.JSX.Element;
|
|
73
82
|
/**
|
|
74
83
|
* Runs a raw GraphQL query on the server using the registered Apollo client.
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@apollo/client";
|
|
7
7
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
8
8
|
import { cookies } from "next/headers";
|
|
9
|
+
import { connection } from "next/server";
|
|
9
10
|
import React from "react";
|
|
10
11
|
import { Suspense } from "react";
|
|
11
12
|
|
|
@@ -63,15 +64,28 @@ function getEnv(key, skipCheck) {
|
|
|
63
64
|
function Injector({
|
|
64
65
|
fetch,
|
|
65
66
|
Component,
|
|
66
|
-
props
|
|
67
|
+
props,
|
|
68
|
+
isStatic
|
|
67
69
|
}) {
|
|
68
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
70
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(
|
|
71
|
+
InjectorSuspensed,
|
|
72
|
+
{
|
|
73
|
+
Component,
|
|
74
|
+
fetch,
|
|
75
|
+
props,
|
|
76
|
+
isStatic
|
|
77
|
+
}
|
|
78
|
+
));
|
|
69
79
|
}
|
|
70
80
|
async function InjectorSuspensed({
|
|
71
81
|
fetch,
|
|
72
82
|
Component,
|
|
73
|
-
props
|
|
83
|
+
props,
|
|
84
|
+
isStatic
|
|
74
85
|
}) {
|
|
86
|
+
if (!isStatic) {
|
|
87
|
+
await connection();
|
|
88
|
+
}
|
|
75
89
|
const data = await fetch();
|
|
76
90
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
77
91
|
}
|