@contentstorage/core 1.1.0 → 1.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.
|
@@ -30,7 +30,11 @@ export async function fetchContent(language, options = {}) {
|
|
|
30
30
|
try {
|
|
31
31
|
// Fetch data for the current language
|
|
32
32
|
const response = await axios.get(fileUrl, requestConfig);
|
|
33
|
-
|
|
33
|
+
let jsonData = response.data;
|
|
34
|
+
// Handle API response structure - only for pending changes API
|
|
35
|
+
if (usePendingChangesToFetch && jsonData && typeof jsonData === 'object' && 'data' in jsonData) {
|
|
36
|
+
jsonData = jsonData.data;
|
|
37
|
+
}
|
|
34
38
|
if (jsonData === undefined || jsonData === null) {
|
|
35
39
|
throw new Error(`No data received from ${fileUrl} for language ${languageToFetch}.`);
|
|
36
40
|
}
|
|
@@ -121,7 +121,11 @@ export async function generateTypes() {
|
|
|
121
121
|
console.log(chalk.blue(`Attempting to fetch JSON from: ${fileUrl}`));
|
|
122
122
|
try {
|
|
123
123
|
const response = await axios.get(fileUrl, requestConfig);
|
|
124
|
-
|
|
124
|
+
let jsonResponse = response.data;
|
|
125
|
+
// Handle API response structure - API returns { data: actualContent }
|
|
126
|
+
if (config.pendingChanges && jsonResponse && typeof jsonResponse === 'object' && 'data' in jsonResponse) {
|
|
127
|
+
jsonResponse = jsonResponse.data;
|
|
128
|
+
}
|
|
125
129
|
console.log(chalk.blue('Flattening JSON for type generation'));
|
|
126
130
|
jsonObject = flattenJson(jsonResponse);
|
|
127
131
|
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
|
@@ -83,7 +83,11 @@ export async function pullContent() {
|
|
|
83
83
|
try {
|
|
84
84
|
// Fetch data for the current language
|
|
85
85
|
const response = await axios.get(fileUrl, requestConfig);
|
|
86
|
-
|
|
86
|
+
let jsonData = response.data;
|
|
87
|
+
// Handle API response structure - only for pending changes API
|
|
88
|
+
if (config.pendingChanges && jsonData && typeof jsonData === 'object' && 'data' in jsonData) {
|
|
89
|
+
jsonData = jsonData.data;
|
|
90
|
+
}
|
|
87
91
|
// Basic check for data existence, although axios usually throws for non-2xx responses
|
|
88
92
|
if (jsonData === undefined || jsonData === null) {
|
|
89
93
|
throw new Error(`No data received from ${fileUrl} for language ${languageCode}.`);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@contentstorage/core",
|
|
3
3
|
"author": "Kaido Hussar <kaidohus@gmail.com>",
|
|
4
4
|
"homepage": "https://contentstorage.app",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Fetch content from contentstorage and generate TypeScript types",
|
|
8
8
|
"module": "dist/index.js",
|