@blocklet/sdk 1.16.15-beta-7e0c580a → 1.16.15-beta-04d1e821

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.
@@ -19,7 +19,6 @@ const doCall = async ({ url, ...options }) => {
19
19
  ...options,
20
20
  headers: {
21
21
  'x-component-sig': (0, verify_sign_1.sign)(options.data),
22
- 'x-component-did': process.env.BLOCKLET_COMPONENT_DID,
23
22
  },
24
23
  timeout: 60 * 1000,
25
24
  });
@@ -2,10 +2,12 @@ import user from './user';
2
2
  import auth from './auth';
3
3
  import component from './component';
4
4
  import fallback from './fallback';
5
+ import sitemap from './sitemap';
5
6
  export { user };
6
7
  export { auth };
7
8
  export { component };
8
9
  export { fallback };
10
+ export { sitemap };
9
11
  declare const _default: {
10
12
  user: () => (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> & {
11
13
  user?: {
@@ -28,5 +30,39 @@ declare const _default: {
28
30
  maxAge?: string | number;
29
31
  root?: string;
30
32
  }) => (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;
33
+ sitemap: (generatorFn: (fn: (item: {
34
+ url: string;
35
+ img?: {
36
+ url: string;
37
+ caption: string;
38
+ title: string;
39
+ geoLocation: string;
40
+ license: string;
41
+ }[];
42
+ video?: {
43
+ thumbnail_loc: string;
44
+ title: string;
45
+ description: string;
46
+ player_loc?: string;
47
+ 'player_loc:autoplay'?: string;
48
+ 'player_loc:allow_embed'?: string;
49
+ }[];
50
+ links?: {
51
+ lang: string;
52
+ url: string;
53
+ }[];
54
+ androidLink?: string;
55
+ news?: {
56
+ publication: {
57
+ name: string;
58
+ language: string;
59
+ };
60
+ genres: string;
61
+ publication_date: string;
62
+ title: string;
63
+ keywords: string;
64
+ stock_tickers: string;
65
+ };
66
+ }) => void) => 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>;
31
67
  };
32
68
  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.fallback = exports.component = exports.auth = exports.user = void 0;
6
+ exports.sitemap = exports.fallback = exports.component = exports.auth = exports.user = void 0;
7
7
  const user_1 = __importDefault(require("./user"));
8
8
  exports.user = user_1.default;
9
9
  const auth_1 = __importDefault(require("./auth"));
@@ -12,9 +12,12 @@ const component_1 = __importDefault(require("./component"));
12
12
  exports.component = component_1.default;
13
13
  const fallback_1 = __importDefault(require("./fallback"));
14
14
  exports.fallback = fallback_1.default;
15
+ const sitemap_1 = __importDefault(require("./sitemap"));
16
+ exports.sitemap = sitemap_1.default;
15
17
  exports.default = {
16
18
  user: user_1.default,
17
19
  auth: auth_1.default,
18
20
  component: component_1.default,
19
21
  fallback: fallback_1.default,
22
+ sitemap: sitemap_1.default,
20
23
  };
@@ -0,0 +1,43 @@
1
+ import { Request, Response } from 'express';
2
+ type Image = {
3
+ url: string;
4
+ caption: string;
5
+ title: string;
6
+ geoLocation: string;
7
+ license: string;
8
+ };
9
+ type Video = {
10
+ thumbnail_loc: string;
11
+ title: string;
12
+ description: string;
13
+ player_loc?: string;
14
+ 'player_loc:autoplay'?: string;
15
+ 'player_loc:allow_embed'?: string;
16
+ };
17
+ type Link = {
18
+ lang: string;
19
+ url: string;
20
+ };
21
+ type Publication = {
22
+ name: string;
23
+ language: string;
24
+ };
25
+ type News = {
26
+ publication: Publication;
27
+ genres: string;
28
+ publication_date: string;
29
+ title: string;
30
+ keywords: string;
31
+ stock_tickers: string;
32
+ };
33
+ type SitemapItem = {
34
+ url: string;
35
+ img?: Image[];
36
+ video?: Video[];
37
+ links?: Link[];
38
+ androidLink?: string;
39
+ news?: News;
40
+ };
41
+ type GeneratorFn = (fn: (item: SitemapItem) => void) => Promise<void>;
42
+ declare const sitemap: (generatorFn: GeneratorFn) => (req: Request, res: Response) => Promise<void>;
43
+ export = sitemap;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ const sitemap_1 = require("sitemap");
3
+ const config_1 = require("../config");
4
+ const sitemap = (generatorFn) => {
5
+ return async (req, res) => {
6
+ res.header('Content-Type', 'application/xml');
7
+ try {
8
+ const stream = new sitemap_1.SitemapStream({ hostname: config_1.env.appUrl });
9
+ await generatorFn(stream.write.bind(stream));
10
+ stream.end();
11
+ const result = await (0, sitemap_1.streamToPromise)(stream).then((data) => data.toString());
12
+ res.send(result);
13
+ }
14
+ catch (err) {
15
+ console.error('Failed to generate sitemap', err);
16
+ res.status(500);
17
+ res.send(err.message);
18
+ }
19
+ };
20
+ };
21
+ module.exports = sitemap;
@@ -65,6 +65,7 @@ class AuthService {
65
65
  const apiList = [
66
66
  // user
67
67
  'login',
68
+ 'switchProfile',
68
69
  'refreshSession',
69
70
  'getUsers',
70
71
  'getUser',
@@ -121,6 +122,7 @@ class AuthService {
121
122
  // removeUser: apiConvertDid,
122
123
  // updateUserRole: (fn: Function) => (did: string, role: string) => fn({ input: { user: { did, role }, teamDid } }),
123
124
  updateUserApproval: (fn) => (did, approved) => fn({ input: { user: { did, approved }, teamDid } }),
125
+ switchProfile: (fn) => (did, profile) => fn({ input: { teamDid, userDid: did, profile } }),
124
126
  getPermissionsByRole: (fn) => (name) => fn({ input: { role: { name }, teamDid } }),
125
127
  createRole: (fn) => ({ name, title, description }) => fn({ input: { ...(0, pickBy_1.default)({ name, title, description }, isNotNullOrUndefined), teamDid } }),
126
128
  updateRole: (fn) => (name, { title, description }) => fn({ input: { role: (0, pickBy_1.default)({ name, title, description }, isNotNullOrUndefined), teamDid } }),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.15-beta-7e0c580a",
6
+ "version": "1.16.15-beta-04d1e821",
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.14",
30
- "@abtnode/constant": "1.16.14",
29
+ "@abtnode/client": "1.16.15-beta-04d1e821",
30
+ "@abtnode/constant": "1.16.15-beta-04d1e821",
31
31
  "@arcblock/did": "1.18.89",
32
32
  "@arcblock/did-auth": "1.18.89",
33
33
  "@arcblock/jwt": "1.18.89",
34
34
  "@arcblock/ws": "1.18.89",
35
- "@blocklet/constant": "1.16.14",
36
- "@blocklet/env": "1.16.14",
37
- "@blocklet/meta": "1.16.14",
35
+ "@blocklet/constant": "1.16.15-beta-04d1e821",
36
+ "@blocklet/env": "1.16.15-beta-04d1e821",
37
+ "@blocklet/meta": "1.16.15-beta-04d1e821",
38
38
  "@did-connect/authenticator": "^2.2.0",
39
39
  "@did-connect/handler": "^2.2.0",
40
40
  "@nedb/core": "^2.1.5",
@@ -48,6 +48,7 @@
48
48
  "lodash": "^4.17.21",
49
49
  "lru-cache": "^6.0.0",
50
50
  "semver": "^7.3.8",
51
+ "sitemap": "^7.1.1",
51
52
  "ufo": "^1.1.1",
52
53
  "url-join": "^4.0.1"
53
54
  },
@@ -72,5 +73,6 @@
72
73
  "ts-jest": "^27.1.5",
73
74
  "ts-node": "^10.9.1",
74
75
  "typescript": "^5.0.4"
75
- }
76
+ },
77
+ "gitHead": "42e1523e5b92a3a57d9083ae29455df429afb0f6"
76
78
  }