@jsb188/mday 1.1.10 → 1.1.12
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/package.json +140 -54
- package/src/constants/agentMemory.ts +123 -0
- package/src/constants/agentNote.ts +212 -0
- package/src/constants/aiChat.ts +10 -0
- package/src/constants/billing.ts +126 -0
- package/src/constants/campaign.ts +236 -0
- package/src/constants/contact.ts +72 -0
- package/src/constants/csvExport.ts +133 -0
- package/src/constants/dataTable.ts +21 -21
- package/src/constants/dataTableFieldTypes.generated.ts +59 -0
- package/src/constants/docAccess.ts +33 -0
- package/src/constants/dt.ts +234 -0
- package/src/constants/email.ts +125 -7
- package/src/constants/fieldDoc.ts +104 -0
- package/src/constants/graphqlReactivity.ts +196 -0
- package/src/constants/integration.ts +8 -9
- package/src/constants/log.ts +14 -408
- package/src/constants/logDisplay/README.md +88 -0
- package/src/constants/logDisplay/defaults.ts +39 -0
- package/src/constants/logDisplay/index.ts +27 -0
- package/src/constants/logDisplay/operations/arable.ts +16 -0
- package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
- package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
- package/src/constants/logDisplay/shared/accounting.ts +13 -0
- package/src/constants/logDisplay/shared/interactions.ts +13 -0
- package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
- package/src/constants/logTaxonomy.generated.ts +2207 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +18 -21
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/qrCode.ts +30 -0
- package/src/constants/sheet.ts +126 -14
- package/src/constants/sms.ts +18 -0
- package/src/constants/square.ts +6 -6
- package/src/constants/storage.ts +80 -7
- package/src/constants/usage.ts +82 -0
- package/src/constants/workflowSteps.ts +60 -0
- package/src/schemas/editLogEntry.ts +836 -780
- package/src/schemas/inboundContact.ts +60 -55
- package/src/schemas/logsQuery.ts +55 -49
- package/src/types/account.d.ts +4 -1
- package/src/types/agentMemory.d.ts +98 -0
- package/src/types/agentNote.d.ts +443 -0
- package/src/types/billing.d.ts +537 -0
- package/src/types/campaign.d.ts +1533 -0
- package/src/types/contact.d.ts +15 -0
- package/src/types/csvExport.d.ts +213 -0
- package/src/types/dataAnalysis.d.ts +44 -0
- package/src/types/dataTable.d.ts +115 -403
- package/src/types/definitionElement.d.ts +35 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/dt.d.ts +257 -0
- package/src/types/email.d.ts +184 -24
- package/src/types/emailReplyReport.d.ts +76 -0
- package/src/types/fieldDoc.d.ts +702 -0
- package/src/types/fieldDocContract.d.ts +90 -0
- package/src/types/inboundContact.d.ts +10 -1
- package/src/types/log.d.ts +254 -295
- package/src/types/logDisplay.types.ts +85 -0
- package/src/types/organization.d.ts +91 -43
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/qrCode.d.ts +96 -0
- package/src/types/richText.d.ts +81 -0
- package/src/types/sheet.d.ts +678 -129
- package/src/types/sms.d.ts +38 -0
- package/src/types/storage.d.ts +449 -129
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +315 -54
- package/src/utils/agentMemory.ts +15 -0
- package/src/utils/agentNote.ts +850 -0
- package/src/utils/aiChat.ts +43 -0
- package/src/utils/aiChatWork.ts +64 -0
- package/src/utils/billing.ts +37 -0
- package/src/utils/campaign.ts +1174 -0
- package/src/utils/campaignAI.ts +72 -0
- package/src/utils/campaignAccess.ts +239 -0
- package/src/utils/campaignEmail.ts +601 -0
- package/src/utils/campaignEmailCompiler.ts +372 -0
- package/src/utils/campaignEmailImages.ts +60 -0
- package/src/utils/campaignEmailStyles.ts +544 -0
- package/src/utils/campaignLifecycle.ts +104 -0
- package/src/utils/campaignPreview.ts +285 -0
- package/src/utils/contact.ts +50 -0
- package/src/utils/csvExport.ts +19 -0
- package/src/utils/dataTable.ts +95 -618
- package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
- package/src/utils/dataTableRelativeDate.ts +447 -0
- package/src/utils/definitionElement.ts +84 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +317 -51
- package/src/utils/emailReplyReport.test.ts +187 -0
- package/src/utils/emailReplyReport.ts +143 -0
- package/src/utils/fieldDoc.ts +157 -0
- package/src/utils/fieldDocAnswers.ts +128 -0
- package/src/utils/fieldDocDefaults.ts +36 -0
- package/src/utils/fieldDocProgram.ts +36 -0
- package/src/utils/fieldDocSummary.ts +30 -0
- package/src/utils/log.ts +276 -192
- package/src/utils/logDisplay.helpers.ts +177 -0
- package/src/utils/logDisplay.ts +87 -0
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +262 -0
- package/src/utils/logTaxonomy.helpers.ts +17 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +395 -0
- package/src/utils/noteDoc.ts +609 -0
- package/src/utils/organization.ts +337 -84
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/qrCode.helpers.ts +189 -0
- package/src/utils/qrCode.test.ts +519 -0
- package/src/utils/qrCode.ts +273 -0
- package/src/utils/richTextHTML.ts +385 -0
- package/src/utils/sheet.ts +199 -107
- package/src/utils/sheetAxisMove.ts +616 -0
- package/src/utils/sheetBootstrap.ts +1402 -0
- package/src/utils/sheetCellLiteral.ts +101 -0
- package/src/utils/sheetCommand.ts +358 -0
- package/src/utils/sheetDesign.ts +705 -0
- package/src/utils/sheetExport.ts +186 -0
- package/src/utils/sheetFeatureReference.ts +183 -0
- package/src/utils/sheetFormulaArgs.ts +168 -0
- package/src/utils/sheetFormulaCompile.ts +475 -0
- package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
- package/src/utils/sheetFormulaCriteria.ts +656 -0
- package/src/utils/sheetFormulaDate.ts +444 -0
- package/src/utils/sheetFormulaEvaluation.ts +899 -0
- package/src/utils/sheetFormulaEvaluator.ts +997 -0
- package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
- package/src/utils/sheetFormulaLogical.ts +116 -0
- package/src/utils/sheetFormulaLookup.ts +488 -0
- package/src/utils/sheetFormulaMath.ts +48 -0
- package/src/utils/sheetFormulaParser.ts +729 -0
- package/src/utils/sheetFormulaRange.ts +330 -0
- package/src/utils/sheetFormulaReference.ts +703 -0
- package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
- package/src/utils/sheetFormulaReferenceDates.ts +237 -0
- package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
- package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
- package/src/utils/sheetFormulaReferenceMath.ts +95 -0
- package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
- package/src/utils/sheetFormulaReferenceText.ts +462 -0
- package/src/utils/sheetFormulaSyntax.ts +1027 -0
- package/src/utils/sheetFormulaText.ts +430 -0
- package/src/utils/sheetJournal.ts +200 -0
- package/src/utils/sheetNumberFormat.ts +1012 -0
- package/src/utils/sheetPreview.ts +68 -0
- package/src/utils/sheetSequence.ts +118 -0
- package/src/utils/sheetSnapshot.ts +739 -0
- package/src/utils/sheetStructureEdit.ts +914 -0
- package/src/utils/sheetStructureReferences.ts +389 -0
- package/src/utils/square.ts +22 -12
- package/src/utils/storage.ts +198 -0
- package/src/utils/table-route.ts +127 -11
- package/src/utils/time.ts +12 -0
- package/src/utils/workflow.ts +334 -40
- package/src/utils/workflowLogFingerprint.ts +302 -0
- package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
- package/src/utils/workflowProgress.ts +280 -0
- package/src/utils/workflowTriggers.ts +61 -0
- package/tests/agentNote.test.ts +395 -0
- package/tests/campaignAI.test.ts +119 -0
- package/tests/campaignAccess.test.ts +239 -0
- package/tests/campaignEmail.test.ts +441 -0
- package/tests/campaignLifecycle.test.ts +134 -0
- package/tests/campaignPublication.test.ts +309 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
- package/tests/dataTableRelativeDate.test.ts +412 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/email.test.ts +39 -0
- package/tests/fieldDocProgram.test.ts +114 -0
- package/tests/logDisplay.fixtures.ts +67 -0
- package/tests/logDisplay.test.ts +227 -0
- package/tests/noteDoc.test.ts +514 -0
- package/tests/richTextHTML.test.ts +185 -0
- package/tests/sheetAxisMove.test.ts +352 -0
- package/tests/sheetBootstrap.test.ts +1967 -0
- package/tests/sheetFeatureReference.test.ts +22 -0
- package/tests/sheetFormulaCriteria.test.ts +269 -0
- package/tests/sheetFormulaEvaluator.test.ts +468 -0
- package/tests/sheetFormulaFunctions.test.ts +538 -0
- package/tests/sheetFormulaLanguage.test.ts +361 -0
- package/tests/sheetFormulaParity.fixtures.ts +872 -0
- package/tests/sheetFormulaParity.test.ts +188 -0
- package/tests/sheetFormulaRange.test.ts +167 -0
- package/tests/sheetFormulaReference.test.ts +78 -0
- package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
- package/tests/sheetFormulaTextDate.test.ts +512 -0
- package/tests/sheetSequence.test.ts +22 -0
- package/tests/sheetSnapshot.test.ts +134 -0
- package/tests/sheetStructureEdit.test.ts +537 -0
- package/tests/sheetStructureReferences.test.ts +589 -0
- package/tests/workflowLifecycleStatus.test.ts +60 -0
- package/tests/workflowLogFingerprint.test.ts +203 -0
- package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
- package/tests/workflowProgress.test.ts +180 -0
- package/tests/workflowTriggers.test.ts +29 -0
- package/tsconfig.json +10 -10
- package/vitest.config.ts +8 -0
- package/src/constants/log-activityTexts.ts +0 -235
- package/src/constants/product.ts +0 -42
- package/src/constants/report.ts +0 -44
- package/src/schemas/organization.ts +0 -65
- package/src/schemas/productsQuery.ts +0 -53
- package/src/schemas/reportsQuery.ts +0 -20
- package/src/types/product.d.ts +0 -84
- package/src/types/report.d.ts +0 -290
- package/src/utils/product-calEvent.ts +0 -455
- package/src/utils/report.ts +0 -158
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { parseSheetFormulaExpression, parseSheetFormulaRangeReference } from '../src/utils/sheetFormulaParser.ts';
|
|
3
|
+
import { getSheetFormulaExpression } from '../src/utils/sheetFormulaSyntax.ts';
|
|
4
|
+
import { SHEET_FEATURE_REFERENCE } from '../src/utils/sheetFeatureReference.ts';
|
|
5
|
+
import { SHEET_MAX_ROW_COUNT } from '../src/constants/sheet.ts';
|
|
6
|
+
|
|
7
|
+
describe('Sheet feature reference examples', () => {
|
|
8
|
+
it('keeps documented formulas within the actual parser grammar', () => {
|
|
9
|
+
for (const topic of Object.values(SHEET_FEATURE_REFERENCE)) {
|
|
10
|
+
for (const example of topic.examples) {
|
|
11
|
+
if (example.expression) {
|
|
12
|
+
expect(parseSheetFormulaExpression(getSheetFormulaExpression(example.expression)), example.expression).not.toBeNull();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('keeps the documented open-range boundary', () => {
|
|
19
|
+
expect(parseSheetFormulaRangeReference('C3:C')?.endRowIndex).toBe(SHEET_MAX_ROW_COUNT);
|
|
20
|
+
expect(parseSheetFormulaRangeReference('C:C')).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
compareSheetFormulaLookupValues,
|
|
4
|
+
compileSheetFormulaWildcardPattern,
|
|
5
|
+
getSheetFormulaLookupMatcher,
|
|
6
|
+
getSheetFormulaLookupValueClass,
|
|
7
|
+
getSheetFormulaLookupValueKey,
|
|
8
|
+
parseSheetFormulaCriterion,
|
|
9
|
+
type SheetFormulaCriterion,
|
|
10
|
+
sheetFormulaCriterionMatches,
|
|
11
|
+
sheetFormulaLookupValuesEqual,
|
|
12
|
+
sheetFormulaSwitchValuesEqual,
|
|
13
|
+
sheetFormulaWildcardMatches,
|
|
14
|
+
} from '../src/utils/sheetFormulaCriteria.ts';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Parse one criterion that must be valid.
|
|
18
|
+
*/
|
|
19
|
+
function parseCriterion(value: unknown, timeZone = 'UTC'): SheetFormulaCriterion {
|
|
20
|
+
const parsed = parseSheetFormulaCriterion(value, timeZone);
|
|
21
|
+
if (!parsed.ok) {
|
|
22
|
+
throw new Error(`Criterion ${String(value)} did not parse.`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return parsed.criterion;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Return which of the cell values one criterion matches.
|
|
30
|
+
*/
|
|
31
|
+
function getMatchedValues(criterionValue: unknown, cells: unknown[], timeZone = 'UTC') {
|
|
32
|
+
const criterion = parseCriterion(criterionValue, timeZone);
|
|
33
|
+
return cells.filter((cell) => sheetFormulaCriterionMatches(criterion, cell, timeZone));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Return whether one wildcard pattern matches one text.
|
|
38
|
+
*/
|
|
39
|
+
function globMatches(pattern: string, text: string) {
|
|
40
|
+
return sheetFormulaWildcardMatches(compileSheetFormulaWildcardPattern(pattern), text);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('wildcard matcher', () => {
|
|
44
|
+
const cases: Array<[string, string, boolean]> = [
|
|
45
|
+
['a*', 'apple', true],
|
|
46
|
+
['a*', 'Apple', true],
|
|
47
|
+
['A*E', 'apple', true],
|
|
48
|
+
['*le', 'apple', true],
|
|
49
|
+
['*le', 'apples', false],
|
|
50
|
+
['a?ple', 'apple', true],
|
|
51
|
+
['a?ple', 'aple', false],
|
|
52
|
+
['a??le', 'apple', true],
|
|
53
|
+
['*', '', true],
|
|
54
|
+
['?', '', false],
|
|
55
|
+
['*a*b*', 'xxaxxbxx', true],
|
|
56
|
+
['*a*b*', 'xxbxxaxx', false],
|
|
57
|
+
['a**b', 'ab', true],
|
|
58
|
+
['~*', '*', true],
|
|
59
|
+
['~*', 'x', false],
|
|
60
|
+
['a~?', 'a?', true],
|
|
61
|
+
['a~?', 'ab', false],
|
|
62
|
+
['~~', '~', true],
|
|
63
|
+
['a~b', 'a~b', true],
|
|
64
|
+
['a*~*', 'abc*', true],
|
|
65
|
+
['a*~*', 'abc', false],
|
|
66
|
+
['?*', 'é', true],
|
|
67
|
+
['é*', 'ÉCOLE', true],
|
|
68
|
+
['x', 'X', true],
|
|
69
|
+
['x', 'xy', false],
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
for (const [pattern, text, expected] of cases) {
|
|
73
|
+
it(`${JSON.stringify(pattern)} ${expected ? 'matches' : 'does not match'} ${JSON.stringify(text)}`, () => {
|
|
74
|
+
expect(globMatches(pattern, text)).toBe(expected);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
it('compiles patterns without an active wildcard to plain literals', () => {
|
|
79
|
+
expect(compileSheetFormulaWildcardPattern('A~*B').program).toBeNull();
|
|
80
|
+
expect(compileSheetFormulaWildcardPattern('A~*B').literal).toBe('a*b');
|
|
81
|
+
expect(compileSheetFormulaWildcardPattern('a*').program).not.toBeNull();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('handles patterns longer than one 32-state word', () => {
|
|
85
|
+
const pattern = `${'?'.repeat(40)}*${'b'.repeat(40)}`;
|
|
86
|
+
expect(globMatches(pattern, `${'a'.repeat(45)}${'b'.repeat(40)}`)).toBe(true);
|
|
87
|
+
expect(globMatches(pattern, `${'a'.repeat(39)}${'b'.repeat(40)}`)).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('stays linear on patterns that make backtracking regex explode', () => {
|
|
91
|
+
const text = 'a'.repeat(10_000);
|
|
92
|
+
const started = performance.now();
|
|
93
|
+
expect(globMatches('*a*a*a*a*b', text)).toBe(false);
|
|
94
|
+
expect(globMatches(`*${'a*'.repeat(100)}b`, text)).toBe(false);
|
|
95
|
+
expect(globMatches(`*${'a*'.repeat(100)}`, text)).toBe(true);
|
|
96
|
+
expect(performance.now() - started).toBeLessThan(250);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('criterion parsing', () => {
|
|
101
|
+
it('classifies scalar criteria', () => {
|
|
102
|
+
expect(parseCriterion(5)).toEqual({
|
|
103
|
+
kind: 'NUMBER',
|
|
104
|
+
operator: '=',
|
|
105
|
+
value: 5,
|
|
106
|
+
});
|
|
107
|
+
expect(parseCriterion(true)).toEqual({
|
|
108
|
+
kind: 'BOOLEAN',
|
|
109
|
+
operator: '=',
|
|
110
|
+
value: true,
|
|
111
|
+
});
|
|
112
|
+
expect(parseCriterion(null)).toEqual({ kind: 'BLANK' });
|
|
113
|
+
expect(parseCriterion('')).toEqual({ kind: 'BLANK' });
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('classifies operator-prefixed text criteria', () => {
|
|
117
|
+
expect(parseCriterion('>=5')).toMatchObject({
|
|
118
|
+
kind: 'NUMBER',
|
|
119
|
+
operator: '>=',
|
|
120
|
+
value: 5,
|
|
121
|
+
});
|
|
122
|
+
expect(parseCriterion('!=5')).toMatchObject({
|
|
123
|
+
kind: 'NUMBER',
|
|
124
|
+
operator: '<>',
|
|
125
|
+
});
|
|
126
|
+
expect(parseCriterion('> -2.5')).toMatchObject({
|
|
127
|
+
kind: 'NUMBER',
|
|
128
|
+
value: -2.5,
|
|
129
|
+
});
|
|
130
|
+
expect(parseCriterion('=true')).toMatchObject({
|
|
131
|
+
kind: 'BOOLEAN',
|
|
132
|
+
value: true,
|
|
133
|
+
});
|
|
134
|
+
expect(parseCriterion('<>FALSE')).toMatchObject({
|
|
135
|
+
kind: 'BOOLEAN',
|
|
136
|
+
operator: '<>',
|
|
137
|
+
value: false,
|
|
138
|
+
});
|
|
139
|
+
expect(parseCriterion('=')).toEqual({ kind: 'BLANK' });
|
|
140
|
+
expect(parseCriterion('<>')).toEqual({ kind: 'NONBLANK' });
|
|
141
|
+
expect(parseCriterion('<')).toEqual({ kind: 'NONE' });
|
|
142
|
+
expect(parseCriterion('>=2026-01-02')).toMatchObject({
|
|
143
|
+
kind: 'DATE',
|
|
144
|
+
operator: '>=',
|
|
145
|
+
});
|
|
146
|
+
expect(parseCriterion('ap*')).toMatchObject({
|
|
147
|
+
kind: 'TEXT',
|
|
148
|
+
operator: '=',
|
|
149
|
+
});
|
|
150
|
+
expect(parseCriterion('>b')).toMatchObject({
|
|
151
|
+
kind: 'TEXT',
|
|
152
|
+
operator: '>',
|
|
153
|
+
pattern: null,
|
|
154
|
+
value: 'b',
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('rejects wildcard criteria over 255 characters but not long literals', () => {
|
|
159
|
+
const wildcard = parseSheetFormulaCriterion(`${'a'.repeat(300)}*`, 'UTC');
|
|
160
|
+
expect(wildcard.ok).toBe(false);
|
|
161
|
+
if (!wildcard.ok) {
|
|
162
|
+
expect(wildcard.result.error?.code).toBe('INVALID_VALUE');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
expect(parseSheetFormulaCriterion('a'.repeat(300), 'UTC').ok).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('criterion matching', () => {
|
|
170
|
+
const mixed = [1, 2, '3', 'x', true, false, null, '', '2026-01-05'];
|
|
171
|
+
|
|
172
|
+
it('matches numbers and numeric text, never booleans or blanks', () => {
|
|
173
|
+
expect(getMatchedValues('>1', mixed)).toEqual([2, '3']);
|
|
174
|
+
expect(getMatchedValues(1, mixed)).toEqual([1]);
|
|
175
|
+
expect(getMatchedValues('=3', mixed)).toEqual(['3']);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('lets <> match every value of another type, blanks included', () => {
|
|
179
|
+
expect(getMatchedValues('<>1', mixed)).toEqual([2, '3', 'x', true, false, null, '', '2026-01-05']);
|
|
180
|
+
expect(getMatchedValues('<>x', mixed)).toEqual([1, 2, '3', true, false, null, '', '2026-01-05']);
|
|
181
|
+
expect(getMatchedValues('<>TRUE', mixed)).toEqual([1, 2, '3', 'x', false, null, '', '2026-01-05']);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('matches blank and nonblank cells', () => {
|
|
185
|
+
expect(getMatchedValues('', mixed)).toEqual([null, '']);
|
|
186
|
+
expect(getMatchedValues('<>', mixed)).toHaveLength(mixed.length - 2);
|
|
187
|
+
expect(getMatchedValues('<', mixed)).toEqual([]);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('matches booleans only against boolean cells', () => {
|
|
191
|
+
expect(getMatchedValues(true, mixed)).toEqual([true]);
|
|
192
|
+
expect(getMatchedValues('=false', mixed)).toEqual([false]);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('matches text case-insensitively with wildcards, only on text cells', () => {
|
|
196
|
+
const cells = ['Apple', 'apricot', 'pear', 5, null, 'APPLE PIE'];
|
|
197
|
+
expect(getMatchedValues('apple', cells)).toEqual(['Apple']);
|
|
198
|
+
expect(getMatchedValues('ap*', cells)).toEqual(['Apple', 'apricot', 'APPLE PIE']);
|
|
199
|
+
expect(getMatchedValues('<>ap*', cells)).toEqual(['pear', 5, null]);
|
|
200
|
+
expect(getMatchedValues('>b', cells)).toEqual(['pear']);
|
|
201
|
+
expect(getMatchedValues('<=apple', cells)).toEqual(['Apple']);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('compares ISO dates by serial and ignores non-date cells', () => {
|
|
205
|
+
const cells = ['2026-01-01', '2026-01-02', '2026-01-02T10:00:00', '2026-01-03', 'text', 20, null];
|
|
206
|
+
expect(getMatchedValues('>=2026-01-02', cells)).toEqual(['2026-01-02', '2026-01-02T10:00:00', '2026-01-03']);
|
|
207
|
+
expect(getMatchedValues('2026-01-02', cells)).toEqual(['2026-01-02']);
|
|
208
|
+
expect(getMatchedValues('<2026-01-02', cells)).toEqual(['2026-01-01']);
|
|
209
|
+
expect(getMatchedValues('<>2026-01-02', cells)).toEqual(['2026-01-01', '2026-01-02T10:00:00', '2026-01-03', 'text', 20, null]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('reads zoned datetimes in the organization time zone', () => {
|
|
213
|
+
const cells = ['2026-01-02T03:00:00.000Z'];
|
|
214
|
+
// 03:00Z is still January 1 in Toronto and already January 2 in UTC
|
|
215
|
+
expect(getMatchedValues('>=2026-01-02', cells, 'UTC')).toEqual(cells);
|
|
216
|
+
expect(getMatchedValues('>=2026-01-02', cells, 'America/Toronto')).toEqual([]);
|
|
217
|
+
expect(getMatchedValues('<2026-01-02', cells, 'America/Toronto')).toEqual(cells);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe('lookup matching vocabulary', () => {
|
|
222
|
+
it('classifies lookup values', () => {
|
|
223
|
+
expect(getSheetFormulaLookupValueClass(null)).toBe('BLANK');
|
|
224
|
+
expect(getSheetFormulaLookupValueClass('')).toBe('BLANK');
|
|
225
|
+
expect(getSheetFormulaLookupValueClass(1)).toBe('NUMBER');
|
|
226
|
+
expect(getSheetFormulaLookupValueClass('1.5')).toBe('NUMBER');
|
|
227
|
+
expect(getSheetFormulaLookupValueClass(true)).toBe('BOOLEAN');
|
|
228
|
+
expect(getSheetFormulaLookupValueClass('abc')).toBe('TEXT');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('compares for equality within one type class, ignoring case', () => {
|
|
232
|
+
expect(sheetFormulaLookupValuesEqual('Apple', 'apple')).toBe(true);
|
|
233
|
+
expect(sheetFormulaLookupValuesEqual(1, '1')).toBe(true);
|
|
234
|
+
expect(sheetFormulaLookupValuesEqual(1, true)).toBe(false);
|
|
235
|
+
expect(sheetFormulaLookupValuesEqual(true, true)).toBe(true);
|
|
236
|
+
expect(sheetFormulaLookupValuesEqual(null, null)).toBe(false);
|
|
237
|
+
expect(sheetFormulaLookupValuesEqual('', '')).toBe(false);
|
|
238
|
+
expect(sheetFormulaSwitchValuesEqual(null, '')).toBe(true);
|
|
239
|
+
expect(sheetFormulaSwitchValuesEqual('A', 'a')).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('orders numbers before text before booleans', () => {
|
|
243
|
+
const sorted = ['b', true, 10, 'A', 2, false].sort(compareSheetFormulaLookupValues);
|
|
244
|
+
expect(sorted).toEqual([2, 10, 'A', 'b', false, true]);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('builds one hash key per equal value', () => {
|
|
248
|
+
expect(getSheetFormulaLookupValueKey('Apple')).toBe(getSheetFormulaLookupValueKey('APPLE'));
|
|
249
|
+
expect(getSheetFormulaLookupValueKey(1)).toBe(getSheetFormulaLookupValueKey('1'));
|
|
250
|
+
expect(getSheetFormulaLookupValueKey(1)).not.toBe(getSheetFormulaLookupValueKey(true));
|
|
251
|
+
expect(getSheetFormulaLookupValueKey('n1')).not.toBe(getSheetFormulaLookupValueKey(1));
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('uses wildcards only for text keys when enabled', () => {
|
|
255
|
+
const wildcard = getSheetFormulaLookupMatcher('ap*', true);
|
|
256
|
+
const literal = getSheetFormulaLookupMatcher('ap*', false);
|
|
257
|
+
const numeric = getSheetFormulaLookupMatcher(5, true);
|
|
258
|
+
if (!wildcard.ok || !literal.ok || !numeric.ok) {
|
|
259
|
+
throw new Error('Matchers must compile.');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
expect(wildcard.matches('Apple')).toBe(true);
|
|
263
|
+
expect(wildcard.matches(5)).toBe(false);
|
|
264
|
+
expect(literal.matches('Apple')).toBe(false);
|
|
265
|
+
expect(literal.matches('AP*')).toBe(true);
|
|
266
|
+
expect(numeric.matches('5')).toBe(true);
|
|
267
|
+
expect(getSheetFormulaLookupMatcher(`${'x'.repeat(300)}*`, true).ok).toBe(false);
|
|
268
|
+
});
|
|
269
|
+
});
|