@commercelayer/provisioning-sdk 1.0.5 → 1.1.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 (99) hide show
  1. package/lib/index.d.mts +576 -0
  2. package/lib/index.d.ts +576 -0
  3. package/lib/index.js +1 -0
  4. package/lib/index.mjs +1 -0
  5. package/package.json +14 -15
  6. package/lib/cjs/api.d.ts +0 -43
  7. package/lib/cjs/api.js +0 -45
  8. package/lib/cjs/client.d.ts +0 -42
  9. package/lib/cjs/client.js +0 -149
  10. package/lib/cjs/commercelayer.d.ts +0 -39
  11. package/lib/cjs/commercelayer.js +0 -130
  12. package/lib/cjs/common.d.ts +0 -5
  13. package/lib/cjs/common.js +0 -12
  14. package/lib/cjs/config.d.ts +0 -15
  15. package/lib/cjs/config.js +0 -19
  16. package/lib/cjs/debug.d.ts +0 -3
  17. package/lib/cjs/debug.js +0 -38
  18. package/lib/cjs/error.d.ts +0 -31
  19. package/lib/cjs/error.js +0 -77
  20. package/lib/cjs/index.d.ts +0 -7
  21. package/lib/cjs/index.js +0 -13
  22. package/lib/cjs/interceptor.d.ts +0 -25
  23. package/lib/cjs/interceptor.js +0 -2
  24. package/lib/cjs/jsonapi.d.ts +0 -6
  25. package/lib/cjs/jsonapi.js +0 -94
  26. package/lib/cjs/model.d.ts +0 -11
  27. package/lib/cjs/model.js +0 -3
  28. package/lib/cjs/query.d.ts +0 -17
  29. package/lib/cjs/query.js +0 -52
  30. package/lib/cjs/resource.d.ts +0 -86
  31. package/lib/cjs/resource.js +0 -194
  32. package/lib/cjs/resources/api_credentials.d.ts +0 -59
  33. package/lib/cjs/resources/api_credentials.js +0 -33
  34. package/lib/cjs/resources/application_memberships.d.ts +0 -57
  35. package/lib/cjs/resources/application_memberships.js +0 -41
  36. package/lib/cjs/resources/memberships.d.ts +0 -58
  37. package/lib/cjs/resources/memberships.js +0 -45
  38. package/lib/cjs/resources/organizations.d.ts +0 -84
  39. package/lib/cjs/resources/organizations.js +0 -42
  40. package/lib/cjs/resources/permissions.d.ts +0 -52
  41. package/lib/cjs/resources/permissions.js +0 -34
  42. package/lib/cjs/resources/roles.d.ts +0 -47
  43. package/lib/cjs/resources/roles.js +0 -42
  44. package/lib/cjs/resources/user.d.ts +0 -29
  45. package/lib/cjs/resources/user.js +0 -20
  46. package/lib/cjs/resources/versions.d.ts +0 -22
  47. package/lib/cjs/resources/versions.js +0 -16
  48. package/lib/cjs/static.d.ts +0 -12
  49. package/lib/cjs/static.js +0 -51
  50. package/lib/cjs/util.d.ts +0 -9
  51. package/lib/cjs/util.js +0 -16
  52. package/lib/esm/api.d.ts +0 -43
  53. package/lib/esm/api.js +0 -31
  54. package/lib/esm/client.d.ts +0 -42
  55. package/lib/esm/client.js +0 -144
  56. package/lib/esm/commercelayer.d.ts +0 -39
  57. package/lib/esm/commercelayer.js +0 -101
  58. package/lib/esm/common.d.ts +0 -5
  59. package/lib/esm/common.js +0 -8
  60. package/lib/esm/config.d.ts +0 -15
  61. package/lib/esm/config.js +0 -17
  62. package/lib/esm/debug.d.ts +0 -3
  63. package/lib/esm/debug.js +0 -36
  64. package/lib/esm/error.d.ts +0 -31
  65. package/lib/esm/error.js +0 -69
  66. package/lib/esm/index.d.ts +0 -7
  67. package/lib/esm/index.js +0 -4
  68. package/lib/esm/interceptor.d.ts +0 -25
  69. package/lib/esm/interceptor.js +0 -1
  70. package/lib/esm/jsonapi.d.ts +0 -6
  71. package/lib/esm/jsonapi.js +0 -87
  72. package/lib/esm/model.d.ts +0 -11
  73. package/lib/esm/model.js +0 -2
  74. package/lib/esm/query.d.ts +0 -17
  75. package/lib/esm/query.js +0 -45
  76. package/lib/esm/resource.d.ts +0 -86
  77. package/lib/esm/resource.js +0 -187
  78. package/lib/esm/resources/api_credentials.d.ts +0 -59
  79. package/lib/esm/resources/api_credentials.js +0 -31
  80. package/lib/esm/resources/application_memberships.d.ts +0 -57
  81. package/lib/esm/resources/application_memberships.js +0 -39
  82. package/lib/esm/resources/memberships.d.ts +0 -58
  83. package/lib/esm/resources/memberships.js +0 -43
  84. package/lib/esm/resources/organizations.d.ts +0 -84
  85. package/lib/esm/resources/organizations.js +0 -40
  86. package/lib/esm/resources/permissions.d.ts +0 -52
  87. package/lib/esm/resources/permissions.js +0 -32
  88. package/lib/esm/resources/roles.d.ts +0 -47
  89. package/lib/esm/resources/roles.js +0 -40
  90. package/lib/esm/resources/user.d.ts +0 -29
  91. package/lib/esm/resources/user.js +0 -18
  92. package/lib/esm/resources/versions.d.ts +0 -22
  93. package/lib/esm/resources/versions.js +0 -14
  94. package/lib/esm/static.d.ts +0 -12
  95. package/lib/esm/static.js +0 -25
  96. package/lib/esm/util.d.ts +0 -9
  97. package/lib/esm/util.js +0 -37
  98. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  99. package/lib/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@commercelayer/provisioning-sdk",
