@or-sdk/bots 0.25.0-beta.427.0 → 0.25.0

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 +1 @@
1
- {"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAW1C,MAAM,OAAO,IAAK,SAAQ,IAAI;IAS5B,YAAY,MAAkB;QAC5B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAC/D,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,WAAW;YACvB,SAAS;YACT,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IASL,CAAC;IAEK,IAAI;;QAEV,CAAC;KAAA;IAQY,OAAO,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,UAAU,EAAE,cAAc,GAAG,KAAK,EAAE,eAAe,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,KAAoB,EAAE;;YAChI,IAAI,cAAc,IAAI,CAAC,eAAe;gBAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;YAC/D,IAAI,CAAC,cAAc,IAAI,eAAe;gBAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;YAChE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,OAAO;gBACd,MAAM,EAAE;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;oBACL,MAAM;iBACP;aACF,CAAC,CAAC;QACL,CAAC;KAAA;IAQY,QAAQ,CAAC,SAAyB,EAAE;;YAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;KAAA;IAQY,UAAU,CAAC,KAAa,EAAE,UAAqB;;YA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AAI,CAAC,OAAO,iCACd,MAAM,KACT,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IACrC,CAAC;QACL,CAAC;KAAA;IAQY,UAAU,CAAC,MAAW,EAAE,QAAkB;;YACrD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC;YAExC,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAE1D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;gBACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACnC;YAED,OAAO,IAAI,CAAC,OAAO,iCACd,MAAM,KACT,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,CAAC;QACL,CAAC;KAAA;CAEF"}
@@ -1,2 +1,10 @@
1
- export const SERVICE_KEY = 'datahub2';
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+ export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
3
+ deleteTemporarily(entity: $entity, data: $data) {
4
+ ... on AsyncRequest {
5
+ requestId
6
+ }
7
+ }
8
+ }`;
9
+ export const ENTITY_NAME = 'BOT';
2
10
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { Bots } from './Bots';
2
2
  export * from './types';
3
+ export * from './constants';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -1,26 +1,16 @@
1
- import { Base, List } from '@or-sdk/base';
2
- import { Bot, BotsConfig, GetBotsParams, ListBotsParams } from './types';
3
- export declare class Bots extends Base {
1
+ import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
2
+ import { BotsConfig, Bot, ListBotsParams, ListBotsResponse } from './types';
3
+ import { Taggable } from '@or-sdk/tags';
4
+ export declare class Bots implements Taggable<Bot> {
5
+ private readonly dataHub;
6
+ private readonly tags;
4
7
  constructor(params: BotsConfig);
5
8
  init(): Promise<void>;
6
- getBots({ query, projection, includeDeleted, includeExisting, limit, offset }?: GetBotsParams): Promise<List<Bot>>;
7
- listBots(params?: ListBotsParams): Promise<List<Bot>>;
8
- getBotById(botId: string, projection?: string[]): Promise<Bot>;
9
+ listBots(params?: ListBotsParams): Promise<ListBotsResponse>;
9
10
  getBot(id: string): Promise<Bot>;
10
- saveBot(bot: Bot): Promise<Bot>;
11
- deleteBot(bot: {
12
- id: string;
13
- }, temporarily?: boolean): Promise<null>;
14
- static getNewBot(): Promise<{
15
- data: {
16
- label: string;
17
- description: string;
18
- longDescription: string;
19
- iconUrl: string;
20
- deploy: {};
21
- };
22
- }>;
23
- recoverBot(bot: {
24
- id: string;
25
- }): Promise<null>;
11
+ saveBot(source: Bot): Promise<Bot>;
12
+ deleteBot(botId: string): Promise<GraphqlResponseCheckExecution>;
13
+ addTags(source: Bot, tagNames: string[]): Promise<Bot>;
14
+ removeTags(source: Bot, tagNames: string[]): Promise<Bot>;
26
15
  }
16
+ //# sourceMappingURL=Bots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bots.d.ts","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,6BAA6B,EAAyC,MAAM,kBAAkB,CAAC;AAClI,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAK5E,OAAO,EAAQ,QAAQ,EAA0C,MAAM,cAAc,CAAC;AAUtF,qBAAa,IAAK,YAAW,QAAQ,CAAC,GAAG,CAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;gBAQhB,MAAM,EAAE,UAAU;IAiBxB,IAAI;IAcG,QAAQ,CAAC,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkChE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBhC,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBlC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAoChE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBtD,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAgBvE"}
@@ -1 +1,4 @@
1
- export declare const SERVICE_KEY = "datahub2";
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+ export declare const QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
3
+ export declare const ENTITY_NAME = "BOT";
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,YAAY,4LAMvB,CAAC;AAEH,eAAO,MAAM,WAAW,QAAQ,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export { Bots } from './Bots';
2
2
  export * from './types';
3
+ export * from './constants';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -1,9 +1,9 @@
1
- import { Token } from '@or-sdk/base';
1
+ import { List, Token } from '@or-sdk/base';
2
2
  export declare type BotsConfig = {
3
3
  token: Token;
4
4
  discoveryUrl?: string;
5
5
  accountId?: string;
6
- dataHub2Url?: string;
6
+ dataHubUrl?: string;
7
7
  };
8
8
  export declare type Bot = {
9
9
  id?: string;
@@ -22,18 +22,10 @@ export declare type Bot = {
22
22
  schemaVersion?: number;
23
23
  tags?: string[];
24
24
  };
25
+ export declare type ListBotsResponse = List<Bot>;
25
26
  export declare type ListBotsParams = {
26
27
  includeDeleted?: boolean;
27
28
  includeExisting?: boolean;
28
29
  projection?: string[];
29
30
  };
30
- export declare type GetBotsParams = {
31
- includeDeleted?: boolean;
32
- includeExisting?: boolean;
33
- projection?: string[];
34
- query?: {
35
- [key: string]: any;
36
- };
37
- limit?: number;
38
- offset?: number;
39
- };
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE3C,oBAAY,UAAU,GAAG;IAIvB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,GAAG,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE;YACN,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzC,oBAAY,cAAc,GAAG;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC"}
@@ -3,3 +3,4 @@ declare function getListQuery({ projection, crossAccount }: {
3
3
  crossAccount: boolean;
4
4
  }): string;
5
5
  export default getListQuery;
6
+ //# sourceMappingURL=getListQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getListQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAEA,iBAAS,YAAY,CAAC,EAAE,UAAe,EAAE,YAAoB,EAAE,EAAE;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;CAAC,GAAG,MAAM,CAkCvH;AAED,eAAe,YAAY,CAAC"}
@@ -1 +1,2 @@
1
1
  export { default as getListQuery } from './getListQuery';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
- "version": "0.25.0-beta.427.0",
3
2
  "name": "@or-sdk/bots",
3
+ "version": "0.25.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "scripts": {
8
- "build": "npm run clean && concurrently \"npm run build:cjs\" \"npm run build:esm\" \"npm run build:types\"",
9
- "build:watch": "concurrently -r --hide 1,2 \"npm run build:watch:cjs\" \"npm run build:watch:esm\" \"npm run build:watch:types\"",
8
+ "build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
10
9
  "build:cjs": "tsc --project tsconfig.json",
11
- "build:watch:cjs": "tsc --project tsconfig.json -w",
12
10
  "build:esm": "tsc --project tsconfig.esm.json",
13
- "build:watch:esm": "tsc --project tsconfig.esm.json -w",
14
11
  "build:types": "tsc --project tsconfig.types.json",
12
+ "build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
13
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
14
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
15
15
  "build:watch:types": "tsc --project tsconfig.types.json -w",
16
16
  "clean": "rm -rf ./dist",
17
- "dev": "tsc --project tsconfig.dev.json -w"
17
+ "dev": "pnpm build:watch:esm"
18
+ },
19
+ "dependencies": {
20
+ "@or-sdk/base": "^0.26.3",
21
+ "@or-sdk/data-hub": "^0.25.0",
22
+ "@or-sdk/tags": "^0.25.0"
18
23
  },
19
24
  "devDependencies": {
20
25
  "concurrently": "^6.4.0",
@@ -23,9 +28,5 @@
23
28
  "publishConfig": {
24
29
  "access": "public"
25
30
  },
26
- "dependencies": {
27
- "@or-sdk/base": "^0.24.3-beta.427.0",
28
- "@or-sdk/data-hub": "^0.23.9-beta.427.0",
29
- "@or-sdk/tags": "^0.25.0-beta.427.0"
30
- }
31
+ "gitHead": "2359a0fc3850132af47bd9e0766b62185e66c986"
31
32
  }
package/src/Bots.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { Base, List } from '@or-sdk/base';
2
- // import { addTagsIds, filterTagIds, removeTagIds, Tags } from '@or-sdk/tags';
3
- import { SERVICE_KEY } from './constants';
4
- import { Bot, BotsConfig, GetBotsParams, ListBotsParams } from './types';
5
-
1
+ import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDelete, OperationNames } from '@or-sdk/data-hub';
2
+ import { BotsConfig, Bot, ListBotsParams, ListBotsResponse } from './types';
3
+ import {
4
+ QUERY_DELETE,
5
+ ENTITY_NAME,
6
+ } from './constants';
7
+ import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
8
+ import { getListQuery } from './utils';
6
9
 
7
10
  /**
8
11
  * OneReach Bots service client
@@ -11,8 +14,9 @@ import { Bot, BotsConfig, GetBotsParams, ListBotsParams } from './types';
11
14
  * $ npm i @or-sdk/bots
12
15
  * ```
