@jsb188/graphql 1.1.7 → 1.1.10

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.
Files changed (73) hide show
  1. package/cache/config.ts +14 -4
  2. package/cache/index.test.ts +319 -0
  3. package/cache/index.ts +522 -85
  4. package/client/index.ts +2 -2
  5. package/client/request.ts +48 -9
  6. package/deno.test.json +6 -0
  7. package/gql/fragments/accountFragments.ts +1 -0
  8. package/gql/fragments/aiChatFragments.ts +1 -0
  9. package/gql/fragments/dataTableFragments.ts +212 -0
  10. package/gql/fragments/emailFragments.ts +26 -0
  11. package/gql/fragments/inboundContactFragments.ts +15 -0
  12. package/gql/fragments/integrationFragments.ts +22 -0
  13. package/gql/fragments/logFragments.ts +40 -12
  14. package/gql/fragments/organizationFragments.ts +59 -24
  15. package/gql/fragments/productFragments.ts +0 -24
  16. package/gql/fragments/reportFragments.ts +52 -10
  17. package/gql/fragments/sheetFragments.ts +145 -0
  18. package/gql/fragments/storageFragments.ts +3 -1
  19. package/gql/fragments/workflowFragments.ts +43 -0
  20. package/gql/mutations/accountMutations.ts +24 -2
  21. package/gql/mutations/aiChatMutations.ts +28 -1
  22. package/gql/mutations/authMutations.ts +3 -3
  23. package/gql/mutations/billingMutations.ts +1 -1
  24. package/gql/mutations/dataTableMutations.ts +84 -0
  25. package/gql/mutations/inboundContactMutations.ts +24 -0
  26. package/gql/mutations/index.ts +12 -8
  27. package/gql/mutations/integrationMutations.ts +25 -0
  28. package/gql/mutations/logMutations.ts +15 -1
  29. package/gql/mutations/organizationMutations.ts +151 -2
  30. package/gql/mutations/sheetMutations.ts +168 -0
  31. package/gql/mutations/storageMutations.ts +1 -2
  32. package/gql/queries/aiChatQueries.ts +1 -1
  33. package/gql/queries/billingQueries.ts +1 -1
  34. package/gql/queries/dataTableQueries.ts +45 -0
  35. package/gql/queries/emailQueries.ts +44 -0
  36. package/gql/queries/inboundContactQueries.ts +40 -0
  37. package/gql/queries/index.ts +11 -6
  38. package/gql/queries/logQueries.ts +47 -20
  39. package/gql/queries/organizationQueries.ts +62 -8
  40. package/gql/queries/productQueries.ts +1 -40
  41. package/gql/queries/reportQueries.ts +81 -13
  42. package/gql/queries/sheetQueries.ts +72 -0
  43. package/gql/queries/workflowQueries.ts +30 -0
  44. package/hooks/index.ts +208 -58
  45. package/hooks/use-account-mtn.ts +52 -4
  46. package/hooks/use-aiChat-mtn.ts +62 -6
  47. package/hooks/use-aiChat-qry.ts +76 -24
  48. package/hooks/use-app-qry.ts +2 -2
  49. package/hooks/use-auth-mtn.ts +5 -5
  50. package/hooks/use-dataTable-mtn.ts +87 -0
  51. package/hooks/use-dataTable-qry.ts +172 -0
  52. package/hooks/use-email-qry.ts +112 -0
  53. package/hooks/use-inboundContact-mtn.ts +31 -0
  54. package/hooks/use-inboundContact-qry.ts +88 -0
  55. package/hooks/use-integration-mtn.ts +59 -0
  56. package/hooks/use-integration-qry.ts +15 -0
  57. package/hooks/use-log-mtn.ts +6 -6
  58. package/hooks/use-log-qry.ts +38 -35
  59. package/hooks/use-organization-mtn.ts +288 -16
  60. package/hooks/use-organization-qry.ts +71 -22
  61. package/hooks/use-product-qry.ts +4 -46
  62. package/hooks/use-report-qry.ts +94 -10
  63. package/hooks/use-sheet-mtn.ts +181 -0
  64. package/hooks/use-sheet-qry.ts +157 -0
  65. package/hooks/use-storage-mtn.ts +6 -5
  66. package/hooks/use-storage-qry.ts +1 -1
  67. package/hooks/use-workflow-qry.ts +72 -0
  68. package/package.json +23 -4
  69. package/sse.ts +2 -2
  70. package/tsconfig.json +12 -0
  71. package/types.d.ts +2 -1
  72. package/utils.ts +2 -4
  73. package/gql/fragments/actionFragments.ts +0 -16
