@or-sdk/cards 0.26.0-beta.631.0 → 0.26.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.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/cjs/Cards.js +79 -121
- package/dist/cjs/Cards.js.map +1 -1
- package/dist/cjs/constants.js +3 -13
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Cards.js +105 -141
- package/dist/esm/Cards.js.map +1 -1
- package/dist/esm/constants.js +1 -367
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Cards.d.ts +6 -6
- package/dist/types/Cards.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -11
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +13 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/Cards.ts +83 -131
- package/src/constants.ts +1 -376
- package/src/types.ts +16 -2
- package/tsconfig.esm.json +1 -1
package/dist/types/Cards.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { List } from '@or-sdk/base';
|
|
2
|
-
import {
|
|
3
|
-
import { CardsConfig, Card } from './types';
|
|
2
|
+
import { CardsConfig, Card, ListCardsParams, PaginationOptions } from './types';
|
|
4
3
|
import { Taggable } from '@or-sdk/tags';
|
|
5
4
|
export declare class Cards implements Taggable<Card> {
|
|
6
|
-
private readonly
|
|
5
|
+
private readonly dataHubSvc;
|
|
7
6
|
private readonly tags;
|
|
8
7
|
constructor(params: CardsConfig);
|
|
9
|
-
|
|
10
|
-
listCards(): Promise<List<Card>>;
|
|
8
|
+
listCards(params?: ListCardsParams, paginationOptions?: PaginationOptions): Promise<List<Card>>;
|
|
11
9
|
getCard(id: string): Promise<Card>;
|
|
12
10
|
saveCard(source: Card): Promise<Card>;
|
|
13
11
|
createCard(source: Card): Promise<Card>;
|
|
14
12
|
updateCard(source: Card): Promise<Card>;
|
|
15
|
-
deleteCard(cardId: string): Promise<
|
|
13
|
+
deleteCard(cardId: string, temporarily?: boolean): Promise<void>;
|
|
14
|
+
recoverCard(cardId: string): Promise<void>;
|
|
15
|
+
cloneCard(cardId: string, keepTemplateDetails?: boolean): Promise<Card>;
|
|
16
16
|
addTags(source: Card, tagNames: string[]): Promise<Card>;
|
|
17
17
|
removeTags(source: Card, tagNames: string[]): Promise<Card>;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cards.d.ts","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"Cards.d.ts","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAQ,QAAQ,EAA0C,MAAM,cAAc,CAAC;AAEtF,qBAAa,KAAM,YAAW,QAAQ,CAAC,IAAI,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;gBAEhB,MAAM,EAAE,WAAW;IAuBlB,SAAS,CAAC,MAAM,GAAE,eAAoB,EAAE,iBAAiB,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAoBvG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlC,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrC,UAAU,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBvC,UAAU,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBvC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB7D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB1C,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBpE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBxD,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzE"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export declare const QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n last\n }\n}\n";
|
|
3
|
-
export declare const QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n last\n }\n}\n";
|
|
4
|
-
export declare const QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
5
|
-
export declare const QUERY_GET_CROSSACCOUNT = "query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
6
|
-
export declare const QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
7
|
-
export declare const QUERY_CREATE_CROSSACCOUNT = "mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {\n createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
8
|
-
export declare const QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
9
|
-
export declare const QUERY_UPDATE_CROSSACCOUNT = "mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {\n updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n tagIds\n }\n reference {\n id\n type\n }\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}\n";
|
|
10
|
-
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}";
|
|
11
|
-
export declare const ENTITY_NAME = "CARD";
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
|
12
2
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare type CardsConfig = {
|
|
|
3
3
|
token: Token;
|
|
4
4
|
discoveryUrl?: string;
|
|
5
5
|
accountId?: string;
|
|
6
|
-
|
|
6
|
+
dataHubSvcUrl?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type Card = {
|
|
9
9
|
id?: string;
|
|
@@ -41,4 +41,16 @@ export declare type Card = {
|
|
|
41
41
|
reference?: string | null;
|
|
42
42
|
template?: string | null;
|
|
43
43
|
};
|
|
44
|
+
export declare type ListCardsParams = {
|
|
45
|
+
query?: {
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
projection?: string[];
|
|
49
|
+
group?: string[];
|
|
50
|
+
sandbox?: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare type PaginationOptions = {
|
|
53
|
+
limit?: number;
|
|
54
|
+
offset?: number;
|
|
55
|
+
};
|
|
44
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,WAAW,GAAG;IAIxB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,WAAW,GAAG;IAIxB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,oBAAY,IAAI,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE;gBACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,GAAG,IAAI,CAAC;SACV,CAAC;QACF,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE;gBACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;aACxB,CAAC;SACH,CAAC;QACF,IAAI,EAAE;YACJ,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC;YACf,YAAY,EAAE,MAAM,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,EAAE,CAAC;YACtB,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;QACF,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/cards",
|
|
3
|
-
"version": "0.26.0
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dev": "pnpm build:watch:esm"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@or-sdk/base": "^0.
|
|
21
|
-
"@or-sdk/data-hub": "^
|
|
22
|
-
"@or-sdk/tags": "^0.26.0
|
|
20
|
+
"@or-sdk/base": "^0.26.7",
|
|
21
|
+
"@or-sdk/data-hub-svc": "^2.0.0",
|
|
22
|
+
"@or-sdk/tags": "^0.26.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"concurrently": "^6.4.0",
|
|
@@ -27,5 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "33b5f8276be1644a5e3567c87e19174e910a61ef"
|
|
31
32
|
}
|
package/src/Cards.ts
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
import { List } from '@or-sdk/base';
|
|
2
|
-
import {
|
|
3
|
-
import { CardsConfig, Card } from './types';
|
|
4
|
-
import {
|
|
5
|
-
ENTITY_NAME,
|
|
6
|
-
QUERY_LIST,
|
|
7
|
-
QUERY_GET,
|
|
8
|
-
QUERY_CREATE,
|
|
9
|
-
QUERY_UPDATE,
|
|
10
|
-
QUERY_DELETE,
|
|
11
|
-
QUERY_LIST_CROSSACCOUNT,
|
|
12
|
-
QUERY_GET_CROSSACCOUNT,
|
|
13
|
-
QUERY_CREATE_CROSSACCOUNT,
|
|
14
|
-
QUERY_UPDATE_CROSSACCOUNT,
|
|
15
|
-
} from './constants';
|
|
1
|
+
import { List, makeList } from '@or-sdk/base';
|
|
2
|
+
import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
|
|
3
|
+
import { CardsConfig, Card, ListCardsParams, PaginationOptions } from './types';
|
|
16
4
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
17
5
|
|
|
18
6
|
export class Cards implements Taggable<Card> {
|
|
19
|
-
private readonly
|
|
7
|
+
private readonly dataHubSvc: DataHubSvc;
|
|
20
8
|
private readonly tags: Tags;
|
|
21
9
|
|
|
22
10
|
constructor(params: CardsConfig) {
|
|
23
|
-
const { token, discoveryUrl, accountId,
|
|
11
|
+
const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
|
|
24
12
|
|
|
25
|
-
this.
|
|
13
|
+
this.dataHubSvc = new DataHubSvc({
|
|
26
14
|
token,
|
|
27
15
|
discoveryUrl,
|
|
28
16
|
accountId,
|
|
29
|
-
|
|
17
|
+
dataHubSvcUrl,
|
|
30
18
|
});
|
|
31
19
|
this.tags = new Tags({
|
|
32
20
|
token,
|
|
33
21
|
discoveryUrl,
|
|
34
22
|
accountId,
|
|
35
|
-
|
|
23
|
+
dataHubSvcUrl,
|
|
36
24
|
});
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async init() {
|
|
41
|
-
await Promise.all([
|
|
42
|
-
this.dataHub.init(),
|
|
43
|
-
this.tags.init(),
|
|
44
|
-
]);
|
|
45
25
|
}
|
|
46
26
|
|
|
47
27
|
/**
|
|
@@ -50,27 +30,18 @@ export class Cards implements Taggable<Card> {
|
|
|
50
30
|
* const cardList = await cards.listCards();
|
|
51
31
|
* ```
|
|
52
32
|
*/
|
|
53
|
-
public async listCards(): Promise<List<Card>> {
|
|
54
|
-
const
|
|
55
|
-
|
|
33
|
+
public async listCards(params: ListCardsParams = {}, paginationOptions: PaginationOptions = {}): Promise<List<Card>> {
|
|
34
|
+
const result = await this.dataHubSvc.makeRequest<Card[]>({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
route: 'get-cards',
|
|
56
37
|
params: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
limit: 30,
|
|
38
|
+
...params,
|
|
39
|
+
...paginationOptions,
|
|
40
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
61
41
|
},
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const operationName = this.dataHub.getOperationName(OperationNames.LIST);
|
|
66
|
-
|
|
67
|
-
const data = {
|
|
68
|
-
operationName,
|
|
69
|
-
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
70
|
-
variables,
|
|
71
|
-
};
|
|
42
|
+
});
|
|
72
43
|
|
|
73
|
-
return
|
|
44
|
+
return makeList<Card>(result);
|
|
74
45
|
}
|
|
75
46
|
|
|
76
47
|
/**
|
|
@@ -80,31 +51,13 @@ export class Cards implements Taggable<Card> {
|
|
|
80
51
|
* ```
|
|
81
52
|
*/
|
|
82
53
|
public async getCard(id: string): Promise<Card> {
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
return this.dataHubSvc.makeRequest<Card>({
|
|
55
|
+
method: 'GET',
|
|
56
|
+
route: `cards/${id}`,
|
|
85
57
|
params: {
|
|
86
|
-
|
|
87
|
-
includeDeleted: false,
|
|
88
|
-
includeExisting: true,
|
|
58
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
89
59
|
},
|
|
90
|
-
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const operationName = this.dataHub.getOperationName(OperationNames.GET);
|
|
94
|
-
|
|
95
|
-
const data = {
|
|
96
|
-
operationName,
|
|
97
|
-
query: this.dataHub.isCrossAccount ? QUERY_GET_CROSSACCOUNT : QUERY_GET,
|
|
98
|
-
variables,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
102
|
-
method: 'POST',
|
|
103
|
-
route: '/graphql',
|
|
104
|
-
data,
|
|
105
60
|
});
|
|
106
|
-
|
|
107
|
-
return result.data[operationName] as Card;
|
|
108
61
|
}
|
|
109
62
|
|
|
110
63
|
/**
|
|
@@ -116,7 +69,7 @@ export class Cards implements Taggable<Card> {
|
|
|
116
69
|
* ```
|
|
117
70
|
*/
|
|
118
71
|
public async saveCard(source: Card): Promise<Card> {
|
|
119
|
-
return source.id ? this.updateCard(source) : this.createCard(source);
|
|
72
|
+
return (source.id && source.id !== 'new') ? this.updateCard(source) : this.createCard(source);
|
|
120
73
|
}
|
|
121
74
|
|
|
122
75
|
/**
|
|
@@ -126,29 +79,21 @@ export class Cards implements Taggable<Card> {
|
|
|
126
79
|
* ```
|
|
127
80
|
*/
|
|
128
81
|
public async createCard(source: Card): Promise<Card> {
|
|
129
|
-
const
|
|
130
|
-
|
|
82
|
+
const result = await this.dataHubSvc.makeRequest<{ id: string; }>({
|
|
83
|
+
method: 'POST',
|
|
84
|
+
route: 'cards/new',
|
|
131
85
|
data: {
|
|
132
|
-
|
|
86
|
+
card: {
|
|
87
|
+
...source,
|
|
88
|
+
id: 'new', //TODO: remove later
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
params: {
|
|
92
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
133
93
|
},
|
|
134
|
-
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const operationName = this.dataHub.getOperationName(OperationNames.CREATE);
|
|
138
|
-
|
|
139
|
-
const data = {
|
|
140
|
-
operationName,
|
|
141
|
-
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
142
|
-
variables,
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
146
|
-
method: 'POST',
|
|
147
|
-
route: '/graphql',
|
|
148
|
-
data,
|
|
149
94
|
});
|
|
150
95
|
|
|
151
|
-
return result
|
|
96
|
+
return setDiff<Card>(source, result);
|
|
152
97
|
}
|
|
153
98
|
|
|
154
99
|
/**
|
|
@@ -158,30 +103,18 @@ export class Cards implements Taggable<Card> {
|
|
|
158
103
|
* ```
|
|
159
104
|
*/
|
|
160
105
|
public async updateCard(source: Card): Promise<Card> {
|
|
161
|
-
const
|
|
162
|
-
|
|
106
|
+
const result = await this.dataHubSvc.makeRequest<{ id: string; }>({
|
|
107
|
+
method: 'POST',
|
|
108
|
+
route: `cards/${source.id}`,
|
|
163
109
|
data: {
|
|
164
|
-
|
|
165
|
-
|
|
110
|
+
card: source,
|
|
111
|
+
},
|
|
112
|
+
params: {
|
|
113
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
166
114
|
},
|
|
167
|
-
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const operationName = this.dataHub.getOperationName(OperationNames.UPDATE);
|
|
171
|
-
|
|
172
|
-
const data = {
|
|
173
|
-
operationName,
|
|
174
|
-
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
175
|
-
variables,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
179
|
-
method: 'POST',
|
|
180
|
-
route: '/graphql',
|
|
181
|
-
data,
|
|
182
115
|
});
|
|
183
116
|
|
|
184
|
-
return result
|
|
117
|
+
return setDiff<Card>(source, result);
|
|
185
118
|
}
|
|
186
119
|
|
|
187
120
|
/**
|
|
@@ -190,34 +123,52 @@ export class Cards implements Taggable<Card> {
|
|
|
190
123
|
* await cards.deleteCard('card-id');
|
|
191
124
|
* ```
|
|
192
125
|
*/
|
|
193
|
-
public async deleteCard(cardId: string): Promise<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const variables = {
|
|
199
|
-
entity: ENTITY_NAME,
|
|
126
|
+
public async deleteCard(cardId: string, temporarily = true): Promise<void> {
|
|
127
|
+
return this.dataHubSvc.makeRequest<void>({
|
|
128
|
+
method: 'DELETE',
|
|
129
|
+
route: `cards/${cardId}`,
|
|
200
130
|
data: {
|
|
201
|
-
|
|
202
|
-
subscribe: true,
|
|
131
|
+
temporarily,
|
|
203
132
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
operationName,
|
|
210
|
-
query: QUERY_DELETE,
|
|
211
|
-
variables,
|
|
212
|
-
};
|
|
133
|
+
params: {
|
|
134
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
213
138
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Recover card
|
|
141
|
+
* ```typescript
|
|
142
|
+
* await cards.recoverCard('card-id');
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
public async recoverCard(cardId: string): Promise<void> {
|
|
146
|
+
return this.dataHubSvc.makeRequest<void>({
|
|
147
|
+
method: 'PATCH',
|
|
148
|
+
route: `cards/${cardId}`,
|
|
149
|
+
params: {
|
|
150
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
151
|
+
},
|
|
218
152
|
});
|
|
153
|
+
}
|
|
219
154
|
|
|
220
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Clone card
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const result = await cards.cloneCard('card-id');
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
public async cloneCard(cardId: string, keepTemplateDetails = true): Promise<Card> {
|
|
162
|
+
return this.dataHubSvc.makeRequest<Card>({
|
|
163
|
+
method: 'PUT',
|
|
164
|
+
route: `cards/${cardId}`,
|
|
165
|
+
data: {
|
|
166
|
+
keepTemplateDetails,
|
|
167
|
+
},
|
|
168
|
+
params: {
|
|
169
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
170
|
+
},
|
|
171
|
+
});
|
|
221
172
|
}
|
|
222
173
|
|
|
223
174
|
/**
|
|
@@ -269,4 +220,5 @@ export class Cards implements Taggable<Card> {
|
|
|
269
220
|
},
|
|
270
221
|
});
|
|
271
222
|
}
|
|
223
|
+
|
|
272
224
|
}
|