@dhis2/app-service-data 3.2.9 → 3.3.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.
@@ -3,14 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isSvgConversion = exports.isAppInstall = exports.isStaticContentUpload = exports.isMessageConversationAttachment = exports.isFileResourceUpload = void 0;
6
+ exports.isSvgConversion = exports.isAppInstall = exports.isStaticContentUpload = exports.isMessageConversationAttachment = exports.isFileResourceUpload = exports.isDataValue = void 0;
7
7
 
8
8
  /*
9
9
  * Requests that expect a "multipart/form-data" Content-Type have been collected by scanning
10
10
  * the developer documentation:
11
11
  * https://docs.dhis2.org/master/en/developer/html/dhis2_developer_manual_full.html
12
12
  */
13
- // POST to 'fileResources' (upload a file resource)
13
+ // Post to 'dataValues' (send/update a data value; endpoint doesn't support JSON)
14
+ // For file-uploads too
15
+ const isDataValue = (type, {
16
+ resource
17
+ }) => type === 'create' && (resource === 'dataValues' || resource === 'dataValues/file'); // POST to 'fileResources' (upload a file resource)
18
+
19
+
20
+ exports.isDataValue = isDataValue;
21
+
14
22
  const isFileResourceUpload = (type, {
15
23
  resource
16
24
  }) => type === 'create' && resource === 'fileResources'; // POST to 'messageConversations/attachments' (upload a message conversation attachment)
@@ -2,6 +2,23 @@
2
2
 
3
3
  var _multipartFormDataMatchers = require("./multipartFormDataMatchers");
4
4
 
5
+ describe('isDataValue', () => {
6
+ it('returns true for a POST to "dataValues"', () => {
7
+ expect((0, _multipartFormDataMatchers.isDataValue)('create', {
8
+ resource: 'dataValues'
9
+ })).toEqual(true);
10
+ });
11
+ it('returns true for a POST to "dataValues/file"', () => {
12
+ expect((0, _multipartFormDataMatchers.isDataValue)('create', {
13
+ resource: 'dataValues/file'
14
+ })).toEqual(true);
15
+ });
16
+ it('returns false for a POST to a different resource', () => {
17
+ expect((0, _multipartFormDataMatchers.isDataValue)('create', {
18
+ resource: 'somethingElse'
19
+ })).toEqual(false);
20
+ });
21
+ });
5
22
  describe('isFileResourceUpload', () => {
6
23
  it('returns true for a POST to "fileResources"', () => {
7
24
  expect((0, _multipartFormDataMatchers.isFileResourceUpload)('create', {
@@ -3,7 +3,12 @@
3
3
  * the developer documentation:
4
4
  * https://docs.dhis2.org/master/en/developer/html/dhis2_developer_manual_full.html
5
5
  */
6
- // POST to 'fileResources' (upload a file resource)
6
+ // Post to 'dataValues' (send/update a data value; endpoint doesn't support JSON)
7
+ // For file-uploads too
8
+ export const isDataValue = (type, {
9
+ resource
10
+ }) => type === 'create' && (resource === 'dataValues' || resource === 'dataValues/file'); // POST to 'fileResources' (upload a file resource)
11
+
7
12
  export const isFileResourceUpload = (type, {
8
13
  resource
9
14
  }) => type === 'create' && resource === 'fileResources'; // POST to 'messageConversations/attachments' (upload a message conversation attachment)
@@ -1,4 +1,21 @@
1
- import { isFileResourceUpload, isMessageConversationAttachment, isStaticContentUpload, isAppInstall, isSvgConversion } from './multipartFormDataMatchers';
1
+ import { isFileResourceUpload, isMessageConversationAttachment, isStaticContentUpload, isAppInstall, isSvgConversion, isDataValue } from './multipartFormDataMatchers';
2
+ describe('isDataValue', () => {
3
+ it('returns true for a POST to "dataValues"', () => {
4
+ expect(isDataValue('create', {
5
+ resource: 'dataValues'
6
+ })).toEqual(true);
7
+ });
8
+ it('returns true for a POST to "dataValues/file"', () => {
9
+ expect(isDataValue('create', {
10
+ resource: 'dataValues/file'
11
+ })).toEqual(true);
12
+ });
13
+ it('returns false for a POST to a different resource', () => {
14
+ expect(isDataValue('create', {
15
+ resource: 'somethingElse'
16
+ })).toEqual(false);
17
+ });
18
+ });
2
19
  describe('isFileResourceUpload', () => {
3
20
  it('returns true for a POST to "fileResources"', () => {
4
21
  expect(isFileResourceUpload('create', {
@@ -1,4 +1,5 @@
1
1
  import { ResolvedResourceQuery, FetchType } from '../../../engine';
2
+ export declare const isDataValue: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
2
3
  export declare const isFileResourceUpload: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
3
4
  export declare const isMessageConversationAttachment: (type: FetchType, { resource }: ResolvedResourceQuery) => boolean;
4
5
  export declare const isStaticContentUpload: (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.9",
3
+ "version": "3.3.0",
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.9",
25
+ "@dhis2/app-service-config": "3.3.0",
26
26
  "@dhis2/cli-app-scripts": "^7.1.1",
27
27
  "prop-types": "^15.7.2",
28
28
  "react": "^16.8",