@shopware/api-client
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "@shopware/api-client", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Shopware client for API connection.", | ||
@@ -21,9 +21,20 @@ "author": "Shopware", | ||
"module": "./dist/index.mjs", | ||
"main": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"api-types" | ||
"api-types", | ||
"admin-api-types" | ||
], | ||
"exports": { | ||
"import": "./dist/index.mjs" | ||
".": { | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
}, | ||
"import": { | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
} | ||
} | ||
}, | ||
@@ -33,10 +44,11 @@ "devDependencies": { | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"prettier": "^3.0.0", | ||
"vitest": "^0.33.0", | ||
"@shopware/api-gen": "0.0.6", | ||
"eslint-config-shopware": "0.0.5", | ||
"prettier": "^3.0.3", | ||
"unbuild": "^2.0.0", | ||
"vitest": "^0.34.3", | ||
"@shopware/api-gen": "0.0.7", | ||
"eslint-config-shopware": "0.0.6", | ||
"tsconfig": "0.0.0" | ||
}, | ||
"dependencies": { | ||
"ofetch": "^1.1.1" | ||
"ofetch": "^1.3.3" | ||
}, | ||
@@ -43,0 +55,0 @@ "scripts": { |
@@ -53,3 +53,2 @@ # shopware/frontends - api-client | ||
contextToken: Cookies.get("sw-context-token"), | ||
apiType: "store-api", | ||
onContextChanged(newContextToken) { | ||
@@ -74,2 +73,43 @@ Cookies.set("sw-context-token", newContextToken, { | ||
## Admin API client setup | ||
The setup works the same way as `creteAPIClient` function, with few differences: | ||
```typescript | ||
// example adminApiClient.ts file | ||
import { createAdminAPIClient } from "@shopware/api-client"; // we use different function to create admin api client | ||
import { | ||
RequestParameters, | ||
RequestReturnType, | ||
createAdminAPIClient, | ||
} from "@shopware/api-client"; | ||
import { | ||
operationPaths, | ||
operations, | ||
components, | ||
} from "@shopware/api-client/admin-api-types"; // we take default admin api types from different directory than store-api | ||
import Cookies from "js-cookie"; | ||
export const adminApiClient = createAdminAPIClient<operations, operationPaths>({ | ||
baseURL: "https://demo-frontends.shopware.store/api", | ||
sessionData: JSON.parse(Cookies.get("sw-admin-session-data") || "{}"), | ||
onAuthChange(sessionData) { | ||
Cookies.set("sw-admin-session-data", JSON.stringify(sessionData), { | ||
expires: 1, // days | ||
path: "/", | ||
sameSite: "lax", | ||
}); | ||
}, | ||
}); | ||
export type AdminApiSchemas = components["schemas"]; | ||
export type AdminApiRequestParams<OPERATION_NAME extends keyof operations> = | ||
RequestParameters<OPERATION_NAME, operations>; | ||
export type AdminApiReturnType<OPERATION_NAME extends keyof operations> = | ||
RequestReturnType<OPERATION_NAME, operations>; | ||
``` | ||
the rest works the same as store-api client. | ||
## Basic usage | ||
@@ -151,6 +191,22 @@ | ||
### Latest changes: 0.3.0 | ||
### Latest changes: 0.4.0 | ||
### Minor Changes | ||
- [#330](https://github.com/shopware/frontends/pull/330) [`3683116`](https://github.com/shopware/frontends/commit/3683116588a7ef75e750fc33deee119f038c88e8) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Add `setCurrentCountry` for changing context countryId | ||
- [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - New method `createAdminAPIClient` supporting Admin API π °π Ώπ Έ | ||
- [#373](https://github.com/shopware/frontends/pull/373) [`5510bb02`](https://github.com/shopware/frontends/commit/5510bb028b1fea4c63d677850f50bb7b5a1cf01a) Thanks [@patzick](https://github.com/patzick)! - Added `getSessionData` and `setSessionData` methods in admin API client for test purposes. | ||
### Patch Changes | ||
- [#385](https://github.com/shopware/frontends/pull/385) [`5d7e7973`](https://github.com/shopware/frontends/commit/5d7e7973437a4d74d19ec2fa0765c6d927bf8b2a) Thanks [@patzick](https://github.com/patzick)! - Dependency changes: | ||
- Changed dependency _ofetch_ from **^1.2.1** to **^1.3.3** | ||
- [#375](https://github.com/shopware/frontends/pull/375) [`bd88d6fa`](https://github.com/shopware/frontends/commit/bd88d6fa95de2b90f8a1e08e34159b46c5932b3b) Thanks [@patzick](https://github.com/patzick)! - Dependency changes: | ||
- Changed dependency _ofetch_ from **^1.1.1** to **^1.2.1** | ||
- [`15d6e696`](https://github.com/shopware/frontends/commit/15d6e69616bd9bc5ad32f2a5f697e00c45a94784) Thanks [@patzick](https://github.com/patzick)! - Emit cjs bundle | ||
- [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - Deprecated `apiType` param in `createAPIClient`, for Admin API client use `createAdminAPIClient` instead. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15190597
23
335630
210
8
Updatedofetch@^1.3.3