griddo-sdk 1.2.5 → 1.2.7
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.
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const dotenv = require("dotenv");
|
|
2
|
+
const SDK = require('./../index');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Para probar el ejemplo hay que crearse un .env con las siguientes variables:
|
|
6
|
+
* - API_URL
|
|
7
|
+
* - PUBLIC_API_URL
|
|
8
|
+
* - USER_EMAIL
|
|
9
|
+
* - USER_PASSWORD
|
|
10
|
+
* - VERBOSE
|
|
11
|
+
*/
|
|
12
|
+
(async () => {
|
|
13
|
+
dotenv.config();
|
|
14
|
+
|
|
15
|
+
const sdk = new SDK();
|
|
16
|
+
|
|
17
|
+
const { API_URL, PUBLIC_API_URL, USER_EMAIL, USER_PASSWORD, VERBOSE } =
|
|
18
|
+
process.env;
|
|
19
|
+
|
|
20
|
+
if (!API_URL || !PUBLIC_API_URL || !USER_EMAIL || !USER_PASSWORD) {
|
|
21
|
+
throw new Error("Environment variables must be set");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Conectar al entorno
|
|
25
|
+
await sdk.connect({
|
|
26
|
+
api: API_URL,
|
|
27
|
+
publicApi: PUBLIC_API_URL,
|
|
28
|
+
user: USER_EMAIL,
|
|
29
|
+
password: USER_PASSWORD,
|
|
30
|
+
verbose: VERBOSE === "true",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const queryParams = {
|
|
34
|
+
page: 1,
|
|
35
|
+
itemsPerPage: 2,
|
|
36
|
+
pagination: true,
|
|
37
|
+
includeDraft: false,
|
|
38
|
+
relatedFields: true,
|
|
39
|
+
deleted: false,
|
|
40
|
+
query: "prueba",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const paginationStructuredData = await sdk.getPaginationStructuredData(
|
|
44
|
+
"ALUMNI",
|
|
45
|
+
"8",
|
|
46
|
+
"2",
|
|
47
|
+
queryParams,
|
|
48
|
+
);
|
|
49
|
+
console.log("Structured Data:", paginationStructuredData);
|
|
50
|
+
})();
|
package/models/structuredData.js
CHANGED
|
@@ -35,7 +35,13 @@ const getStructuredData = async (
|
|
|
35
35
|
const path = `${site ? `/site/${site}` : ''}/structured_data_contents/${contentType || ''}?${query}`
|
|
36
36
|
|
|
37
37
|
const items = await api(env, 'get', path, null, headers)
|
|
38
|
-
.then(data =>
|
|
38
|
+
.then(data => {
|
|
39
|
+
if (queryParams.pagination) {
|
|
40
|
+
data.page = queryParams.page
|
|
41
|
+
return data
|
|
42
|
+
}
|
|
43
|
+
return data.items
|
|
44
|
+
});
|
|
39
45
|
if (env.verbose) {
|
|
40
46
|
console.log(`\tStructured data ${contentType} loaded.`);
|
|
41
47
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "griddo-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test
|
|
7
|
+
"test:example": "node examples/runTest.js",
|
|
8
8
|
"release": "bumpp --commit --push --tag"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"axios": "0.26.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"bumpp": "^9.4.1"
|
|
24
|
+
"bumpp": "^9.4.1",
|
|
25
|
+
"dotenv": "^16.4.5"
|
|
25
26
|
}
|
|
26
27
|
}
|