@jsb188/mday 1.1.2

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 (202) hide show
  1. package/package.json +142 -0
  2. package/src/constants/agentMemory.ts +166 -0
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +10 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +236 -0
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +22 -0
  10. package/src/constants/dataTableFieldTypes.generated.ts +59 -0
  11. package/src/constants/docAccess.ts +33 -0
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +146 -0
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/inboundContact.ts +8 -0
  17. package/src/constants/integration.ts +13 -0
  18. package/src/constants/log.ts +21 -0
  19. package/src/constants/logDisplay/README.md +88 -0
  20. package/src/constants/logDisplay/defaults.ts +39 -0
  21. package/src/constants/logDisplay/index.ts +27 -0
  22. package/src/constants/logDisplay/operations/arable.ts +16 -0
  23. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  24. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  25. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  26. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  27. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  28. package/src/constants/logTaxonomy.generated.ts +2199 -0
  29. package/src/constants/noteDoc.ts +77 -0
  30. package/src/constants/organization.ts +60 -0
  31. package/src/constants/pageRoute.ts +23 -0
  32. package/src/constants/qrCode.ts +30 -0
  33. package/src/constants/sheet.ts +132 -0
  34. package/src/constants/sms.ts +18 -0
  35. package/src/constants/square.ts +16 -0
  36. package/src/constants/storage.ts +85 -0
  37. package/src/constants/usage.ts +82 -0
  38. package/src/constants/workflowSteps.ts +60 -0
  39. package/src/schemas/editLogEntry.ts +879 -0
  40. package/src/schemas/inboundContact.ts +77 -0
  41. package/src/schemas/logsQuery.ts +93 -0
  42. package/src/types/account.d.ts +81 -0
  43. package/src/types/agentMemory.d.ts +100 -0
  44. package/src/types/agentNote.d.ts +441 -0
  45. package/src/types/billing.d.ts +537 -0
  46. package/src/types/campaign.d.ts +1533 -0
  47. package/src/types/contact.d.ts +15 -0
  48. package/src/types/csvExport.d.ts +213 -0
  49. package/src/types/dataAnalysis.d.ts +44 -0
  50. package/src/types/dataTable.d.ts +159 -0
  51. package/src/types/definitionElement.d.ts +35 -0
  52. package/src/types/docAccess.d.ts +96 -0
  53. package/src/types/dt.d.ts +257 -0
  54. package/src/types/email.d.ts +231 -0
  55. package/src/types/emailReplyReport.d.ts +76 -0
  56. package/src/types/fieldDoc.d.ts +702 -0
  57. package/src/types/fieldDocContract.d.ts +90 -0
  58. package/src/types/inboundContact.d.ts +65 -0
  59. package/src/types/integration.d.ts +42 -0
  60. package/src/types/log.d.ts +338 -0
  61. package/src/types/logDisplay.types.ts +85 -0
  62. package/src/types/organization.d.ts +350 -0
  63. package/src/types/pageRoute.d.ts +48 -0
  64. package/src/types/qrCode.d.ts +96 -0
  65. package/src/types/richText.d.ts +81 -0
  66. package/src/types/sheet.d.ts +847 -0
  67. package/src/types/sms.d.ts +38 -0
  68. package/src/types/storage.d.ts +481 -0
  69. package/src/types/usage.d.ts +106 -0
  70. package/src/types/workflow.d.ts +435 -0
  71. package/src/utils/agentMemory.ts +15 -0
  72. package/src/utils/agentNote.ts +850 -0
  73. package/src/utils/aiChat.ts +43 -0
  74. package/src/utils/aiChatWork.ts +64 -0
  75. package/src/utils/billing.ts +37 -0
  76. package/src/utils/campaign.ts +1173 -0
  77. package/src/utils/campaignAI.ts +72 -0
  78. package/src/utils/campaignAccess.ts +239 -0
  79. package/src/utils/campaignEmail.ts +601 -0
  80. package/src/utils/campaignEmailCompiler.ts +372 -0
  81. package/src/utils/campaignEmailImages.ts +60 -0
  82. package/src/utils/campaignEmailStyles.ts +544 -0
  83. package/src/utils/campaignLifecycle.ts +104 -0
  84. package/src/utils/campaignPreview.ts +285 -0
  85. package/src/utils/contact.ts +50 -0
  86. package/src/utils/csvExport.ts +19 -0
  87. package/src/utils/dataTable.ts +311 -0
  88. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  89. package/src/utils/dataTableRelativeDate.ts +447 -0
  90. package/src/utils/definitionElement.ts +84 -0
  91. package/src/utils/docAccess.ts +383 -0
  92. package/src/utils/documentName.ts +53 -0
  93. package/src/utils/email.ts +379 -0
  94. package/src/utils/emailReplyReport.test.ts +187 -0
  95. package/src/utils/emailReplyReport.ts +143 -0
  96. package/src/utils/fieldDoc.ts +157 -0
  97. package/src/utils/fieldDocAnswers.ts +128 -0
  98. package/src/utils/fieldDocDefaults.ts +36 -0
  99. package/src/utils/fieldDocProgram.ts +36 -0
  100. package/src/utils/fieldDocSummary.ts +30 -0
  101. package/src/utils/log.ts +357 -0
  102. package/src/utils/logDisplay.helpers.ts +177 -0
  103. package/src/utils/logDisplay.ts +87 -0
  104. package/src/utils/logRegistryValue.ts +90 -0
  105. package/src/utils/logStoreRead.ts +262 -0
  106. package/src/utils/logTaxonomy.helpers.ts +17 -0
  107. package/src/utils/logTaxonomy.ts +76 -0
  108. package/src/utils/logTaxonomyDisplay.ts +395 -0
  109. package/src/utils/noteDoc.ts +609 -0
  110. package/src/utils/organization.ts +669 -0
  111. package/src/utils/pageRoute.ts +71 -0
  112. package/src/utils/qrCode.helpers.ts +189 -0
  113. package/src/utils/qrCode.test.ts +519 -0
  114. package/src/utils/qrCode.ts +273 -0
  115. package/src/utils/richTextHTML.ts +385 -0
  116. package/src/utils/sheet.ts +262 -0
  117. package/src/utils/sheetAxisMove.ts +616 -0
  118. package/src/utils/sheetBootstrap.ts +1402 -0
  119. package/src/utils/sheetCellLiteral.ts +101 -0
  120. package/src/utils/sheetCommand.ts +358 -0
  121. package/src/utils/sheetDesign.ts +705 -0
  122. package/src/utils/sheetExport.ts +186 -0
  123. package/src/utils/sheetFeatureReference.ts +183 -0
  124. package/src/utils/sheetFormulaArgs.ts +168 -0
  125. package/src/utils/sheetFormulaCompile.ts +475 -0
  126. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  127. package/src/utils/sheetFormulaCriteria.ts +656 -0
  128. package/src/utils/sheetFormulaDate.ts +444 -0
  129. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  130. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  131. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  132. package/src/utils/sheetFormulaLogical.ts +116 -0
  133. package/src/utils/sheetFormulaLookup.ts +488 -0
  134. package/src/utils/sheetFormulaMath.ts +48 -0
  135. package/src/utils/sheetFormulaParser.ts +729 -0
  136. package/src/utils/sheetFormulaRange.ts +330 -0
  137. package/src/utils/sheetFormulaReference.ts +703 -0
  138. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  139. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  140. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  141. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  142. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  143. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  144. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  145. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  146. package/src/utils/sheetFormulaText.ts +430 -0
  147. package/src/utils/sheetJournal.ts +200 -0
  148. package/src/utils/sheetNumberFormat.ts +1012 -0
  149. package/src/utils/sheetPreview.ts +68 -0
  150. package/src/utils/sheetSequence.ts +118 -0
  151. package/src/utils/sheetSnapshot.ts +739 -0
  152. package/src/utils/sheetStructureEdit.ts +914 -0
  153. package/src/utils/sheetStructureReferences.ts +389 -0
  154. package/src/utils/square.ts +32 -0
  155. package/src/utils/storage.ts +198 -0
  156. package/src/utils/table-route.ts +262 -0
  157. package/src/utils/time.ts +12 -0
  158. package/src/utils/workflow.ts +506 -0
  159. package/src/utils/workflowLogFingerprint.ts +302 -0
  160. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  161. package/src/utils/workflowProgress.ts +280 -0
  162. package/src/utils/workflowTriggers.ts +61 -0
  163. package/tests/agentNote.test.ts +395 -0
  164. package/tests/campaignAI.test.ts +119 -0
  165. package/tests/campaignAccess.test.ts +239 -0
  166. package/tests/campaignEmail.test.ts +441 -0
  167. package/tests/campaignLifecycle.test.ts +134 -0
  168. package/tests/campaignPublication.test.ts +309 -0
  169. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  170. package/tests/dataTableRelativeDate.test.ts +412 -0
  171. package/tests/docAccess.test.ts +525 -0
  172. package/tests/editLogEntry.test.ts +112 -0
  173. package/tests/email.test.ts +39 -0
  174. package/tests/fieldDocProgram.test.ts +114 -0
  175. package/tests/logDisplay.fixtures.ts +67 -0
  176. package/tests/logDisplay.test.ts +227 -0
  177. package/tests/noteDoc.test.ts +514 -0
  178. package/tests/richTextHTML.test.ts +185 -0
  179. package/tests/sheetAxisMove.test.ts +352 -0
  180. package/tests/sheetBootstrap.test.ts +1967 -0
  181. package/tests/sheetFeatureReference.test.ts +22 -0
  182. package/tests/sheetFormulaCriteria.test.ts +269 -0
  183. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  184. package/tests/sheetFormulaFunctions.test.ts +538 -0
  185. package/tests/sheetFormulaLanguage.test.ts +361 -0
  186. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  187. package/tests/sheetFormulaParity.test.ts +188 -0
  188. package/tests/sheetFormulaRange.test.ts +167 -0
  189. package/tests/sheetFormulaReference.test.ts +78 -0
  190. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  191. package/tests/sheetFormulaTextDate.test.ts +512 -0
  192. package/tests/sheetSequence.test.ts +22 -0
  193. package/tests/sheetSnapshot.test.ts +134 -0
  194. package/tests/sheetStructureEdit.test.ts +537 -0
  195. package/tests/sheetStructureReferences.test.ts +589 -0
  196. package/tests/workflowLifecycleStatus.test.ts +60 -0
  197. package/tests/workflowLogFingerprint.test.ts +203 -0
  198. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  199. package/tests/workflowProgress.test.ts +180 -0
  200. package/tests/workflowTriggers.test.ts +29 -0
  201. package/tsconfig.json +12 -0
  202. package/vitest.config.ts +8 -0
