@txo/service-graphql-react 2.6.12 → 2.6.13

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,3 +1,10 @@
1
+ ## [2.6.13](https://github.com/technology-studio/service-graphql-react/compare/v2.6.12...v2.6.13) (2024-06-26)
2
+
3
+
4
+ ### Bug fixes
5
+
6
+ * **deps:** update dependency @apollo/client to ^3.10.7 ([06eb2e2](https://github.com/technology-studio/service-graphql-react/commit/06eb2e267781ccaac3a32a7852c45e004a51a7bf))
7
+
1
8
  ## [2.6.12](https://github.com/technology-studio/service-graphql-react/compare/v2.6.11...v2.6.12) (2024-06-21)
2
9
 
3
10
 
@@ -3,5 +3,4 @@
3
3
  * @Date: 2024-04-30T09:31:07+02:00
4
4
  * @Copyright: Technology Studio
5
5
  **/
6
- /// <reference types="react" />
7
6
  export declare const ObservableContext: import("react").Context<boolean>;
@@ -6,6 +6,7 @@
6
6
  **/
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.getName = void 0;
9
+ const types_1 = require("@txo/types");
9
10
  const graphql_1 = require("graphql");
10
11
  const upperCaseFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);
11
12
  const pascalCase = (string) => (`${string}`
@@ -13,14 +14,15 @@ const pascalCase = (string) => (`${string}`
13
14
  .replace(/[^\w\s]/g, '')
14
15
  .replace(/\s+(.)(\w*)/g, (_$1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`)
15
16
  .replace(/\w/, s => s.toUpperCase()));
17
+ const isOperationDefinitionNode = (node) => (node?.kind === graphql_1.Kind.OPERATION_DEFINITION);
16
18
  const getName = (query) => {
17
19
  const definition = query.definitions
18
- .find(definition => (definition.kind === graphql_1.Kind.OPERATION_DEFINITION));
20
+ .find(isOperationDefinitionNode);
19
21
  const operationName = definition?.name?.value
20
22
  .split('_')
21
23
  .map(pascalCase)
22
24
  .join('.');
23
- return operationName ?? upperCaseFirst(definition.operation);
25
+ return operationName ?? upperCaseFirst((0, types_1.is)(definition).operation);
24
26
  };
25
27
  exports.getName = getName;
26
28
  //# sourceMappingURL=OperationHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OperationHelper.js","sourceRoot":"","sources":["../../src/Api/OperationHelper.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qCAIgB;AAEhB,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC1F,MAAM,UAAU,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,CAC7C,GAAG,MAAM,EAAE;KACR,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KACtB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;KACvB,OAAO,CACN,cAAc,EACd,CAAC,GAAG,EAAE,EAAU,EAAE,EAAU,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAC1E;KACA,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CACvC,CAAA;AAEM,MAAM,OAAO,GAAG,CAAC,KAAmB,EAAU,EAAE;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW;SACjC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAClB,UAAU,CAAC,IAAI,KAAK,cAAI,CAAC,oBAAoB,CAC9C,CAA4B,CAAA;IAC/B,MAAM,aAAa,GAAG,UAAU,EAAE,IAAI,EAAE,KAAK;SAC1C,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,UAAU,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,OAAO,aAAa,IAAI,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,CA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C,CAAA;AAClE,CAAC,CAAA;AARY,QAAA,OAAO,WAQnB"}
@@ -19,7 +19,4 @@ export type MutationOptions<DATA, ATTRIBUTES> = {
19
19
  onFieldErrorsDependencyList?: DependencyList;
20
20
  errorMapDependencyList?: DependencyList;
21
21
  };
22
- export declare const useServiceMutation: <ATTRIBUTES extends Record<string, unknown>, DATA, CALL_ATTRIBUTES extends Partial<ATTRIBUTES & {
23
- context?: string | undefined;
24
- onFieldErrors?: ((fieldErrors: Record<string, Record<string, string>>) => void) | undefined;
25
- }>>(mutationDocument: TypedDocumentNode<DATA, ATTRIBUTES>, options?: MutationOptions<DATA, ATTRIBUTES>) => MutationServiceProp<ATTRIBUTES, DATA, CALL_ATTRIBUTES>;
22
+ export declare const useServiceMutation: <ATTRIBUTES extends Record<string, unknown>, DATA, CALL_ATTRIBUTES extends CallAttributes<ATTRIBUTES>>(mutationDocument: TypedDocumentNode<DATA, ATTRIBUTES>, options?: MutationOptions<DATA, ATTRIBUTES>) => MutationServiceProp<ATTRIBUTES, DATA, CALL_ATTRIBUTES>;
@@ -16,8 +16,5 @@ type QueryOptions<DATA, ATTRIBUTES extends OperationVariables, DATA_PATH extends
16
16
  options?: QueryHookOptions<DATA, ATTRIBUTES>;
17
17
  dataPath: DATA_PATH;
18
18
  };
19
- export declare const useServiceQuery: <ATTRIBUTES extends Record<string, unknown>, DATA, CALL_ATTRIBUTES extends Partial<ATTRIBUTES & {
20
- context?: string | undefined;
21
- onFieldErrors?: ((fieldErrors: Record<string, Record<string, string>>) => void) | undefined;
22
- }>, DATA_PATH extends string>(queryDocument: TypedDocumentNode<DATA, ATTRIBUTES>, options: QueryOptions<DATA, ATTRIBUTES, DATA_PATH>) => QueryServiceProp<ATTRIBUTES, DATA, Get<DATA, DATA_PATH>, CALL_ATTRIBUTES>;
19
+ export declare const useServiceQuery: <ATTRIBUTES extends Record<string, unknown>, DATA, CALL_ATTRIBUTES extends CallAttributes<ATTRIBUTES>, DATA_PATH extends string>(queryDocument: TypedDocumentNode<DATA, ATTRIBUTES>, options: QueryOptions<DATA, ATTRIBUTES, DATA_PATH>) => QueryServiceProp<ATTRIBUTES, DATA, Get<DATA, DATA_PATH>, CALL_ATTRIBUTES>;
23
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txo/service-graphql-react",
3
- "version": "2.6.12",
3
+ "version": "2.6.13",
4
4
  "description": "Technology Studio - Service graphql react",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -46,13 +46,13 @@
46
46
  "type-fest": "^4.20.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@apollo/client": "^3.10.6",
49
+ "@apollo/client": "^3.10.7",
50
50
  "@txo-peer-dep/service-error-handler-react": "^1.2.29",
51
51
  "@txo-peer-dep/service-graphql": "^3.3.3",
52
52
  "graphql": "^16.9.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@apollo/client": "^3.10.6",
55
+ "@apollo/client": "^3.10.7",
56
56
  "@txo-peer-dep/log": "^4.0.4",
57
57
  "@txo-peer-dep/service-error-handler-react": "^1.2.29",
58
58
  "@txo-peer-dep/service-graphql": "^3.3.3",
@@ -76,6 +76,6 @@
76
76
  "redux-saga": "^1.3.0",
77
77
  "rimraf": "^5.0.7",
78
78
  "ts-jest": "^29.1.5",
79
- "typescript": "^5.4.5"
79
+ "typescript": "^5.5.2"
80
80
  }
81
81
  }
@@ -4,7 +4,9 @@
4
4
  * @Copyright: Technology Studio
5
5
  **/
6
6
 
7
+ import { is } from '@txo/types'
7
8
  import {
9
+ type DefinitionNode,
8
10
  Kind,
9
11
  type DocumentNode,
10
12
  type OperationDefinitionNode,
@@ -22,14 +24,16 @@ const pascalCase = (string: string): string => (
22
24
  .replace(/\w/, s => s.toUpperCase())
23
25
  )
24
26
 
27
+ const isOperationDefinitionNode = (node: DefinitionNode): node is OperationDefinitionNode => (
28
+ node?.kind === Kind.OPERATION_DEFINITION
29
+ )
30
+
25
31
  export const getName = (query: DocumentNode): string => {
26
32
  const definition = query.definitions
27
- .find(definition => (
28
- definition.kind === Kind.OPERATION_DEFINITION
29
- )) as OperationDefinitionNode
33
+ .find(isOperationDefinitionNode)
30
34
  const operationName = definition?.name?.value
31
35
  .split('_')
32
36
  .map(pascalCase)
33
37
  .join('.')
34
- return operationName ?? upperCaseFirst(definition.operation)
38
+ return operationName ?? upperCaseFirst(is(definition).operation)
35
39
  }