@dataggo/node-akeneo-api 1.0.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/LICENSE +21 -0
- package/README.md +92 -0
- package/dist/cjs/endpoints/asset-family.d.ts +39 -0
- package/dist/cjs/endpoints/asset-family.js +41 -0
- package/dist/cjs/endpoints/attribute.d.ts +24 -0
- package/dist/cjs/endpoints/attribute.js +30 -0
- package/dist/cjs/endpoints/category.d.ts +21 -0
- package/dist/cjs/endpoints/category.js +39 -0
- package/dist/cjs/endpoints/family.d.ts +15 -0
- package/dist/cjs/endpoints/family.js +21 -0
- package/dist/cjs/endpoints/index.d.ts +7 -0
- package/dist/cjs/endpoints/index.js +29 -0
- package/dist/cjs/endpoints/product-model.d.ts +17 -0
- package/dist/cjs/endpoints/product-model.js +31 -0
- package/dist/cjs/endpoints/product.d.ts +21 -0
- package/dist/cjs/endpoints/product.js +33 -0
- package/dist/cjs/endpoints/raw.d.ts +11 -0
- package/dist/cjs/endpoints/raw.js +92 -0
- package/dist/cjs/endpoints/reference-entity.d.ts +15 -0
- package/dist/cjs/endpoints/reference-entity.js +21 -0
- package/dist/cjs/error-handler.d.ts +2 -0
- package/dist/cjs/error-handler.js +32 -0
- package/dist/cjs/http-client.d.ts +16 -0
- package/dist/cjs/http-client.js +87 -0
- package/dist/cjs/index.d.ts +349 -0
- package/dist/cjs/index.js +166 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types.d.ts +243 -0
- package/dist/cjs/types.js +2 -0
- package/dist/mjs/endpoints/asset-family.d.ts +39 -0
- package/dist/mjs/endpoints/asset-family.js +31 -0
- package/dist/mjs/endpoints/attribute.d.ts +24 -0
- package/dist/mjs/endpoints/attribute.js +22 -0
- package/dist/mjs/endpoints/category.d.ts +21 -0
- package/dist/mjs/endpoints/category.js +18 -0
- package/dist/mjs/endpoints/family.d.ts +15 -0
- package/dist/mjs/endpoints/family.js +17 -0
- package/dist/mjs/endpoints/index.d.ts +7 -0
- package/dist/mjs/endpoints/index.js +7 -0
- package/dist/mjs/endpoints/product-model.d.ts +17 -0
- package/dist/mjs/endpoints/product-model.js +22 -0
- package/dist/mjs/endpoints/product.d.ts +21 -0
- package/dist/mjs/endpoints/product.js +24 -0
- package/dist/mjs/endpoints/raw.d.ts +11 -0
- package/dist/mjs/endpoints/raw.js +81 -0
- package/dist/mjs/endpoints/reference-entity.d.ts +15 -0
- package/dist/mjs/endpoints/reference-entity.js +13 -0
- package/dist/mjs/error-handler.d.ts +2 -0
- package/dist/mjs/error-handler.js +33 -0
- package/dist/mjs/http-client.d.ts +16 -0
- package/dist/mjs/http-client.js +86 -0
- package/dist/mjs/index.d.ts +349 -0
- package/dist/mjs/index.js +124 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/types.d.ts +243 -0
- package/dist/mjs/types.js +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
export declare type AppParams = {
|
|
3
|
+
/**
|
|
4
|
+
* API host
|
|
5
|
+
*/
|
|
6
|
+
url: string;
|
|
7
|
+
/**
|
|
8
|
+
* App access token
|
|
9
|
+
*/
|
|
10
|
+
accessToken: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional: axiosOptions (https://github.com/axios/axios#request-config)
|
|
13
|
+
*/
|
|
14
|
+
axiosOptions?: AxiosRequestConfig;
|
|
15
|
+
};
|
|
16
|
+
export declare type ClientParams = {
|
|
17
|
+
/**
|
|
18
|
+
* API host
|
|
19
|
+
*/
|
|
20
|
+
url: string;
|
|
21
|
+
/**
|
|
22
|
+
* username
|
|
23
|
+
*/
|
|
24
|
+
username: string;
|
|
25
|
+
/**
|
|
26
|
+
* password
|
|
27
|
+
*/
|
|
28
|
+
password: string;
|
|
29
|
+
/**
|
|
30
|
+
* clientId of your app
|
|
31
|
+
*/
|
|
32
|
+
clientId: string;
|
|
33
|
+
/**
|
|
34
|
+
* matching secret
|
|
35
|
+
*/
|
|
36
|
+
secret: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional: axiosOptions (https://github.com/axios/axios#request-config)
|
|
39
|
+
*/
|
|
40
|
+
axiosOptions?: AxiosRequestConfig;
|
|
41
|
+
};
|
|
42
|
+
export declare type PaginationType = 'page' | 'search_after';
|
|
43
|
+
export declare type ProductModelQueryParameters = {
|
|
44
|
+
search?: string;
|
|
45
|
+
scope?: string;
|
|
46
|
+
locales?: string;
|
|
47
|
+
attributes?: string;
|
|
48
|
+
pagination_type?: PaginationType;
|
|
49
|
+
page?: number;
|
|
50
|
+
search_after?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
with_count?: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare type ProductQueryParameters = {
|
|
55
|
+
search?: string;
|
|
56
|
+
scope?: string;
|
|
57
|
+
locales?: string;
|
|
58
|
+
attributes?: string;
|
|
59
|
+
pagination_type?: PaginationType;
|
|
60
|
+
page?: number;
|
|
61
|
+
search_after?: string;
|
|
62
|
+
limit?: number;
|
|
63
|
+
with_count?: boolean;
|
|
64
|
+
with_attribute_options?: boolean;
|
|
65
|
+
with_quality_scores?: boolean;
|
|
66
|
+
};
|
|
67
|
+
export declare type CategoryQueryParameters = {
|
|
68
|
+
search?: string;
|
|
69
|
+
page?: number;
|
|
70
|
+
limit?: number;
|
|
71
|
+
with_count?: boolean;
|
|
72
|
+
};
|
|
73
|
+
export declare type AttributeQueryParameters = {
|
|
74
|
+
search?: string;
|
|
75
|
+
page?: number;
|
|
76
|
+
limit?: number;
|
|
77
|
+
with_count?: boolean;
|
|
78
|
+
};
|
|
79
|
+
export declare type AttributeOptionQueryParameters = {
|
|
80
|
+
page?: number;
|
|
81
|
+
limit?: number;
|
|
82
|
+
with_count?: boolean;
|
|
83
|
+
};
|
|
84
|
+
export declare type ReferenceEntityQueryParameters = {
|
|
85
|
+
search?: string;
|
|
86
|
+
page?: number;
|
|
87
|
+
limit?: number;
|
|
88
|
+
with_count?: boolean;
|
|
89
|
+
};
|
|
90
|
+
export declare type FamilyQueryParameters = {
|
|
91
|
+
search?: string;
|
|
92
|
+
page?: number;
|
|
93
|
+
limit?: number;
|
|
94
|
+
with_count?: boolean;
|
|
95
|
+
};
|
|
96
|
+
export declare type FamilyVariantQueryParameters = {
|
|
97
|
+
page?: number;
|
|
98
|
+
limit?: number;
|
|
99
|
+
with_count?: boolean;
|
|
100
|
+
};
|
|
101
|
+
export declare type ReferenceEntityRecordQueryParameters = {
|
|
102
|
+
search_after?: string;
|
|
103
|
+
};
|
|
104
|
+
export declare type AssetFamilyQueryParameters = {
|
|
105
|
+
search_after?: string;
|
|
106
|
+
};
|
|
107
|
+
export declare type AssetQueryParameters = {
|
|
108
|
+
search?: string;
|
|
109
|
+
channel?: string;
|
|
110
|
+
locales?: string;
|
|
111
|
+
search_after?: string;
|
|
112
|
+
};
|
|
113
|
+
export declare type ListResponse<T> = {
|
|
114
|
+
items_count?: number;
|
|
115
|
+
current_page?: number;
|
|
116
|
+
items: T[];
|
|
117
|
+
};
|
|
118
|
+
declare type Association = {
|
|
119
|
+
products: string[];
|
|
120
|
+
product_models: string[];
|
|
121
|
+
groups: string[];
|
|
122
|
+
};
|
|
123
|
+
export declare type ProductModel = {
|
|
124
|
+
code: string;
|
|
125
|
+
family: string;
|
|
126
|
+
family_variant: string;
|
|
127
|
+
parent?: string;
|
|
128
|
+
categories: string[];
|
|
129
|
+
values: Record<string, any>;
|
|
130
|
+
created: string;
|
|
131
|
+
updated: string;
|
|
132
|
+
associations: Record<string, Association>;
|
|
133
|
+
quantified_associations: Record<string, Association>;
|
|
134
|
+
metadata: Record<string, any>;
|
|
135
|
+
};
|
|
136
|
+
export declare type Product = {
|
|
137
|
+
identifier: string;
|
|
138
|
+
uuid?: string;
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
family: string;
|
|
141
|
+
categories: string[];
|
|
142
|
+
groups: string[];
|
|
143
|
+
parent: string;
|
|
144
|
+
values: Record<string, any>;
|
|
145
|
+
associations: Record<string, Association>;
|
|
146
|
+
created: string;
|
|
147
|
+
updated: string;
|
|
148
|
+
quantified_associations: Record<string, Association>;
|
|
149
|
+
metadata: Record<string, any>;
|
|
150
|
+
};
|
|
151
|
+
export declare type Family = {
|
|
152
|
+
code: string;
|
|
153
|
+
attribute_as_label: string;
|
|
154
|
+
attribute_as_image: string;
|
|
155
|
+
attributes: string[];
|
|
156
|
+
attribute_requirements: Record<string, any>;
|
|
157
|
+
labels: Record<string, any>;
|
|
158
|
+
};
|
|
159
|
+
declare type VariantAttributeSet = {
|
|
160
|
+
level: number;
|
|
161
|
+
attributes: string[];
|
|
162
|
+
axes: string[];
|
|
163
|
+
};
|
|
164
|
+
export declare type Variant = {
|
|
165
|
+
code: string;
|
|
166
|
+
variant_attribute_sets: VariantAttributeSet[];
|
|
167
|
+
labels: Record<string, any>;
|
|
168
|
+
};
|
|
169
|
+
export declare type Attribute = {
|
|
170
|
+
code: string;
|
|
171
|
+
type: string;
|
|
172
|
+
labels: Record<string, string>;
|
|
173
|
+
group: string;
|
|
174
|
+
group_labels: Record<string, string>;
|
|
175
|
+
sort_order: number;
|
|
176
|
+
localizable: boolean;
|
|
177
|
+
scopable: boolean;
|
|
178
|
+
available_locales: string[];
|
|
179
|
+
unique: boolean;
|
|
180
|
+
useable_as_grid_filter: boolean;
|
|
181
|
+
max_characters: number;
|
|
182
|
+
validation_rule: string;
|
|
183
|
+
validation_regexp: string;
|
|
184
|
+
wysiwyg_enabled: boolean;
|
|
185
|
+
number_min: string;
|
|
186
|
+
number_max: string;
|
|
187
|
+
decimals_allowed: boolean;
|
|
188
|
+
negative_allowed: boolean;
|
|
189
|
+
metric_family: string;
|
|
190
|
+
default_metric_unit: string;
|
|
191
|
+
date_min: string;
|
|
192
|
+
date_max: string;
|
|
193
|
+
allowed_extensions: string[];
|
|
194
|
+
max_file_size: string;
|
|
195
|
+
reference_data_name: string;
|
|
196
|
+
default_value: boolean;
|
|
197
|
+
};
|
|
198
|
+
export declare type AttributeOption = {
|
|
199
|
+
code: string;
|
|
200
|
+
attribute: string;
|
|
201
|
+
sort_order: number;
|
|
202
|
+
labels: Record<string, string>;
|
|
203
|
+
};
|
|
204
|
+
declare type ValuesRecord = {
|
|
205
|
+
locale: string;
|
|
206
|
+
channel: string;
|
|
207
|
+
data: string | string[];
|
|
208
|
+
};
|
|
209
|
+
export declare type KeyValueMap = Record<string, any>;
|
|
210
|
+
export declare type Entity = {
|
|
211
|
+
code: string;
|
|
212
|
+
labels: KeyValueMap;
|
|
213
|
+
};
|
|
214
|
+
export declare type EntityRecord = {
|
|
215
|
+
code: string;
|
|
216
|
+
values: Record<string, ValuesRecord[]>;
|
|
217
|
+
};
|
|
218
|
+
export declare type Category<T = KeyValueMap> = {
|
|
219
|
+
code: string;
|
|
220
|
+
parent?: string;
|
|
221
|
+
labels: T;
|
|
222
|
+
};
|
|
223
|
+
export declare type AssetFamily = {
|
|
224
|
+
code: string;
|
|
225
|
+
labels: Record<string, string>;
|
|
226
|
+
attribute_as_main_media: string;
|
|
227
|
+
product_link_rules: Record<string, Record<string, string>>[];
|
|
228
|
+
transformations: any[];
|
|
229
|
+
naming_convention: {
|
|
230
|
+
source: {
|
|
231
|
+
property: string;
|
|
232
|
+
channel: any;
|
|
233
|
+
locale: any;
|
|
234
|
+
};
|
|
235
|
+
pattern: string;
|
|
236
|
+
abort_asset_creation_on_error: boolean;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
export declare type Asset = {
|
|
240
|
+
code: string;
|
|
241
|
+
values: Record<string, ValuesRecord[]>;
|
|
242
|
+
};
|
|
243
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { Asset, AssetFamily, AssetFamilyQueryParameters, AssetQueryParameters, ListResponse } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#Assetfamily
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, params: {
|
|
7
|
+
query?: AssetFamilyQueryParameters;
|
|
8
|
+
}) => Promise<ListResponse<AssetFamily>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_asset_family__code_
|
|
11
|
+
*/
|
|
12
|
+
export declare const getOne: (http: AxiosInstance, { code, query, }: {
|
|
13
|
+
code: string;
|
|
14
|
+
query?: {
|
|
15
|
+
with_attribute_options?: boolean | undefined;
|
|
16
|
+
with_quality_scores?: boolean | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}) => Promise<AssetFamily>;
|
|
19
|
+
export declare const getAll: (http: AxiosInstance, { query }: {
|
|
20
|
+
query?: AssetFamilyQueryParameters | undefined;
|
|
21
|
+
}) => Promise<ListResponse<AssetFamily>>;
|
|
22
|
+
/**
|
|
23
|
+
* @see https://api.akeneo.com/api-reference.html#get_assets
|
|
24
|
+
*/
|
|
25
|
+
export declare const getAssets: (http: AxiosInstance, { assetFamilyCode, query, }: {
|
|
26
|
+
assetFamilyCode: string;
|
|
27
|
+
query?: AssetQueryParameters | undefined;
|
|
28
|
+
}) => Promise<ListResponse<Asset>>;
|
|
29
|
+
/**
|
|
30
|
+
* @see https://api.akeneo.com/api-reference.html#get_assets__code_
|
|
31
|
+
*/
|
|
32
|
+
export declare const getAsset: (http: AxiosInstance, { assetFamilyCode, code, }: {
|
|
33
|
+
assetFamilyCode: string;
|
|
34
|
+
code: string;
|
|
35
|
+
}) => Promise<Asset>;
|
|
36
|
+
export declare const getAssetsAll: (http: AxiosInstance, { assetFamilyCode, query, }: {
|
|
37
|
+
assetFamilyCode: string;
|
|
38
|
+
query?: AssetQueryParameters | undefined;
|
|
39
|
+
}) => Promise<ListResponse<Asset>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#Assetfamily
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, params) => raw.get(http, `/api/rest/v1/asset-families`, {
|
|
6
|
+
params: {
|
|
7
|
+
...params.query,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @see https://api.akeneo.com/api-reference.html#get_asset_family__code_
|
|
12
|
+
*/
|
|
13
|
+
export const getOne = (http, { code, query, }) => raw.getOne(http, `/api/rest/v1/asset-families/${code}`, {
|
|
14
|
+
params: query,
|
|
15
|
+
});
|
|
16
|
+
export const getAll = (http, { query }) => raw.getAllBySearchAfter(http, `/api/rest/v1/asset-families`, {
|
|
17
|
+
params: query,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* @see https://api.akeneo.com/api-reference.html#get_assets
|
|
21
|
+
*/
|
|
22
|
+
export const getAssets = (http, { assetFamilyCode, query, }) => raw.get(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets`, {
|
|
23
|
+
params: query,
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* @see https://api.akeneo.com/api-reference.html#get_assets__code_
|
|
27
|
+
*/
|
|
28
|
+
export const getAsset = (http, { assetFamilyCode, code, }) => raw.getOne(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets/${code}`, {});
|
|
29
|
+
export const getAssetsAll = (http, { assetFamilyCode, query, }) => raw.getAllBySearchAfter(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets`, {
|
|
30
|
+
params: query,
|
|
31
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, Attribute, AttributeOption, AttributeQueryParameters, AttributeOptionQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, params: {
|
|
7
|
+
query?: AttributeQueryParameters;
|
|
8
|
+
}) => Promise<ListResponse<Attribute>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes__code_
|
|
11
|
+
*/
|
|
12
|
+
export declare const getOne: (http: AxiosInstance, { code, }: {
|
|
13
|
+
code: string;
|
|
14
|
+
}) => Promise<Attribute>;
|
|
15
|
+
export declare const getAll: (http: AxiosInstance, { query }: {
|
|
16
|
+
query?: AttributeQueryParameters | undefined;
|
|
17
|
+
}) => Promise<ListResponse<Attribute>>;
|
|
18
|
+
/**
|
|
19
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes__attribute_code__options
|
|
20
|
+
*/
|
|
21
|
+
export declare const getOptions: (http: AxiosInstance, { attributeCode, query, }: {
|
|
22
|
+
attributeCode: string;
|
|
23
|
+
query?: AttributeOptionQueryParameters | undefined;
|
|
24
|
+
}) => Promise<ListResponse<AttributeOption>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, params) => raw.get(http, `/api/rest/v1/attributes`, {
|
|
6
|
+
params: {
|
|
7
|
+
...params.query,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes__code_
|
|
12
|
+
*/
|
|
13
|
+
export const getOne = (http, { code, }) => raw.getOne(http, `/api/rest/v1/attributes/${code}`);
|
|
14
|
+
export const getAll = (http, { query = {} }) => raw.getAllByPage(http, `/api/rest/v1/attributes`, {
|
|
15
|
+
params: query,
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* @see https://api.akeneo.com/api-reference.html#get_attributes__attribute_code__options
|
|
19
|
+
*/
|
|
20
|
+
export const getOptions = (http, { attributeCode, query, }) => raw.getAllByPage(http, `/api/rest/v1/attributes/${attributeCode}/options`, {
|
|
21
|
+
params: query,
|
|
22
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, Category, CategoryQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#Category
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, params: {
|
|
7
|
+
query?: CategoryQueryParameters;
|
|
8
|
+
}) => Promise<ListResponse<Category>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_categories__code_
|
|
11
|
+
*/
|
|
12
|
+
export declare const getOne: (http: AxiosInstance, { code, ...params }: {
|
|
13
|
+
code: string;
|
|
14
|
+
query?: {
|
|
15
|
+
with_attribute_options?: boolean | undefined;
|
|
16
|
+
with_quality_scores?: boolean | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}) => Promise<Category>;
|
|
19
|
+
export declare const getAll: (http: AxiosInstance, params: {
|
|
20
|
+
query?: CategoryQueryParameters;
|
|
21
|
+
}) => Promise<ListResponse<Category>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#Category
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, params) => raw.get(http, `/api/rest/v1/categories`, {
|
|
6
|
+
params: {
|
|
7
|
+
...params.query,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @see https://api.akeneo.com/api-reference.html#get_categories__code_
|
|
12
|
+
*/
|
|
13
|
+
export const getOne = (http, { code, ...params }) => raw.getOne(http, `/api/rest/v1/categories/${code}`, {
|
|
14
|
+
params,
|
|
15
|
+
});
|
|
16
|
+
export const getAll = (http, params) => raw.getAllByPage(http, `/api/rest/v1/categories`, {
|
|
17
|
+
params,
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, Family, Variant, FamilyQueryParameters, FamilyVariantQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#get_families
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, params: {
|
|
7
|
+
query?: FamilyQueryParameters;
|
|
8
|
+
}) => Promise<ListResponse<Family>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#Familyvariant
|
|
11
|
+
*/
|
|
12
|
+
export declare const getVariants: (http: AxiosInstance, params: {
|
|
13
|
+
familyCode: string;
|
|
14
|
+
query?: FamilyVariantQueryParameters;
|
|
15
|
+
}) => Promise<ListResponse<Variant>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#get_families
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, params) => raw.get(http, `/api/rest/v1/families`, {
|
|
6
|
+
params: {
|
|
7
|
+
...params.query,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* @see https://api.akeneo.com/api-reference.html#Familyvariant
|
|
12
|
+
*/
|
|
13
|
+
export const getVariants = (http, params) => raw.get(http, `/api/rest/v1/families/${params.familyCode}/variants`, {
|
|
14
|
+
params: {
|
|
15
|
+
...params.query,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * as assetFamily from './asset-family';
|
|
2
|
+
export * as attribute from './attribute';
|
|
3
|
+
export * as category from './category';
|
|
4
|
+
export * as family from './family';
|
|
5
|
+
export * as productModel from './product-model';
|
|
6
|
+
export * as product from './product';
|
|
7
|
+
export * as referenceEntity from './reference-entity';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * as assetFamily from './asset-family';
|
|
2
|
+
export * as attribute from './attribute';
|
|
3
|
+
export * as category from './category';
|
|
4
|
+
export * as family from './family';
|
|
5
|
+
export * as productModel from './product-model';
|
|
6
|
+
export * as product from './product';
|
|
7
|
+
export * as referenceEntity from './reference-entity';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, ProductModel, ProductModelQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#get_product_models
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, { query }: {
|
|
7
|
+
query?: ProductModelQueryParameters | undefined;
|
|
8
|
+
}) => Promise<ListResponse<ProductModel>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_product_models__code_
|
|
11
|
+
*/
|
|
12
|
+
export declare const getOne: (http: AxiosInstance, params: {
|
|
13
|
+
code: string;
|
|
14
|
+
}) => Promise<ProductModel>;
|
|
15
|
+
export declare const getAll: (http: AxiosInstance, { query }: {
|
|
16
|
+
query?: ProductModelQueryParameters | undefined;
|
|
17
|
+
}) => Promise<ListResponse<ProductModel>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#get_product_models
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, { query }) => raw.get(http, `/api/rest/v1/product-models`, {
|
|
6
|
+
params: query,
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* @see https://api.akeneo.com/api-reference.html#get_product_models__code_
|
|
10
|
+
*/
|
|
11
|
+
export const getOne = (http, params) => raw.getOne(http, `/api/rest/v1/product-models/${params.code}`, {});
|
|
12
|
+
export const getAll = (http, { query }) => {
|
|
13
|
+
// support legacy pagination_type "page"
|
|
14
|
+
if (query?.pagination_type === 'page') {
|
|
15
|
+
return raw.getAllByPage(http, `/api/rest/v1/product-models`, {
|
|
16
|
+
params: query,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return raw.getAllBySearchAfter(http, `/api/rest/v1/product-models`, {
|
|
20
|
+
params: query,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, Product, ProductQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#get_products
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, { query }: {
|
|
7
|
+
query?: ProductQueryParameters | undefined;
|
|
8
|
+
}) => Promise<ListResponse<Product>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_products__code_
|
|
11
|
+
*/
|
|
12
|
+
export declare const getOne: (http: AxiosInstance, { code, query, }: {
|
|
13
|
+
code: string;
|
|
14
|
+
query?: {
|
|
15
|
+
with_attribute_options?: boolean | undefined;
|
|
16
|
+
with_quality_scores?: boolean | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}) => Promise<Product>;
|
|
19
|
+
export declare const getAll: (http: AxiosInstance, { query }: {
|
|
20
|
+
query?: ProductQueryParameters | undefined;
|
|
21
|
+
}) => Promise<ListResponse<Product>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#get_products
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, { query }) => raw.get(http, `/api/rest/v1/products`, {
|
|
6
|
+
params: query,
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* @see https://api.akeneo.com/api-reference.html#get_products__code_
|
|
10
|
+
*/
|
|
11
|
+
export const getOne = (http, { code, query, }) => raw.getOne(http, `/api/rest/v1/products/${code}`, {
|
|
12
|
+
params: query,
|
|
13
|
+
});
|
|
14
|
+
export const getAll = (http, { query = {} }) => {
|
|
15
|
+
// support legacy pagination_type "page"
|
|
16
|
+
if (query?.pagination_type === 'page') {
|
|
17
|
+
return raw.getAllByPage(http, `/api/rest/v1/products`, {
|
|
18
|
+
params: query,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return raw.getAllBySearchAfter(http, `/api/rest/v1/products`, {
|
|
22
|
+
params: query,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { ListResponse } from '../types';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
get: (http: AxiosInstance, url: string, config: AxiosRequestConfig) => Promise<ListResponse<any> & {
|
|
5
|
+
_links: any;
|
|
6
|
+
}>;
|
|
7
|
+
getOne: (http: AxiosInstance, url: string, config?: AxiosRequestConfig | undefined) => Promise<any>;
|
|
8
|
+
getAllByPage: (http: AxiosInstance, url: string, { params }: AxiosRequestConfig) => Promise<ListResponse<any>>;
|
|
9
|
+
getAllBySearchAfter: (http: AxiosInstance, url: string, config?: AxiosRequestConfig | undefined) => Promise<ListResponse<any>>;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as querystring from 'querystring';
|
|
2
|
+
import errorHandler from '../error-handler';
|
|
3
|
+
export default {
|
|
4
|
+
get: function get(http, url, config) {
|
|
5
|
+
return http
|
|
6
|
+
.get(url, {
|
|
7
|
+
...config,
|
|
8
|
+
})
|
|
9
|
+
.then((response) => {
|
|
10
|
+
const { data } = response;
|
|
11
|
+
return {
|
|
12
|
+
...(data.current_page ? { current_page: data.current_page } : {}),
|
|
13
|
+
...(data.items_count ? { items_count: data.items_count } : {}),
|
|
14
|
+
items: data._embedded.items,
|
|
15
|
+
_links: data._links,
|
|
16
|
+
};
|
|
17
|
+
}, errorHandler);
|
|
18
|
+
},
|
|
19
|
+
getOne: function getOne(http, url, config) {
|
|
20
|
+
return http
|
|
21
|
+
.get(url, {
|
|
22
|
+
...config,
|
|
23
|
+
})
|
|
24
|
+
.then((response) => {
|
|
25
|
+
const { data } = response;
|
|
26
|
+
return data;
|
|
27
|
+
}, errorHandler);
|
|
28
|
+
},
|
|
29
|
+
getAllByPage: async function getAllByPage(http, url, { params = {} }) {
|
|
30
|
+
const page = params?.page || 1;
|
|
31
|
+
const { items_count = 0, items } = await this.get(http, url, {
|
|
32
|
+
params: {
|
|
33
|
+
...params,
|
|
34
|
+
with_count: true,
|
|
35
|
+
limit: 100,
|
|
36
|
+
page,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return items_count / 100 > page
|
|
40
|
+
? {
|
|
41
|
+
items: [
|
|
42
|
+
...items,
|
|
43
|
+
...(await this.getAllByPage(http, url, {
|
|
44
|
+
params: {
|
|
45
|
+
...params,
|
|
46
|
+
limit: 100,
|
|
47
|
+
page: page + 1,
|
|
48
|
+
},
|
|
49
|
+
})).items,
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
: { items };
|
|
53
|
+
},
|
|
54
|
+
getAllBySearchAfter: async function getAllBySearchAfter(http, url, config) {
|
|
55
|
+
const params = config?.params;
|
|
56
|
+
const { items, _links } = await this.get(http, url, {
|
|
57
|
+
params: {
|
|
58
|
+
...(params?.search_after ? { search_after: params.search_after } : {}),
|
|
59
|
+
pagination_type: 'search_after',
|
|
60
|
+
limit: 100,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const nextUrl = _links?.next?.href;
|
|
64
|
+
if (!nextUrl)
|
|
65
|
+
return { items };
|
|
66
|
+
const search_after = querystring.parse(nextUrl.split('?').at(1))?.search_after || '';
|
|
67
|
+
return {
|
|
68
|
+
items: [
|
|
69
|
+
...items,
|
|
70
|
+
...(await this.getAllBySearchAfter(http, url, {
|
|
71
|
+
params: {
|
|
72
|
+
...params,
|
|
73
|
+
limit: params?.limit || 100,
|
|
74
|
+
pagination_type: 'search_after',
|
|
75
|
+
search_after,
|
|
76
|
+
},
|
|
77
|
+
})).items,
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ListResponse, Entity, EntityRecord, ReferenceEntityQueryParameters, ReferenceEntityRecordQueryParameters } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entities
|
|
5
|
+
*/
|
|
6
|
+
export declare const get: (http: AxiosInstance, { query }: {
|
|
7
|
+
query?: ReferenceEntityQueryParameters | undefined;
|
|
8
|
+
}) => Promise<ListResponse<Entity>>;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entity_records
|
|
11
|
+
*/
|
|
12
|
+
export declare const getRecords: (http: AxiosInstance, { referenceEntityCode, query, }: {
|
|
13
|
+
referenceEntityCode: string;
|
|
14
|
+
query?: ReferenceEntityRecordQueryParameters | undefined;
|
|
15
|
+
}) => Promise<ListResponse<EntityRecord>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import raw from './raw';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entities
|
|
4
|
+
*/
|
|
5
|
+
export const get = (http, { query }) => raw.get(http, `/api/rest/v1/reference-entities`, {
|
|
6
|
+
params: query,
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entity_records
|
|
10
|
+
*/
|
|
11
|
+
export const getRecords = (http, { referenceEntityCode, query, }) => raw.get(http, `/api/rest/v1/reference-entities/${referenceEntityCode}/records`, {
|
|
12
|
+
params: query,
|
|
13
|
+
});
|