@cyberskill/shared 3.2.0 → 3.3.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.js +8 -9
- package/dist/config/commitlint/index.js.map +1 -1
- package/dist/config/config.type.js +8 -5
- package/dist/config/config.type.js.map +1 -1
- package/dist/config/config.util.js +33 -42
- package/dist/config/config.util.js.map +1 -1
- package/dist/config/env/env.constant.js +6 -5
- package/dist/config/env/env.constant.js.map +1 -1
- package/dist/config/env/env.util.js +26 -27
- package/dist/config/env/env.util.js.map +1 -1
- package/dist/config/env/index.js +2 -7
- package/dist/config/eslint/index.js +23 -19
- package/dist/config/eslint/index.js.map +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +30 -38
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -1
- package/dist/config/graphql-codegen/index.js +2 -5
- package/dist/config/index.js +3 -7
- package/dist/config/lint-staged/index.js +8 -7
- package/dist/config/lint-staged/index.js.map +1 -1
- package/dist/config/storybook/index.js +2 -6
- package/dist/config/storybook/storybook.main.js +19 -18
- package/dist/config/storybook/storybook.main.js.map +1 -1
- package/dist/config/storybook/storybook.preview.js +31 -37
- package/dist/config/storybook/storybook.preview.js.map +1 -1
- package/dist/config/vitest/index.js +3 -7
- package/dist/config/vitest/vitest.e2e.js +14 -17
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.js +31 -32
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/constant/common.js +6 -5
- package/dist/constant/common.js.map +1 -1
- package/dist/constant/index.js +3 -7
- package/dist/constant/response-status.d.ts +186 -186
- package/dist/constant/response-status.js +254 -253
- package/dist/constant/response-status.js.map +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +27 -29
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
- package/dist/node/apollo-server/index.js +2 -7
- package/dist/node/cli/index.js +112 -113
- package/dist/node/cli/index.js.map +1 -1
- package/dist/node/command/command.type.js +8 -5
- package/dist/node/command/command.type.js.map +1 -1
- package/dist/node/command/command.util.js +136 -149
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/command/index.js +3 -12
- package/dist/node/express/express.type.d.ts +11 -0
- package/dist/node/express/express.type.js +2 -0
- package/dist/node/express/express.util.js +74 -65
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/express/index.js +3 -14
- package/dist/node/fs/fs.util.js +27 -51
- package/dist/node/fs/fs.util.js.map +1 -1
- package/dist/node/fs/index.js +2 -19
- package/dist/node/log/index.js +2 -8
- package/dist/node/log/log.type.js +8 -5
- package/dist/node/log/log.type.js.map +1 -1
- package/dist/node/log/log.util.js +51 -68
- package/dist/node/log/log.util.js.map +1 -1
- package/dist/node/mongo/index.js +8 -26
- package/dist/node/mongo/mongo.constant.js +6 -6
- package/dist/node/mongo/mongo.constant.js.map +1 -1
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +6 -1
- package/dist/node/mongo/mongo.controller.mongoose.js +333 -467
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/node/mongo/mongo.controller.native.js +153 -212
- package/dist/node/mongo/mongo.controller.native.js.map +1 -1
- package/dist/node/mongo/mongo.dynamic-populate.js +164 -192
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
- package/dist/node/mongo/mongo.populate.js +229 -262
- package/dist/node/mongo/mongo.populate.js.map +1 -1
- package/dist/node/mongo/mongo.type.js +8 -17
- package/dist/node/mongo/mongo.type.js.map +1 -1
- package/dist/node/mongo/mongo.util.js +134 -293
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/package/index.js +3 -11
- package/dist/node/package/package.type.js +8 -5
- package/dist/node/package/package.type.js.map +1 -1
- package/dist/node/package/package.util.js +216 -225
- package/dist/node/package/package.util.js.map +1 -1
- package/dist/node/path/index.js +3 -58
- package/dist/node/path/path.constant.js +211 -298
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/path/path.util.js +13 -16
- package/dist/node/path/path.util.js.map +1 -1
- package/dist/node/storage/index.js +3 -10
- package/dist/node/storage/storage.constant.js +6 -8
- package/dist/node/storage/storage.constant.js.map +1 -1
- package/dist/node/storage/storage.util.js +127 -178
- package/dist/node/storage/storage.util.js.map +1 -1
- package/dist/node/upload/index.js +4 -16
- package/dist/node/upload/upload.constant.js +58 -32
- package/dist/node/upload/upload.constant.js.map +1 -1
- package/dist/node/upload/upload.type.js +8 -5
- package/dist/node/upload/upload.type.js.map +1 -1
- package/dist/node/upload/upload.util.js +125 -137
- package/dist/node/upload/upload.util.js.map +1 -1
- package/dist/node/ws/index.js +2 -6
- package/dist/node/ws/ws.type.d.ts +7 -8
- package/dist/node/ws/ws.util.js +46 -44
- package/dist/node/ws/ws.util.js.map +1 -1
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js +8 -0
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +16 -18
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.constant.js +6 -5
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.context.js +10 -13
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.module.scss.js +8 -7
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +57 -75
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-client/index.js +7 -30
- package/dist/react/apollo-client/links/index.js +2 -5
- package/dist/react/apollo-client/links/upload.js +63 -107
- package/dist/react/apollo-client/links/upload.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +14 -16
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +8 -7
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +14 -14
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -1
- package/dist/react/apollo-client-nextjs/index.js +3 -7
- package/dist/react/apollo-error/apollo-error.component.js +57 -69
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.context.js +7 -6
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.hook.js +10 -10
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +15 -11
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.provider.js +31 -25
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +14 -16
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
- package/dist/react/apollo-error/index.js +5 -15
- package/dist/react/i18next/i18next.hook.js +7 -6
- package/dist/react/i18next/i18next.hook.js.map +1 -1
- package/dist/react/i18next/i18next.util.js +9 -8
- package/dist/react/i18next/i18next.util.js.map +1 -1
- package/dist/react/i18next/index.js +3 -7
- package/dist/react/loading/index.js +3 -9
- package/dist/react/loading/loading.component.js +47 -48
- package/dist/react/loading/loading.component.js.map +1 -1
- package/dist/react/loading/loading.context.js +7 -6
- package/dist/react/loading/loading.context.js.map +1 -1
- package/dist/react/loading/loading.hook.js +11 -11
- package/dist/react/loading/loading.hook.js.map +1 -1
- package/dist/react/loading/loading.module.scss.js +18 -15
- package/dist/react/loading/loading.module.scss.js.map +1 -1
- package/dist/react/loading/loading.provider.js +26 -18
- package/dist/react/loading/loading.provider.js.map +1 -1
- package/dist/react/log/index.js +2 -6
- package/dist/react/log/log.util.d.ts +8 -0
- package/dist/react/log/log.util.js +33 -29
- package/dist/react/log/log.util.js.map +1 -1
- package/dist/react/next-intl/index.js +6 -14
- package/dist/react/next-intl/next-intl.constant.js +16 -15
- package/dist/react/next-intl/next-intl.constant.js.map +1 -1
- package/dist/react/next-intl/next-intl.context.js +7 -6
- package/dist/react/next-intl/next-intl.context.js.map +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +20 -23
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
- package/dist/react/next-intl/next-intl.hook.js +13 -14
- package/dist/react/next-intl/next-intl.hook.js.map +1 -1
- package/dist/react/next-intl/next-intl.provider.js +28 -23
- package/dist/react/next-intl/next-intl.provider.js.map +1 -1
- package/dist/react/storage/index.js +3 -7
- package/dist/react/storage/storage.hook.js +61 -58
- package/dist/react/storage/storage.hook.js.map +1 -1
- package/dist/react/storage/storage.util.js +36 -68
- package/dist/react/storage/storage.util.js.map +1 -1
- package/dist/react/toast/index.js +2 -6
- package/dist/react/userback/index.js +2 -5
- package/dist/react/userback/userback.component.js +27 -27
- package/dist/react/userback/userback.component.js.map +1 -1
- package/dist/style.css +2 -1
- package/dist/typescript/common.type.js +8 -5
- package/dist/typescript/common.type.js.map +1 -1
- package/dist/typescript/index.js +2 -5
- package/dist/util/common/common.util.js +119 -48
- package/dist/util/common/common.util.js.map +1 -1
- package/dist/util/common/index.js +2 -9
- package/dist/util/index.js +6 -27
- package/dist/util/object/index.d.ts +3 -0
- package/dist/util/object/index.js +2 -10
- package/dist/util/object/object.util.js +94 -128
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/index.js +2 -5
- package/dist/util/serializer/serializer.util.js +73 -78
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/string/index.d.ts +3 -0
- package/dist/util/string/index.js +2 -10
- package/dist/util/string/string.util.js +59 -71
- package/dist/util/string/string.util.js.map +1 -1
- package/dist/util/validate/index.d.ts +3 -0
- package/dist/util/validate/index.js +2 -5
- package/dist/util/validate/validate.util.js +13 -39
- package/dist/util/validate/validate.util.js.map +1 -1
- package/package.json +29 -27
- package/dist/config/env/index.js.map +0 -1
- package/dist/config/graphql-codegen/index.js.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/storybook/index.js.map +0 -1
- package/dist/config/vitest/index.js.map +0 -1
- package/dist/constant/index.js.map +0 -1
- package/dist/node/apollo-server/index.js.map +0 -1
- package/dist/node/command/index.js.map +0 -1
- package/dist/node/express/index.js.map +0 -1
- package/dist/node/fs/index.js.map +0 -1
- package/dist/node/log/index.js.map +0 -1
- package/dist/node/mongo/index.js.map +0 -1
- package/dist/node/package/index.js.map +0 -1
- package/dist/node/path/index.js.map +0 -1
- package/dist/node/storage/index.js.map +0 -1
- package/dist/node/upload/index.js.map +0 -1
- package/dist/node/ws/index.js.map +0 -1
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js +0 -7
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +0 -1
- package/dist/react/apollo-client/index.js.map +0 -1
- package/dist/react/apollo-client/links/index.js.map +0 -1
- package/dist/react/apollo-client-nextjs/index.js.map +0 -1
- package/dist/react/apollo-error/index.js.map +0 -1
- package/dist/react/i18next/index.js.map +0 -1
- package/dist/react/loading/index.js.map +0 -1
- package/dist/react/log/index.js.map +0 -1
- package/dist/react/next-intl/index.js.map +0 -1
- package/dist/react/storage/index.js.map +0 -1
- package/dist/react/toast/index.js.map +0 -1
- package/dist/react/userback/index.js.map +0 -1
- package/dist/typescript/index.js.map +0 -1
- package/dist/util/common/index.js.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/object/index.js.map +0 -1
- package/dist/util/serializer/index.js.map +0 -1
- package/dist/util/string/index.js.map +0 -1
- package/dist/util/validate/index.js.map +0 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { createContext as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) {
|
|
8
|
-
return /* @__PURE__ */ o.createElement(l, { value: t }, e);
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { createContext as t } from "react";
|
|
3
|
+
//#region src/react/apollo-client/apollo-client.context.tsx
|
|
4
|
+
var n = t(null);
|
|
5
|
+
function r({ client: t, children: r }) {
|
|
6
|
+
return /* @__PURE__ */ e.createElement(n, { value: t }, r);
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=apollo-client.context.js.map
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as ApolloClientContext, r as ApolloClientProvider };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=apollo-client.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.context.js","sources":["../../../src/react/apollo-client/apollo-client.context.tsx"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\n\nimport * as React from 'react';\nimport { createContext } from 'react';\n\n/**\n * React context for providing Apollo Client instance to child components.\n * This context allows components to access the Apollo Client instance without\n * prop drilling, enabling direct access to client methods and cache operations.\n */\nconst ApolloClientContext = createContext<ApolloClient | null>(null);\n\n/**\n * Provider component that makes Apollo Client available to the component tree.\n * This component wraps the Apollo Client instance in a React context, allowing\n * any child component to access the client using the useApolloClient hook.\n *\n * @param props - Component props containing client and children.\n * @param props.client - The Apollo Client instance to provide to the component tree.\n * @param props.children - React children that will have access to the Apollo Client context.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloClientProvider({\n client,\n children,\n}: {\n client: ApolloClient;\n children: React.ReactNode;\n}) {\n return (\n <ApolloClientContext value={client}>\n {children}\n </ApolloClientContext>\n );\n}\n\nexport { ApolloClientContext };\n"],"
|
|
1
|
+
{"version":3,"file":"apollo-client.context.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.context.tsx"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\n\nimport * as React from 'react';\nimport { createContext } from 'react';\n\n/**\n * React context for providing Apollo Client instance to child components.\n * This context allows components to access the Apollo Client instance without\n * prop drilling, enabling direct access to client methods and cache operations.\n */\nconst ApolloClientContext = createContext<ApolloClient | null>(null);\n\n/**\n * Provider component that makes Apollo Client available to the component tree.\n * This component wraps the Apollo Client instance in a React context, allowing\n * any child component to access the client using the useApolloClient hook.\n *\n * @param props - Component props containing client and children.\n * @param props.client - The Apollo Client instance to provide to the component tree.\n * @param props.children - React children that will have access to the Apollo Client context.\n * @returns A React component that provides Apollo Client context to its children.\n */\nexport function ApolloClientProvider({\n client,\n children,\n}: {\n client: ApolloClient;\n children: React.ReactNode;\n}) {\n return (\n <ApolloClientContext value={client}>\n {children}\n </ApolloClientContext>\n );\n}\n\nexport { ApolloClientContext };\n"],"mappings":";;;AAUA,IAAM,IAAsB,EAAmC,KAAK;AAYpE,SAAgB,EAAqB,EACjC,WACA,eAID;AACC,QACI,kBAAA,cAAC,GAAD,EAAqB,OAAO,GAEN,EADjB,EACiB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/react/apollo-client/apollo-client.module.scss
|
|
2
|
+
var e = {
|
|
3
|
+
"error-container": "_error-container_wq4ix_1",
|
|
4
|
+
"error-details-button": "_error-details-button_wq4ix_8"
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=apollo-client.module.scss.js.map
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=apollo-client.module.scss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.module.scss.js","
|
|
1
|
+
{"version":3,"file":"apollo-client.module.scss.js","names":[],"sources":["../../../src/react/apollo-client/apollo-client.module.scss"],"sourcesContent":[".error-container {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n}\n\n.error-details-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 0.5rem 1rem;\n background-color: #ef4444;\n color: white;\n border: 2px solid #dc2626;\n border-radius: 0.5rem;\n font-size: 0.875rem;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease-in-out;\n\n &:hover {\n background-color: #dc2626;\n border-color: #b91c1c;\n transform: translateY(-1px);\n box-shadow:\n 0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n }\n\n &:active {\n transform: translateY(0);\n box-shadow:\n 0 1px 3px 0 rgba(0, 0, 0, 0.1),\n 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n }\n\n &:focus-visible {\n outline: 2px solid #fca5a5;\n outline-offset: 2px;\n }\n}\n"],"mappings":""}
|
|
@@ -1,78 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"button",
|
|
34
|
-
{
|
|
35
|
-
type: "button",
|
|
36
|
-
className: f["error-details-button"],
|
|
37
|
-
onClick: () => {
|
|
38
|
-
u(o), L.dismiss(r.id);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"Error Details"
|
|
42
|
-
))));
|
|
1
|
+
import { toast as e } from "../toast/index.js";
|
|
2
|
+
import { log as t } from "../log/log.util.js";
|
|
3
|
+
import { hasCustomApolloErrorHandler as n, showGlobalApolloError as r } from "../apollo-error/apollo-error.util.js";
|
|
4
|
+
import { GRAPHQL_URI_DEFAULT as i } from "./apollo-client.constant.js";
|
|
5
|
+
import a from "./apollo-client.module.scss.js";
|
|
6
|
+
import { createUploadLink as o } from "./links/upload.js";
|
|
7
|
+
import * as s from "react";
|
|
8
|
+
import { ApolloLink as c } from "@apollo/client/link";
|
|
9
|
+
import { ApolloClient as l, CombinedGraphQLErrors as u, CombinedProtocolErrors as d, InMemoryCache as f, ServerError as p } from "@apollo/client/core";
|
|
10
|
+
import { ErrorLink as m } from "@apollo/client/link/error";
|
|
11
|
+
import { RemoveTypenameFromVariablesLink as h } from "@apollo/client/link/remove-typename";
|
|
12
|
+
import { GraphQLWsLink as g } from "@apollo/client/link/subscriptions";
|
|
13
|
+
import { OperationTypeNode as _ } from "graphql";
|
|
14
|
+
import { createClient as v } from "graphql-ws";
|
|
15
|
+
import { tap as y } from "rxjs";
|
|
16
|
+
//#region src/react/apollo-client/apollo-client.util.tsx
|
|
17
|
+
var b = new c((e, n) => (e.setContext({ start: performance.now() }), n(e).pipe(y(() => {
|
|
18
|
+
let n = Math.round(performance.now() - e.getContext().start);
|
|
19
|
+
t.info(`Operation ${e.operationName} took ${n}ms to complete`);
|
|
20
|
+
})))), x = new m(({ error: i, operation: o }) => {
|
|
21
|
+
let c = o?.operationName || "Unknown", l = "";
|
|
22
|
+
u.is(i) ? i.errors.forEach(({ message: e, locations: n, path: r }, i) => {
|
|
23
|
+
i === 0 && (l = e), t.error(`[GraphQL error] ${c}: ${e}, Location: ${JSON.stringify(n, null, 4)}, Path: ${r}`);
|
|
24
|
+
}) : d.is(i) ? i.errors.forEach(({ message: e, extensions: n }, r) => {
|
|
25
|
+
r === 0 && (l = e), t.error(`[Protocol error]: ${e}, Extensions: ${JSON.stringify(n, null, 4)}`);
|
|
26
|
+
}) : p.is(i) ? (l = i.message, t.error(`[Server error]: ${i.message}`)) : (l = i.message, t.error(`[Network error]: ${i.message}`)), i && l && typeof window < "u" && (n() ? r(i) : e.error((t) => /* @__PURE__ */ s.createElement("div", { className: a["error-container"] }, l, /* @__PURE__ */ s.createElement("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
className: a["error-details-button"],
|
|
29
|
+
onClick: () => {
|
|
30
|
+
r(i), e.dismiss(t.id);
|
|
31
|
+
}
|
|
32
|
+
}, "Error Details"))));
|
|
43
33
|
});
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
R,
|
|
60
|
-
S,
|
|
61
|
-
r,
|
|
62
|
-
...i ?? [],
|
|
63
|
-
a
|
|
64
|
-
];
|
|
34
|
+
function S(e) {
|
|
35
|
+
let { uri: n, wsUrl: r, customLinks: a } = e, s = new h();
|
|
36
|
+
n || t.warn(`[Apollo] No GraphQL URI provided — using "${i}" as default`);
|
|
37
|
+
let l = o({
|
|
38
|
+
uri: n ?? "/graphql",
|
|
39
|
+
credentials: "include",
|
|
40
|
+
headers: { "apollo-require-preflight": "true" }
|
|
41
|
+
}), u = r ? new g(v({ url: r })) : c.empty(), d = r ? c.split(({ operationType: e }) => e === _.SUBSCRIPTION, u, l) : l;
|
|
42
|
+
return [
|
|
43
|
+
b,
|
|
44
|
+
x,
|
|
45
|
+
s,
|
|
46
|
+
...a ?? [],
|
|
47
|
+
d
|
|
48
|
+
];
|
|
65
49
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
50
|
+
function C(e) {
|
|
51
|
+
return new l({
|
|
52
|
+
link: c.from(S(e)),
|
|
53
|
+
cache: new f(),
|
|
54
|
+
...e
|
|
55
|
+
});
|
|
73
56
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//# sourceMappingURL=apollo-client.util.js.map
|
|
57
|
+
//#endregion
|
|
58
|
+
export { S as createApolloLinks, C as getClient };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=apollo-client.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.util.js","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 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:
|
|
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 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 && typeof window !== 'undefined') {\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":";;;;;;;;;;;;;;;;AAmBA,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,OAAO,SAAW,QACvC,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,mBAAgB,GAE9B,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;EACA;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,31 +1,8 @@
|
|
|
1
|
+
import { GRAPHQL_URI_DEFAULT as e } from "./apollo-client.constant.js";
|
|
2
|
+
import { createUploadLink as t } from "./links/upload.js";
|
|
3
|
+
import { createApolloLinks as n, getClient as r } from "./apollo-client.util.js";
|
|
4
|
+
import { ApolloClientContext as i, ApolloClientProvider as a } from "./apollo-client.context.js";
|
|
1
5
|
import { ApolloProvider as o } from "./apollo-client.component.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { makeVar as f } from "@apollo/client/cache";
|
|
6
|
-
import { useApolloClient as y, useBackgroundQuery as Q, useFragment as d, useLazyQuery as A, useLoadableQuery as L, useMutation as c, useQuery as C, useQueryRefHandlers as R, useReactiveVar as g, useReadQuery as k, useSubscription as v, useSuspenseFragment as F, useSuspenseQuery as P } from "@apollo/client/react";
|
|
7
|
-
import { createUploadLink as U } from "./links/upload.js";
|
|
8
|
-
export {
|
|
9
|
-
l as ApolloClientContext,
|
|
10
|
-
a as ApolloClientProvider,
|
|
11
|
-
o as ApolloProvider,
|
|
12
|
-
t as GRAPHQL_URI_DEFAULT,
|
|
13
|
-
n as createApolloLinks,
|
|
14
|
-
U as createUploadLink,
|
|
15
|
-
i as getClient,
|
|
16
|
-
f as makeVar,
|
|
17
|
-
y as useApolloClient,
|
|
18
|
-
Q as useBackgroundQuery,
|
|
19
|
-
d as useFragment,
|
|
20
|
-
A as useLazyQuery,
|
|
21
|
-
L as useLoadableQuery,
|
|
22
|
-
c as useMutation,
|
|
23
|
-
C as useQuery,
|
|
24
|
-
R as useQueryRefHandlers,
|
|
25
|
-
g as useReactiveVar,
|
|
26
|
-
k as useReadQuery,
|
|
27
|
-
v as useSubscription,
|
|
28
|
-
F as useSuspenseFragment,
|
|
29
|
-
P as useSuspenseQuery
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=index.js.map
|
|
6
|
+
import { useApolloClient as s, useBackgroundQuery as c, useFragment as l, useLazyQuery as u, useLoadableQuery as d, useMutation as f, useQuery as p, useQueryRefHandlers as m, useReactiveVar as h, useReadQuery as g, useSubscription as _, useSuspenseFragment as v, useSuspenseQuery as y } from "@apollo/client/react";
|
|
7
|
+
import { makeVar as b } from "@apollo/client/cache";
|
|
8
|
+
export { i as ApolloClientContext, a as ApolloClientProvider, o as ApolloProvider, e as GRAPHQL_URI_DEFAULT, n as createApolloLinks, t as createUploadLink, r as getClient, b as makeVar, s as useApolloClient, c as useBackgroundQuery, l as useFragment, u as useLazyQuery, d as useLoadableQuery, f as useMutation, p as useQuery, m as useQueryRefHandlers, h as useReactiveVar, g as useReadQuery, _ as useSubscription, v as useSuspenseFragment, y as useSuspenseQuery };
|
|
@@ -1,109 +1,65 @@
|
|
|
1
|
-
import { ApolloLink as
|
|
2
|
-
import {
|
|
3
|
-
import { Observable as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const r = new AbortController(), i = r.signal;
|
|
10
|
-
return { controller: r, signal: i };
|
|
1
|
+
import { ApolloLink as e } from "@apollo/client/link";
|
|
2
|
+
import { defaultPrinter as t, fallbackHttpConfig as n, parseAndCheckHttpResponse as r, rewriteURIForGET as i, selectHttpOptionsAndBodyInternal as a, selectURI as o } from "@apollo/client/link/http";
|
|
3
|
+
import { Observable as s } from "@apollo/client/utilities";
|
|
4
|
+
import c from "extract-files/extractFiles.mjs";
|
|
5
|
+
import l from "extract-files/isExtractableFile.mjs";
|
|
6
|
+
//#region src/react/apollo-client/links/upload.tsx
|
|
7
|
+
function u(e, t, n) {
|
|
8
|
+
"name" in n ? e.append(t, n, n.name) : e.append(t, n);
|
|
11
9
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
10
|
+
function d({ uri: d = "/graphql", useGETForQueries: f, isExtractableFile: p = l, FormData: m, formDataAppendFile: h = u, print: g = t, fetch: _, fetchOptions: v, credentials: y, headers: b, includeExtensions: x } = {}) {
|
|
11
|
+
let S = {
|
|
12
|
+
http: { includeExtensions: x },
|
|
13
|
+
options: v,
|
|
14
|
+
credentials: y,
|
|
15
|
+
headers: b
|
|
16
|
+
};
|
|
17
|
+
return new e((e) => {
|
|
18
|
+
let t = e.getContext(), { clientAwareness: { name: l, version: u } = {}, headers: v } = t, { options: y, body: b } = a(e, g, n, S, {
|
|
19
|
+
http: t.http,
|
|
20
|
+
options: t.fetchOptions,
|
|
21
|
+
credentials: t.credentials,
|
|
22
|
+
headers: {
|
|
23
|
+
...l && { "apollographql-client-name": l },
|
|
24
|
+
...u && { "apollographql-client-version": u },
|
|
25
|
+
...v
|
|
26
|
+
}
|
|
27
|
+
}), { clone: x, files: C } = c(b, p, ""), w = o(e, d);
|
|
28
|
+
if (C.size) {
|
|
29
|
+
y.headers && delete y.headers["content-type"];
|
|
30
|
+
let e = new (m || FormData)();
|
|
31
|
+
e.append("operations", JSON.stringify(x));
|
|
32
|
+
let t = {}, n = 0;
|
|
33
|
+
C.forEach((e) => {
|
|
34
|
+
t[++n] = e;
|
|
35
|
+
}), e.append("map", JSON.stringify(t)), n = 0, C.forEach((t, r) => {
|
|
36
|
+
h(e, String(++n), r);
|
|
37
|
+
}), y.body = e;
|
|
38
|
+
} else if (f && !e.query.definitions.some((e) => e.kind === "OperationDefinition" && e.operation === "mutation") && (y.method = "GET"), y.method === "GET") {
|
|
39
|
+
let { newURI: e, parseError: t } = i(w, b);
|
|
40
|
+
if (t) return new s((e) => {
|
|
41
|
+
e.error(t);
|
|
42
|
+
});
|
|
43
|
+
w = e;
|
|
44
|
+
} else y.body = JSON.stringify(x);
|
|
45
|
+
let T = new AbortController();
|
|
46
|
+
y.signal && (y.signal.aborted ? T.abort() : y.signal.addEventListener("abort", () => {
|
|
47
|
+
T.abort();
|
|
48
|
+
}, { once: !0 })), y.signal = T.signal;
|
|
49
|
+
let E = _ || fetch;
|
|
50
|
+
return new s((t) => {
|
|
51
|
+
let n;
|
|
52
|
+
return E(w, y).then((t) => (e.setContext({ response: t }), t)).then(r(e)).then((e) => {
|
|
53
|
+
t.next(e), t.complete();
|
|
54
|
+
}).catch((e) => {
|
|
55
|
+
n || (e.result && e.result.errors && e.result.data && t.next(e.result), t.error(e));
|
|
56
|
+
}), () => {
|
|
57
|
+
n = !0, T !== void 0 && T.abort();
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
});
|
|
14
61
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
FormData: x,
|
|
20
|
-
formDataAppendFile: F = P,
|
|
21
|
-
print: E = H,
|
|
22
|
-
fetch: w,
|
|
23
|
-
fetchOptions: A,
|
|
24
|
-
credentials: C,
|
|
25
|
-
headers: O,
|
|
26
|
-
includeExtensions: k
|
|
27
|
-
} = {}) {
|
|
28
|
-
const S = {
|
|
29
|
-
http: { includeExtensions: k },
|
|
30
|
-
options: A,
|
|
31
|
-
credentials: C,
|
|
32
|
-
headers: O
|
|
33
|
-
};
|
|
34
|
-
return new q((l) => {
|
|
35
|
-
const c = l.getContext(), {
|
|
36
|
-
// Apollo Studio client awareness `name` and `version` can be configured
|
|
37
|
-
// via `ApolloClient` constructor options:
|
|
38
|
-
// https://www.apollographql.com/docs/graphos/metrics/client-awareness/#setup
|
|
39
|
-
clientAwareness: { name: m, version: h } = {},
|
|
40
|
-
headers: D
|
|
41
|
-
} = c, I = {
|
|
42
|
-
http: c.http,
|
|
43
|
-
options: c.fetchOptions,
|
|
44
|
-
credentials: c.credentials,
|
|
45
|
-
headers: {
|
|
46
|
-
// Client awareness headers can be overridden by context `headers`.
|
|
47
|
-
...m && { "apollographql-client-name": m },
|
|
48
|
-
...h && { "apollographql-client-version": h },
|
|
49
|
-
...D
|
|
50
|
-
}
|
|
51
|
-
}, { options: e, body: u } = G(
|
|
52
|
-
l,
|
|
53
|
-
E,
|
|
54
|
-
J,
|
|
55
|
-
S,
|
|
56
|
-
I
|
|
57
|
-
), { clone: g, files: p } = v(u, a, "");
|
|
58
|
-
let f = L(l, r);
|
|
59
|
-
if (p.size) {
|
|
60
|
-
e.headers && delete e.headers["content-type"];
|
|
61
|
-
const n = x || FormData, o = new n();
|
|
62
|
-
o.append("operations", JSON.stringify(g));
|
|
63
|
-
const t = {};
|
|
64
|
-
let d = 0;
|
|
65
|
-
p.forEach((b) => {
|
|
66
|
-
t[++d] = b;
|
|
67
|
-
}), o.append("map", JSON.stringify(t)), d = 0, p.forEach((b, U) => {
|
|
68
|
-
F(o, String(++d), U);
|
|
69
|
-
}), e.body = o;
|
|
70
|
-
} else if (i && !l.query.definitions.some(
|
|
71
|
-
(n) => n.kind === "OperationDefinition" && n.operation === "mutation"
|
|
72
|
-
) && (e.method = "GET"), e.method === "GET") {
|
|
73
|
-
const { newURI: n, parseError: o } = T(f, u);
|
|
74
|
-
if (o)
|
|
75
|
-
return new y((t) => {
|
|
76
|
-
t.error(o);
|
|
77
|
-
});
|
|
78
|
-
f = n;
|
|
79
|
-
} else
|
|
80
|
-
e.body = JSON.stringify(g);
|
|
81
|
-
const { controller: s } = B();
|
|
82
|
-
typeof s != "boolean" && (e.signal && (e.signal.aborted ? s.abort() : e.signal.addEventListener(
|
|
83
|
-
"abort",
|
|
84
|
-
() => {
|
|
85
|
-
s.abort();
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
// Prevent a memory leak if the user configured abort controller
|
|
89
|
-
// is long lasting, or controls multiple things.
|
|
90
|
-
once: !0
|
|
91
|
-
}
|
|
92
|
-
)), e.signal = s.signal);
|
|
93
|
-
const R = w || fetch;
|
|
94
|
-
return new y((n) => {
|
|
95
|
-
let o;
|
|
96
|
-
return R(f, e).then((t) => (l.setContext({ response: t }), t)).then(N(l)).then((t) => {
|
|
97
|
-
n.next(t), n.complete();
|
|
98
|
-
}).catch((t) => {
|
|
99
|
-
o || (t.result && t.result.errors && t.result.data && n.next(t.result), n.error(t));
|
|
100
|
-
}), () => {
|
|
101
|
-
o = !0, typeof s != "boolean" && s.abort();
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
export {
|
|
107
|
-
V as createUploadLink
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=upload.js.map
|
|
62
|
+
//#endregion
|
|
63
|
+
export { d as createUploadLink };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sources":["../../../../src/react/apollo-client/links/upload.tsx"],"sourcesContent":["import type { BaseHttpLink } from '@apollo/client/link/http';\nimport type { ExtractableFile } from 'extract-files/isExtractableFile.mjs';\n\nimport { ApolloLink } from '@apollo/client/link';\nimport { defaultPrinter, fallbackHttpConfig, parseAndCheckHttpResponse, rewriteURIForGET, selectHttpOptionsAndBodyInternal, selectURI } from '@apollo/client/link/http';\nimport { Observable } from '@apollo/client/utilities';\nimport extractFiles from 'extract-files/extractFiles.mjs';\nimport isExtractableFile from 'extract-files/isExtractableFile.mjs';\n\n/**\n * Creates a signal if supported.\n * @returns {boolean} Signal if supported.\n */\nfunction createSignalIfSupported() {\n if (typeof AbortController === 'undefined') {\n return { controller: false, signal: false };\n }\n\n const controller = new AbortController();\n const signal = controller.signal;\n\n return { controller, signal };\n}\n\n/**\n * Appends a file to the form data.\n * @param {FormData} formData Form data to append the file to.\n * @param {string} fieldName Field name to append the file to.\n * @param {ExtractableFile} file File to append.\n */\nfunction formDataAppendFile(formData: FormData, fieldName: string, file: ExtractableFile) {\n 'name' in file\n ? formData.append(fieldName, file, file.name)\n : formData.append(fieldName, file);\n}\n\n/**\n * Creates a\n * [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)\n * for [Apollo Client](https://www.apollographql.com/docs/react) that fetches a\n * [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec)\n * if the GraphQL variables contain files (by default\n * [`FileList`](https://developer.mozilla.org/en-US/docs/Web/API/FileList),\n * [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), or\n * [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instances),\n * or else fetches a regular\n * [GraphQL POST or GET request](https://www.apollographql.com/docs/apollo-server/workflow/requests)\n * (depending on the config and GraphQL operation).\n *\n * Some of the options are similar to the\n * [`createHttpLink` options](https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options).\n * @see [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec).\n * @param {object} options Options.\n * @param {Parameters<typeof selectURI>[1]} [options.uri] GraphQL endpoint URI.\n * Defaults to `\"/graphql\"`.\n * @param {boolean} [options.useGETForQueries] Should GET be used to fetch\n * queries, if there are no files to upload.\n * @param {ExtractableFileMatcher} [options.isExtractableFile] Matches\n * extractable files in the GraphQL operation. Defaults to\n * {@linkcode isExtractableFile}.\n * @param {typeof FormData} [options.FormData]\n * [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n * class. Defaults to the {@linkcode FormData} global.\n * @param {FormDataFileAppender} [options.formDataAppendFile]\n * Customizes how extracted files are appended to the\n * [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n * instance. Defaults to {@linkcode formDataAppendFile}.\n * @param {import(\"@apollo/client/link/http/selectHttpOptionsAndBody.js\").Printer} [options.print]\n * Prints the GraphQL query or mutation AST to a string for transport.\n * Defaults to {@linkcode defaultPrinter}.\n * @param {typeof fetch} [options.fetch] [`fetch`](https://fetch.spec.whatwg.org)\n * implementation. Defaults to the {@linkcode fetch} global.\n * @param {RequestInit} [options.fetchOptions] `fetch` options; overridden by\n * upload requirements.\n * @param {string} [options.credentials] Overrides\n * {@linkcode RequestInit.credentials credentials} in\n * {@linkcode fetchOptions}.\n * @param {{ [headerName: string]: string }} [options.headers] Merges with and\n * overrides {@linkcode RequestInit.headers headers} in\n * {@linkcode fetchOptions}.\n * @param {boolean} [options.includeExtensions] Toggles sending `extensions`\n * fields to the GraphQL server. Defaults to `false`.\n * @returns A [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link).\n * @example\n * A basic Apollo Client setup:\n *\n * ```js\n * import { ApolloClient, InMemoryCache } from \"@apollo/client\";\n * import createUploadLink from \"apollo-upload-client/createUploadLink.mjs\";\n *\n * const client = new ApolloClient({\n * cache: new InMemoryCache(),\n * link: createUploadLink(),\n * });\n * ```\n */\nexport function createUploadLink({\n uri: fetchUri = '/graphql',\n useGETForQueries,\n isExtractableFile: customIsExtractableFile = isExtractableFile,\n FormData: CustomFormData,\n formDataAppendFile: customFormDataAppendFile = formDataAppendFile,\n print = defaultPrinter,\n fetch: customFetch,\n fetchOptions,\n credentials,\n headers,\n includeExtensions,\n}: {\n uri?: string;\n useGETForQueries?: boolean;\n isExtractableFile?: (value: unknown) => value is ExtractableFile;\n FormData?: typeof FormData;\n formDataAppendFile?: (formData: FormData, fieldName: string, file: ExtractableFile) => void;\n print?: BaseHttpLink.Printer;\n fetch?: typeof fetch;\n fetchOptions?: RequestInit;\n credentials?: RequestCredentials;\n headers?: Record<string, string>;\n includeExtensions?: boolean;\n} = {}) {\n const linkConfig = {\n http: { includeExtensions },\n options: fetchOptions,\n credentials,\n headers,\n };\n\n return new ApolloLink((operation) => {\n const context = (operation.getContext());\n const {\n // Apollo Studio client awareness `name` and `version` can be configured\n // via `ApolloClient` constructor options:\n // https://www.apollographql.com/docs/graphos/metrics/client-awareness/#setup\n clientAwareness: { name, version } = {},\n headers,\n } = context;\n\n const contextConfig = {\n http: context['http'],\n options: context['fetchOptions'],\n credentials: context['credentials'],\n headers: {\n // Client awareness headers can be overridden by context `headers`.\n ...(name && { 'apollographql-client-name': name }),\n ...(version && { 'apollographql-client-version': version }),\n ...headers,\n },\n };\n\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig,\n );\n\n const { clone, files } = extractFiles(body, customIsExtractableFile, '');\n\n let uri = selectURI(operation, fetchUri);\n\n if (files.size) {\n if (options.headers)\n // Automatically set by `fetch` when the `body` is a `FormData` instance.\n delete options.headers['content-type'];\n\n // GraphQL multipart request spec:\n // https://github.com/jaydenseric/graphql-multipart-request-spec\n\n const RuntimeFormData = CustomFormData || FormData;\n\n const form = new RuntimeFormData();\n\n form.append('operations', JSON.stringify(clone));\n\n const map: Record<string, Array<string>> = {};\n\n let i = 0;\n files.forEach((paths) => {\n map[++i] = paths;\n });\n form.append('map', JSON.stringify(map));\n\n i = 0;\n files.forEach((_paths, file) => {\n customFormDataAppendFile(form, String(++i), file);\n });\n\n options['body'] = form;\n }\n else {\n if (\n useGETForQueries\n // If the operation contains some mutations GET shouldn’t be used.\n && !operation.query.definitions.some(\n definition =>\n definition.kind === 'OperationDefinition'\n && definition.operation === 'mutation',\n )\n ) {\n options['method'] = 'GET';\n }\n\n if (options['method'] === 'GET') {\n const { newURI, parseError } = rewriteURIForGET(uri, body);\n if (parseError) {\n // Apollo’s `HttpLink` uses `fromError` for this, but it’s not\n // exported from `@apollo/client/link/http`.\n return new Observable((observer) => {\n observer.error(parseError);\n });\n }\n uri = newURI;\n }\n else {\n options['body'] = JSON.stringify(clone);\n }\n }\n\n const { controller } = createSignalIfSupported();\n\n if (typeof controller !== 'boolean') {\n if (options['signal']) {\n // Respect the user configured abort controller signal.\n options['signal'].aborted\n // Signal already aborted, so immediately abort.\n ? controller.abort()\n // Signal not already aborted, so setup a listener to abort when it does.\n : options['signal'].addEventListener(\n 'abort',\n () => {\n controller.abort();\n },\n {\n // Prevent a memory leak if the user configured abort controller\n // is long lasting, or controls multiple things.\n once: true,\n },\n );\n }\n\n options['signal'] = controller.signal;\n }\n\n const runtimeFetch = customFetch || fetch;\n\n return new Observable((observer) => {\n /**\n * Is the observable being cleaned up.\n */\n let cleaningUp: boolean;\n\n runtimeFetch(uri, options)\n .then((response) => {\n // Forward the response on the context.\n operation.setContext({ response });\n return response;\n })\n .then(parseAndCheckHttpResponse(operation))\n .then((result) => {\n observer.next(result);\n observer.complete();\n })\n .catch((error) => {\n // If the observable is being cleaned up, there is no need to call\n // next or error because there are no more subscribers. An error after\n // cleanup begins is likely from the cleanup function aborting the\n // fetch.\n if (!cleaningUp) {\n // For errors such as an invalid fetch URI there will be no GraphQL\n // result with errors or data to forward.\n if (error.result && error.result.errors && error.result.data)\n observer.next(error.result);\n\n observer.error(error);\n }\n });\n\n // Cleanup function.\n return () => {\n cleaningUp = true;\n\n // Abort fetch. It’s ok to signal an abort even when not fetching.\n if (typeof controller !== 'boolean')\n controller.abort();\n };\n });\n });\n}\n"],"names":["ApolloLink","selectHttpOptionsAndBodyInternal","defaultPrinter","fallbackHttpConfig","selectURI","rewriteURIForGET","parseAndCheckHttpResponse","Observable","extractFiles","isExtractableFile","createSignalIfSupported","controller","signal","formDataAppendFile","formData","fieldName","file","createUploadLink","fetchUri","useGETForQueries","customIsExtractableFile","CustomFormData","customFormDataAppendFile","print","customFetch","fetchOptions","credentials","headers","includeExtensions","linkConfig","operation","context","name","version","contextConfig","options","body","clone","files","uri","RuntimeFormData","form","map","i","paths","_paths","definition","newURI","parseError","observer","runtimeFetch","cleaningUp","response","result","error"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../../../src/react/apollo-client/links/upload.tsx"],"sourcesContent":["import type { BaseHttpLink } from '@apollo/client/link/http';\nimport type { ExtractableFile } from 'extract-files/isExtractableFile.mjs';\n\nimport { ApolloLink } from '@apollo/client/link';\nimport { defaultPrinter, fallbackHttpConfig, parseAndCheckHttpResponse, rewriteURIForGET, selectHttpOptionsAndBodyInternal, selectURI } from '@apollo/client/link/http';\nimport { Observable } from '@apollo/client/utilities';\nimport extractFiles from 'extract-files/extractFiles.mjs';\nimport isExtractableFile from 'extract-files/isExtractableFile.mjs';\n\n/**\n * Appends a file to the form data.\n * @param {FormData} formData Form data to append the file to.\n * @param {string} fieldName Field name to append the file to.\n * @param {ExtractableFile} file File to append.\n */\nfunction formDataAppendFile(formData: FormData, fieldName: string, file: ExtractableFile) {\n 'name' in file\n ? formData.append(fieldName, file, file.name)\n : formData.append(fieldName, file);\n}\n\n/**\n * Creates a\n * [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)\n * for [Apollo Client](https://www.apollographql.com/docs/react) that fetches a\n * [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec)\n * if the GraphQL variables contain files (by default\n * [`FileList`](https://developer.mozilla.org/en-US/docs/Web/API/FileList),\n * [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), or\n * [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instances),\n * or else fetches a regular\n * [GraphQL POST or GET request](https://www.apollographql.com/docs/apollo-server/workflow/requests)\n * (depending on the config and GraphQL operation).\n *\n * Some of the options are similar to the\n * [`createHttpLink` options](https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options).\n * @see [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec).\n * @param {object} options Options.\n * @param {Parameters<typeof selectURI>[1]} [options.uri] GraphQL endpoint URI.\n * Defaults to `\"/graphql\"`.\n * @param {boolean} [options.useGETForQueries] Should GET be used to fetch\n * queries, if there are no files to upload.\n * @param {ExtractableFileMatcher} [options.isExtractableFile] Matches\n * extractable files in the GraphQL operation. Defaults to\n * {@linkcode isExtractableFile}.\n * @param {typeof FormData} [options.FormData]\n * [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n * class. Defaults to the {@linkcode FormData} global.\n * @param {FormDataFileAppender} [options.formDataAppendFile]\n * Customizes how extracted files are appended to the\n * [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)\n * instance. Defaults to {@linkcode formDataAppendFile}.\n * @param {import(\"@apollo/client/link/http/selectHttpOptionsAndBody.js\").Printer} [options.print]\n * Prints the GraphQL query or mutation AST to a string for transport.\n * Defaults to {@linkcode defaultPrinter}.\n * @param {typeof fetch} [options.fetch] [`fetch`](https://fetch.spec.whatwg.org)\n * implementation. Defaults to the {@linkcode fetch} global.\n * @param {RequestInit} [options.fetchOptions] `fetch` options; overridden by\n * upload requirements.\n * @param {string} [options.credentials] Overrides\n * {@linkcode RequestInit.credentials credentials} in\n * {@linkcode fetchOptions}.\n * @param {{ [headerName: string]: string }} [options.headers] Merges with and\n * overrides {@linkcode RequestInit.headers headers} in\n * {@linkcode fetchOptions}.\n * @param {boolean} [options.includeExtensions] Toggles sending `extensions`\n * fields to the GraphQL server. Defaults to `false`.\n * @returns A [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link).\n * @example\n * A basic Apollo Client setup:\n *\n * ```js\n * import { ApolloClient, InMemoryCache } from \"@apollo/client\";\n * import createUploadLink from \"apollo-upload-client/createUploadLink.mjs\";\n *\n * const client = new ApolloClient({\n * cache: new InMemoryCache(),\n * link: createUploadLink(),\n * });\n * ```\n */\nexport function createUploadLink({\n uri: fetchUri = '/graphql',\n useGETForQueries,\n isExtractableFile: customIsExtractableFile = isExtractableFile,\n FormData: CustomFormData,\n formDataAppendFile: customFormDataAppendFile = formDataAppendFile,\n print = defaultPrinter,\n fetch: customFetch,\n fetchOptions,\n credentials,\n headers,\n includeExtensions,\n}: {\n uri?: string;\n useGETForQueries?: boolean;\n isExtractableFile?: (value: unknown) => value is ExtractableFile;\n FormData?: typeof FormData;\n formDataAppendFile?: (formData: FormData, fieldName: string, file: ExtractableFile) => void;\n print?: BaseHttpLink.Printer;\n fetch?: typeof fetch;\n fetchOptions?: RequestInit;\n credentials?: RequestCredentials;\n headers?: Record<string, string>;\n includeExtensions?: boolean;\n} = {}) {\n const linkConfig = {\n http: { includeExtensions },\n options: fetchOptions,\n credentials,\n headers,\n };\n\n return new ApolloLink((operation) => {\n const context = (operation.getContext());\n const {\n // Apollo Studio client awareness `name` and `version` can be configured\n // via `ApolloClient` constructor options:\n // https://www.apollographql.com/docs/graphos/metrics/client-awareness/#setup\n clientAwareness: { name, version } = {},\n headers,\n } = context;\n\n const contextConfig = {\n http: context['http'],\n options: context['fetchOptions'],\n credentials: context['credentials'],\n headers: {\n // Client awareness headers can be overridden by context `headers`.\n ...(name && { 'apollographql-client-name': name }),\n ...(version && { 'apollographql-client-version': version }),\n ...headers,\n },\n };\n\n const { options, body } = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig,\n );\n\n const { clone, files } = extractFiles(body, customIsExtractableFile, '');\n\n let uri = selectURI(operation, fetchUri);\n\n if (files.size) {\n if (options.headers)\n // Automatically set by `fetch` when the `body` is a `FormData` instance.\n delete options.headers['content-type'];\n\n // GraphQL multipart request spec:\n // https://github.com/jaydenseric/graphql-multipart-request-spec\n\n const RuntimeFormData = CustomFormData || FormData;\n\n const form = new RuntimeFormData();\n\n form.append('operations', JSON.stringify(clone));\n\n const map: Record<string, Array<string>> = {};\n\n let i = 0;\n files.forEach((paths) => {\n map[++i] = paths;\n });\n form.append('map', JSON.stringify(map));\n\n i = 0;\n files.forEach((_paths, file) => {\n customFormDataAppendFile(form, String(++i), file);\n });\n\n options['body'] = form;\n }\n else {\n if (\n useGETForQueries\n // If the operation contains some mutations GET shouldn’t be used.\n && !operation.query.definitions.some(\n definition =>\n definition.kind === 'OperationDefinition'\n && definition.operation === 'mutation',\n )\n ) {\n options['method'] = 'GET';\n }\n\n if (options['method'] === 'GET') {\n const { newURI, parseError } = rewriteURIForGET(uri, body);\n if (parseError) {\n // Apollo’s `HttpLink` uses `fromError` for this, but it’s not\n // exported from `@apollo/client/link/http`.\n return new Observable((observer) => {\n observer.error(parseError);\n });\n }\n uri = newURI;\n }\n else {\n options['body'] = JSON.stringify(clone);\n }\n }\n\n const controller = new AbortController();\n\n if (options['signal']) {\n // Respect the user configured abort controller signal.\n options['signal'].aborted\n // Signal already aborted, so immediately abort.\n ? controller.abort()\n // Signal not already aborted, so setup a listener to abort when it does.\n : options['signal'].addEventListener(\n 'abort',\n () => {\n controller.abort();\n },\n {\n // Prevent a memory leak if the user configured abort controller\n // is long lasting, or controls multiple things.\n once: true,\n },\n );\n }\n\n options['signal'] = controller.signal;\n\n const runtimeFetch = customFetch || fetch;\n\n return new Observable((observer) => {\n /**\n * Is the observable being cleaned up.\n */\n let cleaningUp: boolean;\n\n runtimeFetch(uri, options)\n .then((response) => {\n // Forward the response on the context.\n operation.setContext({ response });\n return response;\n })\n .then(parseAndCheckHttpResponse(operation))\n .then((result) => {\n observer.next(result);\n observer.complete();\n })\n .catch((error) => {\n // If the observable is being cleaned up, there is no need to call\n // next or error because there are no more subscribers. An error after\n // cleanup begins is likely from the cleanup function aborting the\n // fetch.\n if (!cleaningUp) {\n // For errors such as an invalid fetch URI there will be no GraphQL\n // result with errors or data to forward.\n if (error.result && error.result.errors && error.result.data)\n observer.next(error.result);\n\n observer.error(error);\n }\n });\n\n // Cleanup function.\n return () => {\n cleaningUp = true;\n\n // Abort fetch. It’s ok to signal an abort even when not fetching.\n if (typeof controller !== 'undefined')\n controller.abort();\n };\n });\n });\n}\n"],"mappings":";;;;;;AAeA,SAAS,EAAmB,GAAoB,GAAmB,GAAuB;AACtF,WAAU,IACJ,EAAS,OAAO,GAAW,GAAM,EAAK,KAAK,GAC3C,EAAS,OAAO,GAAW,EAAK;;AA+D1C,SAAgB,EAAiB,EAC7B,KAAK,IAAW,YAChB,qBACA,mBAAmB,IAA0B,GAC7C,UAAU,GACV,oBAAoB,IAA2B,GAC/C,WAAQ,GACR,OAAO,GACP,iBACA,gBACA,YACA,yBAaA,EAAE,EAAE;CACJ,IAAM,IAAa;EACf,MAAM,EAAE,sBAAmB;EAC3B,SAAS;EACT;EACA;EACH;AAED,QAAO,IAAI,GAAY,MAAc;EACjC,IAAM,IAAW,EAAU,YAAY,EACjC,EAIF,iBAAiB,EAAE,SAAM,eAAY,EAAE,EACvC,eACA,GAcE,EAAE,YAAS,YAAS,EACtB,GACA,GACA,GACA,GAhBkB;GAClB,MAAM,EAAQ;GACd,SAAS,EAAQ;GACjB,aAAa,EAAQ;GACrB,SAAS;IAEL,GAAI,KAAQ,EAAE,6BAA6B,GAAM;IACjD,GAAI,KAAW,EAAE,gCAAgC,GAAS;IAC1D,GAAG;IACN;GACJ,CAQA,EAEK,EAAE,UAAO,aAAU,EAAa,GAAM,GAAyB,GAAG,EAEpE,IAAM,EAAU,GAAW,EAAS;AAExC,MAAI,EAAM,MAAM;AACZ,GAAI,EAAQ,WAER,OAAO,EAAQ,QAAQ;GAO3B,IAAM,IAAO,KAFW,KAAkB,WAER;AAElC,KAAK,OAAO,cAAc,KAAK,UAAU,EAAM,CAAC;GAEhD,IAAM,IAAqC,EAAE,EAEzC,IAAI;AAWR,GAVA,EAAM,SAAS,MAAU;AACrB,MAAI,EAAE,KAAK;KACb,EACF,EAAK,OAAO,OAAO,KAAK,UAAU,EAAI,CAAC,EAEvC,IAAI,GACJ,EAAM,SAAS,GAAQ,MAAS;AAC5B,MAAyB,GAAM,OAAO,EAAE,EAAE,EAAE,EAAK;KACnD,EAEF,EAAQ,OAAU;aAId,KAEG,CAAC,EAAU,MAAM,YAAY,MAC5B,MACI,EAAW,SAAS,yBACjB,EAAW,cAAc,WACnC,KAED,EAAQ,SAAY,QAGpB,EAAQ,WAAc,OAAO;GAC7B,IAAM,EAAE,WAAQ,kBAAe,EAAiB,GAAK,EAAK;AAC1D,OAAI,EAGA,QAAO,IAAI,GAAY,MAAa;AAChC,MAAS,MAAM,EAAW;KAC5B;AAEN,OAAM;QAGN,GAAQ,OAAU,KAAK,UAAU,EAAM;EAI/C,IAAM,IAAa,IAAI,iBAAiB;AAqBxC,EAnBI,EAAQ,WAER,EAAQ,OAAU,UAEZ,EAAW,OAAO,GAElB,EAAQ,OAAU,iBACZ,eACM;AACF,KAAW,OAAO;KAEtB,EAGI,MAAM,IACT,CACJ,GAGb,EAAQ,SAAY,EAAW;EAE/B,IAAM,IAAe,KAAe;AAEpC,SAAO,IAAI,GAAY,MAAa;GAIhC,IAAI;AA6BJ,UA3BA,EAAa,GAAK,EAAQ,CACrB,MAAM,OAEH,EAAU,WAAW,EAAE,aAAU,CAAC,EAC3B,GACT,CACD,KAAK,EAA0B,EAAU,CAAC,CAC1C,MAAM,MAAW;AAEd,IADA,EAAS,KAAK,EAAO,EACrB,EAAS,UAAU;KACrB,CACD,OAAO,MAAU;AAKd,IAAK,MAGG,EAAM,UAAU,EAAM,OAAO,UAAU,EAAM,OAAO,QACpD,EAAS,KAAK,EAAM,OAAO,EAE/B,EAAS,MAAM,EAAM;KAE3B,QAGO;AAIT,IAHA,IAAa,IAGF,MAAe,UACtB,EAAW,OAAO;;IAE5B;GACJ"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as p } from "react";
|
|
4
|
-
import { getClient as i } from "./apollo-client-nextjs.util.js";
|
|
1
|
+
import { Toaster as e } from "../toast/index.js";
|
|
2
|
+
import { ApolloErrorComponent as t } from "../apollo-error/apollo-error.component.js";
|
|
5
3
|
import { ApolloErrorProvider as n } from "../apollo-error/apollo-error.provider.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import { getClient as r } from "./apollo-client-nextjs.util.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { useMemo as a } from "react";
|
|
7
|
+
import { ApolloNextAppProvider as o } from "@apollo/client-integration-nextjs";
|
|
8
|
+
//#region src/react/apollo-client-nextjs/apollo-client-nextjs.component.tsx
|
|
9
|
+
function s({ options: s, children: c, onError: l }) {
|
|
10
|
+
let u = a(() => () => r(s || {}), [s]);
|
|
11
|
+
return /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement(n, { onError: l }, /* @__PURE__ */ i.createElement(o, { makeClient: u }, c), !l && /* @__PURE__ */ i.createElement(t, null)), /* @__PURE__ */ i.createElement(e, { position: "top-right" }));
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=apollo-client-nextjs.component.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { s as ApolloProvider };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=apollo-client-nextjs.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client-nextjs.component.js","sources":["../../../src/react/apollo-client-nextjs/apollo-client-nextjs.component.tsx"],"sourcesContent":["import { ApolloNextAppProvider } from '@apollo/client-integration-nextjs';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from '../apollo-client/index.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { getClient } from './apollo-client-nextjs.util.js';\n\n/**\n * Next.js 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 * - Next.js specific 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 makeClient = useMemo(\n () => () => getClient(options || {}),\n [options],\n );\n\n return (\n <>\n <ApolloErrorProvider onError={onError}>\n <ApolloNextAppProvider makeClient={makeClient}>\n {children}\n </ApolloNextAppProvider>\n {!onError && <ApolloErrorComponent />}\n </ApolloErrorProvider>\n <Toaster position=\"top-right\" />\n </>\n );\n}\n"],"
|
|
1
|
+
{"version":3,"file":"apollo-client-nextjs.component.js","names":[],"sources":["../../../src/react/apollo-client-nextjs/apollo-client-nextjs.component.tsx"],"sourcesContent":["import { ApolloNextAppProvider } from '@apollo/client-integration-nextjs';\nimport * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_ApolloProviderProps } from '../apollo-client/index.js';\n\nimport { ApolloErrorComponent, ApolloErrorProvider } from '../apollo-error/index.js';\nimport { Toaster } from '../toast/index.js';\nimport { getClient } from './apollo-client-nextjs.util.js';\n\n/**\n * Next.js 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 * - Next.js specific 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 makeClient = useMemo(\n () => () => getClient(options || {}),\n [options],\n );\n\n return (\n <>\n <ApolloErrorProvider onError={onError}>\n <ApolloNextAppProvider makeClient={makeClient}>\n {children}\n </ApolloNextAppProvider>\n {!onError && <ApolloErrorComponent />}\n </ApolloErrorProvider>\n <Toaster position=\"top-right\" />\n </>\n );\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,EAAe,EAAE,YAAS,aAAU,cAAkC;CAClF,IAAM,IAAa,cACH,EAAU,KAAW,EAAE,CAAC,EACpC,CAAC,EAAQ,CACZ;AAED,QACI,kBAAA,cAAA,EAAA,UAAA,MACI,kBAAA,cAAC,GAAD,EAA8B,YAKR,EAJlB,kBAAA,cAAC,GAAD,EAAmC,eAEX,EADnB,EACmB,EACvB,CAAC,KAAW,kBAAA,cAAC,GAAA,KAAuB,CACnB,EACtB,kBAAA,cAAC,GAAD,EAAS,UAAS,aAAc,CAAA,CACjC"}
|