@blocklet/sdk 1.16.30-beta-958ae719 → 1.16.30-beta-b80c7bcd

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.
@@ -1,7 +1,5 @@
1
- /// <reference types="node" />
2
1
  import { AxiosResponse, Method } from 'axios';
3
2
  import { IncomingMessage } from 'http';
4
- import * as Util from './util';
5
3
  import type { Resource } from './util';
6
4
  declare const getComponentWebEndpoint: (keyword: string) => string;
7
5
  type CallComponentOptions<D = any, P = any> = {
@@ -32,7 +30,7 @@ declare const getReleaseExportDir: ({ projectId, releaseId }: {
32
30
  releaseId?: string;
33
31
  }) => string;
34
32
  declare const getResources: ({ scope, types, skipRunningCheck, }?: {
35
- scope?: 'all' | 'pack' | 'excludePack';
33
+ scope?: "all" | "pack" | "excludePack";
36
34
  did?: string;
37
35
  types?: {
38
36
  did: string;
@@ -78,12 +76,12 @@ declare const _default: {
78
76
  type: string;
79
77
  }[];
80
78
  skipRunningCheck?: boolean;
81
- }) => Util.Resource[];
79
+ }) => Resource[];
82
80
  getPackResources: ({ types, }?: {
83
81
  types?: {
84
82
  did: string;
85
83
  type: string;
86
84
  }[];
87
- }) => Util.Resource[];
85
+ }) => Resource[];
88
86
  };
89
87
  export default _default;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getResources = void 0;
6
+ exports.getResources = getResources;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const pick_1 = __importDefault(require("lodash/pick"));
9
9
  const constant_1 = require("@blocklet/constant");
@@ -54,7 +54,6 @@ function getResources({ scope, components: allComponents, types, skipRunningChec
54
54
  });
55
55
  return list;
56
56
  }
57
- exports.getResources = getResources;
58
57
  exports.default = {
59
58
  getResources,
60
59
  };
package/lib/config.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { EventEmitter } from 'events';
3
2
  import { TComponentInternalInfo } from '@blocklet/meta/lib/blocklet';
4
3
  declare const events: EventEmitter<[never]>;
package/lib/config.js CHANGED
@@ -40,6 +40,7 @@ const AppConfigKeyMap = {
40
40
  BLOCKLET_APP_URL: 'appUrl',
41
41
  BLOCKLET_APP_SPACE_ENDPOINT: 'appStorageEndpoint',
42
42
  BLOCKLET_APP_LANGUAGES: ['languages', util_1.getBlockletLanguages],
43
+ BLOCKLET_APP_TENANT_MODE: 'tenantMode',
43
44
  ABT_NODE_VERSION: 'serverVersion',
44
45
  ABT_NODE: 'serverVersion', // for backup compatibility
45
46
  };
@@ -146,8 +147,10 @@ const _setUpdatedComponents = (components) => {
146
147
  return list;
147
148
  };
148
149
  const _handleComponentStarted = (data) => {
150
+ logger.debug('_handleComponentStarted.before', data.components, componentStore);
149
151
  const list = _setComponentStatus(data.components, constant_1.BlockletStatus.running);
150
152
  events.emit(Events.componentStarted, list);
153
+ logger.debug('_handleComponentStarted.after', componentStore);
151
154
  };
152
155
  exports._handleComponentStarted = _handleComponentStarted;
