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