feed-common 1.10.5 → 1.10.6
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/.prettierrc +10 -0
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +7 -0
- package/dist/types/profile.types.d.ts +6 -6
- package/dist/utils/profile.d.ts +18 -2
- package/dist/utils/profile.d.ts.map +1 -1
- package/dist/utils/profile.js +55 -45
- package/dist/utils/profile.js.map +1 -1
- package/package.json +11 -4
- package/src/types/profile.types.ts +6 -6
- package/src/utils/profile.ts +258 -288
- package/tests/company.spec.ts +49 -0
- package/tests/profile.spec.ts +1458 -0
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.10.6](https://github.com/advertikon/package-maxify-feed-common/compare/v1.10.5...v1.10.6) (2024-05-26)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add tests ([cf05aad](https://github.com/advertikon/package-maxify-feed-common/commit/cf05aad1a48e7b5a93845475ff9d77c8b6139a98))
|
7
|
+
|
1
8
|
## [1.10.5](https://github.com/advertikon/package-maxify-feed-common/compare/v1.10.4...v1.10.5) (2024-05-21)
|
2
9
|
|
3
10
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ProductUploadRuleFilters, ProductUploadMappings, RuleOperators } from
|
1
|
+
import { ProductUploadRuleFilters, ProductUploadMappings, RuleOperators } from '../constants/profile.constants.js';
|
2
2
|
export type SelectItem = {
|
3
3
|
label: string;
|
4
4
|
value: string;
|
@@ -26,9 +26,9 @@ export type ProductUploadMapSource = {
|
|
26
26
|
required: boolean;
|
27
27
|
label: string;
|
28
28
|
attribute: string;
|
29
|
-
type:
|
29
|
+
type: 'select' | 'multiselect' | 'text' | 'number';
|
30
30
|
choices?: OptionType[];
|
31
|
-
rules: ProductUploadRuleFilterType[
|
31
|
+
rules: ProductUploadRuleFilterType['value'][];
|
32
32
|
description?: string;
|
33
33
|
defaultValue?: ValueType;
|
34
34
|
};
|
@@ -38,15 +38,15 @@ export type ProductUploadMapping = {
|
|
38
38
|
rules: {
|
39
39
|
sections: {
|
40
40
|
ruleItems: {
|
41
|
-
attribute: (typeof ProductUploadRuleFilters)[number][
|
42
|
-
operator: ProductUploadRuleOperatorType[
|
41
|
+
attribute: (typeof ProductUploadRuleFilters)[number]['value'];
|
42
|
+
operator: ProductUploadRuleOperatorType['value'];
|
43
43
|
value: string | string[] | number[] | number | boolean;
|
44
44
|
id: string;
|
45
45
|
}[];
|
46
46
|
}[];
|
47
47
|
};
|
48
48
|
};
|
49
|
-
type MappingFields = (typeof ProductUploadMappings)[number][
|
49
|
+
type MappingFields = (typeof ProductUploadMappings)[number]['attribute'];
|
50
50
|
export type ProductUploadProfile = {
|
51
51
|
id: string;
|
52
52
|
profileIdTemplate: string;
|
package/dist/utils/profile.d.ts
CHANGED
@@ -1,7 +1,23 @@
|
|
1
|
-
import { OptionType, OptionTypeItem, OptionTypeGroup, ProductUploadProfile, ProductUploadMapping, ProductUploadRuleFilterType, ProductUploadRuleItem, ProductUploadRuleSection, ProductUploadRules } from '../types/profile.types.js';
|
1
|
+
import { OptionType, OptionTypeItem, OptionTypeGroup, ProductUploadProfile, ProductUploadMapping, ProductUploadRuleFilterType, RuleOperatorsType, ProductUploadRuleItem, ProductUploadRuleSection, ProductUploadRules } from '../types/profile.types.js';
|
2
|
+
/**
|
3
|
+
* Check for rules duplication
|
4
|
+
* @param rules
|
5
|
+
* @returns
|
6
|
+
*/
|
2
7
|
export declare function checkRuleDuplication(rules: ProductUploadRuleItem[]): string[];
|
8
|
+
/**
|
9
|
+
* Check if rules mutually exclusive
|
10
|
+
* @param rules
|
11
|
+
* @returns
|
12
|
+
*/
|
3
13
|
export declare function checkRuleAlwaysness(rules: ProductUploadRuleItem[]): string[];
|
4
|
-
|
14
|
+
/**
|
15
|
+
* Checks for contradictions in rules, e.g A == 1 and A != 1
|
16
|
+
* @param sections
|
17
|
+
* @returns
|
18
|
+
*/
|
19
|
+
export declare function checkRuleDeadlocks(input: ProductUploadRuleSection[]): string[];
|
20
|
+
export declare function getOperatorCounterpart(operator: keyof RuleOperatorsType): keyof RuleOperatorsType;
|
5
21
|
export declare function getEmptyRuleItem(attribute?: ProductUploadRuleFilterType['value']): ProductUploadRuleItem;
|
6
22
|
export declare function sortMappings(a: ProductUploadMapping, b: ProductUploadMapping): number;
|
7
23
|
export declare function hasRules(rules: ProductUploadRules): boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AACA,OAAO,EACH,UAAU,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EACrB,MAAM,2BAA2B,CAAC;AAInC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,MAAM,EAAE,CAgB7E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,MAAM,EAAE,CAW5E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,wBAAwB,EAAE,GAAG,MAAM,EAAE,CAwB9E;AAWD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAiCjG;AAED,wBAAgB,gBAAgB,CAAC,SAAS,GAAE,2BAA2B,CAAC,OAAO,CAAM,GAAG,qBAAqB,CAE5G;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,oBAAoB,GAAG,MAAM,CA6BrF;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,CAAC,GAAE,kBAAqC,EACxC,CAAC,GAAE,kBAAqC,GACzC,OAAO,CAmCT;AAUD,wBAAgB,eAAe,CAAC,CAAC,EAAE,oBAAoB,EAAE,EAAE,CAAC,EAAE,oBAAoB,EAAE,GAAG,OAAO,CA6B7F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,MAAM,CAEnE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,cAAc,CAEzE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,eAAe,CAE3E;AAED,wBAAgB,mBAAmB,CAC/B,CAAC,EAAE,oBAAoB,EACvB,CAAC,EAAE,oBAAoB,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,CAkCnE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,oBAAoB,CAczF"}
|
package/dist/utils/profile.js
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
import { ProductUploadMappings } from '../constants/profile.constants.js';
|
2
2
|
import { code } from './utils.js';
|
3
|
+
/**
|
4
|
+
* Check for rules duplication
|
5
|
+
* @param rules
|
6
|
+
* @returns
|
7
|
+
*/
|
3
8
|
export function checkRuleDuplication(rules) {
|
4
9
|
return rules
|
5
|
-
.map(
|
10
|
+
.map(r => {
|
6
11
|
for (const rule of rules) {
|
7
12
|
if (r.id !== rule.id &&
|
8
13
|
r.attribute === rule.attribute &&
|
@@ -15,11 +20,16 @@ export function checkRuleDuplication(rules) {
|
|
15
20
|
})
|
16
21
|
.filter(Boolean);
|
17
22
|
}
|
23
|
+
/**
|
24
|
+
* Check if rules mutually exclusive
|
25
|
+
* @param rules
|
26
|
+
* @returns
|
27
|
+
*/
|
18
28
|
export function checkRuleAlwaysness(rules) {
|
19
29
|
return rules
|
20
|
-
.map(
|
30
|
+
.map(r => {
|
21
31
|
for (const rule of rules) {
|
22
|
-
if (
|
32
|
+
if (isExclusive(r, rule)) {
|
23
33
|
return r.id;
|
24
34
|
}
|
25
35
|
}
|
@@ -27,38 +37,40 @@ export function checkRuleAlwaysness(rules) {
|
|
27
37
|
})
|
28
38
|
.filter(Boolean);
|
29
39
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
40
|
+
/**
|
41
|
+
* Checks for contradictions in rules, e.g A == 1 and A != 1
|
42
|
+
* @param sections
|
43
|
+
* @returns
|
44
|
+
*/
|
45
|
+
export function checkRuleDeadlocks(input) {
|
46
|
+
const totalList = [];
|
47
|
+
const sections = structuredClone(input);
|
48
|
+
for (let i = 0; i < sections.length - 1; i++) {
|
33
49
|
const currentSection = sections[i];
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
for (let y = i + 1; y < sections.length; y++) {
|
51
|
+
from_start: for (let x = 0; x < currentSection.ruleItems.length; x++) {
|
52
|
+
const ruleA = currentSection.ruleItems[x];
|
53
|
+
for (let z = 0; z < sections[y].ruleItems.length; z++) {
|
54
|
+
const ruleB = sections[y].ruleItems[z];
|
55
|
+
if (isExclusive(ruleA, ruleB)) {
|
56
|
+
totalList.push([ruleA.id, ruleB.id]);
|
57
|
+
currentSection.ruleItems.splice(x, 1);
|
58
|
+
sections[y].ruleItems.splice(z, 1);
|
43
59
|
continue from_start;
|
44
60
|
}
|
45
61
|
}
|
46
62
|
}
|
47
63
|
}
|
48
|
-
if (currentList.length === currentSection.ruleItems.length) {
|
49
|
-
totalList = [...totalList, ...currentList];
|
50
|
-
}
|
51
64
|
}
|
52
|
-
return totalList;
|
65
|
+
return sections.some(s => s.ruleItems.length === 0) ? totalList.flat() : [];
|
53
66
|
}
|
54
|
-
function
|
67
|
+
function isExclusive(rule1, rule2) {
|
55
68
|
return (rule1.id !== rule2.id &&
|
56
69
|
rule1.attribute === rule2.attribute &&
|
57
|
-
rule1.operator ===
|
58
|
-
getOperatorCounterpart(rule2.operator) &&
|
70
|
+
rule1.operator === getOperatorCounterpart(rule2.operator) &&
|
59
71
|
rule1.value === rule2.value);
|
60
72
|
}
|
61
|
-
function getOperatorCounterpart(operator) {
|
73
|
+
export function getOperatorCounterpart(operator) {
|
62
74
|
switch (operator) {
|
63
75
|
case 'equals':
|
64
76
|
return 'notEquals';
|
@@ -102,8 +114,8 @@ export function sortMappings(a, b) {
|
|
102
114
|
if (!b.attribute) {
|
103
115
|
return -1;
|
104
116
|
}
|
105
|
-
const sourceA = ProductUploadMappings.find(
|
106
|
-
const sourceB = ProductUploadMappings.find(
|
117
|
+
const sourceA = ProductUploadMappings.find(m => m.attribute === a.attribute);
|
118
|
+
const sourceB = ProductUploadMappings.find(m => m.attribute === b.attribute);
|
107
119
|
if (sourceA?.required && !sourceB?.required) {
|
108
120
|
return -1;
|
109
121
|
}
|
@@ -119,8 +131,7 @@ export function sortMappings(a, b) {
|
|
119
131
|
return 0;
|
120
132
|
}
|
121
133
|
export function hasRules(rules) {
|
122
|
-
return
|
123
|
-
rules.sections.some((section) => section.ruleItems.length > 0));
|
134
|
+
return Array.isArray(rules?.sections) && rules.sections.some(section => section.ruleItems.length > 0);
|
124
135
|
}
|
125
136
|
/**
|
126
137
|
* Checks if two rules are the same
|
@@ -131,12 +142,10 @@ export function hasRules(rules) {
|
|
131
142
|
export function compareRules(a = { sections: [] }, b = { sections: [] }) {
|
132
143
|
const matchedSections = [];
|
133
144
|
const sameRule = (rA, rB) => {
|
134
|
-
return
|
135
|
-
rA.operator === rB.operator &&
|
136
|
-
compareValues(rA.value, rB.value));
|
145
|
+
return rA.attribute === rB.attribute && rA.operator === rB.operator && compareValues(rA.value, rB.value);
|
137
146
|
};
|
138
|
-
a.sections = a.sections.filter(
|
139
|
-
b.sections = b.sections.filter(
|
147
|
+
a.sections = a.sections.filter(s => s.ruleItems.length > 0);
|
148
|
+
b.sections = b.sections.filter(s => s.ruleItems.length > 0);
|
140
149
|
if (a.sections.length !== b.sections.length) {
|
141
150
|
return false;
|
142
151
|
}
|
@@ -150,7 +159,7 @@ export function compareRules(a = { sections: [] }, b = { sections: [] }) {
|
|
150
159
|
if (rulesA.length !== rulesB.length) {
|
151
160
|
continue;
|
152
161
|
}
|
153
|
-
if (rulesA.every(
|
162
|
+
if (rulesA.every(ruleA => rulesB.some(ruleB => sameRule(ruleA, ruleB)))) {
|
154
163
|
matchedSections.push(j);
|
155
164
|
break;
|
156
165
|
}
|
@@ -160,7 +169,7 @@ export function compareRules(a = { sections: [] }, b = { sections: [] }) {
|
|
160
169
|
}
|
161
170
|
function compareValues(a, b) {
|
162
171
|
if (Array.isArray(a) && Array.isArray(b)) {
|
163
|
-
return a.length === b.length && a.every(
|
172
|
+
return a.length === b.length && a.every(i => b.includes(i));
|
164
173
|
}
|
165
174
|
return a === b;
|
166
175
|
}
|
@@ -205,18 +214,19 @@ export function detectProfileChange(a, b) {
|
|
205
214
|
if (a.name !== b.name) {
|
206
215
|
changes.name = true;
|
207
216
|
}
|
208
|
-
if (
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
if (['targetCountry', 'contentLanguage'].some((key) => {
|
214
|
-
const mappingA = a.mappings?.filter((m) => m.attribute === key) ?? [];
|
215
|
-
const mappingB = b.mappings?.filter((m) => m.attribute === key) ?? [];
|
217
|
+
if (ProductUploadMappings.filter(m => m.required)
|
218
|
+
.map(m => m.attribute)
|
219
|
+
.some(key => {
|
220
|
+
const mappingA = a.mappings?.filter(m => m.attribute === key) ?? [];
|
221
|
+
const mappingB = b.mappings?.filter(m => m.attribute === key) ?? [];
|
216
222
|
return !compareMappings(mappingA, mappingB);
|
217
223
|
})) {
|
218
224
|
changes.id = true;
|
219
225
|
}
|
226
|
+
const requiredAttrs = ProductUploadMappings.filter(m => m.required).map(m => m.attribute);
|
227
|
+
const mappingsA = a.mappings?.filter(m => !requiredAttrs.includes(m.attribute));
|
228
|
+
const mappingsB = b.mappings?.filter(m => !requiredAttrs.includes(m.attribute));
|
229
|
+
changes.mappings = !compareMappings(mappingsA, mappingsB);
|
220
230
|
if (!compareRules(a.rules, b.rules)) {
|
221
231
|
changes.rules = true;
|
222
232
|
}
|
@@ -224,11 +234,11 @@ export function detectProfileChange(a, b) {
|
|
224
234
|
}
|
225
235
|
export function sanitizeUploadProfile(profile) {
|
226
236
|
if (profile.rules?.sections) {
|
227
|
-
profile.rules.sections = profile.rules.sections.filter(
|
237
|
+
profile.rules.sections = profile.rules.sections.filter(section => section.ruleItems.length > 0);
|
228
238
|
}
|
229
|
-
profile.mappings = profile.mappings?.map(
|
239
|
+
profile.mappings = profile.mappings?.map(mapping => {
|
230
240
|
if (mapping.rules?.sections) {
|
231
|
-
mapping.rules.sections = mapping.rules.sections.filter(
|
241
|
+
mapping.rules.sections = mapping.rules.sections.filter(section => section.ruleItems.length > 0);
|
232
242
|
}
|
233
243
|
return mapping;
|
234
244
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA8B;IAC/D,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,CAAC,EAAE;QACL,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IACI,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE;gBAChB,CAAC,CAAC,SAAS,KAA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G,CAAC;IAED,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE;QAC/C,IAAI,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "feed-common",
|
3
|
-
"version": "1.10.
|
3
|
+
"version": "1.10.6",
|
4
4
|
"description": "Maxify feed common library",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"type": "module",
|
7
7
|
"scripts": {
|
8
8
|
"build": "tsc",
|
9
|
-
"install-local": "scripts/install.sh"
|
9
|
+
"install-local": "scripts/install.sh",
|
10
|
+
"test": "vitest"
|
10
11
|
},
|
11
12
|
"devDependencies": {
|
12
13
|
"@semantic-release/changelog": "^6.0.1",
|
@@ -19,9 +20,12 @@
|
|
19
20
|
"@types/express": "^4.17.13",
|
20
21
|
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
21
22
|
"@typescript-eslint/parser": "^5.18.0",
|
23
|
+
"@vitest/coverage-istanbul": "^1.6.0",
|
22
24
|
"semantic-release": "^19.0.5",
|
23
25
|
"semantic-release-slack-bot": "^4.0.2",
|
24
|
-
"
|
26
|
+
"simple-git-hooks": "^2.11.1",
|
27
|
+
"typescript": "^5.3.3",
|
28
|
+
"vitest": "^1.6.0"
|
25
29
|
},
|
26
30
|
"peerDependencies": {
|
27
31
|
"@shopify/shopify-api": "^9.2.0"
|
@@ -35,5 +39,8 @@
|
|
35
39
|
"bugs": {
|
36
40
|
"url": "https://github.com/advertikon/package-maxify-feed-common/issues"
|
37
41
|
},
|
38
|
-
"homepage": "https://github.com/advertikon/package-maxify-feed-common#readme"
|
42
|
+
"homepage": "https://github.com/advertikon/package-maxify-feed-common#readme",
|
43
|
+
"simple-git-hooks": {
|
44
|
+
"pre-commit": "npm run test"
|
45
|
+
}
|
39
46
|
}
|
@@ -2,7 +2,7 @@ import {
|
|
2
2
|
ProductUploadRuleFilters,
|
3
3
|
ProductUploadMappings,
|
4
4
|
RuleOperators,
|
5
|
-
} from
|
5
|
+
} from '../constants/profile.constants.js';
|
6
6
|
|
7
7
|
export type SelectItem = { label: string; value: string };
|
8
8
|
|
@@ -25,9 +25,9 @@ export type ProductUploadMapSource = {
|
|
25
25
|
required: boolean;
|
26
26
|
label: string;
|
27
27
|
attribute: string;
|
28
|
-
type:
|
28
|
+
type: 'select' | 'multiselect' | 'text' | 'number';
|
29
29
|
choices?: OptionType[];
|
30
|
-
rules: ProductUploadRuleFilterType[
|
30
|
+
rules: ProductUploadRuleFilterType['value'][];
|
31
31
|
description?: string;
|
32
32
|
defaultValue?: ValueType;
|
33
33
|
};
|
@@ -38,8 +38,8 @@ export type ProductUploadMapping = {
|
|
38
38
|
rules: {
|
39
39
|
sections: {
|
40
40
|
ruleItems: {
|
41
|
-
attribute: (typeof ProductUploadRuleFilters)[number][
|
42
|
-
operator: ProductUploadRuleOperatorType[
|
41
|
+
attribute: (typeof ProductUploadRuleFilters)[number]['value'];
|
42
|
+
operator: ProductUploadRuleOperatorType['value'];
|
43
43
|
value: string | string[] | number[] | number | boolean;
|
44
44
|
id: string;
|
45
45
|
}[];
|
@@ -47,7 +47,7 @@ export type ProductUploadMapping = {
|
|
47
47
|
};
|
48
48
|
};
|
49
49
|
|
50
|
-
type MappingFields = (typeof ProductUploadMappings)[number][
|
50
|
+
type MappingFields = (typeof ProductUploadMappings)[number]['attribute'];
|
51
51
|
|
52
52
|
export type ProductUploadProfile = {
|
53
53
|
id: string;
|