153
156
  const _handleComponentStopped = (data) => {
@@ -168,8 +171,10 @@ const _handleComponentUpdated = (data) => {
168
171
  };
169
172
  exports._handleComponentUpdated = _handleComponentUpdated;
170
173
  const _handleComponentInstalled = (data) => {
174
+ logger.debug('_handleComponentInstalled.before', data.components, componentStore);
171
175
  const list = _setUpdatedComponents(data.components);
172
176
  events.emit(Events.componentAdded, list);
177
+ logger.debug('_handleComponentInstalled.after', componentStore);
173
178
  };
174
179
  exports._handleComponentInstalled = _handleComponentInstalled;
175
180
  const _handleConfigUpdate = (data) => {
package/lib/did.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWalletDid = exports.getWallet = exports.getPermanentDid = exports.getConnectedDids = exports.getConnectedAccounts = exports.toBlockletDid = exports.getUserInfo = void 0;
6
+ exports.getWalletDid = exports.getWallet = exports.getPermanentDid = exports.getConnectedDids = exports.getConnectedAccounts = exports.toBlockletDid = void 0;
7
+ exports.getUserInfo = getUserInfo;
7
8
  const did_1 = __importDefault(require("@blocklet/meta/lib/did"));
8
9
  exports.toBlockletDid = did_1.default;
9
10
  const did_utils_1 = require("@blocklet/meta/lib/did-utils");
@@ -23,4 +24,3 @@ async function getUserInfo(userDid, { authClient = undefined } = {}) {
23
24
  });
24
25
  return user;
25
26
  }
26
- exports.getUserInfo = getUserInfo;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = generateBlockletEmbed;
3
4
  function safeJsonParse(input, defaultValue) {
4
5
  try {
5
6
  return JSON.parse(input);
@@ -27,4 +28,3 @@ function generateBlockletEmbed() {
27
28
  embed: [],
28
29
  };
29
30
  }
30
- exports.default = generateBlockletEmbed;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const slim_1 = require("cheerio/lib/slim");
6
+ exports.default = getEmbedUrlFromUrl;
7
+ const cheerio_1 = require("cheerio");
7
8
  const ufo_1 = require("ufo");
8
9
  const axios_1 = __importDefault(require("axios"));
9
10
  /**
@@ -12,7 +13,7 @@ const axios_1 = __importDefault(require("axios"));
12
13
  * @returns boolean
13
14
  */
14
15
  function checkViteDev(htmlContent) {
15
- const $ = (0, slim_1.load)(htmlContent);
16
+ const $ = (0, cheerio_1.load)(htmlContent);
16
17
  const scriptList = $('script[type="module"]');
17
18
  return !![...scriptList].find((scriptItem) => {
18
19
  if (scriptItem.firstChild?.type === 'text') {
@@ -30,7 +31,7 @@ async function getEmbedUrlFromUrl(url) {
30
31
  });
31
32
  let prefix = '/';
32
33
  let metaUrl = url;
33
- const $ = (0, slim_1.load)(htmlContent);
34
+ const $ = (0, cheerio_1.load)(htmlContent);
34
35
  const link = $('link[rel="blocklet-open-embed"]');
35
36
  const blockletScript = $('script[src="__blocklet__.js"]');
36
37
  if (link && link.length > 0) {
@@ -52,4 +53,3 @@ async function getEmbedUrlFromUrl(url) {
52
53
  return url;
53
54
  }
54
55
  }
55
- exports.default = getEmbedUrlFromUrl;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = getBlockletEmbedFromUrl;
6
7
  const path_1 = require("path");
7
8
  const lodash_1 = require("lodash");
8
9
  const axios_1 = __importDefault(require("axios"));
@@ -29,4 +30,3 @@ async function getBlockletEmbedFromUrl(url) {
29
30
  }
30
31
  return null;
31
32
  }
32
- exports.default = getBlockletEmbedFromUrl;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Message = exports.useMessage = void 0;
3
+ exports.Message = void 0;
4
+ exports.useMessage = useMessage;
4
5
  const INIT = '__init';
5
6
  const ON_INIT = '__on-init';
6
7
  function checkKey(typeKey) {
@@ -127,7 +128,6 @@ function useMessage(id, type = 'client') {
127
128
  messageCache.set(_id, data);
128
129
  return data;
129
130
  }
130
- exports.useMessage = useMessage;
131
131
  exports.default = {
132
132
  useMessage,
133
133
  Message,
@@ -2,6 +2,6 @@ import { NextFunction, Request, Response } from 'express';
2
2
  declare const verifySig: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
3
3
  export { verifySig };
4
4
  declare const _default: {
5
- verifySig: (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => void | Response<any, Record<string, any>>;
5
+ verifySig: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
6
6
  };
7
7
  export default _default;
@@ -9,32 +9,32 @@ export { component };
9
9
  export { fallback };
10
10
  export { sitemap };
11
11
  declare const _default: {
12
- user: () => (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> & {
12
+ user: () => (req: import("express").Request & {
13
13
  user?: {
14
14
  did: string;
15
- role: string;
15
+ role: string | undefined;
16
16
  provider: string;
17
17
  fullName: string;
18
18
  walletOS: string;
19
19
  };
20
- }, res: import("express").Response<any, Record<string, any>>, next: import("express").NextFunction) => void;
20
+ }, res: import("express").Response, next: import("express").NextFunction) => void;
21
21
  auth: ({ roles, permissions, getClient }?: {
22
22
  roles?: string[];
23
23
  permissions?: string[];
24
24
  getClient?: Function;
25
- }) => (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<any, Record<string, any>>, next: import("express").NextFunction) => Promise<void>;
25
+ }) => (req: import("express").Request, res: import("express").Response, next: import("express").NextFunction) => Promise<void>;
26
26
  component: {
27
- verifySig: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<any, Record<string, any>>, next: import("express").NextFunction) => void | import("express").Response<any, Record<string, any>>;
27
+ verifySig: (req: import("express").Request, res: import("express").Response, next: import("express").NextFunction) => void | import("express").Response<any, Record<string, any>>;
28
28
  };
29
29
  fallback: (file: string, options?: {
30
- root?: string;
31
- getPageData?: (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>) => Promise<{
30
+ root?: string | undefined;
31
+ getPageData?: (req: import("express").Request) => Promise<{
32
32
  title?: string;
33
33
  description?: string;
34
34
  ogImage?: string;
35
35
  embed?: string;
36
36
  }>;
37
- }) => (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<any, Record<string, any>>, next: import("express").NextFunction) => Promise<void>;
37
+ }) => (req: import("express").Request, res: import("express").Response, next: import("express").NextFunction) => Promise<void>;
38
38
  sitemap: (generatorFn: (fn: (item: {
39
39
  url: string;
40
40
  img?: {
@@ -68,6 +68,6 @@ declare const _default: {
68
68
  keywords: string;
69
69
  stock_tickers: string;
70
70
  };
71
- }) => void, req?: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>) => Promise<void>) => (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express").Response<any, Record<string, any>>) => Promise<void>;
71
+ }) => void, req?: import("express").Request) => Promise<void>) => (req: import("express").Request, res: import("express").Response) => Promise<void>;
72
72
  };
