contentful-import 9.4.63 → 9.4.65
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/index.js +46 -3
- package/dist/index.mjs +46 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -70,7 +70,8 @@ var METHODS = {
|
|
|
70
70
|
contentTypes: { name: "content types", method: "getContentTypes" },
|
|
71
71
|
locales: { name: "locales", method: "getLocales" },
|
|
72
72
|
entries: { name: "entries", method: "getEntries" },
|
|
73
|
-
assets: { name: "assets", method: "getAssets" }
|
|
73
|
+
assets: { name: "assets", method: "getAssets" },
|
|
74
|
+
tags: { name: "tags", method: "getTags" }
|
|
74
75
|
};
|
|
75
76
|
async function batchedIdQuery({ environment, type, ids, requestQueue }) {
|
|
76
77
|
const method = METHODS[type].method;
|
|
@@ -91,6 +92,34 @@ async function batchedIdQuery({ environment, type, ids, requestQueue }) {
|
|
|
91
92
|
const responses = await import_bluebird.default.all(allPendingResponses);
|
|
92
93
|
return responses.flat();
|
|
93
94
|
}
|
|
95
|
+
async function batchedPageQuery({ environment, type, requestQueue }) {
|
|
96
|
+
const method = METHODS[type].method;
|
|
97
|
+
const entityTypeName = METHODS[type].name;
|
|
98
|
+
let totalFetched = 0;
|
|
99
|
+
const { items, total } = await requestQueue.add(async () => {
|
|
100
|
+
const response = await environment[method]({
|
|
101
|
+
skip: 0,
|
|
102
|
+
limit: BATCH_SIZE_LIMIT
|
|
103
|
+
});
|
|
104
|
+
totalFetched += response.items.length;
|
|
105
|
+
import_logging2.logEmitter.emit("info", `Fetched ${totalFetched} of ${response.total} ${entityTypeName}`);
|
|
106
|
+
return { items: response.items, total: response.total };
|
|
107
|
+
});
|
|
108
|
+
const batches = getPagedBatches(totalFetched, total);
|
|
109
|
+
const remainingTotalResponses = batches.map(({ skip }) => {
|
|
110
|
+
return requestQueue.add(async () => {
|
|
111
|
+
const response = await environment[method]({
|
|
112
|
+
skip,
|
|
113
|
+
limit: BATCH_SIZE_LIMIT
|
|
114
|
+
});
|
|
115
|
+
totalFetched = totalFetched + response.items.length;
|
|
116
|
+
import_logging2.logEmitter.emit("info", `Fetched ${totalFetched} of ${response.total} ${entityTypeName}`);
|
|
117
|
+
return response.items;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
const remainingResponses = await import_bluebird.default.all(remainingTotalResponses);
|
|
121
|
+
return items.concat(remainingResponses.flat());
|
|
122
|
+
}
|
|
94
123
|
function getIdBatches(ids) {
|
|
95
124
|
const batches = [];
|
|
96
125
|
let currentBatch = "";
|
|
@@ -109,6 +138,18 @@ function getIdBatches(ids) {
|
|
|
109
138
|
}
|
|
110
139
|
return batches;
|
|
111
140
|
}
|
|
141
|
+
function getPagedBatches(totalFetched, total) {
|
|
142
|
+
const batches = [];
|
|
143
|
+
if (totalFetched >= total) {
|
|
144
|
+
return batches;
|
|
145
|
+
}
|
|
146
|
+
let skip = totalFetched;
|
|
147
|
+
while (skip < total) {
|
|
148
|
+
batches.push({ skip });
|
|
149
|
+
skip += BATCH_SIZE_LIMIT;
|
|
150
|
+
}
|
|
151
|
+
return batches;
|
|
152
|
+
}
|
|
112
153
|
async function getDestinationData({
|
|
113
154
|
client,
|
|
114
155
|
spaceId,
|
|
@@ -154,9 +195,11 @@ async function getDestinationData({
|
|
|
154
195
|
}
|
|
155
196
|
}
|
|
156
197
|
}
|
|
157
|
-
|
|
198
|
+
try {
|
|
199
|
+
result.tags = await batchedPageQuery({ environment, type: "tags", requestQueue });
|
|
200
|
+
} catch (_) {
|
|
158
201
|
delete result.tags;
|
|
159
|
-
}
|
|
202
|
+
}
|
|
160
203
|
if (contentModelOnly) {
|
|
161
204
|
return import_bluebird.default.props(result);
|
|
162
205
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,8 @@ var METHODS = {
|
|
|
43
43
|
contentTypes: { name: "content types", method: "getContentTypes" },
|
|
44
44
|
locales: { name: "locales", method: "getLocales" },
|
|
45
45
|
entries: { name: "entries", method: "getEntries" },
|
|
46
|
-
assets: { name: "assets", method: "getAssets" }
|
|
46
|
+
assets: { name: "assets", method: "getAssets" },
|
|
47
|
+
tags: { name: "tags", method: "getTags" }
|
|
47
48
|
};
|
|
48
49
|
async function batchedIdQuery({ environment, type, ids, requestQueue }) {
|
|
49
50
|
const method = METHODS[type].method;
|
|
@@ -64,6 +65,34 @@ async function batchedIdQuery({ environment, type, ids, requestQueue }) {
|
|
|
64
65
|
const responses = await Promise2.all(allPendingResponses);
|
|
65
66
|
return responses.flat();
|
|
66
67
|
}
|
|
68
|
+
async function batchedPageQuery({ environment, type, requestQueue }) {
|
|
69
|
+
const method = METHODS[type].method;
|
|
70
|
+
const entityTypeName = METHODS[type].name;
|
|
71
|
+
let totalFetched = 0;
|
|
72
|
+
const { items, total } = await requestQueue.add(async () => {
|
|
73
|
+
const response = await environment[method]({
|
|
74
|
+
skip: 0,
|
|
75
|
+
limit: BATCH_SIZE_LIMIT
|
|
76
|
+
});
|
|
77
|
+
totalFetched += response.items.length;
|
|
78
|
+
logEmitter2.emit("info", `Fetched ${totalFetched} of ${response.total} ${entityTypeName}`);
|
|
79
|
+
return { items: response.items, total: response.total };
|
|
80
|
+
});
|
|
81
|
+
const batches = getPagedBatches(totalFetched, total);
|
|
82
|
+
const remainingTotalResponses = batches.map(({ skip }) => {
|
|
83
|
+
return requestQueue.add(async () => {
|
|
84
|
+
const response = await environment[method]({
|
|
85
|
+
skip,
|
|
86
|
+
limit: BATCH_SIZE_LIMIT
|
|
87
|
+
});
|
|
88
|
+
totalFetched = totalFetched + response.items.length;
|
|
89
|
+
logEmitter2.emit("info", `Fetched ${totalFetched} of ${response.total} ${entityTypeName}`);
|
|
90
|
+
return response.items;
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
const remainingResponses = await Promise2.all(remainingTotalResponses);
|
|
94
|
+
return items.concat(remainingResponses.flat());
|
|
95
|
+
}
|
|
67
96
|
function getIdBatches(ids) {
|
|
68
97
|
const batches = [];
|
|
69
98
|
let currentBatch = "";
|
|
@@ -82,6 +111,18 @@ function getIdBatches(ids) {
|
|
|
82
111
|
}
|
|
83
112
|
return batches;
|
|
84
113
|
}
|
|
114
|
+
function getPagedBatches(totalFetched, total) {
|
|
115
|
+
const batches = [];
|
|
116
|
+
if (totalFetched >= total) {
|
|
117
|
+
return batches;
|
|
118
|
+
}
|
|
119
|
+
let skip = totalFetched;
|
|
120
|
+
while (skip < total) {
|
|
121
|
+
batches.push({ skip });
|
|
122
|
+
skip += BATCH_SIZE_LIMIT;
|
|
123
|
+
}
|
|
124
|
+
return batches;
|
|
125
|
+
}
|
|
85
126
|
async function getDestinationData({
|
|
86
127
|
client,
|
|
87
128
|
spaceId,
|
|
@@ -127,9 +168,11 @@ async function getDestinationData({
|
|
|
127
168
|
}
|
|
128
169
|
}
|
|
129
170
|
}
|
|
130
|
-
|
|
171
|
+
try {
|
|
172
|
+
result.tags = await batchedPageQuery({ environment, type: "tags", requestQueue });
|
|
173
|
+
} catch (_) {
|
|
131
174
|
delete result.tags;
|
|
132
|
-
}
|
|
175
|
+
}
|
|
133
176
|
if (contentModelOnly) {
|
|
134
177
|
return Promise2.props(result);
|
|
135
178
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-import",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.65",
|
|
4
4
|
"description": "this tool allows you to import JSON dump exported by contentful-export",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"bluebird": "^3.7.2",
|
|
65
65
|
"cli-table3": "^0.6.5",
|
|
66
66
|
"contentful-batch-libs": "^9.6.0",
|
|
67
|
-
"contentful-management": "^11.
|
|
67
|
+
"contentful-management": "^11.36.0",
|
|
68
68
|
"date-fns": "^2.30.0",
|
|
69
69
|
"eslint": "^8.57.1",
|
|
70
70
|
"eslint-config-standard": "^17.1.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/jest": "^29.5.14",
|
|
81
|
-
"@types/lodash": "^4.17.
|
|
81
|
+
"@types/lodash": "^4.17.13",
|
|
82
82
|
"@types/node": "^20.6.3",
|
|
83
83
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
84
84
|
"@typescript-eslint/parser": "^6.21.0",
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
"eslint-plugin-standard": "^5.0.0",
|
|
94
94
|
"jest": "^29.7.0",
|
|
95
95
|
"rimraf": "^5.0.7",
|
|
96
|
-
"semantic-release": "^24.
|
|
96
|
+
"semantic-release": "^24.2.0",
|
|
97
97
|
"ts-jest": "^29.1.3",
|
|
98
|
-
"tsup": "^8.3.
|
|
98
|
+
"tsup": "^8.3.5",
|
|
99
99
|
"typescript": "^5.6.3"
|
|
100
100
|
},
|
|
101
101
|
"files": [
|