@jsb188/graphql 1.1.8 → 1.1.11

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 (122) hide show
  1. package/cache/config.ts +66 -42
  2. package/cache/index.test.ts +881 -0
  3. package/cache/index.ts +1815 -979
  4. package/cache/persist.ts +721 -0
  5. package/cache/store.ts +437 -0
  6. package/client/data-table-realtime-subscriptions.test.ts +740 -0
  7. package/client/data-table-realtime-subscriptions.ts +955 -0
  8. package/client/data-table-realtime.test.ts +792 -0
  9. package/client/data-table-realtime.ts +1218 -0
  10. package/client/fragment-realtime-sequence.ts +52 -0
  11. package/client/index.ts +4 -2
  12. package/client/open-sheet.ts +137 -0
  13. package/client/request-managed-session.test.ts +574 -0
  14. package/client/request-no-store.test.ts +157 -0
  15. package/client/request.ts +973 -143
  16. package/client/sse-ticket.test.ts +26 -0
  17. package/deno.lock +170 -0
  18. package/deno.test.json +10 -0
  19. package/drafts/index.ts +149 -0
  20. package/drafts/store.ts +397 -0
  21. package/gql/eagerQueryMap.ts +12 -0
  22. package/gql/fragments/accountAuthFragments.ts +5 -0
  23. package/gql/fragments/accountFragments.ts +1 -3
  24. package/gql/fragments/accountSessionFragments.ts +16 -0
  25. package/gql/fragments/agentDocFragments.ts +46 -0
  26. package/gql/fragments/agentMemoryFragments.ts +19 -0
  27. package/gql/fragments/aiChatFragments.ts +17 -0
  28. package/gql/fragments/billingFragments.ts +0 -11
  29. package/gql/fragments/campaignFragments.ts +277 -0
  30. package/gql/fragments/dataTableFragments.ts +102 -0
  31. package/gql/fragments/emailFragments.ts +36 -0
  32. package/gql/fragments/fieldDocFragments.ts +82 -0
  33. package/gql/fragments/inboundContactFragments.ts +15 -0
  34. package/gql/fragments/integrationFragments.ts +22 -0
  35. package/gql/fragments/logFragments.ts +33 -64
  36. package/gql/fragments/organizationFragments.ts +94 -21
  37. package/gql/fragments/scheduleFragments.ts +155 -0
  38. package/gql/fragments/sheetFragments.ts +675 -0
  39. package/gql/fragments/storageFragments.ts +21 -1
  40. package/gql/fragments/workflowFragments.ts +67 -0
  41. package/gql/mutations/accountMutations.ts +24 -4
  42. package/gql/mutations/agentDocMutations.ts +177 -0
  43. package/gql/mutations/agentMemoryMutations.ts +36 -0
  44. package/gql/mutations/aiChatMutations.ts +43 -3
  45. package/gql/mutations/authMutations.ts +160 -19
  46. package/gql/mutations/campaignMutations.ts +215 -0
  47. package/gql/mutations/dataTableMutations.ts +106 -0
  48. package/gql/mutations/fieldDocMutations.ts +24 -0
  49. package/gql/mutations/inboundContactMutations.ts +24 -0
  50. package/gql/mutations/index.ts +17 -8
  51. package/gql/mutations/integrationMutations.ts +25 -0
  52. package/gql/mutations/logMutations.ts +10 -19
  53. package/gql/mutations/organizationMutations.ts +160 -2
  54. package/gql/mutations/scheduleMutations.ts +423 -0
  55. package/gql/mutations/sheetMutations.ts +385 -0
  56. package/gql/mutations/storageMutations.ts +21 -2
  57. package/gql/mutations/workflowMutations.ts +42 -0
  58. package/gql/queries/agentDocQueries.ts +120 -0
  59. package/gql/queries/agentMemoryQueries.ts +22 -0
  60. package/gql/queries/aiChatQueries.ts +18 -2
  61. package/gql/queries/authQueries.ts +41 -0
  62. package/gql/queries/billingQueries.ts +24 -1
  63. package/gql/queries/campaignQueries.ts +127 -0
  64. package/gql/queries/dataTableQueries.ts +134 -0
  65. package/gql/queries/emailQueries.ts +96 -0
  66. package/gql/queries/fieldDocQueries.ts +158 -0
  67. package/gql/queries/inboundContactQueries.ts +40 -0
  68. package/gql/queries/index.ts +17 -6
  69. package/gql/queries/logQueries.ts +42 -32
  70. package/gql/queries/organizationQueries.ts +113 -8
  71. package/gql/queries/scheduleQueries.ts +315 -0
  72. package/gql/queries/sheetQueries.ts +383 -0
  73. package/gql/queries/storageQueries.ts +38 -0
  74. package/gql/queries/workflowQueries.ts +99 -0
  75. package/hooks/index.ts +2104 -860
  76. package/hooks/use-account-mtn.ts +91 -48
  77. package/hooks/use-agentDoc-mtn.ts +285 -0
  78. package/hooks/use-agentDoc-qry.ts +208 -0
  79. package/hooks/use-agentMemory-mtn.ts +73 -0
  80. package/hooks/use-agentMemory-qry.ts +44 -0
  81. package/hooks/use-aiChat-mtn.ts +248 -97
  82. package/hooks/use-aiChat-qry.ts +501 -191
  83. package/hooks/use-app-qry.ts +14 -11
  84. package/hooks/use-auth-mtn.ts +410 -256
  85. package/hooks/use-auth-qry.ts +51 -0
  86. package/hooks/use-campaign-mtn.ts +377 -0
  87. package/hooks/use-campaign-qry.ts +257 -0
  88. package/hooks/use-dataTable-mtn.ts +170 -0
  89. package/hooks/use-dataTable-qry.ts +996 -0
  90. package/hooks/use-email-qry.ts +227 -0
  91. package/hooks/use-fieldDoc-mtn.ts +50 -0
  92. package/hooks/use-fieldDoc-qry.ts +180 -0
  93. package/hooks/use-inboundContact-mtn.ts +34 -0
  94. package/hooks/use-inboundContact-qry.ts +96 -0
  95. package/hooks/use-integration-mtn.ts +77 -0
  96. package/hooks/use-integration-qry.ts +30 -0
  97. package/hooks/use-log-mtn.ts +77 -61
  98. package/hooks/use-log-qry.ts +99 -72
  99. package/hooks/use-organization-mtn.ts +409 -80
  100. package/hooks/use-organization-qry.ts +211 -92
  101. package/hooks/use-schedule-mtn.ts +416 -0
  102. package/hooks/use-schedule-qry.ts +157 -0
  103. package/hooks/use-sheet-mtn.ts +367 -0
  104. package/hooks/use-sheet-qry.ts +440 -0
  105. package/hooks/use-storage-mtn.ts +83 -42
  106. package/hooks/use-storage-qry.ts +104 -13
  107. package/hooks/use-workflow-mtn.ts +55 -0
  108. package/hooks/use-workflow-qry.ts +230 -0
  109. package/loaders/campaign.ts +137 -0
  110. package/package.json +94 -52
  111. package/sse.ts +158 -105
  112. package/tsconfig.json +13 -0
  113. package/types.d.ts +60 -29
  114. package/utils.ts +77 -50
  115. package/gql/fragments/actionFragments.ts +0 -16
  116. package/gql/fragments/productFragments.ts +0 -63
  117. package/gql/fragments/reportFragments.ts +0 -48
  118. package/gql/mutations/billingMutations.ts +0 -34
  119. package/gql/queries/productQueries.ts +0 -70
  120. package/gql/queries/reportQueries.ts +0 -66
  121. package/hooks/use-product-qry.ts +0 -109
  122. package/hooks/use-report-qry.ts +0 -69
