@dhis2/app-service-data 3.14.5 → 3.14.7

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/README.md CHANGED
@@ -8,4 +8,4 @@ This library is intended for use with the [DHIS2 Application Platform](https://g
8
8
 
9
9
  This package is internal to `@dhis2/app-runtime` and generally should not be installed independently.
10
10
 
11
- See [the docs](https://runtime.dhis2.nu) for more.
11
+ See [the docs](https://developers.dhis2.org/docs/app-runtime/getting-started) for more.
@@ -19,6 +19,11 @@ class DataEngine {
19
19
  _defineProperty(this, "link", void 0);
20
20
  this.link = link;
21
21
  }
22
+
23
+ // Overload 1: When no generic is provided, accept any Query and return inferred type
24
+
25
+ // Overload 2: When generic is provided, enforce that query keys match the generic keys
26
+
22
27
  query(query) {
23
28
  let {
24
29
  variables = {},
@@ -128,13 +128,13 @@ const isMetadataPackageInstallation = (type, _ref9) => {
128
128
  return type === 'create' && resource === 'synchronization/metadataPull';
129
129
  };
130
130
 
131
- // POST to 'indicators/expression/description' or 'programIndicator/expression/description' (validate an expression)
131
+ // POST to 'indicators/expression/description', 'programIndicator/expression/description', or 'validationRules/expression/description' (validate an expression)
132
132
  exports.isMetadataPackageInstallation = isMetadataPackageInstallation;
133
133
  const isExpressionDescriptionValidation = (type, _ref0) => {
134
134
  let {
135
135
  resource
136
136
  } = _ref0;
137
- const pattern = /^(indicators|programIndicators)\/expression\/description$/;
137
+ const pattern = /^(indicators|programIndicators|validationRules)\/expression\/description$/;
138
138
  return type === 'create' && pattern.test(resource);
139
139
  };
140
140
 
@@ -187,6 +187,16 @@ describe('isExpressionDescriptionValidation', () => {
187
187
  resource: 'programIndicators/expression/somethingelse'
188
188
  })).toBe(false);
189
189
  });
190
+ it('returns true for a POST to "validationRules/expression/description"', () => {
191
+ expect((0, _textPlainMatchers.isExpressionDescriptionValidation)('create', {
192
+ resource: 'validationRules/expression/description'
193
+ })).toBe(true);
194
+ });
195
+ it('retuns false for a POST to a different validationRules resource', () => {
196
+ expect((0, _textPlainMatchers.isExpressionDescriptionValidation)('create', {
197
+ resource: 'validationRules/expression/somethingelse'
198
+ })).toBe(false);
199
+ });
190
200
  });
191
201
  describe('isFilterDescriptionValidation', () => {
192
202
  it('returns true for a POST to "programIndicators/filter/description"', () => {
@@ -13,6 +13,11 @@ export class DataEngine {
13
13
  _defineProperty(this, "link", void 0);
14
14
  this.link = link;
15
15
  }
16
+
17
+ // Overload 1: When no generic is provided, accept any Query and return inferred type
18
+
19
+ // Overload 2: When generic is provided, enforce that query keys match the generic keys
20
+
16
21
  query(query) {
17
22
  let {
18
23
  variables = {},
@@ -114,12 +114,12 @@ export const isMetadataPackageInstallation = (type, _ref9) => {
114
114
  return type === 'create' && resource === 'synchronization/metadataPull';
115
115
  };
116
116
 
117
- // POST to 'indicators/expression/description' or 'programIndicator/expression/description' (validate an expression)
117
+ // POST to 'indicators/expression/description', 'programIndicator/expression/description', or 'validationRules/expression/description' (validate an expression)
118
118
  export const isExpressionDescriptionValidation = (type, _ref0) => {
119
119
  let {
120
120
  resource
121
121
  } = _ref0;
122
- const pattern = /^(indicators|programIndicators)\/expression\/description$/;
122
+ const pattern = /^(indicators|programIndicators|validationRules)\/expression\/description$/;
123
123
  return type === 'create' && pattern.test(resource);
124
124
  };
125
125
 
@@ -185,6 +185,16 @@ describe('isExpressionDescriptionValidation', () => {
185
185
  resource: 'programIndicators/expression/somethingelse'
186
186
  })).toBe(false);
187
187
  });
188
+ it('returns true for a POST to "validationRules/expression/description"', () => {
189
+ expect(isExpressionDescriptionValidation('create', {
190
+ resource: 'validationRules/expression/description'
191
+ })).toBe(true);
192
+ });
193
+ it('retuns false for a POST to a different validationRules resource', () => {
194
+ expect(isExpressionDescriptionValidation('create', {
195
+ resource: 'validationRules/expression/somethingelse'
196
+ })).toBe(false);
197
+ });
188
198
  });
189
199
  describe('isFilterDescriptionValidation', () => {
190
200
  it('returns true for a POST to "programIndicators/filter/description"', () => {
@@ -1,12 +1,13 @@
1
1
  import { DataEngineLink } from './types/DataEngineLink';
2
2
  import { QueryExecuteOptions } from './types/ExecuteOptions';
3
- import { JsonMap, JsonValue } from './types/JsonValue';
3
+ import { JsonValue } from './types/JsonValue';
4
4
  import { Mutation } from './types/Mutation';
5
- import { Query } from './types/Query';
5
+ import type { Query, ResourceQuery } from './types/Query';
6
6
  export declare class DataEngine {
7
7
  private link;
8
8
  constructor(link: DataEngineLink);
9
- query(query: Query, { variables, signal, onComplete, onError, }?: QueryExecuteOptions): Promise<JsonMap>;
9
+ query(query: Query, options?: QueryExecuteOptions): Promise<Record<keyof typeof query, unknown>>;
10
+ query<T extends Record<string, unknown>>(query: Record<keyof T, ResourceQuery>, options?: QueryExecuteOptions): Promise<T>;
10
11
  mutate(mutation: Mutation, { variables, signal, onComplete, onError, }?: QueryExecuteOptions): Promise<JsonValue>;
11
12
  }
12
13
  export default DataEngine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/app-service-data",
3
- "version": "3.14.5",
3
+ "version": "3.14.7",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "types": "build/types/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "prop-types": "^15.7.2"
38
38
  },
39
39
  "peerDependencies": {
40
- "@dhis2/app-service-config": "3.14.5",
40
+ "@dhis2/app-service-config": "3.14.7",
41
41
  "react": "^16.8.6 || ^18",
42
42
  "react-dom": "^16.8.6 || ^18"
43
43
  }