node-woololo-api-client 1.0.24

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/.gitlab-ci.yml ADDED
@@ -0,0 +1,20 @@
1
+ image: node:latest
2
+ stages:
3
+ - deploy
4
+ deploy:
5
+ only:
6
+ - master
7
+ - main
8
+ stage: deploy
9
+ script:
10
+ - export PATH="$PATH:/root/.nvm/versions/node/v12.22.12/bin"
11
+ - echo "PATH='${PATH}'"
12
+ - wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash #install nvm
13
+ - export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use #load nvm
14
+ - eval "[ -f .nvmrc ] && nvm install || nvm install 12" #install node
15
+ - node -v
16
+ - which node
17
+ - which npm
18
+ # - npm version patch --no-git-tag-version
19
+ - npm publish
20
+ environment: production
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # node-woololo-api-client
2
+
3
+ Create repository `.npmrc` file in the root of your project with content:
4
+
5
+ ````
6
+ @oleg:registry=http://gitlab.behind.ai/api/v4/packages/npm/
7
+ ````
8
+
9
+ Install npm package from the repository
10
+ ```bash
11
+ npm i @oleg/node-woololo-api-client
12
+ ```
13
+
14
+ Usage of the library
15
+
16
+ ```javascript
17
+ let api = new WoololoApiClient( 'access_token_here')
18
+ let res = await api.MeInfo();
19
+ ```
20
+
21
+ or on the test environment
22
+
23
+ ```javascript
24
+ let api = new WoololoApiClient( 'access_token_here', 'https://test.api.woololo.com')
25
+ let res = await api.MeInfo();
26
+ ```
package/export.js ADDED
@@ -0,0 +1,53 @@
1
+
2
+ import fs from 'fs';
3
+
4
+ (async () => {
5
+
6
+ // Synchronously read the file
7
+ const rawData = fs.readFileSync('data/api20.methods.json', 'utf8');
8
+
9
+ // Parse the file data as JSON
10
+ const data = JSON.parse(rawData);
11
+
12
+ function capitalize(str) {
13
+ if (str && typeof str === 'string') {
14
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
15
+ }
16
+ return str;
17
+ }
18
+
19
+ function replaceFirstCharacter(str, newChar) {
20
+ if (str.length === 0) {
21
+ return str; // Return the original string if it's empty
22
+ }
23
+ return newChar + str.substring(1);
24
+ }
25
+
26
+ let body = ''
27
+
28
+ data.forEach((module)=>{
29
+ let req = module.name.split('.');
30
+
31
+ let params = '';
32
+
33
+ Object.keys(module.params.data).forEach(key => {
34
+ params += ',' + key +' ';
35
+ });
36
+
37
+ params = replaceFirstCharacter(params, '');
38
+
39
+ body += ` async ${capitalize((req[0] == 'woololo')? "" : req[0])}${capitalize(req[1])}${capitalize(req[2])}${(req[3] === undefined)? "" : capitalize(req[3])}(${params}){
40
+ return this.request('${req[0]}/${req[1]}/${req[2]}${(req[3] === undefined)? "" : "."+ req[3]}', {${params}
41
+ });
42
+ }
43
+ `;
44
+ })
45
+
46
+ fs.writeFile('data/methods.js', body, (err) => {
47
+ if (err) {
48
+ console.error('Error writing file:', err);
49
+ } else {
50
+ console.log('File written successfully');
51
+ }
52
+ });
53
+ })()
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+
2
+ import { WoololoApiClient } from "./lib/woololo-api-client.js";
3
+
4
+
5
+ (async () => {
6
+ let api = new WoololoApiClient( )
7
+ let res = await api.NodeFeedGet('ru-kitchen.ru');
8
+
9
+ console.log(res)
10
+ })()
@@ -0,0 +1,485 @@
1
+ import axios from "axios";
2
+ import https from 'https';
3
+
4
+ export class WoololoApiClient {
5
+ #endpoint = 'https://api.woololo.com'
6
+ #access_token
7
+ constructor(access_token, endpoint) {
8
+ this.#access_token = access_token;
9
+ if(endpoint !== undefined) this.#endpoint = endpoint;
10
+ }
11
+
12
+ async apiRequest(app, module, action, data) {
13
+ let post_data = {};
14
+ post_data = Object.assign(post_data, (typeof data === undefined)? {} : data);
15
+
16
+ const headers = {
17
+ Accept: 'application/json',
18
+ 'Content-Type': 'application/json',
19
+ };
20
+ post_data.access_token = this.#access_token;
21
+
22
+ try {
23
+
24
+ const httpsAgent = new https.Agent({
25
+ rejectUnauthorized: false, // Ignore SSL certificate errors
26
+ checkServerIdentity: () => undefined // Skip hostname verification
27
+ });
28
+
29
+ const instance = axios.create({
30
+ httpsAgent
31
+ });
32
+
33
+ const response = await instance.post(
34
+ `${this.#endpoint}/api20/resource/${app}/${module}.${action}`,
35
+ post_data,
36
+ );
37
+
38
+ if (response.status == 200) {
39
+ let resp = await response.data;
40
+
41
+ let result = {};
42
+
43
+ if (resp.success) {
44
+ if (typeof resp.data !== 'undefined') {
45
+ result = resp.data;
46
+ } else {
47
+ result = resp;
48
+ }
49
+ return result;
50
+ }
51
+
52
+ throw resp.message;
53
+ } else {
54
+ throw new Error(response.data.message);
55
+ }
56
+
57
+ } catch (e) {
58
+ throw e;
59
+ }
60
+ }
61
+
62
+ async request(path_str, data) {
63
+ let path = path_str.split('/');
64
+ return this.apiRequest(path[0], path[1], path[2], data)
65
+ }
66
+ async MeInfo(){
67
+ return this.request('woololo/me/info', {
68
+ });
69
+ }
70
+ async MeNodes(){
71
+ return this.request('woololo/me/nodes', {
72
+ });
73
+ }
74
+ async MeSubscriptions(){
75
+ return this.request('woololo/me/subscriptions', {
76
+ });
77
+ }
78
+ async MeEmail(){
79
+ return this.request('woololo/me/email', {
80
+ });
81
+ }
82
+ async MePermissions(){
83
+ return this.request('woololo/me/permissions', {
84
+ });
85
+ }
86
+ async MeBillingGet(){
87
+ return this.request('woololo/me/billing.get', {
88
+ });
89
+ }
90
+ async MeBillingSet(ssn ,zip ,country ,city ,address ){
91
+ return this.request('woololo/me/billing.set', {ssn ,zip ,country ,city ,address
92
+ });
93
+ }
94
+ async MeUpdate(name ,sname ,gender ,bdate ){
95
+ return this.request('woololo/me/update', {name ,sname ,gender ,bdate
96
+ });
97
+ }
98
+ async NodeCreate(new_node_name ,node_address ,node_name ,general_access ,node_public ){
99
+ return this.request('woololo/node/create', {new_node_name ,node_address ,node_name ,general_access ,node_public
100
+ });
101
+ }
102
+ async NodePageCreate(node_name ,page_title ){
103
+ return this.request('woololo/node/page.create', {node_name ,page_title
104
+ });
105
+ }
106
+ async NodeDelete(node_name ){
107
+ return this.request('woololo/node/delete', {node_name
108
+ });
109
+ }
110
+ async NodeGet(node_name ){
111
+ return this.request('woololo/node/get', {node_name
112
+ });
113
+ }
114
+ async NodeSitemapGet(node_name ){
115
+ return this.request('woololo/node/sitemapget', {node_name
116
+ });
117
+ }
118
+ async NodePagesGet(node_name ){
119
+ return this.request('woololo/node/pages.get', {node_name
120
+ });
121
+ }
122
+ async NodeFeedGet(node_name ){
123
+ return this.request('woololo/node/feed.get', {node_name
124
+ });
125
+ }
126
+ async NodeTagsGet(node_name ){
127
+ return this.request('woololo/node/tags.get', {node_name
128
+ });
129
+ }
130
+ async NodeGrantAccess(node_name ,general_access ,inherit ){
131
+ return this.request('woololo/node/grant.access', {node_name ,general_access ,inherit
132
+ });
133
+ }
134
+ async NodeGrantUser(node_name ,user_id ,access_type ){
135
+ return this.request('woololo/node/grant.user', {node_name ,user_id ,access_type
136
+ });
137
+ }
138
+ async NodeInvite(node_name ,language ,user_list ){
139
+ return this.request('woololo/node/invite', {node_name ,language ,user_list
140
+ });
141
+ }
142
+ async NodeProductSet(node_name ,product_sku ){
143
+ return this.request('woololo/node/product.set', {node_name ,product_sku
144
+ });
145
+ }
146
+ async NodeGetChildren(node_name ,node_owner ){
147
+ return this.request('woololo/node/get.children', {node_name ,node_owner
148
+ });
149
+ }
150
+ async NodeProductCheck(node_name ){
151
+ return this.request('woololo/node/product.check', {node_name
152
+ });
153
+ }
154
+ async NodeSeoGet(node_name ){
155
+ return this.request('woololo/node/seo.get', {node_name
156
+ });
157
+ }
158
+ async NodeSeoSet(node_name ,enabled ){
159
+ return this.request('woololo/node/seo.set', {node_name ,enabled
160
+ });
161
+ }
162
+ async NodeLibsGet(node_name ){
163
+ return this.request('woololo/node/libs.get', {node_name
164
+ });
165
+ }
166
+ async NodeSettingsSet(node_name ,settings_json ){
167
+ return this.request('woololo/node/settings.set', {node_name ,settings_json
168
+ });
169
+ }
170
+ async NodeProductCheck(node_name ){
171
+ return this.request('woololo/node/product.check', {node_name
172
+ });
173
+ }
174
+ async NodeSetDefault(node_name ,page_id ){
175
+ return this.request('woololo/node/set.default', {node_name ,page_id
176
+ });
177
+ }
178
+ async NodePinCreate(node_name ,page_id ){
179
+ return this.request('woololo/node/pin.create', {node_name ,page_id
180
+ });
181
+ }
182
+ async NodePinDelete(node_name ,pin_id ){
183
+ return this.request('woololo/node/pin.delete', {node_name ,pin_id
184
+ });
185
+ }
186
+ async NodePinsGet(node_name ){
187
+ return this.request('woololo/node/pins.get', {node_name
188
+ });
189
+ }
190
+ async NodeSubscribe(node_name ){
191
+ return this.request('woololo/node/subscribe', {node_name
192
+ });
193
+ }
194
+ async NodeUnsubscribe(node_name ){
195
+ return this.request('woololo/node/unsubscribe', {node_name
196
+ });
197
+ }
198
+ async NodeSubscribersget(node_name ){
199
+ return this.request('woololo/node/subscribersget', {node_name
200
+ });
201
+ }
202
+ async NodeUnpublish(node_name ,post_key ){
203
+ return this.request('woololo/node/unpublish', {node_name ,post_key
204
+ });
205
+ }
206
+ async NodeRestoredeletedpost(node_name ,post_key ){
207
+ return this.request('woololo/node/restoredeletedpost', {node_name ,post_key
208
+ });
209
+ }
210
+ async NodeSpawnset(node_name ){
211
+ return this.request('woololo/node/spawnset', {node_name
212
+ });
213
+ }
214
+ async NodeFeedKey(node_name ,page_id ){
215
+ return this.request('woololo/node/feed.key', {node_name ,page_id
216
+ });
217
+ }
218
+ async PageBlockAdd(page_id ,block_type ,block_html ,block_json ){
219
+ return this.request('woololo/page/block.add', {page_id ,block_type ,block_html ,block_json
220
+ });
221
+ }
222
+ async PageBlockSort(page_id ,block_list ){
223
+ return this.request('woololo/page/block.sort', {page_id ,block_list
224
+ });
225
+ }
226
+ async PageGrantAccess(page_id ,general_access ,inherit ){
227
+ return this.request('woololo/page/grant.access', {page_id ,general_access ,inherit
228
+ });
229
+ }
230
+ async PageGrantUser(page_id ,user_id ,access_type ){
231
+ return this.request('woololo/page/grant.user', {page_id ,user_id ,access_type
232
+ });
233
+ }
234
+ async PageGetPersonal(page_id ){
235
+ return this.request('woololo/page/get.personal', {page_id
236
+ });
237
+ }
238
+ async PageGetAccess(page_id ){
239
+ return this.request('woololo/page/get.access', {page_id
240
+ });
241
+ }
242
+ async PagePublish(page_id ,site_name ){
243
+ return this.request('woololo/page/publish', {page_id ,site_name
244
+ });
245
+ }
246
+ async PageTransfer(page_id ,site_name ){
247
+ return this.request('woololo/page/transfer', {page_id ,site_name
248
+ });
249
+ }
250
+ async PageGet(page_id ){
251
+ return this.request('woololo/page/get', {page_id
252
+ });
253
+ }
254
+ async PageMetaget(page_id ){
255
+ return this.request('woololo/page/metaget', {page_id
256
+ });
257
+ }
258
+ async PageMetaupdate(page_id ,meta_title ,meta_description ,meta_header_image ,meta_image ,meta_keywords ){
259
+ return this.request('woololo/page/metaupdate', {page_id ,meta_title ,meta_description ,meta_header_image ,meta_image ,meta_keywords
260
+ });
261
+ }
262
+ async PageHeaderimageset(page_id ,image_id ){
263
+ return this.request('woololo/page/headerimageset', {page_id ,image_id
264
+ });
265
+ }
266
+ async PageUrlset(page_id ,page_url ){
267
+ return this.request('woololo/page/urlset', {page_id ,page_url
268
+ });
269
+ }
270
+ async PageBroadcast(page_id ,node_name ,title ,button_link ,button_text ,smtp_account_name ,custom_name ,custom_header ,custom_footer ,filters ){
271
+ return this.request('woololo/page/broadcast', {page_id ,node_name ,title ,button_link ,button_text ,smtp_account_name ,custom_name ,custom_header ,custom_footer ,filters
272
+ });
273
+ }
274
+ async PageRename(page_id ,page_name ){
275
+ return this.request('woololo/page/rename', {page_id ,page_name
276
+ });
277
+ }
278
+ async PageStat(page_id ){
279
+ return this.request('woololo/page/stat', {page_id
280
+ });
281
+ }
282
+ async PageDelete(page_id ){
283
+ return this.request('woololo/page/delete', {page_id
284
+ });
285
+ }
286
+ async PageSystemGet(page_id ){
287
+ return this.request('woololo/pagesystem/get', {page_id
288
+ });
289
+ }
290
+ async BlockContentUpdate(element_id ,block_html ){
291
+ return this.request('woololo/block/content.update', {element_id ,block_html
292
+ });
293
+ }
294
+ async BlockJsonUpdate(element_id ,block_json ){
295
+ return this.request('woololo/block/json.update', {element_id ,block_json
296
+ });
297
+ }
298
+ async BlockDelete(element_id ){
299
+ return this.request('woololo/block/delete', {element_id
300
+ });
301
+ }
302
+ async UserInfoGet(user_id ){
303
+ return this.request('woololo/user/info.get', {user_id
304
+ });
305
+ }
306
+ async UserFake(user_name ){
307
+ return this.request('woololo/user/fake', {user_name
308
+ });
309
+ }
310
+ async UserIdGet(user_mail ){
311
+ return this.request('woololo/user/id.get', {user_mail
312
+ });
313
+ }
314
+
315
+ async Search(node_name ,query, language ){
316
+ return this.request('woololo/search/query', {node_name ,query, language
317
+ });
318
+ }
319
+
320
+ async SearchArticle(node_name ,query, language ){
321
+ return this.request('woololo/search/article', {node_name ,query, language
322
+ });
323
+ }
324
+
325
+ async ToolsImageMeta(file_id ,alias_name ){
326
+ return this.request('woololo/tools/image.meta', {file_id ,alias_name
327
+ });
328
+ }
329
+ async ToolsGetUrl(url ){
330
+ return this.request('woololo/tools/get.url', {url
331
+ });
332
+ }
333
+ async ToolsGetIp(ip ){
334
+ return this.request('woololo/tools/get.ip', {ip
335
+ });
336
+ }
337
+ async ToolsStat(stat_type ){
338
+ return this.request('woololo/tools/stat', {stat_type
339
+ });
340
+ }
341
+ async ToolsUpdate(){
342
+ return this.request('woololo/tools/update', {
343
+ });
344
+ }
345
+ async ToolsPixabaySearch(query ){
346
+ return this.request('woololo/tools/pixabay.search', {query
347
+ });
348
+ }
349
+ async ToolsSslCheck(domains ){
350
+ return this.request('woololo/tools/ssl.check', {domains
351
+ });
352
+ }
353
+ async ToolsUnban(captcha_token ){
354
+ return this.request('woololo/tools/unban', {captcha_token
355
+ });
356
+ }
357
+ async MessagebucketListGet(){
358
+ return this.request('woololo/messagebucket/list.get', {
359
+ });
360
+ }
361
+ async MessagebucketStatisticGet(bucket_id ){
362
+ return this.request('woololo/messagebucket/statistic.get', {bucket_id
363
+ });
364
+ }
365
+ async MessagebucketUnsubscribe(user_mail ,confirm_code ,node_name ,bucket_key ){
366
+ return this.request('woololo/messagebucket/unsubscribe', {user_mail ,confirm_code ,node_name ,bucket_key
367
+ });
368
+ }
369
+ async ConfirmationCreate(method ,authentication ,app_id ,authentication_name ){
370
+ return this.request('woololo/confirmation/create', {method ,authentication ,app_id ,authentication_name
371
+ });
372
+ }
373
+ async ConfirmationCheck(bucket_id ,confirmation_waste ,confirmation_token ,confirmation_code ,confirmation_signature ){
374
+ return this.request('woololo/confirmation/check', {bucket_id ,confirmation_waste ,confirmation_token ,confirmation_code ,confirmation_signature
375
+ });
376
+ }
377
+ async ConfirmationSetpassword(confirmation_token ,confirmation_code ,confirmation_signature ,confirmation_password ){
378
+ return this.request('woololo/confirmation/setpassword', {confirmation_token ,confirmation_code ,confirmation_signature ,confirmation_password
379
+ });
380
+ }
381
+ async FeedGet(node_name ){
382
+ return this.request('woololo/feed/get', {node_name
383
+ });
384
+ }
385
+ async AuthCodecreate(client_id ){
386
+ return this.request('woololo/auth/codecreate', {client_id
387
+ });
388
+ }
389
+ async AuthTokencreate(client_id ){
390
+ return this.request('woololo/auth/tokencreate', {client_id
391
+ });
392
+ }
393
+ async AuthUserexists(user_email ){
394
+ return this.request('woololo/auth/userexists', {user_email
395
+ });
396
+ }
397
+ async StorageFilecreate(){
398
+ return this.request('woololo/storage/filecreate', {
399
+ });
400
+ }
401
+ async StorageFilestatusset(file_name ,file_status ){
402
+ return this.request('woololo/storage/filestatusset', {file_name ,file_status
403
+ });
404
+ }
405
+ async InsightsAdd(type ,data ,page_id ,node_name ){
406
+ return this.request('woololo/insights/add', {type ,data ,page_id ,node_name
407
+ });
408
+ }
409
+ async InsightsDelete(insight_id ){
410
+ return this.request('woololo/insights/delete', {insight_id
411
+ });
412
+ }
413
+ async InsightsVote(insight_id ,vote ){
414
+ return this.request('woololo/insights/vote', {insight_id ,vote
415
+ });
416
+ }
417
+ async InsightsGetbynode(node_name ){
418
+ return this.request('woololo/insights/getbynode', {node_name
419
+ });
420
+ }
421
+ async InsightsGetbypage(page_id ){
422
+ return this.request('woololo/insights/getbypage', {page_id
423
+ });
424
+ }
425
+ async MailerSend(recipient_user_id ,account_name ,template_name ,message_data ,language ){
426
+ return this.request('woololo/mailer/send', {recipient_user_id ,account_name ,template_name ,message_data ,language
427
+ });
428
+ }
429
+ async MailerGetMessage(message_id ){
430
+ return this.request('woololo/mailer/get.message', {message_id
431
+ });
432
+ }
433
+ async NotificationsCreate(type ,json ,priority ){
434
+ return this.request('woololo/notifications/create', {type ,json ,priority
435
+ });
436
+ }
437
+ async NotificationsCreateToken(token ,type ){
438
+ return this.request('woololo/notifications/create.token', {token ,type
439
+ });
440
+ }
441
+ async NotificationsGet(){
442
+ return this.request('woololo/notifications/get', {
443
+ });
444
+ }
445
+ async NotificationsNew(){
446
+ return this.request('woololo/notifications/new', {
447
+ });
448
+ }
449
+ async FileGrantAccess(stored_file_id ,general_access ){
450
+ return this.request('woololo/file/grant.access', {stored_file_id ,general_access
451
+ });
452
+ }
453
+ async FileMetaGet(stored_file_id ,alias_name ){
454
+ return this.request('woololo/file/meta.get', {stored_file_id ,alias_name
455
+ });
456
+ }
457
+ async FileStatusGet(stored_file_id ){
458
+ return this.request('woololo/file/status.get', {stored_file_id
459
+ });
460
+ }
461
+ async FileGet(stored_file_id ){
462
+ return this.request('woololo/file/get', {stored_file_id
463
+ });
464
+ }
465
+ async AdsUnitGet(app_id ,platform ){
466
+ return this.request('ads/unit/get', {app_id ,platform
467
+ });
468
+ }
469
+ async ApsInfoGet(node_name ){
470
+ return this.request('aps/info/get', {node_name
471
+ });
472
+ }
473
+ async FileSetParent(stored_file_id ,parent_page_key ){
474
+ return this.request('woololo/file/set.parent', {stored_file_id ,parent_page_key
475
+ });
476
+ }
477
+ async LocalizationVariablesGet(package_name ,language ){
478
+ return this.request('localization/variables/get', {package_name ,language
479
+ });
480
+ }
481
+
482
+
483
+ }
484
+
485
+ export default WoololoApiClient;
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "node-woololo-api-client",
3
+ "version": "1.0.24",
4
+ "description": "",
5
+ "main": "lib/woololo-api-client.js",
6
+ "scripts": {
7
+ "start": "node index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git@git.behind.ai:henry/node-woololo-api-client.git"
12
+ },
13
+ "type": "module",
14
+ "author": "",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "axios": "^1.2.0"
18
+ },
19
+ "publishConfig": {
20
+ "@henry:registry": "http://gitlab.behind.ai/api/v4/projects/84/packages/npm/"
21
+ }
22
+ }