1.1.91 • Published 2 months ago

@gudhub/core v1.1.91

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
2 months ago

GudHub logo

npm version npm version

npm version npm downloads

GUDHUB

I't a Library to simplify work with GudHub API. Also this Library contains utilities for better operation with items, fields and apps!

npm Package

The package name is @gudhub/core. This is a private package, so the .npmrc file must be in the root folder in order to load it from npm. This means that if you have @gudhub/core in package.json for GudHubClient, the .npmrc file should be in the root folder too.

Publishing gudhub lib to npm

In order to publish new version of the GudHub Lib you have to:

  1. Change version in package.json
  2. Commit your changes into repository to the master branch
  3. Run npm publish command which will publish new version to npm

Development gudhub lib

If you want to develop the GudHub Lib in another environment, say in GudHubClient, you need to do the following:

  1. You should go to the gudhub folder and run there npm init @gudhub/core command, it will install the @gudhub/core package in to your global environment
  2. Then you have to add @gudhub/core to your package.json as a dependency.
  3. Then package will be downloaded from your local computer after you run npm run dev or npm install command

Initialization

There are several ways to initialize GudHub. The most simple way is initializing gudhub without arguments. In this case only the utils will be available.

import {GudHub} from '@gudhub/core';
const gudhub = new GudHub();

The second way is initialization GudHub with authorization key. It's the most common way for using GudHub in your project. You just need to pass auth_key as argument. In this case you will be able to work with GudHub data and use all the methods listed below.

import {GudHub} from '@gudhub/core';
const auth_key = 'JLKHKJSKJhkjsclkdjcijIOIoiuSTg';
const gudhub = new GudHub(auth_key);

The third way is initialization GudHub with additional parameters. It's useful for development server app on Node.js and for testing on local server. In the example below you can see how to initialize GudHub (in the example you can see default params).

import {GudHub} from '@gudhub/core';
const auth_key = 'JLKHKJSKJhkjsclkdjcijIOIoiuSTg';
const gudhub = new GudHub(auth_key,{
    server_url : "https://gudhub.com/GudHub", 
    wss_url : "wss://gudhub.com/GudHub/ws/app/", 
    initWebsocket : false
});
Param NameDescriptionDefault Value
server_urlAll request will send to this urlhttps://gudhub.com/GudHub
wss_urlurl to setup websoket connectionwss://gudhub.com/GudHub/ws/app/
initWebsockethere we can turn off websoket connectionfalse

Utils

jsonConstructor()

With this method you can get json according to the scheme.

gudhub.jsonConstructor(scheme, item, variables)

Read more information about jsonConstructor on GudHub.

jsonToItems()

This method converts json to gudhub items. The conversion is made based on fieldMap. After generating items, you can send them to create new items.

gudhub.jsonToItems(json, fieldsMap);

Read more information about jsonConstructor on GudHub.

populateWithItemRef()

This method updates destination items with item_ref of source items. The connection between sorceItemsRef & srcFieldIdToCompare is checked with srcFieldIdToCompare & destFieldIdToCompare. After connection is detected we save the item_ref into destFieldForRef.

gudhub.populateWithItemRef(sorceItemsRef, srcFieldIdToCompare, destinationItems, destFieldIdToCompare, destFieldForRef, APPID)

Read more information about populateWithItemRef on GudHub.

mergeItems()

The current method replaces all fields with values in destinationItems by values from sorceItems. If destinationItems does not have the fields that sorceItems has, they will be created in destinationItems.

gudhub.mergeItems(sorceItems, destinationItems, mergeByFieldId);

Read more information about mergeItems on GudHub.

compareItems()

This method compare fields of sorceItems with fields of destinationItems. This means that if sorceItems has the same fields with the same values as destinationItems, they will be described as 'same_items' even if destinationItems has additional fields that sorceItems does not have.

gudhub.compareItems(sorceItems, destinationItems, fieldToCompare);

Read more information about compareItems on GudHub.

getDate()

This method will return a date according to specified namespace. The name space should be in string format

gudhub.getDate(date_type);

Read more information about getDate on GudHub.

makeNestedList()

This method creates the list of fields with infinite nesting. It takes an array of fields and depends of their IDs makes attachments for each of them.

gudhub.makeNestedList(arr, 'id', 'parent_id', 'children_property', 'priority')