73
73
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { EventEmitter } from 'node:events';
3
2
  import { TNotification, TNotificationInput, TSendOptions } from '../types/notification';
4
3
  type $TSFixMe = any;
@@ -40,10 +39,10 @@ declare const _default: {
40
39
  sendToRelay: (topic: string, event: string, data: any) => Promise<any>;
41
40
  sendToMail: (receiver: string | string[], notification: TNotification, options?: TSendOptions) => Promise<any>;
42
41
  broadcast: (notification: TNotificationInput, options?: TSendOptions) => Promise<any>;
43
- on: (event: string, cb?: any) => EventEmitter<[never]>;
42
+ on: (event: string, cb?: $TSFixMe) => EventEmitter<[never]>;
44
43
  off: any;
45
44
  _message: {
46
- on: (event: string, cb: any) => EventEmitter<[never]>;
45
+ on: (event: string, cb: $TSFixMe) => EventEmitter<[never]>;
47
46
  off: any;
48
47
  };
49
48
  };
@@ -164,10 +164,7 @@ const initClient = () => {
164
164
  if (status === 'ok') {
165
165
  const { data, sender, time } = response;
166
166
  // eslint-disable-next-line no-console
167
- console.log(`Received event from component channel: ${event}. time: ${time}`);
168
- if (event === constant_1.BlockletInternalEvents.componentsUpdated) {
169
- return;
170
- }
167
+ console.info(`Received event from component channel: ${event}. time: ${time}`);
171
168
  if (!time || new Date(time).getTime() < new Date(process.env.BLOCKLET_START_AT).getTime()) {
172
169
  return;
173
170
  }
@@ -183,10 +180,7 @@ const initClient = () => {
183
180
  }
184
181
  else {
185
182
  emitError(response);
186
- console.error({
187
- status,
188
- response,
189
- });
183
+ console.error({ status, response });
190
184
  }
191
185
  });