@@ -1,63 +0,0 @@
1
-
2
- export const productFragment = `fragment productFragment on Product {
3
- id
4
- organizationId
5
- cursor
6
-
7
- metadata {
8
- overview
9
- }
10
-
11
- createdAt
12
- updatedAt
13
- }`;
14
-
15
- export const productCalEventFragment = `fragment productCalEventFragment on ProductCalEvent {
16
- __typename
17
-
18
- id
19
- name
20
-
21
- schedule {
22
- frequency
23
- weeksOfMonth
24
- daysOfWeek
25
- time
26
- }
27
-
28
- address {
29
- line1
30
- line2
31
- city
32
- state
33
- postalCode
34
- country
35
- }
36
-
37
- startAt
38
- endAt
39
- }`;
40
-
41
- export const productAttendanceFragment = `fragment productAttendanceFragment on ProductAttendance {
42
- id
43
- productId
44
- organizationId
45
- calDate
46
- attended
47
- }`;
48
-
49
- export const productLivestockFragment = `fragment productLivestockFragment on ProductLivestock {
50
- __typename
51
-
52
- id
53
- damIdentifier
54
- livestockIdentifier
55
- livestockGroup
56
-
57
- type
58
- status
59
- livestockClass
60
-
61
- birthDate
62
- deathDate
63
- }`;
@@ -1,48 +0,0 @@
1
-
2
- export const reportFragment = `fragment reportFragment on Report {
3
- id
4
- organizationId
5
-
6
- documentName
7
- title
8
- description
9
- type
10
- period
11
- evidencesCount
12
- gridLayoutStyle
13
-
14
- activityAt
15
- }`;
16
-
17
- export const reportSectionFragment = `fragment reportSectionFragment on ReportSection {
18
- id
19
- isGroupTitle
20
- sectionKey
21
- sectionName
22
- title
23
- description
24
- requireFileUploads
25
- }`;
26
-
27
- export const reportRowDataFragment = `fragment reportRowDataFragment on ReportRowData {
28
- id
29
- preset
30
- className
31
- isHeader
32
- }`;
33
-
34
- export const reportColumnDataFragment = `fragment reportColumnDataFragment on ReportColumnData {
35
- id
36
- className
37
- label
38
- text
39
- placeholder
40
- checked
41
- }`;
42
-
43
- export const reportAvailabilityFragment = `fragment reportAvailabilityFragment on ReportAvailability {
44
- id
45
- organizationId
46
- type
47
- periods
48
- }`;
@@ -1,34 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
- import { platformProductPurchaseResultFragment } from '../fragments/billingFragments';
3
-
4
- export const purchasePlatformProductMtn = gql`
5
- mutation purchasePlatformProduct (
6
- $paymentId: String!
7
- $paymentMethodId: String!
8
- $productGroup: PlatformProductGroup!
9
- $email: String!
10
- $name: String
11
- ) {
12
- purchasePlatformProduct (
13
- paymentId: $paymentId
14
- paymentMethodId: $paymentMethodId
15
- productGroup: $productGroup
16
- email: $email
17
- name: $name
18
- ) {
19
- ...platformProductPurchaseResultFragment
20
- }
21
- }
22
-
23
- ${platformProductPurchaseResultFragment}
24
- `;
25
-
26
- export const cancelPlatformSubscriptionMtn = gql`
27
- mutation cancelPlatformSubscription {
28
- cancelPlatformSubscription {
29
- ...platformProductPurchaseResultFragment
30
- }
31
- }
32
-
33
- ${platformProductPurchaseResultFragment}
34
- `;
@@ -1,70 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
- import { accountFragment } from '../fragments/accountFragments';
3
- import { organizationComplianceFragment, organizationFragment } from '../fragments/organizationFragments';
4
- import { productAttendanceFragment, productCalEventFragment, productFragment, productLivestockFragment } from '../fragments/productFragments';
5
-
6
- export const productsListQry = gql`
7
- query productsList (
8
- $organizationId: GenericID!
9
- $filter: ProductsFilter!
10
- $cursor: Cursor
11
- $after: Boolean!
12
- $limit: Int!
13
- ) {
14
- productsList (
15
- organizationId: $organizationId
16
- filter: $filter
17
- cursor: $cursor
18
- after: $after
19
- limit: $limit
20
- ) {
21
- ...productFragment
22
-
23
- details {
24
- ...on ProductCalEvent {
25
- ...productCalEventFragment
26
- }
27
- ...on ProductLivestock {
28
- ...productLivestockFragment
29
- }
30
- }
31
- }
32
- }
33
-
34
- ${productFragment}
35
- ${productCalEventFragment}
36
- ${productLivestockFragment}
37
- `;
38
-
39
- export const productAttendanceListQry = gql`
40
- query productAttendanceList (
41
- $productId: GenericID!
42
- $organizationId: GenericID!
43
- $calDate: CalDateString!
44
- ) {
45
- productAttendanceList (
46
- productId: $productId
47
- organizationId: $organizationId
48
- calDate: $calDate
49
- ) {
50
- ...productAttendanceFragment
51
-
52
- organization {
53
- ...organizationFragment
54
-
55
- compliance {
56
- ...organizationComplianceFragment
57
- }
58
- }
59
-
60
- checkedBy {
61
- ...accountFragment
62
- }
63
- }
64
- }
65
-
66
- ${productAttendanceFragment}
67
- ${organizationFragment}
68
- ${organizationComplianceFragment}
69
- ${accountFragment}
70
- `;
@@ -1,66 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
- import { reportColumnDataFragment, reportFragment, reportAvailabilityFragment, reportRowDataFragment, reportSectionFragment } from '../fragments/reportFragments';
3
- import { storageFileFragment } from '../fragments/storageFragments';
4
-
5
- export const reportsQry = gql`
6
- query reports (
7
- $organizationId: GenericID!
8
- $filter: ReportsFilter!
9
- $sort: ReportsSort
10
- ) {
11
- reports (
12
- organizationId: $organizationId
13
- filter: $filter
14
- sort: $sort
15
- ) {
16
- ...reportFragment
17
-
18
- sections {
19
- ...reportSectionFragment
20
-
21
- files {
22
- ...storageFileFragment
23
- }
24
-
25
- rows {
26
- ...reportRowDataFragment
27
-
28
- columns {
29
- ...reportColumnDataFragment
30
- }
31
- }
32
- }
33
-
34
- # This needs to be deprecated and merged to sections
35
- # Its only used for cleaning logs right now
36
-
37
- rows {
38
- ...reportRowDataFragment
39
-
40
- columns {
41
- ...reportColumnDataFragment
42
- }
43
- }
44
- }
45
- }
46
-
47
- ${reportFragment}
48
- ${reportSectionFragment}
49
- ${storageFileFragment}
50
- ${reportRowDataFragment}
51
- ${reportColumnDataFragment}
52
- `;
53
-
54
- export const availableReportsQry = gql`
55
- query availableReports (
56
- $organizationId: GenericID!
57
- ) {
58
- availableReports (
59
- organizationId: $organizationId
60
- ) {
61
- ...reportAvailabilityFragment
62
- }
63
- }
64
-
65
- ${reportAvailabilityFragment}
66
- `;
@@ -1,109 +0,0 @@
1
- import { checkACLPermission } from '@jsb188/mday/utils/organization';
2
- import type { ProductsFilterArgs } from '@jsb188/mday/types/product.d';
3
- import { useMemo } from 'react';
4
- import { useQuery, useReactiveFragment } from '../client';
5
- import { productAttendanceListQry, productsListQry } from '../gql/queries/productQueries';
6
- import type { PaginationArgs, UseQueryParams } from '../types';
7
- import { useOrgRelFromMyOrganizations } from './use-organization-qry';
8
-
9
- /**
10
- * Constants
11
- */
12
-
13
- const PRODUCTS_LIST_LIMIT = 200;
14
-
15
- /**
16
- * Helper; use this to get/use same filter for productsList() query everywhere
17
- */
18
-
19
- // export function getDefaultProductsListFilter(operation: FilterProductsListArgs['operation']): FilterProductsListArgs {
20
- // return {
21
- // operation,
22
- // types: null,
23
- // startDate: null,
24
- // endDate: null,
25
- // query: ''
26
- // };
27
- // }
28
-
29
- /**
30
- * Fetch log entries
31
- */
32
-
33
- export function useProductsList(
34
- variables: PaginationArgs & {
35
- organizationId?: string | null;
36
- filter: ProductsFilterArgs;
37
- },
38
- params: UseQueryParams = {}
39
- ) {
40
- const { data, ...rest } = useQuery(productsListQry, {
41
- variables: {
42
- ...variables,
43
- cursor: null,
44
- after: false,
45
- limit: PRODUCTS_LIST_LIMIT
46
- },
47
- // If this query is used for virtualized list pagination, set {params.skip=true}
48
- skip: !variables.organizationId,
49
- ...params,
50
- });
51
-
52
- return {
53
- productsList: data?.productsList,
54
- ...rest
55
- };
56
- }
57
-
58
- /**
59
- * Get reactive log fragment
60
- */
61
-
62
- export function useReactiveProductFragment(productId: string, currentData?: any, queryCount?: number) {
63
- return useReactiveFragment(
64
- currentData,
65
- [
66
- `$productFragment:${productId}`,
67
- ],
68
- queryCount,
69
- );
70
- }
71
-
72
- /**
73
- * Fetch Org Event attendance, ACL, and Org Event fragment from cache
74
- */
75
-
76
- export function useProductAttendance(
77
- variables: {
78
- organizationId: string;
79
- productId: string;
80
- calDate: string;
81
- },
82
- params: UseQueryParams = {},
83
- ) {
84
-
85
- const { organizationId, productId, calDate } = variables;
86
- const { organizationRelationship } = useOrgRelFromMyOrganizations(organizationId);
87
-
88
- const { data, ...rest } = useQuery(productAttendanceListQry, {
89
- variables,
90
- skip: !productId || !calDate || !organizationId,
91
- ...params,
92
- });
93
-
94
- const productAttendanceList = data?.productAttendanceList;
95
- const notReady = !organizationRelationship || !productAttendanceList;
96
-
97
- const allowEdit = useMemo(() => {
98
- return checkACLPermission(organizationRelationship, 'products', 'MANAGE');
99
- }, [organizationRelationship?.acl, organizationRelationship?.role]);
100
-
101
- // console.log('viewerAccountId', viewerAccountId, organizationEvent?.accountId, isMyDocument, allowEdit);
102
-
103
- return {
104
- productAttendanceList,
105
- notReady,
106
- allowEdit,
107
- ...rest
108
- };
109
- }
@@ -1,69 +0,0 @@
1
- import type { ReportsFilterArgs, ReportsSortEnum } from '@jsb188/mday/types/report.d';
2
- import { useQuery, useReactiveFragment } from '../client';
3
- import { availableReportsQry, reportsQry } from '../gql/queries/reportQueries';
4
- import type { UseQueryParams } from '../types';
5
-
6
- /**
7
- * Get reactive report fragment
8
- */
9
-
10
- export function useReactiveReportFragment(reportId: string, currentData?: any, queryCount?: number) {
11
- return useReactiveFragment(
12
- currentData,
13
- [
14
- `$reportFragment:${reportId}`,
15
- ],
16
- queryCount,
17
- );
18
- }
19
-
20
- /**
21
- * Fetch list of reports by type and period
22
- */
23
-
24
- export function useReports(
25
- variables: {
26
- organizationId: string;
27
- filter: ReportsFilterArgs;
28
- sort?: ReportsSortEnum;
29
- },
30
- params: UseQueryParams = {},
31
- ) {
32
-
33
- const { organizationId, filter } = variables;
34
- const { skip, ...restParams } = params;
35
- const { data, ...rest } = useQuery(reportsQry, {
36
- variables,
37
- skip: skip || !organizationId || !filter,
38
- ...restParams,
39
- });
40
-
41
- return {
42
- reports: data?.reports,
43
- ...rest
44
- };
45
- }
46
-
47
- /**
48
- * Fetch list of available reports statuses
49
- */
50
-
51
- export function useAvailableReports(
52
- organizationId: string | null,
53
- params: UseQueryParams = {},
54
- ) {
55
-
56
- const { skip, ...restParams } = params;
57
- const { data, ...rest } = useQuery(availableReportsQry, {
58
- variables: {
59
- organizationId,
60
- },
61
- skip: skip || !organizationId,
62
- ...restParams,
63
- });
64
-
65
- return {
66
- availableReports: data?.availableReports,
67
- ...rest
68
- };
69
- }