Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
API Reference

Types & Enums


This section provides a comprehensive reference for all TypeScript types and enumerations (enums) utilized across the Blocklet SDK. Understanding these definitions is fundamental for effectively interacting with Blocklet Server, managing data, and building robust decentralized applications.

For details on the SDK's core functionalities that leverage these types, refer to the Core Services section.

Enumerations#

Enums define a set of named constants, making your code more readable and less prone to errors when dealing with specific states or categories.

StatusCodeMap#

Represents common status codes for RPC responses.

Name

Value

Description

OK

0

Operation successful.

BLOCKLET_NOT_FOUND

1

Blocklet not found.

BLOCKLET_NOT_PURCHASED

2

Blocklet not purchased.

FORBIDDEN

403

Access forbidden.

INTERNAL

500

Internal server error.

TIMEOUT

504

Request timed out.

BlockletStatusMap#

Defines the lifecycle statuses of a Blocklet.

Name

Value

Description

ADDED

0

Blocklet added.

DOWNLOADING

1

Blocklet is downloading.

DOWNLOADED

2

Blocklet has been downloaded.

INSTALLING

3

Blocklet is installing.

INSTALLED

4

Blocklet has been installed.

STARTING

5

Blocklet is starting.

RUNNING

6

Blocklet is running.

STOPPING

7

Blocklet is stopping.

STOPPED

8

Blocklet has been stopped.

ERROR

9

An error occurred with the Blocklet.

UPGRADING

10

Blocklet is upgrading.

RESTARTING

11

Blocklet is restarting.

CORRUPTED

12

Blocklet data is corrupted.

WAITING

13

Blocklet is waiting.

DELETED

14

Blocklet has been deleted.

UNKNOWN

15

Blocklet status is unknown.

BlockletSourceMap#

Indicates where a Blocklet originated from.

Name

Value

Description

REGISTRY

0

From a Blocklet Store registry.

LOCAL

1

From local storage.

UPLOAD

2

Uploaded by user.

URL

3

From a direct URL.

CUSTOM

4

Custom source.

HeaderMatchTypeMap#

Specifies how HTTP headers should be matched in routing rules.

Name

Value

Description

EXACT

0

Exact match.

PARTIAL

1

Partial match.

REGEXP

2

Regular expression match.

BackendServiceTypeMap#

Defines the type of backend service for routing.

Name

Value

Description

DAEMON

0

Daemon service.

BLOCKLET

1

Blocklet service.

REDIRECT

2

Redirect to another URL.

NONE

3

No backend service.

GENERAL_PROXY

4

General proxy.

DIRECT_RESPONSE

5

Direct response.

REWRITE

6

URL rewrite.

COMPONENT

7

Internal component.

PublishTypeMap#

Defines the type of publication for projects.

Name

Value

Description

RESOURCE

0

Resource publication.

PACK

1

Pack publication.

ReleaseStatusMap#

Defines the status of a project release.

Name

Value

Description

DRAFT

0

Release is a draft.

PUBLISHED

1

Release is published.

NotificationAttachmentTypeMap#

Defines the various types of attachments that can be included in a notification.

Name

Value

Description

ASSET

0

Digital asset attachment.

VC

1

Verifiable Credential attachment.

TOKEN

2

Token attachment.

TEXT

3

Plain text attachment.

IMAGE

4

Image attachment.

DIVIDER

5

Visual divider.

TRANSACTION

6

Blockchain transaction details.

DAPP

7

Decentralized application (DApp) link.

LINK

8

General URL link.

SECTION

9

A section containing other attachments.

NotificationSourceMap#

Defines the source of a notification.

Name

Value

Description

SYSTEM

0

Notification originated from the system.

COMPONENT

1

Notification originated from a Blocklet component.

NotificationTypeMap#

Defines the general type of a notification for display or processing purposes.

Name

Value

Description

NOTIFICATION

0

Standard informative notification.

CONNECT

1

Connection-related notification (e.g., DID Connect).

FEED

2

Notification for a feed item.

HI

3

Welcome or greeting notification.

PASSTHROUGH

4

Generic passthrough notification.

NotificationSeverityMap#

Defines the severity level of a notification.

Name

Value

Description

INFO

0

Informational message.

SUCCESS

1

Success message.

ERROR

2

Error message.

WARNING

3

Warning message.

ActivityTypeEnumMap#

Defines types of user activities within the notification system.

Name

Value

Description

COMMENT

0

User activity is a comment.

LIKE

1

User activity is a like.

FOLLOW

2

User activity is a follow.

TIPS

3

User activity is a tip/donation.

MENTION

4

User activity is a mention.

ASSIGN

5

User activity is an assignment.

UN_ASSIGN

6

User activity is an un-assignment.

Types#

Types define the structure of data objects used throughout the Blocklet SDK. They are crucial for understanding the data models when making API calls or processing responses.

TNodeState#

Represents the overall state of the Blocklet Server.

