@jsb188/graphql 1.1.10 → 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 (116) hide show
  1. package/cache/config.ts +64 -50
  2. package/cache/index.test.ts +671 -109
  3. package/cache/index.ts +1700 -1240
  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 +2 -0
  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 +954 -163
  16. package/client/sse-ticket.test.ts +26 -0
  17. package/deno.lock +170 -0
  18. package/deno.test.json +8 -4
  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 +0 -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 +16 -0
  28. package/gql/fragments/billingFragments.ts +0 -11
  29. package/gql/fragments/campaignFragments.ts +277 -0
  30. package/gql/fragments/dataTableFragments.ts +18 -128
  31. package/gql/fragments/emailFragments.ts +19 -9
  32. package/gql/fragments/fieldDocFragments.ts +82 -0
  33. package/gql/fragments/logFragments.ts +20 -79
  34. package/gql/fragments/organizationFragments.ts +43 -5
  35. package/gql/fragments/scheduleFragments.ts +155 -0
  36. package/gql/fragments/sheetFragments.ts +552 -22
  37. package/gql/fragments/storageFragments.ts +21 -0
  38. package/gql/fragments/workflowFragments.ts +28 -4
  39. package/gql/mutations/accountMutations.ts +0 -2
  40. package/gql/mutations/agentDocMutations.ts +177 -0
  41. package/gql/mutations/agentMemoryMutations.ts +36 -0
  42. package/gql/mutations/aiChatMutations.ts +17 -4
  43. package/gql/mutations/authMutations.ts +158 -17
  44. package/gql/mutations/campaignMutations.ts +215 -0
  45. package/gql/mutations/dataTableMutations.ts +48 -26
  46. package/gql/mutations/fieldDocMutations.ts +24 -0
  47. package/gql/mutations/index.ts +6 -1
  48. package/gql/mutations/logMutations.ts +6 -29
  49. package/gql/mutations/organizationMutations.ts +13 -4
  50. package/gql/mutations/scheduleMutations.ts +423 -0
  51. package/gql/mutations/sheetMutations.ts +273 -56
  52. package/gql/mutations/storageMutations.ts +20 -0
  53. package/gql/mutations/workflowMutations.ts +42 -0
  54. package/gql/queries/agentDocQueries.ts +120 -0
  55. package/gql/queries/agentMemoryQueries.ts +22 -0
  56. package/gql/queries/aiChatQueries.ts +18 -2
  57. package/gql/queries/authQueries.ts +41 -0
  58. package/gql/queries/billingQueries.ts +23 -0
  59. package/gql/queries/campaignQueries.ts +127 -0
  60. package/gql/queries/dataTableQueries.ts +100 -11
  61. package/gql/queries/emailQueries.ts +55 -3
  62. package/gql/queries/fieldDocQueries.ts +158 -0
  63. package/gql/queries/index.ts +8 -2
  64. package/gql/queries/logQueries.ts +11 -28
  65. package/gql/queries/organizationQueries.ts +52 -1
  66. package/gql/queries/scheduleQueries.ts +315 -0
  67. package/gql/queries/sheetQueries.ts +336 -25
  68. package/gql/queries/storageQueries.ts +38 -0
  69. package/gql/queries/workflowQueries.ts +72 -3
  70. package/hooks/index.ts +2065 -971
  71. package/hooks/use-account-mtn.ts +76 -81
  72. package/hooks/use-agentDoc-mtn.ts +285 -0
  73. package/hooks/use-agentDoc-qry.ts +208 -0
  74. package/hooks/use-agentMemory-mtn.ts +73 -0
  75. package/hooks/use-agentMemory-qry.ts +44 -0
  76. package/hooks/use-aiChat-mtn.ts +232 -137
  77. package/hooks/use-aiChat-qry.ts +480 -222
  78. package/hooks/use-app-qry.ts +12 -9
  79. package/hooks/use-auth-mtn.ts +406 -252
  80. package/hooks/use-auth-qry.ts +51 -0
  81. package/hooks/use-campaign-mtn.ts +377 -0
  82. package/hooks/use-campaign-qry.ts +257 -0
  83. package/hooks/use-dataTable-mtn.ts +116 -33
  84. package/hooks/use-dataTable-qry.ts +859 -35
  85. package/hooks/use-email-qry.ts +194 -79
  86. package/hooks/use-fieldDoc-mtn.ts +50 -0
  87. package/hooks/use-fieldDoc-qry.ts +180 -0
  88. package/hooks/use-inboundContact-mtn.ts +19 -16
  89. package/hooks/use-inboundContact-qry.ts +63 -55
  90. package/hooks/use-integration-mtn.ts +56 -38
  91. package/hooks/use-integration-qry.ts +24 -9
  92. package/hooks/use-log-mtn.ts +72 -56
  93. package/hooks/use-log-qry.ts +93 -69
  94. package/hooks/use-organization-mtn.ts +334 -277
  95. package/hooks/use-organization-qry.ts +199 -129
  96. package/hooks/use-schedule-mtn.ts +416 -0
  97. package/hooks/use-schedule-qry.ts +157 -0
  98. package/hooks/use-sheet-mtn.ts +233 -47
  99. package/hooks/use-sheet-qry.ts +353 -70
  100. package/hooks/use-storage-mtn.ts +81 -41
  101. package/hooks/use-storage-qry.ts +104 -13
  102. package/hooks/use-workflow-mtn.ts +55 -0
  103. package/hooks/use-workflow-qry.ts +206 -48
  104. package/loaders/campaign.ts +137 -0
  105. package/package.json +94 -71
  106. package/sse.ts +157 -104
  107. package/tsconfig.json +11 -10
  108. package/types.d.ts +60 -30
  109. package/utils.ts +78 -49
  110. package/gql/fragments/productFragments.ts +0 -39
  111. package/gql/fragments/reportFragments.ts +0 -90
  112. package/gql/mutations/billingMutations.ts +0 -34
  113. package/gql/queries/productQueries.ts +0 -31
  114. package/gql/queries/reportQueries.ts +0 -134
  115. package/hooks/use-product-qry.ts +0 -67
  116. package/hooks/use-report-qry.ts +0 -153
