@blocklet/sdk 1.16.42-beta-20250408-072924-4b6a877a → 1.16.42-beta-20250412-074212-ef879757
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/util.js +19 -17
- package/lib/middlewares/fallback.js +15 -12
- package/lib/service/auth.js +2 -2
- package/package.json +8 -8
package/lib/component/util.js
CHANGED
|
@@ -29,28 +29,30 @@ function getResources({ scope, components: allComponents, types, skipRunningChec
|
|
|
29
29
|
.filter((x) => scope === 'pack' || skipRunningCheck || x.status === constant_1.BlockletStatus.running)
|
|
30
30
|
.forEach((component) => {
|
|
31
31
|
const resources = component.resourcesV2 || [].filter((x) => ignorePublic || x.public);
|
|
32
|
-
const
|
|
32
|
+
const filteredResources = resources.filter((x) => {
|
|
33
33
|
const [resourceDid, resourceType] = x.path.split('/').slice(-2);
|
|
34
34
|
return types.some((item) => item?.did === resourceDid && item?.type === resourceType);
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
filteredResources.forEach((resource) => {
|
|
37
|
+
if (resource?.path) {
|
|
38
|
+
const item = {
|
|
39
|
+
...(0, pick_1.default)(component, ['title', 'did', 'version', 'status']),
|
|
40
|
+
path: resource.path,
|
|
41
|
+
};
|
|
42
|
+
// import env from public env file
|
|
43
|
+
try {
|
|
44
|
+
const envFile = path_1.default.join(appDataDir, constant_1.APP_CONFIG_PUBLIC_DIR, component.did, constant_1.COMPONENT_ENV_FILE_NAME);
|
|
45
|
+
const env = (0, parse_env_file_1.parseEnvFile)(envFile);
|
|
46
|
+
item.env = env;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
50
|
+
console.error(err);
|
|
51
|
+
}
|
|
50
52
|
}
|
|
53
|
+
list.push(item);
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
}
|
|
55
|
+
});
|
|
54
56
|
});
|
|
55
57
|
return list;
|
|
56
58
|
}
|
|
@@ -12,6 +12,7 @@ const config_1 = require("../config");
|
|
|
12
12
|
// Cache configurations
|
|
13
13
|
const DEFAULT_CACHE_TTL = 1 * 60 * 1000; // 1 minute
|
|
14
14
|
const cache = new Map();
|
|
15
|
+
const cacheEnabled = process.env.FALLBACK_CACHE_ENABLED === 'true' || process.env.NODE_ENV === 'test';
|
|
15
16
|
// Pre-compile regex patterns for better performance
|
|
16
17
|
const TITLE_TAG_REGEX = /<title>(.+)<\/title>/;
|
|
17
18
|
const HEAD_END_TAG = '</head>';
|
|
@@ -79,19 +80,21 @@ const fallback = (file, options = {}) => {
|
|
|
79
80
|
const pageGroup = req.headers['x-page-group'] || '';
|
|
80
81
|
const pathPrefix = req.headers['x-path-prefix'] || '';
|
|
81
82
|
const cacheKey = getCacheKey(filePath, pageGroup, pathPrefix);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (cached
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
if (cacheEnabled) {
|
|
84
|
+
// Check cache first
|
|
85
|
+
const cached = cache.get(cacheKey);
|
|
86
|
+
const cacheTtl = options.cacheTtl || DEFAULT_CACHE_TTL;
|
|
87
|
+
if (cached && Date.now() - cached.timestamp < cacheTtl) {
|
|
88
|
+
if (cached.pageGroup === pageGroup && cached.pathPrefix === pathPrefix) {
|
|
89
|
+
res.setHeader('X-Cache', 'HIT');
|
|
90
|
+
res.setHeader('ETag', cached.etag);
|
|
91
|
+
res.type('html');
|
|
92
|
+
res.send(cached.html);
|
|
93
|
+
if (process.env.NODE_ENV === 'test') {
|
|
94
|
+
next(cached.html);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
93
97
|
}
|
|
94
|
-
return;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
// Get page data with timeout protection
|
package/lib/service/auth.js
CHANGED
|
@@ -220,7 +220,7 @@ class AuthService {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
this.updateUserAddress = async (args, options) => {
|
|
223
|
-
const fn = client.
|
|
223
|
+
const fn = client.updateUserInfo;
|
|
224
224
|
if (!options?.headers?.cookie) {
|
|
225
225
|
throw new Error('Missing required authentication cookie in request headers');
|
|
226
226
|
}
|
|
@@ -229,7 +229,7 @@ class AuthService {
|
|
|
229
229
|
}
|
|
230
230
|
try {
|
|
231
231
|
// @ts-ignore
|
|
232
|
-
const res = await fn({ input: { ...args, teamDid } }, options);
|
|
232
|
+
const res = await fn({ input: { user: { ...args }, teamDid } }, options);
|
|
233
233
|
return res;
|
|
234
234
|
}
|
|
235
235
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.42-beta-
|
|
6
|
+
"version": "1.16.42-beta-20250412-074212-ef879757",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/client": "1.16.42-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.42-beta-
|
|
32
|
-
"@abtnode/util": "1.16.42-beta-
|
|
30
|
+
"@abtnode/client": "1.16.42-beta-20250412-074212-ef879757",
|
|
31
|
+
"@abtnode/constant": "1.16.42-beta-20250412-074212-ef879757",
|
|
32
|
+
"@abtnode/util": "1.16.42-beta-20250412-074212-ef879757",
|
|
33
33
|
"@arcblock/did": "1.19.19",
|
|
34
34
|
"@arcblock/did-auth": "1.19.19",
|
|
35
35
|
"@arcblock/jwt": "1.19.19",
|
|
36
36
|
"@arcblock/ws": "1.19.19",
|
|
37
|
-
"@blocklet/constant": "1.16.42-beta-
|
|
38
|
-
"@blocklet/env": "1.16.42-beta-
|
|
39
|
-
"@blocklet/meta": "1.16.42-beta-
|
|
37
|
+
"@blocklet/constant": "1.16.42-beta-20250412-074212-ef879757",
|
|
38
|
+
"@blocklet/env": "1.16.42-beta-20250412-074212-ef879757",
|
|
39
|
+
"@blocklet/meta": "1.16.42-beta-20250412-074212-ef879757",
|
|
40
40
|
"@did-connect/authenticator": "^2.2.7",
|
|
41
41
|
"@did-connect/handler": "^2.2.7",
|
|
42
42
|
"@nedb/core": "^2.1.5",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"ts-node": "^10.9.1",
|
|
83
83
|
"typescript": "^5.6.3"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "b891a04b4d6722cabed06f737e81da8bc1904849"
|
|
86
86
|
}
|