@@ -1,8 +1,8 @@
1
1
  import type { UseMutationParams } from '@jsb188/graphql/types.d';
2
2
  import { OpenModalPopUpFn } from '@jsb188/react/states';
3
- import { updateFragment } from '../cache/index';
4
- import { createSignedUploadUrlMtn, deleteStorageFileMtn } from '../gql/mutations/storageMutations';
5
- import { useMutation } from './index';
3
+ import { updateFragment } from '../cache/index.ts';
4
+ import { createSignedUploadUrlMtn, deleteStorageFileMtn } from '../gql/mutations/storageMutations.ts';
5
+ import { useMutation } from './index.ts';
6
6
 
7
7
  /**
8
8
  * Get signed URL for file uploads
@@ -38,8 +38,9 @@ export function useDeleteStorageFile(params: UseMutationParams = {}, openModalPo
38
38
  {
39
39
  openModalPopUp,
40
40
  onCompleted: (data, dataMtnValues, variables) => {
41
- if (data?.deleteStorageFile) {
42
- updateFragment(`$storageFileFragment:${variables.fileUri}`, { __deleted: true }, null, false, updateObservers);
41
+ const deletedStorageId = data?.deleteStorageFile;
42
+ if (deletedStorageId) {
43
+ updateFragment(`$storageFileFragment:${deletedStorageId}`, { __deleted: true }, null, false, updateObservers);
43
44
  }
44
45
  onCompleted?.(data, dataMtnValues, variables);
45
46
  },
@@ -1,4 +1,4 @@
1
- import { useReactiveFragment } from '../client';
1
+ import { useReactiveFragment } from '../client/index.ts';
2
2
 
3
3
  /**
4
4
  * Get reactive log fragment
@@ -0,0 +1,72 @@
1
+ import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
2
+ import { workflowRunsQry, workflowsQry } from '../gql/queries/workflowQueries.ts';
3
+ import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
4
+
5
+ /**
6
+ * Constants
7
+ */
8
+
9
+ const WORKFLOWS_LIST_LIMIT = 250;
10
+
11
+ /**
12
+ * Fetch workflows for an organization
13
+ */
14
+
15
+ export function useWorkflows(
16
+ variablesOrOrganizationId?: string | null | (PaginationArgs & {
17
+ organizationId?: string | null;
18
+ }),
19
+ params: UseQueryParams = {},
20
+ ) {
21
+ const usesPaginationVariables = typeof variablesOrOrganizationId === 'object' && variablesOrOrganizationId !== null;
22
+ const variables = usesPaginationVariables
23
+ ? variablesOrOrganizationId
24
+ : { organizationId: variablesOrOrganizationId };
25
+
26
+ const { data, ...rest } = useQuery(workflowsQry, {
27
+ variables: usesPaginationVariables ? {
28
+ ...variables,
29
+ cursor: null,
30
+ after: true,
31
+ limit: WORKFLOWS_LIST_LIMIT,
32
+ } : variables,
33
+ skip: !variables.organizationId,
34
+ ...params,
35
+ });
36
+
37
+ return {
38
+ workflows: data?.workflows,
39
+ ...rest
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Fetch runs for a workflow
45
+ */
46
+
47
+ export function useWorkflowRuns(workflowId?: string | null, params: UseQueryParams = {}) {
48
+ const { data, ...rest } = useQuery(workflowRunsQry, {
49
+ variables: {
50
+ workflowId,
51
+ },
52
+ skip: !workflowId,
53
+ ...params,
54
+ });
55
+
56
+ return {
57
+ workflowRuns: data?.workflowRuns,
58
+ ...rest
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Get reactive workflow fragment
64
+ */
65
+
66
+ export function useReactiveWorkflowFragment(workflowId: string, currentData?: any, queryCount?: number) {
67
+ return useReactiveFragment(
68
+ currentData,
69
+ [`$workflowFragment:${workflowId}`],
70
+ queryCount,
71
+ );
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsb188/graphql",
3
- "version": "1.1.7",
3
+ "version": "1.1.10",
4
4
  "description": "GraphQL client for react, using recoil",
5
5
  "license": "ISC",
6
6
  "author": "jsb188",
@@ -11,27 +11,46 @@
11
11
  "./fragments/accountAuth": "./gql/fragments/accountAuthFragments.ts",
12
12
  "./fragments/aiChat": "./gql/fragments/aiChatFragments.ts",
13
13
  "./fragments/billing": "./gql/fragments/billingFragments.ts",
14
+ "./fragments/email": "./gql/fragments/emailFragments.ts",
15
+ "./fragments/inboundContact": "./gql/fragments/inboundContactFragments.ts",
16
+ "./fragments/integration": "./gql/fragments/integrationFragments.ts",
14
17
  "./fragments/log": "./gql/fragments/logFragments.ts",
15
18
  "./fragments/organization": "./gql/fragments/organizationFragments.ts",
16
19
  "./fragments/other": "./gql/fragments/otherFragments.ts",
17
20
  "./fragments/product": "./gql/fragments/productFragments.ts",
18
21
  "./fragments/report": "./gql/fragments/reportFragments.ts",
22
+ "./fragments/dataTable": "./gql/fragments/dataTableFragments.ts",
23
+ "./fragments/sheet": "./gql/fragments/sheetFragments.ts",
19
24
  "./fragments/storage": "./gql/fragments/storageFragments.ts",
25
+ "./fragments/workflow": "./gql/fragments/workflowFragments.ts",
20
26
  "./hooks": "./hooks/",
21
27
  "./hooks/use-action-qry": "./hooks/use-action-qry.ts",
22
28
  "./hooks/use-aiChat-qry": "./hooks/use-aiChat-qry.ts",
23
29
  "./hooks/use-app-qry": "./hooks/use-app-qry.ts",
30
+ "./hooks/use-email-qry": "./hooks/use-email-qry.ts",
31
+ "./hooks/use-inboundContact-qry": "./hooks/use-inboundContact-qry.ts",
24
32
  "./hooks/use-log-qry": "./hooks/use-log-qry.ts",
25
33
  "./hooks/use-organization-qry": "./hooks/use-organization-qry.ts",
26
34
  "./hooks/use-product-qry": "./hooks/use-product-qry.ts",
27
35
  "./hooks/use-report-qry": "./hooks/use-report-qry.ts",
36
+ "./hooks/use-dataTable-mtn": "./hooks/use-dataTable-mtn.ts",
37
+ "./hooks/use-dataTable-qry": "./hooks/use-dataTable-qry.ts",
38
+ "./hooks/use-sheet-mtn": "./hooks/use-sheet-mtn.ts",
39
+ "./hooks/use-sheet-qry": "./hooks/use-sheet-qry.ts",
28
40
  "./hooks/use-storage-qry": "./hooks/use-storage-qry.ts",
41
+ "./hooks/use-workflow-qry": "./hooks/use-workflow-qry.ts",
29
42
  "./hooks/use-account-mtn": "./hooks/use-account-mtn.ts",
30
43
  "./hooks/use-aiChat-mtn": "./hooks/use-aiChat-mtn.ts",
31
44
  "./hooks/use-auth-mtn": "./hooks/use-auth-mtn.ts",
45
+ "./hooks/use-integration-qry": "./hooks/use-integration-qry.ts",
46
+ "./hooks/use-integration-mtn": "./hooks/use-integration-mtn.ts",
47
+ "./hooks/use-inboundContact-mtn": "./hooks/use-inboundContact-mtn.ts",
32
48
  "./hooks/use-log-mtn": "./hooks/use-log-mtn.ts",
33
49
  "./hooks/use-organization-mtn": "./hooks/use-organization-mtn.ts",
34
50
  "./hooks/use-storage-mtn": "./hooks/use-storage-mtn.ts",
51
+ "./mutations/integration": "./gql/mutations/integrationMutations.ts",
52
+ "./mutations/dataTable": "./gql/mutations/dataTableMutations.ts",
53
+ "./mutations/sheet": "./gql/mutations/sheetMutations.ts",
35
54
  "./mutations": "./gql/mutations/index.ts",
36
55
  "./queries": "./gql/queries/index.ts",
37
56
  "./cache": "./cache/index.ts",
@@ -41,14 +60,14 @@
41
60
  "./utils": "./utils.ts"
42
61
  },
43
62
  "scripts": {
44
- "test": "echo \"Error: no test specified\" && exit 1"
63
+ "test": "deno test --no-check --unstable-sloppy-imports --config ./deno.test.json ./cache/index.test.ts"
45
64
  },
46
65
  "dependencies": {
47
66
  "graphql": "^16.11.0",
48
67
  "graphql-tag": "^2.12.6"
49
68
  },
50
69
  "peerDependencies": {
51
- "@jsb188/app": "1.1.7",
52
- "@jsb188/react": "1.1.7"
70
+ "@jsb188/app": "1.1.10",
71
+ "@jsb188/react": "1.1.10"
53
72
  }
54
73
  }
package/sse.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { addFragmentToCache, updateFragment, updateQuery } from './cache/';
2
- import type { UpdateObserversFn } from './types.d';
1
+ import { addFragmentToCache, updateFragment, updateQuery } from './cache/index.ts';
2
+ import type { UpdateObserversFn } from './types.d.ts';
3
3
 
4
4
  /**
5
5
  * Types
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "noEmit": true,
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["**/*.ts", "**/*.tsx", "**/*.d.ts"]
12
+ }
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ServerErrorObj, SimpleErrorType } from '@jsb188/app/types/app.d';
1
+ import type { ServerErrorObj, SimpleErrorType } from '@jsb188/app/types/app.d.ts';
2
2
 
3
3
  /**
4
4
  * GraphQL API requests
@@ -21,6 +21,7 @@ export interface UpdateDataObserverArgs {
21
21
  queryId?: string | null;
22
22
  fragmentIds?: (string | null)[];
23
23
  forceRefetch?: boolean;
24
+ resetOnly?: boolean;
24
25
  }
25
26
 
26
27
  /**
package/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getENVVariable } from '@jsb188/app';
2
- import type { ServerErrorObj } from '@jsb188/app/types/app.d';
2
+ import type { ServerErrorObj } from '@jsb188/app/types/app.d.ts';
3
3
 
4
4
  const TIME_TRACKER = new Map();
5
5
 
@@ -63,9 +63,7 @@ export function isServerErrorGQL(apiResult: any): boolean {
63
63
  export function apiRequestHeaders(authorization?: string | null, ipAddress?: string | null): Headers {
64
64
  const headers: Record<string, string> = {
65
65
  'Content-Type': 'application/json; charset=utf-8',
66
- api_key: String(getENVVariable('GQL_API_KEY') || ''),
67
- origin: String(getENVVariable('APP_URL') || ''),
68
- 'Access-Control-Allow-Origin': String(getENVVariable('APP_URL') || ''),
66
+ 'x-api-key': String(getENVVariable('GQL_API_KEY') || ''),
69
67
  // recaptcha: ? // Not sure if we're going to do this later any more
70
68
  };
71
69
 
@@ -1,16 +0,0 @@
1
-
2
- export const actionTaskFragment = `fragment actionTaskFragment on ActionTask {
3
- id
4
- logId
5
-
6
- title
7
- message
8
- instruction
9
-
10
- scheduledAt
11
- delay
12
- completed
13
-
14
- createdAt
15
- updatedAt
16
- }`;