@dhis2/app-service-data 3.2.5 → 3.2.6
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/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +18 -8
- package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +38 -10
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +13 -6
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +39 -11
- package/build/types/links/RestAPILink/queryToRequestOptions/textPlainMatchers.d.ts +2 -1
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isMetadataPackageInstallation = exports.addOrUpdateConfigurationProperty = exports.isAddOrUpdateSystemOrUserSetting = exports.isInterpretationCommentUpdate = exports.isCommentOnInterpretation = exports.
|
|
6
|
+
exports.isMetadataPackageInstallation = exports.addOrUpdateConfigurationProperty = exports.isAddOrUpdateSystemOrUserSetting = exports.isInterpretationCommentUpdate = exports.isCommentOnInterpretation = exports.isUpdateInterpretation = exports.isCreateInterpretation = exports.isCreateFeedbackMessage = exports.isReplyToMessageConversation = void 0;
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
* Requests that expect a "text/plain" Content-Type have been collected by scanning
|
|
@@ -28,33 +28,43 @@ exports.isReplyToMessageConversation = isReplyToMessageConversation;
|
|
|
28
28
|
|
|
29
29
|
const isCreateFeedbackMessage = (type, {
|
|
30
30
|
resource
|
|
31
|
-
}) => type === 'create' && resource === 'messageConversations/feedback'; // POST
|
|
31
|
+
}) => type === 'create' && resource === 'messageConversations/feedback'; // POST `interpretations/${objectType}/${id}` (add an interpretation to a visualization)
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
exports.isCreateFeedbackMessage = isCreateFeedbackMessage;
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const isCreateInterpretation = (type, {
|
|
37
|
+
resource
|
|
38
|
+
}) => {
|
|
39
|
+
const pattern = /^interpretations\/(?:reportTable|chart|visualization|map|eventReport|eventChart|dataSetReport)\/[a-zA-Z0-9]{11}$/;
|
|
40
|
+
return type === 'create' && pattern.test(resource);
|
|
41
|
+
}; // PUT to `interpretations/${id}` (update an interpretation)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
exports.isCreateInterpretation = isCreateInterpretation;
|
|
45
|
+
|
|
46
|
+
const isUpdateInterpretation = (type, {
|
|
37
47
|
resource,
|
|
38
48
|
id
|
|
39
49
|
}) => {
|
|
40
|
-
if (type !== '
|
|
50
|
+
if (type !== 'replace') {
|
|
41
51
|
return false;
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
let resourcePattern;
|
|
45
55
|
|
|
46
|
-
if (
|
|
47
|
-
resourcePattern = /^interpretations
|
|
56
|
+
if (id) {
|
|
57
|
+
resourcePattern = /^interpretations$/;
|
|
48
58
|
const idPattern = /^[a-zA-Z0-9]{11}$/;
|
|
49
59
|
return resourcePattern.test(resource) && idPattern.test(id);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
resourcePattern = /^interpretations\/
|
|
62
|
+
resourcePattern = /^interpretations\/[a-zA-Z0-9]{11}$/;
|
|
53
63
|
return resourcePattern.test(resource);
|
|
54
64
|
}; // POST to `interpretations/${id}/comments` (comment on an interpretation)
|
|
55
65
|
|
|
56
66
|
|
|
57
|
-
exports.
|
|
67
|
+
exports.isUpdateInterpretation = isUpdateInterpretation;
|
|
58
68
|
|
|
59
69
|
const isCommentOnInterpretation = (type, {
|
|
60
70
|
resource
|
|
@@ -26,30 +26,58 @@ describe('isCreateFeedbackMessage', () => {
|
|
|
26
26
|
})).toEqual(false);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
-
describe('
|
|
29
|
+
describe('isCreateInterpretation', () => {
|
|
30
30
|
it('returns true for a POST to "interpretations/chart/${id}"', () => {
|
|
31
|
-
expect((0, _textPlainMatchers.
|
|
31
|
+
expect((0, _textPlainMatchers.isCreateInterpretation)('create', {
|
|
32
32
|
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
33
33
|
})).toEqual(true);
|
|
34
34
|
});
|
|
35
|
-
it('returns
|
|
36
|
-
expect((0, _textPlainMatchers.
|
|
35
|
+
it('returns false for a PUT to "interpretations/chart/${id}"', () => {
|
|
36
|
+
expect((0, _textPlainMatchers.isCreateInterpretation)('replace', {
|
|
37
37
|
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
38
|
+
})).toEqual(false);
|
|
39
|
+
});
|
|
40
|
+
it('retuns false for PATCH requests with a valid query', () => {
|
|
41
|
+
expect((0, _textPlainMatchers.isCreateInterpretation)('update', {
|
|
42
|
+
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
43
|
+
})).toEqual(false);
|
|
44
|
+
});
|
|
45
|
+
it('returns false for a request to a different resource', () => {
|
|
46
|
+
expect((0, _textPlainMatchers.isCreateInterpretation)('create', {
|
|
47
|
+
resource: 'interpretations/dummy/oXD88WWSQpR'
|
|
48
|
+
})).toEqual(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('isUpdateInterpretation', () => {
|
|
52
|
+
it('returns true for a PUT to "interpretations/${id}"', () => {
|
|
53
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('replace', {
|
|
54
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
38
55
|
})).toEqual(true);
|
|
39
56
|
});
|
|
40
57
|
it('returns true for PUT with populated query.id', () => {
|
|
41
|
-
expect((0, _textPlainMatchers.
|
|
42
|
-
resource: 'interpretations
|
|
58
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('replace', {
|
|
59
|
+
resource: 'interpretations',
|
|
43
60
|
id: 'oXD88WWSQpR'
|
|
44
61
|
})).toEqual(true);
|
|
45
62
|
});
|
|
46
|
-
it('
|
|
47
|
-
expect((0, _textPlainMatchers.
|
|
48
|
-
resource: 'interpretations/
|
|
63
|
+
it('returns false for a POST to "interpretations/${id}"', () => {
|
|
64
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('create', {
|
|
65
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
66
|
+
})).toEqual(false);
|
|
67
|
+
});
|
|
68
|
+
it('returns false for a PATCH to "interpretations/${id}"', () => {
|
|
69
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('update', {
|
|
70
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
71
|
+
})).toEqual(false);
|
|
72
|
+
});
|
|
73
|
+
it('returns false for PATCH with populated query.id', () => {
|
|
74
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('update', {
|
|
75
|
+
resource: 'interpretations',
|
|
76
|
+
id: 'oXD88WWSQpR'
|
|
49
77
|
})).toEqual(false);
|
|
50
78
|
});
|
|
51
79
|
it('returns false for a request to a different resource', () => {
|
|
52
|
-
expect((0, _textPlainMatchers.
|
|
80
|
+
expect((0, _textPlainMatchers.isUpdateInterpretation)('create', {
|
|
53
81
|
resource: 'interpretations/dummy/oXD88WWSQpR'
|
|
54
82
|
})).toEqual(false);
|
|
55
83
|
});
|
|
@@ -18,25 +18,32 @@ export const isReplyToMessageConversation = (type, {
|
|
|
18
18
|
|
|
19
19
|
export const isCreateFeedbackMessage = (type, {
|
|
20
20
|
resource
|
|
21
|
-
}) => type === 'create' && resource === 'messageConversations/feedback'; // POST
|
|
21
|
+
}) => type === 'create' && resource === 'messageConversations/feedback'; // POST `interpretations/${objectType}/${id}` (add an interpretation to a visualization)
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const isCreateInterpretation = (type, {
|
|
24
|
+
resource
|
|
25
|
+
}) => {
|
|
26
|
+
const pattern = /^interpretations\/(?:reportTable|chart|visualization|map|eventReport|eventChart|dataSetReport)\/[a-zA-Z0-9]{11}$/;
|
|
27
|
+
return type === 'create' && pattern.test(resource);
|
|
28
|
+
}; // PUT to `interpretations/${id}` (update an interpretation)
|
|
29
|
+
|
|
30
|
+
export const isUpdateInterpretation = (type, {
|
|
24
31
|
resource,
|
|
25
32
|
id
|
|
26
33
|
}) => {
|
|
27
|
-
if (type !== '
|
|
34
|
+
if (type !== 'replace') {
|
|
28
35
|
return false;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
let resourcePattern;
|
|
32
39
|
|
|
33
|
-
if (
|
|
34
|
-
resourcePattern = /^interpretations
|
|
40
|
+
if (id) {
|
|
41
|
+
resourcePattern = /^interpretations$/;
|
|
35
42
|
const idPattern = /^[a-zA-Z0-9]{11}$/;
|
|
36
43
|
return resourcePattern.test(resource) && idPattern.test(id);
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
resourcePattern = /^interpretations\/
|
|
46
|
+
resourcePattern = /^interpretations\/[a-zA-Z0-9]{11}$/;
|
|
40
47
|
return resourcePattern.test(resource);
|
|
41
48
|
}; // POST to `interpretations/${id}/comments` (comment on an interpretation)
|
|
42
49
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isReplyToMessageConversation, isCreateFeedbackMessage,
|
|
1
|
+
import { isReplyToMessageConversation, isCreateFeedbackMessage, isCreateInterpretation, isUpdateInterpretation, isCommentOnInterpretation, isInterpretationCommentUpdate, isAddOrUpdateSystemOrUserSetting, addOrUpdateConfigurationProperty, isMetadataPackageInstallation } from './textPlainMatchers';
|
|
2
2
|
describe('isReplyToMessageConversation', () => {
|
|
3
3
|
it('retuns true for POST to `messageConversations/${id}`', () => {
|
|
4
4
|
expect(isReplyToMessageConversation('create', {
|
|
@@ -23,30 +23,58 @@ describe('isCreateFeedbackMessage', () => {
|
|
|
23
23
|
})).toEqual(false);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
describe('
|
|
26
|
+
describe('isCreateInterpretation', () => {
|
|
27
27
|
it('returns true for a POST to "interpretations/chart/${id}"', () => {
|
|
28
|
-
expect(
|
|
28
|
+
expect(isCreateInterpretation('create', {
|
|
29
29
|
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
30
30
|
})).toEqual(true);
|
|
31
31
|
});
|
|
32
|
-
it('returns
|
|
33
|
-
expect(
|
|
32
|
+
it('returns false for a PUT to "interpretations/chart/${id}"', () => {
|
|
33
|
+
expect(isCreateInterpretation('replace', {
|
|
34
34
|
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
35
|
+
})).toEqual(false);
|
|
36
|
+
});
|
|
37
|
+
it('retuns false for PATCH requests with a valid query', () => {
|
|
38
|
+
expect(isCreateInterpretation('update', {
|
|
39
|
+
resource: 'interpretations/chart/oXD88WWSQpR'
|
|
40
|
+
})).toEqual(false);
|
|
41
|
+
});
|
|
42
|
+
it('returns false for a request to a different resource', () => {
|
|
43
|
+
expect(isCreateInterpretation('create', {
|
|
44
|
+
resource: 'interpretations/dummy/oXD88WWSQpR'
|
|
45
|
+
})).toEqual(false);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('isUpdateInterpretation', () => {
|
|
49
|
+
it('returns true for a PUT to "interpretations/${id}"', () => {
|
|
50
|
+
expect(isUpdateInterpretation('replace', {
|
|
51
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
35
52
|
})).toEqual(true);
|
|
36
53
|
});
|
|
37
54
|
it('returns true for PUT with populated query.id', () => {
|
|
38
|
-
expect(
|
|
39
|
-
resource: 'interpretations
|
|
55
|
+
expect(isUpdateInterpretation('replace', {
|
|
56
|
+
resource: 'interpretations',
|
|
40
57
|
id: 'oXD88WWSQpR'
|
|
41
58
|
})).toEqual(true);
|
|
42
59
|
});
|
|
43
|
-
it('
|
|
44
|
-
expect(
|
|
45
|
-
resource: 'interpretations/
|
|
60
|
+
it('returns false for a POST to "interpretations/${id}"', () => {
|
|
61
|
+
expect(isUpdateInterpretation('create', {
|
|
62
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
63
|
+
})).toEqual(false);
|
|
64
|
+
});
|
|
65
|
+
it('returns false for a PATCH to "interpretations/${id}"', () => {
|
|
66
|
+
expect(isUpdateInterpretation('update', {
|
|
67
|
+
resource: 'interpretations/oXD88WWSQpR'
|
|
68
|
+
})).toEqual(false);
|
|
69
|
+
});
|
|
70
|
+
it('returns false for PATCH with populated query.id', () => {
|
|
71
|
+
expect(isUpdateInterpretation('update', {
|
|
72
|
+
resource: 'interpretations',
|
|
73
|
+
id: 'oXD88WWSQpR'
|
|
46
74
|
})).toEqual(false);
|
|
47
75
|
});
|
|
48
76
|
it('returns false for a request to a different resource', () => {
|
|
49
|
-
expect(
|
|
77
|
+
expect(isUpdateInterpretation('create', {
|
|
50
78
|
resource: 'interpretations/dummy/oXD88WWSQpR'
|
|
51
79
|
})).toEqual(false);
|
|
52
80
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ResolvedResourceQuery, FetchType } from '../../../engine';
|
|
2
2
|
export declare const isReplyToMessageConversation: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
|
|
3
3
|
export declare const isCreateFeedbackMessage: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const isCreateInterpretation: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
|
|
5
|
+
export declare const isUpdateInterpretation: (type: FetchType, { resource, id }: ResolvedResourceQuery) => boolean;
|
|
5
6
|
export declare const isCommentOnInterpretation: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
|
|
6
7
|
export declare const isInterpretationCommentUpdate: (type: FetchType, { resource, id }: ResolvedResourceQuery) => boolean;
|
|
7
8
|
export declare const isAddOrUpdateSystemOrUserSetting: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/app-service-data",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"main": "./build/cjs/index.js",
|
|
5
5
|
"module": "./build/es/index.js",
|
|
6
6
|
"types": "build/types/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build/**"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@dhis2/app-service-config": "3.2.
|
|
25
|
+
"@dhis2/app-service-config": "3.2.6",
|
|
26
26
|
"@dhis2/cli-app-scripts": "^7.1.1",
|
|
27
27
|
"prop-types": "^15.7.2",
|
|
28
28
|
"react": "^16.8",
|