@vtex/api 6.50.2-beta.0 → 6.51.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/CHANGELOG.md +7 -0
- package/lib/clients/IOClients.d.ts +2 -1
- package/lib/clients/IOClients.js +3 -0
- package/lib/clients/janus/Catalog/index.d.ts +7 -0
- package/lib/clients/janus/Catalog/index.js +37 -0
- package/lib/clients/janus/Catalog/types.d.ts +5 -0
- package/lib/clients/janus/Catalog/types.js +2 -0
- package/lib/clients/janus/{LicenseManager.d.ts → LicenseManager/index.d.ts} +6 -2
- package/lib/clients/janus/LicenseManager/index.js +91 -0
- package/lib/clients/janus/LicenseManager/types.d.ts +16 -0
- package/lib/clients/janus/LicenseManager/types.js +2 -0
- package/lib/clients/janus/LicenseManager/utils.d.ts +6 -0
- package/lib/clients/janus/LicenseManager/utils.js +40 -0
- package/lib/clients/janus/index.d.ts +1 -0
- package/lib/clients/janus/index.js +1 -0
- package/package.json +1 -1
- package/lib/clients/janus/LicenseManager.js +0 -59
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.51.0] - 2026-06-23
|
|
11
|
+
### Added
|
|
12
|
+
- Base `IOClients` getter `janusCatalogSystem` (Janus Catalog) and
|
|
13
|
+
`licenseManager.listBindings`, plus binding-mapping helpers
|
|
14
|
+
(getCanonicalAndAlternateAddresses, inferTargetProduct) used by the
|
|
15
|
+
Tenant API migration. Backport of #617 to the 6.x line.
|
|
16
|
+
|
|
10
17
|
## [6.50.1] - 2025-09-10
|
|
11
18
|
### Fixed
|
|
12
19
|
- Axios vuln GHSA-jr5f-v2jv-69x6 by using axios@^0.30.1
|
|
@@ -5,7 +5,7 @@ import { CatalogGraphQL } from './apps/catalogGraphQL/index';
|
|
|
5
5
|
import { ID, MasterData, PaymentProvider } from './external';
|
|
6
6
|
import { Apps, Assets, BillingMetrics, Events, Registry, Router, VBase, Workspaces } from './infra';
|
|
7
7
|
import { IOClientConstructor } from './IOClient';
|
|
8
|
-
import { LicenseManager, Segment, Session, TenantClient } from './janus';
|
|
8
|
+
import { Catalog, LicenseManager, Segment, Session, TenantClient } from './janus';
|
|
9
9
|
export type ClientsImplementation<T extends IOClients> = new (clientOptions: Record<string, InstanceOptions>, ctx: IOContext) => T;
|
|
10
10
|
export declare class IOClients {
|
|
11
11
|
private clientOptions;
|
|
@@ -31,6 +31,7 @@ export declare class IOClients {
|
|
|
31
31
|
get vbase(): VBase;
|
|
32
32
|
get workspaces(): Workspaces;
|
|
33
33
|
get catalogGraphQL(): CatalogGraphQL;
|
|
34
|
+
get janusCatalogSystem(): Catalog;
|
|
34
35
|
get paymentProvider(): PaymentProvider;
|
|
35
36
|
protected getOrSet<TClient extends IOClientConstructor>(key: string, Implementation: TClient): InstanceType<TClient>;
|
|
36
37
|
}
|
package/lib/clients/IOClients.js
CHANGED
|
@@ -69,6 +69,9 @@ class IOClients {
|
|
|
69
69
|
get catalogGraphQL() {
|
|
70
70
|
return this.getOrSet('catalogGraphQL', index_1.CatalogGraphQL);
|
|
71
71
|
}
|
|
72
|
+
get janusCatalogSystem() {
|
|
73
|
+
return this.getOrSet('janusCatalogSystem', janus_1.Catalog);
|
|
74
|
+
}
|
|
72
75
|
get paymentProvider() {
|
|
73
76
|
return this.getOrSet('paymentProvider', external_1.PaymentProvider);
|
|
74
77
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestConfig } from '../../../HttpClient';
|
|
2
|
+
import { JanusClient } from '../JanusClient';
|
|
3
|
+
import { SalesChannel } from './types';
|
|
4
|
+
export declare class Catalog extends JanusClient {
|
|
5
|
+
getSalesChannel(id: number, config?: RequestConfig): Promise<SalesChannel>;
|
|
6
|
+
getDefaultSalesChannel(config?: RequestConfig): Promise<SalesChannel>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Catalog = void 0;
|
|
4
|
+
const HttpClient_1 = require("../../../HttpClient");
|
|
5
|
+
const JanusClient_1 = require("../JanusClient");
|
|
6
|
+
const BASE_URL = '/api/catalog_system';
|
|
7
|
+
const routes = {
|
|
8
|
+
defaultSalesChannel: () => `${BASE_URL}/pub/saleschannel/default`,
|
|
9
|
+
salesChannel: (salesChannelId) => `${BASE_URL}/pub/saleschannel/${salesChannelId}`,
|
|
10
|
+
};
|
|
11
|
+
class Catalog extends JanusClient_1.JanusClient {
|
|
12
|
+
getSalesChannel(id, config) {
|
|
13
|
+
const metric = 'catalog-saleschannel';
|
|
14
|
+
return this.http.get(routes.salesChannel(id), {
|
|
15
|
+
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
16
|
+
metric,
|
|
17
|
+
...config,
|
|
18
|
+
tracing: {
|
|
19
|
+
requestSpanNameSuffix: metric,
|
|
20
|
+
...config === null || config === void 0 ? void 0 : config.tracing,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getDefaultSalesChannel(config) {
|
|
25
|
+
const metric = 'catalog-saleschannel-default';
|
|
26
|
+
return this.http.get(routes.defaultSalesChannel(), {
|
|
27
|
+
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
28
|
+
metric,
|
|
29
|
+
...config,
|
|
30
|
+
tracing: {
|
|
31
|
+
requestSpanNameSuffix: metric,
|
|
32
|
+
...config === null || config === void 0 ? void 0 : config.tracing,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Catalog = Catalog;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { RequestTracingConfig } from '
|
|
2
|
-
import { JanusClient } from '
|
|
1
|
+
import { RequestConfig, RequestTracingConfig } from '../../../HttpClient';
|
|
2
|
+
import { JanusClient } from '../JanusClient';
|
|
3
|
+
import { APIBindingRes } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './utils';
|
|
3
6
|
export declare class LicenseManager extends JanusClient {
|
|
4
7
|
getAccountData(VtexIdclientAutCookie: string, tracingConfig?: RequestTracingConfig): Promise<any>;
|
|
5
8
|
getTopbarData(VtexIdclientAutCookie: string, tracingConfig?: RequestTracingConfig): Promise<any>;
|
|
6
9
|
canAccessResource(VtexIdclientAutCookie: string, resourceKey: string, tracingConfig?: RequestTracingConfig): Promise<boolean>;
|
|
10
|
+
listBindings(tenant: string, config?: RequestConfig): Promise<APIBindingRes[]>;
|
|
7
11
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.LicenseManager = void 0;
|
|
18
|
+
const HttpClient_1 = require("../../../HttpClient");
|
|
19
|
+
const JanusClient_1 = require("../JanusClient");
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
|
22
|
+
const TWO_MINUTES_S = 2 * 60;
|
|
23
|
+
const BASE_URL = '/api/license-manager';
|
|
24
|
+
const routes = {
|
|
25
|
+
accountData: () => `${BASE_URL}/account`,
|
|
26
|
+
listBindings: (tenant) => `${BASE_URL}/binding/site/${encodeURIComponent(tenant)}`,
|
|
27
|
+
resourceAccess: (resourceKey) => `${BASE_URL}/resources/${encodeURIComponent(resourceKey)}/access`,
|
|
28
|
+
topbarData: () => `${BASE_URL}/site/pvt/newtopbar`,
|
|
29
|
+
};
|
|
30
|
+
class LicenseManager extends JanusClient_1.JanusClient {
|
|
31
|
+
getAccountData(VtexIdclientAutCookie, tracingConfig) {
|
|
32
|
+
const metric = 'lm-account-data';
|
|
33
|
+
return this.http.get(routes.accountData(), {
|
|
34
|
+
forceMaxAge: TWO_MINUTES_S,
|
|
35
|
+
headers: {
|
|
36
|
+
VtexIdclientAutCookie,
|
|
37
|
+
},
|
|
38
|
+
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
39
|
+
metric,
|
|
40
|
+
tracing: {
|
|
41
|
+
requestSpanNameSuffix: metric,
|
|
42
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getTopbarData(VtexIdclientAutCookie, tracingConfig) {
|
|
47
|
+
const metric = 'lm-topbar-data';
|
|
48
|
+
return this.http.get(routes.topbarData(), {
|
|
49
|
+
headers: {
|
|
50
|
+
VtexIdclientAutCookie,
|
|
51
|
+
},
|
|
52
|
+
metric,
|
|
53
|
+
tracing: {
|
|
54
|
+
requestSpanNameSuffix: metric,
|
|
55
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
canAccessResource(VtexIdclientAutCookie, resourceKey, tracingConfig) {
|
|
60
|
+
const metric = 'lm-resource-access';
|
|
61
|
+
return this.http
|
|
62
|
+
.get(routes.resourceAccess(resourceKey), {
|
|
63
|
+
headers: {
|
|
64
|
+
VtexIdclientAutCookie,
|
|
65
|
+
},
|
|
66
|
+
metric,
|
|
67
|
+
tracing: {
|
|
68
|
+
requestSpanNameSuffix: metric,
|
|
69
|
+
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
.then(() => true, () => false);
|
|
73
|
+
}
|
|
74
|
+
listBindings(tenant, config) {
|
|
75
|
+
const metric = 'lm-list-bindings';
|
|
76
|
+
return this.http.get(routes.listBindings(tenant), {
|
|
77
|
+
headers: {
|
|
78
|
+
VtexIdclientAutCookie: this.context.authToken,
|
|
79
|
+
},
|
|
80
|
+
inflightKey: HttpClient_1.inflightUrlWithQuery,
|
|
81
|
+
memoizeable: true,
|
|
82
|
+
metric,
|
|
83
|
+
...config,
|
|
84
|
+
tracing: {
|
|
85
|
+
requestSpanNameSuffix: metric,
|
|
86
|
+
...config === null || config === void 0 ? void 0 : config.tracing,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.LicenseManager = LicenseManager;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface APIAddress {
|
|
2
|
+
Host: string;
|
|
3
|
+
IsCanonical: boolean;
|
|
4
|
+
BasePath: string;
|
|
5
|
+
Localization: {
|
|
6
|
+
[k: string]: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface APIBindingRes {
|
|
10
|
+
Id: string;
|
|
11
|
+
Addresses: APIAddress[];
|
|
12
|
+
SiteName: string;
|
|
13
|
+
DefaultSalesChannelId: number | null;
|
|
14
|
+
DefaultLocale: string;
|
|
15
|
+
SupportedLocales: string[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { APIBindingRes } from './types';
|
|
2
|
+
export declare const getCanonicalAndAlternateAddresses: (lmBinding: APIBindingRes) => {
|
|
3
|
+
canonicalBaseAddress: string;
|
|
4
|
+
alternateBaseAddresses: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const inferTargetProduct: (canonicalBaseAddress: string, alternateBaseAddresses: string[]) => 'vtex-admin' | 'vtex-storefront';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inferTargetProduct = exports.getCanonicalAndAlternateAddresses = void 0;
|
|
4
|
+
const buildAddressPath = (basePath, localizationKey) => {
|
|
5
|
+
if (basePath === '') {
|
|
6
|
+
return `/${localizationKey}`;
|
|
7
|
+
}
|
|
8
|
+
if (localizationKey === '') {
|
|
9
|
+
return `/${basePath}`;
|
|
10
|
+
}
|
|
11
|
+
return `/${basePath}/${localizationKey}`;
|
|
12
|
+
};
|
|
13
|
+
const getCanonicalAndAlternateAddresses = (lmBinding) => {
|
|
14
|
+
let canonicalBaseAddress = '';
|
|
15
|
+
const alternateBaseAddresses = [];
|
|
16
|
+
for (const addressEntry of lmBinding.Addresses) {
|
|
17
|
+
const localizationKeys = Object.keys(addressEntry.Localization);
|
|
18
|
+
for (const localizationKey of localizationKeys) {
|
|
19
|
+
alternateBaseAddresses.push(addressEntry.Host + buildAddressPath(addressEntry.BasePath, localizationKey));
|
|
20
|
+
}
|
|
21
|
+
if (addressEntry.IsCanonical) {
|
|
22
|
+
// The canonical address is built from the shortest localization key.
|
|
23
|
+
const [shortestLocalizationKey = ''] = [...localizationKeys].sort((a, b) => a.length - b.length);
|
|
24
|
+
canonicalBaseAddress = addressEntry.Host + buildAddressPath(addressEntry.BasePath, shortestLocalizationKey);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// The canonical address must not also appear in the alternates list.
|
|
28
|
+
const canonicalIndexInAlternates = alternateBaseAddresses.indexOf(canonicalBaseAddress);
|
|
29
|
+
if (canonicalIndexInAlternates !== -1) {
|
|
30
|
+
alternateBaseAddresses.splice(canonicalIndexInAlternates, 1);
|
|
31
|
+
}
|
|
32
|
+
return { canonicalBaseAddress, alternateBaseAddresses };
|
|
33
|
+
};
|
|
34
|
+
exports.getCanonicalAndAlternateAddresses = getCanonicalAndAlternateAddresses;
|
|
35
|
+
const inferTargetProduct = (canonicalBaseAddress, alternateBaseAddresses) => {
|
|
36
|
+
const isAdmin = canonicalBaseAddress.endsWith('myvtex.com/admin') ||
|
|
37
|
+
alternateBaseAddresses.some((address) => address.endsWith('myvtex.com/admin'));
|
|
38
|
+
return isAdmin ? 'vtex-admin' : 'vtex-storefront';
|
|
39
|
+
};
|
|
40
|
+
exports.inferTargetProduct = inferTargetProduct;
|
package/package.json
CHANGED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LicenseManager = void 0;
|
|
4
|
-
const qs_1 = require("qs");
|
|
5
|
-
const JanusClient_1 = require("./JanusClient");
|
|
6
|
-
const TWO_MINUTES_S = 2 * 60;
|
|
7
|
-
const BASE_URL = '/api/license-manager';
|
|
8
|
-
const routes = {
|
|
9
|
-
accountData: `${BASE_URL}/account`,
|
|
10
|
-
resourceAccess: `${BASE_URL}/resources`,
|
|
11
|
-
topbarData: `${BASE_URL}/site/pvt/newtopbar`,
|
|
12
|
-
};
|
|
13
|
-
const inflightKey = ({ baseURL, url, params }) => {
|
|
14
|
-
return baseURL + url + (0, qs_1.stringify)(params, { arrayFormat: 'repeat', addQueryPrefix: true });
|
|
15
|
-
};
|
|
16
|
-
class LicenseManager extends JanusClient_1.JanusClient {
|
|
17
|
-
getAccountData(VtexIdclientAutCookie, tracingConfig) {
|
|
18
|
-
const metric = 'lm-account-data';
|
|
19
|
-
return this.http.get(routes.accountData, {
|
|
20
|
-
forceMaxAge: TWO_MINUTES_S,
|
|
21
|
-
headers: {
|
|
22
|
-
VtexIdclientAutCookie,
|
|
23
|
-
},
|
|
24
|
-
inflightKey,
|
|
25
|
-
metric,
|
|
26
|
-
tracing: {
|
|
27
|
-
requestSpanNameSuffix: metric,
|
|
28
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
getTopbarData(VtexIdclientAutCookie, tracingConfig) {
|
|
33
|
-
const metric = 'lm-topbar-data';
|
|
34
|
-
return this.http.get(routes.topbarData, {
|
|
35
|
-
headers: {
|
|
36
|
-
VtexIdclientAutCookie,
|
|
37
|
-
},
|
|
38
|
-
metric,
|
|
39
|
-
tracing: {
|
|
40
|
-
requestSpanNameSuffix: metric,
|
|
41
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
canAccessResource(VtexIdclientAutCookie, resourceKey, tracingConfig) {
|
|
46
|
-
const metric = 'lm-resource-access';
|
|
47
|
-
return this.http.get(`${routes.resourceAccess}/${resourceKey}/access`, {
|
|
48
|
-
headers: {
|
|
49
|
-
VtexIdclientAutCookie,
|
|
50
|
-
},
|
|
51
|
-
metric,
|
|
52
|
-
tracing: {
|
|
53
|
-
requestSpanNameSuffix: metric,
|
|
54
|
-
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
55
|
-
},
|
|
56
|
-
}).then(() => true, () => false);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.LicenseManager = LicenseManager;
|