@cyberskill/shared 3.12.0 → 3.14.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/dist/config/commitlint/index.d.ts +5 -1
- package/dist/{src/config → config}/config.type.d.ts +1 -1
- package/dist/{src/config → config}/config.util.d.ts +1 -1
- package/dist/{src/config → config}/env/env.util.d.ts +5 -0
- package/dist/config/env/env.util.js +20 -16
- package/dist/config/env/env.util.js.map +1 -1
- package/dist/config/env/index.d.ts +3 -1
- package/dist/config/env/index.js +2 -2
- package/dist/config/eslint/index.d.ts +1198 -1
- package/dist/config/graphql-codegen/index.d.ts +2 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/lint-staged/index.d.ts +5 -1
- package/dist/config/storybook/index.d.ts +2 -1
- package/dist/config/vitest/index.d.ts +3 -1
- package/dist/config/vitest/vitest.e2e.d.ts +20 -1
- package/dist/config/vitest/vitest.e2e.js +4 -4
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.d.ts +22 -1
- package/dist/config/vitest/vitest.unit.js +5 -5
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/config/vitest/vitest.unit.setup.js +10 -0
- package/dist/config/vitest/vitest.unit.setup.js.map +1 -0
- package/dist/constant/index.d.ts +5 -1
- package/dist/node/apollo-server/apollo-server.type.d.ts +20 -0
- package/dist/{src/node → node}/apollo-server/apollo-server.util.d.ts +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +40 -16
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
- package/dist/node/apollo-server/index.d.ts +2 -1
- package/dist/node/cli/index.d.ts +2 -1
- package/dist/node/cli/index.js +26 -28
- package/dist/node/cli/index.js.map +1 -1
- package/dist/{src/node → node}/command/command.util.d.ts +5 -0
- package/dist/node/command/command.util.js +49 -48
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/command/index.d.ts +2 -1
- package/dist/node/command/index.js +2 -2
- package/dist/{src/node → node}/express/express.type.d.ts +11 -0
- package/dist/{src/node → node}/express/express.util.d.ts +34 -6
- package/dist/node/express/express.util.js +81 -56
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/express/index.d.ts +2 -1
- package/dist/node/express/index.js +2 -2
- package/dist/node/fs/index.d.ts +2 -1
- package/dist/node/log/index.d.ts +2 -1
- package/dist/node/log/log.type.d.ts +46 -0
- package/dist/node/log/log.type.js.map +1 -1
- package/dist/{src/node → node}/log/log.util.d.ts +1 -1
- package/dist/node/log/log.util.js +25 -11
- package/dist/node/log/log.util.js.map +1 -1
- package/dist/node/mongo/index.d.ts +7 -1
- package/dist/node/mongo/index.js +7 -8
- package/dist/{src/node → node}/mongo/mongo.constant.d.ts +5 -0
- package/dist/node/mongo/mongo.constant.js +2 -2
- package/dist/node/mongo/mongo.constant.js.map +1 -1
- package/dist/{src/node → node}/mongo/mongo.controller.helpers.d.ts +1 -1
- package/dist/{src/node → node}/mongo/mongo.controller.mongoose.d.ts +4 -1
- package/dist/node/mongo/mongo.controller.mongoose.js +41 -55
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/{src/node → node}/mongo/mongo.controller.native.d.ts +30 -3
- package/dist/node/mongo/mongo.controller.native.js +31 -14
- package/dist/node/mongo/mongo.controller.native.js.map +1 -1
- package/dist/{src/node → node}/mongo/mongo.controller.type.d.ts +1 -1
- package/dist/{src/node → node}/mongo/mongo.type.d.ts +3 -1
- package/dist/{src/node → node}/mongo/mongo.util.d.ts +1 -0
- package/dist/node/mongo/mongo.util.js +38 -17
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/package/index.d.ts +2 -1
- package/dist/{src/node → node}/package/package.util.d.ts +1 -1
- package/dist/node/package/package.util.js +47 -47
- package/dist/node/path/index.d.ts +2 -1
- package/dist/node/path/index.js +2 -2
- package/dist/{src/node → node}/path/path.constant.d.ts +4 -0
- package/dist/node/path/path.constant.js +75 -72
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/storage/index.d.ts +3 -1
- package/dist/{src/node → node}/storage/storage.util.d.ts +50 -1
- package/dist/node/storage/storage.util.js +79 -54
- package/dist/node/storage/storage.util.js.map +1 -1
- package/dist/node/upload/index.d.ts +3 -1
- package/dist/{src/node → node}/upload/upload.type.d.ts +2 -0
- package/dist/node/upload/upload.type.js.map +1 -1
- package/dist/{src/node → node}/upload/upload.util.d.ts +2 -1
- package/dist/node/upload/upload.util.js +62 -52
- package/dist/node/upload/upload.util.js.map +1 -1
- package/dist/node/ws/index.d.ts +2 -1
- package/dist/{src/node → node}/ws/ws.util.d.ts +7 -0
- package/dist/node/ws/ws.util.js +20 -19
- package/dist/node/ws/ws.util.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
- package/dist/{src/react → react}/apollo-client/apollo-client.type.d.ts +3 -1
- package/dist/react/apollo-client/apollo-client.util.js +6 -6
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-client/index.d.ts +9 -1
- package/dist/react/apollo-client/links/index.d.ts +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +16 -1
- package/dist/react/apollo-client-nextjs/index.d.ts +2 -1
- package/dist/react/apollo-error/apollo-error.component.js +1 -1
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
- package/dist/react/apollo-error/index.d.ts +6 -1
- package/dist/react/i18next/i18next.server.d.ts +17 -0
- package/dist/react/i18next/i18next.server.js +9 -0
- package/dist/react/i18next/i18next.server.js.map +1 -0
- package/dist/react/i18next/index.d.ts +2 -1
- package/dist/react/loading/index.d.ts +5 -1
- package/dist/{src/react → react}/loading/loading.provider.d.ts +1 -1
- package/dist/react/log/index.d.ts +2 -1
- package/dist/react/log/log.type.d.ts +1 -0
- package/dist/{src/react → react}/log/log.util.d.ts +1 -1
- package/dist/react/next-intl/index.d.ts +6 -1
- package/dist/{src/react → react}/next-intl/next-intl.hoc.d.ts +5 -9
- package/dist/react/next-intl/next-intl.hoc.js +14 -10
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
- package/dist/react/next-intl/next-intl.server.d.ts +10 -0
- package/dist/react/next-intl/next-intl.server.js +7 -0
- package/dist/react/next-intl/next-intl.server.js.map +1 -0
- package/dist/{src/react → react}/next-intl/next-intl.type.d.ts +1 -1
- package/dist/react/storage/index.d.ts +2 -1
- package/dist/{src/react → react}/storage/storage.hook.d.ts +1 -1
- package/dist/{src/react → react}/storage/storage.util.d.ts +34 -1
- package/dist/react/storage/storage.util.js +30 -5
- package/dist/react/storage/storage.util.js.map +1 -1
- package/dist/react/toast/index.d.ts +1 -1
- package/dist/react/userback/index.d.ts +2 -1
- package/dist/react/userback/userback.component.js.map +1 -1
- package/dist/{src/typescript → typescript}/common.type.d.ts +4 -0
- package/dist/typescript/common.type.js +2 -2
- package/dist/typescript/common.type.js.map +1 -1
- package/dist/typescript/index.d.ts +5 -1
- package/dist/typescript/index.js +2 -2
- package/dist/util/common/index.d.ts +5 -1
- package/dist/util/index.d.ts +9 -1
- package/dist/util/log/index.d.ts +2 -1
- package/dist/{src/util → util}/log/log.util.d.ts +1 -1
- package/dist/util/object/index.d.ts +4 -1
- package/dist/util/object/object.util.js +29 -18
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/index.d.ts +2 -1
- package/dist/{src/util → util}/serializer/serializer.util.d.ts +8 -0
- package/dist/util/serializer/serializer.util.js +51 -64
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/storage/storage-envelope.d.ts +25 -0
- package/dist/util/storage/storage-envelope.js +18 -0
- package/dist/util/storage/storage-envelope.js.map +1 -0
- package/dist/util/string/index.d.ts +5 -1
- package/dist/util/validate/index.d.ts +4 -1
- package/package.json +33 -12
- package/dist/node/mongo/mongo.type.js +0 -8
- package/dist/node/mongo/mongo.type.js.map +0 -1
- package/dist/node_modules/.pnpm/vitest@4.1.2_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.3_@types_nod_0827261ede788764a5d99ac6bdf44bde/node_modules/vitest/dist/config.js +0 -8
- package/dist/node_modules/.pnpm/vitest@4.1.2_@types_node@25.5.0_jsdom@29.0.1_@noble_hashes@1.8.0__vite@8.0.3_@types_nod_0827261ede788764a5d99ac6bdf44bde/node_modules/vitest/dist/config.js.map +0 -1
- package/dist/src/config/commitlint/index.d.ts +0 -5
- package/dist/src/config/env/index.d.ts +0 -3
- package/dist/src/config/eslint/index.d.ts +0 -1198
- package/dist/src/config/graphql-codegen/index.d.ts +0 -2
- package/dist/src/config/index.d.ts +0 -2
- package/dist/src/config/lint-staged/index.d.ts +0 -5
- package/dist/src/config/storybook/index.d.ts +0 -2
- package/dist/src/config/vitest/index.d.ts +0 -3
- package/dist/src/config/vitest/vitest.e2e.d.ts +0 -20
- package/dist/src/config/vitest/vitest.unit.d.ts +0 -22
- package/dist/src/constant/index.d.ts +0 -5
- package/dist/src/node/apollo-server/apollo-server.type.d.ts +0 -8
- package/dist/src/node/apollo-server/index.d.ts +0 -2
- package/dist/src/node/cli/index.d.ts +0 -2
- package/dist/src/node/command/index.d.ts +0 -2
- package/dist/src/node/express/index.d.ts +0 -2
- package/dist/src/node/fs/index.d.ts +0 -2
- package/dist/src/node/log/index.d.ts +0 -2
- package/dist/src/node/log/log.type.d.ts +0 -29
- package/dist/src/node/mongo/index.d.ts +0 -6
- package/dist/src/node/package/index.d.ts +0 -2
- package/dist/src/node/path/index.d.ts +0 -2
- package/dist/src/node/storage/index.d.ts +0 -3
- package/dist/src/node/upload/index.d.ts +0 -3
- package/dist/src/node/ws/index.d.ts +0 -2
- package/dist/src/react/apollo-client/index.d.ts +0 -9
- package/dist/src/react/apollo-client/links/index.d.ts +0 -1
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +0 -16
- package/dist/src/react/apollo-client-nextjs/index.d.ts +0 -2
- package/dist/src/react/apollo-error/index.d.ts +0 -6
- package/dist/src/react/i18next/index.d.ts +0 -2
- package/dist/src/react/loading/index.d.ts +0 -5
- package/dist/src/react/log/index.d.ts +0 -2
- package/dist/src/react/log/log.type.d.ts +0 -1
- package/dist/src/react/next-intl/index.d.ts +0 -6
- package/dist/src/react/storage/index.d.ts +0 -2
- package/dist/src/react/toast/index.d.ts +0 -1
- package/dist/src/react/userback/index.d.ts +0 -2
- package/dist/src/typescript/index.d.ts +0 -5
- package/dist/src/util/common/index.d.ts +0 -5
- package/dist/src/util/index.d.ts +0 -9
- package/dist/src/util/log/index.d.ts +0 -2
- package/dist/src/util/object/index.d.ts +0 -4
- package/dist/src/util/serializer/index.d.ts +0 -2
- package/dist/src/util/string/index.d.ts +0 -5
- package/dist/src/util/validate/index.d.ts +0 -4
- /package/dist/{src/config → config}/env/env.constant.d.ts +0 -0
- /package/dist/{src/config → config}/env/env.type.d.ts +0 -0
- /package/dist/{src/config → config}/graphql-codegen/graphql-codegen.type.d.ts +0 -0
- /package/dist/{src/config → config}/graphql-codegen/graphql-codegen.util.d.ts +0 -0
- /package/dist/{src/config → config}/storybook/storybook.main.d.ts +0 -0
- /package/dist/{src/config → config}/storybook/storybook.preview.d.ts +0 -0
- /package/dist/{src/config → config}/vitest/vitest.unit.setup.d.ts +0 -0
- /package/dist/{src/constant → constant}/common.d.ts +0 -0
- /package/dist/{src/constant → constant}/response-status.d.ts +0 -0
- /package/dist/{src/node → node}/command/command.type.d.ts +0 -0
- /package/dist/{src/node → node}/fs/fs.type.d.ts +0 -0
- /package/dist/{src/node → node}/fs/fs.util.d.ts +0 -0
- /package/dist/{src/node → node}/mongo/mongo.controller.d.ts +0 -0
- /package/dist/{src/node → node}/mongo/mongo.dynamic-populate.d.ts +0 -0
- /package/dist/{src/node → node}/mongo/mongo.internal-types.d.ts +0 -0
- /package/dist/{src/node → node}/mongo/mongo.populate.d.ts +0 -0
- /package/dist/{src/node → node}/package/package.type.d.ts +0 -0
- /package/dist/{src/node → node}/path/path.util.d.ts +0 -0
- /package/dist/{src/node → node}/storage/storage.constant.d.ts +0 -0
- /package/dist/{src/node → node}/storage/storage.type.d.ts +0 -0
- /package/dist/{src/node → node}/upload/upload.constant.d.ts +0 -0
- /package/dist/{src/node → node}/ws/ws.type.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/apollo-client.component.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/apollo-client.constant.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/apollo-client.context.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/apollo-client.hook.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/apollo-client.util.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client/links/upload.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-client-nextjs/apollo-client-nextjs.util.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.component.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.context.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.hook.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.provider.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.type.d.ts +0 -0
- /package/dist/{src/react → react}/apollo-error/apollo-error.util.d.ts +0 -0
- /package/dist/{src/react → react}/i18next/i18next.hook.d.ts +0 -0
- /package/dist/{src/react → react}/i18next/i18next.util.d.ts +0 -0
- /package/dist/{src/react → react}/loading/loading.component.d.ts +0 -0
- /package/dist/{src/react → react}/loading/loading.context.d.ts +0 -0
- /package/dist/{src/react → react}/loading/loading.hook.d.ts +0 -0
- /package/dist/{src/react → react}/loading/loading.type.d.ts +0 -0
- /package/dist/{src/react → react}/next-intl/next-intl.constant.d.ts +0 -0
- /package/dist/{src/react → react}/next-intl/next-intl.context.d.ts +0 -0
- /package/dist/{src/react → react}/next-intl/next-intl.hook.d.ts +0 -0
- /package/dist/{src/react → react}/next-intl/next-intl.provider.d.ts +0 -0
- /package/dist/{src/react → react}/userback/userback.component.d.ts +0 -0
- /package/dist/{src/react → react}/userback/userback.type.d.ts +0 -0
- /package/dist/{src/typescript → typescript}/react.type.d.ts +0 -0
- /package/dist/{src/util → util}/common/common.type.d.ts +0 -0
- /package/dist/{src/util → util}/common/common.util.d.ts +0 -0
- /package/dist/{src/util → util}/log/log.type.d.ts +0 -0
- /package/dist/{src/util → util}/object/object.util.d.ts +0 -0
- /package/dist/{src/util → util}/serializer/serializer.type.d.ts +0 -0
- /package/dist/{src/util → util}/string/string.type.d.ts +0 -0
- /package/dist/{src/util → util}/string/string.util.d.ts +0 -0
- /package/dist/{src/util → util}/validate/validate.util.d.ts +0 -0
package/dist/node/ws/ws.util.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { log as e } from "../log/log.util.js";
|
|
2
|
+
import { useServer as t } from "graphql-ws/use/ws";
|
|
3
|
+
import { WebSocketServer as n } from "ws";
|
|
3
4
|
//#region src/node/ws/ws.util.ts
|
|
4
|
-
function
|
|
5
|
-
let { server:
|
|
6
|
-
if (!
|
|
7
|
-
if (!
|
|
8
|
-
if (
|
|
9
|
-
let e = new
|
|
10
|
-
return
|
|
5
|
+
function r(t) {
|
|
6
|
+
let { server: r, path: i, sessionParser: a } = t;
|
|
7
|
+
if (!r) throw Error("[WS] HTTP server instance is required to create a WebSocket server.");
|
|
8
|
+
if (!i || !i.startsWith("/")) throw Error("[WS] WebSocket path must be a non-empty string starting with \"/\".");
|
|
9
|
+
if (a) {
|
|
10
|
+
let e = new n({ noServer: !0 });
|
|
11
|
+
return r.on("upgrade", (t, n, r) => {
|
|
11
12
|
try {
|
|
12
|
-
if (new URL(t.url || "", "http://localhost").pathname !==
|
|
13
|
-
|
|
14
|
-
e.handleUpgrade(t, n,
|
|
13
|
+
if (new URL(t.url || "", "http://localhost").pathname !== i) return;
|
|
14
|
+
a(t, {}, () => {
|
|
15
|
+
e.handleUpgrade(t, n, r, (n) => {
|
|
15
16
|
e.emit("connection", n, t);
|
|
16
17
|
});
|
|
17
18
|
});
|
|
@@ -20,14 +21,14 @@ function n(e) {
|
|
|
20
21
|
}
|
|
21
22
|
}), e;
|
|
22
23
|
}
|
|
23
|
-
return new
|
|
24
|
-
server:
|
|
25
|
-
path:
|
|
24
|
+
return e.warn(`[WS] Creating unauthenticated WebSocket at "${i}". No sessionParser provided — any client can connect. Provide a sessionParser for authenticated endpoints.`), new n({
|
|
25
|
+
server: r,
|
|
26
|
+
path: i
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
let { schema: n, server: r, context: i, onConnect: a } =
|
|
30
|
-
return
|
|
29
|
+
function i(e) {
|
|
30
|
+
let { schema: n, server: r, context: i, onConnect: a } = e;
|
|
31
|
+
return t({
|
|
31
32
|
schema: n,
|
|
32
33
|
context: async (e) => {
|
|
33
34
|
let t = e.extra.request;
|
|
@@ -45,6 +46,6 @@ function r(t) {
|
|
|
45
46
|
}, r);
|
|
46
47
|
}
|
|
47
48
|
//#endregion
|
|
48
|
-
export {
|
|
49
|
+
export { r as createWSServer, i as initGraphQLWS };
|
|
49
50
|
|
|
50
51
|
//# sourceMappingURL=ws.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.util.js","names":[],"sources":["../../../src/node/ws/ws.util.ts"],"sourcesContent":["import type { Request, Response } from 'express';\nimport type { Buffer } from 'node:buffer';\nimport type { IncomingMessage } from 'node:http';\nimport type { Duplex } from 'node:stream';\n\nimport { useServer as createGraphQLWSServer } from 'graphql-ws/use/ws';\nimport { WebSocketServer } from 'ws';\n\nimport type { I_AuthenticatedRequest, I_GraphqlWSOptions, I_WSOptions } from './ws.type.js';\n\n/**\n * Creates a WebSocket server with the specified configuration.\n * This function creates a WebSocket server instance that can be attached to an HTTP server\n * and configured with a specific path for WebSocket connections.\n *\n * @param options - Configuration options including the HTTP server instance and WebSocket path.\n * @returns A configured WebSocket server instance ready to handle connections.\n */\nexport function createWSServer(options: I_WSOptions): WebSocketServer {\n const { server, path, sessionParser } = options;\n\n if (!server) {\n throw new Error('[WS] HTTP server instance is required to create a WebSocket server.');\n }\n\n if (!path || !path.startsWith('/')) {\n throw new Error('[WS] WebSocket path must be a non-empty string starting with \"/\".');\n }\n\n if (sessionParser) {\n const wss = new WebSocketServer({ noServer: true });\n\n server.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer) => {\n try {\n const url = new URL(req.url || '', 'http://localhost');\n if (url.pathname !== path)\n return;\n\n sessionParser(req as Request, {} as Response, () => {\n wss.handleUpgrade(req, socket, head, (ws) => {\n wss.emit('connection', ws, req);\n });\n });\n }\n catch {\n socket.destroy();\n }\n });\n\n return wss;\n }\n\n return new WebSocketServer({ server, path });\n}\n\n/**\n * Initializes GraphQL WebSocket server with schema and WebSocket server.\n * This function sets up GraphQL subscriptions over WebSocket by creating a GraphQL WebSocket server\n * that can handle GraphQL operations including queries, mutations, and subscriptions.\n *\n * @param options - Configuration options including the GraphQL schema and WebSocket server instance.\n * @returns A configured GraphQL WebSocket server ready to handle GraphQL operations over WebSocket.\n */\nexport function initGraphQLWS(options: I_GraphqlWSOptions) {\n const { schema, server, context: makeExtraContext, onConnect } = options;\n\n return createGraphQLWSServer(\n {\n schema,\n context: async (ctx) => {\n const req = ctx.extra.request as I_AuthenticatedRequest;\n\n const extra = makeExtraContext ? await makeExtraContext(req) : {};\n return { req, ...extra };\n },\n onConnect: async (ctx) => {\n if (onConnect) {\n const req = ctx.extra.request as I_AuthenticatedRequest;\n await onConnect(req);\n }\n },\n },\n server,\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ws.util.js","names":[],"sources":["../../../src/node/ws/ws.util.ts"],"sourcesContent":["import type { Request, Response } from 'express';\nimport type { Buffer } from 'node:buffer';\nimport type { IncomingMessage } from 'node:http';\nimport type { Duplex } from 'node:stream';\n\nimport { useServer as createGraphQLWSServer } from 'graphql-ws/use/ws';\nimport { WebSocketServer } from 'ws';\n\nimport type { I_AuthenticatedRequest, I_GraphqlWSOptions, I_WSOptions } from './ws.type.js';\n\nimport { log } from '../log/index.js';\n\n/**\n * Creates a WebSocket server with the specified configuration.\n * This function creates a WebSocket server instance that can be attached to an HTTP server\n * and configured with a specific path for WebSocket connections.\n *\n * @remarks\n * **Authentication Warning:** When `sessionParser` is not provided, the WebSocket server\n * has **no session-based authentication**. Any client that can reach the endpoint can\n * establish a connection. Only omit `sessionParser` for truly public WebSocket endpoints\n * (e.g., health-check or anonymous broadcast channels). For authenticated subscriptions,\n * always provide a `sessionParser` to validate sessions on upgrade.\n *\n * @param options - Configuration options including the HTTP server instance and WebSocket path.\n * @returns A configured WebSocket server instance ready to handle connections.\n */\nexport function createWSServer(options: I_WSOptions): WebSocketServer {\n const { server, path, sessionParser } = options;\n\n if (!server) {\n throw new Error('[WS] HTTP server instance is required to create a WebSocket server.');\n }\n\n if (!path || !path.startsWith('/')) {\n throw new Error('[WS] WebSocket path must be a non-empty string starting with \"/\".');\n }\n\n if (sessionParser) {\n const wss = new WebSocketServer({ noServer: true });\n\n server.on('upgrade', (req: IncomingMessage, socket: Duplex, head: Buffer) => {\n try {\n const url = new URL(req.url || '', 'http://localhost');\n if (url.pathname !== path)\n return;\n\n sessionParser(req as Request, {} as Response, () => {\n wss.handleUpgrade(req, socket, head, (ws) => {\n wss.emit('connection', ws, req);\n });\n });\n }\n catch {\n /* Intentionally empty — destroy socket on any URL parsing or session error */\n socket.destroy();\n }\n });\n\n return wss;\n }\n\n log.warn(`[WS] Creating unauthenticated WebSocket at \"${path}\". No sessionParser provided — any client can connect. Provide a sessionParser for authenticated endpoints.`);\n\n return new WebSocketServer({ server, path });\n}\n\n/**\n * Initializes GraphQL WebSocket server with schema and WebSocket server.\n * This function sets up GraphQL subscriptions over WebSocket by creating a GraphQL WebSocket server\n * that can handle GraphQL operations including queries, mutations, and subscriptions.\n *\n * @param options - Configuration options including the GraphQL schema and WebSocket server instance.\n * @returns A configured GraphQL WebSocket server ready to handle GraphQL operations over WebSocket.\n */\nexport function initGraphQLWS(options: I_GraphqlWSOptions) {\n const { schema, server, context: makeExtraContext, onConnect } = options;\n\n return createGraphQLWSServer(\n {\n schema,\n context: async (ctx) => {\n const req = ctx.extra.request as I_AuthenticatedRequest;\n\n const extra = makeExtraContext ? await makeExtraContext(req) : {};\n return { req, ...extra };\n },\n onConnect: async (ctx) => {\n if (onConnect) {\n const req = ctx.extra.request as I_AuthenticatedRequest;\n await onConnect(req);\n }\n },\n },\n server,\n );\n}\n"],"mappings":";;;;AA2BA,SAAgB,EAAe,GAAuC;CAClE,IAAM,EAAE,WAAQ,SAAM,qBAAkB;AAExC,KAAI,CAAC,EACD,OAAU,MAAM,sEAAsE;AAG1F,KAAI,CAAC,KAAQ,CAAC,EAAK,WAAW,IAAI,CAC9B,OAAU,MAAM,sEAAoE;AAGxF,KAAI,GAAe;EACf,IAAM,IAAM,IAAI,EAAgB,EAAE,UAAU,IAAM,CAAC;AAoBnD,SAlBA,EAAO,GAAG,YAAY,GAAsB,GAAgB,MAAiB;AACzE,OAAI;AAEA,QADY,IAAI,IAAI,EAAI,OAAO,IAAI,mBAAmB,CAC9C,aAAa,EACjB;AAEJ,MAAc,GAAgB,EAAE,QAAoB;AAChD,OAAI,cAAc,GAAK,GAAQ,IAAO,MAAO;AACzC,QAAI,KAAK,cAAc,GAAI,EAAI;OACjC;MACJ;WAEA;AAEF,MAAO,SAAS;;IAEtB,EAEK;;AAKX,QAFA,EAAI,KAAK,+CAA+C,EAAK,6GAA6G,EAEnK,IAAI,EAAgB;EAAE;EAAQ;EAAM,CAAC;;AAWhD,SAAgB,EAAc,GAA6B;CACvD,IAAM,EAAE,WAAQ,WAAQ,SAAS,GAAkB,iBAAc;AAEjE,QAAO,EACH;EACI;EACA,SAAS,OAAO,MAAQ;GACpB,IAAM,IAAM,EAAI,MAAM;AAGtB,UAAO;IAAE;IAAK,GADA,IAAmB,MAAM,EAAiB,EAAI,GAAG,EAAE;IACzC;;EAE5B,WAAW,OAAO,MAAQ;AACtB,OAAI,GAAW;IACX,IAAM,IAAM,EAAI,MAAM;AACtB,UAAM,EAAU,EAAI;;;EAG/B,EACD,EACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.component.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.component.tsx"],"sourcesContent":["import { ApolloProvider as ApolloProviderDefault } from '@apollo/client/react';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from './apollo-client.type.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { ApolloClientProvider } from './apollo-client.context.js';\nimport { getClient } from './apollo-client.util.js';\n\n/**\n * Apollo Provider component that wraps the application with Apollo Client context.\n * This component provides the Apollo Client instance to all child components,\n * enabling GraphQL operations throughout the component tree. It includes\n * error handling and toast integration for a complete GraphQL experience.\n *\n * Features:\n * - Apollo Client context provision\n * - Error boundary integration\n * - Toast notification support\n * - Automatic error handling\n * - Development and production optimizations\n *\n * @param props - Component props containing options, children, and optional error override.\n * @param props.options - Apollo Client configuration options.\n * @param props.children - React children that will have access to Apollo Client context.\n * @param props.onError - Optional callback to override the default modal/toast error handling.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloProvider({ options, children, onError }: I_ApolloProviderProps) {\n const client = useMemo(\n () => getClient(options ?? {}),\n //
|
|
1
|
+
{"version":3,"file":"apollo-client.component.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.component.tsx"],"sourcesContent":["import { ApolloProvider as ApolloProviderDefault } from '@apollo/client/react';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from './apollo-client.type.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { ApolloClientProvider } from './apollo-client.context.js';\nimport { getClient } from './apollo-client.util.js';\n\n/**\n * Apollo Provider component that wraps the application with Apollo Client context.\n * This component provides the Apollo Client instance to all child components,\n * enabling GraphQL operations throughout the component tree. It includes\n * error handling and toast integration for a complete GraphQL experience.\n *\n * Features:\n * - Apollo Client context provision\n * - Error boundary integration\n * - Toast notification support\n * - Automatic error handling\n * - Development and production optimizations\n *\n * @param props - Component props containing options, children, and optional error override.\n * @param props.options - Apollo Client configuration options.\n * @param props.children - React children that will have access to Apollo Client context.\n * @param props.onError - Optional callback to override the default modal/toast error handling.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloProvider({ options, children, onError }: I_ApolloProviderProps) {\n const client = useMemo(\n () => getClient(options ?? {}),\n // eslint-disable-next-line react/exhaustive-deps -- intended to only recreate on uri/wsUrl change\n [options?.uri, options?.wsUrl],\n );\n\n return (\n <>\n <ApolloErrorProvider onError={onError}>\n <ApolloClientProvider client={client}>\n <ApolloProviderDefault client={client}>{children}</ApolloProviderDefault>\n </ApolloClientProvider>\n {!onError && <ApolloErrorComponent />}\n </ApolloErrorProvider>\n <Toaster position=\"top-right\" />\n </>\n );\n}\n"],"mappings":";;;;;;;;;AA8BA,SAAgB,EAAe,EAAE,YAAS,aAAU,cAAkC;CAClF,IAAM,IAAS,QACL,EAAU,KAAW,EAAE,CAAC,EAE9B,CAAC,GAAS,KAAK,GAAS,MAAM,CACjC;AAED,QACI,kBAAA,cAAA,EAAA,UAAA,MACI,kBAAA,cAAC,GAAD,EAA8B,YAKR,EAJlB,kBAAA,cAAC,GAAD,EAA8B,WAEP,EADnB,kBAAA,cAAC,GAAD,EAA+B,WAA0C,EAAjC,EAAiC,CACtD,EACtB,CAAC,KAAW,kBAAA,cAAC,GAAA,KAAuB,CACnB,EACtB,kBAAA,cAAC,GAAD,EAAS,UAAS,aAAc,CAAA,CACjC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
|
2
2
|
import { ApolloLink } from '@apollo/client/link';
|
|
3
3
|
import { GraphQLError } from 'graphql';
|
|
4
|
-
import { I_Children } from '
|
|
4
|
+
import { I_Children } from '../../typescript/index.js';
|
|
5
5
|
export interface I_ApolloOptions extends Omit<ApolloClient.Options, 'link' | 'cache'> {
|
|
6
6
|
uri?: string;
|
|
7
7
|
wsUrl?: string;
|
|
8
8
|
customLinks?: ApolloLink[];
|
|
9
|
+
/** Enable round-trip timing logs for every GraphQL operation. Defaults to false. */
|
|
10
|
+
debug?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export interface I_ApolloProviderProps extends I_Children {
|
|
11
13
|
isNextJS?: boolean;
|
|
@@ -33,19 +33,19 @@ var x = new l((e, t) => (e.setContext({ start: performance.now() }), t(e).pipe(b
|
|
|
33
33
|
}, "Error Details"))));
|
|
34
34
|
});
|
|
35
35
|
function C(e) {
|
|
36
|
-
let { uri: t, wsUrl: r, customLinks: i } = e,
|
|
36
|
+
let { uri: t, wsUrl: r, customLinks: i, debug: o } = e, c = new g();
|
|
37
37
|
t || n.warn(`[Apollo] No GraphQL URI provided — using "${a}" as default`);
|
|
38
|
-
let
|
|
38
|
+
let u = s({
|
|
39
39
|
uri: t ?? "/graphql",
|
|
40
40
|
credentials: "include",
|
|
41
41
|
headers: { "apollo-require-preflight": "true" }
|
|
42
|
-
}),
|
|
42
|
+
}), d = r ? new _(y({ url: r })) : l.empty(), f = r ? l.split(({ operationType: e }) => e === v.SUBSCRIPTION, d, u) : u;
|
|
43
43
|
return [
|
|
44
|
-
x,
|
|
44
|
+
...o ? [x] : [],
|
|
45
45
|
S,
|
|
46
|
-
|
|
46
|
+
c,
|
|
47
47
|
...i ?? [],
|
|
48
|
-
|
|
48
|
+
f
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
function w(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.util.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.util.tsx"],"sourcesContent":["import { ApolloClient, CombinedGraphQLErrors, CombinedProtocolErrors, InMemoryCache, ServerError } from '@apollo/client/core';\nimport { ApolloLink } from '@apollo/client/link';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { RemoveTypenameFromVariablesLink } from '@apollo/client/link/remove-typename';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { OperationTypeNode } from 'graphql';\nimport { createClient } from 'graphql-ws';\nimport * as React from 'react';\nimport { tap } from 'rxjs';\n\nimport { IS_BROWSER } from '#constant/index.js';\n\nimport type { I_ApolloOptions } from './apollo-client.type.js';\n\nimport { hasCustomApolloErrorHandler, showGlobalApolloError } from '../apollo-error/index.js';\nimport { log } from '../log/index.js';\nimport { toast } from '../toast/index.js';\nimport { GRAPHQL_URI_DEFAULT } from './apollo-client.constant.js';\nimport styles from './apollo-client.module.scss';\nimport { createUploadLink } from './links/index.js';\n\nconst roundTripLink = new ApolloLink((operation, forward) => {\n operation.setContext({ start: performance.now() });\n\n return forward(operation).pipe(\n tap(() => {\n const time = Math.round(performance.now() - operation.getContext()['start']);\n\n log.info(`Operation ${operation.operationName} took ${time}ms to complete`);\n }),\n );\n});\n\nconst errorLink = new ErrorLink(({ error, operation }) => {\n const opName = operation?.operationName || 'Unknown';\n let errorMessage = '';\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[GraphQL error] ${opName}: ${message}, Location: ${JSON.stringify(locations, null, 4)}, Path: ${path}`,\n );\n });\n }\n else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[Protocol error]: ${message}, Extensions: ${JSON.stringify(extensions, null, 4)}`,\n );\n });\n }\n else if (ServerError.is(error)) {\n errorMessage = error.message;\n\n log.error(`[Server error]: ${error.message}`);\n }\n else {\n errorMessage = error.message;\n\n log.error(`[Network error]: ${error.message}`);\n }\n\n if (error && errorMessage && IS_BROWSER) {\n if (hasCustomApolloErrorHandler()) {\n showGlobalApolloError(error);\n }\n else {\n toast.error((t: { id: string }) => (\n <div className={styles['error-container']}>\n {errorMessage}\n <button\n type=\"button\"\n className={styles['error-details-button']}\n onClick={() => {\n showGlobalApolloError(error);\n\n toast.dismiss(t.id);\n }}\n >\n Error Details\n </button>\n </div>\n ));\n }\n }\n});\n\n/**\n * Creates a comprehensive Apollo Link chain with all necessary middleware.\n * This function sets up a complete Apollo Link chain including error handling,\n * logging, file uploads, WebSocket subscriptions, and custom links. The chain\n * is configured to handle both HTTP and WebSocket operations with proper routing.\n *\n * The link chain includes:\n * - Development logging for operation tracking\n * - Error handling with user-friendly notifications\n * - Type name removal for cleaner requests\n * - File upload support\n * - WebSocket subscription support\n * - Custom link integration\n *\n * @param options - Configuration options for the Apollo Client including URI, WebSocket URL, and custom links.\n * @returns An array of Apollo Links configured for the specified options.\n */\nexport function createApolloLinks(options: I_ApolloOptions): ApolloLink[] {\n const { uri, wsUrl, customLinks } = options;\n\n const removeTypenameLink = new RemoveTypenameFromVariablesLink();\n\n if (!uri) {\n log.warn(`[Apollo] No GraphQL URI provided — using \"${GRAPHQL_URI_DEFAULT}\" as default`);\n }\n\n const uploadLink = createUploadLink({\n uri: uri ?? GRAPHQL_URI_DEFAULT,\n credentials: 'include',\n headers: {\n 'apollo-require-preflight': 'true',\n },\n });\n\n const wsLink = wsUrl\n ? new GraphQLWsLink(createClient({ url: wsUrl }))\n : ApolloLink.empty();\n\n const splitLink = wsUrl\n ? ApolloLink.split(\n ({ operationType }) => {\n return operationType === OperationTypeNode.SUBSCRIPTION;\n },\n wsLink,\n uploadLink as unknown as ApolloLink,\n )\n : uploadLink;\n\n return [\n roundTripLink,\n errorLink,\n removeTypenameLink,\n ...(customLinks ?? []),\n splitLink as unknown as ApolloLink,\n ];\n}\n\n/**\n * Creates a fully configured Apollo Client instance.\n * This function creates an Apollo Client with all necessary configuration including\n * the link chain, cache, and any additional options provided. The client is ready\n * for immediate use in React applications with comprehensive error handling and\n * development tooling.\n *\n * @param options - Configuration options for the Apollo Client including links, cache, and other settings.\n * @returns A fully configured Apollo Client instance ready for use.\n */\nexport function getClient(options: I_ApolloOptions) {\n const link = ApolloLink.from(createApolloLinks(options));\n\n return new ApolloClient({\n link,\n cache: new InMemoryCache(),\n ...options,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,IAAM,IAAgB,IAAI,GAAY,GAAW,OAC7C,EAAU,WAAW,EAAE,OAAO,YAAY,KAAK,EAAE,CAAC,EAE3C,EAAQ,EAAU,CAAC,KACtB,QAAU;CACN,IAAM,IAAO,KAAK,MAAM,YAAY,KAAK,GAAG,EAAU,YAAY,CAAC,MAAS;AAE5E,GAAI,KAAK,aAAa,EAAU,cAAc,QAAQ,EAAK,gBAAgB;EAC7E,CACL,EACH,EAEI,IAAY,IAAI,GAAW,EAAE,UAAO,mBAAgB;CACtD,IAAM,IAAS,GAAW,iBAAiB,WACvC,IAAe;AAmCnB,CAjCI,EAAsB,GAAG,EAAM,GAC/B,EAAM,OAAO,SAAS,EAAE,YAAS,cAAW,WAAQ,MAAU;AAK1D,EAJI,MAAU,MACV,IAAe,IAGnB,EAAI,MACA,mBAAmB,EAAO,IAAI,EAAQ,cAAc,KAAK,UAAU,GAAW,MAAM,EAAE,CAAC,UAAU,IACpG;GACH,GAEG,EAAuB,GAAG,EAAM,GACrC,EAAM,OAAO,SAAS,EAAE,YAAS,iBAAc,MAAU;AAKrD,EAJI,MAAU,MACV,IAAe,IAGnB,EAAI,MACA,qBAAqB,EAAQ,gBAAgB,KAAK,UAAU,GAAY,MAAM,EAAE,GACnF;GACH,GAEG,EAAY,GAAG,EAAM,IAC1B,IAAe,EAAM,SAErB,EAAI,MAAM,mBAAmB,EAAM,UAAU,KAG7C,IAAe,EAAM,SAErB,EAAI,MAAM,oBAAoB,EAAM,UAAU,GAG9C,KAAS,KAAgB,MACrB,GAA6B,GAC7B,EAAsB,EAAM,GAG5B,EAAM,OAAO,MACT,kBAAA,cAAC,OAAD,EAAK,WAAW,EAAO,oBAajB,EAZD,GACD,kBAAA,cAAC,UAAD;EACI,MAAK;EACL,WAAW,EAAO;EAClB,eAAe;AAGX,GAFA,EAAsB,EAAM,EAE5B,EAAM,QAAQ,EAAE,GAAG;;EAIlB,EAFR,gBAEQ,CACP,CACR;EAGZ;AAmBF,SAAgB,EAAkB,GAAwC;CACtE,IAAM,EAAE,QAAK,UAAO,
|
|
1
|
+
{"version":3,"file":"apollo-client.util.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.util.tsx"],"sourcesContent":["import { ApolloClient, CombinedGraphQLErrors, CombinedProtocolErrors, InMemoryCache, ServerError } from '@apollo/client/core';\nimport { ApolloLink } from '@apollo/client/link';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { RemoveTypenameFromVariablesLink } from '@apollo/client/link/remove-typename';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { OperationTypeNode } from 'graphql';\nimport { createClient } from 'graphql-ws';\nimport * as React from 'react';\nimport { tap } from 'rxjs';\n\nimport { IS_BROWSER } from '#constant/index.js';\n\nimport type { I_ApolloOptions } from './apollo-client.type.js';\n\nimport { hasCustomApolloErrorHandler, showGlobalApolloError } from '../apollo-error/index.js';\nimport { log } from '../log/index.js';\nimport { toast } from '../toast/index.js';\nimport { GRAPHQL_URI_DEFAULT } from './apollo-client.constant.js';\nimport styles from './apollo-client.module.scss';\nimport { createUploadLink } from './links/index.js';\n\nconst roundTripLink = new ApolloLink((operation, forward) => {\n operation.setContext({ start: performance.now() });\n\n return forward(operation).pipe(\n tap(() => {\n const time = Math.round(performance.now() - operation.getContext()['start']);\n\n log.info(`Operation ${operation.operationName} took ${time}ms to complete`);\n }),\n );\n});\n\nconst errorLink = new ErrorLink(({ error, operation }) => {\n const opName = operation?.operationName || 'Unknown';\n let errorMessage = '';\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[GraphQL error] ${opName}: ${message}, Location: ${JSON.stringify(locations, null, 4)}, Path: ${path}`,\n );\n });\n }\n else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[Protocol error]: ${message}, Extensions: ${JSON.stringify(extensions, null, 4)}`,\n );\n });\n }\n else if (ServerError.is(error)) {\n errorMessage = error.message;\n\n log.error(`[Server error]: ${error.message}`);\n }\n else {\n errorMessage = error.message;\n\n log.error(`[Network error]: ${error.message}`);\n }\n\n if (error && errorMessage && IS_BROWSER) {\n if (hasCustomApolloErrorHandler()) {\n showGlobalApolloError(error);\n }\n else {\n toast.error((t: { id: string }) => (\n <div className={styles['error-container']}>\n {errorMessage}\n <button\n type=\"button\"\n className={styles['error-details-button']}\n onClick={() => {\n showGlobalApolloError(error);\n\n toast.dismiss(t.id);\n }}\n >\n Error Details\n </button>\n </div>\n ));\n }\n }\n});\n\n/**\n * Creates a comprehensive Apollo Link chain with all necessary middleware.\n * This function sets up a complete Apollo Link chain including error handling,\n * logging, file uploads, WebSocket subscriptions, and custom links. The chain\n * is configured to handle both HTTP and WebSocket operations with proper routing.\n *\n * The link chain includes:\n * - Development logging for operation tracking\n * - Error handling with user-friendly notifications\n * - Type name removal for cleaner requests\n * - File upload support\n * - WebSocket subscription support\n * - Custom link integration\n *\n * @param options - Configuration options for the Apollo Client including URI, WebSocket URL, and custom links.\n * @returns An array of Apollo Links configured for the specified options.\n */\nexport function createApolloLinks(options: I_ApolloOptions): ApolloLink[] {\n const { uri, wsUrl, customLinks, debug } = options;\n\n const removeTypenameLink = new RemoveTypenameFromVariablesLink();\n\n if (!uri) {\n log.warn(`[Apollo] No GraphQL URI provided — using \"${GRAPHQL_URI_DEFAULT}\" as default`);\n }\n\n const uploadLink = createUploadLink({\n uri: uri ?? GRAPHQL_URI_DEFAULT,\n credentials: 'include',\n headers: {\n 'apollo-require-preflight': 'true',\n },\n });\n\n const wsLink = wsUrl\n ? new GraphQLWsLink(createClient({ url: wsUrl }))\n : ApolloLink.empty();\n\n const splitLink = wsUrl\n ? ApolloLink.split(\n ({ operationType }) => {\n return operationType === OperationTypeNode.SUBSCRIPTION;\n },\n wsLink,\n uploadLink as unknown as ApolloLink,\n )\n : uploadLink;\n\n return [\n ...(debug ? [roundTripLink] : []),\n errorLink,\n removeTypenameLink,\n ...(customLinks ?? []),\n splitLink as unknown as ApolloLink,\n ];\n}\n\n/**\n * Creates a fully configured Apollo Client instance.\n * This function creates an Apollo Client with all necessary configuration including\n * the link chain, cache, and any additional options provided. The client is ready\n * for immediate use in React applications with comprehensive error handling and\n * development tooling.\n *\n * @param options - Configuration options for the Apollo Client including links, cache, and other settings.\n * @returns A fully configured Apollo Client instance ready for use.\n */\nexport function getClient(options: I_ApolloOptions) {\n const link = ApolloLink.from(createApolloLinks(options));\n\n return new ApolloClient({\n link,\n cache: new InMemoryCache(),\n ...options,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,IAAM,IAAgB,IAAI,GAAY,GAAW,OAC7C,EAAU,WAAW,EAAE,OAAO,YAAY,KAAK,EAAE,CAAC,EAE3C,EAAQ,EAAU,CAAC,KACtB,QAAU;CACN,IAAM,IAAO,KAAK,MAAM,YAAY,KAAK,GAAG,EAAU,YAAY,CAAC,MAAS;AAE5E,GAAI,KAAK,aAAa,EAAU,cAAc,QAAQ,EAAK,gBAAgB;EAC7E,CACL,EACH,EAEI,IAAY,IAAI,GAAW,EAAE,UAAO,mBAAgB;CACtD,IAAM,IAAS,GAAW,iBAAiB,WACvC,IAAe;AAmCnB,CAjCI,EAAsB,GAAG,EAAM,GAC/B,EAAM,OAAO,SAAS,EAAE,YAAS,cAAW,WAAQ,MAAU;AAK1D,EAJI,MAAU,MACV,IAAe,IAGnB,EAAI,MACA,mBAAmB,EAAO,IAAI,EAAQ,cAAc,KAAK,UAAU,GAAW,MAAM,EAAE,CAAC,UAAU,IACpG;GACH,GAEG,EAAuB,GAAG,EAAM,GACrC,EAAM,OAAO,SAAS,EAAE,YAAS,iBAAc,MAAU;AAKrD,EAJI,MAAU,MACV,IAAe,IAGnB,EAAI,MACA,qBAAqB,EAAQ,gBAAgB,KAAK,UAAU,GAAY,MAAM,EAAE,GACnF;GACH,GAEG,EAAY,GAAG,EAAM,IAC1B,IAAe,EAAM,SAErB,EAAI,MAAM,mBAAmB,EAAM,UAAU,KAG7C,IAAe,EAAM,SAErB,EAAI,MAAM,oBAAoB,EAAM,UAAU,GAG9C,KAAS,KAAgB,MACrB,GAA6B,GAC7B,EAAsB,EAAM,GAG5B,EAAM,OAAO,MACT,kBAAA,cAAC,OAAD,EAAK,WAAW,EAAO,oBAajB,EAZD,GACD,kBAAA,cAAC,UAAD;EACI,MAAK;EACL,WAAW,EAAO;EAClB,eAAe;AAGX,GAFA,EAAsB,EAAM,EAE5B,EAAM,QAAQ,EAAE,GAAG;;EAIlB,EAFR,gBAEQ,CACP,CACR;EAGZ;AAmBF,SAAgB,EAAkB,GAAwC;CACtE,IAAM,EAAE,QAAK,UAAO,gBAAa,aAAU,GAErC,IAAqB,IAAI,GAAiC;AAEhE,CAAK,KACD,EAAI,KAAK,6CAA6C,EAAoB,cAAc;CAG5F,IAAM,IAAa,EAAiB;EAChC,KAAK,KAAA;EACL,aAAa;EACb,SAAS,EACL,4BAA4B,QAC/B;EACJ,CAAC,EAEI,IAAS,IACT,IAAI,EAAc,EAAa,EAAE,KAAK,GAAO,CAAC,CAAC,GAC/C,EAAW,OAAO,EAElB,IAAY,IACZ,EAAW,OACJ,EAAE,uBACQ,MAAkB,EAAkB,cAE/C,GACA,EACH,GACH;AAEN,QAAO;EACH,GAAI,IAAQ,CAAC,EAAc,GAAG,EAAE;EAChC;EACA;EACA,GAAI,KAAe,EAAE;EACrB;EACH;;AAaL,SAAgB,EAAU,GAA0B;AAGhD,QAAO,IAAI,EAAa;EACpB,MAHS,EAAW,KAAK,EAAkB,EAAQ,CAAC;EAIpD,OAAO,IAAI,GAAe;EAC1B,GAAG;EACN,CAAC"}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './apollo-client.component.js';
|
|
2
|
+
export * from './apollo-client.constant.js';
|
|
3
|
+
export * from './apollo-client.context.js';
|
|
4
|
+
export * from './apollo-client.hook.js';
|
|
5
|
+
export * from './apollo-client.type.js';
|
|
6
|
+
export * from './apollo-client.util.js';
|
|
7
|
+
export * from './links/index.js';
|
|
8
|
+
export { makeVar } from '@apollo/client/cache';
|
|
9
|
+
export { useApolloClient, useBackgroundQuery, useFragment, useLazyQuery, useLoadableQuery, useMutation, useQuery, useQueryRefHandlers, useReactiveVar, useReadQuery, useSubscription, useSuspenseFragment, useSuspenseQuery } from '@apollo/client/react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './upload.js';
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { I_ApolloOptions } from '../apollo-client/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a registered Apollo Client factory for Next.js server components.
|
|
4
|
+
* This function creates a client factory that is registered with Next.js for
|
|
5
|
+
* proper server-side rendering support. The factory function ensures that
|
|
6
|
+
* each request gets its own Apollo Client instance, which is essential for
|
|
7
|
+
* SSR compatibility and preventing client state leakage between requests.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Configuration options for the Apollo Client including URI, WebSocket URL, and custom links.
|
|
10
|
+
* @returns A registered Apollo Client factory function that can be used with Next.js server components.
|
|
11
|
+
*/
|
|
12
|
+
export declare const makeClient: (options?: I_ApolloOptions) => {
|
|
13
|
+
getClient: () => import('@apollo/client-integration-nextjs').ApolloClient;
|
|
14
|
+
query: <TData = unknown, TVariables extends import('@apollo/client').OperationVariables = import('@apollo/client').OperationVariables>(options: import("@apollo/client").ApolloClient.QueryOptions<TData, TVariables>) => Promise<import("@apollo/client").ApolloClient.QueryResult<import('@apollo/client').MaybeMasked<TData>>>;
|
|
15
|
+
PreloadQuery: import('@apollo/client-integration-nextjs').PreloadQueryComponent;
|
|
16
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './apollo-client-nextjs.component.js';
|
|
2
|
+
export * from './apollo-client-nextjs.util.js';
|
|
@@ -23,7 +23,7 @@ function c() {
|
|
|
23
23
|
let t = [...u.current.querySelectorAll(s)].filter((e) => !e.hasAttribute("disabled"));
|
|
24
24
|
if (t.length === 0) return;
|
|
25
25
|
let n = t[0], r = t.at(-1);
|
|
26
|
-
!n || !r || (e.shiftKey ? document.activeElement === n && (e.preventDefault(), r.focus()) : document.activeElement === r && (e.preventDefault(), n.focus()));
|
|
26
|
+
!n || !r || (e.shiftKey ? (document.activeElement === n || document.activeElement === u.current) && (e.preventDefault(), r.focus()) : document.activeElement === r && (e.preventDefault(), n.focus()));
|
|
27
27
|
};
|
|
28
28
|
if (!c) return null;
|
|
29
29
|
let p = "locations" in c || "path" in c || "extensions" in c, m = "message" in c ? c.message : "Unknown error occurred";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-error.component.js","names":[],"sources":["../../../src/react/apollo-error/apollo-error.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport { use, useEffect, useRef } from 'react';\n\nimport { validate } from '#util/validate/validate.util.js';\n\nimport { ApolloErrorContext } from './apollo-error.context.js';\nimport style from './apollo-error.module.scss';\n\nconst FOCUSABLE_SELECTORS = 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Apollo Error Component that displays detailed error information in a modal.\n * This component provides a comprehensive error display interface that shows\n * GraphQL errors and other error types with detailed information for debugging purposes.\n *\n * Features:\n * - Modal overlay with backdrop for focus\n * - Detailed error categorization and display\n * - Reload functionality for error recovery\n * - Close button to dismiss the error modal\n * - Structured display of different error types\n * - Extra information display for debugging\n *\n * @returns A modal component displaying Apollo error details, or null if no error is present.\n */\nexport function ApolloErrorComponent() {\n const context = use(ApolloErrorContext);\n const { error, hideError } = context ?? {};\n const dialogRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!error || !hideError)\n return;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n hideError();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n };\n }, [error, hideError]);\n\n useEffect(() => {\n if (error && dialogRef.current) {\n previousFocusRef.current = document.activeElement as HTMLElement;\n dialogRef.current.focus();\n }\n else if (!error && previousFocusRef.current) {\n previousFocusRef.current.focus();\n previousFocusRef.current = null;\n }\n }, [error]);\n\n const handleFocusTrap = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Tab' || !dialogRef.current)\n return;\n\n const focusableElements = [...dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS)].filter(el => !el.hasAttribute('disabled'));\n\n if (focusableElements.length === 0)\n return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements.at(-1);\n\n if (!firstElement || !lastElement)\n return;\n\n if (event.shiftKey) {\n if (document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n }\n }\n else if (document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n };\n\n if (!error) {\n return null;\n }\n\n const isGraphQLError = 'locations' in error || 'path' in error || 'extensions' in error;\n const errorMessage = 'message' in error ? error.message : 'Unknown error occurred';\n\n return (\n <div className={style['modal-backdrop']} onClick={hideError}>\n <div\n ref={dialogRef}\n className={style['modal-content']}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"apollo-error-title\"\n aria-describedby=\"apollo-error-details\"\n tabIndex={-1}\n onKeyDown={handleFocusTrap}\n onClick={e => e.stopPropagation()}\n >\n <button\n type=\"button\"\n className={style['btn-close']}\n onClick={hideError}\n aria-label=\"Close error details (Esc)\"\n aria-keyshortcuts=\"Escape\"\n title=\"Close error details (Esc)\"\n >\n ✕\n </button>\n <div className={style['error-title']}>\n <button\n type=\"button\"\n className={style['btn-retry']}\n onClick={() => window.location.reload()}\n aria-label=\"Reload page\"\n >\n Reload\n </button>\n {' '}\n <span id=\"apollo-error-title\">\n {errorMessage || 'Error details'}\n </span>\n </div>\n <div id=\"apollo-error-details\" className={style['error-details']}>\n {isGraphQLError && 'locations' in error && error.locations && (\n <pre className=\"locations\">\n <strong>Locations:</strong>\n {' '}\n {JSON.stringify(error.locations, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'path' in error && error.path && (\n <pre className=\"path\">\n <strong>Path:</strong>\n {' '}\n {JSON.stringify(error.path, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'extensions' in error && error.extensions && (\n <pre className=\"extensions\">\n <strong>Extensions:</strong>\n {' '}\n {JSON.stringify(error.extensions, null, 4)}\n </pre>\n )}\n {!isGraphQLError && (\n <pre className=\"error-details\">\n <strong>Error Details:</strong>\n {' '}\n {validate.isEmpty(error) ? errorMessage : JSON.stringify(error, null, 4)}\n </pre>\n )}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AAQA,IAAM,IAAsB;AAiB5B,SAAgB,IAAuB;CAEnC,IAAM,EAAE,UAAO,iBADC,EAAI,EAAmB,IACC,EAAE,EACpC,IAAY,EAAuB,KAAK,EACxC,IAAmB,EAA2B,KAAK;AAmBzD,CAjBA,QAAgB;AACZ,MAAI,CAAC,KAAS,CAAC,EACX;EAEJ,IAAM,KAAiB,MAAyB;AAC5C,GAAI,EAAM,QAAQ,YACd,GAAW;;AAMnB,SAFA,OAAO,iBAAiB,WAAW,EAAc,QAEpC;AACT,UAAO,oBAAoB,WAAW,EAAc;;IAEzD,CAAC,GAAO,EAAU,CAAC,EAEtB,QAAgB;AACZ,EAAI,KAAS,EAAU,WACnB,EAAiB,UAAU,SAAS,eACpC,EAAU,QAAQ,OAAO,IAEpB,CAAC,KAAS,EAAiB,YAChC,EAAiB,QAAQ,OAAO,EAChC,EAAiB,UAAU;IAEhC,CAAC,EAAM,CAAC;CAEX,IAAM,KAAmB,MAA+C;AACpE,MAAI,EAAM,QAAQ,SAAS,CAAC,EAAU,QAClC;EAEJ,IAAM,IAAoB,CAAC,GAAG,EAAU,QAAQ,iBAA8B,EAAoB,CAAC,CAAC,QAAO,MAAM,CAAC,EAAG,aAAa,WAAW,CAAC;AAE9I,MAAI,EAAkB,WAAW,EAC7B;EAEJ,IAAM,IAAe,EAAkB,IACjC,IAAc,EAAkB,GAAG,GAAG;AAExC,GAAC,KAAgB,CAAC,MAGlB,EAAM,
|
|
1
|
+
{"version":3,"file":"apollo-error.component.js","names":[],"sources":["../../../src/react/apollo-error/apollo-error.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport { use, useEffect, useRef } from 'react';\n\nimport { validate } from '#util/validate/validate.util.js';\n\nimport { ApolloErrorContext } from './apollo-error.context.js';\nimport style from './apollo-error.module.scss';\n\nconst FOCUSABLE_SELECTORS = 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Apollo Error Component that displays detailed error information in a modal.\n * This component provides a comprehensive error display interface that shows\n * GraphQL errors and other error types with detailed information for debugging purposes.\n *\n * Features:\n * - Modal overlay with backdrop for focus\n * - Detailed error categorization and display\n * - Reload functionality for error recovery\n * - Close button to dismiss the error modal\n * - Structured display of different error types\n * - Extra information display for debugging\n *\n * @returns A modal component displaying Apollo error details, or null if no error is present.\n */\nexport function ApolloErrorComponent() {\n const context = use(ApolloErrorContext);\n const { error, hideError } = context ?? {};\n const dialogRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!error || !hideError)\n return;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n hideError();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n };\n }, [error, hideError]);\n\n useEffect(() => {\n if (error && dialogRef.current) {\n previousFocusRef.current = document.activeElement as HTMLElement;\n dialogRef.current.focus();\n }\n else if (!error && previousFocusRef.current) {\n previousFocusRef.current.focus();\n previousFocusRef.current = null;\n }\n }, [error]);\n\n const handleFocusTrap = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Tab' || !dialogRef.current)\n return;\n\n const focusableElements = [...dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS)].filter(el => !el.hasAttribute('disabled'));\n\n if (focusableElements.length === 0)\n return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements.at(-1);\n\n if (!firstElement || !lastElement)\n return;\n\n if (event.shiftKey) {\n if (document.activeElement === firstElement || document.activeElement === dialogRef.current) {\n event.preventDefault();\n lastElement.focus();\n }\n }\n else if (document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n };\n\n if (!error) {\n return null;\n }\n\n const isGraphQLError = 'locations' in error || 'path' in error || 'extensions' in error;\n const errorMessage = 'message' in error ? error.message : 'Unknown error occurred';\n\n return (\n <div className={style['modal-backdrop']} onClick={hideError}>\n <div\n ref={dialogRef}\n className={style['modal-content']}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"apollo-error-title\"\n aria-describedby=\"apollo-error-details\"\n tabIndex={-1}\n onKeyDown={handleFocusTrap}\n onClick={e => e.stopPropagation()}\n >\n <button\n type=\"button\"\n className={style['btn-close']}\n onClick={hideError}\n aria-label=\"Close error details (Esc)\"\n aria-keyshortcuts=\"Escape\"\n title=\"Close error details (Esc)\"\n >\n ✕\n </button>\n <div className={style['error-title']}>\n <button\n type=\"button\"\n className={style['btn-retry']}\n onClick={() => window.location.reload()}\n aria-label=\"Reload page\"\n >\n Reload\n </button>\n {' '}\n <span id=\"apollo-error-title\">\n {errorMessage || 'Error details'}\n </span>\n </div>\n <div id=\"apollo-error-details\" className={style['error-details']}>\n {isGraphQLError && 'locations' in error && error.locations && (\n <pre className=\"locations\">\n <strong>Locations:</strong>\n {' '}\n {JSON.stringify(error.locations, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'path' in error && error.path && (\n <pre className=\"path\">\n <strong>Path:</strong>\n {' '}\n {JSON.stringify(error.path, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'extensions' in error && error.extensions && (\n <pre className=\"extensions\">\n <strong>Extensions:</strong>\n {' '}\n {JSON.stringify(error.extensions, null, 4)}\n </pre>\n )}\n {!isGraphQLError && (\n <pre className=\"error-details\">\n <strong>Error Details:</strong>\n {' '}\n {validate.isEmpty(error) ? errorMessage : JSON.stringify(error, null, 4)}\n </pre>\n )}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AAQA,IAAM,IAAsB;AAiB5B,SAAgB,IAAuB;CAEnC,IAAM,EAAE,UAAO,iBADC,EAAI,EAAmB,IACC,EAAE,EACpC,IAAY,EAAuB,KAAK,EACxC,IAAmB,EAA2B,KAAK;AAmBzD,CAjBA,QAAgB;AACZ,MAAI,CAAC,KAAS,CAAC,EACX;EAEJ,IAAM,KAAiB,MAAyB;AAC5C,GAAI,EAAM,QAAQ,YACd,GAAW;;AAMnB,SAFA,OAAO,iBAAiB,WAAW,EAAc,QAEpC;AACT,UAAO,oBAAoB,WAAW,EAAc;;IAEzD,CAAC,GAAO,EAAU,CAAC,EAEtB,QAAgB;AACZ,EAAI,KAAS,EAAU,WACnB,EAAiB,UAAU,SAAS,eACpC,EAAU,QAAQ,OAAO,IAEpB,CAAC,KAAS,EAAiB,YAChC,EAAiB,QAAQ,OAAO,EAChC,EAAiB,UAAU;IAEhC,CAAC,EAAM,CAAC;CAEX,IAAM,KAAmB,MAA+C;AACpE,MAAI,EAAM,QAAQ,SAAS,CAAC,EAAU,QAClC;EAEJ,IAAM,IAAoB,CAAC,GAAG,EAAU,QAAQ,iBAA8B,EAAoB,CAAC,CAAC,QAAO,MAAM,CAAC,EAAG,aAAa,WAAW,CAAC;AAE9I,MAAI,EAAkB,WAAW,EAC7B;EAEJ,IAAM,IAAe,EAAkB,IACjC,IAAc,EAAkB,GAAG,GAAG;AAExC,GAAC,KAAgB,CAAC,MAGlB,EAAM,YACF,SAAS,kBAAkB,KAAgB,SAAS,kBAAkB,EAAU,aAChF,EAAM,gBAAgB,EACtB,EAAY,OAAO,IAGlB,SAAS,kBAAkB,MAChC,EAAM,gBAAgB,EACtB,EAAa,OAAO;;AAI5B,KAAI,CAAC,EACD,QAAO;CAGX,IAAM,IAAiB,eAAe,KAAS,UAAU,KAAS,gBAAgB,GAC5E,IAAe,aAAa,IAAQ,EAAM,UAAU;AAE1D,QACI,kBAAA,cAAC,OAAD;EAAK,WAAW,EAAM;EAAmB,SAAS;EAmE5C,EAlEF,kBAAA,cAAC,OAAD;EACI,KAAK;EACL,WAAW,EAAM;EACjB,MAAK;EACL,cAAW;EACX,mBAAgB;EAChB,oBAAiB;EACjB,UAAU;EACV,WAAW;EACX,UAAS,MAAK,EAAE,iBAAiB;EAwD/B,EAtDF,kBAAA,cAAC,UAAD;EACI,MAAK;EACL,WAAW,EAAM;EACjB,SAAS;EACT,cAAW;EACX,qBAAkB;EAClB,OAAM;EAGD,EAFR,IAEQ,EACT,kBAAA,cAAC,OAAD,EAAK,WAAW,EAAM,gBAahB,EAZF,kBAAA,cAAC,UAAD;EACI,MAAK;EACL,WAAW,EAAM;EACjB,eAAe,OAAO,SAAS,QAAQ;EACvC,cAAW;EAGN,EAFR,SAEQ,EACR,KACD,kBAAA,cAAC,QAAD,EAAM,IAAG,sBAEF,EADF,KAAgB,gBACd,CACL,EACN,kBAAA,cAAC,OAAD;EAAK,IAAG;EAAuB,WAAW,EAAM;EA6B1C,EA5BD,KAAkB,eAAe,KAAS,EAAM,aAC7C,kBAAA,cAAC,OAAD,EAAK,WAAU,aAIT,EAHF,kBAAA,cAAC,UAAA,MAAO,aAAmB,EAC1B,KACA,KAAK,UAAU,EAAM,WAAW,MAAM,EAAE,CACvC,EAET,KAAkB,UAAU,KAAS,EAAM,QACxC,kBAAA,cAAC,OAAD,EAAK,WAAU,QAIT,EAHF,kBAAA,cAAC,UAAA,MAAO,QAAc,EACrB,KACA,KAAK,UAAU,EAAM,MAAM,MAAM,EAAE,CAClC,EAET,KAAkB,gBAAgB,KAAS,EAAM,cAC9C,kBAAA,cAAC,OAAD,EAAK,WAAU,cAIT,EAHF,kBAAA,cAAC,UAAA,MAAO,cAAoB,EAC3B,KACA,KAAK,UAAU,EAAM,YAAY,MAAM,EAAE,CACxC,EAET,CAAC,KACE,kBAAA,cAAC,OAAD,EAAK,WAAU,iBAIT,EAHF,kBAAA,cAAC,UAAA,MAAO,iBAAuB,EAC9B,KACA,EAAS,QAAQ,EAAM,GAAG,IAAe,KAAK,UAAU,GAAO,MAAM,EAAE,CACtE,CAER,CACJ,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-error.util.js","names":[],"sources":["../../../src/react/apollo-error/apollo-error.util.tsx"],"sourcesContent":["import type { GraphQLError } from 'graphql';\n\n/**\n * Global callback function for displaying Apollo errors.\n * This variable holds the callback function that will be called when a global\n * Apollo error needs to be displayed. It is set by the ApolloErrorProvider\n * and used throughout the application for consistent error handling.\n *\n * @remarks\n * **SSR Warning:** These module-level singletons are shared across all requests
|
|
1
|
+
{"version":3,"file":"apollo-error.util.js","names":[],"sources":["../../../src/react/apollo-error/apollo-error.util.tsx"],"sourcesContent":["import type { GraphQLError } from 'graphql';\n\n/**\n * Global callback function for displaying Apollo errors.\n * This variable holds the callback function that will be called when a global\n * Apollo error needs to be displayed. It is set by the ApolloErrorProvider\n * and used throughout the application for consistent error handling.\n *\n * @remarks\n * **SSR Warning — Known Limitation:** These module-level singletons are shared\n * across all requests in SSR environments (e.g., Next.js). In server contexts,\n * Request A's error handler could be invoked for Request B's error, causing\n * intermittent wrong-user error display. This module is designed for **client-side\n * use only**. For SSR, ensure the provider is properly scoped per-request\n * or use a request-scoped error handling strategy.\n */\nlet showErrorCallback: ((err: GraphQLError | Error) => void) | null = null;\nlet hasCustomHandler = false;\n\n/**\n * Sets the global callback function for Apollo error handling.\n * This function registers a callback that will be called whenever a global\n * Apollo error needs to be displayed. The callback is typically set by the\n * ApolloErrorProvider component and used throughout the application for\n * consistent error handling.\n *\n * @param callback - The function to be called when a global Apollo error occurs.\n * @param isCustomHandler - Flag that identifies whether the handler was provided by the consumer.\n */\nexport function setGlobalApolloErrorCallback(\n callback: (err: GraphQLError | Error) => void,\n isCustomHandler = false,\n) {\n showErrorCallback = callback;\n hasCustomHandler = isCustomHandler;\n}\n\n/**\n * Clears the global callback function for Apollo error handling.\n * Useful when the ApolloErrorProvider unmounts to avoid stale references.\n */\nexport function clearGlobalApolloErrorCallback() {\n showErrorCallback = null;\n hasCustomHandler = false;\n}\n\n/**\n * Indicates whether a custom Apollo error handler is registered.\n *\n * @returns True if a custom handler is registered, otherwise false.\n */\nexport function hasCustomApolloErrorHandler() {\n return hasCustomHandler;\n}\n\n/**\n * Displays a global Apollo error using the registered callback.\n * This function triggers the global error display system by calling the\n * registered callback function. If no callback is registered, the function\n * does nothing, providing safe error handling even when the provider is not set up.\n *\n * @param error - The Apollo error to display globally.\n */\nexport function showGlobalApolloError(error: GraphQLError | Error) {\n showErrorCallback?.(error);\n}\n"],"mappings":";AAgBA,IAAI,IAAkE,MAClE,IAAmB;AAYvB,SAAgB,EACZ,GACA,IAAkB,IACpB;AAEE,CADA,IAAoB,GACpB,IAAmB;;AAOvB,SAAgB,IAAiC;AAE7C,CADA,IAAoB,MACpB,IAAmB;;AAQvB,SAAgB,IAA8B;AAC1C,QAAO;;AAWX,SAAgB,EAAsB,GAA6B;AAC/D,KAAoB,EAAM"}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './apollo-error.component.js';
|
|
2
|
+
export * from './apollo-error.context.js';
|
|
3
|
+
export * from './apollo-error.hook.js';
|
|
4
|
+
export * from './apollo-error.provider.js';
|
|
5
|
+
export * from './apollo-error.type.js';
|
|
6
|
+
export * from './apollo-error.util.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { i18n as I18nInstance } from 'i18next';
|
|
2
|
+
export interface I_GetTranslationsI18nextOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Optional i18n instance. If not provided, it falls back to the global i18next instance.
|
|
5
|
+
*/
|
|
6
|
+
i18n?: I18nInstance;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the i18next translation function outside of React components.
|
|
10
|
+
* This provides access to translation functions for use in server components,
|
|
11
|
+
* non-React environments, or normal JS functions.
|
|
12
|
+
*
|
|
13
|
+
* @param namespace - Optional namespace to load translations from.
|
|
14
|
+
* @param options - Options object allowing injection of a specific i18n instance.
|
|
15
|
+
* @returns The translation function (`t`) bound to the specified namespace and instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getTranslationsI18next(namespace?: string | null, options?: I_GetTranslationsI18nextOptions): import('i18next').TFunction<string, undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18next.server.js","names":[],"sources":["../../../src/react/i18next/i18next.server.ts"],"sourcesContent":["import type { i18n as I18nInstance } from 'i18next';\n\nimport globalI18nextInstance from 'i18next';\n\nexport interface I_GetTranslationsI18nextOptions {\n /**\n * Optional i18n instance. If not provided, it falls back to the global i18next instance.\n */\n i18n?: I18nInstance;\n}\n\n/**\n * Retrieves the i18next translation function outside of React components.\n * This provides access to translation functions for use in server components,\n * non-React environments, or normal JS functions.\n *\n * @param namespace - Optional namespace to load translations from.\n * @param options - Options object allowing injection of a specific i18n instance.\n * @returns The translation function (`t`) bound to the specified namespace and instance.\n */\nexport function getTranslationsI18next(\n namespace?: string | null,\n options?: I_GetTranslationsI18nextOptions,\n) {\n const instance = options?.i18n || globalI18nextInstance;\n\n // We bind using getFixedT to ensure the namespace is locked to this t function\n return instance.getFixedT(null, namespace ?? null);\n}\n"],"mappings":";;AAoBA,SAAgB,EACZ,GACA,GACF;AAIE,SAHiB,GAAS,QAAQ,GAGlB,UAAU,MAAM,KAAa,KAAK"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './i18next.hook.js';
|
|
2
|
+
export * from './i18next.util.js';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './log.type.js';
|
|
2
|
+
export * from './log.util.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { I_CatchErrorOptions } from '../../util/log/index.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
import { I_Children } from '
|
|
2
|
+
import { I_Children } from '../../typescript/index.js';
|
|
3
3
|
import { I_NextIntlLanguage, T_NextIntlMessageList } from './next-intl.type.js';
|
|
4
|
-
import * as React from 'react';
|
|
5
4
|
/**
|
|
6
5
|
* Higher-Order Component (HOC) that wraps components with Next.js internationalization support.
|
|
7
6
|
* This HOC provides internationalization capabilities to React components by wrapping them
|
|
@@ -18,10 +17,7 @@ import * as React from 'react';
|
|
|
18
17
|
* @param Component - The React component to wrap with internationalization support.
|
|
19
18
|
* @returns A new component with internationalization capabilities and additional props for languages and messages.
|
|
20
19
|
*/
|
|
21
|
-
export declare function withNextIntl<T extends I_Children>(Component: ComponentType<T>): {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}): React.JSX.Element | null;
|
|
26
|
-
displayName: string;
|
|
27
|
-
};
|
|
20
|
+
export declare function withNextIntl<T extends I_Children>(Component: ComponentType<T>): ComponentType<T & {
|
|
21
|
+
languages: I_NextIntlLanguage[];
|
|
22
|
+
messages: T_NextIntlMessageList;
|
|
23
|
+
}>;
|
|
@@ -5,17 +5,21 @@ import * as r from "react";
|
|
|
5
5
|
import { NextIntlClientProvider as i } from "next-intl";
|
|
6
6
|
//#region src/react/next-intl/next-intl.hoc.tsx
|
|
7
7
|
function a(a) {
|
|
8
|
-
let o = (o) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
let { currentLanguage: o } = n(), { messages: s, languages: c, TargetComponent: l } = a, u = s[o?.value || "en"], d = c.find((e) => e.value === o?.value)?.timezone ?? t.timezone;
|
|
9
|
+
return s ? /* @__PURE__ */ r.createElement(i, {
|
|
10
|
+
locale: o?.value || "en",
|
|
11
|
+
messages: u || null,
|
|
12
|
+
timeZone: d
|
|
13
|
+
}, /* @__PURE__ */ r.createElement(l, a)) : (e.warn(`Missing messages for language: ${o?.value || "en"}`), null);
|
|
14
|
+
}
|
|
15
|
+
function o(e) {
|
|
16
|
+
let t = (t) => /* @__PURE__ */ r.createElement(a, {
|
|
17
|
+
...t,
|
|
18
|
+
TargetComponent: e
|
|
19
|
+
});
|
|
20
|
+
return t.displayName = `withNextIntl(${e.displayName || e.name || "Component"})`, t;
|
|
17
21
|
}
|
|
18
22
|
//#endregion
|
|
19
|
-
export {
|
|
23
|
+
export { o as withNextIntl };
|
|
20
24
|
|
|
21
25
|
//# sourceMappingURL=next-intl.hoc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.hoc.js","names":[],"sources":["../../../src/react/next-intl/next-intl.hoc.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\nimport { NextIntlClientProvider } from 'next-intl';\nimport * as React from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, T_NextIntlMessageList } from './next-intl.type.js';\n\nimport { log } from '../log/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { useNextIntl } from './next-intl.hook.js';\n\n/**\n * Higher-Order Component (HOC) that wraps components with Next.js internationalization support.\n * This HOC provides internationalization capabilities to React components by wrapping them\n * with the NextIntlClientProvider. It automatically handles language detection, message\n * loading, and timezone configuration based on the current language settings.\n *\n * Features:\n * - Automatic language detection and message loading\n * - Timezone configuration based on language settings\n * - Fallback to default language when messages are missing\n * - Warning logging for missing message configurations\n * - Proper display name preservation for debugging\n *\n * @param Component - The React component to wrap with internationalization support.\n * @returns A new component with internationalization capabilities and additional props for languages and messages.\n */\nexport function withNextIntl<T extends I_Children>(Component: ComponentType<T>) {\n const
|
|
1
|
+
{"version":3,"file":"next-intl.hoc.js","names":[],"sources":["../../../src/react/next-intl/next-intl.hoc.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\nimport { NextIntlClientProvider } from 'next-intl';\nimport * as React from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, T_NextIntlMessageList } from './next-intl.type.js';\n\nimport { log } from '../log/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { useNextIntl } from './next-intl.hook.js';\n\n/**\n * Internal component wrapper for the HOC\n */\n// eslint-disable-next-line react-refresh/only-export-components -- HOC is an allowed export\nfunction PageWithI18nInternal<T extends I_Children>(\n props: T & { languages: I_NextIntlLanguage[]; messages: T_NextIntlMessageList; TargetComponent: ComponentType<T> },\n) {\n const { currentLanguage } = useNextIntl();\n const { messages, languages, TargetComponent } = props;\n const defaultLang = 'en';\n\n const defaultMessages = messages[currentLanguage?.value || defaultLang];\n const timeZone = languages.find(lang => lang.value === currentLanguage?.value)?.timezone ?? NEXT_INTL_DEFAULT_LANGUAGE.timezone;\n\n if (!messages) {\n log.warn(`Missing messages for language: ${currentLanguage?.value || defaultLang}`);\n return null;\n }\n\n return (\n <NextIntlClientProvider\n locale={currentLanguage?.value || defaultLang}\n messages={defaultMessages || null}\n timeZone={timeZone}\n >\n <TargetComponent {...(props as T)} />\n </NextIntlClientProvider>\n );\n}\n\n/**\n * Higher-Order Component (HOC) that wraps components with Next.js internationalization support.\n * This HOC provides internationalization capabilities to React components by wrapping them\n * with the NextIntlClientProvider. It automatically handles language detection, message\n * loading, and timezone configuration based on the current language settings.\n *\n * Features:\n * - Automatic language detection and message loading\n * - Timezone configuration based on language settings\n * - Fallback to default language when messages are missing\n * - Warning logging for missing message configurations\n * - Proper display name preservation for debugging\n *\n * @param Component - The React component to wrap with internationalization support.\n * @returns A new component with internationalization capabilities and additional props for languages and messages.\n */\nexport function withNextIntl<T extends I_Children>(Component: ComponentType<T>) {\n const hoc = (props: T & { languages: I_NextIntlLanguage[]; messages: T_NextIntlMessageList }) => {\n return <PageWithI18nInternal {...props} TargetComponent={Component} />;\n };\n\n hoc.displayName = `withNextIntl(${Component.displayName || Component.name || 'Component'})`;\n\n return hoc as unknown as ComponentType<T & { languages: I_NextIntlLanguage[]; messages: T_NextIntlMessageList }>;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,EACL,GACF;CACE,IAAM,EAAE,uBAAoB,GAAa,EACnC,EAAE,aAAU,cAAW,uBAAoB,GAG3C,IAAkB,EAAS,GAAiB,SAAS,OACrD,IAAW,EAAU,MAAK,MAAQ,EAAK,UAAU,GAAiB,MAAM,EAAE,YAAY,EAA2B;AAOvH,QALK,IAMD,kBAAA,cAAC,GAAD;EACI,QAAQ,GAAiB,SAAS;EAClC,UAAU,KAAmB;EACnB;EAGW,EADrB,kBAAA,cAAC,GAAqB,EAAe,CAChB,IAXzB,EAAI,KAAK,kCAAkC,GAAiB,SAAS,OAAc,EAC5E;;AA8Bf,SAAgB,EAAmC,GAA6B;CAC5E,IAAM,KAAO,MACF,kBAAA,cAAC,GAAD;EAAsB,GAAI;EAAO,iBAAiB;EAAa,CAAA;AAK1E,QAFA,EAAI,cAAc,gBAAgB,EAAU,eAAe,EAAU,QAAQ,YAAY,IAElF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getTranslations } from 'next-intl/server';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the translation function from Next.js internationalization context on the server.
|
|
4
|
+
* This function wraps next-intl/server's getTranslations, returning a Promise that resolves
|
|
5
|
+
* to the translation function. It enables asynchronous translation resolution for server components
|
|
6
|
+
* and server actions.
|
|
7
|
+
*
|
|
8
|
+
* @returns A Promise that resolves to the getTranslations function.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getTranslationsNextIntl: typeof getTranslations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-intl.server.js","names":[],"sources":["../../../src/react/next-intl/next-intl.server.ts"],"sourcesContent":["import { getTranslations } from 'next-intl/server';\n\n/**\n * Retrieves the translation function from Next.js internationalization context on the server.\n * This function wraps next-intl/server's getTranslations, returning a Promise that resolves\n * to the translation function. It enables asynchronous translation resolution for server components\n * and server actions.\n *\n * @returns A Promise that resolves to the getTranslations function.\n */\nexport const getTranslationsNextIntl: typeof getTranslations = getTranslations;\n"],"mappings":";;AAUA,IAAa,IAAkD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Locale } from 'date-fns';
|
|
2
2
|
import { AbstractIntlMessages, Timezone } from 'next-intl';
|
|
3
|
-
import { I_Children } from '
|
|
3
|
+
import { I_Children } from '../../typescript/index.js';
|
|
4
4
|
export interface I_NextIntlLanguage {
|
|
5
5
|
label: string;
|
|
6
6
|
value: string;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './storage.hook.js';
|
|
2
|
+
export * from './storage.util.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I_Serializer } from '
|
|
1
|
+
import { I_Serializer } from '../../util/serializer/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* React hook that provides persistent storage functionality with automatic serialization.
|
|
4
4
|
* This hook manages state that persists across browser sessions using localStorage,
|
|
@@ -21,9 +21,13 @@ export declare const storage: {
|
|
|
21
21
|
*
|
|
22
22
|
* @param key - The unique identifier for the value to store.
|
|
23
23
|
* @param value - The data to store (will be automatically serialized to JSON).
|
|
24
|
+
* @param options - Optional settings.
|
|
25
|
+
* @param options.ttlMs - The time-to-live in milliseconds.
|
|
24
26
|
* @returns A promise that resolves when the storage operation is complete.
|
|
25
27
|
*/
|
|
26
|
-
set<T = unknown>(key: string, value: T
|
|
28
|
+
set<T = unknown>(key: string, value: T, options?: {
|
|
29
|
+
ttlMs?: number;
|
|
30
|
+
}): Promise<void>;
|
|
27
31
|
/**
|
|
28
32
|
* Removes a value from browser storage by key.
|
|
29
33
|
* This method permanently deletes the stored data associated with the specified key.
|
|
@@ -41,4 +45,33 @@ export declare const storage: {
|
|
|
41
45
|
* @returns A promise that resolves to an array of storage keys.
|
|
42
46
|
*/
|
|
43
47
|
keys(): Promise<string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a key exists in browser storage.
|
|
50
|
+
* This method efficiently checks for key existence without deserializing the value.
|
|
51
|
+
* It also respects TTL — returns false if the key exists but has expired.
|
|
52
|
+
*
|
|
53
|
+
* @param key - The unique identifier to check.
|
|
54
|
+
* @returns A promise that resolves to true if the key exists and has not expired.
|
|
55
|
+
*/
|
|
56
|
+
has(key: string): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Clears all values from browser storage.
|
|
59
|
+
* This method permanently removes all stored data.
|
|
60
|
+
*
|
|
61
|
+
* @returns A promise that resolves when the clear operation is complete.
|
|
62
|
+
*/
|
|
63
|
+
clear(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves a value from browser storage, or creates and stores it if it doesn't exist.
|
|
66
|
+
* This method combines check, creation, and storage into a single convenient operation.
|
|
67
|
+
*
|
|
68
|
+
* @param key - The unique identifier for the value.
|
|
69
|
+
* @param factory - A function (sync or async) that generates the value if it's missing or expired.
|
|
70
|
+
* @param options - Optional storage options.
|
|
71
|
+
* @param options.ttlMs - The time-to-live in milliseconds.
|
|
72
|
+
* @returns A promise that resolves to the retrieved or newly created value.
|
|
73
|
+
*/
|
|
74
|
+
getOrSet<T = unknown>(key: string, factory: () => T | Promise<T>, options?: {
|
|
75
|
+
ttlMs?: number;
|
|
76
|
+
}): Promise<T>;
|
|
44
77
|
};
|