package/cache/config.ts CHANGED
@@ -1,68 +1,82 @@
1
+ import {
2
+ FRAGMENT_NAMES,
3
+ getFragmentBaseName,
4
+ } from '@jsb188/mday/constants/graphqlReactivity.ts';
1
5
 
2
6
  /**
3
7
  * Rules for GraphQL server that's hard-coded to this package
4
8
  * NOTE: Allow config setup for this later
5
9
  */
6
10
 
11
+ /**
12
+ * Version of the persisted cache record layout. Bump when the shape of what
13
+ * the cache stores changes incompatibly; a mismatch wipes the IndexedDB
14
+ * snapshot on boot. (Stale-but-compatible data self-heals at read time via
15
+ * fetchCachedData's selection completeness check.)
16
+ */
17
+
18
+ export const CACHE_SCHEMA_VERSION = 5;
19
+
7
20
  export const QUERY_EXPIRE_TIMES = {
8
- __default: 5.4e+6, // 1.5 hours
9
- // 6.48e+7, // 18 hours
21
+ __default: 1.08e7, // 3 hours
22
+ // 5.4e+6, // 1.5 hours
23
+ // 2.88e+7, // 8 hours
24
+ // 6.48e+7, // 18 hours
25
+
26
+ // Sheets
27
+ sheets: 1.08e7,
28
+ sheetAccess: 2.88e7,
29
+ sheetRegionSourcePreviewRows: 2.88e7,
30
+ sheetAccessGrants: 2.88e7,
31
+ openSheet: 2.88e7,
32
+ openSheetTab: 2.88e7,
33
+ sheetTabChanges: 2.88e7,
34
+ sheetOperationalHistory: 2.88e7,
35
+
36
+ // Data tables
37
+ dataTables: 1.08e7,
38
+ dataTable: 2.88e7,
39
+ dataTableMetadata: 2.88e7,
40
+ dataTableRowsSnapshot: 2.88e7,
41
+ dataTableChanges: 2.88e7,
10
42
  } as {
11
- [key: string]: number;
43
+ [key: string]: number;
12
44
  };