192
186
  });
@@ -196,10 +190,7 @@ const initClient = () => {
196
190
  }
197
191
  else {
198
192
  emitter.emit('error', response);
199
- console.error({
200
- status,
201
- response,
202
- });
193
+ console.error({ status, response });
203
194
  }
204
195
  });
205
196
  }
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getMemberAppInfo = exports.getAppInfo = exports.getFederatedMasterAppInfo = void 0;
6
+ exports.getFederatedMasterAppInfo = getFederatedMasterAppInfo;
7
+ exports.getAppInfo = getAppInfo;
8
+ exports.getMemberAppInfo = getMemberAppInfo;
7
9
  const ufo_1 = require("ufo");
8
10
  const util_1 = require("@blocklet/meta/lib/util");
9
11
  const info_1 = __importDefault(require("@blocklet/meta/lib/info"));
@@ -22,7 +24,6 @@ function getFederatedMasterAppInfo({ blocklet, sourceAppPid, version, groupPathP
22
24
  nodeDid: nodeInfo.did,
23
25
  };
24
26
  }
25
- exports.getFederatedMasterAppInfo = getFederatedMasterAppInfo;
26
27
  async function getAppInfo({ request, baseUrl, getBlocklet, getNodeInfo, }) {
27
28
  const groupPathPrefix = request.headers['x-group-path-prefix'] || '/';
28
29
  const [blocklet, info] = await Promise.all([getBlocklet(), getNodeInfo()]);
@@ -51,7 +52,6 @@ async function getAppInfo({ request, baseUrl, getBlocklet, getNodeInfo, }) {
51
52
  // NOTE: publisher 是 WalletAuthenticator 中自动添加的
52
53
  };
53
54
  }
54
- exports.getAppInfo = getAppInfo;
55
55
  async function getMemberAppInfo({ request, baseUrl, getBlocklet, getNodeInfo, }) {
56
56
  const groupPathPrefix = request.headers['x-group-path-prefix'] || '/';
57
57
  const [blocklet, info] = await Promise.all([getBlocklet(), getNodeInfo()]);
@@ -75,4 +75,3 @@ async function getMemberAppInfo({ request, baseUrl, getBlocklet, getNodeInfo, })
75
75
  }
76
76
  return null;
77
77
  }
78
- exports.getMemberAppInfo = getMemberAppInfo;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = setupJest;
6
7
  // Setup blocklet environments for jest
7
8
  const os_1 = __importDefault(require("os"));
8
9
  const fs_1 = __importDefault(require("fs"));
@@ -53,4 +54,3 @@ function setupJest() {
53
54
  console.error('Failed to setup blocklet environment for jest', err);
54
55
  }
55
56
  }
56
- exports.default = setupJest;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = setupJest;
6
7
  // Setup blocklet environments for jest
7
8
  const os_1 = __importDefault(require("os"));
8
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -21,4 +22,3 @@ function setupJest() {
21
22
  console.error('Failed to tear blocklet environment for jest', err);
22
23
  }
23
24
  }
