@shopware/api-client 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/api-types/adminApiTypes.d.ts +1 -1
- package/api-types/storeApiSchema.json +1372 -377
- package/api-types/storeApiSchema.overrides.json +346 -0
- package/api-types/storeApiTypes.d.ts +916 -393
- package/api-types/storeApiTypes.overrides.ts +2 -117
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +1022 -496
- package/dist/index.d.mts +1022 -496
- package/dist/index.d.ts +1022 -496
- package/dist/index.mjs +7 -5
- package/package.json +8 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { components as mainComponents } from "./storeApiTypes";
|
|
1
|
+
import type { components as mainComponents } from "./storeApiTypes";
|
|
2
2
|
|
|
3
3
|
export type components = mainComponents;
|
|
4
4
|
// & {
|
|
@@ -43,121 +43,6 @@ export type Schemas = {
|
|
|
43
43
|
entity?: "product";
|
|
44
44
|
sorting?: string;
|
|
45
45
|
};
|
|
46
|
-
SwagPaypalVaultToken: {
|
|
47
|
-
// TODO: [OpenAPI][SwagPaypalVaultToken] - add SwagPaypalVaultToken definition to schema
|
|
48
|
-
/** Format: date-time */
|
|
49
|
-
createdAt: string;
|
|
50
|
-
customer?: components["schemas"]["Customer"];
|
|
51
|
-
customerId: string;
|
|
52
|
-
id?: string;
|
|
53
|
-
identifier: string;
|
|
54
|
-
mainMapping?: components["schemas"]["SwagPaypalVaultTokenMapping"];
|
|
55
|
-
paymentMethod?: components["schemas"]["PaymentMethod"];
|
|
56
|
-
paymentMethodId: string;
|
|
57
|
-
/** Format: date-time */
|
|
58
|
-
updatedAt?: string;
|
|
59
|
-
};
|
|
60
46
|
};
|
|
61
47
|
|
|
62
|
-
export type operations = {
|
|
63
|
-
"register post /account/register": {
|
|
64
|
-
contentType?: "application/json";
|
|
65
|
-
accept?: "application/json";
|
|
66
|
-
body: {
|
|
67
|
-
/** Flag indicating accepted data protection */
|
|
68
|
-
acceptedDataProtection: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Account type of the customer which can be either `private` or `business`.
|
|
71
|
-
* @default private
|
|
72
|
-
*/
|
|
73
|
-
accountType?: string;
|
|
74
|
-
/** Field can be used to store an affiliate tracking code */
|
|
75
|
-
affiliateCode?: string;
|
|
76
|
-
billingAddress: Omit<
|
|
77
|
-
components["schemas"]["CustomerAddress"],
|
|
78
|
-
"createdAt" | "id" | "customerId" | "firstName" | "lastName"
|
|
79
|
-
>; // TODO: [OpenAPI][register] - omit id, createdAt, customerId, firstName, lastName while creating address (or better to reverse and pick required fields)
|
|
80
|
-
/** Birthday day */
|
|
81
|
-
birthdayDay?: number;
|
|
82
|
-
/** Birthday month */
|
|
83
|
-
birthdayMonth?: number;
|
|
84
|
-
/** Birthday year */
|
|
85
|
-
birthdayYear?: number;
|
|
86
|
-
/** Field can be used to store a campaign tracking code */
|
|
87
|
-
campaignCode?: string;
|
|
88
|
-
/** Email of the customer. Has to be unique, unless `guest` is `true` */
|
|
89
|
-
email: string;
|
|
90
|
-
/** Customer first name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
91
|
-
firstName: string;
|
|
92
|
-
/**
|
|
93
|
-
* If set, will create a guest customer. Guest customers can re-use an email address and don't need a password.
|
|
94
|
-
* @default false
|
|
95
|
-
*/
|
|
96
|
-
guest?: boolean;
|
|
97
|
-
/** Customer last name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
98
|
-
lastName: string;
|
|
99
|
-
/** Password for the customer. Required, unless `guest` is `true` */
|
|
100
|
-
password: string;
|
|
101
|
-
/** Id of the salutation for the customer account. Fetch options using `salutation` endpoint. */
|
|
102
|
-
salutationId: string;
|
|
103
|
-
shippingAddress?: components["schemas"]["CustomerAddress"];
|
|
104
|
-
/** URL of the storefront for that registration. Used in confirmation emails. Has to be one of the configured domains of the sales channel. */
|
|
105
|
-
storefrontUrl: string;
|
|
106
|
-
/** (Academic) title of the customer */
|
|
107
|
-
title?: string;
|
|
108
|
-
};
|
|
109
|
-
response: components["schemas"]["Customer"];
|
|
110
|
-
responseCode: 200;
|
|
111
|
-
};
|
|
112
|
-
"updateLineItem patch /checkout/cart/line-item": {
|
|
113
|
-
contentType?: "application/json";
|
|
114
|
-
accept?: "application/json";
|
|
115
|
-
headers?: {
|
|
116
|
-
/** Instructs Shopware to return the response in the given language. */
|
|
117
|
-
"sw-language-id"?: string;
|
|
118
|
-
};
|
|
119
|
-
body: {
|
|
120
|
-
// TODO: [OpenAPI][updateLineItem] - add proper request body type with required fields
|
|
121
|
-
items: Array<{
|
|
122
|
-
id: string;
|
|
123
|
-
quantity: number;
|
|
124
|
-
}>;
|
|
125
|
-
};
|
|
126
|
-
response: components["schemas"]["Cart"];
|
|
127
|
-
responseCode: 200;
|
|
128
|
-
};
|
|
129
|
-
"readProduct post /product": {
|
|
130
|
-
contentType?: "application/json";
|
|
131
|
-
accept?: "application/json";
|
|
132
|
-
headers?: {
|
|
133
|
-
/** Instructs Shopware to return the response in the given language. */
|
|
134
|
-
"sw-language-id"?: string;
|
|
135
|
-
};
|
|
136
|
-
body?: components["schemas"]["Criteria"];
|
|
137
|
-
response: {
|
|
138
|
-
elements: components["schemas"]["Product"][]; // TODO: [OpenAPI][readProduct]: add elements property as required
|
|
139
|
-
} & components["schemas"]["EntitySearchResult"];
|
|
140
|
-
responseCode: 200;
|
|
141
|
-
};
|
|
142
|
-
"readShippingMethod post /shipping-method": {
|
|
143
|
-
contentType?: "application/json";
|
|
144
|
-
accept?: "application/json";
|
|
145
|
-
headers?: {
|
|
146
|
-
/** Instructs Shopware to return the response in the given language. */
|
|
147
|
-
"sw-language-id"?: string;
|
|
148
|
-
};
|
|
149
|
-
query?: {
|
|
150
|
-
/** List only available shipping methods. This filters shipping methods methods which can not be used in the actual context because of their availability rule. */
|
|
151
|
-
onlyAvailable?: boolean;
|
|
152
|
-
};
|
|
153
|
-
body?: components["schemas"]["Criteria"];
|
|
154
|
-
response: {
|
|
155
|
-
/** aggregation result */
|
|
156
|
-
aggregations?: Record<string, never>;
|
|
157
|
-
elements: components["schemas"]["ShippingMethod"][]; // TODO: [OpenAPI][readShippingMethod]: response should be `EntitySearchResult` and elements should be required
|
|
158
|
-
/** Total amount */
|
|
159
|
-
total?: number;
|
|
160
|
-
};
|
|
161
|
-
responseCode: 200;
|
|
162
|
-
};
|
|
163
|
-
};
|
|
48
|
+
// export type operations = {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const ofetch = require('ofetch');
|
|
4
|
-
const hookable = require('hookable');
|
|
5
3
|
const defu = require('defu');
|
|
4
|
+
const hookable = require('hookable');
|
|
5
|
+
const ofetch = require('ofetch');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
8
|
|
|
@@ -130,13 +130,14 @@ function createAPIClient(params) {
|
|
|
130
130
|
},
|
|
131
131
|
(key, value) => {
|
|
132
132
|
apiClientHooks.callHook("onDefaultHeaderChanged", key, value);
|
|
133
|
-
if (key === "sw-context-token") {
|
|
133
|
+
if (key === "sw-context-token" && value) {
|
|
134
134
|
apiClientHooks.callHook("onContextChanged", value);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
const apiFetch = ofetch.ofetch.create({
|
|
139
139
|
baseURL: params.baseURL,
|
|
140
|
+
...params.fetchOptions,
|
|
140
141
|
// async onRequest({ request, options }) {},
|
|
141
142
|
// async onRequestError({ request, options, error }) {},
|
|
142
143
|
async onResponse(context) {
|
|
@@ -163,9 +164,9 @@ function createAPIClient(params) {
|
|
|
163
164
|
const fetchOptions = {
|
|
164
165
|
...currentParams.fetchOptions || {}
|
|
165
166
|
};
|
|
166
|
-
|
|
167
|
+
const mergedHeaders = defu__default(currentParams.headers, defaultHeaders);
|
|
167
168
|
if (mergedHeaders?.["Content-Type"]?.includes("multipart/form-data") && typeof window !== "undefined") {
|
|
168
|
-
|
|
169
|
+
mergedHeaders["Content-Type"] = void 0;
|
|
169
170
|
}
|
|
170
171
|
const resp = await apiFetch.raw(requestPathWithParams, {
|
|
171
172
|
...fetchOptions,
|
|
@@ -237,6 +238,7 @@ function createAdminAPIClient(params) {
|
|
|
237
238
|
}
|
|
238
239
|
const apiFetch = ofetch.ofetch.create({
|
|
239
240
|
baseURL: params.baseURL,
|
|
241
|
+
...params.fetchOptions,
|
|
240
242
|
async onRequest({ request, options }) {
|
|
241
243
|
const isExpired = sessionData.expirationTime <= Date.now();
|
|
242
244
|
if (isExpired && !request.toString().includes("/oauth/token")) {
|