Property

Type

Description

did

string

Decentralized Identifier of the server.

pk

string

Public key of the server.

version

string

Version of the Blocklet Server.

name

string

Name of the Blocklet Server.

description

string

Description of the Blocklet Server.

port

string

Port the server is running on.

initialized

boolean

Indicates if the server has been initialized.

nodeOwner

TWalletInfo

Information about the server's owner wallet.

createdAt

number

Timestamp of server creation.

status

number

Current operational status of the server.

blockletRegistryList

TBlockletStore[]

List of connected Blocklet Stores.

diskAlertThreshold

number

Disk usage threshold for alerts.

trustedPassports

TTrustedPassport[]

List of trusted passports.

runtimeConfig

TNodeRuntimeConfig

Runtime configuration of the server.

TBlockletState#

Describes the current state and configuration of a specific Blocklet instance.

Property

Type

Description

meta

TBlockletMeta

Metadata of the Blocklet.

status

BlockletStatusMap

Current status of the Blocklet (e.g., RUNNING, STOPPED).

createdAt

number

Timestamp when the Blocklet was created.

installedAt

number

Timestamp when the Blocklet was installed.

environments

TConfigEntry[]

Environmental configurations for the Blocklet.

configs

TConfigEntry[]

Runtime configurations for the Blocklet.

diskInfo

TDiskInfo

Disk usage information for the Blocklet.

runtimeInfo

TRuntimeInfo

Runtime performance metrics (CPU, memory).

port

number

The port the Blocklet is exposed on.

children

TComponentState[]

States of child components.

mountPoint

string

The URL path where the Blocklet is mounted.

settings

TBlockletSettings

User-configurable settings for the Blocklet.

appDid

string

The DID of the Blocklet application.

enableDocker

boolean

Indicates if Docker is enabled for the Blocklet.

TBlockletState

TBlockletMeta

TRuntimeInfo

TDiskInfo

TConfigEntry

TComponentState

TOptionalComponentState

TBlockletSettings


TBlockletMeta#

Contains descriptive information about a Blocklet, typically found in its blocklet.yml or package.json.

Property

Type

Description

did

string

The DID of the Blocklet.

name

string

The package name of the Blocklet.

version

string

The version of the Blocklet.

description

string

A brief description of the Blocklet.

title

string

Display title of the Blocklet.

interfaces

TBlockletMetaInterface[]

Defines the external interfaces (e.g., web, API endpoints).

author

TBlockletMetaPerson

Author information.

homepage

string

Project homepage URL.

logo

string

URL to the Blocklet's logo.

capabilities

TBlockletCapabilities

Features and capabilities supported by the Blocklet.

environments

TEnvironment[]

Environment variables the Blocklet uses.

requirements

TRequirement

System requirements for running the Blocklet.

docker

TBlockletDockerMeta

Docker-specific metadata if applicable.

TConfigEntry#

Represents a key-value configuration entry, often used for environment variables or settings.

Property

Type

Description

key

string

The configuration key.

value

string

The configuration value.

required

boolean

Indicates if the configuration is mandatory.

description

string

A description of the configuration entry.

secure

boolean

If true, the value should be treated as sensitive.

custom

boolean

If true, the config is user-defined.

shared

boolean

If true, the config is shared across components.

TUserInfo#

Details information about a user on the Blocklet Server.

Property

Type

Description

did

string

The DID of the user.

pk

string

The public key of the user.

role

string

The role assigned to the user.

avatar

string

URL to the user's avatar image.

fullName

string

The full name of the user.

email

string

The email address of the user.

approved

boolean

Indicates if the user account is approved.

createdAt

number

Timestamp of user creation.

lastLoginAt

number

Timestamp of the user's last login.

connectedAccounts

TConnectedAccount[]

List of connected external accounts.

tags

TTag[]

Tags associated with the user.

emailVerified

boolean

Indicates if the user's email is verified.

phoneVerified

boolean

Indicates if the user's phone is verified.

metadata

TUserMetadata

Additional user metadata like bio, location, etc.

address

TUserAddress

User's physical address.

TNotification#

Represents a notification object that can be sent to users or channels.

Property

Type

Description

sender

string

The DID of the sender.

receiver

string

The DID of the primary receiver.

title

string

The title of the notification.

description

string

The main body/description of the notification.

action

string

A primary action associated with the notification.

entityType

string

The type of entity the notification relates to.

entityId

string

The ID of the entity the notification relates to.

read

boolean

Indicates if the notification has been read.

createdAt

number

Timestamp of notification creation.

id

string

Unique identifier for the notification.

severity

Notification.NotificationSeverityMap

The severity level (INFO, WARNING, ERROR, SUCCESS).

source

Notification.NotificationSourceMap

The source of the notification (SYSTEM, COMPONENT).

attachments

TNotificationAttachment[]

List of attachments included in the notification.

actions

TNotificationAction[]

List of actions users can take from the notification.

