Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@siyuan-community/siyuan-sdk
Advanced tools
A simple and easy to use SDK for SiYuan Note.
Using npm:
$ npm install @siyuan-community/siyuan-sdk
Using pnpm:
$ pnpm i @siyuan-community/siyuan-sdk
Using yarn:
$ yarn add @siyuan-community/siyuan-sdk
import { Client } from "siyuan-sdk";
/* Initialize the client */
const client = new Client({
/**
* (Optional) SiYuan kernel service URL
* @default: document.baseURI
*/
baseURL: "http://localhost:6806/",
/**
* (Optional) SiYuan kernel service token
* @default: empty
*/
token: "0123456789abcdef", // , default is empty
/**
* (Optional) HTTP request timeout
* Unit: milliseconds (ms)
* @default: 60_000
*/
timeout: 10_000,
/**
* (Optional) Other Axios request configurations
* REF: https://axios-http.com/zh/docs/req_config
* REF: https://www.axios-http.cn/docs/req_config
*/
});
client.updateOptions({
timeout: 30_000, // Change HTTP request timeout to 30 seconds
});
import { KernelError, HTTPError } from "siyuan-sdk";
async function func() {
try {
/**
* Asynchronously call the Kernel API `/api/notification/pushMsg`
* Push notification message
*/
const response = await client.pushMsg({
msg: "This is a notification message", // Notification content
timeout: 7_000, // Notification display time
});
console.log(response); // { "code": 0, "msg": "", "data": { "id": "0a1b2c3" } }
}
catch (error) {
if (error instanceof KernelError) { // Kernel error
console.error(error.body); // Response body { "code": -1, "msg": "error message", "data": null }
}
else if (error instanceof HTTPError) { // HTTP request error
console.error(error.status); // HTTP status code
}
else { // Other uncaught errors
throw error;
}
}
finally {
/* ... */
}
}
import { KernelError, HTTPError } from "siyuan-sdk";
function func() {
/**
* Asynchronously call the Kernel API `/api/notification/pushErrMsg`
* Push error message
*/
client
.pushErrMsg({
msg: "This is an error message", // Notification content
timeout: 7_000, // Notification display time
})
.then((response) => {
console.log(response); // { "code": 0, "msg": "", "data": { "id": "0a1b2c3" } }
})
.catch((error) => {
if (error instanceof KernelError) { // Kernel error
console.error(error.body); // Response body { "code": -1, "msg": "error message", "data": null }
}
else if (error instanceof HTTPError) { // HTTP request error
console.error(error.status); // HTTP status code
}
else { // Other uncaught errors
throw error;
}
})
.finally(() => {
/* ... */
});
}
import { types } from "@siyuan-community/siyuan-sdk";
const payload: types.kernel.api.notification.pushMsg.IPayload = {
msg: "This is a notification message", // Notification content
timeout: 7_000, // Notification display time
};
import pushMsg from "@siyuan-community/siyuan-sdk/dist/src/types/kernel/api/notification/pushMsg";
const payload: pushMsg.IPayload = {
msg: "This is a notification message", // Notification content
timeout: 7_000, // Notification display time
};
v0.1.0 / 2023-07-02
FAQs
A simple and easy to use SDK for SiYuan.
The npm package @siyuan-community/siyuan-sdk receives a total of 11 weekly downloads. As such, @siyuan-community/siyuan-sdk popularity was classified as not popular.
We found that @siyuan-community/siyuan-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.