24
- exports.default = setupJest;
package/lib/util/login.js CHANGED
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSourceAppPid = exports.getLoginProvider = void 0;
3
+ exports.getLoginProvider = getLoginProvider;
4
+ exports.getSourceAppPid = getSourceAppPid;
4
5
  /* eslint-disable import/prefer-default-export */
5
6
  const constant_1 = require("@blocklet/constant");
6
7
  function getLoginProvider(request) {
7
8
  const extraParams = request?.context?.store?.extraParams || request.query || {};
8
9
  return extraParams.provider || constant_1.LOGIN_PROVIDER.WALLET;
9
10
  }
10
- exports.getLoginProvider = getLoginProvider;
11
11
  function getSourceAppPid(request) {
12
12
  const extraParams = request?.context?.store?.extraParams || request.query || {};
13
13
  return extraParams?.sourceAppPid || null;
14
14
  }
15
- exports.getSourceAppPid = getSourceAppPid;
@@ -18,7 +18,7 @@ export type TNotificationSender = {
18
18
  declare const sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk, type }: TNotificationSender, port?: string, options?: {
19
19
  keepForOfflineUser?: boolean;
20
20
  locale?: string;
21
- channels?: ('app' | 'email' | 'push' | 'webhook')[];
21
+ channels?: ("app" | "email" | "push" | "webhook")[];
22
22
  }, pathname?: string) => Promise<any>;
23
23
  declare const sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
24
24
  declare const sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
@@ -27,7 +27,7 @@ declare const _default: {
27
27
  sendToUser: (receiver: string | string[], notification: TNotification | TNotificationInput, { appDid, appSk, type }: TNotificationSender, port?: string, options?: {
28
28
  keepForOfflineUser?: boolean;
29
29
  locale?: string;
30
- channels?: ("push" | "app" | "email" | "webhook")[];
30
+ channels?: ("app" | "email" | "push" | "webhook")[];
31
31
  }, pathname?: string) => Promise<any>;
32
32
  sendToAppChannel: (channel: string, event: string, notification: TNotificationInput, { appDid, appSk }: TNotificationSender, port?: string, options?: TSendOptions) => Promise<any>;
33
33
  sendToRelay: (topic: string, event: string, data: any, { appDid, appSk }: TNotificationSender, port?: string) => Promise<any>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.30-beta-958ae719",
6
+ "version": "1.16.30-beta-b80c7bcd",
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,15 +27,15 @@
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.30-beta-958ae719",
31
- "@abtnode/constant": "1.16.30-beta-958ae719",
30
+ "@abtnode/client": "1.16.30-beta-b80c7bcd",
31
+ "@abtnode/constant": "1.16.30-beta-b80c7bcd",
32
32
  "@arcblock/did": "1.18.128",
33
33
  "@arcblock/did-auth": "1.18.128",
34
34
  "@arcblock/jwt": "1.18.128",
35
35
  "@arcblock/ws": "1.18.128",
36
- "@blocklet/constant": "1.16.30-beta-958ae719",
37
- "@blocklet/env": "1.16.30-beta-958ae719",
38
- "@blocklet/meta": "1.16.30-beta-958ae719",
36
+ "@blocklet/constant": "1.16.30-beta-b80c7bcd",
37
+ "@blocklet/env": "1.16.30-beta-b80c7bcd",
38
+ "@blocklet/meta": "1.16.30-beta-b80c7bcd",
39
39
  "@did-connect/authenticator": "^2.2.4",
40
40
  "@did-connect/handler": "^2.2.4",
41
41
  "@nedb/core": "^2.1.5",
@@ -75,5 +75,5 @@
75
75
  "ts-node": "^10.9.1",
76
76
  "typescript": "^5.0.4"
77
77
  },
78
- "gitHead": "75590ff3be51e7fe2a070124541aebc203ed16dc"
78
+ "gitHead": "9d68833290b1a59357b7c362018416b82b5d1503"
79
79
  }