New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

siyuan_api_cache_lib

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

siyuan_api_cache_lib - npm Package Compare versions

Comparing version

to
1.0.1

6

dist/cache/api-cache.js

@@ -8,8 +8,8 @@ import { config } from "../config";

* 参数以及返回值需要可使用 JSON.stringify
* @param f
* @returns
*/
function cache(f) {
return (async (...arg) => {
if (config.apiCache && getCurrentEnv() === getCurrentEnv.env.siYuan) {
if (config.apiCache &&
!f.noCache &&
getCurrentEnv() === getCurrentEnv.env.siYuan) {
const r = await f(...arg);

@@ -16,0 +16,0 @@ const id = currentNodeId();

import * as siYuanApi from "./siyuan-api/index";
/** 这里面是对于思源一些 api 的包装 */
/**
* 这里面是对于思源一些 api 的包装
* 查询类的 api 默认会进行缓存,非查询类的 api 则不会,可以通过查看函数的 noCache 属性来分辨
* (非查询类的 api 如果进行 cache 很容易导致过多的数据被缓存到挂件块的自定义属性,查询类的 api 也需要使用者自行斟酌,)
*/
export declare const api: typeof siYuanApi;

@@ -4,0 +8,0 @@ /** 一些工具方法 */

import { cacheWarp } from "./cache/api-cache";
import * as siYuanApi from "./siyuan-api/index";
/** 这里面是对于思源一些 api 的包装 */
/**
* 这里面是对于思源一些 api 的包装
* 查询类的 api 默认会进行缓存,非查询类的 api 则不会,可以通过查看函数的 noCache 属性来分辨
* (非查询类的 api 如果进行 cache 很容易导致过多的数据被缓存到挂件块的自定义属性,查询类的 api 也需要使用者自行斟酌,)
*/
export const api = cacheWarp(siYuanApi);

@@ -5,0 +9,0 @@ /** 一些工具方法 */

import type { attrRow } from "./type";
/**
* 此函数默认不被 cache
*/
export declare function setBlockAttrs(p: {

@@ -13,2 +16,5 @@ /** 挂件块 ID */

}>;
export declare namespace setBlockAttrs {
let noCache: boolean;
}
/**

@@ -24,1 +30,4 @@ * 查询块属性

}>;
export declare namespace getBlockAttrs {
let noCache: boolean;
}

@@ -6,2 +6,5 @@ import { htmlDecode } from "../util/index";

htmlDecode.toString();
/**
* 此函数默认不被 cache
*/
export function setBlockAttrs(p) {

@@ -11,2 +14,5 @@ const raw = JSON.stringify(p);

}
(function (setBlockAttrs) {
setBlockAttrs.noCache = true;
})(setBlockAttrs || (setBlockAttrs = {}));
/**

@@ -20,1 +26,4 @@ * 查询块属性

}
(function (getBlockAttrs) {
getBlockAttrs.noCache = false;
})(getBlockAttrs || (getBlockAttrs = {}));

@@ -9,1 +9,4 @@ /**

}>;
export declare namespace sqlQuery {
let noCache: boolean;
}

@@ -11,1 +11,4 @@ import { fetch_proxy } from "../util/fetch-aop";

}
(function (sqlQuery) {
sqlQuery.noCache = false;
})(sqlQuery || (sqlQuery = {}));
{
"name": "siyuan_api_cache_lib",
"version": "1.0.0",
"version": "1.0.1",
"description": "为思源挂件块提供 api 访问的工具库,同时具有缓存 api 调用结果到块属性上以及在非思源笔记环境下使用缓存结果的功能",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -13,2 +13,6 @@ # siyuan_api_cache_lib

- getBlockAttrs : 对 /api/attr/getBlockAttrs 接口的包装
查询类的 api 默认会进行缓存,非查询类的 api 则不会,可以通过查看函数的 noCache 属性来分辨,这个属性也是可以 set 的
(查询类的 api 也需要使用者自行斟酌避免过多的数据被缓存到挂件块的自定义属性)
- util

@@ -28,3 +32,3 @@ - htmlDecode : 思源对于 setBlockAttrs 的属性会 encode ,所以提供此工具方法

配置 iframe 的资源链接为 `http://127.0.0.1/widget/run-code/` (run-code 是我在开发的插件 [github.com/run-code](https://github.com/2234839/run-code),建议查看这个项目里面对本库的使用方式)
配置 iframe 的资源链接为 `http://127.0.0.1/widgets/run-code/` (run-code 是我在开发的插件 [github.com/run-code](https://github.com/2234839/run-code),建议查看这个项目里面对本库的使用方式)

@@ -44,4 +48,4 @@ 对于在思源中的开发调试建议采用 nginx 进行如下配置,然后使用思源的在浏览器中打开,在这里进行开发调试

}
location /widget/run-code/ {
#// run-code 所启动的服务, run-code 还配置了 base 路径为 /widget/run-code/
location /widgets/run-code/ {
#// run-code 所启动的服务, run-code 还配置了 base 路径为 /widgets/run-code/
proxy_pass http://127.0.0.1:3000;

@@ -65,3 +69,3 @@ proxy_set_header Host $host;

}
location /widget/run-code/ {
location /widgets/run-code/ {
proxy_pass http://127.0.0.1:3000;

@@ -68,0 +72,0 @@ proxy_set_header Host $host;