@shopware/api-client 1.1.2 → 1.2.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/README.md +3 -3
- package/api-types/adminApiTypes.d.ts +1 -1
- package/api-types/storeApiSchema.overrides.json +177 -0
- package/api-types/storeApiTypes.d.ts +60 -18
- package/api-types/storeApiTypes.overrides.ts +1 -50
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +66 -21
- package/dist/index.d.mts +66 -21
- package/dist/index.d.ts +66 -21
- package/dist/index.mjs +7 -5
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -279,8 +279,8 @@ calling `apiClient.hook` will autocomplete the list of available hooks.
|
|
|
279
279
|
|
|
280
280
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client/CHANGELOG.md)
|
|
281
281
|
|
|
282
|
-
### Latest changes: 1.
|
|
282
|
+
### Latest changes: 1.2.0
|
|
283
283
|
|
|
284
|
-
###
|
|
284
|
+
### Minor Changes
|
|
285
285
|
|
|
286
|
-
- [#
|
|
286
|
+
- [#1468](https://github.com/shopware/frontends/pull/1468) [`a87bbcf`](https://github.com/shopware/frontends/commit/a87bbcfa3f5aa440265b1e8f0fc72a204863befc) Thanks [@JimTacobs](https://github.com/JimTacobs)! - Added fetchOptions to both API clients to allow for base configuration of http client
|
|
@@ -10805,7 +10805,7 @@ export type Schemas = {
|
|
|
10805
10805
|
};
|
|
10806
10806
|
MultiNotFilter: {
|
|
10807
10807
|
/** @enum {string} */
|
|
10808
|
-
operator: "AND" | "
|
|
10808
|
+
operator: "AND" | "OR" | "and" | "or";
|
|
10809
10809
|
queries: components["schemas"]["Filters"];
|
|
10810
10810
|
/** @enum {string} */
|
|
10811
10811
|
type: "multi" | "not";
|
|
@@ -149,6 +149,47 @@
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
],
|
|
152
|
+
"Customer": [
|
|
153
|
+
{
|
|
154
|
+
"properties": {
|
|
155
|
+
"accountType": "_DELETE_",
|
|
156
|
+
"company": "_DELETE_",
|
|
157
|
+
"vatIds": "_DELETE_"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"oneOf": [
|
|
162
|
+
{
|
|
163
|
+
"required": ["accountType"],
|
|
164
|
+
"properties": {
|
|
165
|
+
"accountType": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"enum": ["private"]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"required": ["accountType", "vatIds", "company"],
|
|
173
|
+
"properties": {
|
|
174
|
+
"accountType": {
|
|
175
|
+
"type": "string",
|
|
176
|
+
"enum": ["business"]
|
|
177
|
+
},
|
|
178
|
+
"vatIds": {
|
|
179
|
+
"type": "array",
|
|
180
|
+
"items": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
},
|
|
183
|
+
"minItems": 1
|
|
184
|
+
},
|
|
185
|
+
"company": {
|
|
186
|
+
"type": "string"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
],
|
|
152
193
|
"DeliveryInformation": [
|
|
153
194
|
{
|
|
154
195
|
"required": ["stock"]
|
|
@@ -447,6 +488,75 @@
|
|
|
447
488
|
}
|
|
448
489
|
]
|
|
449
490
|
},
|
|
491
|
+
"/account/change-profile": {
|
|
492
|
+
"post": [
|
|
493
|
+
{
|
|
494
|
+
"requestBody": {
|
|
495
|
+
"content": {
|
|
496
|
+
"application/json": {
|
|
497
|
+
"schema": {
|
|
498
|
+
"properties": {
|
|
499
|
+
"accountType": "_DELETE_",
|
|
500
|
+
"company": "_DELETE_",
|
|
501
|
+
"vatIds": "_DELETE_"
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"requestBody": {
|
|
510
|
+
"content": {
|
|
511
|
+
"application/json": {
|
|
512
|
+
"schema": {
|
|
513
|
+
"oneOf": [
|
|
514
|
+
{
|
|
515
|
+
"properties": {
|
|
516
|
+
"accountType": {
|
|
517
|
+
"description": "Type of the customer account. Default value is 'private'.",
|
|
518
|
+
"type": "string",
|
|
519
|
+
"enum": ["private"],
|
|
520
|
+
"default": "private"
|
|
521
|
+
},
|
|
522
|
+
"company": {
|
|
523
|
+
"type": "null"
|
|
524
|
+
},
|
|
525
|
+
"vatIds": {
|
|
526
|
+
"type": "null"
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"required": ["accountType", "company", "vatIds"],
|
|
532
|
+
"properties": {
|
|
533
|
+
"accountType": {
|
|
534
|
+
"description": "Type of the customer account. Can be `private` or `business`.",
|
|
535
|
+
"type": "string",
|
|
536
|
+
"enum": ["business"]
|
|
537
|
+
},
|
|
538
|
+
"company": {
|
|
539
|
+
"description": "Company of the customer. Only required when `accountType` is `business`.",
|
|
540
|
+
"type": "string"
|
|
541
|
+
},
|
|
542
|
+
"vatIds": {
|
|
543
|
+
"description": "VAT IDs of the customer's company. Only valid when `accountType` is `business`.",
|
|
544
|
+
"type": "array",
|
|
545
|
+
"items": {
|
|
546
|
+
"type": "string"
|
|
547
|
+
},
|
|
548
|
+
"minItems": 1
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
]
|
|
559
|
+
},
|
|
450
560
|
"/account/list-address": {
|
|
451
561
|
"post": [
|
|
452
562
|
{
|
|
@@ -481,6 +591,73 @@
|
|
|
481
591
|
}
|
|
482
592
|
]
|
|
483
593
|
},
|
|
594
|
+
"/account/register": {
|
|
595
|
+
"post":[
|
|
596
|
+
{
|
|
597
|
+
"requestBody": {
|
|
598
|
+
"content": {
|
|
599
|
+
"application/json": {
|
|
600
|
+
"schema": {
|
|
601
|
+
"properties": {
|
|
602
|
+
"accountType": "_DELETE_"
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"requestBody": {
|
|
611
|
+
"content": {
|
|
612
|
+
"application/json": {
|
|
613
|
+
"schema": {
|
|
614
|
+
"oneOf": [
|
|
615
|
+
{
|
|
616
|
+
"properties": {
|
|
617
|
+
"accountType": {
|
|
618
|
+
"description": "Type of the customer account. Default value is 'private'.",
|
|
619
|
+
"type": "string",
|
|
620
|
+
"enum": ["private"],
|
|
621
|
+
"default": "private"
|
|
622
|
+
},
|
|
623
|
+
"company": {
|
|
624
|
+
"type": "null"
|
|
625
|
+
},
|
|
626
|
+
"vatIds": {
|
|
627
|
+
"type": "null"
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"required": ["accountType", "company", "vatIds"],
|
|
633
|
+
"properties": {
|
|
634
|
+
"accountType": {
|
|
635
|
+
"description": "Type of the customer account. Can be `private` or `business`.",
|
|
636
|
+
"type": "string",
|
|
637
|
+
"enum": ["business"]
|
|
638
|
+
},
|
|
639
|
+
"company": {
|
|
640
|
+
"description": "Company of the customer. Only required when `accountType` is `business`.",
|
|
641
|
+
"type": "string"
|
|
642
|
+
},
|
|
643
|
+
"vatIds": {
|
|
644
|
+
"description": "VAT IDs of the customer's company. Only valid when `accountType` is `business`.",
|
|
645
|
+
"type": "array",
|
|
646
|
+
"items": {
|
|
647
|
+
"type": "string"
|
|
648
|
+
},
|
|
649
|
+
"minItems": 1
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
]
|
|
660
|
+
},
|
|
484
661
|
"/account/shopping-list/line-item/{id}/add": {
|
|
485
662
|
"post": {
|
|
486
663
|
"requestBody": {
|
|
@@ -668,7 +668,7 @@ export type Schemas = {
|
|
|
668
668
|
keywords?: string;
|
|
669
669
|
linkNewTab?: boolean;
|
|
670
670
|
/** @enum {string} */
|
|
671
|
-
linkType?: "
|
|
671
|
+
linkType?: "category" | "external" | "landing_page" | "product";
|
|
672
672
|
metaDescription?: string;
|
|
673
673
|
metaTitle?: string;
|
|
674
674
|
name: string;
|
|
@@ -1704,7 +1704,6 @@ export type Schemas = {
|
|
|
1704
1704
|
readonly updatedAt?: string;
|
|
1705
1705
|
};
|
|
1706
1706
|
Customer: {
|
|
1707
|
-
accountType?: string;
|
|
1708
1707
|
active?: boolean;
|
|
1709
1708
|
activeBillingAddress: components["schemas"]["CustomerAddress"];
|
|
1710
1709
|
activeShippingAddress: components["schemas"]["CustomerAddress"];
|
|
@@ -1714,7 +1713,6 @@ export type Schemas = {
|
|
|
1714
1713
|
apiAlias: "customer";
|
|
1715
1714
|
birthday?: string;
|
|
1716
1715
|
campaignCode?: string;
|
|
1717
|
-
company?: string;
|
|
1718
1716
|
/** Format: date-time */
|
|
1719
1717
|
readonly createdAt?: string;
|
|
1720
1718
|
createdById?: string;
|
|
@@ -1781,8 +1779,18 @@ export type Schemas = {
|
|
|
1781
1779
|
/** Format: date-time */
|
|
1782
1780
|
readonly updatedAt?: string;
|
|
1783
1781
|
updatedById?: string;
|
|
1784
|
-
|
|
1785
|
-
|
|
1782
|
+
} & (
|
|
1783
|
+
| {
|
|
1784
|
+
/** @enum {string} */
|
|
1785
|
+
accountType: "private";
|
|
1786
|
+
}
|
|
1787
|
+
| {
|
|
1788
|
+
/** @enum {string} */
|
|
1789
|
+
accountType: "business";
|
|
1790
|
+
company: string;
|
|
1791
|
+
vatIds: [string, ...string[]];
|
|
1792
|
+
}
|
|
1793
|
+
);
|
|
1786
1794
|
CustomerAddress: {
|
|
1787
1795
|
additionalAddressLine1?: string;
|
|
1788
1796
|
additionalAddressLine2?: string;
|
|
@@ -7547,8 +7555,6 @@ export type operations = {
|
|
|
7547
7555
|
birthdayMonth?: number;
|
|
7548
7556
|
/** Birthday year */
|
|
7549
7557
|
birthdayYear?: number;
|
|
7550
|
-
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7551
|
-
company?: string;
|
|
7552
7558
|
/** Customer first name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
7553
7559
|
firstName: string;
|
|
7554
7560
|
/** Customer last name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
@@ -7557,7 +7563,29 @@ export type operations = {
|
|
|
7557
7563
|
salutationId: string;
|
|
7558
7564
|
/** (Academic) title of the customer */
|
|
7559
7565
|
title?: string;
|
|
7560
|
-
}
|
|
7566
|
+
} & (
|
|
7567
|
+
| {
|
|
7568
|
+
/**
|
|
7569
|
+
* Type of the customer account. Default value is 'private'.
|
|
7570
|
+
* @default private
|
|
7571
|
+
* @enum {string}
|
|
7572
|
+
*/
|
|
7573
|
+
accountType?: "private";
|
|
7574
|
+
company?: null;
|
|
7575
|
+
vatIds?: null;
|
|
7576
|
+
}
|
|
7577
|
+
| {
|
|
7578
|
+
/**
|
|
7579
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7580
|
+
* @enum {string}
|
|
7581
|
+
*/
|
|
7582
|
+
accountType: "business";
|
|
7583
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7584
|
+
company: string;
|
|
7585
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7586
|
+
vatIds: [string, ...string[]];
|
|
7587
|
+
}
|
|
7588
|
+
);
|
|
7561
7589
|
response: components["schemas"]["SuccessResponse"];
|
|
7562
7590
|
responseCode: 200;
|
|
7563
7591
|
};
|
|
@@ -7679,17 +7707,9 @@ export type operations = {
|
|
|
7679
7707
|
body: {
|
|
7680
7708
|
/** Flag indicating accepted data protection */
|
|
7681
7709
|
acceptedDataProtection: boolean;
|
|
7682
|
-
/**
|
|
7683
|
-
* Account type of the customer which can be either `private` or `business`.
|
|
7684
|
-
* @default private
|
|
7685
|
-
*/
|
|
7686
|
-
accountType?: string;
|
|
7687
7710
|
/** Field can be used to store an affiliate tracking code */
|
|
7688
7711
|
affiliateCode?: string;
|
|
7689
|
-
billingAddress:
|
|
7690
|
-
components["schemas"]["CustomerAddress"],
|
|
7691
|
-
"createdAt" | "id" | "customerId" | "firstName" | "lastName"
|
|
7692
|
-
>; // TODO: [OpenAPI][register] - omit id, createdAt, customerId, firstName, lastName while creating address (or better to reverse and pick required fields)
|
|
7712
|
+
billingAddress: components["schemas"]["CustomerAddress"];
|
|
7693
7713
|
/** Birthday day */
|
|
7694
7714
|
birthdayDay?: number;
|
|
7695
7715
|
/** Birthday month */
|
|
@@ -7718,7 +7738,29 @@ export type operations = {
|
|
|
7718
7738
|
storefrontUrl: string;
|
|
7719
7739
|
/** (Academic) title of the customer */
|
|
7720
7740
|
title?: string;
|
|
7721
|
-
}
|
|
7741
|
+
} & (
|
|
7742
|
+
| {
|
|
7743
|
+
/**
|
|
7744
|
+
* Type of the customer account. Default value is 'private'.
|
|
7745
|
+
* @default private
|
|
7746
|
+
* @enum {string}
|
|
7747
|
+
*/
|
|
7748
|
+
accountType?: "private";
|
|
7749
|
+
company?: null;
|
|
7750
|
+
vatIds?: null;
|
|
7751
|
+
}
|
|
7752
|
+
| {
|
|
7753
|
+
/**
|
|
7754
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7755
|
+
* @enum {string}
|
|
7756
|
+
*/
|
|
7757
|
+
accountType: "business";
|
|
7758
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7759
|
+
company: string;
|
|
7760
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7761
|
+
vatIds: [string, ...string[]];
|
|
7762
|
+
}
|
|
7763
|
+
);
|
|
7722
7764
|
response: components["schemas"]["Customer"];
|
|
7723
7765
|
responseCode: 200;
|
|
7724
7766
|
};
|
|
@@ -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
|
// & {
|
|
@@ -60,55 +60,6 @@ export type Schemas = {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
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
63
|
"updateLineItem patch /checkout/cart/line-item": {
|
|
113
64
|
contentType?: "application/json";
|
|
114
65
|
accept?: "application/json";
|
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")) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as hookable from 'hookable';
|
|
2
|
-
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
2
|
+
import { FetchOptions, ResponseType, FetchResponse } from 'ofetch';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Source: https://github.com/shopware/shopware/blob/trunk/src/Core/PlatformRequest.php#L16
|
|
@@ -696,7 +696,7 @@ type Schemas$1 = {
|
|
|
696
696
|
keywords?: string;
|
|
697
697
|
linkNewTab?: boolean;
|
|
698
698
|
/** @enum {string} */
|
|
699
|
-
linkType?: "
|
|
699
|
+
linkType?: "category" | "external" | "landing_page" | "product";
|
|
700
700
|
metaDescription?: string;
|
|
701
701
|
metaTitle?: string;
|
|
702
702
|
name: string;
|
|
@@ -1732,7 +1732,6 @@ type Schemas$1 = {
|
|
|
1732
1732
|
readonly updatedAt?: string;
|
|
1733
1733
|
};
|
|
1734
1734
|
Customer: {
|
|
1735
|
-
accountType?: string;
|
|
1736
1735
|
active?: boolean;
|
|
1737
1736
|
activeBillingAddress: components$1["schemas"]["CustomerAddress"];
|
|
1738
1737
|
activeShippingAddress: components$1["schemas"]["CustomerAddress"];
|
|
@@ -1742,7 +1741,6 @@ type Schemas$1 = {
|
|
|
1742
1741
|
apiAlias: "customer";
|
|
1743
1742
|
birthday?: string;
|
|
1744
1743
|
campaignCode?: string;
|
|
1745
|
-
company?: string;
|
|
1746
1744
|
/** Format: date-time */
|
|
1747
1745
|
readonly createdAt?: string;
|
|
1748
1746
|
createdById?: string;
|
|
@@ -1809,8 +1807,18 @@ type Schemas$1 = {
|
|
|
1809
1807
|
/** Format: date-time */
|
|
1810
1808
|
readonly updatedAt?: string;
|
|
1811
1809
|
updatedById?: string;
|
|
1812
|
-
|
|
1813
|
-
|
|
1810
|
+
} & (
|
|
1811
|
+
| {
|
|
1812
|
+
/** @enum {string} */
|
|
1813
|
+
accountType: "private";
|
|
1814
|
+
}
|
|
1815
|
+
| {
|
|
1816
|
+
/** @enum {string} */
|
|
1817
|
+
accountType: "business";
|
|
1818
|
+
company: string;
|
|
1819
|
+
vatIds: [string, ...string[]];
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1814
1822
|
CustomerAddress: {
|
|
1815
1823
|
additionalAddressLine1?: string;
|
|
1816
1824
|
additionalAddressLine2?: string;
|
|
@@ -7575,8 +7583,6 @@ type operations$1 = {
|
|
|
7575
7583
|
birthdayMonth?: number;
|
|
7576
7584
|
/** Birthday year */
|
|
7577
7585
|
birthdayYear?: number;
|
|
7578
|
-
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7579
|
-
company?: string;
|
|
7580
7586
|
/** Customer first name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
7581
7587
|
firstName: string;
|
|
7582
7588
|
/** Customer last name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
@@ -7585,7 +7591,29 @@ type operations$1 = {
|
|
|
7585
7591
|
salutationId: string;
|
|
7586
7592
|
/** (Academic) title of the customer */
|
|
7587
7593
|
title?: string;
|
|
7588
|
-
}
|
|
7594
|
+
} & (
|
|
7595
|
+
| {
|
|
7596
|
+
/**
|
|
7597
|
+
* Type of the customer account. Default value is 'private'.
|
|
7598
|
+
* @default private
|
|
7599
|
+
* @enum {string}
|
|
7600
|
+
*/
|
|
7601
|
+
accountType?: "private";
|
|
7602
|
+
company?: null;
|
|
7603
|
+
vatIds?: null;
|
|
7604
|
+
}
|
|
7605
|
+
| {
|
|
7606
|
+
/**
|
|
7607
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7608
|
+
* @enum {string}
|
|
7609
|
+
*/
|
|
7610
|
+
accountType: "business";
|
|
7611
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7612
|
+
company: string;
|
|
7613
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7614
|
+
vatIds: [string, ...string[]];
|
|
7615
|
+
}
|
|
7616
|
+
);
|
|
7589
7617
|
response: components$1["schemas"]["SuccessResponse"];
|
|
7590
7618
|
responseCode: 200;
|
|
7591
7619
|
};
|
|
@@ -7707,17 +7735,9 @@ type operations$1 = {
|
|
|
7707
7735
|
body: {
|
|
7708
7736
|
/** Flag indicating accepted data protection */
|
|
7709
7737
|
acceptedDataProtection: boolean;
|
|
7710
|
-
/**
|
|
7711
|
-
* Account type of the customer which can be either `private` or `business`.
|
|
7712
|
-
* @default private
|
|
7713
|
-
*/
|
|
7714
|
-
accountType?: string;
|
|
7715
7738
|
/** Field can be used to store an affiliate tracking code */
|
|
7716
7739
|
affiliateCode?: string;
|
|
7717
|
-
billingAddress:
|
|
7718
|
-
components$1["schemas"]["CustomerAddress"],
|
|
7719
|
-
"createdAt" | "id" | "customerId" | "firstName" | "lastName"
|
|
7720
|
-
>; // TODO: [OpenAPI][register] - omit id, createdAt, customerId, firstName, lastName while creating address (or better to reverse and pick required fields)
|
|
7740
|
+
billingAddress: components$1["schemas"]["CustomerAddress"];
|
|
7721
7741
|
/** Birthday day */
|
|
7722
7742
|
birthdayDay?: number;
|
|
7723
7743
|
/** Birthday month */
|
|
@@ -7746,7 +7766,29 @@ type operations$1 = {
|
|
|
7746
7766
|
storefrontUrl: string;
|
|
7747
7767
|
/** (Academic) title of the customer */
|
|
7748
7768
|
title?: string;
|
|
7749
|
-
}
|
|
7769
|
+
} & (
|
|
7770
|
+
| {
|
|
7771
|
+
/**
|
|
7772
|
+
* Type of the customer account. Default value is 'private'.
|
|
7773
|
+
* @default private
|
|
7774
|
+
* @enum {string}
|
|
7775
|
+
*/
|
|
7776
|
+
accountType?: "private";
|
|
7777
|
+
company?: null;
|
|
7778
|
+
vatIds?: null;
|
|
7779
|
+
}
|
|
7780
|
+
| {
|
|
7781
|
+
/**
|
|
7782
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7783
|
+
* @enum {string}
|
|
7784
|
+
*/
|
|
7785
|
+
accountType: "business";
|
|
7786
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7787
|
+
company: string;
|
|
7788
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7789
|
+
vatIds: [string, ...string[]];
|
|
7790
|
+
}
|
|
7791
|
+
);
|
|
7750
7792
|
response: components$1["schemas"]["Customer"];
|
|
7751
7793
|
responseCode: 200;
|
|
7752
7794
|
};
|
|
@@ -9599,6 +9641,7 @@ type RequestParameters<CURRENT_OPERATION> = SimpleUnionOmit$1<CURRENT_OPERATION,
|
|
|
9599
9641
|
type InvokeParameters<CURRENT_OPERATION> = RequestParameters<CURRENT_OPERATION> & {
|
|
9600
9642
|
fetchOptions?: Pick<FetchOptions<"json">, "cache" | "duplex" | "keepalive" | "priority" | "redirect" | "retry" | "retryDelay" | "retryStatusCodes" | "signal" | "timeout">;
|
|
9601
9643
|
};
|
|
9644
|
+
type GlobalFetchOptions = Pick<FetchOptions<ResponseType>, "retry" | "retryDelay" | "retryStatusCodes" | "timeout">;
|
|
9602
9645
|
type ApiClientHooks = {
|
|
9603
9646
|
onContextChanged: (newContextToken: string) => void;
|
|
9604
9647
|
onResponseError: (response: FetchResponse<ResponseType>) => void;
|
|
@@ -9610,6 +9653,7 @@ declare function createAPIClient<OPERATIONS extends Record<string, any> = operat
|
|
|
9610
9653
|
accessToken?: string;
|
|
9611
9654
|
contextToken?: string;
|
|
9612
9655
|
defaultHeaders?: ClientHeaders;
|
|
9656
|
+
fetchOptions?: GlobalFetchOptions;
|
|
9613
9657
|
}): {
|
|
9614
9658
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit$1<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
9615
9659
|
body: unknown;
|
|
@@ -20436,7 +20480,7 @@ type Schemas = {
|
|
|
20436
20480
|
};
|
|
20437
20481
|
MultiNotFilter: {
|
|
20438
20482
|
/** @enum {string} */
|
|
20439
|
-
operator: "AND" | "
|
|
20483
|
+
operator: "AND" | "OR" | "and" | "or";
|
|
20440
20484
|
queries: components["schemas"]["Filters"];
|
|
20441
20485
|
/** @enum {string} */
|
|
20442
20486
|
type: "multi" | "not";
|
|
@@ -100188,9 +100232,10 @@ declare function createAdminAPIClient<OPERATIONS extends Record<string, any> = o
|
|
|
100188
100232
|
* If you pass `credentials` object, it will be used to authenticate the client whenever session expires.
|
|
100189
100233
|
* You don't need to manually invoke `/token` endpoint first.
|
|
100190
100234
|
*/
|
|
100191
|
-
credentials?: OPERATIONS["token"]["body"];
|
|
100235
|
+
credentials?: OPERATIONS["token post /oauth/token"]["body"];
|
|
100192
100236
|
sessionData?: AdminSessionData;
|
|
100193
100237
|
defaultHeaders?: ClientHeaders;
|
|
100238
|
+
fetchOptions?: GlobalFetchOptions;
|
|
100194
100239
|
}): {
|
|
100195
100240
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
100196
100241
|
body: unknown;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as hookable from 'hookable';
|
|
2
|
-
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
2
|
+
import { FetchOptions, ResponseType, FetchResponse } from 'ofetch';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Source: https://github.com/shopware/shopware/blob/trunk/src/Core/PlatformRequest.php#L16
|
|
@@ -696,7 +696,7 @@ type Schemas$1 = {
|
|
|
696
696
|
keywords?: string;
|
|
697
697
|
linkNewTab?: boolean;
|
|
698
698
|
/** @enum {string} */
|
|
699
|
-
linkType?: "
|
|
699
|
+
linkType?: "category" | "external" | "landing_page" | "product";
|
|
700
700
|
metaDescription?: string;
|
|
701
701
|
metaTitle?: string;
|
|
702
702
|
name: string;
|
|
@@ -1732,7 +1732,6 @@ type Schemas$1 = {
|
|
|
1732
1732
|
readonly updatedAt?: string;
|
|
1733
1733
|
};
|
|
1734
1734
|
Customer: {
|
|
1735
|
-
accountType?: string;
|
|
1736
1735
|
active?: boolean;
|
|
1737
1736
|
activeBillingAddress: components$1["schemas"]["CustomerAddress"];
|
|
1738
1737
|
activeShippingAddress: components$1["schemas"]["CustomerAddress"];
|
|
@@ -1742,7 +1741,6 @@ type Schemas$1 = {
|
|
|
1742
1741
|
apiAlias: "customer";
|
|
1743
1742
|
birthday?: string;
|
|
1744
1743
|
campaignCode?: string;
|
|
1745
|
-
company?: string;
|
|
1746
1744
|
/** Format: date-time */
|
|
1747
1745
|
readonly createdAt?: string;
|
|
1748
1746
|
createdById?: string;
|
|
@@ -1809,8 +1807,18 @@ type Schemas$1 = {
|
|
|
1809
1807
|
/** Format: date-time */
|
|
1810
1808
|
readonly updatedAt?: string;
|
|
1811
1809
|
updatedById?: string;
|
|
1812
|
-
|
|
1813
|
-
|
|
1810
|
+
} & (
|
|
1811
|
+
| {
|
|
1812
|
+
/** @enum {string} */
|
|
1813
|
+
accountType: "private";
|
|
1814
|
+
}
|
|
1815
|
+
| {
|
|
1816
|
+
/** @enum {string} */
|
|
1817
|
+
accountType: "business";
|
|
1818
|
+
company: string;
|
|
1819
|
+
vatIds: [string, ...string[]];
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1814
1822
|
CustomerAddress: {
|
|
1815
1823
|
additionalAddressLine1?: string;
|
|
1816
1824
|
additionalAddressLine2?: string;
|
|
@@ -7575,8 +7583,6 @@ type operations$1 = {
|
|
|
7575
7583
|
birthdayMonth?: number;
|
|
7576
7584
|
/** Birthday year */
|
|
7577
7585
|
birthdayYear?: number;
|
|
7578
|
-
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7579
|
-
company?: string;
|
|
7580
7586
|
/** Customer first name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
7581
7587
|
firstName: string;
|
|
7582
7588
|
/** Customer last name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
@@ -7585,7 +7591,29 @@ type operations$1 = {
|
|
|
7585
7591
|
salutationId: string;
|
|
7586
7592
|
/** (Academic) title of the customer */
|
|
7587
7593
|
title?: string;
|
|
7588
|
-
}
|
|
7594
|
+
} & (
|
|
7595
|
+
| {
|
|
7596
|
+
/**
|
|
7597
|
+
* Type of the customer account. Default value is 'private'.
|
|
7598
|
+
* @default private
|
|
7599
|
+
* @enum {string}
|
|
7600
|
+
*/
|
|
7601
|
+
accountType?: "private";
|
|
7602
|
+
company?: null;
|
|
7603
|
+
vatIds?: null;
|
|
7604
|
+
}
|
|
7605
|
+
| {
|
|
7606
|
+
/**
|
|
7607
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7608
|
+
* @enum {string}
|
|
7609
|
+
*/
|
|
7610
|
+
accountType: "business";
|
|
7611
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7612
|
+
company: string;
|
|
7613
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7614
|
+
vatIds: [string, ...string[]];
|
|
7615
|
+
}
|
|
7616
|
+
);
|
|
7589
7617
|
response: components$1["schemas"]["SuccessResponse"];
|
|
7590
7618
|
responseCode: 200;
|
|
7591
7619
|
};
|
|
@@ -7707,17 +7735,9 @@ type operations$1 = {
|
|
|
7707
7735
|
body: {
|
|
7708
7736
|
/** Flag indicating accepted data protection */
|
|
7709
7737
|
acceptedDataProtection: boolean;
|
|
7710
|
-
/**
|
|
7711
|
-
* Account type of the customer which can be either `private` or `business`.
|
|
7712
|
-
* @default private
|
|
7713
|
-
*/
|
|
7714
|
-
accountType?: string;
|
|
7715
7738
|
/** Field can be used to store an affiliate tracking code */
|
|
7716
7739
|
affiliateCode?: string;
|
|
7717
|
-
billingAddress:
|
|
7718
|
-
components$1["schemas"]["CustomerAddress"],
|
|
7719
|
-
"createdAt" | "id" | "customerId" | "firstName" | "lastName"
|
|
7720
|
-
>; // TODO: [OpenAPI][register] - omit id, createdAt, customerId, firstName, lastName while creating address (or better to reverse and pick required fields)
|
|
7740
|
+
billingAddress: components$1["schemas"]["CustomerAddress"];
|
|
7721
7741
|
/** Birthday day */
|
|
7722
7742
|
birthdayDay?: number;
|
|
7723
7743
|
/** Birthday month */
|
|
@@ -7746,7 +7766,29 @@ type operations$1 = {
|
|
|
7746
7766
|
storefrontUrl: string;
|
|
7747
7767
|
/** (Academic) title of the customer */
|
|
7748
7768
|
title?: string;
|
|
7749
|
-
}
|
|
7769
|
+
} & (
|
|
7770
|
+
| {
|
|
7771
|
+
/**
|
|
7772
|
+
* Type of the customer account. Default value is 'private'.
|
|
7773
|
+
* @default private
|
|
7774
|
+
* @enum {string}
|
|
7775
|
+
*/
|
|
7776
|
+
accountType?: "private";
|
|
7777
|
+
company?: null;
|
|
7778
|
+
vatIds?: null;
|
|
7779
|
+
}
|
|
7780
|
+
| {
|
|
7781
|
+
/**
|
|
7782
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7783
|
+
* @enum {string}
|
|
7784
|
+
*/
|
|
7785
|
+
accountType: "business";
|
|
7786
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7787
|
+
company: string;
|
|
7788
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7789
|
+
vatIds: [string, ...string[]];
|
|
7790
|
+
}
|
|
7791
|
+
);
|
|
7750
7792
|
response: components$1["schemas"]["Customer"];
|
|
7751
7793
|
responseCode: 200;
|
|
7752
7794
|
};
|
|
@@ -9599,6 +9641,7 @@ type RequestParameters<CURRENT_OPERATION> = SimpleUnionOmit$1<CURRENT_OPERATION,
|
|
|
9599
9641
|
type InvokeParameters<CURRENT_OPERATION> = RequestParameters<CURRENT_OPERATION> & {
|
|
9600
9642
|
fetchOptions?: Pick<FetchOptions<"json">, "cache" | "duplex" | "keepalive" | "priority" | "redirect" | "retry" | "retryDelay" | "retryStatusCodes" | "signal" | "timeout">;
|
|
9601
9643
|
};
|
|
9644
|
+
type GlobalFetchOptions = Pick<FetchOptions<ResponseType>, "retry" | "retryDelay" | "retryStatusCodes" | "timeout">;
|
|
9602
9645
|
type ApiClientHooks = {
|
|
9603
9646
|
onContextChanged: (newContextToken: string) => void;
|
|
9604
9647
|
onResponseError: (response: FetchResponse<ResponseType>) => void;
|
|
@@ -9610,6 +9653,7 @@ declare function createAPIClient<OPERATIONS extends Record<string, any> = operat
|
|
|
9610
9653
|
accessToken?: string;
|
|
9611
9654
|
contextToken?: string;
|
|
9612
9655
|
defaultHeaders?: ClientHeaders;
|
|
9656
|
+
fetchOptions?: GlobalFetchOptions;
|
|
9613
9657
|
}): {
|
|
9614
9658
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit$1<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
9615
9659
|
body: unknown;
|
|
@@ -20436,7 +20480,7 @@ type Schemas = {
|
|
|
20436
20480
|
};
|
|
20437
20481
|
MultiNotFilter: {
|
|
20438
20482
|
/** @enum {string} */
|
|
20439
|
-
operator: "AND" | "
|
|
20483
|
+
operator: "AND" | "OR" | "and" | "or";
|
|
20440
20484
|
queries: components["schemas"]["Filters"];
|
|
20441
20485
|
/** @enum {string} */
|
|
20442
20486
|
type: "multi" | "not";
|
|
@@ -100188,9 +100232,10 @@ declare function createAdminAPIClient<OPERATIONS extends Record<string, any> = o
|
|
|
100188
100232
|
* If you pass `credentials` object, it will be used to authenticate the client whenever session expires.
|
|
100189
100233
|
* You don't need to manually invoke `/token` endpoint first.
|
|
100190
100234
|
*/
|
|
100191
|
-
credentials?: OPERATIONS["token"]["body"];
|
|
100235
|
+
credentials?: OPERATIONS["token post /oauth/token"]["body"];
|
|
100192
100236
|
sessionData?: AdminSessionData;
|
|
100193
100237
|
defaultHeaders?: ClientHeaders;
|
|
100238
|
+
fetchOptions?: GlobalFetchOptions;
|
|
100194
100239
|
}): {
|
|
100195
100240
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
100196
100241
|
body: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as hookable from 'hookable';
|
|
2
|
-
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
2
|
+
import { FetchOptions, ResponseType, FetchResponse } from 'ofetch';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Source: https://github.com/shopware/shopware/blob/trunk/src/Core/PlatformRequest.php#L16
|
|
@@ -696,7 +696,7 @@ type Schemas$1 = {
|
|
|
696
696
|
keywords?: string;
|
|
697
697
|
linkNewTab?: boolean;
|
|
698
698
|
/** @enum {string} */
|
|
699
|
-
linkType?: "
|
|
699
|
+
linkType?: "category" | "external" | "landing_page" | "product";
|
|
700
700
|
metaDescription?: string;
|
|
701
701
|
metaTitle?: string;
|
|
702
702
|
name: string;
|
|
@@ -1732,7 +1732,6 @@ type Schemas$1 = {
|
|
|
1732
1732
|
readonly updatedAt?: string;
|
|
1733
1733
|
};
|
|
1734
1734
|
Customer: {
|
|
1735
|
-
accountType?: string;
|
|
1736
1735
|
active?: boolean;
|
|
1737
1736
|
activeBillingAddress: components$1["schemas"]["CustomerAddress"];
|
|
1738
1737
|
activeShippingAddress: components$1["schemas"]["CustomerAddress"];
|
|
@@ -1742,7 +1741,6 @@ type Schemas$1 = {
|
|
|
1742
1741
|
apiAlias: "customer";
|
|
1743
1742
|
birthday?: string;
|
|
1744
1743
|
campaignCode?: string;
|
|
1745
|
-
company?: string;
|
|
1746
1744
|
/** Format: date-time */
|
|
1747
1745
|
readonly createdAt?: string;
|
|
1748
1746
|
createdById?: string;
|
|
@@ -1809,8 +1807,18 @@ type Schemas$1 = {
|
|
|
1809
1807
|
/** Format: date-time */
|
|
1810
1808
|
readonly updatedAt?: string;
|
|
1811
1809
|
updatedById?: string;
|
|
1812
|
-
|
|
1813
|
-
|
|
1810
|
+
} & (
|
|
1811
|
+
| {
|
|
1812
|
+
/** @enum {string} */
|
|
1813
|
+
accountType: "private";
|
|
1814
|
+
}
|
|
1815
|
+
| {
|
|
1816
|
+
/** @enum {string} */
|
|
1817
|
+
accountType: "business";
|
|
1818
|
+
company: string;
|
|
1819
|
+
vatIds: [string, ...string[]];
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1814
1822
|
CustomerAddress: {
|
|
1815
1823
|
additionalAddressLine1?: string;
|
|
1816
1824
|
additionalAddressLine2?: string;
|
|
@@ -7575,8 +7583,6 @@ type operations$1 = {
|
|
|
7575
7583
|
birthdayMonth?: number;
|
|
7576
7584
|
/** Birthday year */
|
|
7577
7585
|
birthdayYear?: number;
|
|
7578
|
-
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7579
|
-
company?: string;
|
|
7580
7586
|
/** Customer first name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
7581
7587
|
firstName: string;
|
|
7582
7588
|
/** Customer last name. Value will be reused for shipping and billing address if not provided explicitly. */
|
|
@@ -7585,7 +7591,29 @@ type operations$1 = {
|
|
|
7585
7591
|
salutationId: string;
|
|
7586
7592
|
/** (Academic) title of the customer */
|
|
7587
7593
|
title?: string;
|
|
7588
|
-
}
|
|
7594
|
+
} & (
|
|
7595
|
+
| {
|
|
7596
|
+
/**
|
|
7597
|
+
* Type of the customer account. Default value is 'private'.
|
|
7598
|
+
* @default private
|
|
7599
|
+
* @enum {string}
|
|
7600
|
+
*/
|
|
7601
|
+
accountType?: "private";
|
|
7602
|
+
company?: null;
|
|
7603
|
+
vatIds?: null;
|
|
7604
|
+
}
|
|
7605
|
+
| {
|
|
7606
|
+
/**
|
|
7607
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7608
|
+
* @enum {string}
|
|
7609
|
+
*/
|
|
7610
|
+
accountType: "business";
|
|
7611
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7612
|
+
company: string;
|
|
7613
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7614
|
+
vatIds: [string, ...string[]];
|
|
7615
|
+
}
|
|
7616
|
+
);
|
|
7589
7617
|
response: components$1["schemas"]["SuccessResponse"];
|
|
7590
7618
|
responseCode: 200;
|
|
7591
7619
|
};
|
|
@@ -7707,17 +7735,9 @@ type operations$1 = {
|
|
|
7707
7735
|
body: {
|
|
7708
7736
|
/** Flag indicating accepted data protection */
|
|
7709
7737
|
acceptedDataProtection: boolean;
|
|
7710
|
-
/**
|
|
7711
|
-
* Account type of the customer which can be either `private` or `business`.
|
|
7712
|
-
* @default private
|
|
7713
|
-
*/
|
|
7714
|
-
accountType?: string;
|
|
7715
7738
|
/** Field can be used to store an affiliate tracking code */
|
|
7716
7739
|
affiliateCode?: string;
|
|
7717
|
-
billingAddress:
|
|
7718
|
-
components$1["schemas"]["CustomerAddress"],
|
|
7719
|
-
"createdAt" | "id" | "customerId" | "firstName" | "lastName"
|
|
7720
|
-
>; // TODO: [OpenAPI][register] - omit id, createdAt, customerId, firstName, lastName while creating address (or better to reverse and pick required fields)
|
|
7740
|
+
billingAddress: components$1["schemas"]["CustomerAddress"];
|
|
7721
7741
|
/** Birthday day */
|
|
7722
7742
|
birthdayDay?: number;
|
|
7723
7743
|
/** Birthday month */
|
|
@@ -7746,7 +7766,29 @@ type operations$1 = {
|
|
|
7746
7766
|
storefrontUrl: string;
|
|
7747
7767
|
/** (Academic) title of the customer */
|
|
7748
7768
|
title?: string;
|
|
7749
|
-
}
|
|
7769
|
+
} & (
|
|
7770
|
+
| {
|
|
7771
|
+
/**
|
|
7772
|
+
* Type of the customer account. Default value is 'private'.
|
|
7773
|
+
* @default private
|
|
7774
|
+
* @enum {string}
|
|
7775
|
+
*/
|
|
7776
|
+
accountType?: "private";
|
|
7777
|
+
company?: null;
|
|
7778
|
+
vatIds?: null;
|
|
7779
|
+
}
|
|
7780
|
+
| {
|
|
7781
|
+
/**
|
|
7782
|
+
* Type of the customer account. Can be `private` or `business`.
|
|
7783
|
+
* @enum {string}
|
|
7784
|
+
*/
|
|
7785
|
+
accountType: "business";
|
|
7786
|
+
/** Company of the customer. Only required when `accountType` is `business`. */
|
|
7787
|
+
company: string;
|
|
7788
|
+
/** VAT IDs of the customer's company. Only valid when `accountType` is `business`. */
|
|
7789
|
+
vatIds: [string, ...string[]];
|
|
7790
|
+
}
|
|
7791
|
+
);
|
|
7750
7792
|
response: components$1["schemas"]["Customer"];
|
|
7751
7793
|
responseCode: 200;
|
|
7752
7794
|
};
|
|
@@ -9599,6 +9641,7 @@ type RequestParameters<CURRENT_OPERATION> = SimpleUnionOmit$1<CURRENT_OPERATION,
|
|
|
9599
9641
|
type InvokeParameters<CURRENT_OPERATION> = RequestParameters<CURRENT_OPERATION> & {
|
|
9600
9642
|
fetchOptions?: Pick<FetchOptions<"json">, "cache" | "duplex" | "keepalive" | "priority" | "redirect" | "retry" | "retryDelay" | "retryStatusCodes" | "signal" | "timeout">;
|
|
9601
9643
|
};
|
|
9644
|
+
type GlobalFetchOptions = Pick<FetchOptions<ResponseType>, "retry" | "retryDelay" | "retryStatusCodes" | "timeout">;
|
|
9602
9645
|
type ApiClientHooks = {
|
|
9603
9646
|
onContextChanged: (newContextToken: string) => void;
|
|
9604
9647
|
onResponseError: (response: FetchResponse<ResponseType>) => void;
|
|
@@ -9610,6 +9653,7 @@ declare function createAPIClient<OPERATIONS extends Record<string, any> = operat
|
|
|
9610
9653
|
accessToken?: string;
|
|
9611
9654
|
contextToken?: string;
|
|
9612
9655
|
defaultHeaders?: ClientHeaders;
|
|
9656
|
+
fetchOptions?: GlobalFetchOptions;
|
|
9613
9657
|
}): {
|
|
9614
9658
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit$1<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
9615
9659
|
body: unknown;
|
|
@@ -20436,7 +20480,7 @@ type Schemas = {
|
|
|
20436
20480
|
};
|
|
20437
20481
|
MultiNotFilter: {
|
|
20438
20482
|
/** @enum {string} */
|
|
20439
|
-
operator: "AND" | "
|
|
20483
|
+
operator: "AND" | "OR" | "and" | "or";
|
|
20440
20484
|
queries: components["schemas"]["Filters"];
|
|
20441
20485
|
/** @enum {string} */
|
|
20442
20486
|
type: "multi" | "not";
|
|
@@ -100188,9 +100232,10 @@ declare function createAdminAPIClient<OPERATIONS extends Record<string, any> = o
|
|
|
100188
100232
|
* If you pass `credentials` object, it will be used to authenticate the client whenever session expires.
|
|
100189
100233
|
* You don't need to manually invoke `/token` endpoint first.
|
|
100190
100234
|
*/
|
|
100191
|
-
credentials?: OPERATIONS["token"]["body"];
|
|
100235
|
+
credentials?: OPERATIONS["token post /oauth/token"]["body"];
|
|
100192
100236
|
sessionData?: AdminSessionData;
|
|
100193
100237
|
defaultHeaders?: ClientHeaders;
|
|
100238
|
+
fetchOptions?: GlobalFetchOptions;
|
|
100194
100239
|
}): {
|
|
100195
100240
|
invoke: <INVOKE_PATH extends PATHS, OPERATION_NAME extends string = INVOKE_PATH extends `${infer R}` ? R extends string ? R : never : never, CURRENT_OPERATION extends OPERATIONS[OPERATION_NAME] = OPERATION_NAME extends keyof OPERATIONS ? OPERATIONS[OPERATION_NAME] : never>(pathParam: OPERATION_NAME extends keyof OPERATIONS ? OPERATION_NAME : never, ...params: SimpleUnionOmit<CURRENT_OPERATION, "response" | "responseCode"> extends {
|
|
100196
100241
|
body: unknown;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ofetch } from 'ofetch';
|
|
2
|
-
import { createHooks } from 'hookable';
|
|
3
1
|
import defu from 'defu';
|
|
2
|
+
import { createHooks } from 'hookable';
|
|
3
|
+
import { ofetch } from 'ofetch';
|
|
4
4
|
|
|
5
5
|
function createHeaders(init, hookCallback) {
|
|
6
6
|
const _headers = {
|
|
@@ -124,13 +124,14 @@ function createAPIClient(params) {
|
|
|
124
124
|
},
|
|
125
125
|
(key, value) => {
|
|
126
126
|
apiClientHooks.callHook("onDefaultHeaderChanged", key, value);
|
|
127
|
-
if (key === "sw-context-token") {
|
|
127
|
+
if (key === "sw-context-token" && value) {
|
|
128
128
|
apiClientHooks.callHook("onContextChanged", value);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
132
|
const apiFetch = ofetch.create({
|
|
133
133
|
baseURL: params.baseURL,
|
|
134
|
+
...params.fetchOptions,
|
|
134
135
|
// async onRequest({ request, options }) {},
|
|
135
136
|
// async onRequestError({ request, options, error }) {},
|
|
136
137
|
async onResponse(context) {
|
|
@@ -157,9 +158,9 @@ function createAPIClient(params) {
|
|
|
157
158
|
const fetchOptions = {
|
|
158
159
|
...currentParams.fetchOptions || {}
|
|
159
160
|
};
|
|
160
|
-
|
|
161
|
+
const mergedHeaders = defu(currentParams.headers, defaultHeaders);
|
|
161
162
|
if (mergedHeaders?.["Content-Type"]?.includes("multipart/form-data") && typeof window !== "undefined") {
|
|
162
|
-
|
|
163
|
+
mergedHeaders["Content-Type"] = void 0;
|
|
163
164
|
}
|
|
164
165
|
const resp = await apiFetch.raw(requestPathWithParams, {
|
|
165
166
|
...fetchOptions,
|
|
@@ -231,6 +232,7 @@ function createAdminAPIClient(params) {
|
|
|
231
232
|
}
|
|
232
233
|
const apiFetch = ofetch.create({
|
|
233
234
|
baseURL: params.baseURL,
|
|
235
|
+
...params.fetchOptions,
|
|
234
236
|
async onRequest({ request, options }) {
|
|
235
237
|
const isExpired = sessionData.expirationTime <= Date.now();
|
|
236
238
|
if (isExpired && !request.toString().includes("/oauth/token")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shopware client for API connection.",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"type": "module",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"./admin-api-types": "./api-types/adminApiTypes.d.ts"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@biomejs/biome": "1.8.3",
|
|
45
46
|
"@codspeed/vitest-plugin": "3.1.1",
|
|
46
47
|
"@types/prettier": "3.0.0",
|
|
47
|
-
"@vitest/coverage-v8": "2.1.
|
|
48
|
+
"@vitest/coverage-v8": "2.1.8",
|
|
48
49
|
"jsdom": "^25.0.1",
|
|
49
|
-
"prettier": "3.
|
|
50
|
+
"prettier": "3.4.2",
|
|
50
51
|
"unbuild": "2.0.0",
|
|
51
|
-
"vitest": "2.1.
|
|
52
|
-
"eslint-config-shopware": "1.0.0",
|
|
52
|
+
"vitest": "2.1.8",
|
|
53
53
|
"tsconfig": "0.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"build": "export NODE_ENV=production && unbuild && pnpm build:types",
|
|
62
62
|
"build:types": "tsc ./src/*.ts --declaration --allowJs --emitDeclarationOnly --outDir ./temp --skipLibCheck",
|
|
63
63
|
"dev": "export NODE_ENV=development && unbuild --stub",
|
|
64
|
-
"lint": "
|
|
64
|
+
"lint": "biome check .",
|
|
65
|
+
"lint:fix": "biome check . --write && pnpm typecheck",
|
|
65
66
|
"typecheck": "tsc --noEmit",
|
|
66
67
|
"test": "vitest run --typecheck",
|
|
67
68
|
"test:bench": "vitest bench",
|