3
- "version": "1.0.5",
4
- "main": "lib/cjs/index.js",
5
- "types": "lib/cjs/index.d.ts",
6
- "module": "lib/esm/index.js",
3
+ "version": "1.1.0",
4
+ "main": "lib/index.js",
5
+ "types": "lib/index.d.ts",
6
+ "module": "lib/index.mjs",
7
7
  "scripts": {
8
8
  "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage",
9
- "build": "tsc -b tsconfig.json tsconfig.esm.json --verbose",
10
- "postbuild": "minimize-js -d lib",
9
+ "build": "tsup",
11
10
  "generate": "tsx gen/generator.ts",
12
11
  "generate-local": "tsx gen/generator.ts -- --local",
13
12
  "lint": "eslint ./src --ext .ts",
@@ -33,19 +32,19 @@
33
32
  "node": ">=16 || ^14.17"
34
33
  },
35
34
  "dependencies": {
36
- "axios": "1.6.7"
35
+ "axios": "1.6.8"
37
36
  },
38
37
  "devDependencies": {
39
- "@babel/preset-env": "^7.24.0",
40
- "@babel/preset-typescript": "^7.23.3",
41
- "@commercelayer/eslint-config-ts": "1.3.0",
42
- "@commercelayer/js-auth": "^4.2.2",
38
+ "@babel/preset-env": "^7.24.3",
39
+ "@babel/preset-typescript": "^7.24.1",
40
+ "@commercelayer/eslint-config-ts": "1.4.5",
41
+ "@commercelayer/js-auth": "^5.2.1",
43
42
  "@semantic-release/changelog": "^6.0.3",
44
43
  "@semantic-release/git": "^10.0.1",
45
44
  "@types/debug": "^4.1.12",
46
45
  "@types/jest": "^29.5.12",
47
46
  "@types/lodash": "^4.17.0",
48
- "@types/node": "^20.11.26",
47
+ "@types/node": "^20.11.30",
49
48
  "dotenv": "^16.4.5",
50
49
  "eslint": "^8.57.0",
51
50
  "inflector-js": "^1.0.1",
@@ -53,10 +52,10 @@
53
52
  "json-typescript": "^1.1.2",
54
53
  "jsonapi-typescript": "^0.1.3",
55
54
  "lodash": "^4.17.21",
56
- "minimize-js": "^1.4.0",
57
- "semantic-release": "^23.0.2",
55
+ "semantic-release": "^23.0.6",
56
+ "tsup": "^8.0.2",
58
57
  "tsx": "^4.7.1",
59
- "typescript": "^5.4.2"
58
+ "typescript": "^5.4.3"
60
59
  },