13
45
 
14
46
  export const RULES = {
15
- // __limit: 8000, // 8000: approximately 5.15 MB; calculated at 644.666666668 bytes for 30 objects
16
- __limit: 100000, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
17
- // __limit: 50, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
47
+ // __limit: 8000, // 8000: approximately 5.15 MB; calculated at 644.666666668 bytes for 30 objects
48
+ __limit: 100000, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
49
+ // __limit: 50, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
18
50
 
19
- // List of queries that should be cached
20
- // NOTE: Fragments are always cached
21
- aiChat: true,
22
- aiChats: true,
23
- aiChatMessages: true,
24
- alerts: true,
25
- chat: true,
26
- chatsList: true,
27
- childOrganizations: true,
28
- eventsList: true,
29
- eventAttendanceList: true,
30
- integrationConnection: true,
31
- parentOrganization: true,
32
- logEntry: true,
33
- logEntries: true,
34
- logEntriesForReport: true,
35
- myChats: true,
36
- myOrganizations: true,
37
- organizationMembers: true,
38
- organizationRelationship: true,
39
- organizationSites: true,
40
- platformProducts: true,
41
- productsList: true,
42
- report: true,
43
- reportGroups: true,
44
- reports: true,
45
- reportSubmissions: true,
46
- dataTables: true,
47
- dataTableRows: true,
48
- sheets: true,
49
- sheet: true,
50
- sheetGrid: true,
51
- searchUsers: true,
52
- updateNote: true,
53
- userIdToChatId: true,
54
- workflows: true,
51
+ // NOTE: ALL fragments are cached by default,
52
+ // but if you want to skip some, add it here
53
+ accountAuthFragment: false,
55
54
 
56
- // All fragments are cached,
57
- // but if you want to skip some, add it here
58
- accountAuthFragment: false,
55
+ // NOTE: ALL queries are cached by default,
56
+ // but if you want to skip some, add it here
57
+ // e.g.: someQueryName: false,
58
+
59
+ // Respondent identity travels via header/cookie (not query variables), so
60
+ // the cache key cannot distinguish viewers; never cache per-viewer results
59
61
  } as {
60
- __limit: number;
61
- [key: string]: boolean | number;
62
+ __limit: number;
63
+ [key: string]: boolean | number;
62
64
  };
63
65
 
64
66
  export const PARTIALS_MAP = {
65
- // Partial fragments are supported if you map them to its original fragment name
66
- chatPartial: 'chatFragment',
67
- chatStatusPartial: 'chatFragment',
67
+ // Partial fragments are supported if you map them to its original fragment name
68
+ dataTablePartialFragment: getFragmentBaseName(FRAGMENT_NAMES.dataTable),
69
+ sheetViewPatchFragment: getFragmentBaseName(FRAGMENT_NAMES.sheetView),
70
+ // List rows are a narrower projection of the same record. Without these the
71
+ // server's $campaignTemplateFragment / $campaignFragment patches would only
72
+ // reach a detail view, and a GENERATING card in a list would never settle to
73
+ // ACTIVE.
74
+ campaignTemplateSummaryFragment: getFragmentBaseName(
75
+ FRAGMENT_NAMES.campaignTemplate,
76
+ ),
77
+ campaignSummaryFragment: getFragmentBaseName(FRAGMENT_NAMES.campaign),
68
78
  } as Record<string, string>;
79
+
80
+ export const PARTIAL_NULL_PRESERVE_FIELDS = {
81
+ sheetViewPatchFragment: ['ranges', 'sheetTab'],
82
+ } as Record<string, string[]>;