@atlaskit/editor-synced-block-provider 3.1.0 → 3.2.1
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 +14 -0
- package/dist/cjs/clients/block-service/ari.js +13 -16
- package/dist/cjs/clients/block-service/blockService.js +37 -14
- package/dist/cjs/clients/confluence/ari.js +7 -40
- package/dist/cjs/clients/confluence/sourceInfo.js +3 -1
- package/dist/cjs/clients/jira/ari.js +5 -2
- package/dist/cjs/index.js +2 -27
- package/dist/cjs/providers/block-service/blockServiceAPI.js +71 -28
- package/dist/cjs/providers/syncBlockProvider.js +57 -38
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +5 -8
- package/dist/es2019/clients/block-service/ari.js +15 -16
- package/dist/es2019/clients/block-service/blockService.js +39 -7
- package/dist/es2019/clients/confluence/ari.js +11 -37
- package/dist/es2019/clients/confluence/sourceInfo.js +3 -1
- package/dist/es2019/clients/jira/ari.js +9 -2
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/providers/block-service/blockServiceAPI.js +75 -28
- package/dist/es2019/providers/syncBlockProvider.js +45 -25
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +5 -8
- package/dist/esm/clients/block-service/ari.js +13 -16
- package/dist/esm/clients/block-service/blockService.js +37 -14
- package/dist/esm/clients/confluence/ari.js +6 -39
- package/dist/esm/clients/confluence/sourceInfo.js +3 -1
- package/dist/esm/clients/jira/ari.js +5 -2
- package/dist/esm/index.js +2 -3
- package/dist/esm/providers/block-service/blockServiceAPI.js +70 -27
- package/dist/esm/providers/syncBlockProvider.js +57 -38
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +4 -8
- package/dist/types/clients/block-service/ari.d.ts +14 -4
- package/dist/types/clients/block-service/blockService.d.ts +1 -2
- package/dist/types/clients/confluence/ari.d.ts +8 -21
- package/dist/types/clients/jira/ari.d.ts +7 -2
- package/dist/types/index.d.ts +5 -6
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +31 -6
- package/dist/types/providers/syncBlockProvider.d.ts +14 -13
- package/dist/types/providers/types.d.ts +9 -6
- package/dist/types-ts4.5/clients/block-service/ari.d.ts +14 -4
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +1 -2
- package/dist/types-ts4.5/clients/confluence/ari.d.ts +8 -21
- package/dist/types-ts4.5/clients/jira/ari.d.ts +7 -2
- package/dist/types-ts4.5/index.d.ts +5 -6
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +31 -6
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +14 -13
- package/dist/types-ts4.5/providers/types.d.ts +9 -6
- package/package.json +1 -1
- package/dist/cjs/clients/confluence/contentProperty.js +0 -284
- package/dist/cjs/providers/confluence/confluenceContentAPI.js +0 -446
- package/dist/es2019/clients/confluence/contentProperty.js +0 -288
- package/dist/es2019/providers/confluence/confluenceContentAPI.js +0 -310
- package/dist/esm/clients/confluence/contentProperty.js +0 -277
- package/dist/esm/providers/confluence/confluenceContentAPI.js +0 -440
- package/dist/types/clients/confluence/contentProperty.d.ts +0 -139
- package/dist/types/providers/confluence/confluenceContentAPI.d.ts +0 -44
- package/dist/types-ts4.5/clients/confluence/contentProperty.d.ts +0 -139
- package/dist/types-ts4.5/providers/confluence/confluenceContentAPI.d.ts +0 -44
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
* @param cloudId - the cloud ID
|
|
5
5
|
* @returns the Jira work item ARI
|
|
6
6
|
*/
|
|
7
|
-
export declare const getJiraWorkItemAri: (
|
|
7
|
+
export declare const getJiraWorkItemAri: ({ cloudId, workItemId, }: {
|
|
8
|
+
cloudId: string;
|
|
9
|
+
workItemId: string;
|
|
10
|
+
}) => string;
|
|
8
11
|
/**
|
|
9
12
|
* Extracts the Jira work item ID from the Jira work item ARI
|
|
10
13
|
* @param ari - the Jira work item ARI
|
|
11
14
|
* @returns the Jira work item ID
|
|
12
15
|
*/
|
|
13
|
-
export declare const getJiraWorkItemIdFromAri: (ari:
|
|
16
|
+
export declare const getJiraWorkItemIdFromAri: ({ ari }: {
|
|
17
|
+
ari: string;
|
|
18
|
+
}) => string;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
export { rebaseTransaction } from './common/rebase-transaction';
|
|
2
2
|
export { SyncBlockError } from './common/types';
|
|
3
|
-
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, } from './common/types';
|
|
3
|
+
export type { SyncBlockData, SyncBlockNode, SyncBlockProduct, BlockInstanceId, SyncBlockAttrs, } from './common/types';
|
|
4
4
|
export { useFetchSyncBlockData, type UseFetchSyncBlockDataResult, } from './hooks/useFetchSyncBlockData';
|
|
5
5
|
export { useFetchSyncBlockTitle } from './hooks/useFetchSyncBlockTitle';
|
|
6
6
|
export { useHandleContentChanges } from './hooks/useHandleContentChanges';
|
|
7
7
|
export { generateBlockAri, generateBlockAriFromReference, getLocalIdFromBlockResourceId, } from './clients/block-service/ari';
|
|
8
|
-
export { getConfluencePageAri,
|
|
8
|
+
export { getConfluencePageAri, getPageIdAndTypeFromConfluencePageAri, } from './clients/confluence/ari';
|
|
9
9
|
export { getJiraWorkItemAri, getJiraWorkItemIdFromAri } from './clients/jira/ari';
|
|
10
|
-
export { useMemoizedBlockServiceAPIProviders } from './providers/block-service/blockServiceAPI';
|
|
11
|
-
export { createContentAPIProvidersWithDefaultKey, useMemoizedContentAPIProviders, } from './providers/confluence/confluenceContentAPI';
|
|
10
|
+
export { useMemoizedBlockServiceAPIProviders, useMemoizedBlockServiceFetchOnlyAPIProvider, } from './providers/block-service/blockServiceAPI';
|
|
12
11
|
export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
|
|
13
12
|
export { SyncBlockProvider as SyncedBlockProvider, useMemoizedSyncedBlockProvider, } from './providers/syncBlockProvider';
|
|
14
|
-
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, } from './providers/types';
|
|
13
|
+
export type { ADFFetchProvider, ADFWriteProvider, SyncBlockDataProvider, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, } from './providers/types';
|
|
15
14
|
export { type ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
|
|
16
15
|
export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
|
|
17
16
|
export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
|
|
18
|
-
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, getContentIdAndProductFromResourceId } from './utils/utils';
|
|
17
|
+
export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, getContentIdAndProductFromResourceId, } from './utils/utils';
|
|
19
18
|
export { fetchErrorPayload } from './utils/errorHandling';
|
|
20
19
|
export { fetchReferences } from './providers/block-service/blockServiceAPI';
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { SyncBlockError, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
|
|
2
2
|
import type { ADFFetchProvider, ADFWriteProvider, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
|
|
3
3
|
export declare const fetchReferences: (documentAri: string) => Promise<SyncBlockInstance[] | SyncBlockError>;
|
|
4
|
+
interface BlockServiceADFFetchProviderProps {
|
|
5
|
+
cloudId: string;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* ADFFetchProvider implementation that fetches synced block data from Block Service API
|
|
6
9
|
*/
|
|
7
10
|
declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
|
|
8
|
-
private
|
|
9
|
-
constructor(
|
|
11
|
+
private cloudId;
|
|
12
|
+
constructor({ cloudId }: BlockServiceADFFetchProviderProps);
|
|
10
13
|
fetchData(resourceId: string): Promise<SyncBlockInstance>;
|
|
11
14
|
}
|
|
15
|
+
interface BlockServiceADFWriteProviderProps {
|
|
16
|
+
cloudId: string;
|
|
17
|
+
getVersion?: () => number | undefined;
|
|
18
|
+
parentAri: string;
|
|
19
|
+
parentId: string;
|
|
20
|
+
product: SyncBlockProduct;
|
|
21
|
+
}
|
|
12
22
|
/**
|
|
13
23
|
* ADFWriteProvider implementation that writes synced block data to Block Service API
|
|
14
24
|
*/
|
|
15
25
|
declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
16
|
-
private
|
|
17
|
-
private
|
|
26
|
+
private cloudId;
|
|
27
|
+
private parentAri;
|
|
28
|
+
private parentId;
|
|
18
29
|
private getVersion?;
|
|
19
30
|
product: SyncBlockProduct;
|
|
20
|
-
constructor(
|
|
31
|
+
constructor({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceADFWriteProviderProps);
|
|
21
32
|
writeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
22
33
|
createData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
23
34
|
deleteData(resourceId: string): Promise<DeleteSyncBlockResult>;
|
|
@@ -25,8 +36,22 @@ declare class BlockServiceADFWriteProvider implements ADFWriteProvider {
|
|
|
25
36
|
generateResourceId(): ResourceId;
|
|
26
37
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
27
38
|
}
|
|
28
|
-
|
|
39
|
+
interface BlockServiceAPIProvidersProps {
|
|
40
|
+
cloudId: string;
|
|
41
|
+
getVersion?: () => number | undefined;
|
|
42
|
+
parentAri: string;
|
|
43
|
+
parentId: string;
|
|
44
|
+
product: SyncBlockProduct;
|
|
45
|
+
}
|
|
46
|
+
export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceAPIProvidersProps) => {
|
|
29
47
|
fetchProvider: BlockServiceADFFetchProvider;
|
|
30
48
|
writeProvider: BlockServiceADFWriteProvider;
|
|
31
49
|
};
|
|
50
|
+
interface BlockServiceFetchOnlyAPIProviderProps {
|
|
51
|
+
cloudId: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const useMemoizedBlockServiceFetchOnlyAPIProvider: ({ cloudId, }: BlockServiceFetchOnlyAPIProviderProps) => {
|
|
54
|
+
fetchProvider: BlockServiceADFFetchProvider;
|
|
55
|
+
writeProvider: undefined;
|
|
56
|
+
};
|
|
32
57
|
export {};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { JSONNode } from '@atlaskit/editor-json-transformer/types';
|
|
3
3
|
import { type BlockInstanceId, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockNode, type SyncBlockProduct } from '../common/types';
|
|
4
|
-
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from '
|
|
4
|
+
import { SyncBlockDataProvider, type ADFFetchProvider, type ADFWriteProvider, type DeleteSyncBlockResult, type SyncBlockInstance, type SyncBlockParentInfo, type SyncBlockSourceInfo, type SyncedBlockRendererProviderOptions, type UpdateReferenceSyncBlockResult, type WriteSyncBlockResult } from './types';
|
|
5
5
|
export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
6
6
|
name: string;
|
|
7
7
|
private fetchProvider;
|
|
8
8
|
private writeProvider;
|
|
9
|
-
private sourceId;
|
|
10
9
|
private providerOptions;
|
|
11
10
|
/**
|
|
12
11
|
* Constructor for the SyncBlockProvider
|
|
13
12
|
*
|
|
14
13
|
* @param fetchProvider
|
|
15
14
|
* @param writeProvider
|
|
16
|
-
* @param sourceId
|
|
17
15
|
* @param nestedRendererDataProviders
|
|
18
16
|
*/
|
|
19
|
-
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider
|
|
17
|
+
constructor(fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider | undefined);
|
|
20
18
|
setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
21
|
-
getProduct(): SyncBlockProduct | undefined;
|
|
22
19
|
/**
|
|
23
20
|
* Check if the node is supported by the provider
|
|
24
21
|
*
|
|
@@ -62,12 +59,6 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
62
59
|
* @returns Array of {resourceId?: string, error?: string}.
|
|
63
60
|
*/
|
|
64
61
|
deleteNodesData(resourceIds: ResourceId[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
65
|
-
/**
|
|
66
|
-
* Get the source id
|
|
67
|
-
*
|
|
68
|
-
* @returns The source id
|
|
69
|
-
*/
|
|
70
|
-
getSourceId(): string;
|
|
71
62
|
/**
|
|
72
63
|
* Fetch the source info from the source id
|
|
73
64
|
*
|
|
@@ -78,7 +69,10 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
78
69
|
* @returns The source info
|
|
79
70
|
*/
|
|
80
71
|
fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
81
|
-
generateResourceId(
|
|
72
|
+
generateResourceId(): {
|
|
73
|
+
localId: BlockInstanceId;
|
|
74
|
+
resourceId: ResourceId;
|
|
75
|
+
};
|
|
82
76
|
generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
83
77
|
/**
|
|
84
78
|
* Get the synced block renderer provider options
|
|
@@ -97,4 +91,11 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
|
|
|
97
91
|
retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
98
92
|
updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
99
93
|
}
|
|
100
|
-
|
|
94
|
+
type UseMemoizedSyncedBlockProviderProps = {
|
|
95
|
+
fetchProvider: ADFFetchProvider;
|
|
96
|
+
getSSRData?: () => Record<string, SyncBlockInstance> | undefined;
|
|
97
|
+
providerOptions: SyncedBlockRendererProviderOptions;
|
|
98
|
+
writeProvider: ADFWriteProvider | undefined;
|
|
99
|
+
};
|
|
100
|
+
export declare const useMemoizedSyncedBlockProvider: ({ fetchProvider, writeProvider, providerOptions, getSSRData, }: UseMemoizedSyncedBlockProviderProps) => SyncBlockProvider;
|
|
101
|
+
export {};
|
|
@@ -55,7 +55,6 @@ export interface ADFWriteProvider {
|
|
|
55
55
|
* User should not be blocked by not_found error when deleting, so successful result should be returned for 404 error
|
|
56
56
|
*/
|
|
57
57
|
deleteData: (resourceId: ResourceId) => Promise<DeleteSyncBlockResult>;
|
|
58
|
-
generateResourceId: (sourceId: string, localId: string) => ResourceId;
|
|
59
58
|
generateResourceIdForReference: (sourceId: ResourceId) => ResourceId;
|
|
60
59
|
product: SyncBlockProduct;
|
|
61
60
|
updateReferenceData: (blocks: SyncBlockAttrs[], noContent?: boolean) => Promise<UpdateReferenceSyncBlockResult>;
|
|
@@ -82,19 +81,23 @@ export declare abstract class SyncBlockDataProvider extends NodeDataProvider<Syn
|
|
|
82
81
|
abstract writeNodesData(nodes: SyncBlockNode[], data: SyncBlockData[]): Promise<Array<WriteSyncBlockResult>>;
|
|
83
82
|
abstract createNodeData(data: SyncBlockData): Promise<WriteSyncBlockResult>;
|
|
84
83
|
abstract deleteNodesData(resourceIds: string[]): Promise<Array<DeleteSyncBlockResult>>;
|
|
85
|
-
abstract getSourceId(): ResourceId;
|
|
86
|
-
abstract getProduct(): SyncBlockProduct | undefined;
|
|
87
84
|
abstract fetchSyncBlockSourceInfo(localId: BlockInstanceId, sourceAri: string, sourceProduct: SyncBlockProduct, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): Promise<SyncBlockSourceInfo | undefined>;
|
|
88
85
|
abstract setProviderOptions(providerOptions: SyncedBlockRendererProviderOptions): void;
|
|
89
86
|
abstract getSyncedBlockRendererProviderOptions(): SyncedBlockRendererProviderOptions;
|
|
90
87
|
abstract retrieveSyncBlockParentInfo(sourceAri: string, sourceProduct: SyncBlockProduct): SyncBlockParentInfo | undefined;
|
|
91
88
|
/**
|
|
92
|
-
* Generates a resource ID
|
|
89
|
+
* Generates a resource ID for source synced block.
|
|
90
|
+
* @returns The generated resource ID
|
|
91
|
+
*/
|
|
92
|
+
abstract generateResourceId(): {
|
|
93
|
+
localId: BlockInstanceId;
|
|
94
|
+
resourceId: ResourceId;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Generates a resource ID for reference synced block.
|
|
93
98
|
* @param sourceId - The source document ID (e.g., page ARI)
|
|
94
|
-
* @param localId - The local block ID (usually a UUID)
|
|
95
99
|
* @returns The generated resource ID
|
|
96
100
|
*/
|
|
97
|
-
abstract generateResourceId(sourceId: ResourceId, localId: BlockInstanceId): ResourceId;
|
|
98
101
|
abstract generateResourceIdForReference(sourceId: ResourceId): ResourceId;
|
|
99
102
|
abstract updateReferenceData(blocks: SyncBlockAttrs[], noContent?: boolean): Promise<UpdateReferenceSyncBlockResult>;
|
|
100
103
|
}
|
package/package.json
CHANGED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.updateContentProperty = exports.getContentProperty = exports.deleteContentProperty = exports.createContentProperty = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _retry = require("../../utils/retry");
|
|
12
|
-
var _ari = require("./ari");
|
|
13
|
-
var _utils = require("./utils");
|
|
14
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
-
var COMMON_HEADERS = {
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
Accept: 'application/json'
|
|
19
|
-
};
|
|
20
|
-
var AGG_HEADERS = {
|
|
21
|
-
'X-ExperimentalApi': 'confluence-agg-beta'
|
|
22
|
-
};
|
|
23
|
-
var GRAPHQL_ENDPOINT = '/gateway/api/graphql';
|
|
24
|
-
var GET_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_GET';
|
|
25
|
-
var CREATE_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_CREATE';
|
|
26
|
-
var UPDATE_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_UPDATE';
|
|
27
|
-
var DELETE_OPERATION_NAME = 'EDITOR_SYNCED_BLOCK_DELETE';
|
|
28
|
-
/**
|
|
29
|
-
* Query to get the page property by key
|
|
30
|
-
* @param documentARI
|
|
31
|
-
* @param key
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
var GET_PAGE_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]!) {\n\t\t\t\t\tconfluence {\n\t\t\t\t\t\tpage (id: $id) {\n\t\t\t\t\t\t\tproperties(keys: $keys) {\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}");
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Query to get the blog page property by key
|
|
38
|
-
* @param documentARI
|
|
39
|
-
* @param key
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
var GET_BLOG_QUERY = "query ".concat(GET_OPERATION_NAME, " ($id: ID!, $keys: [String]!) {\n\tconfluence {\n\t\tblogPost (id: $id) {\n\t\t\tproperties(keys: $keys) {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Query to create a page property with key and value
|
|
46
|
-
* @param documentARI
|
|
47
|
-
* @param key
|
|
48
|
-
* @param value
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
var CREATE_PAGE_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: ConfluenceCreatePagePropertyInput!){\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tcreatePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Query to create a blog page property with key and value
|
|
55
|
-
* @param documentARI
|
|
56
|
-
* @param key
|
|
57
|
-
* @param value
|
|
58
|
-
* @returns
|
|
59
|
-
*/
|
|
60
|
-
var CREATE_BLOG_QUERY = "mutation ".concat(CREATE_OPERATION_NAME, " ($input: ConfluenceCreateBlogPostPropertyInput!){\n\tconfluence {\n\t\tcreateBlogPostProperty(input: $input) {\n\t\t\tblogPostProperty {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Query to update a page property with key and value without bumping the version
|
|
64
|
-
* @param documentARI
|
|
65
|
-
* @param key
|
|
66
|
-
* @param value
|
|
67
|
-
* @returns
|
|
68
|
-
*/
|
|
69
|
-
var UPDATE_PAGE_QUERY = "mutation ".concat(UPDATE_OPERATION_NAME, " ($input: ConfluenceUpdateValuePagePropertyInput!) {\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tupdateValuePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tpageProperty {\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Query to update a blog page property with key and value without bumping the version
|
|
73
|
-
* @param documentARI
|
|
74
|
-
* @param key
|
|
75
|
-
* @param value
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
var UPDATE_BLOG_QUERY = "mutation ".concat(UPDATE_OPERATION_NAME, " ($input: ConfluenceUpdateValueBlogPostPropertyInput!) {\n\tconfluence {\n\t\tupdateValueBlogPostProperty(input: $input) {\n\t\t\tblogPostProperty {\n\t\t\t\tkey,\n\t\t\t\tvalue\n\t\t\t}\n\t\t}\n\t}\n}");
|
|
79
|
-
var DELETE_PAGE_QUERY = "mutation ".concat(DELETE_OPERATION_NAME, " ($input: ConfluenceDeletePagePropertyInput!) {\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tdeletePageProperty(input: $input) {\n\t\t\t\t\t\t\t\tsuccess, errors {\n\t\t\t\t\t\t\t\t message\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
|
|
80
|
-
var DELETE_BLOG_QUERY = "mutation ".concat(DELETE_OPERATION_NAME, " ($input: ConfluenceDeleteBlogPostPropertyInput!) {\n\t\t\t\t\t\tconfluence {\n\t\t\t\t\t\t\tdeleteBlogPostProperty(input: $input) {\n\t\t\t\t\t\t\t\tsuccess, errors {\n\t\t\t\t\t\t\t\t message\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}");
|
|
81
|
-
var getContentProperty = exports.getContentProperty = /*#__PURE__*/function () {
|
|
82
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
83
|
-
var pageId, key, cloudId, pageType, documentARI, isBlog, bodyData, response;
|
|
84
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
85
|
-
while (1) switch (_context.prev = _context.next) {
|
|
86
|
-
case 0:
|
|
87
|
-
pageId = _ref.pageId, key = _ref.key, cloudId = _ref.cloudId, pageType = _ref.pageType;
|
|
88
|
-
documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
|
|
89
|
-
isBlog = (0, _utils.isBlogPageType)(pageType);
|
|
90
|
-
bodyData = {
|
|
91
|
-
query: isBlog ? GET_BLOG_QUERY : GET_PAGE_QUERY,
|
|
92
|
-
operationName: GET_OPERATION_NAME,
|
|
93
|
-
variables: {
|
|
94
|
-
id: documentARI,
|
|
95
|
-
keys: [key]
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
_context.next = 6;
|
|
99
|
-
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
100
|
-
method: 'POST',
|
|
101
|
-
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
102
|
-
body: JSON.stringify(bodyData)
|
|
103
|
-
});
|
|
104
|
-
case 6:
|
|
105
|
-
response = _context.sent;
|
|
106
|
-
if (response.ok) {
|
|
107
|
-
_context.next = 9;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
throw new Error("Failed to get content property: ".concat(response.statusText));
|
|
111
|
-
case 9:
|
|
112
|
-
_context.next = 11;
|
|
113
|
-
return response.json();
|
|
114
|
-
case 11:
|
|
115
|
-
return _context.abrupt("return", _context.sent);
|
|
116
|
-
case 12:
|
|
117
|
-
case "end":
|
|
118
|
-
return _context.stop();
|
|
119
|
-
}
|
|
120
|
-
}, _callee);
|
|
121
|
-
}));
|
|
122
|
-
return function getContentProperty(_x) {
|
|
123
|
-
return _ref2.apply(this, arguments);
|
|
124
|
-
};
|
|
125
|
-
}();
|
|
126
|
-
var updateContentProperty = exports.updateContentProperty = /*#__PURE__*/function () {
|
|
127
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
128
|
-
var pageId, key, value, cloudId, pageType, documentARI, isBlog, useSameVersion, input, bodyData, response;
|
|
129
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
130
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
131
|
-
case 0:
|
|
132
|
-
pageId = _ref3.pageId, key = _ref3.key, value = _ref3.value, cloudId = _ref3.cloudId, pageType = _ref3.pageType;
|
|
133
|
-
documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
|
|
134
|
-
isBlog = (0, _utils.isBlogPageType)(pageType);
|
|
135
|
-
useSameVersion = {
|
|
136
|
-
useSameVersion: true
|
|
137
|
-
};
|
|
138
|
-
input = _objectSpread(_objectSpread({}, isBlog ? {
|
|
139
|
-
blogPostId: documentARI
|
|
140
|
-
} : {
|
|
141
|
-
pageId: documentARI
|
|
142
|
-
}), {}, {
|
|
143
|
-
key: key,
|
|
144
|
-
value: JSON.stringify(value)
|
|
145
|
-
}); // Blog content properties don't support the useSameVersion flag at the moment
|
|
146
|
-
if (!isBlog) {
|
|
147
|
-
input = _objectSpread(_objectSpread({}, input), useSameVersion);
|
|
148
|
-
}
|
|
149
|
-
bodyData = {
|
|
150
|
-
query: isBlog ? UPDATE_BLOG_QUERY : UPDATE_PAGE_QUERY,
|
|
151
|
-
operationName: UPDATE_OPERATION_NAME,
|
|
152
|
-
variables: {
|
|
153
|
-
input: input
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
_context2.next = 9;
|
|
157
|
-
return fetch(GRAPHQL_ENDPOINT, {
|
|
158
|
-
method: 'POST',
|
|
159
|
-
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
160
|
-
body: JSON.stringify(bodyData)
|
|
161
|
-
});
|
|
162
|
-
case 9:
|
|
163
|
-
response = _context2.sent;
|
|
164
|
-
if (response.ok) {
|
|
165
|
-
_context2.next = 12;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
throw new Error("Failed to update content property: ".concat(response.statusText));
|
|
169
|
-
case 12:
|
|
170
|
-
_context2.next = 14;
|
|
171
|
-
return response.json();
|
|
172
|
-
case 14:
|
|
173
|
-
return _context2.abrupt("return", _context2.sent);
|
|
174
|
-
case 15:
|
|
175
|
-
case "end":
|
|
176
|
-
return _context2.stop();
|
|
177
|
-
}
|
|
178
|
-
}, _callee2);
|
|
179
|
-
}));
|
|
180
|
-
return function updateContentProperty(_x2) {
|
|
181
|
-
return _ref4.apply(this, arguments);
|
|
182
|
-
};
|
|
183
|
-
}();
|
|
184
|
-
var createContentProperty = exports.createContentProperty = /*#__PURE__*/function () {
|
|
185
|
-
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref5) {
|
|
186
|
-
var pageId, key, value, cloudId, pageType, documentARI, isBlog, bodyData, response;
|
|
187
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
188
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
189
|
-
case 0:
|
|
190
|
-
pageId = _ref5.pageId, key = _ref5.key, value = _ref5.value, cloudId = _ref5.cloudId, pageType = _ref5.pageType;
|
|
191
|
-
documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
|
|
192
|
-
isBlog = (0, _utils.isBlogPageType)(pageType);
|
|
193
|
-
bodyData = {
|
|
194
|
-
query: isBlog ? CREATE_BLOG_QUERY : CREATE_PAGE_QUERY,
|
|
195
|
-
operationName: CREATE_OPERATION_NAME,
|
|
196
|
-
variables: {
|
|
197
|
-
input: _objectSpread(_objectSpread({}, isBlog ? {
|
|
198
|
-
blogPostId: documentARI
|
|
199
|
-
} : {
|
|
200
|
-
pageId: documentARI
|
|
201
|
-
}), {}, {
|
|
202
|
-
key: key,
|
|
203
|
-
value: JSON.stringify(value)
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
_context3.next = 6;
|
|
208
|
-
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
209
|
-
method: 'POST',
|
|
210
|
-
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
211
|
-
body: JSON.stringify(bodyData)
|
|
212
|
-
});
|
|
213
|
-
case 6:
|
|
214
|
-
response = _context3.sent;
|
|
215
|
-
if (response.ok) {
|
|
216
|
-
_context3.next = 9;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
throw new Error("Failed to create content property: ".concat(response.statusText));
|
|
220
|
-
case 9:
|
|
221
|
-
_context3.next = 11;
|
|
222
|
-
return response.json();
|
|
223
|
-
case 11:
|
|
224
|
-
return _context3.abrupt("return", _context3.sent);
|
|
225
|
-
case 12:
|
|
226
|
-
case "end":
|
|
227
|
-
return _context3.stop();
|
|
228
|
-
}
|
|
229
|
-
}, _callee3);
|
|
230
|
-
}));
|
|
231
|
-
return function createContentProperty(_x3) {
|
|
232
|
-
return _ref6.apply(this, arguments);
|
|
233
|
-
};
|
|
234
|
-
}();
|
|
235
|
-
var deleteContentProperty = exports.deleteContentProperty = /*#__PURE__*/function () {
|
|
236
|
-
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref7) {
|
|
237
|
-
var pageId, cloudId, pageType, key, documentARI, isBlog, bodyData, response;
|
|
238
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
239
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
240
|
-
case 0:
|
|
241
|
-
pageId = _ref7.pageId, cloudId = _ref7.cloudId, pageType = _ref7.pageType, key = _ref7.key;
|
|
242
|
-
documentARI = (0, _ari.getConfluencePageAri)(pageId, cloudId, pageType);
|
|
243
|
-
isBlog = (0, _utils.isBlogPageType)(pageType);
|
|
244
|
-
bodyData = {
|
|
245
|
-
query: isBlog ? DELETE_BLOG_QUERY : DELETE_PAGE_QUERY,
|
|
246
|
-
operationName: DELETE_OPERATION_NAME,
|
|
247
|
-
variables: {
|
|
248
|
-
input: _objectSpread(_objectSpread({}, isBlog ? {
|
|
249
|
-
blogPostId: documentARI
|
|
250
|
-
} : {
|
|
251
|
-
pageId: documentARI
|
|
252
|
-
}), {}, {
|
|
253
|
-
key: key
|
|
254
|
-
})
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
_context4.next = 6;
|
|
258
|
-
return (0, _retry.fetchWithRetry)(GRAPHQL_ENDPOINT, {
|
|
259
|
-
method: 'POST',
|
|
260
|
-
headers: _objectSpread(_objectSpread({}, COMMON_HEADERS), AGG_HEADERS),
|
|
261
|
-
body: JSON.stringify(bodyData)
|
|
262
|
-
});
|
|
263
|
-
case 6:
|
|
264
|
-
response = _context4.sent;
|
|
265
|
-
if (response.ok) {
|
|
266
|
-
_context4.next = 9;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
throw new Error("Failed to delete content property: ".concat(response.statusText));
|
|
270
|
-
case 9:
|
|
271
|
-
_context4.next = 11;
|
|
272
|
-
return response.json();
|
|
273
|
-
case 11:
|
|
274
|
-
return _context4.abrupt("return", _context4.sent);
|
|
275
|
-
case 12:
|
|
276
|
-
case "end":
|
|
277
|
-
return _context4.stop();
|
|
278
|
-
}
|
|
279
|
-
}, _callee4);
|
|
280
|
-
}));
|
|
281
|
-
return function deleteContentProperty(_x4) {
|
|
282
|
-
return _ref8.apply(this, arguments);
|
|
283
|
-
};
|
|
284
|
-
}();
|