@blocklet/sdk 1.16.21-beta-bd0e2503 → 1.16.21-beta-445a8baa

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.
@@ -27,10 +27,16 @@ declare const getResourceExportDir: ({ projectId, releaseId }?: {
27
27
  projectId: string;
28
28
  releaseId?: string;
29
29
  }) => string;
30
- declare const getResources: ({ types, skipRunningCheck, }?: {
30
+ declare const getResources: ({ scope, did, types, skipRunningCheck, }?: {
31
+ scope?: 'all' | 'pack' | 'excludePack';
32
+ did?: string;
31
33
  types?: string[];
32
34
  skipRunningCheck?: boolean;
33
35
  }) => Resource[];
36
+ declare const getPackResources: ({ did, types, }?: {
37
+ did?: string;
38
+ types?: string[];
39
+ }) => Resource[];
34
40
  declare const waitForComponentRunning: (name: string, timeout?: number, interval?: number) => Promise<boolean>;
35
41
  export { call };
36
42
  export { getUrl };
@@ -39,6 +45,7 @@ export { getComponentWebEndpoint };
39
45
  export { waitForComponentRunning };
40
46
  export { getResourceExportDir };
41
47
  export { getResources };
48
+ export { getPackResources };
42
49
  declare const _default: {
43
50
  call: CallComponent;
44
51
  getUrl: (...parts: string[]) => string;
@@ -49,9 +56,15 @@ declare const _default: {
49
56
  projectId: string;
50
57
  releaseId?: string;
51
58
  }) => string;
52
- getResources: ({ types, skipRunningCheck, }?: {
59
+ getResources: ({ scope, did, types, skipRunningCheck, }?: {
60
+ scope?: "pack" | "all" | "excludePack";
61
+ did?: string;
53
62
  types?: string[];
54
63
  skipRunningCheck?: boolean;
55
64
  }) => Util.Resource[];
65
+ getPackResources: ({ did, types, }?: {
66
+ did?: string;
67
+ types?: string[];
68
+ }) => Util.Resource[];
56
69
  };
57
70
  export default _default;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getResources = exports.getResourceExportDir = exports.waitForComponentRunning = exports.getComponentWebEndpoint = exports.getComponentMountPoint = exports.getUrl = exports.call = void 0;
29
+ exports.getPackResources = exports.getResources = exports.getResourceExportDir = exports.waitForComponentRunning = exports.getComponentWebEndpoint = exports.getComponentMountPoint = exports.getUrl = exports.call = void 0;
30
30
  const path_1 = require("path");
31
31
  const axios_1 = __importDefault(require("axios"));
32
32
  const get_1 = __importDefault(require("lodash/get"));
@@ -119,10 +119,14 @@ const getResourceExportDir = ({ projectId, releaseId } = { projectId: '' }) => {
119
119
  return dir;
120
120
  };
121
121
  exports.getResourceExportDir = getResourceExportDir;
122
- const getResources = ({ types, skipRunningCheck, } = {}) => {
123
- return Util.getResources({ components: config_1.components, types, skipRunningCheck });
122
+ const getResources = ({ scope = 'all', did, types, skipRunningCheck, } = {}) => {
123
+ return Util.getResources({ components: config_1.components, scope, did, types, skipRunningCheck });
124
124
  };
125
125
  exports.getResources = getResources;
126
+ const getPackResources = ({ did, types, } = {}) => {
127
+ return Util.getResources({ components: config_1.components, scope: 'pack', did, types, ignorePublic: true });
128
+ };
129
+ exports.getPackResources = getPackResources;
126
130
  const waitForComponentRunning = async (name, timeout = 30000, interval = 250) => {
127
131
  const component = getComponent(name);
128
132
  if (!component) {
@@ -147,4 +151,5 @@ exports.default = {
147
151
  waitForComponentRunning,
148
152
  getResourceExportDir,
149
153
  getResources,
154
+ getPackResources,
150
155
  };
@@ -6,10 +6,13 @@ type Resource = {
6
6
  status?: number;
7
7
  path?: string;
8
8
  };
9
- declare function getResources({ components, types, skipRunningCheck, }?: {
9
+ declare function getResources({ scope, components: allComponents, did, types, skipRunningCheck, ignorePublic, }?: {
10
+ scope?: 'all' | 'pack' | 'excludePack';
10
11
  components: TComponent[];
12
+ did?: string;
11
13
  types?: string[];
12
14
  skipRunningCheck?: boolean;
15
+ ignorePublic?: boolean;
13
16
  }): Resource[];
14
17
  export { getResources };
15
18
  export { Resource };
@@ -6,18 +6,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getResources = void 0;
7
7
  const pick_1 = __importDefault(require("lodash/pick"));
8
8
  const constant_1 = require("@blocklet/constant");
9
- function getResources({ components, types, skipRunningCheck, } = {
9
+ function getResources({ scope, components: allComponents, did, types, skipRunningCheck, ignorePublic, } = {
10
+ scope: 'all',
10
11
  components: [],
11
12
  }) {
12
13
  const list = [];
14
+ if (!did && !types?.length) {
15
+ return list;
16
+ }
17
+ let components = allComponents;
18
+ if (scope === 'pack') {
19
+ components = allComponents.filter((x) => x.group === constant_1.BlockletGroup.pack);
20
+ }
21
+ else if (scope === 'excludePack') {
22
+ components = allComponents.filter((x) => x.group !== constant_1.BlockletGroup.pack);
23
+ }
13
24
  components
14
- .filter((x) => skipRunningCheck || x.status === constant_1.BlockletStatus.running)
25
+ // auto skip running check for pack component
26
+ .filter((x) => scope === 'pack' || skipRunningCheck || x.status === constant_1.BlockletStatus.running)
15
27
  .forEach((component) => {
16
- const resource = component.resources?.find((x) => (types || []).some((type) => x.endsWith(type)));
17
- if (resource) {
28
+ const resources = component.resourcesV2 || [].filter((x) => ignorePublic || x.public);
29
+ let resourcePath;
30
+ if (did && types?.length) {
31
+ const resource = resources.find((x) => {
32
+ const [resourceDid, resourceType] = x.path.split('/').slice(-2);
33
+ return did === resourceDid && types.includes(resourceType);
34
+ });
35
+ resourcePath = resource?.path;
36
+ }
37
+ if (resourcePath) {
18
38
  list.push({
19
39
  ...(0, pick_1.default)(component, ['title', 'did', 'version', 'status']),
20
- path: resource,
40
+ path: resourcePath,
21
41
  });
22
42
  }
23
43
  });
package/lib/config.d.ts CHANGED
@@ -45,6 +45,7 @@ declare const env: {
45
45
  }[];
46
46
  preferences: Record<string, any>;
47
47
  componentDid: string;
48
+ initialized?: boolean;
48
49
  [key: string]: any;
49
50
  };
50
51
  type MountPoint = TComponentInternalInfo & {
@@ -113,6 +114,7 @@ declare const _default: {
113
114
  }[];
114
115
  preferences: Record<string, any>;
115
116
  componentDid: string;
117
+ initialized?: boolean;
116
118
  };
117
119
  components: TComponents;
118
120
  events: EventEmitter;
package/lib/config.js CHANGED
@@ -100,7 +100,7 @@ const env = {
100
100
  ...env_1.default.preferences,
101
101
  ...appEnvFromDisk.preferences,
102
102
  ...envFromDisk.preferences,
103
- }
103
+ },
104
104
  };
105
105
  exports.env = env;
106
106
  const _fillWebEndpoint = (components) => {
@@ -263,7 +263,9 @@ const getBlockletJs = (pageGroup = '', pathPrefix = '', source = blockletJs) =>
263
263
  if (pathPrefix) {
264
264
  const componentDid = process.env.BLOCKLET_COMPONENT_DID;
265
265
  const { mountPoint } = componentStore.find((x) => x.did === componentDid);
266
- copy = copy.replace(`prefix: "${normalize(mountPoint)}",`, `prefix: "${normalize(pathPrefix)}",`).replace('prefix: "/",', `prefix: "${normalize(pathPrefix)}",`);
266
+ copy = copy
267
+ .replace(`prefix: "${normalize(mountPoint)}",`, `prefix: "${normalize(pathPrefix)}",`)
268
+ .replace('prefix: "/",', `prefix: "${normalize(pathPrefix)}",`);
267
269
  }
268
270
  return copy;
269
271
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.21-beta-bd0e2503",
6
+ "version": "1.16.21-beta-445a8baa",
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",
@@ -26,15 +26,15 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.16.21-beta-bd0e2503",
30
- "@abtnode/constant": "1.16.21-beta-bd0e2503",
29
+ "@abtnode/client": "1.16.21-beta-445a8baa",
30
+ "@abtnode/constant": "1.16.21-beta-445a8baa",
31
31
  "@arcblock/did": "1.18.107",
32
32
  "@arcblock/did-auth": "1.18.107",
33
33
  "@arcblock/jwt": "1.18.107",
34
34
  "@arcblock/ws": "1.18.107",
35
- "@blocklet/constant": "1.16.21-beta-bd0e2503",
36
- "@blocklet/env": "1.16.21-beta-bd0e2503",
37
- "@blocklet/meta": "1.16.21-beta-bd0e2503",
35
+ "@blocklet/constant": "1.16.21-beta-445a8baa",
36
+ "@blocklet/env": "1.16.21-beta-445a8baa",
37
+ "@blocklet/meta": "1.16.21-beta-445a8baa",
38
38
  "@did-connect/authenticator": "^2.2.1",
39
39
  "@did-connect/handler": "^2.2.1",
40
40
  "@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": "f4550e061b661cb67d7f1413ada51f3f6491f0b8"
78
+ "gitHead": "7a7ff8be7f424775c3bde0eead773d8e6177fa1a"
79
79
  }