@jsb188/mday 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 (123) hide show
  1. package/package.json +105 -35
  2. package/src/constants/agentDoc.ts +12 -0
  3. package/src/constants/agentMemory.ts +154 -0
  4. package/src/constants/aiChat.ts +5 -0
  5. package/src/constants/campaign.ts +127 -0
  6. package/src/constants/dataTable.ts +48 -0
  7. package/src/constants/dataTableFieldTypes.generated.ts +63 -0
  8. package/src/constants/docAccess.ts +32 -0
  9. package/src/constants/email.ts +44 -0
  10. package/src/constants/fieldDoc.ts +34 -0
  11. package/src/constants/graphqlReactivity.ts +113 -0
  12. package/src/constants/inboundContact.ts +8 -0
  13. package/src/constants/integration.ts +13 -0
  14. package/src/constants/log.ts +7 -366
  15. package/src/constants/logActivityGroupColors.generated.ts +19 -0
  16. package/src/constants/logTaxonomy.generated.ts +1103 -0
  17. package/src/constants/noteDoc.ts +77 -0
  18. package/src/constants/organization.ts +18 -11
  19. package/src/constants/pageRoute.ts +23 -0
  20. package/src/constants/schedule.ts +220 -0
  21. package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
  22. package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
  23. package/src/constants/sheet.ts +168 -0
  24. package/src/constants/sheetRegionSources.generated.ts +578 -0
  25. package/src/constants/square.ts +16 -0
  26. package/src/constants/storage.ts +61 -0
  27. package/src/constants/usage.ts +79 -0
  28. package/src/schemas/editLogEntry.ts +1017 -738
  29. package/src/schemas/fieldDocsQuery.ts +12 -0
  30. package/src/schemas/inboundContact.ts +77 -0
  31. package/src/schemas/logsQuery.ts +57 -316
  32. package/src/schemas/organization.ts +53 -213
  33. package/src/types/account.d.ts +81 -0
  34. package/src/types/agentDoc.d.ts +64 -0
  35. package/src/types/agentMemory.d.ts +74 -0
  36. package/src/types/campaign.d.ts +683 -0
  37. package/src/types/dataTable.d.ts +366 -0
  38. package/src/types/docAccess.d.ts +96 -0
  39. package/src/types/email.d.ts +142 -0
  40. package/src/types/fieldDoc.d.ts +273 -0
  41. package/src/types/inboundContact.d.ts +57 -0
  42. package/src/types/integration.d.ts +42 -0
  43. package/src/types/log.d.ts +169 -190
  44. package/src/types/noteDoc.d.ts +86 -0
  45. package/src/types/organization.d.ts +175 -76
  46. package/src/types/pageRoute.d.ts +48 -0
  47. package/src/types/schedule.d.ts +391 -0
  48. package/src/types/sheet.d.ts +1130 -0
  49. package/src/types/storage.d.ts +242 -0
  50. package/src/types/usage.d.ts +106 -0
  51. package/src/types/workflow.d.ts +305 -0
  52. package/src/utils/agentDoc.ts +109 -0
  53. package/src/utils/aiChat.ts +26 -0
  54. package/src/utils/campaign.ts +741 -0
  55. package/src/utils/campaignFormEditor.ts +871 -0
  56. package/src/utils/dataTable.ts +849 -0
  57. package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
  58. package/src/utils/dataTableRealtimeAuthority.ts +209 -0
  59. package/src/utils/dataTableRealtimeSelection.ts +134 -0
  60. package/src/utils/dataTableRowDocument.ts +508 -0
  61. package/src/utils/dataTableSource.ts +230 -0
  62. package/src/utils/docAccess.ts +383 -0
  63. package/src/utils/documentName.ts +53 -0
  64. package/src/utils/email.ts +172 -0
  65. package/src/utils/fieldDoc.ts +113 -0
  66. package/src/utils/log.ts +173 -778
  67. package/src/utils/logRegistryValue.ts +90 -0
  68. package/src/utils/logStoreRead.ts +266 -0
  69. package/src/utils/logTaxonomy.ts +76 -0
  70. package/src/utils/logTaxonomyDisplay.ts +439 -0
  71. package/src/utils/noteDoc.ts +827 -0
  72. package/src/utils/organization.ts +683 -81
  73. package/src/utils/pageRoute.ts +71 -0
  74. package/src/utils/schedule.ts +799 -0
  75. package/src/utils/scheduleEvaluation.ts +1994 -0
  76. package/src/utils/scheduleICS.ts +246 -0
  77. package/src/utils/scheduleRuleTemplates.ts +188 -0
  78. package/src/utils/sheet.ts +4973 -0
  79. package/src/utils/sheetAxisMove.ts +830 -0
  80. package/src/utils/sheetBootstrap.ts +1769 -0
  81. package/src/utils/sheetCommand.ts +423 -0
  82. package/src/utils/sheetExport.ts +238 -0
  83. package/src/utils/sheetFormulaEvaluation.ts +914 -0
  84. package/src/utils/sheetFormulaEvaluator.ts +852 -0
  85. package/src/utils/sheetJournal.ts +78 -0
  86. package/src/utils/sheetNumberFormat.ts +1211 -0
  87. package/src/utils/sheetRegion.ts +374 -0
  88. package/src/utils/sheetRegionFilter.ts +1259 -0
  89. package/src/utils/sheetRegionSourceRegistry.ts +594 -0
  90. package/src/utils/sheetSequence.ts +148 -0
  91. package/src/utils/sheetSnapshot.ts +992 -0
  92. package/src/utils/sheetStructureEdit.ts +1284 -0
  93. package/src/utils/square.ts +32 -0
  94. package/src/utils/storage.ts +152 -0
  95. package/src/utils/table-route.ts +262 -0
  96. package/src/utils/workflow.ts +380 -0
  97. package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
  98. package/tests/docAccess.test.ts +525 -0
  99. package/tests/editLogEntry.test.ts +112 -0
  100. package/tests/noteDoc.test.ts +669 -0
  101. package/tests/schedule.test.ts +693 -0
  102. package/tests/scheduleEvaluation.test.ts +1970 -0
  103. package/tests/scheduleICS.test.ts +208 -0
  104. package/tests/scheduleRuleTemplates.test.ts +176 -0
  105. package/tests/scheduleSweepInvariants.test.ts +428 -0
  106. package/tests/sheetAxisMove.test.ts +343 -0
  107. package/tests/sheetFormulaEvaluator.test.ts +575 -0
  108. package/tests/sheetRegionFilter.test.ts +1135 -0
  109. package/tests/sheetSequence.test.ts +41 -0
  110. package/tests/sheetStructureEdit.test.ts +82 -0
  111. package/tsconfig.json +12 -0
  112. package/vitest.config.ts +8 -0
  113. package/src/constants/log-activityTexts.ts +0 -209
  114. package/src/constants/product.ts +0 -66
  115. package/src/constants/report.ts +0 -25
  116. package/src/schemas/childOrganizationsQuery.ts +0 -44
  117. package/src/schemas/productsQuery.ts +0 -145
  118. package/src/schemas/reportsQuery.ts +0 -107
  119. package/src/types/action.d.ts +0 -42
  120. package/src/types/product.d.ts +0 -173
  121. package/src/types/report.d.ts +0 -203
  122. package/src/utils/product-calEvent.ts +0 -508
  123. package/src/utils/route-helpers.ts +0 -583
