@atlaskit/media-client 33.4.0 → 33.5.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,23 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 33.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#172332](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/172332)
8
+ [`d257b57972216`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d257b57972216) -
9
+ Updating the response type of document content endpoint to add the new annotation and links from
10
+ documents
11
+
12
+ ## 33.4.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#169848](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169848)
17
+ [`0c2daefdb5712`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0c2daefdb5712) -
18
+ Standardise generation of telemetry IDs across media packages.
19
+ - Updated dependencies
20
+
3
21
  ## 33.4.0
4
22
 
5
23
  ### Minor Changes
@@ -665,26 +665,28 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
665
665
  key: "getDocumentContent",
666
666
  value: function () {
667
667
  var _getDocumentContent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(id, options) {
668
- var metadata, requestOptions;
668
+ var endpoint, metadata, requestOptions;
669
669
  return _regenerator.default.wrap(function _callee12$(_context12) {
670
670
  while (1) switch (_context12.prev = _context12.next) {
671
671
  case 0:
672
+ endpoint = cdnFeatureFlag('contents');
672
673
  metadata = {
673
674
  method: 'GET',
674
- endpoint: '/file/{fileId}/document/contents'
675
+ endpoint: "/file/{fileId}/document/".concat(endpoint)
675
676
  };
676
677
  requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
677
678
  authContext: {
678
679
  collectionName: options.collectionName
679
680
  },
680
681
  params: {
682
+ collection: options.collectionName,
681
683
  pageStart: options.pageStart,
682
684
  pageEnd: options.pageEnd,
683
685
  'max-age': _constants.FILE_CACHE_MAX_AGE
684
686
  }
685
687
  });
686
- return _context12.abrupt("return", this.request("/file/".concat(id, "/document/contents"), requestOptions).then((0, _helpers.createMapResponseToJson)(metadata)));
687
- case 3:
688
+ return _context12.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then((0, _helpers.createMapResponseToJson)(metadata)));
689
+ case 4:
688
690
  case "end":
689
691
  return _context12.stop();
690
692
  }
@@ -703,6 +705,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
703
705
  return _regenerator.default.wrap(function _callee13$(_context13) {
704
706
  while (1) switch (_context13.prev = _context13.next) {
705
707
  case 0:
708
+ // Temporarily disabling CDN for document due to bug of CDN not forwarding query params
706
709
  endpoint = cdnFeatureFlag('page');
707
710
  metadata = {
708
711
  method: 'GET',
@@ -713,6 +716,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
713
716
  collectionName: options.collectionName
714
717
  },
715
718
  params: {
719
+ collection: options.collectionName,
716
720
  page: options.page,
717
721
  zoom: options.zoom,
718
722
  'max-age': _constants.FILE_CACHE_MAX_AGE
@@ -51,8 +51,8 @@ function createBatchCopyIntentRegisterationFunc(mediaStore) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
53
53
  metadataTraceContext = {
54
- traceId: (0, _mediaCommon.getRandomHex)(8),
55
- spanId: (0, _mediaCommon.getRandomHex)(8)
54
+ traceId: (0, _mediaCommon.getRandomTelemetryId)(),
55
+ spanId: (0, _mediaCommon.getRandomTelemetryId)()
56
56
  };
57
57
  files = keysByToken[batchKey].map(function (key) {
58
58
  return {
@@ -101,8 +101,8 @@ function createBatchLoadingFunc(mediaStore) {
101
101
  while (1) switch (_context.prev = _context.next) {
102
102
  case 0:
103
103
  metadataTraceContext = {
104
- traceId: (0, _mediaCommon.getRandomHex)(8),
105
- spanId: (0, _mediaCommon.getRandomHex)(8)
104
+ traceId: (0, _mediaCommon.getRandomTelemetryId)(),
105
+ spanId: (0, _mediaCommon.getRandomTelemetryId)()
106
106
  };
107
107
  fileIds = fileIdsByCollection[collectionNameKey];
108
108
  includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
@@ -56,7 +56,7 @@ function isRateLimitedError(error) {
56
56
  }
57
57
  var extendTraceContext = exports.extendTraceContext = function extendTraceContext(traceContext) {
58
58
  return traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
59
- spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || (0, _mediaCommon.getRandomHex)(8)
59
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || (0, _mediaCommon.getRandomTelemetryId)()
60
60
  }) : undefined;
61
61
  };
62
62
  var ZipkinHeaderKeys = exports.ZipkinHeaderKeys = {
@@ -395,9 +395,10 @@ export class MediaStore {
395
395
  return this.request(`/file/${id}/image/metadata`, options).then(createMapResponseToJson(metadata));
396
396
  }
397
397
  async getDocumentContent(id, options) {
398
+ const endpoint = cdnFeatureFlag('contents');
398
399
  const metadata = {
399
400
  method: 'GET',
400
- endpoint: '/file/{fileId}/document/contents'
401
+ endpoint: `/file/{fileId}/document/${endpoint}`
401
402
  };
402
403
  const requestOptions = {
403
404
  ...metadata,
@@ -405,14 +406,16 @@ export class MediaStore {
405
406
  collectionName: options.collectionName
406
407
  },
407
408
  params: {
409
+ collection: options.collectionName,
408
410
  pageStart: options.pageStart,
409
411
  pageEnd: options.pageEnd,
410
412
  'max-age': FILE_CACHE_MAX_AGE
411
413
  }
412
414
  };
413
- return this.request(`/file/${id}/document/contents`, requestOptions).then(createMapResponseToJson(metadata));
415
+ return this.request(`/file/${id}/document/${endpoint}`, requestOptions).then(createMapResponseToJson(metadata));
414
416
  }
415
417
  async getDocumentPageImage(id, options) {
418
+ // Temporarily disabling CDN for document due to bug of CDN not forwarding query params
416
419
  const endpoint = cdnFeatureFlag('page');
417
420
  const metadata = {
418
421
  method: 'GET',
@@ -424,6 +427,7 @@ export class MediaStore {
424
427
  collectionName: options.collectionName
425
428
  },
426
429
  params: {
430
+ collection: options.collectionName,
427
431
  page: options.page,
428
432
  zoom: options.zoom,
429
433
  'max-age': FILE_CACHE_MAX_AGE
@@ -1,5 +1,5 @@
1
1
  import Dataloader from 'dataloader';
2
- import { getRandomHex } from '@atlaskit/media-common';
2
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
3
3
  export const MAX_BATCH_SIZE = 100;
4
4
  /**
5
5
  * Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
@@ -29,8 +29,8 @@ function createBatchCopyIntentRegisterationFunc(mediaStore) {
29
29
  const items = [];
30
30
  await Promise.all(Object.keys(keysByToken).map(async batchKey => {
31
31
  const metadataTraceContext = {
32
- traceId: getRandomHex(8),
33
- spanId: getRandomHex(8)
32
+ traceId: getRandomTelemetryId(),
33
+ spanId: getRandomTelemetryId()
34
34
  };
35
35
  const files = keysByToken[batchKey].map(key => ({
36
36
  id: key.id,
@@ -1,5 +1,5 @@
1
1
  import Dataloader from 'dataloader';
2
- import { getRandomHex } from '@atlaskit/media-common';
2
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
3
3
  export const MAX_BATCH_SIZE = 100;
4
4
  const isBatchLoadingErrorResult = result => {
5
5
  return result.error instanceof Error;
@@ -77,8 +77,8 @@ export function createBatchLoadingFunc(mediaStore) {
77
77
  const items = [];
78
78
  await Promise.all(Object.keys(fileIdsByCollection).map(async collectionNameKey => {
79
79
  const metadataTraceContext = {
80
- traceId: getRandomHex(8),
81
- spanId: getRandomHex(8)
80
+ traceId: getRandomTelemetryId(),
81
+ spanId: getRandomTelemetryId()
82
82
  };
83
83
  const fileIds = fileIdsByCollection[collectionNameKey];
84
84
  const includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
@@ -1,5 +1,5 @@
1
1
  import { isClientBasedAuth } from '@atlaskit/media-core';
2
- import { getRandomHex } from '@atlaskit/media-common';
2
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
3
3
  import { mapAuthToQueryParameters } from '../../models/auth-query-parameters';
4
4
  import { RequestError, isRequestError } from './errors';
5
5
  const getStatusCode = error => {
@@ -23,7 +23,7 @@ export function isRateLimitedError(error) {
23
23
  }
24
24
  export const extendTraceContext = traceContext => traceContext ? {
25
25
  ...traceContext,
26
- spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
26
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomTelemetryId()
27
27
  } : undefined;
28
28
  export const ZipkinHeaderKeys = {
29
29
  traceId: 'x-b3-traceid',
@@ -659,26 +659,28 @@ export var MediaStore = /*#__PURE__*/function () {
659
659
  key: "getDocumentContent",
660
660
  value: function () {
661
661
  var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, options) {
662
- var metadata, requestOptions;
662
+ var endpoint, metadata, requestOptions;
663
663
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
664
664
  while (1) switch (_context12.prev = _context12.next) {
665
665
  case 0:
666
+ endpoint = cdnFeatureFlag('contents');
666
667
  metadata = {
667
668
  method: 'GET',
668
- endpoint: '/file/{fileId}/document/contents'
669
+ endpoint: "/file/{fileId}/document/".concat(endpoint)
669
670
  };
670
671
  requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
671
672
  authContext: {
672
673
  collectionName: options.collectionName
673
674
  },
674
675
  params: {
676
+ collection: options.collectionName,
675
677
  pageStart: options.pageStart,
676
678
  pageEnd: options.pageEnd,
677
679
  'max-age': FILE_CACHE_MAX_AGE
678
680
  }
679
681
  });
680
- return _context12.abrupt("return", this.request("/file/".concat(id, "/document/contents"), requestOptions).then(createMapResponseToJson(metadata)));
681
- case 3:
682
+ return _context12.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToJson(metadata)));
683
+ case 4:
682
684
  case "end":
683
685
  return _context12.stop();
684
686
  }
@@ -697,6 +699,7 @@ export var MediaStore = /*#__PURE__*/function () {
697
699
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
698
700
  while (1) switch (_context13.prev = _context13.next) {
699
701
  case 0:
702
+ // Temporarily disabling CDN for document due to bug of CDN not forwarding query params
700
703
  endpoint = cdnFeatureFlag('page');
701
704
  metadata = {
702
705
  method: 'GET',
@@ -707,6 +710,7 @@ export var MediaStore = /*#__PURE__*/function () {
707
710
  collectionName: options.collectionName
708
711
  },
709
712
  params: {
713
+ collection: options.collectionName,
710
714
  page: options.page,
711
715
  zoom: options.zoom,
712
716
  'max-age': FILE_CACHE_MAX_AGE
@@ -1,7 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import Dataloader from 'dataloader';
4
- import { getRandomHex } from '@atlaskit/media-common';
4
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
5
5
  export var MAX_BATCH_SIZE = 100;
6
6
  /**
7
7
  * Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
@@ -43,8 +43,8 @@ function createBatchCopyIntentRegisterationFunc(mediaStore) {
43
43
  while (1) switch (_context.prev = _context.next) {
44
44
  case 0:
45
45
  metadataTraceContext = {
46
- traceId: getRandomHex(8),
47
- spanId: getRandomHex(8)
46
+ traceId: getRandomTelemetryId(),
47
+ spanId: getRandomTelemetryId()
48
48
  };
49
49
  files = keysByToken[batchKey].map(function (key) {
50
50
  return {
@@ -5,7 +5,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  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; }
6
6
  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) { _defineProperty(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; }
7
7
  import Dataloader from 'dataloader';
8
- import { getRandomHex } from '@atlaskit/media-common';
8
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
9
9
  export var MAX_BATCH_SIZE = 100;
10
10
  var isBatchLoadingErrorResult = function isBatchLoadingErrorResult(result) {
11
11
  return result.error instanceof Error;
@@ -91,8 +91,8 @@ export function createBatchLoadingFunc(mediaStore) {
91
91
  while (1) switch (_context.prev = _context.next) {
92
92
  case 0:
93
93
  metadataTraceContext = {
94
- traceId: getRandomHex(8),
95
- spanId: getRandomHex(8)
94
+ traceId: getRandomTelemetryId(),
95
+ spanId: getRandomTelemetryId()
96
96
  };
97
97
  fileIds = fileIdsByCollection[collectionNameKey];
98
98
  includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
@@ -6,7 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  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; }
7
7
  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) { _defineProperty(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; }
8
8
  import { isClientBasedAuth } from '@atlaskit/media-core';
9
- import { getRandomHex } from '@atlaskit/media-common';
9
+ import { getRandomTelemetryId } from '@atlaskit/media-common';
10
10
  import { mapAuthToQueryParameters } from '../../models/auth-query-parameters';
11
11
  import { RequestError, isRequestError } from './errors';
12
12
  var getStatusCode = function getStatusCode(error) {
@@ -32,7 +32,7 @@ export function isRateLimitedError(error) {
32
32
  }
33
33
  export var extendTraceContext = function extendTraceContext(traceContext) {
34
34
  return traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
35
- spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
35
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomTelemetryId()
36
36
  }) : undefined;
37
37
  };
38
38
  export var ZipkinHeaderKeys = {
@@ -4,7 +4,7 @@ import { type MediaFileArtifacts } from '@atlaskit/media-state';
4
4
  import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
5
5
  import { type MediaFile, type MediaUpload } from '../../models/media';
6
6
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
7
- import { GetDocumentPageImage, type DocumentPageRangeContent, type GetDocumentContentOptions } from '../../models/document';
7
+ import { type GetDocumentPageImage, type DocumentPageRangeContent, type GetDocumentContentOptions } from '../../models/document';
8
8
  export declare class MediaStore implements MediaApi {
9
9
  private readonly config;
10
10
  private readonly _chunkHashAlgorithm;
@@ -27,11 +27,48 @@ export type Line = {
27
27
  r: number;
28
28
  spans: readonly Span[];
29
29
  };
30
+ export type DocumentAnnotations = {
31
+ text_form_fields: readonly TextField[];
32
+ combobox_form_fields: readonly ComboBoxField[];
33
+ };
34
+ export type TextField = {
35
+ x: number;
36
+ y: number;
37
+ w: number;
38
+ h: number;
39
+ f: number;
40
+ text: string;
41
+ };
42
+ export type ComboBoxField = {
43
+ x: number;
44
+ y: number;
45
+ w: number;
46
+ h: number;
47
+ f: number;
48
+ text: string;
49
+ };
50
+ export type DocumentLink = {
51
+ type: 'uri';
52
+ dest: string;
53
+ x: number;
54
+ y: number;
55
+ w: number;
56
+ h: number;
57
+ } | {
58
+ type: 'local';
59
+ p_num: number;
60
+ x: number;
61
+ y: number;
62
+ w: number;
63
+ h: number;
64
+ };
30
65
  export type DocumentPageContent = {
31
66
  rotation: number;
32
67
  width: number;
33
68
  height: number;
34
69
  lines: readonly Line[];
70
+ annotations: DocumentAnnotations;
71
+ links: readonly DocumentLink[];
35
72
  };
36
73
  export type DocumentPageRangeContent = {
37
74
  total_pages: number;
@@ -4,7 +4,7 @@ import { type MediaFileArtifacts } from '@atlaskit/media-state';
4
4
  import type { ItemsPayload, ImageMetadata, MediaStoreResponse, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, RejectedTouchFile, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, TouchedFiles, MediaApi, CopyFileParams } from './types';
5
5
  import { type MediaFile, type MediaUpload } from '../../models/media';
6
6
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
7
- import { GetDocumentPageImage, type DocumentPageRangeContent, type GetDocumentContentOptions } from '../../models/document';
7
+ import { type GetDocumentPageImage, type DocumentPageRangeContent, type GetDocumentContentOptions } from '../../models/document';
8
8
  export declare class MediaStore implements MediaApi {
9
9
  private readonly config;
10
10
  private readonly _chunkHashAlgorithm;
@@ -27,11 +27,48 @@ export type Line = {
27
27
  r: number;
28
28
  spans: readonly Span[];
29
29
  };
30
+ export type DocumentAnnotations = {
31
+ text_form_fields: readonly TextField[];
32
+ combobox_form_fields: readonly ComboBoxField[];
33
+ };
34
+ export type TextField = {
35
+ x: number;
36
+ y: number;
37
+ w: number;
38
+ h: number;
39
+ f: number;
40
+ text: string;
41
+ };
42
+ export type ComboBoxField = {
43
+ x: number;
44
+ y: number;
45
+ w: number;
46
+ h: number;
47
+ f: number;
48
+ text: string;
49
+ };
50
+ export type DocumentLink = {
51
+ type: 'uri';
52
+ dest: string;
53
+ x: number;
54
+ y: number;
55
+ w: number;
56
+ h: number;
57
+ } | {
58
+ type: 'local';
59
+ p_num: number;
60
+ x: number;
61
+ y: number;
62
+ w: number;
63
+ h: number;
64
+ };
30
65
  export type DocumentPageContent = {
31
66
  rotation: number;
32
67
  width: number;
33
68
  height: number;
34
69
  lines: readonly Line[];
70
+ annotations: DocumentAnnotations;
71
+ links: readonly DocumentLink[];
35
72
  };
36
73
  export type DocumentPageRangeContent = {
37
74
  total_pages: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "33.4.0",
3
+ "version": "33.5.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@atlaskit/chunkinator": "^7.0.0",
38
- "@atlaskit/media-common": "^12.1.0",
38
+ "@atlaskit/media-common": "^12.2.0",
39
39
  "@atlaskit/platform-feature-flags": "^1.1.0",
40
40
  "@babel/runtime": "^7.0.0",
41
41
  "dataloader": "^2.1.0",
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/media-core": "^36.1.0",
58
58
  "@atlaskit/media-state": "^1.6.0",
59
59
  "@atlaskit/ssr": "workspace:^",
60
- "@atlaskit/tokens": "^5.1.0",
60
+ "@atlaskit/tokens": "^5.2.0",
61
61
  "@atlassian/feature-flags-test-utils": "^0.3.0",
62
62
  "@emotion/react": "^11.7.1",
63
63
  "@types/deep-equal": "^1.0.1",