@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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/dist/cjs/endpoints/asset-family.d.ts +39 -0
  4. package/dist/cjs/endpoints/asset-family.js +41 -0
  5. package/dist/cjs/endpoints/attribute.d.ts +24 -0
  6. package/dist/cjs/endpoints/attribute.js +30 -0
  7. package/dist/cjs/endpoints/category.d.ts +21 -0
  8. package/dist/cjs/endpoints/category.js +39 -0
  9. package/dist/cjs/endpoints/family.d.ts +15 -0
  10. package/dist/cjs/endpoints/family.js +21 -0
  11. package/dist/cjs/endpoints/index.d.ts +7 -0
  12. package/dist/cjs/endpoints/index.js +29 -0
  13. package/dist/cjs/endpoints/product-model.d.ts +17 -0
  14. package/dist/cjs/endpoints/product-model.js +31 -0
  15. package/dist/cjs/endpoints/product.d.ts +21 -0
  16. package/dist/cjs/endpoints/product.js +33 -0
  17. package/dist/cjs/endpoints/raw.d.ts +11 -0
  18. package/dist/cjs/endpoints/raw.js +92 -0
  19. package/dist/cjs/endpoints/reference-entity.d.ts +15 -0
  20. package/dist/cjs/endpoints/reference-entity.js +21 -0
  21. package/dist/cjs/error-handler.d.ts +2 -0
  22. package/dist/cjs/error-handler.js +32 -0
  23. package/dist/cjs/http-client.d.ts +16 -0
  24. package/dist/cjs/http-client.js +87 -0
  25. package/dist/cjs/index.d.ts +349 -0
  26. package/dist/cjs/index.js +166 -0
  27. package/dist/cjs/package.json +3 -0
  28. package/dist/cjs/types.d.ts +243 -0
  29. package/dist/cjs/types.js +2 -0
  30. package/dist/mjs/endpoints/asset-family.d.ts +39 -0
  31. package/dist/mjs/endpoints/asset-family.js +31 -0
  32. package/dist/mjs/endpoints/attribute.d.ts +24 -0
  33. package/dist/mjs/endpoints/attribute.js +22 -0
  34. package/dist/mjs/endpoints/category.d.ts +21 -0
  35. package/dist/mjs/endpoints/category.js +18 -0
  36. package/dist/mjs/endpoints/family.d.ts +15 -0
  37. package/dist/mjs/endpoints/family.js +17 -0
  38. package/dist/mjs/endpoints/index.d.ts +7 -0
  39. package/dist/mjs/endpoints/index.js +7 -0
  40. package/dist/mjs/endpoints/product-model.d.ts +17 -0
  41. package/dist/mjs/endpoints/product-model.js +22 -0
  42. package/dist/mjs/endpoints/product.d.ts +21 -0
  43. package/dist/mjs/endpoints/product.js +24 -0
  44. package/dist/mjs/endpoints/raw.d.ts +11 -0
  45. package/dist/mjs/endpoints/raw.js +81 -0
  46. package/dist/mjs/endpoints/reference-entity.d.ts +15 -0
  47. package/dist/mjs/endpoints/reference-entity.js +13 -0
  48. package/dist/mjs/error-handler.d.ts +2 -0
  49. package/dist/mjs/error-handler.js +33 -0
  50. package/dist/mjs/http-client.d.ts +16 -0
  51. package/dist/mjs/http-client.js +86 -0
  52. package/dist/mjs/index.d.ts +349 -0
  53. package/dist/mjs/index.js +124 -0
  54. package/dist/mjs/package.json +3 -0
  55. package/dist/mjs/types.d.ts +243 -0
  56. package/dist/mjs/types.js +1 -0
  57. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Craftzing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWAREr
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ [![Node Akeneo API](https://github.com/craftzing/node-akeneo-api/raw/master/art/banner.jpg)](https://craftzing.com)
2
+
3
+ [![Quality assurance](https://github.com/craftzing/node-akeneo-api/actions/workflows/quality-assurance.yml/badge.svg?branch=master)](https://github.com/craftzing/node-akeneo-api/actions/workflows/quality-assurance.yml)
4
+ [![Code style](https://github.com/craftzing/node-akeneo-api/actions/workflows/code-style.yml/badge.svg?branch=master)](https://github.com/craftzing/node-akeneo-api/actions/workflows/code-style.yml)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/90013a42a4dce3766813/test_coverage)](https://codeclimate.com/github/craftzing/akeneo-api/test_coverage)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/90013a42a4dce3766813/maintainability)](https://codeclimate.com/github/craftzing/akeneo-api/maintainability)
7
+ ![Software License](https://img.shields.io/github/license/craftzing/node-akeneo-api)
8
+ [![js-airbnb-style](https://img.shields.io/badge/code%20style-airbnb-brightgreen.svg)](https://github.com/airbnb/javascript/)
9
+ ![npm (scoped)](https://img.shields.io/npm/v/@craftzing/akeneo-api)
10
+
11
+ # Akeneo API
12
+
13
+ This is an unofficial Node client for the Akeneo PIM REST API.
14
+
15
+ More info at [Akeneo REST API reference](https://api.akeneo.com/api-reference-index.html)
16
+
17
+ Note: not all endpoints are implements. Mostly only the GET are available. YMMV
18
+
19
+ ## 🔥 Features
20
+
21
+ - Easy typed access to your Akeneo environment via Typescript
22
+ - Built in token handling
23
+ - Helper function to get all products or product models easily
24
+
25
+ ## ⚒️ Requirements
26
+
27
+ - node.js ([LTS](https://nodejs.org/en/about/releases/))
28
+
29
+ ## 🧙 Installation
30
+
31
+ Using npm:
32
+
33
+ ```sh
34
+ npm install @craftzing/akeneo-api
35
+ ```
36
+
37
+ Using yarn:
38
+
39
+ ```sh
40
+ yarn add @craftzing/akeneo-api
41
+ ```
42
+
43
+ ## ⚙️ Configuration
44
+
45
+ ### Authentication
46
+
47
+ Follow the instructions for your Akeneo version to get the required parameters:
48
+
49
+ - clientId/secret: [client-idsecret-generation](https://api.akeneo.com/documentation/authentication.html#client-idsecret-generation)
50
+ - username/password: [api-user-creation](https://api.akeneo.com/documentation/authentication.html#api-user-creation)
51
+
52
+ ### Your first request
53
+
54
+ With es6 imports
55
+
56
+ ```js
57
+ import client from '@craftzing/akeneo-api';
58
+
59
+ const akeneo = client({
60
+ url,
61
+ username,
62
+ password,
63
+ clientId,
64
+ secret,
65
+ // Optionally you can also pass in axiosOptions which will be passed to the Axios instance
66
+ });
67
+
68
+ console.log(await akeneo.productModel.getAll({}));
69
+ ```
70
+
71
+ ## 📚 Docs
72
+
73
+ - [docs](https://craftzing.github.io/node-akeneo-api/)
74
+
75
+ ## 📝 Changelog
76
+
77
+ You can check the changelog on the [releases](https://github.com/craftzing/node-akeneo-api/releases) page.
78
+
79
+ ## 🤝 Support
80
+
81
+ If you have a problem with this library, please file an [issue](https://github.com/craftzing/akeneo-api/issues/new) here on GitHub.
82
+
83
+ If you have other problems with Akeneo not related to this library, you can contact their [Customer Support](https://www.akeneo.com/support/).
84
+
85
+ ## 💙 Thanks to...
86
+
87
+ - [The entire Craftzing team](https://craftzing.com)
88
+ - [All current and future contributors](https://github.com/craftzing/node-akeneo-api/graphs/contributors)
89
+
90
+ ## 🔑 License
91
+
92
+ The MIT License (MIT). Please see [License File](/LICENSE) for more information.
@@ -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,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAssetsAll = exports.getAsset = exports.getAssets = exports.getAll = exports.getOne = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#Assetfamily
10
+ */
11
+ const get = (http, params) => raw_1.default.get(http, `/api/rest/v1/asset-families`, {
12
+ params: Object.assign({}, params.query),
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#get_asset_family__code_
17
+ */
18
+ const getOne = (http, { code, query, }) => raw_1.default.getOne(http, `/api/rest/v1/asset-families/${code}`, {
19
+ params: query,
20
+ });
21
+ exports.getOne = getOne;
22
+ const getAll = (http, { query }) => raw_1.default.getAllBySearchAfter(http, `/api/rest/v1/asset-families`, {
23
+ params: query,
24
+ });
25
+ exports.getAll = getAll;
26
+ /**
27
+ * @see https://api.akeneo.com/api-reference.html#get_assets
28
+ */
29
+ const getAssets = (http, { assetFamilyCode, query, }) => raw_1.default.get(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets`, {
30
+ params: query,
31
+ });
32
+ exports.getAssets = getAssets;
33
+ /**
34
+ * @see https://api.akeneo.com/api-reference.html#get_assets__code_
35
+ */
36
+ const getAsset = (http, { assetFamilyCode, code, }) => raw_1.default.getOne(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets/${code}`, {});
37
+ exports.getAsset = getAsset;
38
+ const getAssetsAll = (http, { assetFamilyCode, query, }) => raw_1.default.getAllBySearchAfter(http, `/api/rest/v1/asset-families/${assetFamilyCode}/assets`, {
39
+ params: query,
40
+ });
41
+ exports.getAssetsAll = getAssetsAll;
@@ -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,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getOptions = exports.getAll = exports.getOne = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#get_attributes
10
+ */
11
+ const get = (http, params) => raw_1.default.get(http, `/api/rest/v1/attributes`, {
12
+ params: Object.assign({}, params.query),
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#get_attributes__code_
17
+ */
18
+ const getOne = (http, { code, }) => raw_1.default.getOne(http, `/api/rest/v1/attributes/${code}`);
19
+ exports.getOne = getOne;
20
+ const getAll = (http, { query = {} }) => raw_1.default.getAllByPage(http, `/api/rest/v1/attributes`, {
21
+ params: query,
22
+ });
23
+ exports.getAll = getAll;
24
+ /**
25
+ * @see https://api.akeneo.com/api-reference.html#get_attributes__attribute_code__options
26
+ */
27
+ const getOptions = (http, { attributeCode, query, }) => raw_1.default.getAllByPage(http, `/api/rest/v1/attributes/${attributeCode}/options`, {
28
+ params: query,
29
+ });
30
+ exports.getOptions = getOptions;
@@ -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,39 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getAll = exports.getOne = exports.get = void 0;
18
+ const raw_1 = __importDefault(require("./raw"));
19
+ /**
20
+ * @see https://api.akeneo.com/api-reference.html#Category
21
+ */
22
+ const get = (http, params) => raw_1.default.get(http, `/api/rest/v1/categories`, {
23
+ params: Object.assign({}, params.query),
24
+ });
25
+ exports.get = get;
26
+ /**
27
+ * @see https://api.akeneo.com/api-reference.html#get_categories__code_
28
+ */
29
+ const getOne = (http, _a) => {
30
+ var { code } = _a, params = __rest(_a, ["code"]);
31
+ return raw_1.default.getOne(http, `/api/rest/v1/categories/${code}`, {
32
+ params,
33
+ });
34
+ };
35
+ exports.getOne = getOne;
36
+ const getAll = (http, params) => raw_1.default.getAllByPage(http, `/api/rest/v1/categories`, {
37
+ params,
38
+ });
39
+ exports.getAll = getAll;
@@ -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,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getVariants = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#get_families
10
+ */
11
+ const get = (http, params) => raw_1.default.get(http, `/api/rest/v1/families`, {
12
+ params: Object.assign({}, params.query),
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#Familyvariant
17
+ */
18
+ const getVariants = (http, params) => raw_1.default.get(http, `/api/rest/v1/families/${params.familyCode}/variants`, {
19
+ params: Object.assign({}, params.query),
20
+ });
21
+ exports.getVariants = getVariants;
@@ -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,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.referenceEntity = exports.product = exports.productModel = exports.family = exports.category = exports.attribute = exports.assetFamily = void 0;
23
+ exports.assetFamily = __importStar(require("./asset-family"));
24
+ exports.attribute = __importStar(require("./attribute"));
25
+ exports.category = __importStar(require("./category"));
26
+ exports.family = __importStar(require("./family"));
27
+ exports.productModel = __importStar(require("./product-model"));
28
+ exports.product = __importStar(require("./product"));
29
+ exports.referenceEntity = __importStar(require("./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,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAll = exports.getOne = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#get_product_models
10
+ */
11
+ const get = (http, { query }) => raw_1.default.get(http, `/api/rest/v1/product-models`, {
12
+ params: query,
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#get_product_models__code_
17
+ */
18
+ const getOne = (http, params) => raw_1.default.getOne(http, `/api/rest/v1/product-models/${params.code}`, {});
19
+ exports.getOne = getOne;
20
+ const getAll = (http, { query }) => {
21
+ // support legacy pagination_type "page"
22
+ if ((query === null || query === void 0 ? void 0 : query.pagination_type) === 'page') {
23
+ return raw_1.default.getAllByPage(http, `/api/rest/v1/product-models`, {
24
+ params: query,
25
+ });
26
+ }
27
+ return raw_1.default.getAllBySearchAfter(http, `/api/rest/v1/product-models`, {
28
+ params: query,
29
+ });
30
+ };
31
+ exports.getAll = getAll;
@@ -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,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAll = exports.getOne = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#get_products
10
+ */
11
+ const get = (http, { query }) => raw_1.default.get(http, `/api/rest/v1/products`, {
12
+ params: query,
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#get_products__code_
17
+ */
18
+ const getOne = (http, { code, query, }) => raw_1.default.getOne(http, `/api/rest/v1/products/${code}`, {
19
+ params: query,
20
+ });
21
+ exports.getOne = getOne;
22
+ const getAll = (http, { query = {} }) => {
23
+ // support legacy pagination_type "page"
24
+ if ((query === null || query === void 0 ? void 0 : query.pagination_type) === 'page') {
25
+ return raw_1.default.getAllByPage(http, `/api/rest/v1/products`, {
26
+ params: query,
27
+ });
28
+ }
29
+ return raw_1.default.getAllBySearchAfter(http, `/api/rest/v1/products`, {
30
+ params: query,
31
+ });
32
+ };
33
+ exports.getAll = getAll;
@@ -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,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ const querystring = __importStar(require("querystring"));
35
+ const error_handler_1 = __importDefault(require("../error-handler"));
36
+ exports.default = {
37
+ get: function get(http, url, config) {
38
+ return http
39
+ .get(url, Object.assign({}, config))
40
+ .then((response) => {
41
+ const { data } = response;
42
+ return Object.assign(Object.assign(Object.assign({}, (data.current_page ? { current_page: data.current_page } : {})), (data.items_count ? { items_count: data.items_count } : {})), { items: data._embedded.items, _links: data._links });
43
+ }, error_handler_1.default);
44
+ },
45
+ getOne: function getOne(http, url, config) {
46
+ return http
47
+ .get(url, Object.assign({}, config))
48
+ .then((response) => {
49
+ const { data } = response;
50
+ return data;
51
+ }, error_handler_1.default);
52
+ },
53
+ getAllByPage: function getAllByPage(http, url, { params = {} }) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const page = (params === null || params === void 0 ? void 0 : params.page) || 1;
56
+ const { items_count = 0, items } = yield this.get(http, url, {
57
+ params: Object.assign(Object.assign({}, params), { with_count: true, limit: 100, page }),
58
+ });
59
+ return items_count / 100 > page
60
+ ? {
61
+ items: [
62
+ ...items,
63
+ ...(yield this.getAllByPage(http, url, {
64
+ params: Object.assign(Object.assign({}, params), { limit: 100, page: page + 1 }),
65
+ })).items,
66
+ ],
67
+ }
68
+ : { items };
69
+ });
70
+ },
71
+ getAllBySearchAfter: function getAllBySearchAfter(http, url, config) {
72
+ var _a, _b;
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ const params = config === null || config === void 0 ? void 0 : config.params;
75
+ const { items, _links } = yield this.get(http, url, {
76
+ params: Object.assign(Object.assign({}, ((params === null || params === void 0 ? void 0 : params.search_after) ? { search_after: params.search_after } : {})), { pagination_type: 'search_after', limit: 100 }),
77
+ });
78
+ const nextUrl = (_a = _links === null || _links === void 0 ? void 0 : _links.next) === null || _a === void 0 ? void 0 : _a.href;
79
+ if (!nextUrl)
80
+ return { items };
81
+ const search_after = ((_b = querystring.parse(nextUrl.split('?').at(1))) === null || _b === void 0 ? void 0 : _b.search_after) || '';
82
+ return {
83
+ items: [
84
+ ...items,
85
+ ...(yield this.getAllBySearchAfter(http, url, {
86
+ params: Object.assign(Object.assign({}, params), { limit: (params === null || params === void 0 ? void 0 : params.limit) || 100, pagination_type: 'search_after', search_after }),
87
+ })).items,
88
+ ],
89
+ };
90
+ });
91
+ },
92
+ };
@@ -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,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRecords = exports.get = void 0;
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ /**
9
+ * @see https://api.akeneo.com/api-reference.html#get_reference_entities
10
+ */
11
+ const get = (http, { query }) => raw_1.default.get(http, `/api/rest/v1/reference-entities`, {
12
+ params: query,
13
+ });
14
+ exports.get = get;
15
+ /**
16
+ * @see https://api.akeneo.com/api-reference.html#get_reference_entity_records
17
+ */
18
+ const getRecords = (http, { referenceEntityCode, query, }) => raw_1.default.get(http, `/api/rest/v1/reference-entities/${referenceEntityCode}/records`, {
19
+ params: query,
20
+ });
21
+ exports.getRecords = getRecords;
@@ -0,0 +1,2 @@
1
+ import { AxiosError } from 'axios';
2
+ export default function errorHandler({ config, response }: AxiosError): never;