13
16
  */
14
- export class Bots extends Base {
15
- // private readonly tags: Tags;
17
+ export class Bots implements Taggable<Bot> {
18
+ private readonly dataHub: DataHub;
19
+ private readonly tags: Tags;
16
20
 
17
21
  /**
18
22
  * ```typescript
@@ -21,47 +25,29 @@ export class Bots extends Base {
21
25
  * ```
22
26
  */
23
27
  constructor(params: BotsConfig) {
24
- const { token, discoveryUrl, accountId, dataHub2Url } = params;
25
- super({
28
+ const { token, discoveryUrl, accountId, dataHubUrl } = params;
29
+
30
+ this.dataHub = new DataHub({
26
31
  token,
27
32
  discoveryUrl,
28
- serviceKey: SERVICE_KEY,
29
33
  accountId,
30
- serviceUrl: dataHub2Url,
34
+ dataHubUrl,
35
+ });
36
+ this.tags = new Tags({
37
+ token,
38
+ discoveryUrl,
39
+ accountId,
40
+ dataHubUrl,
31
41
  });
32
-
33
- // this.tags = new Tags({
34
- // token,
35
- // discoveryUrl,
36
- // accountId,
37
- // serviceKey: SERVICE_KEY,
38
- // dataHub2Url,
39
- // });
40
42
  }
41
43
 
42
44
  async init() {
43
- // await this.tags.init();
45
+ await Promise.all([
46
+ this.dataHub.init(),
47
+ this.tags.init(),
48
+ ]);
44
49
  }
45
- /**
46
- * Get bots
47
- * ```typescript
48
- * const botList = await bots.getBots();
49
- * ```
50
- */
51
50
 
52
- public async getBots({ query = {}, projection, includeDeleted = false, includeExisting = true, limit, offset }: GetBotsParams = {}): Promise<List<Bot>> {
53
- if (includeDeleted && !includeExisting) query.isDeleted = true;
54
- if (!includeDeleted && includeExisting) query.isDeleted = false;
55
- return this.callApiV2({
56
- route: '/bots',
57
- params: {
58
- query,
59
- projection,
60
- limit,
61
- offset,
62
- },
63
- });
64
- }
65
51
 
66
52
  /**
67
53
  * List bots
@@ -69,24 +55,34 @@ export class Bots extends Base {
69
55
  * const botList = await bots.listBots();
70
56
  * ```
71
57
  */
72
- public async listBots(params: ListBotsParams = {}): Promise<List<Bot>> {
73
- return this.getBots(params);
74
- }
75
-
76
- /**
77
- * Get bot by id
78
- * ```typescript
79
- * const bot = await bots.getBotById('bot-id');
80
- * ```
81
- */
82
- public async getBotById(botId: string, projection?: string[]): Promise<Bot> {
83
- return this.callApiV2({
84
- route: `/bots/${botId}`,
58
+ public async listBots(params: ListBotsParams = {}): Promise<ListBotsResponse> {
59
+ const { projection = [], ...varPrams } = params;
60
+ const variables = {
61
+ entity: ENTITY_NAME,
85
62
  params: {
86
- projection,
63
+ queryParams: {},
64
+ includeDeleted: false,
65
+ includeExisting: true,
66
+ limit: 30,
67
+
68
+ // overrides
69
+ ...varPrams,
87
70
  },
88
- });
71
+ ... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
72
+ };
73
+
74
+ const data = {
75
+ operationName: this.dataHub.getOperationName(OperationNames.LIST),
76
+ query: getListQuery({
77
+ crossAccount: this.dataHub.isCrossAccount,
78
+ projection,
79
+ }),
80
+ variables,
81
+ };
82
+
83
+ return this.dataHub.getFullList<Bot>('POST', '/graphql', data);
89
84
  }
85
+
90
86
  /**
91
87
  * Get bot
92
88
  * ```typescript
@@ -94,7 +90,18 @@ export class Bots extends Base {
94
90
  * ```
95
91
  */
96
92
  public async getBot(id: string): Promise<Bot> {
97
- return this.getBotById(id);
93
+ const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${id}`;
94
+
95
+ const params = {
96
+ includeDeleted: false,
97
+ includeExisting: true,
98
+ };
99
+
100
+ return await this.dataHub.makeRequest<Bot>({
101
+ method: 'GET',
102
+ route,
103
+ params,
104
+ });
98
105
  }
99
106
 
100
107
  /**
@@ -105,20 +112,18 @@ export class Bots extends Base {
105
112
  * const savedBot = await bots.saveBot(botSource);
106
113
  * ```
107
114
  */
108
- public async saveBot(bot: Bot): Promise<Bot> {
109
- bot.id = bot.id || 'new';
110
- const { id } = await this.callApiV2({
111
- route: `/bots/${bot.id}`,
112
- data: {
113
- bot,
114
- },
115
- method: 'post',
116
- });
115
+ public async saveBot(source: Bot): Promise<Bot> {
116
+ const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${source.id ? source.id : 'new'}`;
117
117
 
118
- return {
119
- ...bot,
120
- id,
118
+ const data = {
119
+ bot: source,
121
120
  };
121
+
122
+ return await this.dataHub.makeRequest<Bot>({
123
+ method: 'POST',
124
+ route,
125
+ data,
126
+ });
122
127
  }
123
128
 
124
129
  /**
@@ -127,14 +132,34 @@ export class Bots extends Base {
127
132
  * await bots.deleteBot('bot-id');
128
133
  * ```
129
134
  */
130
- public async deleteBot(bot: {id: string;}, temporarily = true): Promise<null> {
131
- return this.callApiV2({
132
- route: `/bots/${bot.id}`,
135
+ public async deleteBot(botId: string): Promise<GraphqlResponseCheckExecution> {
136
+ if (this.dataHub.isCrossAccount) {
137
+ throw Error('Cross-account deleting is not implemented.');
138
+ }
139
+
140
+ const variables = {
141
+ entity: ENTITY_NAME,
133
142
  data: {
134
- temporarily,
143
+ id: botId,
144
+ subscribe: true,
135
145
  },
136
- method: 'delete',
146
+ };
147
+
148
+ const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
149
+
150
+ const data = {
151
+ operationName,
152
+ query: QUERY_DELETE,
153
+ variables,
154
+ };
155
+
156
+ const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
157
+ method: 'POST',
158
+ route: '/graphql',
159
+ data,
137
160
  });
161
+
162
+ return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
138
163
  }
139
164
 
140
165
  /**
@@ -143,21 +168,21 @@ export class Bots extends Base {
143
168
  * const bot = await bots.addTags(botSource, tagIdsArr);
144
169
  * ```
145
170
  */
146
- // public async addTags(source: Bot, tagNames: string[]): Promise<Bot> {
147
- // const tags = await this.tags.getMultipleTagsByName(tagNames, true);
148
- // const tagIds = tags.map(tag => tag.id!);
171
+ public async addTags(source: Bot, tagNames: string[]): Promise<Bot> {
172
+ const tags = await this.tags.getMultipleTagsByName(tagNames, true);
173
+ const tagIds = tags.map(tag => tag.id!);
149
174
 
150
- // const { newIds } = filterTagIds(source.tags, tagIds);
175
+ const { newIds } = filterTagIds(source.tags, tagIds);
151
176
 
152
- // if (!newIds.length) {
153
- // throw Error('No tags to add.');
154
- // }
177
+ if (!newIds.length) {
178
+ throw Error('No tags to add.');
179
+ }
155
180
 
156
- // return this.saveBot({
157
- // ...source,
158
- // tags: addTagsIds(source.tags, newIds),
159
- // });
160
- // }
181
+ return this.saveBot({
182
+ ...source,
183
+ tags: addTagsIds(source.tags, newIds),
184
+ });
185
+ }
161
186
 
162
187
  /**
163
188
  * Remove tags
@@ -165,50 +190,20 @@ export class Bots extends Base {
165
190
  * const bot = await bots.removeTags(botSource, tagIdsArr);
166
191
  * ```
167
192
  */
168
- // public async removeTags(source: Bot, tagNames: string[]): Promise<Bot> {
169
- // const tags = await this.tags.getMultipleTagsByName(tagNames);
170
- // const tagIds = tags.map(tag => tag.id!);
171
-
172
- // const { existingIds } = filterTagIds(source.tags, tagIds);
193
+ public async removeTags(source: Bot, tagNames: string[]): Promise<Bot> {
194
+ const tags = await this.tags.getMultipleTagsByName(tagNames);
195
+ const tagIds = tags.map(tag => tag.id!);
173
196
 
174
- // if (!existingIds.length) {
175
- // throw Error('No tags to remove.');
176
- // }
197
+ const { existingIds } = filterTagIds(source.tags, tagIds);
177
198
 
178
- // return this.saveBot({
179
- // ...source,
180
- // tags: removeTagIds(source.tags, existingIds),
181
- // });
182
- // }
183
-
184
- /**
185
- * Get new bot
186
- * ```typescript
187
- * const bot = await bots.getNewBot();
188
- * ```
189
- */
190
- static async getNewBot() {
191
- return {
192
- data: {
193
- label: '',
194
- description: '',
195
- longDescription: '',
196
- iconUrl: '',
197
- deploy: {},
198
- },
199
- };
200
- }
199
+ if (!existingIds.length) {
200
+ throw Error('No tags to remove.');
201
+ }
201
202
 
202
- /**
203
- * Recover deleted bot
204
- * ```typescript
205
- * const bot = await bots.recoverBot({id});
206
- * ```
207
- */
208
- public async recoverBot(bot: {id: string;}): Promise<null> {
209
- return this.callApiV2({
210
- route: `/bots/${bot.id}`,
211
- method: 'patch',
203
+ return this.saveBot({
204
+ ...source,
205
+ tags: removeTagIds(source.tags, existingIds),
212
206
  });
213
207
  }
208
+
214
209
  }
package/src/constants.ts CHANGED
@@ -1,2 +1,12 @@
1
- export const SERVICE_KEY = 'datahub2';
1
+ export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
2
+
3
+ export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
4
+ deleteTemporarily(entity: $entity, data: $data) {
5
+ ... on AsyncRequest {
6
+ requestId
7
+ }
8
+ }
9
+ }`;
10
+
11
+ export const ENTITY_NAME = 'BOT';
2
12
 
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Bots } from './Bots';
2
2
  export * from './types';
3
+ export * from './constants';
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Token } from '@or-sdk/base';
1
+ import { List, Token } from '@or-sdk/base';
2
2
 
3
3
  export type BotsConfig = {
4
4
  /**
@@ -19,7 +19,7 @@ export type BotsConfig = {
19
19
  /**
20
20
  * Url of OneReach DataHub api
21
21
  */
22
- dataHub2Url?: string;
22
+ dataHubUrl?: string;
23
23
  };
24
24
 
25
25
  export type Bot = {
@@ -40,17 +40,10 @@ export type Bot = {
40
40
  tags?: string[];
41
41
  };
42
42
 
43
- export type ListBotsParams = {
44
- includeDeleted?: boolean;
45
- includeExisting?: boolean;
46
- projection?: string[];
47
- };
43
+ export type ListBotsResponse = List<Bot>;
48
44
 
49
- export type GetBotsParams = {
45
+ export type ListBotsParams = {
50
46
  includeDeleted?: boolean;
51
47
  includeExisting?: boolean;
52
48
  projection?: string[];
53
- query?: {[key: string]: any;};
54
- limit?: number;
55
- offset?: number;
56
49
  };
package/tsconfig.dev.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "extends": "./tsconfig.esm.json",
3
3
  "compilerOptions": {
4
- "outDir": "./dist/types",
4
+ "declarationDir": "./dist/types",
5
5
  "rootDir": "./src",
6
- "declaration": true,
6
+ "declaration": true
7
7
  }
8
8
  }
package/tsconfig.esm.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
+ "outDir": "./dist/esm",
5
+ "declarationDir": "./dist/types",
4
6
  "module": "ES6",
5
7
  "target": "es6",
6
- "outDir": "./dist/esm/",
7
- "rootDir": "./src"
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true
8
11
  }
9
- }
12
+ }
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "outDir": "./dist/types/",
4
+ "outDir": "./dist/types",
5
5
  "rootDir": "./src",
6
6
  "declaration": true,
7
+ "declarationMap": true,
7
8
  "emitDeclarationOnly": true
8
9
  }
9
10
  }