@atlaskit/node-data-provider 4.5.2 → 4.6.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/node-data-provider
2
2
 
3
+ ## 4.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5763f85b421a2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5763f85b421a2) - -
8
+ The new method `getCacheStatusForNode` is added to `NodeDataProvider` class to get the cache
9
+ status for a given node.
10
+ - The `CardSSR` component will start supporting `hideIconLoadingSkeleton` property for any type of
11
+ smart card.
12
+
13
+ ### Patch Changes
14
+
15
+ - [`a2cd8c46a3e94`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a2cd8c46a3e94) -
16
+ EDITOR-1442 Bump adf-schema
17
+ - Updated dependencies
18
+
19
+ ## 4.5.3
20
+
21
+ ### Patch Changes
22
+
23
+ - [`0fdcb6f2f96fd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0fdcb6f2f96fd) -
24
+ Sorted type and interface props to improve Atlaskit docs
25
+ - Updated dependencies
26
+
3
27
  ## 4.5.2
4
28
 
5
29
  ### Patch Changes
@@ -272,6 +272,31 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
272
272
  }
273
273
  });
274
274
  }
275
+
276
+ /**
277
+ * Checks the cache for the given node and returns its status.
278
+ *
279
+ * Possible return values:
280
+ * - `false`: No cached data found for the node.
281
+ * - `'ssr'`: Data is cached from server-side rendering (SSR).
282
+ * - `'network'`: Data is cached from a network request.
283
+ *
284
+ * @param node The node (or its ProseMirror representation) to check in the cache.
285
+ * @returns The cache status: `false`, `'ssr'`, or `'network'`.
286
+ */
287
+ }, {
288
+ key: "getCacheStatusForNode",
289
+ value: function getCacheStatusForNode(node) {
290
+ var jsonNode = 'toJSON' in node ? node.toJSON() : node;
291
+ if (!this.isNodeSupported(jsonNode)) {
292
+ // eslint-disable-next-line no-console
293
+ console.error("The ".concat(this.constructor.name, " doesn't support Node ").concat(jsonNode.type, "."));
294
+ return false;
295
+ }
296
+ var dataKey = this.nodeDataKey(jsonNode);
297
+ var dataFromCache = this.cache[dataKey];
298
+ return dataFromCache ? dataFromCache.source : false;
299
+ }
275
300
  }]);
276
301
  }();
277
302
  function isPromise(value) {
@@ -231,6 +231,29 @@ export class NodeDataProvider {
231
231
  }
232
232
  });
233
233
  }
234
+
235
+ /**
236
+ * Checks the cache for the given node and returns its status.
237
+ *
238
+ * Possible return values:
239
+ * - `false`: No cached data found for the node.
240
+ * - `'ssr'`: Data is cached from server-side rendering (SSR).
241
+ * - `'network'`: Data is cached from a network request.
242
+ *
243
+ * @param node The node (or its ProseMirror representation) to check in the cache.
244
+ * @returns The cache status: `false`, `'ssr'`, or `'network'`.
245
+ */
246
+ getCacheStatusForNode(node) {
247
+ const jsonNode = 'toJSON' in node ? node.toJSON() : node;
248
+ if (!this.isNodeSupported(jsonNode)) {
249
+ // eslint-disable-next-line no-console
250
+ console.error(`The ${this.constructor.name} doesn't support Node ${jsonNode.type}.`);
251
+ return false;
252
+ }
253
+ const dataKey = this.nodeDataKey(jsonNode);
254
+ const dataFromCache = this.cache[dataKey];
255
+ return dataFromCache ? dataFromCache.source : false;
256
+ }
234
257
  }
235
258
  function isPromise(value) {
236
259
  return typeof value === 'object' && value !== null && 'then' in value && typeof value.then === 'function';
@@ -269,6 +269,31 @@ export var NodeDataProvider = /*#__PURE__*/function () {
269
269
  }
270
270
  });
271
271
  }
