pim-import 2.82.3 → 3.1.1
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/dist/algolia/families.js +6 -0
- package/dist/algolia/families.js.map +1 -1
- package/dist/algolia/models.js +6 -0
- package/dist/algolia/models.js.map +1 -1
- package/dist/algolia/products.js +6 -0
- package/dist/algolia/products.js.map +1 -1
- package/dist/algolia/subFamilies.js +6 -0
- package/dist/algolia/subFamilies.js.map +1 -1
- package/dist/algolia/subModels.js +6 -0
- package/dist/algolia/subModels.js.map +1 -1
- package/dist/browser.js +2 -4
- package/dist/browser.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/libs/logs.js +6 -1
- package/dist/libs/logs.js.map +1 -1
- package/dist/pim/endpoints.js +4 -3
- package/dist/pim/endpoints.js.map +1 -1
- package/dist/pim/methods/catalogs.js +9 -0
- package/dist/pim/methods/catalogs.js.map +1 -1
- package/dist/pim/methods/dictionary.js +25 -0
- package/dist/pim/methods/dictionary.js.map +1 -1
- package/dist/pim/methods/families.js +9 -0
- package/dist/pim/methods/families.js.map +1 -1
- package/dist/pim/methods/latestProducts.js +28 -36
- package/dist/pim/methods/latestProducts.js.map +1 -1
- package/dist/pim/methods/models.js +6 -0
- package/dist/pim/methods/models.js.map +1 -1
- package/dist/pim/methods/products.js +36 -1
- package/dist/pim/methods/products.js.map +1 -1
- package/dist/pim/methods/subfamilies.js +6 -0
- package/dist/pim/methods/subfamilies.js.map +1 -1
- package/dist/pim/methods/submodels.js +6 -0
- package/dist/pim/methods/submodels.js.map +1 -1
- package/package.json +1 -1
- package/src/algolia/families.ts +7 -1
- package/src/algolia/models.ts +7 -1
- package/src/algolia/products.ts +7 -1
- package/src/algolia/subFamilies.ts +7 -1
- package/src/algolia/subModels.ts +7 -1
- package/src/browser.ts +0 -1
- package/src/index.ts +2 -2
- package/src/libs/logs.ts +6 -0
- package/src/pim/endpoints.ts +7 -4
- package/src/pim/methods/catalogs.ts +12 -1
- package/src/pim/methods/dictionary.ts +33 -1
- package/src/pim/methods/families.ts +11 -1
- package/src/pim/methods/latestProducts.ts +44 -53
- package/src/pim/methods/models.ts +10 -1
- package/src/pim/methods/products.ts +44 -2
- package/src/pim/methods/subfamilies.ts +10 -1
- package/src/pim/methods/submodels.ts +10 -1
- package/types/browser.d.ts +0 -1
- package/types/fonts.d.ts +2 -0
- package/types/index.d.ts +2 -3
- package/types/libs/logs.d.ts +2 -0
- package/types/pim/endpoints.d.ts +1 -1
- package/types/pim/methods/latestProducts.d.ts +2 -12
- package/dist/pim/methods/dailyProductsUpdate.js +0 -51
- package/dist/pim/methods/dailyProductsUpdate.js.map +0 -1
- package/src/pim/methods/dailyProductsUpdate.ts +0 -73
- package/types/pim/methods/dailyProductsUpdate.d.ts +0 -2
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { AvailableCatalogs, PaginationResults } from "../../types";
|
|
2
|
-
import { getStaticDailyProducts } from "../endpoints";
|
|
3
|
-
import { log } from "../../libs/logs";
|
|
4
|
-
import { getFileFromS3 } from "../../libs/s3";
|
|
5
|
-
import { ProductDetails } from "../../resources/ProductDetails";
|
|
6
|
-
import { importProduct } from "./products";
|
|
7
|
-
import { secondBetweenTwoDate } from "../../utils";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Daily products update
|
|
11
|
-
*
|
|
12
|
-
* @param {string} catalogCode The catalog code. Format: ARCHITECTURAL
|
|
13
|
-
* @param {string} day The last modified data. Format: 20200426 - yearmonthday
|
|
14
|
-
* @param {number} offset Default 0
|
|
15
|
-
* @param {number} limit Default 50
|
|
16
|
-
* @param {string} s3FilePath Default 50
|
|
17
|
-
*/
|
|
18
|
-
export const dailyProductsUpdate = async (
|
|
19
|
-
catalog: AvailableCatalogs,
|
|
20
|
-
day: string,
|
|
21
|
-
offset: number = 0,
|
|
22
|
-
limit: number = 50,
|
|
23
|
-
s3FilePath: string = ""
|
|
24
|
-
): Promise<PaginationResults> => {
|
|
25
|
-
const timeStart = new Date();
|
|
26
|
-
offset = Number(offset);
|
|
27
|
-
limit = Number(limit);
|
|
28
|
-
log(
|
|
29
|
-
`dailyProductsUpdate - catalog: ${catalog} day: ${day} offset: ${offset} limit: ${limit} s3FilePath: ${s3FilePath}`,
|
|
30
|
-
"INFO"
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
if (!s3FilePath) {
|
|
34
|
-
const s3Path = await getStaticDailyProducts(catalog, day, true);
|
|
35
|
-
return {
|
|
36
|
-
offset,
|
|
37
|
-
limit,
|
|
38
|
-
completed: !s3Path,
|
|
39
|
-
s3FilePath: s3Path,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const JSONData = await getFileFromS3(s3FilePath);
|
|
44
|
-
const total: number = JSONData.length;
|
|
45
|
-
|
|
46
|
-
log(`${total} products founded`);
|
|
47
|
-
|
|
48
|
-
let count: number = 0;
|
|
49
|
-
let updated: number = 0;
|
|
50
|
-
for (const product of JSONData) {
|
|
51
|
-
const productDetails: ProductDetails = product.content;
|
|
52
|
-
if (offset <= count || limit === -1) {
|
|
53
|
-
await importProduct(productDetails, catalog);
|
|
54
|
-
updated++;
|
|
55
|
-
if (limit !== -1 && count + 1 - offset >= limit) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
count++;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const timeEnd = new Date();
|
|
63
|
-
const seconds = secondBetweenTwoDate(timeStart, timeEnd);
|
|
64
|
-
log(`Request time: ${seconds} seconds`);
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
offset: offset + limit,
|
|
68
|
-
limit,
|
|
69
|
-
completed: limit === -1 || limit > updated,
|
|
70
|
-
s3FilePath,
|
|
71
|
-
total: JSONData.length,
|
|
72
|
-
};
|
|
73
|
-
};
|