componentDid

string

The DID of the component sending the notification.

type

Notification.NotificationTypeMap

The type of notification (NOTIFICATION, CONNECT, FEED, HI, PASSTHROUGH).

receivers

TNotificationReceiver[]

Detailed information about all receivers.

data

Record<string, any>

Generic data associated with the notification.

feedType

string

Specific type for feed notifications.

statistics

TNotificationStatistics

Statistics related to notification delivery.

activity

TNotificationActivity

Activity details for activity-based notifications.

actorInfo

TUserInfo

Information about the actor in activity notifications.

TRoutingSite#

Defines a routing configuration for a specific domain.

Property

Type

Description

id

string

Unique identifier for the routing site.

domain

string

The primary domain for this site.

domainAliases

Record<string, any>[]

Aliases for the domain.

rules

TRoutingRule[]

A list of routing rules for this site.

isProtected

boolean

Indicates if the site is protected.

corsAllowedOrigins

string[]

List of allowed CORS origins.

TAccessKey#

Represents an access key for authenticating API requests.

Property

Type

Description

accessKeyId

string

The public ID of the access key.

accessKeyPublic

string

The public key associated with the access key.

remark

string

A human-readable remark for the key.

passport

string

The passport DID associated with the key's permissions.

createdAt

number

Timestamp of key creation.

updatedAt

number

Timestamp of last update.

lastUsedAt

number

Timestamp of last usage.

createdBy

string

The DID of the creator.

authType

string

The authentication type (e.g., simple).

componentDid

string

The DID of the component the key is for.

resourceType

string

The type of resource the key can access.

resourceId

string

The ID of the resource the key can access.

expireAt

number

Timestamp when the key expires.

TProject#

Represents a Blocklet project, used for development and publishing.

Property

Type

Description

id

string

Unique identifier for the project.

type

PublishTypeMap

The type of publication (RESOURCE, PACK).

blockletDid

string

The DID of the Blocklet associated with the project.

blockletVersion

string

The version of the Blocklet.

blockletTitle

string

Display title of the Blocklet in the project.

blockletDescription

string

Description of the Blocklet.

blockletLogo

string

URL to the Blocklet's logo.

createdAt

string

Timestamp of project creation.

updatedAt

string

Timestamp of last update.

componentdid

string

The component DID associated with the project.

connectedStores

TConnectedStore[]

List of connected Blocklet Stores.

tenantScope

string

The tenant scope of the project.

autoUpload

boolean

Indicates if automatic upload is enabled.

connectedEndpoints

TConnectedEndpoint[]

List of connected endpoints.

TRelease#

Represents a specific release version of a Blocklet project.

Property

Type

Description

id

string

Unique identifier for the release.

projectId

string

The ID of the parent project.

blockletDid

string

The DID of the Blocklet for this release.

blockletVersion

string

The version of the Blocklet for this release.

blockletTitle

string

Display title for this release.

note

string

Release notes/changelog.

files

string[]

List of files included in the release.

status

ReleaseStatusMap

The status of the release (DRAFT, PUBLISHED).

createdAt

string

Timestamp of release creation.

updatedAt

string

Timestamp of last update.

blockletComponents

TReleaseComponent[]

List of components included in this release.

publishedStoreIds

string[]

IDs of stores where this release is published.

uploadedResource

string

URL or path to the uploaded resource.

blockletDocker

TBlockletDocker

Docker configuration for the Blocklet.

TBlockletSecurityRule#

Defines a security rule for Blocklet access and response headers.

Property

Type

Description

id

string

Unique identifier for the rule.

pathPattern

string

URL path pattern for the rule.

componentDid

string

The component DID to which the rule applies.

priority

number

Priority of the rule (lower is higher priority).

responseHeaderPolicyId

string

ID of the linked response header policy.

accessPolicyId

string

ID of the linked access policy.

enabled

boolean

Indicates if the rule is active.

remark

string

An optional remark for the rule.

accessPolicy

TBlockletAccessPolicy

Details of the associated access policy.

responseHeaderPolicy

TBlockletResponseHeaderPolicy

Details of the associated response header policy.

TWebhookEndpointState#

Represents the state of a registered Webhook endpoint.

Property

Type

Description

id

string

Unique identifier for the webhook endpoint.

apiVersion

string

The API version used by the endpoint.

url

string

The URL where webhook events are sent.

description

string

A description of the endpoint.

enabledEvents

TEnableEvent[]

List of event types enabled for this endpoint.

metadata

Record<string, any>

Additional metadata.

status

string

Current status of the endpoint.

createdAt

number

Timestamp of creation.

updatedAt

number

Timestamp of last update.

These definitions provide the building blocks for understanding and interacting with the Blocklet SDK's various functionalities. By familiarizing yourself with these types, you can ensure your applications handle data correctly and robustly.

To see how these types are used in practice, proceed to the GraphQL Client section for examples of data querying and manipulation.