@commercelayer/sdk 5.22.0 → 5.23.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.
@@ -1,9 +1,5 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
4
2
  import type { InterceptorManager } from './interceptor';
5
- import type { Agent as HttpAgent } from 'http';
6
- import type { Agent as HttpsAgent } from 'https';
7
3
  type ProxyConfig = AxiosProxyConfig | false;
8
4
  type Adapter = AxiosAdapter;
9
5
  type RequestParams = Record<string, string | number | boolean>;
@@ -11,8 +7,8 @@ type RequestHeaders = Record<string, string>;
11
7
  type RequestConfig = {
12
8
  timeout?: number;
13
9
  params?: RequestParams;
14
- httpAgent?: HttpAgent;
15
- httpsAgent?: HttpsAgent;
10
+ httpAgent?: any;
11
+ httpsAgent?: any;
16
12
  proxy?: ProxyConfig;
17
13
  headers?: RequestHeaders;
18
14
  };
package/lib/cjs/client.js CHANGED
@@ -18,8 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  const error_1 = require("./error");
20
20
  const config_1 = __importDefault(require("./config"));
21
+ // import type { Agent as HttpAgent } from 'http'
22
+ // import type { Agent as HttpsAgent } from 'https'
23
+ // import { packageInfo } from './util'
21
24
  const debug_1 = __importDefault(require("./debug"));
22
- const util_1 = require("./util");
23
25
  const debug = (0, debug_1.default)('client');
