@jsb188/graphql 1.1.8 → 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.
- package/cache/config.ts +14 -4
- package/cache/index.test.ts +319 -0
- package/cache/index.ts +478 -102
- package/client/index.ts +2 -2
- package/client/request.ts +48 -9
- package/deno.test.json +6 -0
- package/gql/fragments/accountFragments.ts +1 -0
- package/gql/fragments/aiChatFragments.ts +1 -0
- package/gql/fragments/dataTableFragments.ts +212 -0
- package/gql/fragments/emailFragments.ts +26 -0
- package/gql/fragments/inboundContactFragments.ts +15 -0
- package/gql/fragments/integrationFragments.ts +22 -0
- package/gql/fragments/logFragments.ts +40 -12
- package/gql/fragments/organizationFragments.ts +59 -24
- package/gql/fragments/productFragments.ts +0 -24
- package/gql/fragments/reportFragments.ts +52 -10
- package/gql/fragments/sheetFragments.ts +145 -0
- package/gql/fragments/storageFragments.ts +0 -1
- package/gql/fragments/workflowFragments.ts +43 -0
- package/gql/mutations/accountMutations.ts +24 -2
- package/gql/mutations/aiChatMutations.ts +28 -1
- package/gql/mutations/authMutations.ts +3 -3
- package/gql/mutations/billingMutations.ts +1 -1
- package/gql/mutations/dataTableMutations.ts +84 -0
- package/gql/mutations/inboundContactMutations.ts +24 -0
- package/gql/mutations/index.ts +12 -8
- package/gql/mutations/integrationMutations.ts +25 -0
- package/gql/mutations/logMutations.ts +15 -1
- package/gql/mutations/organizationMutations.ts +151 -2
- package/gql/mutations/sheetMutations.ts +168 -0
- package/gql/mutations/storageMutations.ts +1 -2
- package/gql/queries/aiChatQueries.ts +1 -1
- package/gql/queries/billingQueries.ts +1 -1
- package/gql/queries/dataTableQueries.ts +45 -0
- package/gql/queries/emailQueries.ts +44 -0
- package/gql/queries/inboundContactQueries.ts +40 -0
- package/gql/queries/index.ts +11 -6
- package/gql/queries/logQueries.ts +47 -20
- package/gql/queries/organizationQueries.ts +62 -8
- package/gql/queries/productQueries.ts +1 -40
- package/gql/queries/reportQueries.ts +81 -13
- package/gql/queries/sheetQueries.ts +72 -0
- package/gql/queries/workflowQueries.ts +30 -0
- package/hooks/index.ts +208 -58
- package/hooks/use-account-mtn.ts +52 -4
- package/hooks/use-aiChat-mtn.ts +62 -6
- package/hooks/use-aiChat-qry.ts +76 -24
- package/hooks/use-app-qry.ts +2 -2
- package/hooks/use-auth-mtn.ts +5 -5
- package/hooks/use-dataTable-mtn.ts +87 -0
- package/hooks/use-dataTable-qry.ts +172 -0
- package/hooks/use-email-qry.ts +112 -0
- package/hooks/use-inboundContact-mtn.ts +31 -0
- package/hooks/use-inboundContact-qry.ts +88 -0
- package/hooks/use-integration-mtn.ts +59 -0
- package/hooks/use-integration-qry.ts +15 -0
- package/hooks/use-log-mtn.ts +6 -6
- package/hooks/use-log-qry.ts +38 -35
- package/hooks/use-organization-mtn.ts +288 -16
- package/hooks/use-organization-qry.ts +71 -22
- package/hooks/use-product-qry.ts +4 -46
- package/hooks/use-report-qry.ts +93 -9
- package/hooks/use-sheet-mtn.ts +181 -0
- package/hooks/use-sheet-qry.ts +157 -0
- package/hooks/use-storage-mtn.ts +6 -5
- package/hooks/use-storage-qry.ts +1 -1
- package/hooks/use-workflow-qry.ts +72 -0
- package/package.json +23 -4
- package/sse.ts +2 -2
- package/tsconfig.json +12 -0
- package/types.d.ts +2 -1
- package/utils.ts +2 -4
- package/gql/fragments/actionFragments.ts +0 -16
package/hooks/use-storage-mtn.ts
CHANGED
|
@@ -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
|
-
|
|
42
|
-
|
|
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
|
},
|
package/hooks/use-storage-qry.ts
CHANGED
|
@@ -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.
|
|
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": "
|
|
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.
|
|
52
|
-
"@jsb188/react": "1.1.
|
|
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
|
-
|
|
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
|
|