@blocklet/sdk 1.8.57 → 1.8.59

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.
@@ -3,6 +3,29 @@ export interface TDataAsset {
3
3
  chainHost: string;
4
4
  did: unknown;
5
5
  }
6
+ export interface TDataDapp {
7
+ appDID: unknown;
8
+ desc?: string;
9
+ logo: string;
10
+ title: string;
11
+ url: string;
12
+ }
13
+ export interface TDataImage {
14
+ alt?: string;
15
+ url: string;
16
+ }
17
+ export interface TDataLink {
18
+ description?: string;
19
+ image?: string;
20
+ title?: string;
21
+ url: string;
22
+ }
23
+ export interface TDataText {
24
+ color?: string;
25
+ size?: 'small' | 'normal' | 'big';
26
+ text: string;
27
+ type: string;
28
+ }
6
29
  export interface TDataToken {
7
30
  address?: unknown;
8
31
  amount: string;
@@ -11,6 +34,10 @@ export interface TDataToken {
11
34
  senderDid: unknown;
12
35
  symbol: string;
13
36
  }
37
+ export interface TDataTransaction {
38
+ chainId: string;
39
+ hash: string;
40
+ }
14
41
  export interface TDataVC {
15
42
  credential: {
16
43
  /**
@@ -40,10 +67,39 @@ export interface TNotificationAction {
40
67
  name: string;
41
68
  title?: string;
42
69
  }
43
- export interface TNotificationAttachment {
44
- data?: object;
45
- type: 'asset' | 'vc' | 'token';
46
- }
70
+ export type TNotificationAttachment = {
71
+ data: TDataAsset;
72
+ type: 'asset';
73
+ } | {
74
+ data: TDataVC;
75
+ type: 'vc';
76
+ } | {
77
+ data: TDataToken;
78
+ type: 'token';
79
+ } | {
80
+ data: TDataText;
81
+ type: 'text';
82
+ } | {
83
+ data: TDataImage;
84
+ type: 'image';
85
+ } | {
86
+ data: TDataTransaction;
87
+ type: 'transaction';
88
+ } | {
89
+ data: TDataDapp;
90
+ type: 'dapp';
91
+ } | {
92
+ data: TDataLink;
93
+ type: 'link';
94
+ } | {
95
+ fields?: {
96
+ data: TDataText;
97
+ type: 'text';
98
+ }[];
99
+ type: 'section';
100
+ } | {
101
+ type: 'divider';
102
+ };
47
103
  export interface TNotificationConnect {
48
104
  checkUrl?: string;
49
105
  type?: 'connect';
@@ -58,7 +114,9 @@ export type TNotificationInput = TNotification[] | TNotification;
58
114
  export interface TNotificationItem {
59
115
  actions?: TNotificationAction[];
60
116
  attachments?: TNotificationAttachment[];
117
+ blocks?: TNotificationAttachment[];
61
118
  body?: string;
119
+ severity?: 'normal' | 'success' | 'error' | 'warning';
62
120
  title?: string;
63
121
  type?: 'notification';
64
122
  }
@@ -8,8 +8,13 @@ declare const TYPES: {
8
8
  declare const assetSchema: JOI.ObjectSchema<any>;
9
9
  declare const vcSchema: JOI.ObjectSchema<any>;
10
10
  declare const tokenSchema: JOI.ObjectSchema<any>;
11
+ declare const textSchema: JOI.ObjectSchema<any>;
12
+ declare const imageSchema: JOI.ObjectSchema<any>;
13
+ declare const transactionSchema: JOI.ObjectSchema<any>;
14
+ declare const dappSchema: JOI.ObjectSchema<any>;
15
+ declare const linkSchema: JOI.ObjectSchema<any>;
11
16
  declare const actionSchema: JOI.ObjectSchema<any>;
12
- declare const attachmentSchema: JOI.ObjectSchema<any>;
17
+ declare const attachmentSchema: JOI.AlternativesSchema<any>;
13
18
  declare const notificationTypeSchema: JOI.ObjectSchema<any>;
14
19
  declare const connectTypeSchema: JOI.ObjectSchema<any>;
15
20
  declare const feedTypeSchema: JOI.ObjectSchema<any>;
@@ -27,6 +32,11 @@ export { tokenSchema };
27
32
  export { actionSchema };
28
33
  export { assetSchema };
29
34
  export { vcSchema };
35
+ export { transactionSchema };
36
+ export { textSchema };
37
+ export { linkSchema };
38
+ export { imageSchema };
39
+ export { dappSchema };
30
40
  export { attachmentSchema };
31
41
  export { notificationSchema };
32
42
  export { messageSchema };
@@ -44,7 +54,12 @@ declare const _default: {
44
54
  actionSchema: JOI.ObjectSchema<any>;
45
55
  assetSchema: JOI.ObjectSchema<any>;
46
56
  vcSchema: JOI.ObjectSchema<any>;
47
- attachmentSchema: JOI.ObjectSchema<any>;
57
+ transactionSchema: JOI.ObjectSchema<any>;
58
+ textSchema: JOI.ObjectSchema<any>;
59
+ linkSchema: JOI.ObjectSchema<any>;
60
+ imageSchema: JOI.ObjectSchema<any>;
61
+ dappSchema: JOI.ObjectSchema<any>;
62
+ attachmentSchema: JOI.AlternativesSchema<any>;
48
63
  notificationSchema: JOI.AlternativesSchema<any>;
49
64
  messageSchema: JOI.ObjectSchema<any>;
50
65
  optionSchema: JOI.ObjectSchema<any>;
@@ -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.feedTypeSchema = exports.connectTypeSchema = exports.notificationTypeSchema = exports.inputNotificationSchema = exports.NOTIFICATION_TYPES = exports.channelEventSchema = exports.optionSchema = exports.messageSchema = exports.notificationSchema = exports.attachmentSchema = exports.vcSchema = exports.assetSchema = exports.actionSchema = exports.tokenSchema = exports.validateOption = exports.validateChannelEvent = exports.validateMessage = exports.validateNotification = exports.validateReceiver = void 0;
6
+ exports.feedTypeSchema = exports.connectTypeSchema = exports.notificationTypeSchema = exports.inputNotificationSchema = exports.NOTIFICATION_TYPES = exports.channelEventSchema = exports.optionSchema = exports.messageSchema = exports.notificationSchema = exports.attachmentSchema = exports.dappSchema = exports.imageSchema = exports.linkSchema = exports.textSchema = exports.transactionSchema = exports.vcSchema = exports.assetSchema = exports.actionSchema = exports.tokenSchema = exports.validateOption = exports.validateChannelEvent = exports.validateMessage = exports.validateNotification = exports.validateReceiver = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const extension_1 = require("@blocklet/meta/lib/extension");
9
9
  const Joi = joi_1.default.extend(extension_1.didExtension);
@@ -14,6 +14,24 @@ const TYPES = {
14
14
  HI: 'hi',
15
15
  };
16
16
  exports.NOTIFICATION_TYPES = TYPES;
17
+ const SEVERITIES = {
18
+ NORMAL: 'normal',
19
+ SUCCESS: 'success',
20
+ ERROR: 'error',
21
+ WARNING: 'warning',
22
+ };
23
+ const ATTACHMENT_TYPES = {
24
+ ASSET: 'asset',
25
+ VC: 'vc',
26
+ TOKEN: 'token',
27
+ TEXT: 'text',
28
+ IMAGE: 'image',
29
+ DIVIDER: 'divider',
30
+ TRANSACTION: 'transaction',
31
+ DAPP: 'dapp',
32
+ LINK: 'link',
33
+ SECTION: 'section',
34
+ };
17
35
  const assetSchema = Joi.object({
18
36
  did: Joi.DID().trim().required(),
19
37
  chainHost: Joi.string().uri().required(),
@@ -39,6 +57,48 @@ const tokenSchema = Joi.object({
39
57
  .required()
40
58
  .meta({ className: 'TDataToken' });
41
59
  exports.tokenSchema = tokenSchema;
60
+ const textSchema = Joi.object({
61
+ type: Joi.string().required(),
62
+ text: Joi.string().required(),
63
+ color: Joi.string().min(0),
64
+ size: Joi.string().valid('small', 'normal', 'big'),
65
+ })
66
+ .required()
67
+ .meta({ className: 'TDataText' });
68
+ exports.textSchema = textSchema;
69
+ const imageSchema = Joi.object({
70
+ url: Joi.string().uri().required(),
71
+ alt: Joi.string().min(0),
72
+ })
73
+ .required()
74
+ .meta({ className: 'TDataImage' });
75
+ exports.imageSchema = imageSchema;
76
+ const transactionSchema = Joi.object({
77
+ hash: Joi.string().required(),
78
+ chainId: Joi.string().required(),
79
+ })
80
+ .required()
81
+ .meta({ className: 'TDataTransaction' });
82
+ exports.transactionSchema = transactionSchema;
83
+ const dappSchema = Joi.object({
84
+ url: Joi.string().uri().required(),
85
+ appDID: Joi.DID().trim().required(),
86
+ logo: Joi.string().uri().required(),
87
+ title: Joi.string().required(),
88
+ desc: Joi.string().min(0),
89
+ })
90
+ .required()
91
+ .meta({ className: 'TDataDapp' });
92
+ exports.dappSchema = dappSchema;
93
+ const linkSchema = Joi.object({
94
+ url: Joi.string().uri().required(),
95
+ description: Joi.string().min(0),
96
+ title: Joi.string().min(0),
97
+ image: Joi.string().uri().min(0),
98
+ })
99
+ .required()
100
+ .meta({ className: 'TDataLink' });
101
+ exports.linkSchema = linkSchema;
42
102
  const actionSchema = Joi.object({
43
103
  name: Joi.string().required(),
44
104
  title: Joi.string(),
@@ -47,13 +107,40 @@ const actionSchema = Joi.object({
47
107
  link: Joi.string().uri(),
48
108
  }).meta({ className: 'TNotificationAction' });
49
109
  exports.actionSchema = actionSchema;
50
- const attachmentSchema = Joi.object({
51
- type: Joi.string().required().valid('asset', 'vc', 'token'),
52
- data: Joi.object()
53
- .when('type', { is: 'asset', then: assetSchema })
54
- .concat(Joi.object().when('type', { is: 'vc', then: vcSchema }))
55
- .concat(Joi.object().when('type', { is: 'token', then: tokenSchema })),
56
- })
110
+ const attachmentSchema = Joi.alternatives()
111
+ .try(Joi.object({
112
+ type: Joi.string().valid(ATTACHMENT_TYPES.ASSET).required(),
113
+ data: assetSchema,
114
+ }), Joi.object({
115
+ type: Joi.string().valid(ATTACHMENT_TYPES.VC).required(),
116
+ data: vcSchema,
117
+ }), Joi.object({
118
+ type: Joi.string().valid(ATTACHMENT_TYPES.TOKEN).required(),
119
+ data: tokenSchema,
120
+ }), Joi.object({
121
+ type: Joi.string().valid(ATTACHMENT_TYPES.TEXT).required(),
122
+ data: textSchema,
123
+ }), Joi.object({
124
+ type: Joi.string().valid(ATTACHMENT_TYPES.IMAGE).required(),
125
+ data: imageSchema,
126
+ }), Joi.object({
127
+ type: Joi.string().valid(ATTACHMENT_TYPES.TRANSACTION).required(),
128
+ data: transactionSchema,
129
+ }), Joi.object({
130
+ type: Joi.string().valid(ATTACHMENT_TYPES.DAPP).required(),
131
+ data: dappSchema,
132
+ }), Joi.object({
133
+ type: Joi.string().valid(ATTACHMENT_TYPES.LINK).required(),
134
+ data: linkSchema,
135
+ }), Joi.object({
136
+ type: Joi.string().valid(ATTACHMENT_TYPES.SECTION).required(),
137
+ fields: Joi.array().items(Joi.object({
138
+ type: Joi.string().valid(ATTACHMENT_TYPES.TEXT).required(),
139
+ data: textSchema,
140
+ })),
141
+ }), Joi.object({
142
+ type: Joi.string().valid(ATTACHMENT_TYPES.DIVIDER).required(),
143
+ }))
57
144
  .required()
58
145
  .meta({ className: 'TNotificationAttachment' });
59
146
  exports.attachmentSchema = attachmentSchema;
@@ -61,6 +148,8 @@ const notificationTypeSchema = Joi.object({
61
148
  type: Joi.string().valid(TYPES.NOTIFICATION),
62
149
  title: Joi.string(),
63
150
  body: Joi.string(),
151
+ severity: Joi.string().valid(...Object.values(SEVERITIES)),
152
+ blocks: Joi.array().items(attachmentSchema).default([]),
64
153
  attachments: Joi.array().items(attachmentSchema).default([]),
65
154
  actions: Joi.array().items(actionSchema).default([]),
66
155
  })
@@ -133,6 +222,11 @@ exports.default = {
133
222
  actionSchema,
134
223
  assetSchema,
135
224
  vcSchema,
225
+ transactionSchema,
226
+ textSchema,
227
+ linkSchema,
228
+ imageSchema,
229
+ dappSchema,
136
230
  attachmentSchema,
137
231
  notificationSchema,
138
232
  messageSchema,
package/lib/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const version = "1.8.57";
1
+ declare const version = "1.8.59";
2
2
  export { version };
3
3
  declare const _default: {
4
4
  version: string;
package/lib/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- const version = '1.8.57';
4
+ const version = '1.8.59';
5
5
  exports.version = version;
6
6
  exports.default = { version };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.57",
6
+ "version": "1.8.59",
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,13 +26,13 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.8.57",
30
- "@abtnode/constant": "1.8.57",
29
+ "@abtnode/client": "1.8.59",
30
+ "@abtnode/constant": "1.8.59",
31
31
  "@arcblock/did-auth": "1.18.34",
32
32
  "@arcblock/jwt": "1.18.34",
33
33
  "@arcblock/ws": "1.18.34",
34
- "@blocklet/constant": "1.8.57",
35
- "@blocklet/meta": "1.8.57",
34
+ "@blocklet/constant": "1.8.59",
35
+ "@blocklet/meta": "1.8.59",
36
36
  "@did-connect/authenticator": "^2.1.33",
37
37
  "@did-connect/handler": "^2.1.33",
38
38
  "@nedb/core": "^2.1.2",
@@ -69,5 +69,5 @@
69
69
  "ts-node": "^10.9.1",
70
70
  "typescript": "^4.8.4"
71
71
  },
72
- "gitHead": "2573eb9370c79853cba88cba418a964fb1cc8949"
72
+ "gitHead": "2cc84bf7f971585a6cc29b566d33c0a74d1ee94a"
73
73
  }