@adobe-commerce/fetch-graphql 1.3.1 → 1.3.2-alpha-20260928110639
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/CHANGELOG.md +156 -51
- package/LICENSE.md +288 -0
- package/eslint.config.js +7 -2
- package/package.json +8 -5
- package/src/index.ts +49 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @adobe-commerce/fetch-graphql
|
|
2
2
|
|
|
3
|
+
## 1.3.2-alpha-20260928110639
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3313516: feat(elsie): make `typescript` a peer dependency; remove the `types`
|
|
8
|
+
command
|
|
9
|
+
|
|
10
|
+
`typescript` is now an optional `peerDependency` of `@adobe-commerce/elsie`
|
|
11
|
+
instead of a bundled `dependency`. The `dts` Vite plugin (used by
|
|
12
|
+
`elsie build` for `.d.ts` generation) resolves `typescript` from the building
|
|
13
|
+
package's own install rather than elsie's, so declaration output reflects the
|
|
14
|
+
exact compiler version that package's `tsconfig.json`, source, and IDE
|
|
15
|
+
actually use. A package with no `typescript` devDependency of its own gets a
|
|
16
|
+
clear error instead of a silently mismatched build. See
|
|
17
|
+
`docs/toolchain-peer-dependencies.md` for the full rationale.
|
|
18
|
+
|
|
19
|
+
The `elsie types` command (`tsc --noEmit` plus TS6 tsconfig validation) is
|
|
20
|
+
removed — with `typescript` no longer bundled, elsie has no reason to own a
|
|
21
|
+
type-checking command. A package that wants one defines its own script (e.g.
|
|
22
|
+
`"types": "tsc --noEmit"`), using its own installed `typescript`.
|
|
23
|
+
|
|
24
|
+
`build-tools`, `event-bus`, `fetch-graphql`, and `recaptcha` each gain a
|
|
25
|
+
`typescript` devDependency of their own (pinned via `pnpm-workspace.yaml`'s
|
|
26
|
+
`catalog.typescript`) so `.d.ts` generation and any future type-checking
|
|
27
|
+
script keep working now that elsie no longer bundles it.
|
|
28
|
+
|
|
3
29
|
## 1.3.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -9,47 +35,78 @@
|
|
|
9
35
|
## What changed
|
|
10
36
|
|
|
11
37
|
### TypeScript 4.7 → 6.0
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- `
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- `
|
|
38
|
+
- `tsconfig-base.json` updated with correct TS 6 defaults. Two new-default
|
|
39
|
+
opt-outs are deferred as tech debt: `exactOptionalPropertyTypes` and
|
|
40
|
+
`verbatimModuleSyntax`.
|
|
41
|
+
- `moduleResolution` changed from `"nodenext"` to `"bundler"` across all
|
|
42
|
+
packages — the correct pairing for `module: "esnext"` in a Vite monorepo.
|
|
43
|
+
Only `packages/elsie` keeps `"NodeNext"` (paired with `module: "NodeNext"`
|
|
44
|
+
for its dual CJS/ESM output).
|
|
45
|
+
- `baseUrl` removed from all tsconfigs (deprecated in TS 6; `paths` resolves
|
|
46
|
+
relative to the tsconfig file directly).
|
|
47
|
+
- `rootDir` added explicitly to `build-tools`, `event-bus`, `fetch-graphql`,
|
|
48
|
+
and `recaptcha` tsconfigs (implicit `rootDir` deprecated in TS 6).
|
|
49
|
+
- `types: []` set in `tsconfig-base.json` to prevent ambient test types from
|
|
50
|
+
leaking into declaration output. Each package's own `tsconfig.json` declares
|
|
51
|
+
its `types` explicitly (`jest`, `node`, `vite/client`, etc.).
|
|
52
|
+
- `babel-plugin-tsconfig-paths` removed — it was a no-op in every package that
|
|
53
|
+
listed it.
|
|
54
|
+
- `noUncheckedIndexedAccess` enabled — violations were few enough to fix in
|
|
55
|
+
source.
|
|
20
56
|
|
|
21
57
|
### ESLint 8 → 9 (flat config)
|
|
22
|
-
|
|
23
|
-
|
|
58
|
+
- `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` (v5)
|
|
59
|
+
removed; replaced by the unified `typescript-eslint` v8 package.
|
|
24
60
|
- `eslint-config-preact` bumped to `^2.0.0` (ESLint 9 support).
|
|
25
61
|
- `eslint-config-prettier` bumped to `^10.0.0`.
|
|
26
|
-
- `eslint-plugin-mdx` bumped to `^3.8.1`. **ESLint 10 is not supported** —
|
|
62
|
+
- `eslint-plugin-mdx` bumped to `^3.8.1`. **ESLint 10 is not supported** —
|
|
63
|
+
`eslint-plugin-mdx` vendors an internal ESLint API removed in v10; ESLint 9
|
|
64
|
+
is pinned until a fix is released.
|
|
27
65
|
- `globals` added (`^15.0.0`) for `languageOptions.globals` in flat config.
|
|
28
|
-
- Shared config (`packages/elsie/config/eslint.mjs`) rewritten as a
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
66
|
+
- Shared config (`packages/elsie/config/eslint.mjs`) rewritten as a
|
|
67
|
+
flat-config array export.
|
|
68
|
+
- Per-package `.eslintrc.js` files deleted; replaced with `eslint.config.js`
|
|
69
|
+
(ESM flat config).
|
|
70
|
+
- Several `typescript-eslint` v8 rules disabled to preserve prior behavior:
|
|
71
|
+
`no-explicit-any`, `ban-ts-comment`, `no-unused-expressions`,
|
|
72
|
+
`no-unsafe-function-type`, `no-require-imports`, `no-empty-object-type`.
|
|
73
|
+
Tracked as tech debt.
|
|
74
|
+
- `reportUnusedDisableDirectives` disabled to avoid sweeping pre-existing
|
|
75
|
+
inline disable comments.
|
|
32
76
|
|
|
33
77
|
### `vite-plugin-dts` removed; replaced with custom `dtsPlugin`
|
|
34
78
|
|
|
35
|
-
`vite-plugin-dts@3.9.1` declared a `typescript <5.0` peer range and its v5
|
|
79
|
+
`vite-plugin-dts@3.9.1` declared a `typescript <5.0` peer range and its v5
|
|
80
|
+
successor was incompatible with this monorepo's layout (cross-package sources,
|
|
81
|
+
workspace symlinks, multi-`outDir`). It was removed and replaced with a thin
|
|
82
|
+
custom Vite plugin at `packages/elsie/config/plugins/dts.mjs` (`dtsPlugin`)
|
|
83
|
+
that runs `tsc` directly. The resulting `dist/` layout is identical to what
|
|
84
|
+
v3.9 produced (147 `.d.ts` files, 12 top-level entry shims).
|
|
36
85
|
|
|
37
86
|
### Module format standardization
|
|
38
87
|
|
|
39
88
|
All tooling config files now follow a consistent format:
|
|
40
89
|
|
|
41
|
-
- **ESLint / Jest / Vite configs** — ESM (`.js` in `"type":"module"` packages;
|
|
42
|
-
|
|
90
|
+
- **ESLint / Jest / Vite configs** — ESM (`.js` in `"type":"module"` packages;
|
|
91
|
+
`.mjs` in elsie).
|
|
92
|
+
- **Prettier** — JSON only (`@adobe-commerce/elsie/config/prettier.json`
|
|
93
|
+
referenced via each package's `"prettier"` key). `prettier.config.*` files
|
|
94
|
+
deleted from all packages.
|
|
43
95
|
- **elsie CLI** (`bin/**`) — intentionally stays CommonJS.
|
|
44
96
|
|
|
45
97
|
See `architecture/decisions/009-module-format.md` for the full convention.
|
|
46
98
|
|
|
47
99
|
### `.elsie.js` → `.elsie.cjs`
|
|
48
100
|
|
|
49
|
-
The consumer project config file is renamed from `.elsie.js` to `.elsie.cjs`.
|
|
101
|
+
The consumer project config file is renamed from `.elsie.js` to `.elsie.cjs`.
|
|
102
|
+
With `"type":"module"` now required in consumer packages, a plain `.js` file
|
|
103
|
+
is treated as ES module — making `module.exports` a SyntaxError and making
|
|
104
|
+
`require()` in the elsie CLI fail with `ERR_REQUIRE_ESM`. The `.cjs` extension
|
|
105
|
+
forces CommonJS regardless of the package's `"type"` field.
|
|
50
106
|
|
|
51
107
|
- `elsie generate config` now writes `.elsie.cjs`.
|
|
52
|
-
- The CLI (`bin/lib/config.js`) and `config/vite.mjs` both prefer `.elsie.cjs`
|
|
108
|
+
- The CLI (`bin/lib/config.js`) and `config/vite.mjs` both prefer `.elsie.cjs`
|
|
109
|
+
and fall back to `.elsie.js` for packages not yet migrated.
|
|
53
110
|
- `.elsie.cjs` added to `.npmignore` in all consumer packages.
|
|
54
111
|
|
|
55
112
|
## Consumer migration
|
|
@@ -57,12 +114,16 @@
|
|
|
57
114
|
See `docs/elsie-v2-migration.md` for the full step-by-step guide. Key actions:
|
|
58
115
|
|
|
59
116
|
1. Add `"type": "module"` to `package.json`.
|
|
60
|
-
2. Replace `.eslintrc.js` with `eslint.config.js` (ESM flat config importing
|
|
117
|
+
2. Replace `.eslintrc.js` with `eslint.config.js` (ESM flat config importing
|
|
118
|
+
from `@adobe-commerce/elsie/config/eslint.mjs`).
|
|
61
119
|
3. Rename `.elsie.js` → `.elsie.cjs` (keep `module.exports` content as-is).
|
|
62
|
-
4. Add `"prettier": "@adobe-commerce/elsie/config/prettier.json"` to
|
|
63
|
-
|
|
120
|
+
4. Add `"prettier": "@adobe-commerce/elsie/config/prettier.json"` to
|
|
121
|
+
`package.json`; delete `prettier.config.js`.
|
|
122
|
+
5. Update `tsconfig.json`: remove `baseUrl`, add explicit `rootDir` and
|
|
123
|
+
`types`.
|
|
64
124
|
6. Add `tsconfig.build.json` for declaration emit (required by `dtsPlugin`).
|
|
65
|
-
7. Convert `.elsie.js` imports in `.storybook/main.js` and
|
|
125
|
+
7. Convert `.elsie.js` imports in `.storybook/main.js` and
|
|
126
|
+
`storybook-stories.js` to reference `.elsie.cjs`.
|
|
66
127
|
|
|
67
128
|
## 1.3.1-beta.0
|
|
68
129
|
|
|
@@ -73,47 +134,78 @@
|
|
|
73
134
|
## What changed
|
|
74
135
|
|
|
75
136
|
### TypeScript 4.7 → 6.0
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
- `
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
- `
|
|
137
|
+
- `tsconfig-base.json` updated with correct TS 6 defaults. Two new-default
|
|
138
|
+
opt-outs are deferred as tech debt: `exactOptionalPropertyTypes` and
|
|
139
|
+
`verbatimModuleSyntax`.
|
|
140
|
+
- `moduleResolution` changed from `"nodenext"` to `"bundler"` across all
|
|
141
|
+
packages — the correct pairing for `module: "esnext"` in a Vite monorepo.
|
|
142
|
+
Only `packages/elsie` keeps `"NodeNext"` (paired with `module: "NodeNext"`
|
|
143
|
+
for its dual CJS/ESM output).
|
|
144
|
+
- `baseUrl` removed from all tsconfigs (deprecated in TS 6; `paths` resolves
|
|
145
|
+
relative to the tsconfig file directly).
|
|
146
|
+
- `rootDir` added explicitly to `build-tools`, `event-bus`, `fetch-graphql`,
|
|
147
|
+
and `recaptcha` tsconfigs (implicit `rootDir` deprecated in TS 6).
|
|
148
|
+
- `types: []` set in `tsconfig-base.json` to prevent ambient test types from
|
|
149
|
+
leaking into declaration output. Each package's own `tsconfig.json` declares
|
|
150
|
+
its `types` explicitly (`jest`, `node`, `vite/client`, etc.).
|
|
151
|
+
- `babel-plugin-tsconfig-paths` removed — it was a no-op in every package that
|
|
152
|
+
listed it.
|
|
153
|
+
- `noUncheckedIndexedAccess` enabled — violations were few enough to fix in
|
|
154
|
+
source.
|
|
84
155
|
|
|
85
156
|
### ESLint 8 → 9 (flat config)
|
|
86
|
-
|
|
87
|
-
|
|
157
|
+
- `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` (v5)
|
|
158
|
+
removed; replaced by the unified `typescript-eslint` v8 package.
|
|
88
159
|
- `eslint-config-preact` bumped to `^2.0.0` (ESLint 9 support).
|
|
89
160
|
- `eslint-config-prettier` bumped to `^10.0.0`.
|
|
90
|
-
- `eslint-plugin-mdx` bumped to `^3.8.1`. **ESLint 10 is not supported** —
|
|
161
|
+
- `eslint-plugin-mdx` bumped to `^3.8.1`. **ESLint 10 is not supported** —
|
|
162
|
+
`eslint-plugin-mdx` vendors an internal ESLint API removed in v10; ESLint 9
|
|
163
|
+
is pinned until a fix is released.
|
|
91
164
|
- `globals` added (`^15.0.0`) for `languageOptions.globals` in flat config.
|
|
92
|
-
- Shared config (`packages/elsie/config/eslint.mjs`) rewritten as a
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
165
|
+
- Shared config (`packages/elsie/config/eslint.mjs`) rewritten as a
|
|
166
|
+
flat-config array export.
|
|
167
|
+
- Per-package `.eslintrc.js` files deleted; replaced with `eslint.config.js`
|
|
168
|
+
(ESM flat config).
|
|
169
|
+
- Several `typescript-eslint` v8 rules disabled to preserve prior behavior:
|
|
170
|
+
`no-explicit-any`, `ban-ts-comment`, `no-unused-expressions`,
|
|
171
|
+
`no-unsafe-function-type`, `no-require-imports`, `no-empty-object-type`.
|
|
172
|
+
Tracked as tech debt.
|
|
173
|
+
- `reportUnusedDisableDirectives` disabled to avoid sweeping pre-existing
|
|
174
|
+
inline disable comments.
|
|
96
175
|
|
|
97
176
|
### `vite-plugin-dts` removed; replaced with custom `dtsPlugin`
|
|
98
177
|
|
|
99
|
-
`vite-plugin-dts@3.9.1` declared a `typescript <5.0` peer range and its v5
|
|
178
|
+
`vite-plugin-dts@3.9.1` declared a `typescript <5.0` peer range and its v5
|
|
179
|
+
successor was incompatible with this monorepo's layout (cross-package sources,
|
|
180
|
+
workspace symlinks, multi-`outDir`). It was removed and replaced with a thin
|
|
181
|
+
custom Vite plugin at `packages/elsie/config/plugins/dts.mjs` (`dtsPlugin`)
|
|
182
|
+
that runs `tsc` directly. The resulting `dist/` layout is identical to what
|
|
183
|
+
v3.9 produced (147 `.d.ts` files, 12 top-level entry shims).
|
|
100
184
|
|
|
101
185
|
### Module format standardization
|
|
102
186
|
|
|
103
187
|
All tooling config files now follow a consistent format:
|
|
104
188
|
|
|
105
|
-
- **ESLint / Jest / Vite configs** — ESM (`.js` in `"type":"module"` packages;
|
|
106
|
-
|
|
189
|
+
- **ESLint / Jest / Vite configs** — ESM (`.js` in `"type":"module"` packages;
|
|
190
|
+
`.mjs` in elsie).
|
|
191
|
+
- **Prettier** — JSON only (`@adobe-commerce/elsie/config/prettier.json`
|
|
192
|
+
referenced via each package's `"prettier"` key). `prettier.config.*` files
|
|
193
|
+
deleted from all packages.
|
|
107
194
|
- **elsie CLI** (`bin/**`) — intentionally stays CommonJS.
|
|
108
195
|
|
|
109
196
|
See `architecture/decisions/009-module-format.md` for the full convention.
|
|
110
197
|
|
|
111
198
|
### `.elsie.js` → `.elsie.cjs`
|
|
112
199
|
|
|
113
|
-
The consumer project config file is renamed from `.elsie.js` to `.elsie.cjs`.
|
|
200
|
+
The consumer project config file is renamed from `.elsie.js` to `.elsie.cjs`.
|
|
201
|
+
With `"type":"module"` now required in consumer packages, a plain `.js` file
|
|
202
|
+
is treated as ES module — making `module.exports` a SyntaxError and making
|
|
203
|
+
`require()` in the elsie CLI fail with `ERR_REQUIRE_ESM`. The `.cjs` extension
|
|
204
|
+
forces CommonJS regardless of the package's `"type"` field.
|
|
114
205
|
|
|
115
206
|
- `elsie generate config` now writes `.elsie.cjs`.
|
|
116
|
-
- The CLI (`bin/lib/config.js`) and `config/vite.mjs` both prefer `.elsie.cjs`
|
|
207
|
+
- The CLI (`bin/lib/config.js`) and `config/vite.mjs` both prefer `.elsie.cjs`
|
|
208
|
+
and fall back to `.elsie.js` for packages not yet migrated.
|
|
117
209
|
- `.elsie.cjs` added to `.npmignore` in all consumer packages.
|
|
118
210
|
|
|
119
211
|
## Consumer migration
|
|
@@ -121,12 +213,16 @@
|
|
|
121
213
|
See `docs/elsie-v2-migration.md` for the full step-by-step guide. Key actions:
|
|
122
214
|
|
|
123
215
|
1. Add `"type": "module"` to `package.json`.
|
|
124
|
-
2. Replace `.eslintrc.js` with `eslint.config.js` (ESM flat config importing
|
|
216
|
+
2. Replace `.eslintrc.js` with `eslint.config.js` (ESM flat config importing
|
|
217
|
+
from `@adobe-commerce/elsie/config/eslint.mjs`).
|
|
125
218
|
3. Rename `.elsie.js` → `.elsie.cjs` (keep `module.exports` content as-is).
|
|
126
|
-
4. Add `"prettier": "@adobe-commerce/elsie/config/prettier.json"` to
|
|
127
|
-
|
|
219
|
+
4. Add `"prettier": "@adobe-commerce/elsie/config/prettier.json"` to
|
|
220
|
+
`package.json`; delete `prettier.config.js`.
|
|
221
|
+
5. Update `tsconfig.json`: remove `baseUrl`, add explicit `rootDir` and
|
|
222
|
+
`types`.
|
|
128
223
|
6. Add `tsconfig.build.json` for declaration emit (required by `dtsPlugin`).
|
|
129
|
-
7. Convert `.elsie.js` imports in `.storybook/main.js` and
|
|
224
|
+
7. Convert `.elsie.js` imports in `.storybook/main.js` and
|
|
225
|
+
`storybook-stories.js` to reference `.elsie.cjs`.
|
|
130
226
|
|
|
131
227
|
## 1.3.0
|
|
132
228
|
|
|
@@ -134,7 +230,10 @@
|
|
|
134
230
|
|
|
135
231
|
- af62897: Update minimum Node.js requirement to 22 LTS
|
|
136
232
|
|
|
137
|
-
Packages are now built with Node.js 22. `elsie` requires `>=22`; browser-only
|
|
233
|
+
Packages are now built with Node.js 22. `elsie` requires `>=22`; browser-only
|
|
234
|
+
packages (`fetch-graphql`, `event-bus`, `recaptcha`, `storefront-design`,
|
|
235
|
+
`build-tools`) do not declare an `engines` field as they do not run in
|
|
236
|
+
Node.js.
|
|
138
237
|
|
|
139
238
|
## 1.3.0-beta.1
|
|
140
239
|
|
|
@@ -142,7 +241,10 @@
|
|
|
142
241
|
|
|
143
242
|
- af62897: Update minimum Node.js requirement to 22 LTS
|
|
144
243
|
|
|
145
|
-
Packages are now built with Node.js 22. `elsie` requires `>=22`; browser-only
|
|
244
|
+
Packages are now built with Node.js 22. `elsie` requires `>=22`; browser-only
|
|
245
|
+
packages (`fetch-graphql`, `event-bus`, `recaptcha`, `storefront-design`,
|
|
246
|
+
`build-tools`) do not declare an `engines` field as they do not run in
|
|
247
|
+
Node.js.
|
|
146
248
|
|
|
147
249
|
## 1.3.0-beta.0
|
|
148
250
|
|
|
@@ -150,4 +252,7 @@
|
|
|
150
252
|
|
|
151
253
|
- f55a79c: Migrate to Node.js 24 LTS
|
|
152
254
|
|
|
153
|
-
Minimum required Node.js version is now 24. Updated `engines.node` from
|
|
255
|
+
Minimum required Node.js version is now 24. Updated `engines.node` from
|
|
256
|
+
`>=16`/`>=18` to `>=24` across all packages. Regenerated lockfile under
|
|
257
|
+
Node 24. Updated CI workflows to use `storefront-workflows@v6` with Node 24
|
|
258
|
+
support.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
ADOBE SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT
|
|
2
|
+
Effective Date: first date you use the SDK
|
|
3
|
+
|
|
4
|
+
The SDK is licensed to you subject to the terms and conditions below which form
|
|
5
|
+
a binding agreement between you and Adobe. By downloading, installing, or making
|
|
6
|
+
use of any portion of the SDK, you are agreeing to the following terms and
|
|
7
|
+
conditions. If you do not agree to the terms and conditions below, do not use
|
|
8
|
+
the SDK. If you agree to be bound by this agreement on behalf of your employer
|
|
9
|
+
or other entity, you must have the legal authority to do so. If you are not
|
|
10
|
+
authorized to so bind your employer or such entity, do not use the SDK.
|
|
11
|
+
|
|
12
|
+
AGREED TERMS AND CONDITIONS
|
|
13
|
+
|
|
14
|
+
1. DEFINITIONS.
|
|
15
|
+
|
|
16
|
+
1.1 “Adobe” means collectively, Adobe Inc., a company incorporated in
|
|
17
|
+
Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose,
|
|
18
|
+
California USA 95110-2704, U.S.A. (“Adobe US”) and Adobe Systems Software
|
|
19
|
+
Ireland, company incorporated in Ireland, having a place of business 4-6
|
|
20
|
+
Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland (“Adobe
|
|
21
|
+
Ireland”).
|
|
22
|
+
|
|
23
|
+
1.2 “Adobe Product(s)” means software applications, programs and other
|
|
24
|
+
technologies not included in or with the SDK which are or may be made
|
|
25
|
+
generally available by Adobe for licensing. This agreement does not govern
|
|
26
|
+
use of Adobe Products.
|
|
27
|
+
|
|
28
|
+
1.3 “Developer Product(s)” means any software application(s), program(s) and
|
|
29
|
+
other teconolog(y/ies) you develop with use of the SDK to function or
|
|
30
|
+
interoperate with Adobe Products.
|
|
31
|
+
|
|
32
|
+
1.4 “Intellectual Property Rights” means copyright, moral rights, trademark,
|
|
33
|
+
trade dress, patent, trade secret, unfair competition, and any other
|
|
34
|
+
intellectual and proprietary rights.
|
|
35
|
+
|
|
36
|
+
1.5 “SDK” or “Software Development Kit” means all items comprising the
|
|
37
|
+
software development kit and all associated materials licensed to you by
|
|
38
|
+
Adobe as part of the SDK, including all SDK system files, tools, programs
|
|
39
|
+
and utilities, as well as any plug-ins or other application programming
|
|
40
|
+
interfaces, header or JAR files (“API”), sample images, sounds, or similar
|
|
41
|
+
assets (“Content Files”), software code samples, runtimes and libraries,
|
|
42
|
+
including any portion(s) that is modified by you, or merged or incorporated
|
|
43
|
+
with your Developer Products (“Sample Code”), and any related documentation,
|
|
44
|
+
technical specifications, notes and explanatory materials, as well any
|
|
45
|
+
modifications, updates, upgrades, or copies of, any of the foregoing items,
|
|
46
|
+
that may be made available by Adobe.
|
|
47
|
+
|
|
48
|
+
2. LICENSES GRANTED TO YOU.
|
|
49
|
+
|
|
50
|
+
2.1 SDK. Subject to your compliance with terms of this agreement, Adobe
|
|
51
|
+
grants to you a non-exclusive, non-sublicensable, non-transferable license
|
|
52
|
+
to install and use the SDK solely for your internal design, development and
|
|
53
|
+
testing of your Developer Products, subject further to the requirements and
|
|
54
|
+
limitations below.
|
|
55
|
+
|
|
56
|
+
2.2 API. Subject to your compliance with terms of this agreement, Adobe
|
|
57
|
+
grants to you a non-exclusive, non-sublicensable, non-transferable license
|
|
58
|
+
to use the API only as provided in or by the applicable specification and to
|
|
59
|
+
distribute the API solely in, with, and on the same media as, your Developer
|
|
60
|
+
Products. For clarification, you may not modify the API.
|
|
61
|
+
|
|
62
|
+
2.3 Content Files. You may not use, modify, reproduce or distribute any of
|
|
63
|
+
the Content Files. For the avoidance of doubt, the Content Files are
|
|
64
|
+
included as examples only. You acquire no rights to the Content Files.
|
|
65
|
+
|
|
66
|
+
2.4 Sample Code. Subject to your compliance with terms of this agreement,
|
|
67
|
+
Adobe grants to you a non-exclusive, non-sublicensable, non-transferable
|
|
68
|
+
license to use, modify, merge, and redistribute (in object code form only)
|
|
69
|
+
all or any portions of the Sample Code solely as part of, and as necessary
|
|
70
|
+
to properly implement, the SDK in your Developer Products. All and any
|
|
71
|
+
portion of the Sample code that is modified or merged by you in your
|
|
72
|
+
Developer Products is subject to the terms of this agreement.
|
|
73
|
+
|
|
74
|
+
3. SCOPE OF LICENSE; LIMITATIONS AND RESTRICTIONS
|
|
75
|
+
|
|
76
|
+
3.1 You may not distribute the SDK or any of its component parts to
|
|
77
|
+
interoperate with or to run on a platform other than the Adobe-approved
|
|
78
|
+
platform.
|
|
79
|
+
|
|
80
|
+
3.2 Third-Party Software. The SDK may contain third-party software, subject
|
|
81
|
+
to additional terms and conditions; and
|
|
82
|
+
|
|
83
|
+
3.3 You may not modify, port, adapt, creative derivate works, redistribute,
|
|
84
|
+
or translate any portion of this SDK; or add or delete any SDK program files
|
|
85
|
+
that would in any way result in modifying the functionality or appearance of
|
|
86
|
+
any element of the Adobe Products.
|
|
87
|
+
|
|
88
|
+
3.4 You may not reverse engineer, decompile, disassemble, or otherwise
|
|
89
|
+
attempt to discover the source code of, any portion of the SDK, except and
|
|
90
|
+
only to the extent that applicable laws of the jurisdiction where you are
|
|
91
|
+
located grant you the right to decompile SDK in order to obtain information
|
|
92
|
+
necessary to render the SDK interoperable with other software; in which case
|
|
93
|
+
you must first request the information from Adobe in writing and Adobe may,
|
|
94
|
+
in its discretion, either provide such information to you or impose
|
|
95
|
+
reasonable conditions, including reasonable fees, on your use of the SDK
|
|
96
|
+
software to ensure that Adobe’s and its licensors’ Intellectual Proprietary
|
|
97
|
+
Rights in the SDK are protected.
|
|
98
|
+
|
|
99
|
+
3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell,
|
|
100
|
+
resale, sublicense, assign or transfer all, or any component parts of the
|
|
101
|
+
SDK, or any of your rights in the SDK, nor authorize any portion of the SDK
|
|
102
|
+
to be copied onto another’s device, computer or platform, including on a
|
|
103
|
+
service bureau basis to other providers (i.e., volume printing, banking,
|
|
104
|
+
payroll service providers, etc) who provide you free or fee-based business
|
|
105
|
+
services.
|
|
106
|
+
|
|
107
|
+
4. VIRAL OPEN SOURCE SOFTWARE AND SERVICES
|
|
108
|
+
|
|
109
|
+
You are not license to (and you agree that you will not) merge, integrate or
|
|
110
|
+
use the SDK with any Viral Open Source Software or Viral Service, or
|
|
111
|
+
otherwise take any action that could require disclosure, distribution, or
|
|
112
|
+
licensing of all or any part of the SDK in source code form for any purpose
|
|
113
|
+
whatsoever. For purposes of this Section, “Viral Open Source Software” means
|
|
114
|
+
software licensed under the GNU General Public License, the GNU Affero
|
|
115
|
+
General Public License (AGPL), the GNU Lesser General Public License (LGPL),
|
|
116
|
+
or any other license terms that would require, or condition your use,
|
|
117
|
+
modification, or distribution of such licensed software on the disclosure,
|
|
118
|
+
distribution, or licensing of any other software in source code form, for
|
|
119
|
+
the purpose of making derivative works, or at no charge, and “Viral Service”
|
|
120
|
+
means any service that contains any viruses, Trojan horses, worms, time
|
|
121
|
+
bombs, cancelbots or other computer programming routines that are intended
|
|
122
|
+
to damage, detrimentally interfere with, surreptitiously intercept,
|
|
123
|
+
expropriate or deprive owners’ possession of any system, data or personal
|
|
124
|
+
information, or that in any way violates any law, statute, ordinance,
|
|
125
|
+
regulation or rights (including any law, regulations or rights respecting
|
|
126
|
+
intellectual property, computer spyware, privacy, export control, unfair
|
|
127
|
+
competition, antidiscrimination or false advertising), or otherwise
|
|
128
|
+
interferes with the operability of Adobe Products or third-party programs or
|
|
129
|
+
software.
|
|
130
|
+
|
|
131
|
+
5. NON-BLOCKING OF ADOBE DEVELOPMENT
|
|
132
|
+
|
|
133
|
+
You acknowledge that Adobe is currently developing or may develop
|
|
134
|
+
technologies and Adobe Products in the future that have, or may have, design
|
|
135
|
+
or functionality similar to Developer Products that you may develop based on
|
|
136
|
+
the license granted to you in this agreement. Nothing in this agreement will
|
|
137
|
+
impair, limit or curtail Adobe’s right to continue with its development,
|
|
138
|
+
maintenance or distribution of Adobe Products. You agree that you will not
|
|
139
|
+
assert in any way any patent owned by you arising out of or in connection
|
|
140
|
+
with your use of the SDK, or any SDK modifications made by you, against
|
|
141
|
+
Adobe, its customers, subsidiaries or affiliates, or any of their customers,
|
|
142
|
+
direct or indirect, agents and contractors for the manufacture, use, import,
|
|
143
|
+
license, offer for sale, or sale of any Adobe Products.
|
|
144
|
+
|
|
145
|
+
6. OWNERSHIP; INTELLECTUAL PROPERTY RIGHTS
|
|
146
|
+
|
|
147
|
+
6.1 The items contained in the SDK are the Intellectual Property of Adobe
|
|
148
|
+
and its licensors and are protected by United States copyright and patent
|
|
149
|
+
law, international treaty provisions and applicable laws of the country in
|
|
150
|
+
which it is being used. Adobe and its licensors reserve all rights not
|
|
151
|
+
expressly granted to you under this agreement, and retain all right, title,
|
|
152
|
+
and interest in the SDK, including all Intellectual Property Rights.
|
|
153
|
+
|
|
154
|
+
6.2 The SDK, or any of its component parts, may be supplied to you with
|
|
155
|
+
certain accompanying proprietary notices, including patent, copyright and
|
|
156
|
+
trademark notices. You agree to protect all copyright and other ownership
|
|
157
|
+
interests of Adobe and its licensors in the SDK supplied to you under this
|
|
158
|
+
agreement; to preserve exactly (and not remove or alter) all proprietary
|
|
159
|
+
notices displayed in or on the SDK; to reproduce the same proprietary
|
|
160
|
+
notices in all copies you make of any portion of the SDK.
|
|
161
|
+
|
|
162
|
+
6.3 You agree to include in your Developer Products Adobe’s copyright
|
|
163
|
+
notices, wherever such notices are customarily posted, in substantially the
|
|
164
|
+
following form: Portions of software used to develop this product
|
|
165
|
+
copyrighted by Adobe and its licensors. All Rights Reserved.
|
|
166
|
+
|
|
167
|
+
6.4 Nothing in this agreement gives you a right to use the name, logo or
|
|
168
|
+
trademarks of Adobe or its licensors to market your Developer Products.
|
|
169
|
+
|
|
170
|
+
7. CONFIDENTIAL INFORMATION
|
|
171
|
+
|
|
172
|
+
With respect to the API, and any portion, included in the SDK (for purposes
|
|
173
|
+
of this Section, “Adobe Confidential Information”), you will treat the Adobe
|
|
174
|
+
Confidential Information, and exercise the same degree of care to protect
|
|
175
|
+
it, as you afford to your own confidential information. Your obligations
|
|
176
|
+
under this Section will terminate when you can document that (a) the Adobe
|
|
177
|
+
Confidential Information was in the public domain at or subsequent to the
|
|
178
|
+
time Adobe communicated or provided it to you with no fault of your own; (b)
|
|
179
|
+
your employees or agents developed independently without reference to any
|
|
180
|
+
Adobe Confidential Information Adobe communicated or provided to you; or (c)
|
|
181
|
+
your communication of Adobe Confidential Information was in response to a
|
|
182
|
+
valid order by a court or other governmental body, was otherwise required by
|
|
183
|
+
law, or was necessary to establish the rights of a party under this
|
|
184
|
+
agreement.
|
|
185
|
+
|
|
186
|
+
8. TERM; TERMINATION
|
|
187
|
+
|
|
188
|
+
This agreement will commence on the Effective Date and will continue unless
|
|
189
|
+
terminated. Adobe may terminate this agreement immediately upon notice to
|
|
190
|
+
you, and without judicial intervention, if you fail to comply with any term
|
|
191
|
+
of its terms. You may terminate this agreement at any time by discontinuing
|
|
192
|
+
all your use(s) of the SDK and you agree to destroying or removing all full
|
|
193
|
+
and partial copies of the SDK from your computer. If requested by Adobe, you
|
|
194
|
+
must demonstrate proof of your compliance with the terms of this Section. In
|
|
195
|
+
the event of termination, the terms of this agreement that, by their nature,
|
|
196
|
+
are meant to survive termination, including all terms relating to viral open
|
|
197
|
+
source software and services, ownership, confidential information, indemnity
|
|
198
|
+
obligations and procedures, disclaimers of warranty, limitations on and
|
|
199
|
+
exclusions of remedies and damages, dispute resolution, and waiver, will
|
|
200
|
+
survive termination of this agreement.
|
|
201
|
+
|
|
202
|
+
9. DISCLAIMER OF WARRANTY; LIMITATION OF LIABILITY
|
|
203
|
+
|
|
204
|
+
You expressly understand and agree that, to the maximum extent permitted by
|
|
205
|
+
applicable law:
|
|
206
|
+
|
|
207
|
+
9.1 Use OF THE SDK is entirely at your own risk. The SDK is provided by
|
|
208
|
+
Adobe “AS-IS” and with all faults. Adobe and its licensors are not liable to
|
|
209
|
+
you or anyone else for any special, incidental, indirect, consequential, or
|
|
210
|
+
punitive damages whatsoever (even if Adobe has been advised of the
|
|
211
|
+
possibility of such damages), including (a) damages resulting from loss of
|
|
212
|
+
use, data, or profits, whether or not foreseeable, (b) damages based on any
|
|
213
|
+
theory of liability, including breach of contract or warranty, negligence or
|
|
214
|
+
other tortious action, or (c) damages arising from any other claim arising
|
|
215
|
+
out of or in connection with your use of the SDK.
|
|
216
|
+
|
|
217
|
+
9.2 Adobe’s total liability in any matter arising out of or related to these
|
|
218
|
+
terms is limited to US $100 or the aggregate amount that you paid for use of
|
|
219
|
+
the SDK during the 12 months prior to the event giving rise to the damages,
|
|
220
|
+
whichever is larger. This limitation will apply even if Adobe has been
|
|
221
|
+
advised of the possibility of such damages and regardless of any failure of
|
|
222
|
+
the essential purpose of any limited remedy.
|
|
223
|
+
|
|
224
|
+
10. INDEMNIFICATION
|
|
225
|
+
|
|
226
|
+
To the maximum extent permitted by law, you agree to indemnify Adobe, its
|
|
227
|
+
subsidiaries, affiliates, officers, agents, employees, partners, licensors,
|
|
228
|
+
or suppliers from any claim or demand, including reasonable attorneys’ fees,
|
|
229
|
+
that arise from the use and distribution of your Developer Products that
|
|
230
|
+
contain or are based upon any portion of the SDK, or from your violation of
|
|
231
|
+
the terms of this agreement.
|
|
232
|
+
|
|
233
|
+
11. DISPUTE RESOLUTION
|
|
234
|
+
|
|
235
|
+
11.1 Choice of Law. If you are a resident of North America (or if your
|
|
236
|
+
organization is headquartered in North America), your relationship is with
|
|
237
|
+
Adobe Inc., a Delaware corporation, and the SDK is governed by the laws of
|
|
238
|
+
California. If you reside outside of North America, your relationship is
|
|
239
|
+
with Adobe Systems Software Ireland Limited, and the SDK is governed by the
|
|
240
|
+
laws of Ireland.
|
|
241
|
+
|
|
242
|
+
11.2 Venue. You agree that any claim or dispute you may have against Adobe
|
|
243
|
+
must be resolved by a court located in Santa Clara County, California when
|
|
244
|
+
the laws of California apply, or Dublin, Ireland, when the laws of Ireland
|
|
245
|
+
apply . You agree to submit to the personal jurisdiction of the courts
|
|
246
|
+
located in Santa Clara County, California, United States of America when the
|
|
247
|
+
laws of California apply, and the courts of Dublin, Ireland, when the laws
|
|
248
|
+
of Ireland applies, for the purpose of litigating such claims or disputes.
|
|
249
|
+
The parties specifically disclaim the U.N. Convention on Contracts for the
|
|
250
|
+
International Sale of Goods.
|
|
251
|
+
|
|
252
|
+
11.3 Injunctive Relief. Notwithstanding the foregoing, in the event of your
|
|
253
|
+
or others’ unauthorized access to or use of the SDK in violation of this
|
|
254
|
+
Agreement, you agree that Adobe is entitled to apply for injunctive remedies
|
|
255
|
+
(or an equivalent type of urgent legal relief) in any jurisdiction.
|
|
256
|
+
|
|
257
|
+
12. EXPORT RULES
|
|
258
|
+
|
|
259
|
+
The SDK and your use of the SDK are subject to U.S. and international laws,
|
|
260
|
+
restrictions, and regulations that may govern the import, export, and use of
|
|
261
|
+
the SDK. You agree to comply with all such laws, restrictions, and
|
|
262
|
+
regulations.
|
|
263
|
+
|
|
264
|
+
13. NOTICE TO U.S. GOVERNMENT END USERS
|
|
265
|
+
|
|
266
|
+
For U.S. Government procurements, the SDK is a commercial computer software
|
|
267
|
+
as defined in FAR 12.212 and subject to restricted rights as defined in FAR
|
|
268
|
+
Section 52.227-19 "Commercial Computer Software - Restricted Rights" and
|
|
269
|
+
DFARS 227.7202, “Rights in Commercial Computer Software or Commercial
|
|
270
|
+
Computer Software Documentation”, as applicable, and any successor
|
|
271
|
+
regulations. Any use, modification, reproduction release, performance,
|
|
272
|
+
display or disclosure of the SDK by the U.S. Government shall be solely in
|
|
273
|
+
accordance with license rights and restrictions described herein.
|
|
274
|
+
|
|
275
|
+
14. GENERAL PROVISIONS
|
|
276
|
+
|
|
277
|
+
14.1 Severability. If it turns out that a particular term is not
|
|
278
|
+
enforceable, the unenforceability of that term will not affect any other
|
|
279
|
+
terms.
|
|
280
|
+
|
|
281
|
+
14.2 Modification; Waiver. No provision of this agreement will be deemed to
|
|
282
|
+
have been modified or waived by any act or acquiescence on the part of
|
|
283
|
+
Adobe, its agents, or employees, but only by any instrument in writing,
|
|
284
|
+
signed by an authorized officer of Adobe.
|
|
285
|
+
|
|
286
|
+
14.3 Entire Agreement. This Agreement is the entire agreement, superseding
|
|
287
|
+
any prior written or oral agreements, between you and Adobe relating to the
|
|
288
|
+
SDK.
|
package/eslint.config.js
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
defineConfig,
|
|
12
|
+
typescript,
|
|
13
|
+
tests,
|
|
14
|
+
} from '@adobe-commerce/elsie/configs/eslint.js';
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
// Runtime-agnostic (no DOM, no Node-specific APIs) — no environment globals.
|
|
17
|
+
export default defineConfig(typescript(), tests());
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe-commerce/fetch-graphql",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2-alpha-20260928110639",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"description": "A library to fetch GraphQL queries and mutations",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
-
"prettier": "@adobe-commerce/elsie/
|
|
8
|
+
"prettier": "@adobe-commerce/elsie/configs/prettier.js",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"typescript": "^6.0.0"
|
|
11
|
+
},
|
|
9
12
|
"scripts": {
|
|
10
|
-
"build": "echo 'No build step required'",
|
|
11
13
|
"lint": "elsie lint",
|
|
12
14
|
"test": "elsie test",
|
|
13
|
-
"test:ci": "elsie test --config jest.config.js --passWithNoTests --coverage"
|
|
15
|
+
"test:ci": "elsie test --config jest.config.js --passWithNoTests --coverage",
|
|
16
|
+
"build": "echo 'No build step required'"
|
|
14
17
|
}
|
|
15
|
-
}
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright 2024 Adobe
|
|
3
3
|
* All Rights Reserved.
|
|
4
4
|
*
|
|
5
|
-
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
-
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
-
* accompanying it.
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
8
|
*******************************************************************/
|
|
9
9
|
|
|
10
10
|
export type Header = { [key: string]: string | null };
|
|
@@ -27,11 +27,15 @@ export type FetchQueryError = Array<{
|
|
|
27
27
|
extensions: { category: string };
|
|
28
28
|
}>;
|
|
29
29
|
|
|
30
|
-
export type BeforeHook = (
|
|
30
|
+
export type BeforeHook = (
|
|
31
|
+
requestInit: RequestInit,
|
|
32
|
+
) => RequestInit | Promise<RequestInit>;
|
|
31
33
|
export type AfterHook<T = any> = (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
) =>
|
|
34
|
+
requestInit: RequestInit,
|
|
35
|
+
response: { errors?: FetchQueryError; data: T },
|
|
36
|
+
) =>
|
|
37
|
+
| { errors?: FetchQueryError; data: T }
|
|
38
|
+
| Promise<{ errors?: FetchQueryError; data: T }>;
|
|
35
39
|
|
|
36
40
|
const defaultHeaders = {
|
|
37
41
|
'Content-Type': 'application/json',
|
|
@@ -106,7 +110,7 @@ class FetchGraphQLMesh {
|
|
|
106
110
|
* ```js
|
|
107
111
|
* // set headers
|
|
108
112
|
* setFetchGraphQlHeaders({ test: 'test' });
|
|
109
|
-
*
|
|
113
|
+
*
|
|
110
114
|
* // merge with previous headers
|
|
111
115
|
* setFetchGraphQlHeaders((prev) => ({
|
|
112
116
|
* ...prev,
|
|
@@ -158,7 +162,7 @@ class FetchGraphQLMesh {
|
|
|
158
162
|
public addAfterHook(hook: AfterHook): void {
|
|
159
163
|
this._afterHooks.push(hook);
|
|
160
164
|
}
|
|
161
|
-
|
|
165
|
+
|
|
162
166
|
/**
|
|
163
167
|
* Collects all before hooks. Can be overridden by subclasses for inheritance.
|
|
164
168
|
* @protected
|
|
@@ -166,7 +170,7 @@ class FetchGraphQLMesh {
|
|
|
166
170
|
protected _collectBeforeHooks(): BeforeHook[] {
|
|
167
171
|
return this._beforeHooks;
|
|
168
172
|
}
|
|
169
|
-
|
|
173
|
+
|
|
170
174
|
/**
|
|
171
175
|
* Collects all after hooks. Can be overridden by subclasses for inheritance.
|
|
172
176
|
* @protected
|
|
@@ -174,7 +178,7 @@ class FetchGraphQLMesh {
|
|
|
174
178
|
protected _collectAfterHooks(): AfterHook[] {
|
|
175
179
|
return this._afterHooks;
|
|
176
180
|
}
|
|
177
|
-
|
|
181
|
+
|
|
178
182
|
/**
|
|
179
183
|
* Fetches GraphQL data.
|
|
180
184
|
* @param query - The GraphQL query.
|
|
@@ -183,7 +187,7 @@ class FetchGraphQLMesh {
|
|
|
183
187
|
*/
|
|
184
188
|
public async fetchGraphQl<T = any>(
|
|
185
189
|
query: string,
|
|
186
|
-
options?: FetchOptions
|
|
190
|
+
options?: FetchOptions,
|
|
187
191
|
): Promise<{ errors?: FetchQueryError; data: T }> {
|
|
188
192
|
const endpoint = this.endpoint;
|
|
189
193
|
const fetchGraphQlHeaders = this.fetchGraphQlHeaders;
|
|
@@ -226,20 +230,24 @@ class FetchGraphQLMesh {
|
|
|
226
230
|
// Collect and execute before hooks
|
|
227
231
|
const allBeforeHooks = this._collectBeforeHooks();
|
|
228
232
|
requestInit = await allBeforeHooks.reduce(
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
async (prev, hook) => hook(await prev),
|
|
234
|
+
Promise.resolve(requestInit),
|
|
231
235
|
);
|
|
232
236
|
|
|
233
237
|
// Collect and execute after hooks
|
|
234
238
|
const allAfterHooks = this._collectAfterHooks();
|
|
235
|
-
return await fetch(url, requestInit).then((r) =>
|
|
236
|
-
|
|
239
|
+
return await fetch(url, requestInit).then((r) =>
|
|
240
|
+
r
|
|
241
|
+
.json()
|
|
242
|
+
.then((response) =>
|
|
243
|
+
allAfterHooks.reduce(
|
|
237
244
|
async (result, hook) => hook(requestInit, await result),
|
|
238
|
-
Promise.resolve(response)
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
Promise.resolve(response),
|
|
246
|
+
),
|
|
247
|
+
),
|
|
248
|
+
);
|
|
241
249
|
}
|
|
242
|
-
|
|
250
|
+
|
|
243
251
|
/**
|
|
244
252
|
* Gets the configuration.
|
|
245
253
|
*/
|
|
@@ -278,7 +286,7 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
278
286
|
private _mode: 'standalone' | 'linked' | 'default' = 'default';
|
|
279
287
|
private _source?: string | FetchGraphQL;
|
|
280
288
|
|
|
281
|
-
get endpoint(): string | undefined {
|
|
289
|
+
override get endpoint(): string | undefined {
|
|
282
290
|
switch (this._mode) {
|
|
283
291
|
case 'standalone':
|
|
284
292
|
return this._source as string;
|
|
@@ -289,7 +297,7 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
289
297
|
}
|
|
290
298
|
}
|
|
291
299
|
|
|
292
|
-
get fetchGraphQlHeaders(): Header {
|
|
300
|
+
override get fetchGraphQlHeaders(): Header {
|
|
293
301
|
switch (this._mode) {
|
|
294
302
|
case 'standalone':
|
|
295
303
|
// Standalone instance - only use own headers
|
|
@@ -313,16 +321,16 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
313
321
|
* ```js
|
|
314
322
|
* // Set endpoint as string
|
|
315
323
|
* instance.setEndpoint('https://api.example.com/graphql');
|
|
316
|
-
*
|
|
324
|
+
*
|
|
317
325
|
* // Link to another instance
|
|
318
326
|
* const parent = new FetchGraphQL();
|
|
319
327
|
* parent.setEndpoint('https://api.example.com/graphql');
|
|
320
|
-
*
|
|
328
|
+
*
|
|
321
329
|
* const child = new FetchGraphQL();
|
|
322
330
|
* child.setEndpoint(parent); // Links to parent, shares endpoint, headers, and hooks
|
|
323
331
|
* ```
|
|
324
332
|
*/
|
|
325
|
-
public setEndpoint(endpoint: string | FetchGraphQL): void {
|
|
333
|
+
public override setEndpoint(endpoint: string | FetchGraphQL): void {
|
|
326
334
|
if (endpoint instanceof FetchGraphQL) {
|
|
327
335
|
// Link to another instance
|
|
328
336
|
this._mode = 'linked';
|
|
@@ -339,7 +347,10 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
339
347
|
* @param key - The key of the header.
|
|
340
348
|
* @param value - The value of the header.
|
|
341
349
|
*/
|
|
342
|
-
public setFetchGraphQlHeader(
|
|
350
|
+
public override setFetchGraphQlHeader(
|
|
351
|
+
key: string,
|
|
352
|
+
value: string | null,
|
|
353
|
+
): void {
|
|
343
354
|
if (this._mode === 'linked') {
|
|
344
355
|
// Delegate to linked instance
|
|
345
356
|
(this._source as FetchGraphQL).setFetchGraphQlHeader(key, value);
|
|
@@ -353,7 +364,9 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
353
364
|
* Sets the GraphQL headers. When linked to another instance, this sets the headers on the linked instance.
|
|
354
365
|
* @param header - The header object or a function that returns a header object.
|
|
355
366
|
*/
|
|
356
|
-
public setFetchGraphQlHeaders(
|
|
367
|
+
public override setFetchGraphQlHeaders(
|
|
368
|
+
header: Header | ((prev: Header) => Header),
|
|
369
|
+
): void {
|
|
357
370
|
if (this._mode === 'linked') {
|
|
358
371
|
// Delegate to linked instance
|
|
359
372
|
(this._source as FetchGraphQL).setFetchGraphQlHeaders(header);
|
|
@@ -367,7 +380,7 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
367
380
|
* Removes a specific GraphQL header. When linked to another instance, this removes the header from the linked instance.
|
|
368
381
|
* @param key - The key of the header.
|
|
369
382
|
*/
|
|
370
|
-
public removeFetchGraphQlHeader(key: string): void {
|
|
383
|
+
public override removeFetchGraphQlHeader(key: string): void {
|
|
371
384
|
if (this._mode === 'linked') {
|
|
372
385
|
// Delegate to linked instance
|
|
373
386
|
(this._source as FetchGraphQL).removeFetchGraphQlHeader(key);
|
|
@@ -382,7 +395,9 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
382
395
|
* @param key - The key of the header.
|
|
383
396
|
* @returns The value of the header, or undefined if not found.
|
|
384
397
|
*/
|
|
385
|
-
public getFetchGraphQlHeader(
|
|
398
|
+
public override getFetchGraphQlHeader(
|
|
399
|
+
key: string,
|
|
400
|
+
): string | null | undefined {
|
|
386
401
|
if (this._mode === 'linked') {
|
|
387
402
|
// Delegate to linked instance
|
|
388
403
|
return (this._source as FetchGraphQL).getFetchGraphQlHeader(key);
|
|
@@ -395,7 +410,7 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
395
410
|
* Adds a before hook. When linked to another instance, this adds the hook to the linked instance.
|
|
396
411
|
* @param hook - The hook function.
|
|
397
412
|
*/
|
|
398
|
-
public addBeforeHook(hook: BeforeHook): void {
|
|
413
|
+
public override addBeforeHook(hook: BeforeHook): void {
|
|
399
414
|
if (this._mode === 'linked') {
|
|
400
415
|
// Delegate to linked instance
|
|
401
416
|
(this._source as FetchGraphQL).addBeforeHook(hook);
|
|
@@ -409,7 +424,7 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
409
424
|
* Adds an after hook. When linked to another instance, this adds the hook to the linked instance.
|
|
410
425
|
* @param hook - The hook function.
|
|
411
426
|
*/
|
|
412
|
-
public addAfterHook(hook: AfterHook): void {
|
|
427
|
+
public override addAfterHook(hook: AfterHook): void {
|
|
413
428
|
if (this._mode === 'linked') {
|
|
414
429
|
// Delegate to linked instance
|
|
415
430
|
(this._source as FetchGraphQL).addAfterHook(hook);
|
|
@@ -423,18 +438,18 @@ export class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
423
438
|
* Collects all before hooks. When linked, delegates to the linked instance.
|
|
424
439
|
* @protected
|
|
425
440
|
*/
|
|
426
|
-
protected _collectBeforeHooks(): BeforeHook[] {
|
|
441
|
+
protected override _collectBeforeHooks(): BeforeHook[] {
|
|
427
442
|
if (this._mode === 'linked') {
|
|
428
443
|
return (this._source as FetchGraphQL)._collectBeforeHooks();
|
|
429
444
|
}
|
|
430
445
|
return this._beforeHooks;
|
|
431
446
|
}
|
|
432
|
-
|
|
447
|
+
|
|
433
448
|
/**
|
|
434
449
|
* Collects all after hooks. When linked, delegates to the linked instance.
|
|
435
450
|
* @protected
|
|
436
451
|
*/
|
|
437
|
-
protected _collectAfterHooks(): AfterHook[] {
|
|
452
|
+
protected override _collectAfterHooks(): AfterHook[] {
|
|
438
453
|
if (this._mode === 'linked') {
|
|
439
454
|
return (this._source as FetchGraphQL)._collectAfterHooks();
|
|
440
455
|
}
|