61
60
  "repository": "github:commercelayer/provisioning-sdk",
62
61
  "bugs": "https://github.com/commercelayer/provisioning-sdk/issues",
package/lib/cjs/api.d.ts DELETED
@@ -1,43 +0,0 @@
1
- import type { Resource, ResourceRel } from './resource';
2
- import type { VersionType } from './resources/versions';
3
- /**
4
- * ©2024 Commerce Layer Inc.
5
- **/
6
- export { default as ApiCredentials } from './resources/api_credentials';
7
- export { default as ApplicationMemberships } from './resources/application_memberships';
8
- export { default as Memberships } from './resources/memberships';
9
- export { default as Organizations } from './resources/organizations';
10
- export { default as Permissions } from './resources/permissions';
11
- export { default as Roles } from './resources/roles';
12
- export { default as Users } from './resources/user';
13
- export { default as Versions } from './resources/versions';
14
- export type ResourceTypeLock = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles' | 'user' | 'versions';
15
- export declare const resourceList: readonly ["api_credentials", "application_memberships", "memberships", "organizations", "permissions", "roles", "user", "versions"];
16
- export declare const singletonList: readonly ["user"];
17
- export type RetrievableResourceType = ResourceTypeLock;
18
- export type RetrievableResource = Resource & {
19
- type: RetrievableResourceType;
20
- };
21
- export type ListableResourceType = Exclude<ResourceTypeLock, 'user'>;
22
- export type ListableResource = Resource & {
23
- type: ListableResourceType;
24
- };
25
- export type CreatableResourceType = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles';
26
- export type CreatableResource = Resource & {
27
- type: CreatableResourceType;
28
- };
29
- export type UpdatableResourceType = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles';
30
- export type UpdatableResource = Resource & {
31
- type: UpdatableResourceType;
32
- };
33
- export type DeletableResourceType = 'api_credentials' | 'application_memberships' | 'memberships';
34
- export type DeletableResource = Resource & {
35
- type: DeletableResourceType;
36
- };
37
- export type VersionableResourceType = 'memberships' | 'permissions' | 'roles';
38
- export type VersionableResource = Resource & {
39
- type: VersionableResourceType;
40
- versions?: Array<ResourceRel & {
41
- type: VersionType;
42
- }> | null;
43
- };
package/lib/cjs/api.js DELETED
@@ -1,45 +0,0 @@
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.singletonList = exports.resourceList = exports.Versions = exports.Users = exports.Roles = exports.Permissions = exports.Organizations = exports.Memberships = exports.ApplicationMemberships = exports.ApiCredentials = void 0;
7
- // ##__API_RESOURCES_START__##
8
- // ##__API_RESOURCES_TEMPLATE:: export { default as ##__RESOURCE_CLASS__## } from './resources/##__RESOURCE_TYPE__##'
9
- /**
10
- * ©2024 Commerce Layer Inc.
11
- **/
12
- var api_credentials_1 = require("./resources/api_credentials");
13
- Object.defineProperty(exports, "ApiCredentials", { enumerable: true, get: function () { return __importDefault(api_credentials_1).default; } });
14
- var application_memberships_1 = require("./resources/application_memberships");
15
- Object.defineProperty(exports, "ApplicationMemberships", { enumerable: true, get: function () { return __importDefault(application_memberships_1).default; } });
16
- var memberships_1 = require("./resources/memberships");
17
- Object.defineProperty(exports, "Memberships", { enumerable: true, get: function () { return __importDefault(memberships_1).default; } });
18
- var organizations_1 = require("./resources/organizations");
19
- Object.defineProperty(exports, "Organizations", { enumerable: true, get: function () { return __importDefault(organizations_1).default; } });
20
- var permissions_1 = require("./resources/permissions");
21
- Object.defineProperty(exports, "Permissions", { enumerable: true, get: function () { return __importDefault(permissions_1).default; } });
22
- var roles_1 = require("./resources/roles");
23
- Object.defineProperty(exports, "Roles", { enumerable: true, get: function () { return __importDefault(roles_1).default; } });
24
- var user_1 = require("./resources/user");
25
- Object.defineProperty(exports, "Users", { enumerable: true, get: function () { return __importDefault(user_1).default; } });
26
- var versions_1 = require("./resources/versions");
27
- Object.defineProperty(exports, "Versions", { enumerable: true, get: function () { return __importDefault(versions_1).default; } });
28
- // ##__API_RESOURCE_TYPES_STOP__##
29
- exports.resourceList = [
30
- // ##__API_RESOURCE_LIST_START__##
31
- 'api_credentials',
32
- 'application_memberships',
33
- 'memberships',
34
- 'organizations',
35
- 'permissions',
36
- 'roles',
37
- 'user',
38
- 'versions'
39
- // ##__API_RESOURCE_LIST_STOP__##
40
- ];
41
- exports.singletonList = [
42
- // ##__API_RESOURCE_SINGLETON_START__##
43
- 'user'
44
- // ##__API_RESOURCE_SINGLETON_STOP__##
45
- ];
@@ -1,42 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
4
- import type { InterceptorManager } from './interceptor';
5
- import type { Agent as HttpAgent } from 'http';
6
- import type { Agent as HttpsAgent } from 'https';
7
- type ProxyConfig = AxiosProxyConfig | false;
8
- type Adapter = AxiosAdapter;
9
- type RequestParams = Record<string, string | number | boolean>;
10
- type RequestHeaders = Record<string, string>;
11
- type RequestConfig = {
12
- timeout?: number;
13
- params?: RequestParams;
14
- httpAgent?: HttpAgent;
15
- httpsAgent?: HttpsAgent;
16
- proxy?: ProxyConfig;
17
- headers?: RequestHeaders;
18
- };
19
- type RequestConfigExtra = {
20
- adapter?: Adapter;
21
- userAgent?: string;
22
- };
23
- type ApiConfig = {
24
- domain?: string;
25
- accessToken: string;
26
- };
27
- type ApiClientInitConfig = ApiConfig & RequestConfig & RequestConfigExtra;
28
- type ApiClientConfig = Partial<ApiClientInitConfig>;
29
- declare class ApiClient {
30
- #private;
31
- static create(options: ApiClientInitConfig): ApiClient;
32
- baseUrl: string;
33
- interceptors: InterceptorManager;
34
- private constructor();
35
- config(config: ApiClientConfig): ApiClient;
36
- userAgent(userAgent: string): ApiClient;
37
- adapter(adapter: Adapter): ApiClient;
38
- request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
39
- private customHeaders;
40
- }
41
- export default ApiClient;
42
- export type { ApiClientInitConfig, ApiClientConfig, RequestConfig };
package/lib/cjs/client.js DELETED
@@ -1,149 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- var _ApiClient_accessToken, _ApiClient_client;
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const axios_1 = __importDefault(require("axios"));
19
- const error_1 = require("./error");
20
- const config_1 = __importDefault(require("./config"));
21
- // import { packageInfo } from './util'
22
- const debug_1 = __importDefault(require("./debug"));
23
- const debug = (0, debug_1.default)('client');
24
- const baseURL = (domain) => {
25
- return `https://provisioning.${domain || config_1.default.default.domain}/api`;
26
- };
27
- class ApiClient {
28
- static create(options) {
29
- for (const attr of config_1.default.client.requiredAttributes)
30
- if (!options || !options[attr])
31
- throw new error_1.SdkError({ message: `Undefined '${attr}' parameter` });
32
- return new ApiClient(options);
33
- }
34
- constructor(options) {
35
- _ApiClient_accessToken.set(this, void 0);
36
- _ApiClient_client.set(this, void 0);
37
- debug('new client instance %O', options);
38
- this.baseUrl = baseURL(options.domain);
39
- __classPrivateFieldSet(this, _ApiClient_accessToken, options.accessToken, "f");
40
- const axiosConfig = {
41
- timeout: options.timeout || config_1.default.client.timeout,
42
- proxy: options.proxy,
43
- httpAgent: options.httpAgent,
44
- httpsAgent: options.httpsAgent
45
- };
46
- // Set custom headers
47
- const customHeaders = this.customHeaders(options.headers);
48
- // Set headers
49
- const headers = {
50
- ...customHeaders,
51
- 'Accept': 'application/vnd.api+json',
52
- 'Content-Type': 'application/vnd.api+json',
53
- 'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
54
- };
55
- // Set User-Agent
56
- let userAgent = options.userAgent; // || `SDK-provisioning axios/${axios.VERSION}`
57
- if (userAgent) {
58
- if (!userAgent.includes('axios/'))
59
- userAgent += ` axios/${axios_1.default.VERSION}`;
60
- headers['User-Agent'] = userAgent;
61
- }
62
- const axiosOptions = {
63
- baseURL: this.baseUrl,
64
- timeout: config_1.default.client.timeout,
65
- headers,
66
- ...axiosConfig
67
- };
68
- if (options.adapter)
69
- axiosOptions.adapter = options.adapter;
70
- debug('axios options: %O', axiosOptions);
71
- __classPrivateFieldSet(this, _ApiClient_client, axios_1.default.create(axiosOptions), "f");
72
- this.interceptors = __classPrivateFieldGet(this, _ApiClient_client, "f").interceptors;
73
- }
74
- config(config) {
75
- debug('config %o', config);
76
- const def = __classPrivateFieldGet(this, _ApiClient_client, "f").defaults;
77
- // Axios config
78
- if (config.timeout)
79
- def.timeout = config.timeout;
80
- if (config.proxy)
81
- def.proxy = config.proxy;
82
- if (config.httpAgent)
83
- def.httpAgent = config.httpAgent;
84
- if (config.httpsAgent)
85
- def.httpsAgent = config.httpsAgent;
86
- if (config.adapter)
87
- this.adapter(config.adapter);
88
- if (config.userAgent)
89
- this.userAgent(config.userAgent);
90
- // API Client config
91
- if (config.accessToken) {
92
- __classPrivateFieldSet(this, _ApiClient_accessToken, config.accessToken, "f");
93
- def.headers.common.Authorization = 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
94
- }
95
- if (config.headers)
96
- def.headers.common = this.customHeaders(config.headers);
97
- return this;
98
- }
99
- userAgent(userAgent) {
100
- if (userAgent) {
101
- let ua = userAgent;
102
- if (!ua.includes('axios/')) {
103
- // const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true })
104
- if (axios_1.default.VERSION)
105
- ua += ` axios/${axios_1.default.VERSION}`;
106
- }
107
- __classPrivateFieldGet(this, _ApiClient_client, "f").defaults.headers['User-Agent'] = ua;
108
- }
109
- return this;
110
- }
111
- adapter(adapter) {
112
- if (adapter)
113
- __classPrivateFieldGet(this, _ApiClient_client, "f").defaults.adapter = adapter;
114
- return this;
115
- }
116
- async request(method, path, body, options) {
117
- debug('request %s %s, %O, %O', method, path, body || {}, options || {});
118
- // Ignored params alerts (in debug mode)
119
- if (options === null || options === void 0 ? void 0 : options.adapter)
120
- debug('Adapter ignored in request config');
121
- if (options === null || options === void 0 ? void 0 : options.userAgent)
122
- debug('User-Agent header ignored in request config');
123
- const data = body ? { data: body } : undefined;
124
- const url = path;
125
- // Runtime request parameters
126
- const accessToken = (options === null || options === void 0 ? void 0 : options.accessToken) || __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
127
- const headers = this.customHeaders(options === null || options === void 0 ? void 0 : options.headers);
128
- if (accessToken)
129
- headers.Authorization = 'Bearer ' + accessToken;
130
- const requestParams = { method, url, data, ...options, headers };
131
- debug('request params: %O', requestParams);
132
- // const start = Date.now()
133
- return __classPrivateFieldGet(this, _ApiClient_client, "f").request(requestParams)
134
- .then(response => response.data)
135
- .catch((error) => (0, error_1.handleError)(error));
136
- // .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
137
- }
138
- customHeaders(headers) {
139
- const customHeaders = {};
140
- if (headers) {
141
- for (const [name, value] of Object.entries(headers))
142
- if (!['accept', 'content-type', 'authorization', 'user-agent'].includes(name.toLowerCase()))
143
- customHeaders[name] = value;
144
- }
145
- return customHeaders;
146
- }
147
- }
148
- _ApiClient_accessToken = new WeakMap(), _ApiClient_client = new WeakMap();
149
- exports.default = ApiClient;
@@ -1,39 +0,0 @@
1
- import * as api from './api';
2
- import type { ApiError } from './error';
3
- import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
- import { type ResourcesInitConfig } from './resource';
5
- declare const OPEN_API_SCHEMA_VERSION = "1.0.2";
6
- export { OPEN_API_SCHEMA_VERSION };
7
- type SdkConfig = {};
8
- type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
9
- type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
10
- declare class CommerceLayerProvisioningClient {
11
- #private;
12
- readonly openApiSchemaVersion = "1.0.2";
13
- api_credentials: api.ApiCredentials;
14
- application_memberships: api.ApplicationMemberships;
15
- memberships: api.Memberships;
16
- organizations: api.Organizations;
17
- permissions: api.Permissions;
18
- roles: api.Roles;
19
- user: api.Users;
20
- versions: api.Versions;
21
- constructor(config: CommerceLayerInitConfig);
22
- private localConfig;
23
- config(config: CommerceLayerConfig): CommerceLayerProvisioningClient;
24
- resources(): readonly string[];
25
- singletons(): readonly string[];
26
- isSingleton(resource: api.ResourceTypeLock): boolean;
27
- isApiError(error: any): error is ApiError;
28
- addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
29
- addResponseInterceptor(onFulfilled?: ResponseInterceptor, onRejected?: ErrorInterceptor): number;
30
- removeInterceptor(type: InterceptorType, id: number): void;
31
- addRawResponseReader(options?: {
32
- headers: boolean;
33
- }): RawResponseReader;
34
- removeRawResponseReader(reader: number | RawResponseReader): void;
35
- }
36
- declare const CommerceLayerProvisioning: (config: CommerceLayerInitConfig) => CommerceLayerProvisioningClient;
37
- export default CommerceLayerProvisioning;
38
- export { CommerceLayerProvisioning };
39
- export type { CommerceLayerProvisioningClient, CommerceLayerConfig, CommerceLayerInitConfig };
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
- if (kind === "m") throw new TypeError("Private method is not writable");
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
- };
31
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
34
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- var _CommerceLayerProvisioningClient_adapter;
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.CommerceLayerProvisioning = exports.OPEN_API_SCHEMA_VERSION = void 0;
42
- const api = __importStar(require("./api"));
43
- const static_1 = require("./static");
44
- const resource_1 = __importDefault(require("./resource"));
45
- const debug_1 = __importDefault(require("./debug"));
46
- const debug = (0, debug_1.default)('commercelayer');
47
- // Autogenerated schema version number, do not remove this line
48
- const OPEN_API_SCHEMA_VERSION = '1.0.2';
49
- exports.OPEN_API_SCHEMA_VERSION = OPEN_API_SCHEMA_VERSION;
50
- class CommerceLayerProvisioningClient {
51
- // ##__CL_RESOURCES_DEF_STOP__##
52
- constructor(config) {
53
- // static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
54
- this.openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
55
- _CommerceLayerProvisioningClient_adapter.set(this, void 0);
56
- debug('new commercelayer provisioning instance %O', config);
57
- __classPrivateFieldSet(this, _CommerceLayerProvisioningClient_adapter, new resource_1.default(config), "f");
58
- // this.#environment = 'test'
59
- // ##__CL_RESOURCES_INIT_START__##
60
- // ##__CL_RESOURCES_INIT_TEMPLATE:: ##__TAB__####__TAB__##this.##__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)
61
- this.api_credentials = new api.ApiCredentials(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
62
- this.application_memberships = new api.ApplicationMemberships(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
63
- this.memberships = new api.Memberships(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
64
- this.organizations = new api.Organizations(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
65
- this.permissions = new api.Permissions(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
66
- this.roles = new api.Roles(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
67
- this.user = new api.Users(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
68
- this.versions = new api.Versions(__classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f"));
69
- // ##__CL_RESOURCES_INIT_STOP__##
70
- }
71
- // get environment(): ApiMode { return this.#environment }
72
- localConfig(config) {
73
- }
74
- config(config) {
75
- debug('config %o', config);
76
- // CommerceLayer config
77
- this.localConfig(config);
78
- // ResourceAdapter config
79
- __classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f").config(config);
80
- return this;
81
- }
82
- resources() {
83
- return static_1.CommerceLayerProvisioningStatic.resources();
84
- }
85
- singletons() {
86
- return static_1.CommerceLayerProvisioningStatic.singletons();
87
- }
88
- isSingleton(resource) {
89
- return static_1.CommerceLayerProvisioningStatic.isSingleton(resource);
90
- }
91
- isApiError(error) {
92
- return static_1.CommerceLayerProvisioningStatic.isApiError(error);
93
- }
94
- addRequestInterceptor(onFulfilled, onRejected) {
95
- return __classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f").interceptors.request.use(onFulfilled, onRejected);
96
- }
97
- addResponseInterceptor(onFulfilled, onRejected) {
98
- return __classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f").interceptors.response.use(onFulfilled, onRejected);
99
- }
100
- removeInterceptor(type, id) {
101
- __classPrivateFieldGet(this, _CommerceLayerProvisioningClient_adapter, "f").interceptors[type].eject(id);
102
- }
103
- addRawResponseReader(options) {
104
- const reader = {
105
- id: undefined,
106
- rawResponse: undefined,
107
- headers: undefined,
108
- };
109
- function rawResponseInterceptor(response) {
110
- reader.rawResponse = response === null || response === void 0 ? void 0 : response.data;
111
- if (options === null || options === void 0 ? void 0 : options.headers)
112
- reader.headers = response.headers;
113
- return response;
114
- }
115
- const interceptor = this.addResponseInterceptor(rawResponseInterceptor);
116
- reader.id = interceptor;
117
- return reader;
118
- }
119
- removeRawResponseReader(reader) {
120
- const id = (typeof reader === 'number') ? reader : reader === null || reader === void 0 ? void 0 : reader.id;
121
- if (id && (id >= 0))
122
- this.removeInterceptor('response', id);
123
- }
124
- }
125
- _CommerceLayerProvisioningClient_adapter = new WeakMap();
126
- const CommerceLayerProvisioning = (config) => {
127
- return new CommerceLayerProvisioningClient(config);
128
- };
129
- exports.CommerceLayerProvisioning = CommerceLayerProvisioning;
130
- exports.default = CommerceLayerProvisioning;
@@ -1,5 +0,0 @@
1
- import type { ResourceId, ResourceType } from './resource';
2
- declare const isResourceId: (resource: any) => resource is ResourceId;
3
- declare const isResourceType: (resource: any) => resource is ResourceType;
4
- export { isResourceId, isResourceType };
5
- export type ObjectType = Record<string, any>;
package/lib/cjs/common.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isResourceType = exports.isResourceId = void 0;
4
- const api_1 = require("./api");
5
- const isResourceId = (resource) => {
6
- return ((resource === null || resource === void 0 ? void 0 : resource.type) && resource.id) && api_1.resourceList.includes(resource.type);
7
- };
8
- exports.isResourceId = isResourceId;
9
- const isResourceType = (resource) => {
10
- return resource && (typeof resource.type !== 'undefined') && resource.type && api_1.resourceList.includes(resource.type);
11
- };
12
- exports.isResourceType = isResourceType;
@@ -1,15 +0,0 @@
1
- declare const config: {
2
- readonly default: {
3
- readonly domain: "commercelayer.io";
4
- readonly pageNumber: 1;
5
- readonly pageSize: 10;
6
- };
7
- readonly client: {
8
- readonly timeout: 15000;
9
- readonly requiredAttributes: readonly ["accessToken"];
10
- };
11
- readonly jsonapi: {
12
- readonly maxResourceIncluded: 2;
13
- };
14
- };
15
- export default config;
package/lib/cjs/config.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- // export type ApiMode = 'test' | 'live'
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const config = {
5
- default: {
6
- // environment: 'test',
7
- domain: 'commercelayer.io',
8
- pageNumber: 1,
9
- pageSize: 10,
10
- },
11
- client: {
12
- timeout: 15000,
13
- requiredAttributes: ['accessToken']
14
- },
15
- jsonapi: {
16
- maxResourceIncluded: 2
17
- }
18
- };
19
- exports.default = config;
@@ -1,3 +0,0 @@
1
- type Debugger = (pattern: string, ...args: any[]) => void;
2
- declare const debug: (namespace: string) => Debugger;
3
- export default debug;
package/lib/cjs/debug.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* Nope debugger */
4
- const debuggerFunction = (_pattern, ..._args) => {
5
- // console.log(_pattern)
6
- };
7
- let debuggerFactory = (_namespace) => debuggerFunction;
8
- /* Try loading 'debug' module */
9
- try {
10
- const debugModule = require('debug');
11
- if (debugModule && (typeof debugModule === 'function'))
12
- debuggerFactory = debugModule;
13
- }
14
- catch (error) {
15
- //
16
- }
17
- const debugPrefix = 'clsdk';
18
- /* Retrieve the name of the caller 'module' */
19
- /*
20
- const caller = (): string => {
21
-
22
- const err = new Error()
23
-
24
- Error.prepareStackTrace = (_, stack) => stack
25
- const stack = err.stack as unknown as NodeJS.CallSite[]
26
- Error.prepareStackTrace = undefined
27
-
28
- const fileName = stack[2].getFileName() || '/'
29
-
30
- return fileName.replace(/^.*[\\/]/, '').replace('.ts', '')
31
-
32
- }
33
- */
34
- /* Return a debugger for the defined namespace */
35
- const debug = (namespace) => {
36
- return debuggerFactory(`${debugPrefix}:${namespace}`);
37
- };
38
- exports.default = debug;
@@ -1,31 +0,0 @@
1
- declare enum ErrorType {
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
- GENERIC = "generic"
8
- }
9
- declare class SdkError extends Error {
10
- static NAME: string;
11
- static isSdkError(error: any): error is SdkError;
12
- type: ErrorType;
13
- code?: string;
14
- source?: Error;
15
- request?: any;
16
- constructor(error: {
17
- message: string;
18
- type?: ErrorType;
19
- });
20
- }
21
- declare class ApiError extends SdkError {
22
- static NAME: string;
23
- static isApiError(error: any): error is ApiError;
24
- errors: any[];
25
- status?: number;
26
- statusText?: string;
27
- constructor(error: SdkError);
28
- first(): any;
29
- }
30
- declare const handleError: (error: Error) => never;
31
- export { SdkError, ApiError, ErrorType, handleError };