@@ -0,0 +1,462 @@
1
+ import type { SheetFormulaFunctionReference } from './sheetFormulaReference.ts';
2
+
3
+ /* Shared reference for the text builtins added with formula language v4.
4
+ * Merged into SHEET_FORMULA_REFERENCE; every example is executed by the
5
+ * reference test. */
6
+
7
+ const FILE_CONSTANTS = {
8
+ textArg: {
9
+ key: 'text',
10
+ type: 'scalar',
11
+ description: 'Text, or a number or TRUE/FALSE read as text.',
12
+ descriptionI18nKey: 'sheet_formula.arg_text',
13
+ },
14
+ textValueBehavior:
15
+ 'Values read as text: blank is empty, TRUE/FALSE stay uppercase, numbers use up to 15 significant digits. Lengths and positions count UTF-16 code units, as in Excel.',
16
+ rangeError: 'INVALID_VALUE (#VALUE!) for a range where one value is needed, or an invalid count or position.',
17
+ textCapError: 'INVALID_VALUE (#VALUE!) when the result is longer than 10,000 characters.',
18
+ joinValuesArg: {
19
+ key: 'value',
20
+ type: 'scalar | range',
21
+ description: 'Values or ranges to join; ranges are read row by row.',
22
+ descriptionI18nKey: 'sheet_formula.arg_join_value',
23
+ repeatable: true,
24
+ },
25
+ textReturns: { type: 'text', description: 'The resulting text.' },
26
+ countArg: {
27
+ key: 'number_of_characters',
28
+ type: 'number',
29
+ description: 'How many characters to return; defaults to 1.',
30
+ descriptionI18nKey: 'sheet_formula.arg_number_of_characters',
31
+ optional: true,
32
+ },
33
+ findArgs: [
34
+ {
35
+ key: 'search_for',
36
+ type: 'text',
37
+ description: 'Text to look for.',
38
+ descriptionI18nKey: 'sheet_formula.arg_search_for',
39
+ },
40
+ {
41
+ key: 'text_to_search',
42
+ type: 'text',
43
+ description: 'Text to search in.',
44
+ descriptionI18nKey: 'sheet_formula.arg_text_to_search',
45
+ },
46
+ {
47
+ key: 'starting_at',
48
+ type: 'number',
49
+ description: 'Position to start searching from; defaults to 1.',
50
+ descriptionI18nKey: 'sheet_formula.arg_starting_at',
51
+ optional: true,
52
+ },
53
+ ],
54
+ positionReturns: {
55
+ type: 'number',
56
+ description: '1-based position of the first match.',
57
+ },
58
+ };
59
+
60
+ export const SHEET_FORMULA_TEXT_REFERENCE: Record<
61
+ | 'CONCAT'
62
+ | 'CONCATENATE'
63
+ | 'FIND'
64
+ | 'LEFT'
65
+ | 'LEN'
66
+ | 'LOWER'
67
+ | 'MID'
68
+ | 'PROPER'
69
+ | 'REPLACE'
70
+ | 'RIGHT'
71
+ | 'SEARCH'
72
+ | 'SUBSTITUTE'
73
+ | 'TEXT'
74
+ | 'TEXTJOIN'
75
+ | 'TRIM'
76
+ | 'UPPER'
77
+ | 'VALUE',
78
+ SheetFormulaFunctionReference
79
+ > = {
80
+ CONCAT: {
81
+ name: 'CONCAT',
82
+ topic: 'text',
83
+ signature: 'CONCAT(value, ...)',
84
+ args: [FILE_CONSTANTS.joinValuesArg],
85
+ description: 'Joins values and ranges into one text.',
86
+ descriptionI18nKey: 'sheet_formula.concat_description',
87
+ returns: FILE_CONSTANTS.textReturns,
88
+ behavior: [FILE_CONSTANTS.textValueBehavior, 'The & operator joins two values the same way: =A1&" "&B1.'],
89
+ errors: [FILE_CONSTANTS.textCapError],
90
+ examples: [
91
+ {
92
+ formula: '=CONCAT(A1, "-", A2)',
93
+ cells: { A1: 'ab', A2: 12 },
94
+ expectedValue: 'ab-12',
95
+ },
96
+ {
97
+ formula: '=CONCAT(A1:A3)',
98
+ cells: { A1: 'x', A3: true },
99
+ expectedValue: 'xTRUE',
100
+ },
101
+ ],
102
+ },
103
+ CONCATENATE: {
104
+ name: 'CONCATENATE',
105
+ topic: 'text',
106
+ signature: 'CONCATENATE(value, ...)',
107
+ args: [FILE_CONSTANTS.joinValuesArg],
108
+ description: 'Joins values into one text; the same as CONCAT.',
109
+ descriptionI18nKey: 'sheet_formula.concatenate_description',
110
+ returns: FILE_CONSTANTS.textReturns,
111
+ behavior: [FILE_CONSTANTS.textValueBehavior],
112
+ errors: [FILE_CONSTANTS.textCapError],
113
+ examples: [{ formula: '=CONCATENATE("Q", 3, " ", 2026)', expectedValue: 'Q3 2026' }],
114
+ },
115
+ FIND: {
116
+ name: 'FIND',
117
+ topic: 'text',
118
+ signature: 'FIND(search_for, text_to_search, [starting_at])',
119
+ args: FILE_CONSTANTS.findArgs,
120
+ description: 'Returns the position of text inside another text.',
121
+ descriptionI18nKey: 'sheet_formula.find_description',
122
+ returns: FILE_CONSTANTS.positionReturns,
123
+ behavior: ['Case-sensitive and literal (no wildcards); use SEARCH to ignore case.'],
124
+ errors: [
125
+ 'INVALID_VALUE (#VALUE!) when the text is not found or starting_at is out of range. ISNUMBER(FIND(...)) tests for a match.',
126
+ ],
127
+ examples: [
128
+ { formula: '=FIND("b", "abcb", 3)', expectedValue: 4 },
129
+ {
130
+ formula: '=FIND("B", "abc")',
131
+ expectedValue: '#VALUE!',
132
+ expectedErrorCode: 'INVALID_VALUE',
133
+ },
134
+ ],
135
+ },
136
+ LEFT: {
137
+ name: 'LEFT',
138
+ topic: 'text',
139
+ signature: 'LEFT(text, [number_of_characters])',
140
+ args: [FILE_CONSTANTS.textArg, FILE_CONSTANTS.countArg],
141
+ description: 'Returns characters from the start of a text.',
142
+ descriptionI18nKey: 'sheet_formula.left_description',
143
+ returns: FILE_CONSTANTS.textReturns,
144
+ behavior: [FILE_CONSTANTS.textValueBehavior],
145
+ errors: [FILE_CONSTANTS.rangeError],
146
+ examples: [
147
+ { formula: '=LEFT("Invoice-42", 7)', expectedValue: 'Invoice' },
148
+ {
149
+ formula: '=LEFT("abc", -1)',
150
+ expectedValue: '#VALUE!',
151
+ expectedErrorCode: 'INVALID_VALUE',
152
+ },
153
+ ],
154
+ },
155
+ LEN: {
156
+ name: 'LEN',
157
+ topic: 'text',
158
+ signature: 'LEN(text)',
159
+ args: [FILE_CONSTANTS.textArg],
160
+ description: 'Returns the number of characters in a text.',
161
+ descriptionI18nKey: 'sheet_formula.len_description',
162
+ returns: { type: 'number', description: 'Character count.' },
163
+ behavior: [FILE_CONSTANTS.textValueBehavior],
164
+ errors: [FILE_CONSTANTS.rangeError],
165
+ examples: [
166
+ { formula: '=LEN("hello")', expectedValue: 5 },
167
+ { formula: '=LEN(A1)', expectedValue: 0 },
168
+ ],
169
+ },
170
+ LOWER: {
171
+ name: 'LOWER',
172
+ topic: 'text',
173
+ signature: 'LOWER(text)',
174
+ args: [FILE_CONSTANTS.textArg],
175
+ description: 'Converts a text to lowercase.',
176
+ descriptionI18nKey: 'sheet_formula.lower_description',
177
+ returns: FILE_CONSTANTS.textReturns,
178
+ behavior: [FILE_CONSTANTS.textValueBehavior],
179
+ errors: [FILE_CONSTANTS.rangeError],
180
+ examples: [{ formula: '=LOWER("North WEST")', expectedValue: 'north west' }],
181
+ },
182
+ MID: {
183
+ name: 'MID',
184
+ topic: 'text',
185
+ signature: 'MID(text, starting_at, extract_length)',
186
+ args: [
187
+ FILE_CONSTANTS.textArg,
188
+ {
189
+ key: 'starting_at',
190
+ type: 'number',
191
+ description: '1-based position of the first character.',
192
+ descriptionI18nKey: 'sheet_formula.mid_arg_starting_at',
193
+ },
194
+ {
195
+ key: 'extract_length',
196
+ type: 'number',
197
+ description: 'How many characters to return.',
198
+ descriptionI18nKey: 'sheet_formula.mid_arg_extract_length',
199
+ },
200
+ ],
201
+ description: 'Returns characters from the middle of a text.',
202
+ descriptionI18nKey: 'sheet_formula.mid_description',
203
+ returns: FILE_CONSTANTS.textReturns,
204
+ behavior: [FILE_CONSTANTS.textValueBehavior, 'A start past the end returns empty text.'],
205
+ errors: [FILE_CONSTANTS.rangeError],
206
+ examples: [
207
+ { formula: '=MID("2026-09-25", 6, 2)', expectedValue: '09' },
208
+ {
209
+ formula: '=MID("abc", 0, 1)',
210
+ expectedValue: '#VALUE!',
211
+ expectedErrorCode: 'INVALID_VALUE',
212
+ },
213
+ ],
214
+ },
215
+ PROPER: {
216
+ name: 'PROPER',
217
+ topic: 'text',
218
+ signature: 'PROPER(text)',
219
+ args: [FILE_CONSTANTS.textArg],
220
+ description: 'Capitalizes the first letter of each word.',
221
+ descriptionI18nKey: 'sheet_formula.proper_description',
222
+ returns: FILE_CONSTANTS.textReturns,
223
+ behavior: ['A letter after any non-letter (space, digit, apostrophe) is upper-cased and the rest are lower-cased, as in Excel.'],
224
+ errors: [FILE_CONSTANTS.rangeError],
225
+ examples: [{ formula: '=PROPER("jane DOE-smith")', expectedValue: 'Jane Doe-Smith' }],
226
+ },
227
+ REPLACE: {
228
+ name: 'REPLACE',
229
+ topic: 'text',
230
+ signature: 'REPLACE(text, position, length, new_text)',
231
+ args: [
232
+ FILE_CONSTANTS.textArg,
233
+ {
234
+ key: 'position',
235
+ type: 'number',
236
+ description: '1-based position where the replacement starts.',
237
+ descriptionI18nKey: 'sheet_formula.replace_arg_position',
238
+ },
239
+ {
240
+ key: 'length',
241
+ type: 'number',
242
+ description: 'How many characters to replace.',
243
+ descriptionI18nKey: 'sheet_formula.replace_arg_length',
244
+ },
245
+ {
246
+ key: 'new_text',
247
+ type: 'text',
248
+ description: 'Text inserted in their place.',
249
+ descriptionI18nKey: 'sheet_formula.replace_arg_new_text',
250
+ },
251
+ ],
252
+ description: 'Replaces part of a text by position.',
253
+ descriptionI18nKey: 'sheet_formula.replace_description',
254
+ returns: FILE_CONSTANTS.textReturns,
255
+ behavior: ['Use SUBSTITUTE to replace by content instead of position.'],
256
+ errors: [FILE_CONSTANTS.rangeError, FILE_CONSTANTS.textCapError],
257
+ examples: [{ formula: '=REPLACE("abcdef", 2, 3, "X")', expectedValue: 'aXef' }],
258
+ },
259
+ RIGHT: {
260
+ name: 'RIGHT',
261
+ topic: 'text',
262
+ signature: 'RIGHT(text, [number_of_characters])',
263
+ args: [FILE_CONSTANTS.textArg, FILE_CONSTANTS.countArg],
264
+ description: 'Returns characters from the end of a text.',
265
+ descriptionI18nKey: 'sheet_formula.right_description',
266
+ returns: FILE_CONSTANTS.textReturns,
267
+ behavior: [FILE_CONSTANTS.textValueBehavior],
268
+ errors: [FILE_CONSTANTS.rangeError],
269
+ examples: [
270
+ { formula: '=RIGHT("Invoice-42", 2)', expectedValue: '42' },
271
+ { formula: '=RIGHT(12345, 3)', expectedValue: '345' },
272
+ ],
273
+ },
274
+ SEARCH: {
275
+ name: 'SEARCH',
276
+ topic: 'text',
277
+ signature: 'SEARCH(search_for, text_to_search, [starting_at])',
278
+ args: FILE_CONSTANTS.findArgs,
279
+ description: 'Returns the position of text inside another text, ignoring case.',
280
+ descriptionI18nKey: 'sheet_formula.search_description',
281
+ returns: FILE_CONSTANTS.positionReturns,
282
+ behavior: ['Ignores case. * matches any run of characters, ? one character, ~ escapes them.'],
283
+ errors: [
284
+ 'INVALID_VALUE (#VALUE!) when the text is not found or starting_at is out of range. ISNUMBER(SEARCH(...)) tests for a match.',
285
+ ],
286
+ examples: [
287
+ { formula: '=SEARCH("B", "abc")', expectedValue: 2 },
288
+ { formula: '=SEARCH("b*d", "xxbcd")', expectedValue: 3 },
289
+ { formula: '=ISNUMBER(SEARCH("z", "abc"))', expectedValue: false },
290
+ ],
291
+ },
292
+ SUBSTITUTE: {
293
+ name: 'SUBSTITUTE',
294
+ topic: 'text',
295
+ signature: 'SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])',
296
+ args: [
297
+ {
298
+ key: 'text_to_search',
299
+ type: 'text',
300
+ description: 'Text to change.',
301
+ descriptionI18nKey: 'sheet_formula.substitute_arg_text_to_search',
302
+ },
303
+ {
304
+ key: 'search_for',
305
+ type: 'text',
306
+ description: 'Text to replace (case-sensitive).',
307
+ descriptionI18nKey: 'sheet_formula.substitute_arg_search_for',
308
+ },
309
+ {
310
+ key: 'replace_with',
311
+ type: 'text',
312
+ description: 'Replacement text.',
313
+ descriptionI18nKey: 'sheet_formula.substitute_arg_replace_with',
314
+ },
315
+ {
316
+ key: 'occurrence_number',
317
+ type: 'number',
318
+ description: 'Replace only this occurrence; omit to replace all.',
319
+ descriptionI18nKey: 'sheet_formula.substitute_arg_occurrence_number',
320
+ optional: true,
321
+ },
322
+ ],
323
+ description: 'Replaces text by content.',
324
+ descriptionI18nKey: 'sheet_formula.substitute_description',
325
+ returns: FILE_CONSTANTS.textReturns,
326
+ behavior: ['Literal and case-sensitive. An empty search_for returns the text unchanged.'],
327
+ errors: [FILE_CONSTANTS.rangeError, FILE_CONSTANTS.textCapError],
328
+ examples: [
329
+ { formula: '=SUBSTITUTE("a-b-c", "-", "/")', expectedValue: 'a/b/c' },
330
+ { formula: '=SUBSTITUTE("a-b-c", "-", "/", 2)', expectedValue: 'a-b/c' },
331
+ ],
332
+ },
333
+ TEXT: {
334
+ name: 'TEXT',
335
+ topic: 'text',
336
+ signature: 'TEXT(value, format)',
337
+ args: [
338
+ {
339
+ key: 'value',
340
+ type: 'number | ISO date | ISO datetime',
341
+ description: 'Number or date to format.',
342
+ descriptionI18nKey: 'sheet_formula.text_arg_value',
343
+ },
344
+ {
345
+ key: 'format',
346
+ type: 'text',
347
+ description: 'Number format pattern such as "#,##0.00" or "mmm d".',
348
+ descriptionI18nKey: 'sheet_formula.text_arg_format',
349
+ },
350
+ ],
351
+ description: 'Formats a number or date as text with a format pattern.',
352
+ descriptionI18nKey: 'sheet_formula.text_description',
353
+ returns: {
354
+ type: 'text',
355
+ description: 'The formatted text.',
356
+ },
357
+ behavior: [
358
+ 'Uses the cell number format patterns. Datetimes use the organization time zone; month names are English.',
359
+ 'Numeric text formats as a number. Other text is returned unchanged unless the pattern has an @ section; TRUE/FALSE are returned as text.',
360
+ ],
361
+ errors: ['INVALID_VALUE (#VALUE!) for an invalid pattern or a range.'],
362
+ examples: [
363
+ { formula: '=TEXT(1234.5, "#,##0.00")', expectedValue: '1,234.50' },
364
+ {
365
+ formula: '=TEXT("2026-01-05", "mmm d, yyyy")',
366
+ expectedValue: 'Jan 5, 2026',
367
+ },
368
+ { formula: '=TEXT(0.25, "0%")', expectedValue: '25%' },
369
+ ],
370
+ },
371
+ TEXTJOIN: {
372
+ name: 'TEXTJOIN',
373
+ topic: 'text',
374
+ signature: 'TEXTJOIN(delimiter, ignore_empty, value, ...)',
375
+ args: [
376
+ {
377
+ key: 'delimiter',
378
+ type: 'text',
379
+ description: 'Text placed between the values, such as ", ".',
380
+ descriptionI18nKey: 'sheet_formula.textjoin_arg_delimiter',
381
+ },
382
+ {
383
+ key: 'ignore_empty',
384
+ type: 'boolean',
385
+ description: 'TRUE skips empty cells and empty text.',
386
+ descriptionI18nKey: 'sheet_formula.textjoin_arg_ignore_empty',
387
+ },
388
+ FILE_CONSTANTS.joinValuesArg,
389
+ ],
390
+ description: 'Joins values and ranges with a delimiter.',
391
+ descriptionI18nKey: 'sheet_formula.textjoin_description',
392
+ returns: FILE_CONSTANTS.textReturns,
393
+ behavior: [FILE_CONSTANTS.textValueBehavior, 'Accepts UNIQUE(...) to join distinct values.'],
394
+ errors: [FILE_CONSTANTS.textCapError, 'INVALID_VALUE (#VALUE!) when ignore_empty is not TRUE/FALSE.'],
395
+ examples: [
396
+ {
397
+ formula: '=TEXTJOIN(", ", TRUE, A1:A4)',
398
+ cells: { A1: 'red', A3: 'blue', A4: '' },
399
+ expectedValue: 'red, blue',
400
+ },
401
+ {
402
+ formula: '=TEXTJOIN("/", FALSE, A1:A3)',
403
+ cells: { A1: 'a', A3: 'c' },
404
+ expectedValue: 'a//c',
405
+ },
406
+ ],
407
+ },
408
+ TRIM: {
409
+ name: 'TRIM',
410
+ topic: 'text',
411
+ signature: 'TRIM(text)',
412
+ args: [FILE_CONSTANTS.textArg],
413
+ description: 'Removes extra spaces from a text.',
414
+ descriptionI18nKey: 'sheet_formula.trim_description',
415
+ returns: FILE_CONSTANTS.textReturns,
416
+ behavior: ['Removes spaces at both ends and collapses runs of spaces to one, as in Excel. Tabs and other whitespace are kept.'],
417
+ errors: [FILE_CONSTANTS.rangeError],
418
+ examples: [{ formula: '=TRIM(" a b ")', expectedValue: 'a b' }],
419
+ },
420
+ UPPER: {
421
+ name: 'UPPER',
422
+ topic: 'text',
423
+ signature: 'UPPER(text)',
424
+ args: [FILE_CONSTANTS.textArg],
425
+ description: 'Converts a text to uppercase.',
426
+ descriptionI18nKey: 'sheet_formula.upper_description',
427
+ returns: FILE_CONSTANTS.textReturns,
428
+ behavior: [FILE_CONSTANTS.textValueBehavior],
429
+ errors: [FILE_CONSTANTS.rangeError],
430
+ examples: [{ formula: '=UPPER("sku-9a")', expectedValue: 'SKU-9A' }],
431
+ },
432
+ VALUE: {
433
+ name: 'VALUE',
434
+ topic: 'text',
435
+ signature: 'VALUE(text)',
436
+ args: [
437
+ {
438
+ key: 'text',
439
+ type: 'text',
440
+ description: 'Text that reads as a number, such as "1,234.50".',
441
+ descriptionI18nKey: 'sheet_formula.value_arg_text',
442
+ },
443
+ ],
444
+ description: 'Converts text that looks like a number into a number.',
445
+ descriptionI18nKey: 'sheet_formula.value_description',
446
+ returns: { type: 'number', description: 'The number.' },
447
+ behavior: [
448
+ 'Accepts thousands separators, a leading $, a trailing % (divided by 100), an exponent, and (12) for -12. Numbers pass through, TRUE/FALSE are 1/0, blank is 0.',
449
+ 'Dates are not converted, because dates are ISO text rather than serial numbers.',
450
+ ],
451
+ errors: ['INVALID_VALUE (#VALUE!) for text that is not a number, including dates.'],
452
+ examples: [
453
+ { formula: '=VALUE("$1,234.50")', expectedValue: 1234.5 },
454
+ { formula: '=VALUE("15%")', expectedValue: 0.15 },
455
+ {
456
+ formula: '=VALUE("2026-01-05")',
457
+ expectedValue: '#VALUE!',
458
+ expectedErrorCode: 'INVALID_VALUE',
459
+ },
460
+ ],
461
+ },
462
+ };