@gudhub/core

中文文档
1.1.162发布于 2026/10/09ISCES Module近 30 天下载 9.5万
原始使用文档
文档目录61 节
  1. npm Package
  2. Publishing gudhub lib to npm
  3. Development gudhub lib
  4. Initialization
  5. Utils
  6. jsonConstructor()
  7. jsonToItems()
  8. populateWithItemRef()
  9. mergeItems()
  10. compareItems()
  11. getDate()
  12. makeNestedList()
  13. App Processor
  14. getAppInfo()
  15. getApp()
  16. getAppsList()
  17. Authentication
  18. login()
  19. logout()
  20. signup()
  21. getUserById()
  22. getUsersList()
  23. getUserWorkspace()
  24. updateUser()
  25. getToken()
  26. updateToken()
  27. updateAvatar()
  28. getUserFromStorage()
  29. saveUserToStorage()
  30. getVersion()
  31. Items Processor
  32. getItems()
  33. addNewItems()
  34. updateItems()
  35. deleteItems()
  36. Field Processor
  37. getField()
  38. updateField()
  39. deleteField()
  40. getFieldModels()
  41. getFieldValue()
  42. setFieldValue()
  43. File Processor
  44. getFile()
  45. getFiles()
  46. uploadFile()
  47. uploadFileFromString()
  48. isFileExists()
  49. updateFileFromString()
  50. duplicateFile()
  51. downloadFileFromString()
  52. deleteFile()
  53. Document Processor
  54. createDocument()
  55. getDocument()
  56. getDocuments()
  57. deleteDocument()
  58. PipeService
  59. on()
  60. emit()
  61. destroy()

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://app.gudhub.com/GudHub", 
    wss_url : "wss://app.gudhub.com/GudHub/ws/app/", 
    initWebsocket : false
});
Param NameDescriptionDefault Value
server_urlAll request will send to this urlhttps://app.gudhub.com/GudHub
wss_urlurl to setup websoket connectionwss://app.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.

getUserWorkspace()

This method is used to get the list of users belonging to the current user's workspace. Returned users are cached in storage.

gudhub.getUserWorkspace();

Read more information about getUserWorkspace 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.

版本与发布记录

@gudhub/core 共发布 256 个版本,首次发布于 2021/12/02;过去 12 个月发布了 50 个版本。

版本发布日期距今
1.1.162latest2026/10/091 个月前
1.1.1612026/10/061 个月前
1.1.1602026/09/291 个月前
1.1.1592026/09/291 个月前
1.1.1582026/09/231 个月前
1.1.1572026/09/132 个月前

其他发布通道:beta-vlad → 1.2.5-beta.1,beta → 1.2.4-beta.63。

关于 @gudhub/core 的常见问题

如何安装 @gudhub/core?

在项目目录运行 npm install @gudhub/core,或使用 pnpm add / yarn add / bun add。

@gudhub/core 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gudhub__core 是否存在。

@gudhub/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gudhub/core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js 22.22.2。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gudhub/core 可以商用吗?

@gudhub/core 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gudhub/core 的下载量有多少?

根据 npm 官方下载统计,@gudhub/core 在 2026/10/17 – 2026/11/15 这 30 天内被下载 95,188 次,日均约 3,173 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gudhub/core 还在维护吗?

最新版本 1.1.162 发布于 2026/10/09(1 个月前);至今共发布 256 个版本,其中过去 12 个月发布了 50 个;首次发布于 2021/12/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。