Read more information about makeNestedList on GudHub.

App Processor

getAppInfo()

This is the method that returns application with empty arrays: field_list, items_list, file_list, views_list. Such simple data needed to render App Icons, and do some simple updates in App like: updating App name icon permissions etc when full app data is not needed

gudhub.getAppInfo(app_id);

Read more information about getAppInfo on GudHub.

getApp()

This method is called to get an application by its ID specified as an argument.

gudhub.getApp(app_id);

Read more information about getApp on GudHub.

getAppsList()

This method is called after logging in to get a list of user`s applications. It has no arguments. getAppList return list of applications that are shared to users.

gudhub.getAppsList();

Read more information about getApp on GudHub.

Authentication

login()

This method is used for getting access to the account. It can be called with login and password or the authentication key with or without additional parameters.

gudhub.login(data);

Read more information about login on GudHub.

logout()

This method is used when the user logs out of his/her account.

gudhub.logout(token);

Read more information about logout on GudHub.

signup()

This method is used to register a user account in GudHub.

gudhub.signup(user);

Read more information about signup on GudHub.

getUserById()

This method gets user from user list who have access to the application.

gudhub.getUserById(userId);

Read more information about getUserById on GudHub.

getUsersList()

This method is called during the search for users to share. Namely, when you enter a keyword into the search box, GudHub displays all users whose names match that word.

gudhub.getUsersList(keyword);

Read more information about getUsersList on GudHub.

updateUser()

This is the method used to update user account data.

gudhub.updateUser(userData);

Read more information about updateUser on GudHub.

getToken()

This method is used to get the current token.

gudhub.getToken();

Read more information about getToken on GudHub.

updateToken()

This method is called when the token is updated.

gudhub.updateToken(auth_key)

Read more information about updateToken on GudHub.

updateAvatar()

This method is used when user changes his photo of the account.

gudhub.updateAvatar(imageData);

Read more information about updateAvatar on GudHub.

getUserFromStorage()

This method is used for getting needed user from the user list during sharing.

gudhub.getUserFromStorage(id);

Read more information about getUserFromStorage on GudHub.

saveUserToStorage()

This method allows you to add new user to the user list.

gudhub.saveUserToStorage(saveUser);

Read more information about saveUserToStorage on GudHub.

getVersion()

Use this method to to find out the current version of the GudHub.

gudhub.getVersion();

Read more information about getVersion on GudHub.

Items Processor

getItems()

This method is used to get the items of the current application.

await gudhub.getItems(app_id, trash);

Read more information about getItems on GudHub.

addNewItems()

Use this method to add new items to the items list.

await gudhub.addNewItems(app_id, itemsList);

Read more information about addNewItems on GudHub.

updateItems()

This method is used to update certain items.

await gudhub.updateItems(app_id, itemsList);

Read more information about updateItems on GudHub.

deleteItems()

Due to this method you can delete one and more items from thee application.

await gudhub.deleteItems(app_id, itemsIds);

Read more information about deleteItems on GudHub.

Field Processor

getField()

Due to this method you can get field from the relevant application.

await gudhub.getField(app_id, field_id);

Read more information about getField on GudHub.

updateField()

This method allows you to update field model of the current application.

await gudhub.updateField(app_id, fieldModel);

Read more information about updateField on GudHub.

deleteField()

The method is created for deleting field from the application.

await gudhub.deleteField(app_id, field_id);

Read more information about deleteField on GudHub.

getFieldModels()

This method is used for getting a list of field models.

await gudhub.getFieldModels(app_id);

Read more information about getFieldModels on GudHub.

getFieldValue()

This method is responsible for getting the value from the desired field.

await gudhub.getFieldValue(app_id, item_id, field_id);

Read more information about getFieldValue on GudHub.

setFieldValue()

This method is called to set value in the desired field.

await gudhub.setFieldValue(app_id, item_id, field_id, field_value);

Read more information about setFieldValue on GudHub.

File Processor

getFile()

This method is called to get file from the application.

gudhub.getFile(app_id, file_id);

Read more information about getFile on GudHub.

getFiles()

This method is called for getting a list of files from current application.

gudhub.getFiles(app_id, filesId);

Read more information about getFiles on GudHub.

uploadFile()

The current method allows to upload files. It transfers the file through the form.

await gudhub.uploadFile(fileData, app_id, file_id)

Read more information about uploadFile on GudHub.

uploadFileFromString()

This is the method that allows to upload different files in base64 format to the application.

await gudhub.uploadFileFromString(fileObject);

Read more information about uploadFileFromString on GudHub.

isFileExists()

Due to this method you can check whether the file with the following ID exists in such an application.

await gudhub.isFileExists(app_id, file_id)

Read more information about isFileExists on GudHub.

updateFileFromString()

The current method allows to update the data and name of the certain file.

await gudhub.updateFileFromString(data, file_id, file_name, extension, format)

Read more information about updateFileFromString on GudHub.

duplicateFile()

This method is used to create the duplicate of the file.

await gudhub.duplicateFile(files)

Read more information about duplicateFile on GudHub.

downloadFileFromString()

Use this method to download the file from the fil list.

await gudhub.downloadFileFromString(app_id,file_id)

Read more information about downloadFileFromString on GudHub.

deleteFile()

Due to this method files can be deleted from the application.

gudhub.deleteFile(app_id, file_id);

Read more information about deleteFile on GudHub.

Document Processor

createDocument()

This method is called for creating a new document in the certain application.

gudhub.createDocument(documentObject);

Read more information about createDocument on GudHub.

getDocument()

The method for getting needed document from the applications documents list.

gudhub.getDocument(documentAddress);

Read more information about getDocument on GudHub.

getDocuments()

This method is called to get array of documents from the application.

gudhub.getDocuments(documentsAddresses);

Read more information about getDocuments on GudHub.

deleteDocument()

Due to this method you can delete document from the application.

gudhub.deleteDocumentApi(documentAddress);

Read more information about deleteDocument on GudHub.

PipeService

on()

This is the method that is called for getting subscription.

gudhub.on(event, address, myFunction);

Read more information about On on GudHub.

emit()

This is the method that is used by GudHub itself. It is called for getting existing subscription.

gudhub.on(event, address, myFunction);

Read more information about Emit on GudHub.

destroy()

This method exists for ruining extra subscriptions and for optimization the process.

gudhub.destroy('gh_app_views_update', address, myFunction);

Read more information about Destroy on GudHub.

1.1.91

2 months ago

1.1.90

4 months ago

1.1.89

4 months ago

1.1.88

4 months ago

1.1.87

4 months ago

1.1.86

4 months ago

1.1.85

5 months ago

1.1.84

5 months ago

1.1.70

10 months ago

1.1.74

8 months ago

1.1.73

8 months ago

1.1.72

9 months ago

1.1.71

10 months ago

1.1.78

7 months ago

1.1.77

7 months ago

1.1.76

8 months ago

1.1.75

8 months ago

1.1.79

7 months ago

1.1.81

6 months ago

1.1.80

6 months ago

1.1.83

5 months ago

1.1.82

5 months ago

1.1.67

10 months ago

1.1.69

10 months ago

1.1.68

10 months ago

1.1.66

11 months ago

1.1.59

12 months ago

1.1.58

12 months ago

1.1.63

11 months ago

1.1.62

11 months ago

1.1.61

11 months ago

1.1.60

11 months ago

1.1.65

11 months ago

1.1.64

11 months ago

1.1.49

1 year ago

1.1.48

1 year ago

1.1.47

1 year ago

1.1.52

1 year ago

1.1.51

1 year ago

1.1.50

1 year ago

1.1.56

1 year ago

1.1.55

1 year ago

1.1.54

1 year ago

1.1.53

1 year ago

1.1.57

1 year ago

1.1.38

1 year ago

1.1.37

1 year ago

1.1.39

1 year ago

1.1.41

1 year ago

1.1.40

1 year ago

1.1.45

1 year ago

1.1.44

1 year ago

1.1.43

1 year ago

1.1.42

1 year ago

1.1.46

1 year ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.30

1 year ago

1.1.34

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.1.31

1 year ago

1.1.36

1 year ago

1.1.35

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.1

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.1.12

2 years ago

1.0.66

2 years ago

1.1.11

2 years ago

1.0.65

2 years ago

1.1.10

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.69

2 years ago

1.0.68

2 years ago

1.1.13

2 years ago

1.0.67

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.51

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.57

2 years ago

1.0.56

2 years ago

1.0.49

2 years ago

1.0.50

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.40

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago