@bacano/sdk 1.2.6 → 1.2.8
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/CATALOG_MANAGEMENT.md +261 -0
- package/CONTENT_ICONS.md +113 -0
- package/CONTENT_TYPE_MANAGEMENT.md +8 -2
- package/README.md +15 -5
- package/STOREFRONT_FORMS.md +38 -0
- package/STOREFRONT_LEADS.md +5 -1
- package/STOREFRONT_PAYMENTS.md +57 -2
- package/STOREFRONT_PERFORMANCE.md +35 -0
- package/catalog-draft-types.d.ts +145 -0
- package/catalog-management-types.d.ts +143 -0
- package/catalog-management.cjs +125 -0
- package/catalog-management.d.ts +37 -0
- package/catalog-management.js +104 -0
- package/content-management-types.d.ts +9 -1
- package/icons.cjs +5515 -0
- package/icons.d.ts +20 -0
- package/icons.js +5496 -0
- package/index.cjs +153 -63
- package/index.js +153 -63
- package/modules/checkout-contact.d.ts +4 -0
- package/package.json +16 -1
- package/react/icon.cjs +5555 -0
- package/react/icon.d.ts +10 -0
- package/react/icon.js +5534 -0
- package/react.cjs +153 -63
- package/react.js +153 -63
- package/skills/bacano-web/SKILL.md +10 -3
- package/skills/bacano-web/references/common.md +18 -0
- package/skills/bacano-web/references/forms.md +2 -0
- package/skills/bacano-web/references/storefront.md +20 -0
- package/skills/bacano-web/scripts/cli.mjs +28 -5
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export interface CatalogDraftReference {
|
|
2
|
+
id: string | null;
|
|
3
|
+
source_label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CatalogDraftAttribute {
|
|
6
|
+
attribute: CatalogDraftReference;
|
|
7
|
+
values: CatalogDraftReference[];
|
|
8
|
+
text_value?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface CatalogDraftSource {
|
|
11
|
+
namespace: string;
|
|
12
|
+
key: string;
|
|
13
|
+
kind: "excel" | "wordpress" | "shopify" | "other";
|
|
14
|
+
url?: string;
|
|
15
|
+
row_numbers?: number[];
|
|
16
|
+
}
|
|
17
|
+
export interface CatalogDraftContent {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string | null;
|
|
20
|
+
long_description: unknown;
|
|
21
|
+
seo_title: string | null;
|
|
22
|
+
seo_description: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface CatalogDraftImage {
|
|
25
|
+
source_key: string;
|
|
26
|
+
source_url?: string;
|
|
27
|
+
storage_file_id: string | null;
|
|
28
|
+
file_name: string;
|
|
29
|
+
alt_text: string;
|
|
30
|
+
position: number;
|
|
31
|
+
variant_source_keys: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface CatalogCreateProposal {
|
|
34
|
+
contract_version: 1;
|
|
35
|
+
operation: "create";
|
|
36
|
+
source: CatalogDraftSource;
|
|
37
|
+
product: CatalogDraftContent & {
|
|
38
|
+
structure_type: "SIMPLE" | "VARIABLE";
|
|
39
|
+
category_code: string | null;
|
|
40
|
+
category_source_label: string;
|
|
41
|
+
subcategory: CatalogDraftReference;
|
|
42
|
+
measurement_unit: string | null;
|
|
43
|
+
sales_tax_profile_code: string | null;
|
|
44
|
+
price_tax_basis: "included" | "excluded" | null;
|
|
45
|
+
currency: string | null;
|
|
46
|
+
attributes: CatalogDraftAttribute[];
|
|
47
|
+
variant_attributes: CatalogDraftReference[];
|
|
48
|
+
};
|
|
49
|
+
destinations: Array<{
|
|
50
|
+
chain_id: string;
|
|
51
|
+
initial_status: "draft" | "active";
|
|
52
|
+
}>;
|
|
53
|
+
websites: Array<{
|
|
54
|
+
website_id: string;
|
|
55
|
+
show: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
variants: Array<{
|
|
58
|
+
source_key: string;
|
|
59
|
+
excluded: boolean;
|
|
60
|
+
sku: string | null;
|
|
61
|
+
barcode: string | null;
|
|
62
|
+
attributes: CatalogDraftAttribute[];
|
|
63
|
+
prices: Array<{
|
|
64
|
+
chain_id: string;
|
|
65
|
+
price_type: "CLIENT" | "WHOLESALE" | "WHOLESALE_2" | "SALE";
|
|
66
|
+
amount: number | null;
|
|
67
|
+
}>;
|
|
68
|
+
initial_inventory: Array<{
|
|
69
|
+
chain_id: string;
|
|
70
|
+
warehouse_id: string | null;
|
|
71
|
+
source_label: string;
|
|
72
|
+
quantity: number | null;
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
images: CatalogDraftImage[];
|
|
76
|
+
}
|
|
77
|
+
export interface CatalogContentProposal {
|
|
78
|
+
contract_version: 1;
|
|
79
|
+
operation: "edit_content";
|
|
80
|
+
source: CatalogDraftSource;
|
|
81
|
+
product_id: string;
|
|
82
|
+
base_updated_at: string;
|
|
83
|
+
base_content: CatalogDraftContent;
|
|
84
|
+
changes: Partial<CatalogDraftContent>;
|
|
85
|
+
}
|
|
86
|
+
export type CatalogDraftProposal = CatalogCreateProposal | CatalogContentProposal;
|
|
87
|
+
export interface CatalogDraftWrite {
|
|
88
|
+
expected_revision: number;
|
|
89
|
+
request_id: string;
|
|
90
|
+
proposal: CatalogDraftProposal;
|
|
91
|
+
}
|
|
92
|
+
export interface CatalogDraftRecord {
|
|
93
|
+
item_id: string;
|
|
94
|
+
batch_id: string;
|
|
95
|
+
revision: number;
|
|
96
|
+
request_id: string;
|
|
97
|
+
draft: CatalogDraftProposal;
|
|
98
|
+
human_changes: Record<string, unknown>;
|
|
99
|
+
conflicts: unknown[];
|
|
100
|
+
closed: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface CatalogDraftIssue {
|
|
103
|
+
path: string;
|
|
104
|
+
code: string;
|
|
105
|
+
}
|
|
106
|
+
export interface CatalogDraftResult {
|
|
107
|
+
item: CatalogDraftRecord;
|
|
108
|
+
issues: CatalogDraftIssue[];
|
|
109
|
+
}
|
|
110
|
+
export interface CatalogDraftWriteResult extends CatalogDraftResult {
|
|
111
|
+
current_revision: number;
|
|
112
|
+
replayed: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface CatalogDraftBatch {
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
status: string;
|
|
118
|
+
}
|
|
119
|
+
export interface CatalogDraftBatchPage {
|
|
120
|
+
batch: CatalogDraftBatch;
|
|
121
|
+
items: CatalogDraftResult[];
|
|
122
|
+
next_cursor: string | null;
|
|
123
|
+
}
|
|
124
|
+
export interface CatalogDraftChunkResult {
|
|
125
|
+
results: Array<{
|
|
126
|
+
request_id: string;
|
|
127
|
+
success: true;
|
|
128
|
+
data: CatalogDraftWriteResult;
|
|
129
|
+
} | {
|
|
130
|
+
request_id: string;
|
|
131
|
+
success: false;
|
|
132
|
+
error: {
|
|
133
|
+
code: string;
|
|
134
|
+
message: string;
|
|
135
|
+
details?: unknown;
|
|
136
|
+
};
|
|
137
|
+
}>;
|
|
138
|
+
}
|
|
139
|
+
export interface CatalogDraftImageResult extends CatalogDraftWriteResult {
|
|
140
|
+
image: {
|
|
141
|
+
source_key: string;
|
|
142
|
+
storage_file_id: string;
|
|
143
|
+
reused: boolean;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export interface CatalogCapabilities {
|
|
2
|
+
references: true;
|
|
3
|
+
drafts: boolean;
|
|
4
|
+
images: boolean;
|
|
5
|
+
content: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface CatalogManagementContext {
|
|
8
|
+
companyId: string;
|
|
9
|
+
grantId: string;
|
|
10
|
+
capabilities: CatalogCapabilities;
|
|
11
|
+
allProducts: boolean;
|
|
12
|
+
productIds: string[];
|
|
13
|
+
branchIds: string[];
|
|
14
|
+
expiresAt: string;
|
|
15
|
+
/** Only draft writes; never confirmation or direct product edits. */
|
|
16
|
+
writesAvailable: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface CatalogReferences {
|
|
19
|
+
contractVersion: 1;
|
|
20
|
+
company: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
country_code: string;
|
|
24
|
+
is_vat_responsible: boolean;
|
|
25
|
+
sales_prices_include_tax_default: boolean;
|
|
26
|
+
};
|
|
27
|
+
priceTypes: Array<{
|
|
28
|
+
price_type: string;
|
|
29
|
+
is_enabled: boolean;
|
|
30
|
+
is_enabled_for_sales: boolean;
|
|
31
|
+
sort_order: number;
|
|
32
|
+
}>;
|
|
33
|
+
taxProfiles: Array<{
|
|
34
|
+
code: string;
|
|
35
|
+
name: string;
|
|
36
|
+
category: string;
|
|
37
|
+
rate: number;
|
|
38
|
+
}>;
|
|
39
|
+
branches: Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
chains_warehouses: Array<{
|
|
43
|
+
warehouse: {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
49
|
+
websites: Array<{
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
chain_id: string | null;
|
|
53
|
+
is_active: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
categories: Array<{
|
|
56
|
+
name: string;
|
|
57
|
+
product_subcategories: Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
}>;
|
|
61
|
+
}>;
|
|
62
|
+
measurementUnits: Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
}>;
|
|
65
|
+
rules: {
|
|
66
|
+
saleMustBeLowerThanClient: true;
|
|
67
|
+
existingProductsContentOnly: true;
|
|
68
|
+
humanConfirmationRequired: true;
|
|
69
|
+
inventoryRequiresExistingWarehouse: true;
|
|
70
|
+
taxonomyEndpoint: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface CatalogAttributeRule {
|
|
74
|
+
attribute_id: string;
|
|
75
|
+
sort_order: number;
|
|
76
|
+
usage_scope: string;
|
|
77
|
+
is_required: boolean;
|
|
78
|
+
is_filterable: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface CatalogTaxonomy {
|
|
81
|
+
attribute_categories: Array<CatalogAttributeRule & {
|
|
82
|
+
category: string;
|
|
83
|
+
}>;
|
|
84
|
+
attribute_subcategories: Array<CatalogAttributeRule & {
|
|
85
|
+
subcategory_id: string;
|
|
86
|
+
}>;
|
|
87
|
+
attribute_subcategory_exclusions: Array<{
|
|
88
|
+
subcategory_id: string;
|
|
89
|
+
attribute_id: string;
|
|
90
|
+
reason: string | null;
|
|
91
|
+
}>;
|
|
92
|
+
attributes: Array<{
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
is_multiple: boolean;
|
|
96
|
+
tooltip: string | null;
|
|
97
|
+
values: unknown;
|
|
98
|
+
attribute_values: Array<{
|
|
99
|
+
id: string;
|
|
100
|
+
code: string;
|
|
101
|
+
sort_order: number;
|
|
102
|
+
metadata: unknown;
|
|
103
|
+
}>;
|
|
104
|
+
attribute_value_sets: Array<{
|
|
105
|
+
id: string;
|
|
106
|
+
code: string;
|
|
107
|
+
category: string;
|
|
108
|
+
attribute_id: string;
|
|
109
|
+
product_subcategory_attribute_value_sets: Array<{
|
|
110
|
+
subcategory_id: string;
|
|
111
|
+
position: number;
|
|
112
|
+
}>;
|
|
113
|
+
attribute_value_set_values: Array<{
|
|
114
|
+
position: number;
|
|
115
|
+
attribute_value: {
|
|
116
|
+
id: string;
|
|
117
|
+
code: string;
|
|
118
|
+
metadata: unknown;
|
|
119
|
+
};
|
|
120
|
+
}>;
|
|
121
|
+
}>;
|
|
122
|
+
}>;
|
|
123
|
+
}
|
|
124
|
+
export interface CatalogProductContent {
|
|
125
|
+
id: string;
|
|
126
|
+
name: string;
|
|
127
|
+
sku: string | null;
|
|
128
|
+
description: string | null;
|
|
129
|
+
long_description: unknown;
|
|
130
|
+
seo_title: string | null;
|
|
131
|
+
seo_description: string | null;
|
|
132
|
+
updated_at: string | null;
|
|
133
|
+
}
|
|
134
|
+
export interface CatalogProductPage {
|
|
135
|
+
items: CatalogProductContent[];
|
|
136
|
+
hasMore: boolean;
|
|
137
|
+
nextOffset: number | null;
|
|
138
|
+
}
|
|
139
|
+
export interface CatalogManagementConfig {
|
|
140
|
+
apiUrl: string;
|
|
141
|
+
accessToken: string | (() => string | Promise<string>);
|
|
142
|
+
fetch?: typeof fetch;
|
|
143
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// libs/sdk/src/catalog-management.ts
|
|
21
|
+
var catalog_management_exports = {};
|
|
22
|
+
__export(catalog_management_exports, {
|
|
23
|
+
CatalogManagementError: () => CatalogManagementError,
|
|
24
|
+
createCatalogManagementClient: () => createCatalogManagementClient
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(catalog_management_exports);
|
|
27
|
+
var CatalogManagementError = class extends Error {
|
|
28
|
+
constructor(code, status, message, details) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.status = status;
|
|
32
|
+
this.details = details;
|
|
33
|
+
this.name = "CatalogManagementError";
|
|
34
|
+
}
|
|
35
|
+
code;
|
|
36
|
+
status;
|
|
37
|
+
details;
|
|
38
|
+
};
|
|
39
|
+
function createCatalogManagementClient(config) {
|
|
40
|
+
const base = config.apiUrl.trim().replace(/\/+$/, "");
|
|
41
|
+
const url = new URL(base);
|
|
42
|
+
if (url.username || url.password || url.search || url.hash || !(url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {
|
|
43
|
+
throw new CatalogManagementError(
|
|
44
|
+
"CATALOG_CONFIG_INVALID",
|
|
45
|
+
0,
|
|
46
|
+
"Usa HTTPS o localhost para el acceso temporal."
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const fetcher = config.fetch ?? globalThis.fetch;
|
|
50
|
+
async function request(path, input) {
|
|
51
|
+
const token = typeof config.accessToken === "function" ? await config.accessToken() : config.accessToken;
|
|
52
|
+
if (!token.trim())
|
|
53
|
+
throw new CatalogManagementError(
|
|
54
|
+
"CATALOG_ACCESS_INVALID",
|
|
55
|
+
401,
|
|
56
|
+
"Falta el acceso temporal."
|
|
57
|
+
);
|
|
58
|
+
const response = await fetcher(`${base}/api/v1/catalog-management${path}`, {
|
|
59
|
+
method: input ? "POST" : "GET",
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: `Bearer ${token.trim()}`,
|
|
62
|
+
Accept: "application/json",
|
|
63
|
+
...input ? {
|
|
64
|
+
"Content-Type": input.bytes ? "application/octet-stream" : "application/json"
|
|
65
|
+
} : {}
|
|
66
|
+
},
|
|
67
|
+
...input ? { body: input.bytes ?? JSON.stringify(input.json) } : {},
|
|
68
|
+
cache: "no-store",
|
|
69
|
+
redirect: "error",
|
|
70
|
+
credentials: "omit"
|
|
71
|
+
});
|
|
72
|
+
const payload = await response.json().catch(() => ({}));
|
|
73
|
+
if (!response.ok || payload.success !== true || payload.data === void 0) {
|
|
74
|
+
throw new CatalogManagementError(
|
|
75
|
+
payload.error?.code ?? "CATALOG_REQUEST_FAILED",
|
|
76
|
+
response.status,
|
|
77
|
+
payload.error?.message ?? payload.message ?? "No fue posible consultar el cat\xE1logo.",
|
|
78
|
+
payload.error?.details
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return payload.data;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
createBatch: (input) => request("/batches", { json: input }),
|
|
85
|
+
getBatch: (batchId, input = {}) => {
|
|
86
|
+
const query = new URLSearchParams();
|
|
87
|
+
if (input.limit !== void 0) query.set("limit", String(input.limit));
|
|
88
|
+
if (input.after !== void 0) query.set("after", input.after);
|
|
89
|
+
return request(
|
|
90
|
+
`/batches/${encodeURIComponent(batchId)}${query.size ? `?${query}` : ""}`
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
getDraft: (batchId, itemId) => request(
|
|
94
|
+
`/batches/${encodeURIComponent(batchId)}/items/${encodeURIComponent(itemId)}`
|
|
95
|
+
),
|
|
96
|
+
sendProposals: (batchId, items) => request(
|
|
97
|
+
`/batches/${encodeURIComponent(batchId)}/items`,
|
|
98
|
+
{ json: { items } }
|
|
99
|
+
),
|
|
100
|
+
uploadImage: (input) => {
|
|
101
|
+
const query = new URLSearchParams({
|
|
102
|
+
source_key: input.source_key,
|
|
103
|
+
expected_revision: String(input.expected_revision),
|
|
104
|
+
request_id: input.request_id
|
|
105
|
+
});
|
|
106
|
+
return request(
|
|
107
|
+
`/batches/${encodeURIComponent(input.batchId)}/items/${encodeURIComponent(input.itemId)}/images?${query}`,
|
|
108
|
+
{ bytes: input.bytes }
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
getContext: () => request("/context"),
|
|
112
|
+
getReferences: () => request("/references"),
|
|
113
|
+
getTaxonomy: (category) => request(
|
|
114
|
+
`/references/taxonomy?category=${encodeURIComponent(category)}`
|
|
115
|
+
),
|
|
116
|
+
listProducts: (input = {}) => {
|
|
117
|
+
const query = new URLSearchParams();
|
|
118
|
+
if (input.limit !== void 0) query.set("limit", String(input.limit));
|
|
119
|
+
if (input.offset !== void 0) query.set("offset", String(input.offset));
|
|
120
|
+
return request(
|
|
121
|
+
`/products${query.size ? `?${query}` : ""}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CatalogManagementConfig, CatalogManagementContext, CatalogProductPage, CatalogReferences, CatalogTaxonomy } from "./catalog-management-types";
|
|
2
|
+
export * from "./catalog-draft-types";
|
|
3
|
+
export * from "./catalog-management-types";
|
|
4
|
+
import type { CatalogDraftBatch, CatalogDraftBatchPage, CatalogDraftChunkResult, CatalogDraftImageResult, CatalogDraftResult, CatalogDraftWrite } from "./catalog-draft-types";
|
|
5
|
+
export declare class CatalogManagementError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly details?: unknown | undefined;
|
|
9
|
+
constructor(code: string, status: number, message: string, details?: unknown | undefined);
|
|
10
|
+
}
|
|
11
|
+
export declare function createCatalogManagementClient(config: CatalogManagementConfig): {
|
|
12
|
+
createBatch: (input: {
|
|
13
|
+
request_id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}) => Promise<CatalogDraftBatch>;
|
|
16
|
+
getBatch: (batchId: string, input?: {
|
|
17
|
+
limit?: number;
|
|
18
|
+
after?: string;
|
|
19
|
+
}) => Promise<CatalogDraftBatchPage>;
|
|
20
|
+
getDraft: (batchId: string, itemId: string) => Promise<CatalogDraftResult>;
|
|
21
|
+
sendProposals: (batchId: string, items: CatalogDraftWrite[]) => Promise<CatalogDraftChunkResult>;
|
|
22
|
+
uploadImage: (input: {
|
|
23
|
+
batchId: string;
|
|
24
|
+
itemId: string;
|
|
25
|
+
source_key: string;
|
|
26
|
+
expected_revision: number;
|
|
27
|
+
request_id: string;
|
|
28
|
+
bytes: Blob;
|
|
29
|
+
}) => Promise<CatalogDraftImageResult>;
|
|
30
|
+
getContext: () => Promise<CatalogManagementContext>;
|
|
31
|
+
getReferences: () => Promise<CatalogReferences>;
|
|
32
|
+
getTaxonomy: (category: string) => Promise<CatalogTaxonomy>;
|
|
33
|
+
listProducts: (input?: {
|
|
34
|
+
limit?: number;
|
|
35
|
+
offset?: number;
|
|
36
|
+
}) => Promise<CatalogProductPage>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// libs/sdk/src/catalog-management.ts
|
|
2
|
+
var CatalogManagementError = class extends Error {
|
|
3
|
+
constructor(code, status, message, details) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = "CatalogManagementError";
|
|
9
|
+
}
|
|
10
|
+
code;
|
|
11
|
+
status;
|
|
12
|
+
details;
|
|
13
|
+
};
|
|
14
|
+
function createCatalogManagementClient(config) {
|
|
15
|
+
const base = config.apiUrl.trim().replace(/\/+$/, "");
|
|
16
|
+
const url = new URL(base);
|
|
17
|
+
if (url.username || url.password || url.search || url.hash || !(url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))) {
|
|
18
|
+
throw new CatalogManagementError(
|
|
19
|
+
"CATALOG_CONFIG_INVALID",
|
|
20
|
+
0,
|
|
21
|
+
"Usa HTTPS o localhost para el acceso temporal."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const fetcher = config.fetch ?? globalThis.fetch;
|
|
25
|
+
async function request(path, input) {
|
|
26
|
+
const token = typeof config.accessToken === "function" ? await config.accessToken() : config.accessToken;
|
|
27
|
+
if (!token.trim())
|
|
28
|
+
throw new CatalogManagementError(
|
|
29
|
+
"CATALOG_ACCESS_INVALID",
|
|
30
|
+
401,
|
|
31
|
+
"Falta el acceso temporal."
|
|
32
|
+
);
|
|
33
|
+
const response = await fetcher(`${base}/api/v1/catalog-management${path}`, {
|
|
34
|
+
method: input ? "POST" : "GET",
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${token.trim()}`,
|
|
37
|
+
Accept: "application/json",
|
|
38
|
+
...input ? {
|
|
39
|
+
"Content-Type": input.bytes ? "application/octet-stream" : "application/json"
|
|
40
|
+
} : {}
|
|
41
|
+
},
|
|
42
|
+
...input ? { body: input.bytes ?? JSON.stringify(input.json) } : {},
|
|
43
|
+
cache: "no-store",
|
|
44
|
+
redirect: "error",
|
|
45
|
+
credentials: "omit"
|
|
46
|
+
});
|
|
47
|
+
const payload = await response.json().catch(() => ({}));
|
|
48
|
+
if (!response.ok || payload.success !== true || payload.data === void 0) {
|
|
49
|
+
throw new CatalogManagementError(
|
|
50
|
+
payload.error?.code ?? "CATALOG_REQUEST_FAILED",
|
|
51
|
+
response.status,
|
|
52
|
+
payload.error?.message ?? payload.message ?? "No fue posible consultar el cat\xE1logo.",
|
|
53
|
+
payload.error?.details
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return payload.data;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
createBatch: (input) => request("/batches", { json: input }),
|
|
60
|
+
getBatch: (batchId, input = {}) => {
|
|
61
|
+
const query = new URLSearchParams();
|
|
62
|
+
if (input.limit !== void 0) query.set("limit", String(input.limit));
|
|
63
|
+
if (input.after !== void 0) query.set("after", input.after);
|
|
64
|
+
return request(
|
|
65
|
+
`/batches/${encodeURIComponent(batchId)}${query.size ? `?${query}` : ""}`
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
getDraft: (batchId, itemId) => request(
|
|
69
|
+
`/batches/${encodeURIComponent(batchId)}/items/${encodeURIComponent(itemId)}`
|
|
70
|
+
),
|
|
71
|
+
sendProposals: (batchId, items) => request(
|
|
72
|
+
`/batches/${encodeURIComponent(batchId)}/items`,
|
|
73
|
+
{ json: { items } }
|
|
74
|
+
),
|
|
75
|
+
uploadImage: (input) => {
|
|
76
|
+
const query = new URLSearchParams({
|
|
77
|
+
source_key: input.source_key,
|
|
78
|
+
expected_revision: String(input.expected_revision),
|
|
79
|
+
request_id: input.request_id
|
|
80
|
+
});
|
|
81
|
+
return request(
|
|
82
|
+
`/batches/${encodeURIComponent(input.batchId)}/items/${encodeURIComponent(input.itemId)}/images?${query}`,
|
|
83
|
+
{ bytes: input.bytes }
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
getContext: () => request("/context"),
|
|
87
|
+
getReferences: () => request("/references"),
|
|
88
|
+
getTaxonomy: (category) => request(
|
|
89
|
+
`/references/taxonomy?category=${encodeURIComponent(category)}`
|
|
90
|
+
),
|
|
91
|
+
listProducts: (input = {}) => {
|
|
92
|
+
const query = new URLSearchParams();
|
|
93
|
+
if (input.limit !== void 0) query.set("limit", String(input.limit));
|
|
94
|
+
if (input.offset !== void 0) query.set("offset", String(input.offset));
|
|
95
|
+
return request(
|
|
96
|
+
`/products${query.size ? `?${query}` : ""}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
CatalogManagementError,
|
|
103
|
+
createCatalogManagementClient
|
|
104
|
+
};
|
|
@@ -3,7 +3,7 @@ export type ContentManagementTypeKind = "entry" | "component";
|
|
|
3
3
|
export type ContentManagementTypeStatus = "draft" | "active" | "archived";
|
|
4
4
|
export type ContentManagementTypeUsage = "website_content" | "product_additional" | "product_specification";
|
|
5
5
|
export type ContentManagementScope = "content_types:manage" | "content_entries:manage" | "content_media:upload" | "content_entries:publish" | "forms:manage" | "forms:publish" | "product_content:manage";
|
|
6
|
-
export type ContentManagementFieldType = "boolean" | "component" | "date" | "link" | "measure" | "media" | "number" | "reference" | "repeater" | "rich_text" | "rich_text_full" | "select" | "slug" | "text" | "textarea";
|
|
6
|
+
export type ContentManagementFieldType = "icon" | "boolean" | "component" | "date" | "link" | "measure" | "media" | "number" | "reference" | "repeater" | "rich_text" | "rich_text_full" | "select" | "slug" | "text" | "textarea";
|
|
7
7
|
export interface ContentManagementChildFieldInput {
|
|
8
8
|
id?: string | null;
|
|
9
9
|
key: string;
|
|
@@ -182,6 +182,14 @@ export interface ContentManagementImageUploadResult extends ContentManagementMed
|
|
|
182
182
|
reused: boolean;
|
|
183
183
|
}
|
|
184
184
|
export interface ContentManagementReferences {
|
|
185
|
+
icons: Array<{
|
|
186
|
+
id: string;
|
|
187
|
+
concept: string;
|
|
188
|
+
label: string;
|
|
189
|
+
category: string;
|
|
190
|
+
keywords: string[];
|
|
191
|
+
provenance: "original-bacano" | "official-brand";
|
|
192
|
+
}>;
|
|
185
193
|
categories: Array<{
|
|
186
194
|
code: string;
|
|
187
195
|
name: string;
|