@atlaskit/adf-utils 18.4.2 → 19.0.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,21 @@
1
1
  # @atlaskit/adf-utils
2
2
 
3
+ ## 19.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`68ef7e6146c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/68ef7e6146c) - [ADF change] added widthType attribute to mediaSingle node, to support fixed width media node.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 18.4.3
14
+
15
+ ### Patch Changes
16
+
17
+ - [`c630941e8ca`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c630941e8ca) - Fix validation spec and modify default card node replacement where rest of the attributes are spread on top of replaced URL
18
+
3
19
  ## 18.4.2
4
20
 
5
21
  ### Patch Changes
@@ -14,9 +14,9 @@ var card = function card(node, _ref) {
14
14
  var valueReplacements = _ref.valueReplacements;
15
15
  return {
16
16
  type: node.type,
17
- attrs: {
17
+ attrs: _objectSpread(_objectSpread({}, node.attrs || {}), {}, {
18
18
  url: valueReplacements.href((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url)
19
- }
19
+ })
20
20
  };
21
21
  };
22
22
  var mediaParent = function mediaParent(node) {
@@ -23,7 +23,7 @@ var BYPASS_ATTR_LIST = {
23
23
  inlineExtension: ['extensionKey', 'extensionType', 'layout'],
24
24
  layoutColumn: ['width'],
25
25
  media: ['__fileMimeType', '__fileSize', 'height', 'width', 'type'],
26
- mediaSingle: ['layout', 'width'],
26
+ mediaSingle: ['layout', 'width', 'widthType'],
27
27
  orderedList: ['order'],
28
28
  panel: ['panelType'],
29
29
  status: ['color', 'style'],
@@ -11,19 +11,6 @@ var _default = {
11
11
  values: ['blockCard']
12
12
  },
13
13
  attrs: [{
14
- props: {
15
- url: {
16
- type: 'string',
17
- validatorFn: 'safeUrl'
18
- }
19
- }
20
- }, {
21
- props: {
22
- data: {
23
- type: 'object'
24
- }
25
- }
26
- }, {
27
14
  props: {
28
15
  url: {
29
16
  type: 'string',
@@ -65,6 +52,19 @@ var _default = {
65
52
  optional: true
66
53
  }
67
54
  }
55
+ }, {
56
+ props: {
57
+ url: {
58
+ type: 'string',
59
+ validatorFn: 'safeUrl'
60
+ }
61
+ }
62
+ }, {
63
+ props: {
64
+ data: {
65
+ type: 'object'
66
+ }
67
+ }
68
68
  }]
69
69
  },
70
70
  required: ['attrs']
@@ -10,8 +10,13 @@ var _default = {
10
10
  type: 'enum',
11
11
  values: ['mediaSingle']
12
12
  },
13
- attrs: {
13
+ attrs: [{
14
14
  props: {
15
+ widthType: {
16
+ type: 'enum',
17
+ values: ['percentage'],
18
+ optional: true
19
+ },
15
20
  width: {
16
21
  type: 'number',
17
22
  minimum: 0,
@@ -22,9 +27,23 @@ var _default = {
22
27
  type: 'enum',
23
28
  values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
24
29
  }
25
- },
26
- optional: true
27
- },
30
+ }
31
+ }, {
32
+ props: {
33
+ width: {
34
+ type: 'number',
35
+ minimum: 0
36
+ },
37
+ widthType: {
38
+ type: 'enum',
39
+ values: ['pixel']
40
+ },
41
+ layout: {
42
+ type: 'enum',
43
+ values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
44
+ }
45
+ }
46
+ }],
28
47
  marks: {
29
48
  type: 'array',
30
49
  items: ['link'],
@@ -708,7 +708,11 @@ function validator(nodes, marks, options) {
708
708
  // Required Props
709
709
  // For object format based on `optional` property
710
710
  var _partitionObject7 = partitionObject(validatorSpec.props, function (k, v) {
711
- return v.optional || (0, _utils.isDefined)(prevEntity[k]);
711
+ var _validatorSpec$requir;
712
+ // if the validator is an array, then check
713
+ // if the `required` field contains the key.
714
+ var isOptional = Array.isArray(v) ? !((_validatorSpec$requir = validatorSpec.required) !== null && _validatorSpec$requir !== void 0 && _validatorSpec$requir.includes(k)) : v.optional;
715
+ return isOptional || (0, _utils.isDefined)(prevEntity[k]);
712
716
  }),
713
717
  _partitionObject8 = (0, _slicedToArray2.default)(_partitionObject7, 2),
714
718
  missingProps = _partitionObject8[1];
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "18.4.2",
3
+ "version": "19.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -6,6 +6,7 @@ const card = (node, {
6
6
  return {
7
7
  type: node.type,
8
8
  attrs: {
9
+ ...(node.attrs || {}),
9
10
  url: valueReplacements.href((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url)
10
11
  }
11
12
  };
@@ -10,7 +10,7 @@ const BYPASS_ATTR_LIST = {
10
10
  inlineExtension: ['extensionKey', 'extensionType', 'layout'],
11
11
  layoutColumn: ['width'],
12
12
  media: ['__fileMimeType', '__fileSize', 'height', 'width', 'type'],
13
- mediaSingle: ['layout', 'width'],
13
+ mediaSingle: ['layout', 'width', 'widthType'],
14
14
  orderedList: ['order'],
15
15
  panel: ['panelType'],
16
16
  status: ['color', 'style'],
@@ -5,19 +5,6 @@ export default {
5
5
  values: ['blockCard']
6
6
  },
7
7
  attrs: [{
8
- props: {
9
- url: {
10
- type: 'string',
11
- validatorFn: 'safeUrl'
12
- }
13
- }
14
- }, {
15
- props: {
16
- data: {
17
- type: 'object'
18
- }
19
- }
20
- }, {
21
8
  props: {
22
9
  url: {
23
10
  type: 'string',
@@ -59,6 +46,19 @@ export default {
59
46
  optional: true
60
47
  }
61
48
  }
49
+ }, {
50
+ props: {
51
+ url: {
52
+ type: 'string',
53
+ validatorFn: 'safeUrl'
54
+ }
55
+ }
56
+ }, {
57
+ props: {
58
+ data: {
59
+ type: 'object'
60
+ }
61
+ }
62
62
  }]
63
63
  },
64
64
  required: ['attrs']
@@ -4,8 +4,13 @@ export default {
4
4
  type: 'enum',
5
5
  values: ['mediaSingle']
6
6
  },
7
- attrs: {
7
+ attrs: [{
8
8
  props: {
9
+ widthType: {
10
+ type: 'enum',
11
+ values: ['percentage'],
12
+ optional: true
13
+ },
9
14
  width: {
10
15
  type: 'number',
11
16
  minimum: 0,
@@ -16,9 +21,23 @@ export default {
16
21
  type: 'enum',
17
22
  values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
18
23
  }
19
- },
20
- optional: true
21
- },
24
+ }
25
+ }, {
26
+ props: {
27
+ width: {
28
+ type: 'number',
29
+ minimum: 0
30
+ },
31
+ widthType: {
32
+ type: 'enum',
33
+ values: ['pixel']
34
+ },
35
+ layout: {
36
+ type: 'enum',
37
+ values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
38
+ }
39
+ }
40
+ }],
22
41
  marks: {
23
42
  type: 'array',
24
43
  items: ['link'],
@@ -672,7 +672,13 @@ export function validator(nodes, marks, options) {
672
672
 
673
673
  // Required Props
674
674
  // For object format based on `optional` property
675
- const [, missingProps] = partitionObject(validatorSpec.props, (k, v) => v.optional || isDefined(prevEntity[k]));
675
+ const [, missingProps] = partitionObject(validatorSpec.props, (k, v) => {
676
+ var _validatorSpec$requir;
677
+ // if the validator is an array, then check
678
+ // if the `required` field contains the key.
679
+ const isOptional = Array.isArray(v) ? !((_validatorSpec$requir = validatorSpec.required) !== null && _validatorSpec$requir !== void 0 && _validatorSpec$requir.includes(k)) : v.optional;
680
+ return isOptional || isDefined(prevEntity[k]);
681
+ });
676
682
  if (missingProps.length) {
677
683
  return {
678
684
  hasValidated: true,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "18.4.2",
3
+ "version": "19.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -7,9 +7,9 @@ var card = function card(node, _ref) {
7
7
  var valueReplacements = _ref.valueReplacements;
8
8
  return {
9
9
  type: node.type,
10
- attrs: {
10
+ attrs: _objectSpread(_objectSpread({}, node.attrs || {}), {}, {
11
11
  url: valueReplacements.href((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url)
12
- }
12
+ })
13
13
  };
14
14
  };
15
15
  var mediaParent = function mediaParent(node) {
@@ -16,7 +16,7 @@ var BYPASS_ATTR_LIST = {
16
16
  inlineExtension: ['extensionKey', 'extensionType', 'layout'],
17
17
  layoutColumn: ['width'],
18
18
  media: ['__fileMimeType', '__fileSize', 'height', 'width', 'type'],
19
- mediaSingle: ['layout', 'width'],
19
+ mediaSingle: ['layout', 'width', 'widthType'],
20
20
  orderedList: ['order'],
21
21
  panel: ['panelType'],
22
22
  status: ['color', 'style'],
@@ -5,19 +5,6 @@ export default {
5
5
  values: ['blockCard']
6
6
  },
7
7
  attrs: [{
8
- props: {
9
- url: {
10
- type: 'string',
11
- validatorFn: 'safeUrl'
12
- }
13
- }
14
- }, {
15
- props: {
16
- data: {
17
- type: 'object'
18
- }
19
- }
20
- }, {
21
8
  props: {
22
9
  url: {
23
10
  type: 'string',
@@ -59,6 +46,19 @@ export default {
59
46
  optional: true
60
47
  }
61
48
  }
49
+ }, {
50
+ props: {
51
+ url: {
52
+ type: 'string',
53
+ validatorFn: 'safeUrl'
54
+ }
55
+ }
56
+ }, {
57
+ props: {
58
+ data: {
59
+ type: 'object'
60
+ }
61
+ }
62
62
  }]
63
63
  },
64
64
  required: ['attrs']
@@ -4,8 +4,13 @@ export default {
4
4
  type: 'enum',
5
5
  values: ['mediaSingle']
6
6
  },
7
- attrs: {
7
+ attrs: [{
8
8
  props: {
9
+ widthType: {
10
+ type: 'enum',
11
+ values: ['percentage'],
12
+ optional: true
13
+ },
9
14
  width: {
10
15
  type: 'number',
11
16
  minimum: 0,
@@ -16,9 +21,23 @@ export default {
16
21
  type: 'enum',
17
22
  values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
18
23
  }
19
- },
20
- optional: true
21
- },
24
+ }
25
+ }, {
26
+ props: {
27
+ width: {
28
+ type: 'number',
29
+ minimum: 0
30
+ },
31
+ widthType: {
32
+ type: 'enum',
33
+ values: ['pixel']
34
+ },
35
+ layout: {
36
+ type: 'enum',
37
+ values: ['wide', 'full-width', 'center', 'wrap-right', 'wrap-left', 'align-end', 'align-start']
38
+ }
39
+ }
40
+ }],
22
41
  marks: {
23
42
  type: 'array',
24
43
  items: ['link'],
@@ -697,7 +697,11 @@ export function validator(nodes, marks, options) {
697
697
  // Required Props
698
698
  // For object format based on `optional` property
699
699
  var _partitionObject7 = partitionObject(validatorSpec.props, function (k, v) {
700
- return v.optional || isDefined(prevEntity[k]);
700
+ var _validatorSpec$requir;
701
+ // if the validator is an array, then check
702
+ // if the `required` field contains the key.
703
+ var isOptional = Array.isArray(v) ? !((_validatorSpec$requir = validatorSpec.required) !== null && _validatorSpec$requir !== void 0 && _validatorSpec$requir.includes(k)) : v.optional;
704
+ return isOptional || isDefined(prevEntity[k]);
701
705
  }),
702
706
  _partitionObject8 = _slicedToArray(_partitionObject7, 2),
703
707
  missingProps = _partitionObject8[1];
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "18.4.2",
3
+ "version": "19.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,2 @@
1
- import { MediaSingleDefinition, MediaDefinition, RichMediaAttributes as MediaSingleAttributes, CaptionDefinition } from '@atlaskit/adf-schema';
1
+ import { MediaSingleDefinition, MediaDefinition, ExtendedMediaAttributes as MediaSingleAttributes, CaptionDefinition } from '@atlaskit/adf-schema';
2
2
  export declare const mediaSingle: (attrs: MediaSingleAttributes | undefined) => (content: MediaDefinition | [MediaDefinition] | [MediaDefinition, CaptionDefinition]) => MediaSingleDefinition;
@@ -5,28 +5,6 @@ declare const _default: {
5
5
  values: string[];
6
6
  };
7
7
  attrs: ({
8
- props: {
9
- url: {
10
- type: string;
11
- validatorFn: string;
12
- optional?: undefined;
13
- };
14
- data?: undefined;
15
- datasource?: undefined;
16
- width?: undefined;
17
- layout?: undefined;
18
- };
19
- } | {
20
- props: {
21
- data: {
22
- type: string;
23
- };
24
- url?: undefined;
25
- datasource?: undefined;
26
- width?: undefined;
27
- layout?: undefined;
28
- };
29
- } | {
30
8
  props: {
31
9
  url: {
32
10
  type: string;
@@ -69,6 +47,28 @@ declare const _default: {
69
47
  };
70
48
  data?: undefined;
71
49
  };
50
+ } | {
51
+ props: {
52
+ url: {
53
+ type: string;
54
+ validatorFn: string;
55
+ optional?: undefined;
56
+ };
57
+ datasource?: undefined;
58
+ width?: undefined;
59
+ layout?: undefined;
60
+ data?: undefined;
61
+ };
62
+ } | {
63
+ props: {
64
+ data: {
65
+ type: string;
66
+ };
67
+ url?: undefined;
68
+ datasource?: undefined;
69
+ width?: undefined;
70
+ layout?: undefined;
71
+ };
72
72
  })[];
73
73
  };
74
74
  required: string[];
@@ -4,8 +4,13 @@ declare const _default: {
4
4
  type: string;
5
5
  values: string[];
6
6
  };
7
- attrs: {
7
+ attrs: ({
8
8
  props: {
9
+ widthType: {
10
+ type: string;
11
+ values: string[];
12
+ optional: boolean;
13
+ };
9
14
  width: {
10
15
  type: string;
11
16
  minimum: number;
@@ -17,8 +22,25 @@ declare const _default: {
17
22
  values: string[];
18
23
  };
19
24
  };
20
- optional: boolean;
21
- };
25
+ } | {
26
+ props: {
27
+ width: {
28
+ type: string;
29
+ minimum: number;
30
+ maximum?: undefined;
31
+ optional?: undefined;
32
+ };
33
+ widthType: {
34
+ type: string;
35
+ values: string[];
36
+ optional?: undefined;
37
+ };
38
+ layout: {
39
+ type: string;
40
+ values: string[];
41
+ };
42
+ };
43
+ })[];
22
44
  marks: {
23
45
  type: string;
24
46
  items: string[];
@@ -1,4 +1,4 @@
1
- import { MediaSingleDefinition, MediaDefinition, RichMediaAttributes as MediaSingleAttributes, CaptionDefinition } from '@atlaskit/adf-schema';
1
+ import { MediaSingleDefinition, MediaDefinition, ExtendedMediaAttributes as MediaSingleAttributes, CaptionDefinition } from '@atlaskit/adf-schema';
2
2
  export declare const mediaSingle: (attrs: MediaSingleAttributes | undefined) => (content: MediaDefinition | [
3
3
  MediaDefinition
4
4
  ] | [
@@ -5,28 +5,6 @@ declare const _default: {
5
5
  values: string[];
6
6
  };
7
7
  attrs: ({
8
- props: {
9
- url: {
10
- type: string;
11
- validatorFn: string;
12
- optional?: undefined;
13
- };
14
- data?: undefined;
15
- datasource?: undefined;
16
- width?: undefined;
17
- layout?: undefined;
18
- };
19
- } | {
20
- props: {
21
- data: {
22
- type: string;
23
- };
24
- url?: undefined;
25
- datasource?: undefined;
26
- width?: undefined;
27
- layout?: undefined;
28
- };
29
- } | {
30
8
  props: {
31
9
  url: {
32
10
  type: string;
@@ -69,6 +47,28 @@ declare const _default: {
69
47
  };
70
48
  data?: undefined;
71
49
  };
50
+ } | {
51
+ props: {
52
+ url: {
53
+ type: string;
54
+ validatorFn: string;
55
+ optional?: undefined;
56
+ };
57
+ datasource?: undefined;
58
+ width?: undefined;
59
+ layout?: undefined;
60
+ data?: undefined;
61
+ };
62
+ } | {
63
+ props: {
64
+ data: {
65
+ type: string;
66
+ };
67
+ url?: undefined;
68
+ datasource?: undefined;
69
+ width?: undefined;
70
+ layout?: undefined;
71
+ };
72
72
  })[];
73
73
  };
74
74
  required: string[];
@@ -4,8 +4,13 @@ declare const _default: {
4
4
  type: string;
5
5
  values: string[];
6
6
  };
7
- attrs: {
7
+ attrs: ({
8
8
  props: {
9
+ widthType: {
10
+ type: string;
11
+ values: string[];
12
+ optional: boolean;
13
+ };
9
14
  width: {
10
15
  type: string;
11
16
  minimum: number;
@@ -17,8 +22,25 @@ declare const _default: {
17
22
  values: string[];
18
23
  };
19
24
  };
20
- optional: boolean;
21
- };
25
+ } | {
26
+ props: {
27
+ width: {
28
+ type: string;
29
+ minimum: number;
30
+ maximum?: undefined;
31
+ optional?: undefined;
32
+ };
33
+ widthType: {
34
+ type: string;
35
+ values: string[];
36
+ optional?: undefined;
37
+ };
38
+ layout: {
39
+ type: string;
40
+ values: string[];
41
+ };
42
+ };
43
+ })[];
22
44
  marks: {
23
45
  type: string;
24
46
  items: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "18.4.2",
3
+ "version": "19.0.0",
4
4
  "description": "Set of utilities to traverse, modify and create ADF documents.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -41,7 +41,7 @@
41
41
  "generate:spec": "rm -rf ./src/validator/specs/ && ../json-schema-generator/bin.js --outDir=./src/validator/specs/ --mode=Spec --stage=0 ./src/validator/entry.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@atlaskit/adf-schema": "^25.9.0",
44
+ "@atlaskit/adf-schema": "^26.0.0",
45
45
  "@atlaskit/codemod-utils": "^4.2.0",
46
46
  "@babel/runtime": "^7.0.0"
47
47
  },