@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,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ramda_1 = require("ramda");
|
|
4
|
+
const cleanHeaders = (headers) => headers && headers.Authorization
|
|
5
|
+
? Object.assign(Object.assign({}, headers), { Authorization: `Bearer ${`...${headers.Authorization.substr(-5)}`}` }) : headers;
|
|
6
|
+
function errorHandler({ config, response }) {
|
|
7
|
+
const data = response === null || response === void 0 ? void 0 : response.data;
|
|
8
|
+
const errorData = {
|
|
9
|
+
status: response === null || response === void 0 ? void 0 : response.status,
|
|
10
|
+
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
11
|
+
message: data && 'message' in data ? data.message : '',
|
|
12
|
+
details: data && 'details' in data ? data.details : {},
|
|
13
|
+
request: config
|
|
14
|
+
? {
|
|
15
|
+
url: config.url,
|
|
16
|
+
headers: cleanHeaders(config.headers),
|
|
17
|
+
method: config.method,
|
|
18
|
+
payloadData: config.data,
|
|
19
|
+
}
|
|
20
|
+
: {},
|
|
21
|
+
};
|
|
22
|
+
const error = new Error();
|
|
23
|
+
error.name = `${response === null || response === void 0 ? void 0 : response.status} ${response === null || response === void 0 ? void 0 : response.statusText}`;
|
|
24
|
+
try {
|
|
25
|
+
error.message = JSON.stringify(errorData, null, ' ');
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
error.message = ramda_1.path(['message'], errorData) || '';
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
exports.default = errorHandler;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AppParams, ClientParams } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Create pre-configured axios instance
|
|
5
|
+
* @private
|
|
6
|
+
* @param {ClientParams} options - Initialization parameters for the HTTP client
|
|
7
|
+
* @return {AxiosInstance} Initialized axios instance
|
|
8
|
+
*/
|
|
9
|
+
export declare const createConnectionHttpClient: (options: ClientParams) => AxiosInstance;
|
|
10
|
+
/**
|
|
11
|
+
* Create pre-configured axios instance
|
|
12
|
+
* @private
|
|
13
|
+
* @param {ClientParams} options - Initialization parameters for the HTTP client
|
|
14
|
+
* @return {AxiosInstance} Initialized axios instance
|
|
15
|
+
*/
|
|
16
|
+
export declare const createAppHttpClient: (options: AppParams) => AxiosInstance;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createAppHttpClient = exports.createConnectionHttpClient = void 0;
|
|
16
|
+
/* eslint-disable no-underscore-dangle */
|
|
17
|
+
const qs_1 = __importDefault(require("qs"));
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const TOKEN_PATH = '/api/oauth/v1/token';
|
|
20
|
+
const defaultConfig = {
|
|
21
|
+
insecure: false,
|
|
22
|
+
retryOnError: true,
|
|
23
|
+
headers: {},
|
|
24
|
+
httpAgent: false,
|
|
25
|
+
httpsAgent: false,
|
|
26
|
+
timeout: 30000,
|
|
27
|
+
proxy: false,
|
|
28
|
+
basePath: '',
|
|
29
|
+
adapter: undefined,
|
|
30
|
+
maxContentLength: 1073741824,
|
|
31
|
+
paramsSerializer: qs_1.default.stringify,
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create pre-configured axios instance
|
|
35
|
+
* @private
|
|
36
|
+
* @param {ClientParams} options - Initialization parameters for the HTTP client
|
|
37
|
+
* @return {AxiosInstance} Initialized axios instance
|
|
38
|
+
*/
|
|
39
|
+
const createConnectionHttpClient = (options) => {
|
|
40
|
+
let accessToken = '';
|
|
41
|
+
const { url, clientId, secret, username, password } = options;
|
|
42
|
+
const baseURL = url.replace(/\/+$/, '');
|
|
43
|
+
const instance = axios_1.default.create(Object.assign(Object.assign(Object.assign({}, defaultConfig), (options.axiosOptions || {})), { baseURL }));
|
|
44
|
+
const base64Encoded = Buffer.from(`${clientId}:${secret}`).toString('base64');
|
|
45
|
+
const refreshAccessToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const tokenResult = yield axios_1.default.post(`${baseURL}${TOKEN_PATH}`, { grant_type: 'password', username, password }, {
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: `Basic ${base64Encoded}`,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
accessToken = tokenResult.data.access_token;
|
|
52
|
+
return accessToken;
|
|
53
|
+
});
|
|
54
|
+
instance.interceptors.request.use((config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
return (Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${accessToken || (yield refreshAccessToken())}` }) }));
|
|
56
|
+
}));
|
|
57
|
+
instance.interceptors.response.use((response) => response, (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const originalRequest = error.config;
|
|
59
|
+
if (error.response &&
|
|
60
|
+
(error.response.status === 403 || error.response.status === 401) &&
|
|
61
|
+
!originalRequest._retry) {
|
|
62
|
+
originalRequest._retry = true;
|
|
63
|
+
accessToken = '';
|
|
64
|
+
originalRequest.headers.Authorization = `Bearer ${yield refreshAccessToken()}`;
|
|
65
|
+
return instance(originalRequest);
|
|
66
|
+
}
|
|
67
|
+
return Promise.reject(error);
|
|
68
|
+
}));
|
|
69
|
+
return instance;
|
|
70
|
+
};
|
|
71
|
+
exports.createConnectionHttpClient = createConnectionHttpClient;
|
|
72
|
+
/**
|
|
73
|
+
* Create pre-configured axios instance
|
|
74
|
+
* @private
|
|
75
|
+
* @param {ClientParams} options - Initialization parameters for the HTTP client
|
|
76
|
+
* @return {AxiosInstance} Initialized axios instance
|
|
77
|
+
*/
|
|
78
|
+
const createAppHttpClient = (options) => {
|
|
79
|
+
const { url, accessToken } = options;
|
|
80
|
+
const baseURL = url.replace(/\/+$/, '');
|
|
81
|
+
const instance = axios_1.default.create(Object.assign(Object.assign(Object.assign({}, defaultConfig), (options.axiosOptions || {})), { baseURL }));
|
|
82
|
+
instance.interceptors.request.use((config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
return (Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, config.headers), { Authorization: `Bearer ${accessToken}` }) }));
|
|
84
|
+
}));
|
|
85
|
+
return instance;
|
|
86
|
+
};
|
|
87
|
+
exports.createAppHttpClient = createAppHttpClient;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Akeneo Management API SDK. Allows you to create instances of a client
|
|
3
|
+
* with access to the Akeneo API.
|
|
4
|
+
*/
|
|
5
|
+
import { AxiosInstance } from 'axios';
|
|
6
|
+
import { AppParams, ClientParams } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Create a client instance
|
|
9
|
+
* @param params - Client initialization parameters
|
|
10
|
+
*
|
|
11
|
+
* ```javascript
|
|
12
|
+
* const client = akeneo({
|
|
13
|
+
* url: AKENEO_API_URL,
|
|
14
|
+
* username: AKENEO_USERNAME,
|
|
15
|
+
* password: AKENEO_PASSWORD,
|
|
16
|
+
* clientId: AKENEO_CLIENT_ID,
|
|
17
|
+
* secret: AKENEO_SECRET,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const createClient: (params: ClientParams) => {
|
|
22
|
+
raw: {
|
|
23
|
+
http: AxiosInstance;
|
|
24
|
+
};
|
|
25
|
+
category: {
|
|
26
|
+
getOne: (params: {
|
|
27
|
+
code: string;
|
|
28
|
+
query?: {
|
|
29
|
+
with_attribute_options?: boolean | undefined;
|
|
30
|
+
with_quality_scores?: boolean | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}) => Promise<import("./types").Category<Record<string, any>>>;
|
|
33
|
+
get: (params: {
|
|
34
|
+
query?: import("./types").CategoryQueryParameters | undefined;
|
|
35
|
+
}) => Promise<import("./types").ListResponse<import("./types").Category<Record<string, any>>>>;
|
|
36
|
+
getAll: (params: {
|
|
37
|
+
query?: import("./types").CategoryQueryParameters | undefined;
|
|
38
|
+
}) => Promise<import("./types").ListResponse<import("./types").Category<Record<string, any>>>>;
|
|
39
|
+
};
|
|
40
|
+
productModel: {
|
|
41
|
+
getOne: (params: {
|
|
42
|
+
code: string;
|
|
43
|
+
}) => Promise<import("./types").ProductModel>;
|
|
44
|
+
get: (params: {
|
|
45
|
+
query?: import("./types").ProductModelQueryParameters | undefined;
|
|
46
|
+
}) => Promise<import("./types").ListResponse<import("./types").ProductModel>>;
|
|
47
|
+
getAll: (params: {
|
|
48
|
+
query?: import("./types").ProductModelQueryParameters | undefined;
|
|
49
|
+
}) => Promise<import("./types").ListResponse<import("./types").ProductModel>>;
|
|
50
|
+
};
|
|
51
|
+
product: {
|
|
52
|
+
getOne: (params: {
|
|
53
|
+
code: string;
|
|
54
|
+
query?: {
|
|
55
|
+
with_attribute_options?: boolean | undefined;
|
|
56
|
+
with_quality_scores?: boolean | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
}) => Promise<import("./types").Product>;
|
|
59
|
+
get: (params: {
|
|
60
|
+
query?: import("./types").ProductQueryParameters | undefined;
|
|
61
|
+
}) => Promise<import("./types").ListResponse<import("./types").Product>>;
|
|
62
|
+
getAll: (params: {
|
|
63
|
+
query?: import("./types").ProductQueryParameters | undefined;
|
|
64
|
+
}) => Promise<import("./types").ListResponse<import("./types").Product>>;
|
|
65
|
+
};
|
|
66
|
+
assetFamily: {
|
|
67
|
+
getOne: (params: {
|
|
68
|
+
code: string;
|
|
69
|
+
query?: {
|
|
70
|
+
with_attribute_options?: boolean | undefined;
|
|
71
|
+
with_quality_scores?: boolean | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
}) => Promise<import("./types").AssetFamily>;
|
|
74
|
+
get: (params: {
|
|
75
|
+
query?: import("./types").AssetFamilyQueryParameters | undefined;
|
|
76
|
+
}) => Promise<import("./types").ListResponse<import("./types").AssetFamily>>;
|
|
77
|
+
getAll: (params: {
|
|
78
|
+
query?: import("./types").AssetFamilyQueryParameters | undefined;
|
|
79
|
+
}) => Promise<import("./types").ListResponse<import("./types").AssetFamily>>;
|
|
80
|
+
getAssets: (params: {
|
|
81
|
+
assetFamilyCode: string;
|
|
82
|
+
query?: import("./types").AssetQueryParameters | undefined;
|
|
83
|
+
}) => Promise<import("./types").ListResponse<import("./types").Asset>>;
|
|
84
|
+
getAsset: (params: {
|
|
85
|
+
assetFamilyCode: string;
|
|
86
|
+
code: string;
|
|
87
|
+
}) => Promise<import("./types").Asset>;
|
|
88
|
+
getAssetsAll: (params: {
|
|
89
|
+
assetFamilyCode: string;
|
|
90
|
+
query?: import("./types").AssetQueryParameters | undefined;
|
|
91
|
+
}) => Promise<import("./types").ListResponse<import("./types").Asset>>;
|
|
92
|
+
};
|
|
93
|
+
assetMediaFile: {
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @see https://api.akeneo.com/api-reference.html#get_asset_media_files__code
|
|
97
|
+
*/
|
|
98
|
+
get: (code: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
99
|
+
};
|
|
100
|
+
referenceEntitiesMediaFile: {
|
|
101
|
+
/**
|
|
102
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entity_media_files__code
|
|
103
|
+
*/
|
|
104
|
+
get: (code: string) => Promise<any>;
|
|
105
|
+
};
|
|
106
|
+
attribute: {
|
|
107
|
+
getOne: (params: {
|
|
108
|
+
code: string;
|
|
109
|
+
}) => Promise<import("./types").Attribute>;
|
|
110
|
+
get: (params: {
|
|
111
|
+
query?: import("./types").AttributeQueryParameters | undefined;
|
|
112
|
+
}) => Promise<import("./types").ListResponse<import("./types").Attribute>>;
|
|
113
|
+
getAll: (params: {
|
|
114
|
+
query?: import("./types").AttributeQueryParameters | undefined;
|
|
115
|
+
}) => Promise<import("./types").ListResponse<import("./types").Attribute>>;
|
|
116
|
+
getOptions: (params: {
|
|
117
|
+
attributeCode: string;
|
|
118
|
+
query?: import("./types").AttributeOptionQueryParameters | undefined;
|
|
119
|
+
}) => Promise<import("./types").ListResponse<import("./types").AttributeOption>>;
|
|
120
|
+
add: ({ code, attribute }: {
|
|
121
|
+
code: string;
|
|
122
|
+
attribute: any;
|
|
123
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
124
|
+
addOption: ({ attributeCode, code, option, }: {
|
|
125
|
+
attributeCode: string;
|
|
126
|
+
code: string;
|
|
127
|
+
option: any;
|
|
128
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
129
|
+
};
|
|
130
|
+
referenceEntity: {
|
|
131
|
+
get: (params: {
|
|
132
|
+
query?: import("./types").ReferenceEntityQueryParameters | undefined;
|
|
133
|
+
}) => Promise<import("./types").ListResponse<import("./types").Entity>>;
|
|
134
|
+
getRecords: (params: {
|
|
135
|
+
referenceEntityCode: string;
|
|
136
|
+
query?: import("./types").ReferenceEntityRecordQueryParameters | undefined;
|
|
137
|
+
}) => Promise<import("./types").ListResponse<import("./types").EntityRecord>>;
|
|
138
|
+
/**
|
|
139
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity__code_
|
|
140
|
+
*/ add: ({ code, body }: {
|
|
141
|
+
code: string;
|
|
142
|
+
body: any;
|
|
143
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
144
|
+
/**
|
|
145
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__code_
|
|
146
|
+
*/
|
|
147
|
+
addAttribute: ({ referenceEntityCode, code, attribute, }: {
|
|
148
|
+
referenceEntityCode: string;
|
|
149
|
+
code: string;
|
|
150
|
+
attribute: any;
|
|
151
|
+
}) => Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__attribute_code__options__code_
|
|
154
|
+
*/
|
|
155
|
+
addAttributeOption: ({ referenceEntityCode, attributeCode, code, option, }: {
|
|
156
|
+
referenceEntityCode: string;
|
|
157
|
+
attributeCode: string;
|
|
158
|
+
code: string;
|
|
159
|
+
option: any;
|
|
160
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
161
|
+
/**
|
|
162
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_records
|
|
163
|
+
*/
|
|
164
|
+
addRecords: ({ referenceEntityCode, records, }: {
|
|
165
|
+
referenceEntityCode: string;
|
|
166
|
+
records: any[];
|
|
167
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
168
|
+
};
|
|
169
|
+
family: {
|
|
170
|
+
get: (params: {
|
|
171
|
+
query?: import("./types").FamilyQueryParameters | undefined;
|
|
172
|
+
}) => Promise<import("./types").ListResponse<import("./types").Family>>;
|
|
173
|
+
getVariants: (params: {
|
|
174
|
+
familyCode: string;
|
|
175
|
+
query?: import("./types").FamilyVariantQueryParameters | undefined;
|
|
176
|
+
}) => Promise<import("./types").ListResponse<import("./types").Variant>>;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Create a client instance
|
|
181
|
+
* @param params - Client initialization parameters
|
|
182
|
+
*
|
|
183
|
+
* ```javascript
|
|
184
|
+
* const client = akeneo({
|
|
185
|
+
* url: AKENEO_API_URL,
|
|
186
|
+
* accessToken: AKENEO_SECRET,
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare const createAppClient: (params: AppParams) => {
|
|
191
|
+
raw: {
|
|
192
|
+
http: AxiosInstance;
|
|
193
|
+
};
|
|
194
|
+
category: {
|
|
195
|
+
getOne: (params: {
|
|
196
|
+
code: string;
|
|
197
|
+
query?: {
|
|
198
|
+
with_attribute_options?: boolean | undefined;
|
|
199
|
+
with_quality_scores?: boolean | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
}) => Promise<import("./types").Category<Record<string, any>>>;
|
|
202
|
+
get: (params: {
|
|
203
|
+
query?: import("./types").CategoryQueryParameters | undefined;
|
|
204
|
+
}) => Promise<import("./types").ListResponse<import("./types").Category<Record<string, any>>>>;
|
|
205
|
+
getAll: (params: {
|
|
206
|
+
query?: import("./types").CategoryQueryParameters | undefined;
|
|
207
|
+
}) => Promise<import("./types").ListResponse<import("./types").Category<Record<string, any>>>>;
|
|
208
|
+
};
|
|
209
|
+
productModel: {
|
|
210
|
+
getOne: (params: {
|
|
211
|
+
code: string;
|
|
212
|
+
}) => Promise<import("./types").ProductModel>;
|
|
213
|
+
get: (params: {
|
|
214
|
+
query?: import("./types").ProductModelQueryParameters | undefined;
|
|
215
|
+
}) => Promise<import("./types").ListResponse<import("./types").ProductModel>>;
|
|
216
|
+
getAll: (params: {
|
|
217
|
+
query?: import("./types").ProductModelQueryParameters | undefined;
|
|
218
|
+
}) => Promise<import("./types").ListResponse<import("./types").ProductModel>>;
|
|
219
|
+
};
|
|
220
|
+
product: {
|
|
221
|
+
getOne: (params: {
|
|
222
|
+
code: string;
|
|
223
|
+
query?: {
|
|
224
|
+
with_attribute_options?: boolean | undefined;
|
|
225
|
+
with_quality_scores?: boolean | undefined;
|
|
226
|
+
} | undefined;
|
|
227
|
+
}) => Promise<import("./types").Product>;
|
|
228
|
+
get: (params: {
|
|
229
|
+
query?: import("./types").ProductQueryParameters | undefined;
|
|
230
|
+
}) => Promise<import("./types").ListResponse<import("./types").Product>>;
|
|
231
|
+
getAll: (params: {
|
|
232
|
+
query?: import("./types").ProductQueryParameters | undefined;
|
|
233
|
+
}) => Promise<import("./types").ListResponse<import("./types").Product>>;
|
|
234
|
+
};
|
|
235
|
+
assetFamily: {
|
|
236
|
+
getOne: (params: {
|
|
237
|
+
code: string;
|
|
238
|
+
query?: {
|
|
239
|
+
with_attribute_options?: boolean | undefined;
|
|
240
|
+
with_quality_scores?: boolean | undefined;
|
|
241
|
+
} | undefined;
|
|
242
|
+
}) => Promise<import("./types").AssetFamily>;
|
|
243
|
+
get: (params: {
|
|
244
|
+
query?: import("./types").AssetFamilyQueryParameters | undefined;
|
|
245
|
+
}) => Promise<import("./types").ListResponse<import("./types").AssetFamily>>;
|
|
246
|
+
getAll: (params: {
|
|
247
|
+
query?: import("./types").AssetFamilyQueryParameters | undefined;
|
|
248
|
+
}) => Promise<import("./types").ListResponse<import("./types").AssetFamily>>;
|
|
249
|
+
getAssets: (params: {
|
|
250
|
+
assetFamilyCode: string;
|
|
251
|
+
query?: import("./types").AssetQueryParameters | undefined;
|
|
252
|
+
}) => Promise<import("./types").ListResponse<import("./types").Asset>>;
|
|
253
|
+
getAsset: (params: {
|
|
254
|
+
assetFamilyCode: string;
|
|
255
|
+
code: string;
|
|
256
|
+
}) => Promise<import("./types").Asset>;
|
|
257
|
+
getAssetsAll: (params: {
|
|
258
|
+
assetFamilyCode: string;
|
|
259
|
+
query?: import("./types").AssetQueryParameters | undefined;
|
|
260
|
+
}) => Promise<import("./types").ListResponse<import("./types").Asset>>;
|
|
261
|
+
};
|
|
262
|
+
assetMediaFile: {
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* @see https://api.akeneo.com/api-reference.html#get_asset_media_files__code
|
|
266
|
+
*/
|
|
267
|
+
get: (code: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
268
|
+
};
|
|
269
|
+
referenceEntitiesMediaFile: {
|
|
270
|
+
/**
|
|
271
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entity_media_files__code
|
|
272
|
+
*/
|
|
273
|
+
get: (code: string) => Promise<any>;
|
|
274
|
+
};
|
|
275
|
+
attribute: {
|
|
276
|
+
getOne: (params: {
|
|
277
|
+
code: string;
|
|
278
|
+
}) => Promise<import("./types").Attribute>;
|
|
279
|
+
get: (params: {
|
|
280
|
+
query?: import("./types").AttributeQueryParameters | undefined;
|
|
281
|
+
}) => Promise<import("./types").ListResponse<import("./types").Attribute>>;
|
|
282
|
+
getAll: (params: {
|
|
283
|
+
query?: import("./types").AttributeQueryParameters | undefined;
|
|
284
|
+
}) => Promise<import("./types").ListResponse<import("./types").Attribute>>;
|
|
285
|
+
getOptions: (params: {
|
|
286
|
+
attributeCode: string;
|
|
287
|
+
query?: import("./types").AttributeOptionQueryParameters | undefined;
|
|
288
|
+
}) => Promise<import("./types").ListResponse<import("./types").AttributeOption>>;
|
|
289
|
+
add: ({ code, attribute }: {
|
|
290
|
+
code: string;
|
|
291
|
+
attribute: any;
|
|
292
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
293
|
+
addOption: ({ attributeCode, code, option, }: {
|
|
294
|
+
attributeCode: string;
|
|
295
|
+
code: string;
|
|
296
|
+
option: any;
|
|
297
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
298
|
+
};
|
|
299
|
+
referenceEntity: {
|
|
300
|
+
get: (params: {
|
|
301
|
+
query?: import("./types").ReferenceEntityQueryParameters | undefined;
|
|
302
|
+
}) => Promise<import("./types").ListResponse<import("./types").Entity>>;
|
|
303
|
+
getRecords: (params: {
|
|
304
|
+
referenceEntityCode: string;
|
|
305
|
+
query?: import("./types").ReferenceEntityRecordQueryParameters | undefined;
|
|
306
|
+
}) => Promise<import("./types").ListResponse<import("./types").EntityRecord>>;
|
|
307
|
+
/**
|
|
308
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity__code_
|
|
309
|
+
*/ add: ({ code, body }: {
|
|
310
|
+
code: string;
|
|
311
|
+
body: any;
|
|
312
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
313
|
+
/**
|
|
314
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__code_
|
|
315
|
+
*/
|
|
316
|
+
addAttribute: ({ referenceEntityCode, code, attribute, }: {
|
|
317
|
+
referenceEntityCode: string;
|
|
318
|
+
code: string;
|
|
319
|
+
attribute: any;
|
|
320
|
+
}) => Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__attribute_code__options__code_
|
|
323
|
+
*/
|
|
324
|
+
addAttributeOption: ({ referenceEntityCode, attributeCode, code, option, }: {
|
|
325
|
+
referenceEntityCode: string;
|
|
326
|
+
attributeCode: string;
|
|
327
|
+
code: string;
|
|
328
|
+
option: any;
|
|
329
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
330
|
+
/**
|
|
331
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_records
|
|
332
|
+
*/
|
|
333
|
+
addRecords: ({ referenceEntityCode, records, }: {
|
|
334
|
+
referenceEntityCode: string;
|
|
335
|
+
records: any[];
|
|
336
|
+
}) => Promise<import("axios").AxiosResponse<any>>;
|
|
337
|
+
};
|
|
338
|
+
family: {
|
|
339
|
+
get: (params: {
|
|
340
|
+
query?: import("./types").FamilyQueryParameters | undefined;
|
|
341
|
+
}) => Promise<import("./types").ListResponse<import("./types").Family>>;
|
|
342
|
+
getVariants: (params: {
|
|
343
|
+
familyCode: string;
|
|
344
|
+
query?: import("./types").FamilyVariantQueryParameters | undefined;
|
|
345
|
+
}) => Promise<import("./types").ListResponse<import("./types").Variant>>;
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
export declare type AkeneoClientAPI = ReturnType<typeof createClient>;
|
|
349
|
+
export * from './types';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Akeneo Management API SDK. Allows you to create instances of a client
|
|
4
|
+
* with access to the Akeneo API.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.createAppClient = exports.createClient = void 0;
|
|
39
|
+
const http_client_1 = require("./http-client");
|
|
40
|
+
const endpoints = __importStar(require("./endpoints"));
|
|
41
|
+
const ATTRIBUTES_PATH = '/api/rest/v1/attributes';
|
|
42
|
+
const ASSET_MEDIA_FILES = '/api/rest/v1/asset-media-files';
|
|
43
|
+
const REFERENCE_ENTITIES_MEDIA_FILES = '/api/rest/v1/reference-entities-media-files';
|
|
44
|
+
const wrap = (http, fn) => (params) => fn(http, params);
|
|
45
|
+
const getHttpClientWithEndpoint = (http) => ({
|
|
46
|
+
raw: {
|
|
47
|
+
http,
|
|
48
|
+
},
|
|
49
|
+
category: {
|
|
50
|
+
getOne: wrap(http, endpoints.category.getOne),
|
|
51
|
+
get: wrap(http, endpoints.category.get),
|
|
52
|
+
getAll: wrap(http, endpoints.category.getAll),
|
|
53
|
+
},
|
|
54
|
+
productModel: {
|
|
55
|
+
getOne: wrap(http, endpoints.productModel.getOne),
|
|
56
|
+
get: wrap(http, endpoints.productModel.get),
|
|
57
|
+
getAll: wrap(http, endpoints.productModel.getAll),
|
|
58
|
+
},
|
|
59
|
+
product: {
|
|
60
|
+
getOne: wrap(http, endpoints.product.getOne),
|
|
61
|
+
get: wrap(http, endpoints.product.get),
|
|
62
|
+
getAll: wrap(http, endpoints.product.getAll),
|
|
63
|
+
},
|
|
64
|
+
assetFamily: {
|
|
65
|
+
getOne: wrap(http, endpoints.assetFamily.getOne),
|
|
66
|
+
get: wrap(http, endpoints.assetFamily.get),
|
|
67
|
+
getAll: wrap(http, endpoints.assetFamily.getAll),
|
|
68
|
+
getAssets: wrap(http, endpoints.assetFamily.getAssets),
|
|
69
|
+
getAsset: wrap(http, endpoints.assetFamily.getAsset),
|
|
70
|
+
getAssetsAll: wrap(http, endpoints.assetFamily.getAssetsAll),
|
|
71
|
+
},
|
|
72
|
+
assetMediaFile: {
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @see https://api.akeneo.com/api-reference.html#get_asset_media_files__code
|
|
76
|
+
*/
|
|
77
|
+
get: (code) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
return http.get(`${ASSET_MEDIA_FILES}/${code}`, {
|
|
79
|
+
responseType: 'arraybuffer',
|
|
80
|
+
params: {},
|
|
81
|
+
});
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
referenceEntitiesMediaFile: {
|
|
85
|
+
/**
|
|
86
|
+
* @see https://api.akeneo.com/api-reference.html#get_reference_entity_media_files__code
|
|
87
|
+
*/
|
|
88
|
+
get: (code) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
return http.get(`${REFERENCE_ENTITIES_MEDIA_FILES}/${code}`, {
|
|
90
|
+
responseType: 'arraybuffer',
|
|
91
|
+
params: {},
|
|
92
|
+
});
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
attribute: {
|
|
96
|
+
getOne: wrap(http, endpoints.attribute.getOne),
|
|
97
|
+
get: wrap(http, endpoints.attribute.get),
|
|
98
|
+
getAll: wrap(http, endpoints.attribute.getAll),
|
|
99
|
+
getOptions: wrap(http, endpoints.attribute.getOptions),
|
|
100
|
+
add: ({ code, attribute }) => __awaiter(void 0, void 0, void 0, function* () { return http.patch(`${ATTRIBUTES_PATH}/${code}`, attribute); }),
|
|
101
|
+
addOption: ({ attributeCode, code, option, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
return http.patch(`${ATTRIBUTES_PATH}/${attributeCode}/options/${code}`, option);
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
referenceEntity: {
|
|
106
|
+
get: wrap(http, endpoints.referenceEntity.get),
|
|
107
|
+
getRecords: wrap(http, endpoints.referenceEntity.getRecords),
|
|
108
|
+
/**
|
|
109
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity__code_
|
|
110
|
+
*/ add: ({ code, body }) => __awaiter(void 0, void 0, void 0, function* () { return http.patch(`/api/rest/v1/reference-entities/${code}`, body); }),
|
|
111
|
+
/**
|
|
112
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__code_
|
|
113
|
+
*/
|
|
114
|
+
addAttribute: ({ referenceEntityCode, code, attribute, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
+
yield http.patch(`/api/rest/v1/reference-entities/${referenceEntityCode}/attributes/${code}`, attribute);
|
|
116
|
+
}),
|
|
117
|
+
/**
|
|
118
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_attributes__attribute_code__options__code_
|
|
119
|
+
*/
|
|
120
|
+
addAttributeOption: ({ referenceEntityCode, attributeCode, code, option, }) => http.patch(`/api/rest/v1/reference-entities/${referenceEntityCode}/attributes/${attributeCode}/options/${code}`, option),
|
|
121
|
+
/**
|
|
122
|
+
* @see https://api.akeneo.com/api-reference.html#patch_reference_entity_records
|
|
123
|
+
*/
|
|
124
|
+
addRecords: ({ referenceEntityCode, records, }) => http.patch(`/api/rest/v1/reference-entities/${referenceEntityCode}/records`, records),
|
|
125
|
+
},
|
|
126
|
+
family: {
|
|
127
|
+
get: wrap(http, endpoints.family.get),
|
|
128
|
+
getVariants: wrap(http, endpoints.family.getVariants),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Create a client instance
|
|
133
|
+
* @param params - Client initialization parameters
|
|
134
|
+
*
|
|
135
|
+
* ```javascript
|
|
136
|
+
* const client = akeneo({
|
|
137
|
+
* url: AKENEO_API_URL,
|
|
138
|
+
* username: AKENEO_USERNAME,
|
|
139
|
+
* password: AKENEO_PASSWORD,
|
|
140
|
+
* clientId: AKENEO_CLIENT_ID,
|
|
141
|
+
* secret: AKENEO_SECRET,
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
const createClient = (params) => {
|
|
146
|
+
const http = http_client_1.createConnectionHttpClient(params);
|
|
147
|
+
return getHttpClientWithEndpoint(http);
|
|
148
|
+
};
|
|
149
|
+
exports.createClient = createClient;
|
|
150
|
+
/**
|
|
151
|
+
* Create a client instance
|
|
152
|
+
* @param params - Client initialization parameters
|
|
153
|
+
*
|
|
154
|
+
* ```javascript
|
|
155
|
+
* const client = akeneo({
|
|
156
|
+
* url: AKENEO_API_URL,
|
|
157
|
+
* accessToken: AKENEO_SECRET,
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
const createAppClient = (params) => {
|
|
162
|
+
const http = http_client_1.createAppHttpClient(params);
|
|
163
|
+
return getHttpClientWithEndpoint(http);
|
|
164
|
+
};
|
|
165
|
+
exports.createAppClient = createAppClient;
|
|
166
|
+
__exportStar(require("./types"), exports);
|