@@ -0,0 +1,109 @@
1
+ import { AGENT_DOC_SURFACE_ENUMS } from '../constants/agentDoc.ts';
2
+ import type {
3
+ AgentDocSettingsObj,
4
+ AgentDocSurfaceEnum,
5
+ } from '../types/agentDoc.d.ts';
6
+
7
+ /**
8
+ * Check whether one value is a valid agent doc surface.
9
+ */
10
+
11
+ export function isValidAgentDocSurface(
12
+ value: unknown,
13
+ ): value is AgentDocSurfaceEnum {
14
+ return AGENT_DOC_SURFACE_ENUMS.includes(value as AgentDocSurfaceEnum);
15
+ }
16
+
17
+ /**
18
+ * Sanitize one agent doc settings object into the closed vocabulary stored
19
+ * in the agent_docs "settings" JSONB. Unknown keys are dropped, booleans are
20
+ * coerced strictly (only literal true is kept, so absent and false collapse
21
+ * to the same default), surfaces are validated and deduplicated, and
22
+ * "reviewBy" must be a parseable date string.
23
+ */
24
+
25
+ export function sanitizeAgentDocSettings(
26
+ settings?: Partial<AgentDocSettingsObj> | null,
27
+ ): AgentDocSettingsObj {
28
+ const sanitized: AgentDocSettingsObj = {};
29
+
30
+ if (settings?.aiCannotEdit === true) {
31
+ sanitized.aiCannotEdit = true;
32
+ }
33
+
34
+ if (settings?.aiCannotRead === true) {
35
+ sanitized.aiCannotRead = true;
36
+ }
37
+
38
+ if (settings?.pinned === true) {
39
+ sanitized.pinned = true;
40
+ }
41
+
42
+ if (Array.isArray(settings?.hiddenSurfaces)) {
43
+ const surfaces = [
44
+ ...new Set(settings.hiddenSurfaces.filter(isValidAgentDocSurface)),
45
+ ];
46
+ if (surfaces.length) {
47
+ sanitized.hiddenSurfaces = surfaces;
48
+ }
49
+ }
50
+
51
+ if (
52
+ typeof settings?.reviewBy === 'string' &&
53
+ settings.reviewBy &&
54
+ !isNaN(Date.parse(settings.reviewBy))
55
+ ) {
56
+ sanitized.reviewBy = settings.reviewBy;
57
+ }
58
+
59
+ return sanitized;
60
+ }
61
+
62
+ /**
63
+ * Check whether agents on one surface may read one agent doc.
64
+ */
65
+
66
+ export function isAgentDocReadableBySurface(
67
+ settings: AgentDocSettingsObj | null | undefined,
68
+ surface: AgentDocSurfaceEnum,
69
+ ): boolean {
70
+ if (settings?.aiCannotRead) {
71
+ return false;
72
+ }
73
+ return !settings?.hiddenSurfaces?.includes(surface);
74
+ }
75
+
76
+ /**
77
+ * Check whether agents on one surface may modify one agent doc. An
78
+ * unreadable document is never writable.
79
+ */
80
+
81
+ export function isAgentDocWritableByAgent(
82
+ settings: AgentDocSettingsObj | null | undefined,
83
+ surface: AgentDocSurfaceEnum,
84
+ ): boolean {
85
+ if (settings?.aiCannotEdit) {
86
+ return false;
87
+ }
88
+ return isAgentDocReadableBySurface(settings, surface);
89
+ }
90
+
91
+ /**
92
+ * Check whether one agent doc is past its review date. Stale documents stay
93
+ * readable; agent tools annotate them so the model verifies with a human
94
+ * instead of silently trusting outdated rules.
95
+ */
96
+
97
+ export function isAgentDocStale(
98
+ settings: AgentDocSettingsObj | null | undefined,
99
+ now: Date | number = Date.now(),
100
+ ): boolean {
101
+ if (!settings?.reviewBy) {
102
+ return false;
103
+ }
104
+ const reviewBy = Date.parse(settings.reviewBy);
105
+ return (
106
+ !isNaN(reviewBy) &&
107
+ reviewBy < (typeof now === 'number' ? now : now.getTime())
108
+ );
109
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Return whether an incoming automatic chat fragment predates the current
3
+ * user-managed summary. User-managed summaries are terminal, so a fragment
4
+ * reporting the automatic state can never be newer once this flag is true.
5
+ */
6
+ export function isStaleAutomaticAIChatFragment(
7
+ currentData: unknown,
8
+ nextData: unknown,
9
+ ) {
10
+ if (
11
+ !currentData ||
12
+ typeof currentData !== 'object' ||
13
+ !nextData ||
14
+ typeof nextData !== 'object'
15
+ ) {
16
+ return false;
17
+ }
18
+
19
+ const currentAIChat = currentData as Record<string, unknown>;
20
+ const nextAIChat = nextData as Record<string, unknown>;
21
+
22
+ return (
23
+ currentAIChat.userManagedSummary === true &&
24
+ nextAIChat.userManagedSummary === false
25
+ );
26
+ }