24
26
  const baseURL = (organization, domain) => {
25
27
  return `https://${organization.toLowerCase()}.${domain || config_1.default.default.domain}/api`;
@@ -46,10 +48,10 @@ class ApiClient {
46
48
  // Set custom headers
47
49
  const customHeaders = this.customHeaders(options.headers);
48
50
  // Set User-Agent
49
- const userAgentData = (0, util_1.packageInfo)(['version', 'dependencies.axios'], { nestedName: true });
50
- let userAgent = options.userAgent || `SDK/${userAgentData.version} axios/${userAgentData.axios}`;
51
+ // const userAgentData = packageInfo(['version', 'dependencies.axios'], { nestedName: true })
52
+ let userAgent = options.userAgent || `SDK-core axios/${axios_1.default.VERSION}`;
51
53
  if (!userAgent.includes('axios/'))
52
- userAgent += ` axios/${userAgentData.axios}`;
54
+ userAgent += ` axios/${axios_1.default.VERSION}`;
53
55
  const axiosOptions = {
54
56
  baseURL: this.baseUrl,
55
57
  timeout: config_1.default.client.timeout,
@@ -99,9 +101,9 @@ class ApiClient {
99
101
  if (userAgent) {
100
102
  let ua = userAgent;
101
103
  if (!ua.includes('axios/')) {
102
- const axiosVer = (0, util_1.packageInfo)(['dependencies.axios'], { nestedName: true });
103
- if (axiosVer)
104
- ua += ` axios/${axiosVer.axios}`;
104
+ // const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true })
105
+ if (axios_1.default.VERSION)
106
+ ua += ` axios/${axios_1.default.VERSION}`;
105
107
  }
106
108
  __classPrivateFieldGet(this, _ApiClient_client, "f").defaults.headers['User-Agent'] = ua;
107
109
  }
@@ -2,14 +2,14 @@ import * as api from './api';
2
2
  import type { ApiError } from './error';
3
3
  import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
4
  import { type ResourcesInitConfig } from './resource';
5
- declare const OPEN_API_SCHEMA_VERSION = "4.19.0";
5
+ declare const OPEN_API_SCHEMA_VERSION = "4.20.0";
6
6
  export { OPEN_API_SCHEMA_VERSION };
7
7
  type SdkConfig = {};
8
8
  type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
9
9
  type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
10
10
  declare class CommerceLayerClient {
11
11
  #private;
12
- readonly openApiSchemaVersion = "4.19.0";
12
+ readonly openApiSchemaVersion = "4.20.0";
13
13
  addresses: api.Addresses;
14
14
  adjustments: api.Adjustments;
15
15
  adyen_gateways: api.AdyenGateways;
@@ -45,7 +45,7 @@ const resource_1 = __importDefault(require("./resource"));
45
45
  const debug_1 = __importDefault(require("./debug"));
46
46
  const debug = (0, debug_1.default)('commercelayer');
47
47
  // Autogenerated schema version number, do not remove this line
48
- const OPEN_API_SCHEMA_VERSION = '4.19.0';
48
+ const OPEN_API_SCHEMA_VERSION = '4.20.0';
49
49
  exports.OPEN_API_SCHEMA_VERSION = OPEN_API_SCHEMA_VERSION;
50
50
  class CommerceLayerClient {
51
51
  // ##__CL_RESOURCES_DEF_STOP__##
@@ -1,9 +1,9 @@
1
1
  declare enum ErrorType {
2
- CLIENT = "client",
3
- REQUEST = "request",
4
- RESPONSE = "response",
5
- CANCEL = "cancel",
6
- PARSE = "parse",
2
+ CLIENT = "client",// Error instantiating the client
3
+ REQUEST = "request",// Error preparing API request
4
+ RESPONSE = "response",// Error response from API
5
+ CANCEL = "cancel",// Forced request abort using interceptor
6
+ PARSE = "parse",// Error parsing API resource
7
7
  GENERIC = "generic"
8
8
  }
9
9
  declare class SdkError extends Error {
@@ -46,7 +46,6 @@ class ResourceAdapter {
46
46
  this.localConfig(config);
47
47
  }
48
48
  get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
49
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
49
  localConfig(config) {
51
50
  // if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
52
51
  }
@@ -63,6 +63,7 @@ interface LineItem extends Resource {
63
63
  sku_code?: string | null;
64
64
  bundle_code?: string | null;
65
65
  quantity: number;
66
+ _external_price?: boolean | null;
66
67
  currency_code?: string | null;
67
68
  unit_amount_cents?: number | null;
68
69
  unit_amount_float?: number | null;
package/lib/cjs/util.d.ts CHANGED
@@ -6,5 +6,4 @@
6
6
  import type { ObjectType } from "../src/common";
7
7
  declare const sleep: (ms: number) => Promise<NodeJS.Timeout>;
8
8
  declare const sortObjectFields: (obj: ObjectType) => ObjectType;
9
- declare const packageInfo: (fields?: string | string[], options?: any) => Record<string, any>;
10
- export { sleep, sortObjectFields, packageInfo };
9
+ export { sleep, sortObjectFields, };
package/lib/cjs/util.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.packageInfo = exports.sortObjectFields = exports.sleep = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
3
+ exports.sortObjectFields = exports.sleep = void 0;
4
+ // import path from 'node:path'
8
5
  const sleep = async (ms) => {
9
6
  return new Promise(resolve => setTimeout(resolve, ms));
10
7
  };
@@ -17,23 +14,3 @@ const sortObjectFields = (obj) => {
17
14
  return sorted;
18
15
  };
19
16
  exports.sortObjectFields = sortObjectFields;
20
- const nestedField = (obj, field) => {
21
- let fp = field;
22
- if (fp.endsWith('.'))
23
- fp = fp.substring(0, fp.length - 1);
24
- const dots = field.split(".");
25
- const key = dots[dots.length - 1];
26
- let val = obj;
27
- while (dots.length && (val = val[dots.shift() || '']))
28
- ;
29
- return { key, val };
30
- };
31
- const packageInfo = (fields, options) => {
32
- const pjson = require(node_path_1.default.resolve('./', 'package.json'));
33
- return fields ? (Array.isArray(fields) ? fields : [fields]).reduce((info, field) => {
34
- const nf = nestedField(pjson, field);
35
- info[(options === null || options === void 0 ? void 0 : options.nestedName) ? nf.key : field] = nf.val;
36
- return info;
37
- }, {}) : pjson;
38
- };
39
- exports.packageInfo = packageInfo;
@@ -1,9 +1,5 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
4
2
  import type { InterceptorManager } from './interceptor';
5
- import type { Agent as HttpAgent } from 'http';
6
- import type { Agent as HttpsAgent } from 'https';
7
3
  type ProxyConfig = AxiosProxyConfig | false;
8
4
  type Adapter = AxiosAdapter;
9
5
  type RequestParams = Record<string, string | number | boolean>;
@@ -11,8 +7,8 @@ type RequestHeaders = Record<string, string>;
11
7
  type RequestConfig = {
12
8
  timeout?: number;
13
9
  params?: RequestParams;
14
- httpAgent?: HttpAgent;
15
- httpsAgent?: HttpsAgent;
10
+ httpAgent?: any;
11
+ httpsAgent?: any;
16
12
  proxy?: ProxyConfig;
17
13
  headers?: RequestHeaders;
18
14
  };
package/lib/esm/client.js CHANGED
@@ -13,8 +13,10 @@ var _ApiClient_accessToken, _ApiClient_client;
13
13
  import axios from 'axios';
14
14
  import { SdkError, handleError } from './error';
15
15
  import config from './config';
16
+ // import type { Agent as HttpAgent } from 'http'
17
+ // import type { Agent as HttpsAgent } from 'https'
18
+ // import { packageInfo } from './util'
16
19
  import Debug from './debug';
17
- import { packageInfo } from './util';
18
20
  const debug = Debug('client');
19
21
  const baseURL = (organization, domain) => {
20
22
  return `https://${organization.toLowerCase()}.${domain || config.default.domain}/api`;
@@ -41,10 +43,10 @@ class ApiClient {
41
43
  // Set custom headers
42
44
  const customHeaders = this.customHeaders(options.headers);
43
45
  // Set User-Agent
44
- const userAgentData = packageInfo(['version', 'dependencies.axios'], { nestedName: true });
45
- let userAgent = options.userAgent || `SDK/${userAgentData.version} axios/${userAgentData.axios}`;
46
+ // const userAgentData = packageInfo(['version', 'dependencies.axios'], { nestedName: true })
47
+ let userAgent = options.userAgent || `SDK-core axios/${axios.VERSION}`;
46
48
  if (!userAgent.includes('axios/'))
47
- userAgent += ` axios/${userAgentData.axios}`;
49
+ userAgent += ` axios/${axios.VERSION}`;
48
50
  const axiosOptions = {
49
51
  baseURL: this.baseUrl,
50
52
  timeout: config.client.timeout,
@@ -94,9 +96,9 @@ class ApiClient {
94
96
  if (userAgent) {
95
97
  let ua = userAgent;
96
98
  if (!ua.includes('axios/')) {
97
- const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true });
98
- if (axiosVer)
99
- ua += ` axios/${axiosVer.axios}`;
99
+ // const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true })
100
+ if (axios.VERSION)
101
+ ua += ` axios/${axios.VERSION}`;
100
102
  }
101
103
  __classPrivateFieldGet(this, _ApiClient_client, "f").defaults.headers['User-Agent'] = ua;
102
104
  }
@@ -2,14 +2,14 @@ import * as api from './api';
2
2
  import type { ApiError } from './error';
3
3
  import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
4
  import { type ResourcesInitConfig } from './resource';
5
- declare const OPEN_API_SCHEMA_VERSION = "4.19.0";
5
+ declare const OPEN_API_SCHEMA_VERSION = "4.20.0";
6
6
  export { OPEN_API_SCHEMA_VERSION };
7
7
  type SdkConfig = {};
8
8
  type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
9
9
  type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
10
10
  declare class CommerceLayerClient {
11
11
  #private;
12
- readonly openApiSchemaVersion = "4.19.0";
12
+ readonly openApiSchemaVersion = "4.20.0";
13
13
  addresses: api.Addresses;
14
14
  adjustments: api.Adjustments;
15
15
  adyen_gateways: api.AdyenGateways;
@@ -16,7 +16,7 @@ import ResourceAdapter from './resource';
16
16
  import Debug from './debug';
17
17
  const debug = Debug('commercelayer');
18
18
  // Autogenerated schema version number, do not remove this line
19
- const OPEN_API_SCHEMA_VERSION = '4.19.0';
19
+ const OPEN_API_SCHEMA_VERSION = '4.20.0';
20
20
  export { OPEN_API_SCHEMA_VERSION };
21
21
  class CommerceLayerClient {
22
22
  // ##__CL_RESOURCES_DEF_STOP__##
@@ -1,9 +1,9 @@
1
1
  declare enum ErrorType {
2
- CLIENT = "client",
3
- REQUEST = "request",
4
- RESPONSE = "response",
5
- CANCEL = "cancel",
6
- PARSE = "parse",
2
+ CLIENT = "client",// Error instantiating the client
3
+ REQUEST = "request",// Error preparing API request
4
+ RESPONSE = "response",// Error response from API
5
+ CANCEL = "cancel",// Forced request abort using interceptor
6
+ PARSE = "parse",// Error parsing API resource
7
7
  GENERIC = "generic"
8
8
  }
9
9
  declare class SdkError extends Error {
@@ -40,7 +40,6 @@ class ResourceAdapter {
40
40
  this.localConfig(config);
41
41
  }
42
42
  get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
43
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
43
  localConfig(config) {
45
44
  // if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
46
45
  }
@@ -63,6 +63,7 @@ interface LineItem extends Resource {
63
63
  sku_code?: string | null;
64
64
  bundle_code?: string | null;
65
65
  quantity: number;
66
+ _external_price?: boolean | null;
66
67
  currency_code?: string | null;
67
68
  unit_amount_cents?: number | null;
68
69
  unit_amount_float?: number | null;
package/lib/esm/util.d.ts CHANGED
@@ -6,5 +6,4 @@
6
6
  import type { ObjectType } from "../src/common";
7
7
  declare const sleep: (ms: number) => Promise<NodeJS.Timeout>;
8
8
  declare const sortObjectFields: (obj: ObjectType) => ObjectType;
9
- declare const packageInfo: (fields?: string | string[], options?: any) => Record<string, any>;
10
- export { sleep, sortObjectFields, packageInfo };
9
+ export { sleep, sortObjectFields, };
package/lib/esm/util.js CHANGED
@@ -1,4 +1,4 @@
1
- import path from 'node:path';
1
+ // import path from 'node:path'
2
2
  const sleep = async (ms) => {
3
3
  return new Promise(resolve => setTimeout(resolve, ms));
4
4
  };
@@ -9,23 +9,29 @@ const sortObjectFields = (obj) => {
9
9
  }, {});
10
10
  return sorted;
11
11
  };
12
- const nestedField = (obj, field) => {
13
- let fp = field;
14
- if (fp.endsWith('.'))
15
- fp = fp.substring(0, fp.length - 1);
16
- const dots = field.split(".");
17
- const key = dots[dots.length - 1];
18
- let val = obj;
19
- while (dots.length && (val = val[dots.shift() || '']))
20
- ;
21
- return { key, val };
22
- };
23
- const packageInfo = (fields, options) => {
24
- const pjson = require(path.resolve('./', 'package.json'));
25
- return fields ? (Array.isArray(fields) ? fields : [fields]).reduce((info, field) => {
26
- const nf = nestedField(pjson, field);
27
- info[(options === null || options === void 0 ? void 0 : options.nestedName) ? nf.key : field] = nf.val;
28
- return info;
29
- }, {}) : pjson;
30
- };
31
- export { sleep, sortObjectFields, packageInfo };
12
+ /*
13
+ const nestedField = (obj: any, field: string): { key: string, val: any } => {
14
+
15
+ let fp = field
16
+ if (fp.endsWith('.')) fp = fp.substring(0, fp.length-1)
17
+
18
+ const dots = field.split(".")
19
+
20
+ const key = dots[dots.length-1]
21
+ let val = obj
22
+ while (dots.length && (val = val[dots.shift() || '']));
23
+
24
+ return { key, val }
25
+ }
26
+ */
27
+ /*
28
+ const packageInfo = (fields?: string | string[], options?: any): Record<string, any> => {
29
+ const pjson = require(path.resolve('./', 'package.json'))
30
+ return fields? (Array.isArray(fields)? fields : [ fields ]).reduce((info: any, field) => {
31
+ const nf = nestedField(pjson, field)
32
+ info[options?.nestedName? nf.key : field] = nf.val
33
+ return info
34
+ }, {}) : pjson
35
+ }
36
+ */
37
+ export { sleep, sortObjectFields, /* packageInfo */ };