naystack 1.1.17 → 1.2.0
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 +742 -24
- package/dist/auth/email/client.cjs.js +116 -0
- package/dist/auth/email/client.d.mts +10 -0
- package/dist/auth/email/client.d.ts +10 -0
- package/dist/auth/email/client.esm.js +92 -0
- package/dist/auth/email/index.cjs.js +1 -1
- package/dist/auth/email/index.esm.js +1 -1
- package/dist/auth/email/routes/delete.cjs.js +1 -1
- package/dist/auth/email/routes/delete.esm.js +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.esm.js +1 -1
- package/dist/client/hooks.d.mts +2 -2
- package/dist/client/hooks.d.ts +2 -2
- package/dist/client/index.cjs.js +180 -5
- package/dist/client/index.d.mts +5 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.esm.js +173 -4
- package/dist/graphql/client.cjs.js +129 -0
- package/dist/graphql/client.d.mts +26 -0
- package/dist/graphql/client.d.ts +26 -0
- package/dist/graphql/client.esm.js +104 -0
- package/dist/graphql/index.cjs.js +55 -0
- package/dist/graphql/index.d.mts +4 -0
- package/dist/graphql/index.d.ts +4 -0
- package/dist/graphql/index.esm.js +57 -0
- package/dist/graphql/server.cjs.js +80 -0
- package/dist/graphql/server.d.mts +28 -0
- package/dist/graphql/server.d.ts +28 -0
- package/dist/graphql/server.esm.js +58 -0
- package/package.json +4 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/graphql/server.tsx
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
Injector: () => Injector,
|
|
24
|
+
getGraphQLQuery: () => getGraphQLQuery
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(server_exports);
|
|
27
|
+
var import_client = require("@apollo/client");
|
|
28
|
+
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
29
|
+
var import_headers = require("next/headers");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
function Injector({
|
|
32
|
+
fetch,
|
|
33
|
+
Component,
|
|
34
|
+
props
|
|
35
|
+
}) {
|
|
36
|
+
return /* @__PURE__ */ React.createElement(import_react.Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch, props }));
|
|
37
|
+
}
|
|
38
|
+
async function InjectorSuspensed({
|
|
39
|
+
fetch,
|
|
40
|
+
Component,
|
|
41
|
+
props
|
|
42
|
+
}) {
|
|
43
|
+
const data = await fetch();
|
|
44
|
+
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
45
|
+
}
|
|
46
|
+
var getGraphQLQuery = ({ uri }) => {
|
|
47
|
+
const getClient = () => {
|
|
48
|
+
return new import_client.ApolloClient({
|
|
49
|
+
cache: new import_client.InMemoryCache(),
|
|
50
|
+
link: new import_client.HttpLink({
|
|
51
|
+
uri
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const { query: queryApollo } = (0, import_client_integration_nextjs.registerApolloClient)(getClient);
|
|
56
|
+
return async (_query, options) => {
|
|
57
|
+
const res = await queryApollo({
|
|
58
|
+
query: _query,
|
|
59
|
+
variables: options?.variables,
|
|
60
|
+
context: {
|
|
61
|
+
headers: {
|
|
62
|
+
Cookie: options?.noCookie ? void 0 : await (0, import_headers.cookies)()
|
|
63
|
+
},
|
|
64
|
+
fetchOptions: {
|
|
65
|
+
cache: options?.revalidate === void 0 ? "force-cache" : void 0,
|
|
66
|
+
next: {
|
|
67
|
+
revalidate: options?.revalidate,
|
|
68
|
+
tags: options?.tags
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return res.data;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
Injector,
|
|
79
|
+
getGraphQLQuery
|
|
80
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { OperationVariables } from '@apollo/client';
|
|
4
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
type OmittedProps<Y> = Omit<Omit<Y, "loading">, "data">;
|
|
7
|
+
type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
8
|
+
props?: object;
|
|
9
|
+
} : {
|
|
10
|
+
props: OmittedProps<Y>;
|
|
11
|
+
};
|
|
12
|
+
declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
13
|
+
fetch: () => Promise<T>;
|
|
14
|
+
Component: FC<{
|
|
15
|
+
data?: T;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
} & Y>;
|
|
18
|
+
} & ComponentProps<Y>): React.JSX.Element;
|
|
19
|
+
declare const getGraphQLQuery: ({ uri }: {
|
|
20
|
+
uri: string;
|
|
21
|
+
}) => <T, V extends OperationVariables>(_query: TypedDocumentNode<T, V>, options?: {
|
|
22
|
+
variables?: V;
|
|
23
|
+
revalidate?: number;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
noCookie?: boolean;
|
|
26
|
+
}) => Promise<T>;
|
|
27
|
+
|
|
28
|
+
export { Injector, getGraphQLQuery };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { OperationVariables } from '@apollo/client';
|
|
4
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
5
|
+
|
|
6
|
+
type OmittedProps<Y> = Omit<Omit<Y, "loading">, "data">;
|
|
7
|
+
type ComponentProps<Y> = OmittedProps<Y> extends Record<string, never> ? {
|
|
8
|
+
props?: object;
|
|
9
|
+
} : {
|
|
10
|
+
props: OmittedProps<Y>;
|
|
11
|
+
};
|
|
12
|
+
declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
13
|
+
fetch: () => Promise<T>;
|
|
14
|
+
Component: FC<{
|
|
15
|
+
data?: T;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
} & Y>;
|
|
18
|
+
} & ComponentProps<Y>): React.JSX.Element;
|
|
19
|
+
declare const getGraphQLQuery: ({ uri }: {
|
|
20
|
+
uri: string;
|
|
21
|
+
}) => <T, V extends OperationVariables>(_query: TypedDocumentNode<T, V>, options?: {
|
|
22
|
+
variables?: V;
|
|
23
|
+
revalidate?: number;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
noCookie?: boolean;
|
|
26
|
+
}) => Promise<T>;
|
|
27
|
+
|
|
28
|
+
export { Injector, getGraphQLQuery };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/graphql/server.tsx
|
|
2
|
+
import {
|
|
3
|
+
ApolloClient,
|
|
4
|
+
HttpLink,
|
|
5
|
+
InMemoryCache
|
|
6
|
+
} from "@apollo/client";
|
|
7
|
+
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
8
|
+
import { cookies } from "next/headers";
|
|
9
|
+
import { Suspense } from "react";
|
|
10
|
+
function Injector({
|
|
11
|
+
fetch,
|
|
12
|
+
Component,
|
|
13
|
+
props
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch, props }));
|
|
16
|
+
}
|
|
17
|
+
async function InjectorSuspensed({
|
|
18
|
+
fetch,
|
|
19
|
+
Component,
|
|
20
|
+
props
|
|
21
|
+
}) {
|
|
22
|
+
const data = await fetch();
|
|
23
|
+
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
24
|
+
}
|
|
25
|
+
var getGraphQLQuery = ({ uri }) => {
|
|
26
|
+
const getClient = () => {
|
|
27
|
+
return new ApolloClient({
|
|
28
|
+
cache: new InMemoryCache(),
|
|
29
|
+
link: new HttpLink({
|
|
30
|
+
uri
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const { query: queryApollo } = registerApolloClient(getClient);
|
|
35
|
+
return async (_query, options) => {
|
|
36
|
+
const res = await queryApollo({
|
|
37
|
+
query: _query,
|
|
38
|
+
variables: options?.variables,
|
|
39
|
+
context: {
|
|
40
|
+
headers: {
|
|
41
|
+
Cookie: options?.noCookie ? void 0 : await cookies()
|
|
42
|
+
},
|
|
43
|
+
fetchOptions: {
|
|
44
|
+
cache: options?.revalidate === void 0 ? "force-cache" : void 0,
|
|
45
|
+
next: {
|
|
46
|
+
revalidate: options?.revalidate,
|
|
47
|
+
tags: options?.tags
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return res.data;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
Injector,
|
|
57
|
+
getGraphQLQuery
|
|
58
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naystack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"author": "Abhinay Pandey <abhinaypandey02@gmail.com>",
|
|
59
59
|
"license": "ISC",
|
|
60
60
|
"dependencies": {
|
|
61
|
+
"@apollo/client": "^3.13.6",
|
|
62
|
+
"@apollo/client-integration-nextjs": "^0.14.2",
|
|
61
63
|
"@apollo/server": "^4.12.0",
|
|
62
64
|
"@as-integrations/next": "^3.2.0",
|
|
63
65
|
"@aws-sdk/client-s3": "^3.913.0",
|
|
@@ -81,6 +83,7 @@
|
|
|
81
83
|
"@types/jsonwebtoken": "^9.0.7",
|
|
82
84
|
"@types/node": "^24.5.2",
|
|
83
85
|
"@types/react": "^19.2",
|
|
86
|
+
"@graphql-typed-document-node/core": "^3.2.0",
|
|
84
87
|
"@types/react-dom": "^19.2",
|
|
85
88
|
"dotenv": "^17.2.2",
|
|
86
89
|
"eslint": "^9.26.0",
|