272
+
273
+ /**
274
+ * Checks the cache for the given node and returns its status.
275
+ *
276
+ * Possible return values:
277
+ * - `false`: No cached data found for the node.
278
+ * - `'ssr'`: Data is cached from server-side rendering (SSR).
279
+ * - `'network'`: Data is cached from a network request.
280
+ *
281
+ * @param node The node (or its ProseMirror representation) to check in the cache.
282
+ * @returns The cache status: `false`, `'ssr'`, or `'network'`.
283
+ */
284
+ }, {
285
+ key: "getCacheStatusForNode",
286
+ value: function getCacheStatusForNode(node) {
287
+ var jsonNode = 'toJSON' in node ? node.toJSON() : node;
288
+ if (!this.isNodeSupported(jsonNode)) {
289
+ // eslint-disable-next-line no-console
290
+ console.error("The ".concat(this.constructor.name, " doesn't support Node ").concat(jsonNode.type, "."));
291
+ return false;
292
+ }
293
+ var dataKey = this.nodeDataKey(jsonNode);
294
+ var dataFromCache = this.cache[dataKey];
295
+ return dataFromCache ? dataFromCache.source : false;
296
+ }
272
297
  }]);
273
298
  }();
274
299
  function isPromise(value) {
@@ -18,9 +18,9 @@ type SSRData<Data> = {
18
18
  * It can either contain an error or the fetched data.
19
19
  */
20
20
  type CallbackPayload<Data> = {
21
+ data?: undefined;
21
22
  /** An error that occurred while fetching data. */
22
23
  error: Error;
23
- data?: undefined;
24
24
  } | {
25
25
  /** Fetched data for the node. */
26
26
  data: Data;
@@ -134,5 +134,17 @@ export declare abstract class NodeDataProvider<Node extends JSONNode, Data> {
134
134
  * @returns A promise that resolves with the node's data.
135
135
  */
136
136
  getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS(node: Node | PMNode): Promise<Data>;
137
+ /**
138
+ * Checks the cache for the given node and returns its status.
139
+ *
140
+ * Possible return values:
141
+ * - `false`: No cached data found for the node.
142
+ * - `'ssr'`: Data is cached from server-side rendering (SSR).
143
+ * - `'network'`: Data is cached from a network request.
144
+ *
145
+ * @param node The node (or its ProseMirror representation) to check in the cache.
146
+ * @returns The cache status: `false`, `'ssr'`, or `'network'`.
147
+ */
148
+ getCacheStatusForNode(node: Node | PMNode): false | 'ssr' | 'network';
137
149
  }
138
150
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { JSONDocNode, JSONNode } from '@atlaskit/editor-json-transformer';
2
2
  import type { NodeDataProvider } from '../node-data-provider';
3
3
  interface ProviderWithNodes {
4
- /** The provider that supports the nodes. */
5
- provider: NodeDataProvider<JSONNode, unknown>;
6
4
  /** The nodes that are supported by the provider. */
7
5
  nodes: JSONNode[];
6
+ /** The provider that supports the nodes. */
7
+ provider: NodeDataProvider<JSONNode, unknown>;
8
8
  }
9
9
  /**
10
10
  * Finds nodes in the document that are supported by the given providers, up to a maximum number of nodes.
@@ -15,7 +15,7 @@ interface ProviderWithNodes {
15
15
  * @returns An array of objects, each containing a provider and the nodes that are supported by that provider.
16
16
  */
17
17
  export declare function findNodesToPrefetch(doc: JSONDocNode, providers: {
18
- provider: NodeDataProvider<JSONNode, unknown>;
19
18
  maxNodesToPrefetch: number;
19
+ provider: NodeDataProvider<JSONNode, unknown>;
20
20
  }[], maxNodesToVisit: number): ProviderWithNodes[];
21
21
  export {};
@@ -40,9 +40,9 @@ type SsrData = {
40
40
  */
41
41
  type NodeDataProvidersSsrData = {
42
42
  [providerName: string]: {
43
- success: boolean;
44
- duration: number;
45
43
  data: SsrData;
44
+ duration: number;
45
+ success: boolean;
46
46
  };
47
47
  };
48
48
  interface Props {
@@ -50,12 +50,6 @@ interface Props {
50
50
  * The document for which to prefetch data.
51
51
  */
52
52
  doc: JSONDocNode;
53
- /**
54
- * A global timeout in milliseconds for all fetch requests.
55
- *
56
- * Each provider will use the minimum of this value and its own specific timeout.
57
- */
58
- timeout: number;
59
53
  /**
60
54
  * The maximum number of nodes to visit when searching for nodes to prefetch.
61
55
  * This is a performance safeguard for very large documents.
@@ -68,10 +62,6 @@ interface Props {
68
62
  * individual configurations.
69
63
  */
70
64
  providers: {
71
- /**
72
- * The provider instance to use for prefetching.
73
- */
74
- provider: NodeDataProvider<JSONNode, unknown>;
75
65
  /**
76
66
  * The maximum number of nodes to prefetch for this specific provider.
77
67
  * This helps prevent performance issues with documents containing many
@@ -80,6 +70,10 @@ interface Props {
80
70
  * @default If not specified, all nodes supported by the provider will be prefetched.
81
71
  */
82
72
  maxNodesToPrefetch?: number;
73
+ /**
74
+ * The provider instance to use for prefetching.
75
+ */
76
+ provider: NodeDataProvider<JSONNode, unknown>;
83
77
  /**
84
78
  * The timeout in milliseconds for the fetch request for this specific provider.
85
79
  * If the request takes longer than this, it will be aborted and return no data.
@@ -88,6 +82,12 @@ interface Props {
88
82
  */
89
83
  timeout?: number;
90
84
  }[];
85
+ /**
86
+ * A global timeout in milliseconds for all fetch requests.
87
+ *
88
+ * Each provider will use the minimum of this value and its own specific timeout.
89
+ */
90
+ timeout: number;
91
91
  }
92
92
  /**
93
93
  * Fetches data for nodes in the document that are supported by the given providers.
@@ -18,9 +18,9 @@ type SSRData<Data> = {
18
18
  * It can either contain an error or the fetched data.
19
19
  */
20
20
  type CallbackPayload<Data> = {
21
+ data?: undefined;
21
22
  /** An error that occurred while fetching data. */
22
23
  error: Error;
23
- data?: undefined;
24
24
  } | {
25
25
  /** Fetched data for the node. */
26
26
  data: Data;
@@ -134,5 +134,17 @@ export declare abstract class NodeDataProvider<Node extends JSONNode, Data> {
134
134
  * @returns A promise that resolves with the node's data.
135
135
  */
136
136
  getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS(node: Node | PMNode): Promise<Data>;
137
+ /**
138
+ * Checks the cache for the given node and returns its status.
139
+ *
140
+ * Possible return values:
141
+ * - `false`: No cached data found for the node.
142
+ * - `'ssr'`: Data is cached from server-side rendering (SSR).
143
+ * - `'network'`: Data is cached from a network request.
144
+ *
145
+ * @param node The node (or its ProseMirror representation) to check in the cache.
146
+ * @returns The cache status: `false`, `'ssr'`, or `'network'`.
147
+ */
148
+ getCacheStatusForNode(node: Node | PMNode): false | 'ssr' | 'network';
137
149
  }
138
150
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { JSONDocNode, JSONNode } from '@atlaskit/editor-json-transformer';
2
2
  import type { NodeDataProvider } from '../node-data-provider';
3
3
  interface ProviderWithNodes {
4
- /** The provider that supports the nodes. */
5
- provider: NodeDataProvider<JSONNode, unknown>;
6
4
  /** The nodes that are supported by the provider. */
7
5
  nodes: JSONNode[];
6
+ /** The provider that supports the nodes. */
7
+ provider: NodeDataProvider<JSONNode, unknown>;
8
8
  }
9
9
  /**
10
10
  * Finds nodes in the document that are supported by the given providers, up to a maximum number of nodes.
@@ -15,7 +15,7 @@ interface ProviderWithNodes {
15
15
  * @returns An array of objects, each containing a provider and the nodes that are supported by that provider.
16
16
  */
17
17
  export declare function findNodesToPrefetch(doc: JSONDocNode, providers: {
18
- provider: NodeDataProvider<JSONNode, unknown>;
19
18
  maxNodesToPrefetch: number;
19
+ provider: NodeDataProvider<JSONNode, unknown>;
20
20
  }[], maxNodesToVisit: number): ProviderWithNodes[];
21
21
  export {};
@@ -40,9 +40,9 @@ type SsrData = {
40
40
  */
41
41
  type NodeDataProvidersSsrData = {
42
42
  [providerName: string]: {
43
- success: boolean;
44
- duration: number;
45
43
  data: SsrData;
44
+ duration: number;
45
+ success: boolean;
46
46
  };
47
47
  };
48
48
  interface Props {
@@ -50,12 +50,6 @@ interface Props {
50
50
  * The document for which to prefetch data.
51
51
  */
52
52
  doc: JSONDocNode;
53
- /**
54
- * A global timeout in milliseconds for all fetch requests.
55
- *
56
- * Each provider will use the minimum of this value and its own specific timeout.
57
- */
58
- timeout: number;
59
53
  /**
60
54
  * The maximum number of nodes to visit when searching for nodes to prefetch.
61
55
  * This is a performance safeguard for very large documents.
@@ -68,10 +62,6 @@ interface Props {
68
62
  * individual configurations.
69
63
  */
70
64
  providers: {
71
- /**
72
- * The provider instance to use for prefetching.
73
- */
74
- provider: NodeDataProvider<JSONNode, unknown>;
75
65
  /**
76
66
  * The maximum number of nodes to prefetch for this specific provider.
77
67
  * This helps prevent performance issues with documents containing many
@@ -80,6 +70,10 @@ interface Props {
80
70
  * @default If not specified, all nodes supported by the provider will be prefetched.
81
71
  */
82
72
  maxNodesToPrefetch?: number;
73
+ /**
74
+ * The provider instance to use for prefetching.
75
+ */
76
+ provider: NodeDataProvider<JSONNode, unknown>;
83
77
  /**
84
78
  * The timeout in milliseconds for the fetch request for this specific provider.
85
79
  * If the request takes longer than this, it will be aborted and return no data.
@@ -88,6 +82,12 @@ interface Props {
88
82
  */
89
83
  timeout?: number;
90
84
  }[];
85
+ /**
86
+ * A global timeout in milliseconds for all fetch requests.
87
+ *
88
+ * Each provider will use the minimum of this value and its own specific timeout.
89
+ */
90
+ timeout: number;
91
91
  }
92
92
  /**
93
93
  * Fetches data for nodes in the document that are supported by the given providers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/node-data-provider",
3
- "version": "4.5.2",
3
+ "version": "4.6.0",
4
4
  "description": "Node data provider for @atlaskit/editor-core plugins and @atlaskit/renderer",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -18,18 +18,15 @@
18
18
  "types": "dist/types/index.d.ts",
19
19
  "sideEffects": false,
20
20
  "atlaskit:src": "src/index.ts",
21
- "af:exports": {
22
- ".": "./src/index.ts"
23
- },
24
21
  "dependencies": {
25
- "@atlaskit/adf-schema": "^50.2.1",
22
+ "@atlaskit/adf-schema": "^50.2.3",
26
23
  "@atlaskit/adf-utils": "^19.21.0",
27
- "@atlaskit/editor-json-transformer": "^8.26.0",
24
+ "@atlaskit/editor-json-transformer": "^8.27.0",
28
25
  "@atlaskit/editor-prosemirror": "7.0.0",
29
26
  "@babel/runtime": "^7.0.0"
30
27
  },
31
28
  "peerDependencies": {
32
- "@atlaskit/editor-common": "^107.26.0"
29
+ "@atlaskit/editor-common": "^107.33.0"
33
30
  },
34
31
  "techstack": {
35
32
  "@atlassian/frontend": {