api-client-fideicomisos 1.0.0
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/.babelrc +10 -0
- package/README.md +21 -0
- package/deploy.bash +5 -0
- package/index.js +5 -0
- package/package.json +34 -0
- package/src/client.js +63 -0
- package/src/enpoints/auth/auth.js +49 -0
- package/src/enpoints/backoffice/blog.js +245 -0
- package/src/enpoints/backoffice/cardHomePage.js +32 -0
- package/src/enpoints/backoffice/companies.js +67 -0
- package/src/enpoints/backoffice/footer.js +33 -0
- package/src/enpoints/backoffice/institucional.js +154 -0
- package/src/enpoints/backoffice/videoSection.js +32 -0
- package/src/enpoints/frontend/blog-financieros-description.js +13 -0
- package/src/enpoints/frontend/blog-financieros.js +164 -0
- package/src/enpoints/frontend/blog-section.js +13 -0
- package/src/enpoints/frontend/home-page.js +13 -0
- package/src/enpoints/frontend/institucional.js +13 -0
- package/src/enpoints/frontend/que-hacemos.js +13 -0
- package/src/enpoints/general/blogMedia.js +77 -0
- package/src/enpoints/general/upload.js +20 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/tsconfig.json +13 -0
package/.babelrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# provincia-api-client
|
|
2
|
+
|
|
3
|
+
Para hacer un deploy de una nueva version
|
|
4
|
+
|
|
5
|
+
1- Hacer el commit del trabajo
|
|
6
|
+
|
|
7
|
+
2- Hacer un pull rebase
|
|
8
|
+
|
|
9
|
+
3- Crear la nueva version con
|
|
10
|
+
|
|
11
|
+
npm version minor
|
|
12
|
+
|
|
13
|
+
este comando hara el cambio de version y el commit al repositorio
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Testing local:
|
|
17
|
+
|
|
18
|
+
Para testear de manera local se puede instalar el modulo desde file:
|
|
19
|
+
|
|
20
|
+
"provincia-api-client": "file:../provincia-api-client",
|
|
21
|
+
En el index => const provinciaClient = require("./src/client").client; en testing usar dist en produccion
|
package/deploy.bash
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api-client-fideicomisos",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Api client Banco Provincia Fideicomisos",
|
|
5
|
+
"homepage": "https://github.com/TeoCoop/api-client-fideicomisos.git",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/TeoCoop/api-client-fideicomisos.git/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/TeoCoop/api-client-fideicomisos.git.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "Cooperativa Teo Coop - https://teocoop.site/",
|
|
15
|
+
"type": "commonjs",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
|
+
"transpile": "babel -d dist/ src/",
|
|
21
|
+
"commit": "git add . && git commit --allow-empty -m \"transpiled\"",
|
|
22
|
+
"preversion": "npm run transpile && npm run types && npm run commit",
|
|
23
|
+
"postversion": "git push origin main && git push --tags",
|
|
24
|
+
"types": "npx -p typescript tsc --project tsconfig.json && cp src/index.d.ts dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"axios": "^1.7.9"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/cli": "^7.15.8",
|
|
31
|
+
"@babel/core": "^7.15.8",
|
|
32
|
+
"@babel/preset-env": "^7.15.8"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/client.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} baseURL
|
|
4
|
+
*/
|
|
5
|
+
function createClient(baseURL) {
|
|
6
|
+
return axios.create({
|
|
7
|
+
baseURL: `${baseURL}`,
|
|
8
|
+
headers: { "Content-Type": "application/json" },
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function frontendEndpoints(baseURL) {
|
|
13
|
+
const client = createClient(baseURL);
|
|
14
|
+
return {
|
|
15
|
+
homePage: require("./enpoints/frontend/home-page.js")({ client }),
|
|
16
|
+
institucional: require("./enpoints/frontend/institucional.js")({ client }),
|
|
17
|
+
queHacemos: require("./enpoints/frontend/que-hacemos.js")({ client }),
|
|
18
|
+
blog: require("./enpoints/frontend/blog-financieros.js")({ client }),
|
|
19
|
+
blogPage: require("./enpoints/frontend/blog-section.js")({ client }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function backendEndpoints(baseURL) {
|
|
23
|
+
const client = createClient(baseURL);
|
|
24
|
+
return {
|
|
25
|
+
cardHomePage: require("./enpoints/backoffice/cardHomePage.js")({ client }),
|
|
26
|
+
institucional: require("./enpoints/backoffice/institucional.js")({
|
|
27
|
+
client,
|
|
28
|
+
}),
|
|
29
|
+
companies: require("./enpoints/backoffice/companies.js")({ client }),
|
|
30
|
+
blog: require("./enpoints/backoffice/blog.js")({ client }),
|
|
31
|
+
videoSection: require("./enpoints/backoffice/videoSection.js")({ client }),
|
|
32
|
+
footer: require("./enpoints/backoffice/footer.js")({ client }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function authEndpoint(baseURL) {
|
|
36
|
+
const client = createClient(baseURL);
|
|
37
|
+
return require("./enpoints/auth/auth.js")({ client });
|
|
38
|
+
}
|
|
39
|
+
function generalEndpoints(baseURL) {
|
|
40
|
+
const client = createClient(baseURL);
|
|
41
|
+
return {
|
|
42
|
+
upload: require("./enpoints/general/upload.js")({ client }),
|
|
43
|
+
blogMedia: require("./enpoints/general/blogMedia.js")({
|
|
44
|
+
client,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function client(options) {
|
|
50
|
+
const { env } = options;
|
|
51
|
+
const baseURL =
|
|
52
|
+
env === "prod"
|
|
53
|
+
? "https://api-provincia-financieros.teo.coop.ar"
|
|
54
|
+
: env === "sandbox"
|
|
55
|
+
? "https://api-prov-fiduciarios-sandbox.teocoop.site/"
|
|
56
|
+
: "http://localhost:1337/";
|
|
57
|
+
return {
|
|
58
|
+
frontend: frontendEndpoints(baseURL),
|
|
59
|
+
auth: authEndpoint(baseURL),
|
|
60
|
+
backend: backendEndpoints(baseURL),
|
|
61
|
+
general: generalEndpoints(baseURL),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function auth({ client }) {
|
|
2
|
+
function auth({ user }) {
|
|
3
|
+
return client({
|
|
4
|
+
url: `/api/auth/local`,
|
|
5
|
+
method: "post",
|
|
6
|
+
data: {
|
|
7
|
+
identifier: user.identifier,
|
|
8
|
+
password: user.password,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function login({ user, access_token }) {
|
|
14
|
+
return client({
|
|
15
|
+
url: `/api/login/request-code`,
|
|
16
|
+
method: "post",
|
|
17
|
+
data: {
|
|
18
|
+
email: user.email,
|
|
19
|
+
password: user.password,
|
|
20
|
+
},
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${access_token}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function verifyTotp({ user, access_token }) {
|
|
28
|
+
// 1. Renamed for clarity
|
|
29
|
+
return client({
|
|
30
|
+
url: `/api/login/verify-code`, // 2. Added /api prefix
|
|
31
|
+
method: "post",
|
|
32
|
+
data: {
|
|
33
|
+
email: user.email,
|
|
34
|
+
code: user.token, // 3. Changed payload key from 'token' to 'code'
|
|
35
|
+
},
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${access_token}`,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
auth,
|
|
44
|
+
login,
|
|
45
|
+
verifyTotp,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = auth;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
function companies({ client }) {
|
|
2
|
+
// ------------------BLOG SECTION-------------------
|
|
3
|
+
function getBlogSection({ jwtToken }) {
|
|
4
|
+
if (!jwtToken) throw new Error("Token is required");
|
|
5
|
+
return client({
|
|
6
|
+
url: `/api/blog-section`,
|
|
7
|
+
method: "get",
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function updateBlogSection({ jwtToken, data }) {
|
|
15
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
16
|
+
if (!data) throw new Error("data is required");
|
|
17
|
+
|
|
18
|
+
const formattedData = { data: { ...data } };
|
|
19
|
+
return client({
|
|
20
|
+
url: `/api/blog-section`,
|
|
21
|
+
method: "put",
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
24
|
+
},
|
|
25
|
+
data: formattedData,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ------------------CADA BLOG-------------------
|
|
30
|
+
function getByIdBlog({ blogId }) {
|
|
31
|
+
if (!blogId) throw new Error("blogId is required");
|
|
32
|
+
return client({
|
|
33
|
+
url: `/api/blogs/${blogId}`,
|
|
34
|
+
method: "get",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getAllBlogs({ jwtToken, pageSize = 20, page = 1 }) {
|
|
39
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
40
|
+
|
|
41
|
+
const params = new URLSearchParams({
|
|
42
|
+
"pagination[page]": page,
|
|
43
|
+
"pagination[pageSize]": pageSize,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return client({
|
|
47
|
+
url: `/api/blogs?${params.toString()}`,
|
|
48
|
+
method: "get",
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function updateBlog({ jwtToken, blogId, data }) {
|
|
56
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
57
|
+
if (!blogId) throw new Error("blogId is required");
|
|
58
|
+
if (!data) throw new Error("data is required");
|
|
59
|
+
|
|
60
|
+
const formattedData = { data: { ...data } };
|
|
61
|
+
return client({
|
|
62
|
+
url: `/api/blogs/${blogId}`,
|
|
63
|
+
method: "put",
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
66
|
+
},
|
|
67
|
+
data: formattedData,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function createBlog({ jwtToken, data }) {
|
|
72
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
73
|
+
if (!data) throw new Error("data is required");
|
|
74
|
+
const formattedData = { data: { ...data } };
|
|
75
|
+
return client({
|
|
76
|
+
url: "/api/blogs",
|
|
77
|
+
method: "post",
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
80
|
+
},
|
|
81
|
+
data: formattedData,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function deleteBlog({ jwtToken, blogId }) {
|
|
86
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
87
|
+
if (!blogId) throw new Error("blogId is required");
|
|
88
|
+
|
|
89
|
+
return client({
|
|
90
|
+
url: `/api/blogs/${blogId}`,
|
|
91
|
+
method: "delete",
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ------------------TOPIC BLOGS -------------------
|
|
99
|
+
function getByIdTopic({ topicId }) {
|
|
100
|
+
if (!topicId) throw new Error("topicId is required");
|
|
101
|
+
return client({
|
|
102
|
+
url: `/api/topic-blogs/${topicId}`,
|
|
103
|
+
method: "get",
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getAllTopic({ jwtToken }) {
|
|
108
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
109
|
+
return client({
|
|
110
|
+
url: `/api/topic-blogs`,
|
|
111
|
+
method: "get",
|
|
112
|
+
headers: {
|
|
113
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function updateTopic({ jwtToken, topicId, data }) {
|
|
119
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
120
|
+
if (!topicId) throw new Error("topicId is required");
|
|
121
|
+
if (!data) throw new Error("data is required");
|
|
122
|
+
const formattedData = { data: { ...data } };
|
|
123
|
+
return client({
|
|
124
|
+
url: `/api/topic-blogs/${topicId}`,
|
|
125
|
+
method: "put",
|
|
126
|
+
headers: {
|
|
127
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
128
|
+
},
|
|
129
|
+
data: formattedData,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function createTopic({ jwtToken, data }) {
|
|
134
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
135
|
+
if (!data) throw new Error("data is required");
|
|
136
|
+
|
|
137
|
+
const formattedData = { data: { ...data } };
|
|
138
|
+
return client({
|
|
139
|
+
url: "/api/topic-blogs",
|
|
140
|
+
method: "post",
|
|
141
|
+
headers: {
|
|
142
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
143
|
+
},
|
|
144
|
+
data: formattedData,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function deleteTopic({ jwtToken, topicId }) {
|
|
149
|
+
if (!jwtToken) throw new Error("jwtToken is required");
|
|
150
|
+
if (!topicId) throw new Error("topicId is required");
|
|
151
|
+
|
|
152
|
+
return client({
|
|
153
|
+
url: `/api/topic-blogs/${topicId}`,
|
|
154
|
+
method: "delete",
|
|
155
|
+
headers: {
|
|
156
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// ------------------BLOG MEDIA -------------------
|
|
161
|
+
function getBlogMedia({ jwtToken, page = 1, pageSize = 20 }) {
|
|
162
|
+
const params = new URLSearchParams({
|
|
163
|
+
"pagination[page]": String(page),
|
|
164
|
+
"pagination[pageSize]": String(pageSize),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return client({
|
|
168
|
+
url: `/api/blog-medias?${params.toString()}`,
|
|
169
|
+
method: "get",
|
|
170
|
+
headers: {
|
|
171
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function updateFile({ jwtToken, data, fileId }) {
|
|
177
|
+
const formattedData = {
|
|
178
|
+
data: {
|
|
179
|
+
...data,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
return client({
|
|
183
|
+
url: `/api/blog-medias/${fileId}`,
|
|
184
|
+
method: "put",
|
|
185
|
+
headers: {
|
|
186
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
187
|
+
},
|
|
188
|
+
data: formattedData,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function deleteFile({ jwtToken, fileId }) {
|
|
192
|
+
return client({
|
|
193
|
+
url: `/api/blog-medias/${fileId}`,
|
|
194
|
+
method: "delete",
|
|
195
|
+
headers: {
|
|
196
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function createFile({ jwtToken, data }) {
|
|
201
|
+
const formattedData = {
|
|
202
|
+
data: {
|
|
203
|
+
...data,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
return client({
|
|
207
|
+
url: "/api/blog-medias",
|
|
208
|
+
method: "post",
|
|
209
|
+
headers: {
|
|
210
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
211
|
+
},
|
|
212
|
+
data: formattedData,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function getMediaById({ jwtToken, fileId }) {
|
|
216
|
+
return client({
|
|
217
|
+
url: `/api/blog-medias/${fileId}`,
|
|
218
|
+
method: "get",
|
|
219
|
+
headers: {
|
|
220
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
getBlogSection,
|
|
226
|
+
updateBlogSection,
|
|
227
|
+
getByIdBlog,
|
|
228
|
+
getAllBlogs,
|
|
229
|
+
updateBlog,
|
|
230
|
+
createBlog,
|
|
231
|
+
deleteBlog,
|
|
232
|
+
createTopic,
|
|
233
|
+
deleteTopic,
|
|
234
|
+
getByIdTopic,
|
|
235
|
+
getAllTopic,
|
|
236
|
+
updateTopic,
|
|
237
|
+
getBlogMedia,
|
|
238
|
+
updateFile,
|
|
239
|
+
deleteFile,
|
|
240
|
+
createFile,
|
|
241
|
+
getMediaById,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
module.exports = companies;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function homeFondos({ client }) {
|
|
2
|
+
function getAllPanel(jwtToken) {
|
|
3
|
+
return client({
|
|
4
|
+
url: `/api/card-home`,
|
|
5
|
+
method: "get",
|
|
6
|
+
headers: {
|
|
7
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function updateHome({ jwtToken, data }) {
|
|
12
|
+
const formattedData = {
|
|
13
|
+
data: {
|
|
14
|
+
...data,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
return client({
|
|
18
|
+
url: `/api/card-home`,
|
|
19
|
+
method: "put",
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
22
|
+
},
|
|
23
|
+
data: formattedData,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
updateHome,
|
|
29
|
+
getAllPanel,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
module.exports = homeFondos;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
function companies({ client }) {
|
|
2
|
+
// ------------------MIEMBROS DE AREAS-------------------
|
|
3
|
+
|
|
4
|
+
function getById({ companieId }) {
|
|
5
|
+
return client({
|
|
6
|
+
url: `/api/companies/${companieId}`,
|
|
7
|
+
method: "get",
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function getCompanies({ jwtToken }) {
|
|
11
|
+
return client({
|
|
12
|
+
url: `/api/companies`,
|
|
13
|
+
method: "get",
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function updateCompanie({ jwtToken, companieId, data }) {
|
|
20
|
+
const formattedData = {
|
|
21
|
+
data: {
|
|
22
|
+
...data,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
return client({
|
|
26
|
+
url: `/api/companies/${companieId}`,
|
|
27
|
+
method: "put",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
30
|
+
},
|
|
31
|
+
data: formattedData,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function createCompanie({ jwtToken, data }) {
|
|
35
|
+
const formattedData = {
|
|
36
|
+
data: {
|
|
37
|
+
...data,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return client({
|
|
41
|
+
url: "/api/companies",
|
|
42
|
+
method: "post",
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
45
|
+
},
|
|
46
|
+
data: formattedData,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function deleteCompanie({ jwtToken, companieId }) {
|
|
50
|
+
return client({
|
|
51
|
+
url: `/api/companies/${companieId}`,
|
|
52
|
+
method: "delete",
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
getById,
|
|
61
|
+
getCompanies,
|
|
62
|
+
updateCompanie,
|
|
63
|
+
createCompanie,
|
|
64
|
+
deleteCompanie,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
module.exports = companies;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function footer({ client }) {
|
|
2
|
+
// ------------------FOOTER-------------------
|
|
3
|
+
function getFooter({ jwtToken }) {
|
|
4
|
+
return client({
|
|
5
|
+
url: "/api/footer",
|
|
6
|
+
method: "get",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function updateFooter({ jwtToken, data }) {
|
|
13
|
+
const formattedData = {
|
|
14
|
+
data: {
|
|
15
|
+
...data,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return client({
|
|
19
|
+
url: "/api/footer",
|
|
20
|
+
method: "put",
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
23
|
+
},
|
|
24
|
+
data: formattedData,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
updateFooter,
|
|
30
|
+
getFooter,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
module.exports = footer;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function institucional({ client }) {
|
|
2
|
+
// ------------------INSTITUCIONAL-------------------
|
|
3
|
+
function getInstitucional({ jwtToken }) {
|
|
4
|
+
return client({
|
|
5
|
+
url: "/api/institucional",
|
|
6
|
+
method: "get",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function updateinstitucional({ jwtToken, data }) {
|
|
13
|
+
const formattedData = {
|
|
14
|
+
data: {
|
|
15
|
+
...data,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return client({
|
|
19
|
+
url: "/api/institucional",
|
|
20
|
+
method: "put",
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
23
|
+
},
|
|
24
|
+
data: formattedData,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// ------------------MIEMBROS DE AREAS-------------------
|
|
28
|
+
|
|
29
|
+
function getByIdMember({ memberId }) {
|
|
30
|
+
return client({
|
|
31
|
+
url: `/api/member-teams/${memberId}`,
|
|
32
|
+
method: "get",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function getMembers({ jwtToken }) {
|
|
36
|
+
return client({
|
|
37
|
+
url: `/api/member-teams`,
|
|
38
|
+
method: "get",
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function updateMember({ jwtToken, memberId, data }) {
|
|
45
|
+
const formattedData = {
|
|
46
|
+
data: {
|
|
47
|
+
...data,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return client({
|
|
51
|
+
url: `/api/member-teams/${memberId}`,
|
|
52
|
+
method: "put",
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
55
|
+
},
|
|
56
|
+
data: formattedData,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createMember({ jwtToken, data }) {
|
|
60
|
+
const formattedData = {
|
|
61
|
+
data: {
|
|
62
|
+
...data,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
return client({
|
|
66
|
+
url: "/api/member-teams",
|
|
67
|
+
method: "post",
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
70
|
+
},
|
|
71
|
+
data: formattedData,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function deleteMember({ jwtToken, memberId }) {
|
|
75
|
+
return client({
|
|
76
|
+
url: `/api/member-teams/${memberId}`,
|
|
77
|
+
method: "delete",
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// ------------------AREAS-------------------
|
|
84
|
+
|
|
85
|
+
function getByIdArea({ areaUd }) {
|
|
86
|
+
return client({
|
|
87
|
+
url: `/api/member-teams/${areaUd}`,
|
|
88
|
+
method: "get",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function getAreas({ jwtToken }) {
|
|
92
|
+
return client({
|
|
93
|
+
url: `/api/areas-teams`,
|
|
94
|
+
method: "get",
|
|
95
|
+
headers: {
|
|
96
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function updateArea({ jwtToken, areaId, data }) {
|
|
101
|
+
const formattedData = {
|
|
102
|
+
data: {
|
|
103
|
+
...data,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
return client({
|
|
107
|
+
url: `/api/areas-teams/${areaId}`,
|
|
108
|
+
method: "put",
|
|
109
|
+
headers: {
|
|
110
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
111
|
+
},
|
|
112
|
+
data: formattedData,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function createArea({ jwtToken, data }) {
|
|
116
|
+
const formattedData = {
|
|
117
|
+
data: {
|
|
118
|
+
...data,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
return client({
|
|
122
|
+
url: "/api/areas-teams",
|
|
123
|
+
method: "post",
|
|
124
|
+
headers: {
|
|
125
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
126
|
+
},
|
|
127
|
+
data: formattedData,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function deleteArea({ jwtToken, areaId }) {
|
|
131
|
+
return client({
|
|
132
|
+
url: `/api/areas-teams/${areaId}`,
|
|
133
|
+
method: "delete",
|
|
134
|
+
headers: {
|
|
135
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
updateinstitucional,
|
|
141
|
+
getInstitucional,
|
|
142
|
+
getByIdMember,
|
|
143
|
+
getMembers,
|
|
144
|
+
updateMember,
|
|
145
|
+
createMember,
|
|
146
|
+
deleteMember,
|
|
147
|
+
getAreas,
|
|
148
|
+
getByIdArea,
|
|
149
|
+
updateArea,
|
|
150
|
+
createArea,
|
|
151
|
+
deleteArea,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
module.exports = institucional;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function videoHome({ client }) {
|
|
2
|
+
function getAllPanel(jwtToken) {
|
|
3
|
+
return client({
|
|
4
|
+
url: `/api/video-home`,
|
|
5
|
+
method: "get",
|
|
6
|
+
headers: {
|
|
7
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function updateVideo({ jwtToken, data }) {
|
|
12
|
+
const formattedData = {
|
|
13
|
+
data: {
|
|
14
|
+
...data,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
return client({
|
|
18
|
+
url: `/api/video-home`,
|
|
19
|
+
method: "put",
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
22
|
+
},
|
|
23
|
+
data: formattedData,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
updateVideo,
|
|
29
|
+
getAllPanel,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
module.exports = videoHome;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
function blog({ client }) {
|
|
2
|
+
function getById({ blogId }) {
|
|
3
|
+
return client({
|
|
4
|
+
url: `/api/blogs/${blogId}`,
|
|
5
|
+
method: "get",
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getByWithCompany({ blogId }) {
|
|
10
|
+
return client({
|
|
11
|
+
url: `/api/blogs/with-company/${blogId}`, // ⚠️ o /with-company/ si renombrás el endpoint
|
|
12
|
+
method: "get",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getTopic() {
|
|
17
|
+
return client({
|
|
18
|
+
url: `/api/topic-blogs`,
|
|
19
|
+
method: "get",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getTopicById({ topicId }) {
|
|
24
|
+
return client({
|
|
25
|
+
url: `/api/topic-blogs/${topicId}`,
|
|
26
|
+
method: "get",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getAll({ page = 1, pageSize = 25, order = "desc" } = {}) {
|
|
31
|
+
const query = `?pagination[page]=${page}&pagination[pageSize]=${pageSize}&sort=create:${order}`;
|
|
32
|
+
return client({
|
|
33
|
+
url: `/api/blogs${query}`,
|
|
34
|
+
method: "get",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getYears() {
|
|
39
|
+
return client({
|
|
40
|
+
url: `/api/blogs/years`,
|
|
41
|
+
method: "get",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function getBlogsExcludingCompany({ companieDocumentId, limit = 5 }) {
|
|
45
|
+
const query = `
|
|
46
|
+
query Blogs($filters: BlogFiltersInput, $limit: Int) {
|
|
47
|
+
blogs(
|
|
48
|
+
filters: $filters
|
|
49
|
+
sort: ["create:desc"]
|
|
50
|
+
pagination: { limit: $limit }
|
|
51
|
+
) {
|
|
52
|
+
documentId
|
|
53
|
+
title
|
|
54
|
+
create
|
|
55
|
+
subtitle
|
|
56
|
+
companie {
|
|
57
|
+
name
|
|
58
|
+
documentId
|
|
59
|
+
logoBlanco {
|
|
60
|
+
url
|
|
61
|
+
}
|
|
62
|
+
logoColor {
|
|
63
|
+
url
|
|
64
|
+
}
|
|
65
|
+
colorPrimary
|
|
66
|
+
colorSecondary
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
const variables = {
|
|
73
|
+
filters: {
|
|
74
|
+
companie: {
|
|
75
|
+
documentId: {
|
|
76
|
+
not: {
|
|
77
|
+
eq: companieDocumentId,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
limit,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return client({
|
|
86
|
+
url: `/graphql`,
|
|
87
|
+
method: "post",
|
|
88
|
+
data: { query, variables },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getCompanies() {
|
|
93
|
+
const query = `
|
|
94
|
+
query Companies {
|
|
95
|
+
companies {
|
|
96
|
+
name
|
|
97
|
+
colorPrimary
|
|
98
|
+
colorSecondary
|
|
99
|
+
documentId
|
|
100
|
+
url
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
return client({
|
|
105
|
+
url: `/graphql`,
|
|
106
|
+
method: "post",
|
|
107
|
+
data: { query },
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Obtiene blogs con filtros dinámicos.
|
|
112
|
+
* @param {Object} params
|
|
113
|
+
* @param {number} [params.year]
|
|
114
|
+
* @param {string} [params.topicDocumentId] - documentId del topic
|
|
115
|
+
* @param {string} [params.companieDocumentId] - documentId de la compañía
|
|
116
|
+
* @param {string} [params.search]
|
|
117
|
+
* @param {number} [params.page=1]
|
|
118
|
+
* @param {number} [params.pageSize=10]
|
|
119
|
+
* @param {string} [params.sortField="create"]
|
|
120
|
+
* @param {"asc"|"desc"} [params.sortOrder="desc"]
|
|
121
|
+
*/
|
|
122
|
+
function getFilters({
|
|
123
|
+
year,
|
|
124
|
+
topicDocumentId,
|
|
125
|
+
companieDocumentId,
|
|
126
|
+
search,
|
|
127
|
+
page = 1,
|
|
128
|
+
pageSize = 10,
|
|
129
|
+
sortField = "create",
|
|
130
|
+
sortOrder = "desc",
|
|
131
|
+
} = {}) {
|
|
132
|
+
const params = new URLSearchParams();
|
|
133
|
+
|
|
134
|
+
params.append("page", page.toString());
|
|
135
|
+
params.append("pageSize", pageSize.toString());
|
|
136
|
+
params.append("sortField", sortField);
|
|
137
|
+
params.append("sortOrder", sortOrder);
|
|
138
|
+
|
|
139
|
+
if (year != null) params.append("year", year.toString());
|
|
140
|
+
if (topicDocumentId) params.append("topicDocumentId", topicDocumentId);
|
|
141
|
+
if (companieDocumentId)
|
|
142
|
+
params.append("companieDocumentId", companieDocumentId);
|
|
143
|
+
if (search) params.append("search", search);
|
|
144
|
+
|
|
145
|
+
return client({
|
|
146
|
+
url: `/api/blogs-filter?${params.toString()}`,
|
|
147
|
+
method: "get",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
getById,
|
|
153
|
+
getAll,
|
|
154
|
+
getFilters,
|
|
155
|
+
getByWithCompany,
|
|
156
|
+
getTopic,
|
|
157
|
+
getTopicById,
|
|
158
|
+
getYears,
|
|
159
|
+
getCompanies,
|
|
160
|
+
getBlogsExcludingCompany,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = blog;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function blogMedia({ client }) {
|
|
2
|
+
function getAll({ jwtToken, page = 1, pageSize = 20 }) {
|
|
3
|
+
const params = new URLSearchParams({
|
|
4
|
+
"pagination[page]": String(page),
|
|
5
|
+
"pagination[pageSize]": String(pageSize),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
return client({
|
|
9
|
+
url: `/api/blog-medias?${params.toString()}`,
|
|
10
|
+
method: "get",
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getById({ jwtToken, fileId }) {
|
|
18
|
+
return client({
|
|
19
|
+
url: `/api/blog-medias/${fileId}`,
|
|
20
|
+
method: "get",
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function updateFile({ jwtToken, data, fileId }) {
|
|
27
|
+
const formattedData = {
|
|
28
|
+
data: {
|
|
29
|
+
...data,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return client({
|
|
33
|
+
url: `/api/blog-medias/${fileId}`,
|
|
34
|
+
method: "put",
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
37
|
+
},
|
|
38
|
+
data: {
|
|
39
|
+
formattedData,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function deleteFile({ jwtToken, fileId }) {
|
|
44
|
+
return client({
|
|
45
|
+
url: `/api/blog-medias/${fileId}`,
|
|
46
|
+
method: "delete",
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function createFile({ jwtToken, data }) {
|
|
53
|
+
const formattedData = {
|
|
54
|
+
data: {
|
|
55
|
+
...data,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return client({
|
|
59
|
+
url: "/api/blog-medias",
|
|
60
|
+
method: "post",
|
|
61
|
+
headers: {
|
|
62
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
63
|
+
},
|
|
64
|
+
data: formattedData,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
getAll,
|
|
69
|
+
updateFile,
|
|
70
|
+
deleteFile,
|
|
71
|
+
getById,
|
|
72
|
+
deleteFile,
|
|
73
|
+
createFile,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = blogMedia;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function upload({ client }) {
|
|
2
|
+
function update({ jwtToken, file }) {
|
|
3
|
+
const formData = new FormData();
|
|
4
|
+
formData.append("files", file);
|
|
5
|
+
return client({
|
|
6
|
+
url: "/api/upload",
|
|
7
|
+
method: "post",
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
10
|
+
"Content-Type": "multipart/form-data",
|
|
11
|
+
},
|
|
12
|
+
data: formData,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
update,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = upload;
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"emitDeclarationOnly": true,
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"target": "es2017", // o superior
|
|
10
|
+
"lib": ["es2017", "dom"] // o ["es2019", "dom"] si querés más moderno
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"]
|
|
13
|
+
}
|