@dhis2/app-service-data 3.14.5 → 3.14.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.
@@ -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 = {},
@@ -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 = {},
@@ -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.6",
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.6",
41
41
  "react": "^16.8.6 || ^18",
42
42
  "react-dom": "^16.8.6 || ^18"
43
43
  }