hikoutei 0.3.3 → 0.3.5

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 (130) hide show
  1. package/README.md +88 -15
  2. package/apps-script/gateway/appsscript.json +17 -0
  3. package/dist/adapter/sheets/providers/apps-script-gateway/index.d.ts +9 -1
  4. package/dist/adapter/sheets/providers/apps-script-gateway/index.d.ts.map +1 -1
  5. package/dist/adapter/sheets/providers/apps-script-gateway/index.js +9 -1
  6. package/dist/adapter/sheets/providers/apps-script-gateway/index.js.map +1 -1
  7. package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.js +1 -1
  8. package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.js +1 -1
  9. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.d.ts +18 -10
  10. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.d.ts.map +1 -1
  11. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.js +157 -27
  12. package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.js.map +1 -1
  13. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.d.ts +4 -2
  14. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.d.ts.map +1 -1
  15. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js +4 -2
  16. package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js.map +1 -1
  17. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiEffectGateway.d.ts +27 -0
  18. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiEffectGateway.d.ts.map +1 -0
  19. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiEffectGateway.js +14 -0
  20. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiEffectGateway.js.map +1 -0
  21. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiSyncProvider.d.ts +156 -0
  22. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiSyncProvider.d.ts.map +1 -0
  23. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiSyncProvider.js +1138 -0
  24. package/dist/adapter/sheets/providers/google-sheets-api/GoogleSheetsApiSyncProvider.js.map +1 -0
  25. package/dist/adapter/sheets/providers/google-sheets-api/constants.d.ts +87 -0
  26. package/dist/adapter/sheets/providers/google-sheets-api/constants.d.ts.map +1 -0
  27. package/dist/adapter/sheets/providers/google-sheets-api/constants.js +97 -0
  28. package/dist/adapter/sheets/providers/google-sheets-api/constants.js.map +1 -0
  29. package/dist/adapter/sheets/providers/google-sheets-api/errors.d.ts +53 -0
  30. package/dist/adapter/sheets/providers/google-sheets-api/errors.d.ts.map +1 -0
  31. package/dist/adapter/sheets/providers/google-sheets-api/errors.js +61 -0
  32. package/dist/adapter/sheets/providers/google-sheets-api/errors.js.map +1 -0
  33. package/dist/adapter/sheets/providers/google-sheets-api/index.d.ts +18 -0
  34. package/dist/adapter/sheets/providers/google-sheets-api/index.d.ts.map +1 -0
  35. package/dist/adapter/sheets/providers/google-sheets-api/index.js +14 -0
  36. package/dist/adapter/sheets/providers/google-sheets-api/index.js.map +1 -0
  37. package/dist/adapter/sheets/providers/google-sheets-api/model/batchBuilder.d.ts +83 -0
  38. package/dist/adapter/sheets/providers/google-sheets-api/model/batchBuilder.d.ts.map +1 -0
  39. package/dist/adapter/sheets/providers/google-sheets-api/model/batchBuilder.js +413 -0
  40. package/dist/adapter/sheets/providers/google-sheets-api/model/batchBuilder.js.map +1 -0
  41. package/dist/adapter/sheets/providers/google-sheets-api/model/observation.d.ts +86 -0
  42. package/dist/adapter/sheets/providers/google-sheets-api/model/observation.d.ts.map +1 -0
  43. package/dist/adapter/sheets/providers/google-sheets-api/model/observation.js +439 -0
  44. package/dist/adapter/sheets/providers/google-sheets-api/model/observation.js.map +1 -0
  45. package/dist/adapter/sheets/providers/google-sheets-api/model/planner.d.ts +115 -0
  46. package/dist/adapter/sheets/providers/google-sheets-api/model/planner.d.ts.map +1 -0
  47. package/dist/adapter/sheets/providers/google-sheets-api/model/planner.js +522 -0
  48. package/dist/adapter/sheets/providers/google-sheets-api/model/planner.js.map +1 -0
  49. package/dist/adapter/sheets/providers/google-sheets-api/model/postcondition.d.ts +17 -0
  50. package/dist/adapter/sheets/providers/google-sheets-api/model/postcondition.d.ts.map +1 -0
  51. package/dist/adapter/sheets/providers/google-sheets-api/model/postcondition.js +99 -0
  52. package/dist/adapter/sheets/providers/google-sheets-api/model/postcondition.js.map +1 -0
  53. package/dist/adapter/sheets/providers/google-sheets-api/model/preflight.d.ts +242 -0
  54. package/dist/adapter/sheets/providers/google-sheets-api/model/preflight.d.ts.map +1 -0
  55. package/dist/adapter/sheets/providers/google-sheets-api/model/preflight.js +707 -0
  56. package/dist/adapter/sheets/providers/google-sheets-api/model/preflight.js.map +1 -0
  57. package/dist/adapter/sheets/providers/google-sheets-api/model/sheetIdAllocator.d.ts +16 -0
  58. package/dist/adapter/sheets/providers/google-sheets-api/model/sheetIdAllocator.d.ts.map +1 -0
  59. package/dist/adapter/sheets/providers/google-sheets-api/model/sheetIdAllocator.js +29 -0
  60. package/dist/adapter/sheets/providers/google-sheets-api/model/sheetIdAllocator.js.map +1 -0
  61. package/dist/adapter/sheets/providers/google-sheets-api/model/tableRead.d.ts +26 -0
  62. package/dist/adapter/sheets/providers/google-sheets-api/model/tableRead.d.ts.map +1 -0
  63. package/dist/adapter/sheets/providers/google-sheets-api/model/tableRead.js +57 -0
  64. package/dist/adapter/sheets/providers/google-sheets-api/model/tableRead.js.map +1 -0
  65. package/dist/adapter/sheets/providers/google-sheets-api/model/valueNormalization.d.ts +102 -0
  66. package/dist/adapter/sheets/providers/google-sheets-api/model/valueNormalization.d.ts.map +1 -0
  67. package/dist/adapter/sheets/providers/google-sheets-api/model/valueNormalization.js +375 -0
  68. package/dist/adapter/sheets/providers/google-sheets-api/model/valueNormalization.js.map +1 -0
  69. package/dist/adapter/sheets/providers/google-sheets-api/transport/googleSheetsApiTransport.d.ts +168 -0
  70. package/dist/adapter/sheets/providers/google-sheets-api/transport/googleSheetsApiTransport.d.ts.map +1 -0
  71. package/dist/adapter/sheets/providers/google-sheets-api/transport/googleSheetsApiTransport.js +247 -0
  72. package/dist/adapter/sheets/providers/google-sheets-api/transport/googleSheetsApiTransport.js.map +1 -0
  73. package/dist/adapter/sheets/providers/google-sheets-api/transport/rateLimiter.d.ts +47 -0
  74. package/dist/adapter/sheets/providers/google-sheets-api/transport/rateLimiter.d.ts.map +1 -0
  75. package/dist/adapter/sheets/providers/google-sheets-api/transport/rateLimiter.js +60 -0
  76. package/dist/adapter/sheets/providers/google-sheets-api/transport/rateLimiter.js.map +1 -0
  77. package/dist/application/sync/gateway/RoutedSyncGateway.d.ts +59 -0
  78. package/dist/application/sync/gateway/RoutedSyncGateway.d.ts.map +1 -0
  79. package/dist/application/sync/gateway/RoutedSyncGateway.js +86 -0
  80. package/dist/application/sync/gateway/RoutedSyncGateway.js.map +1 -0
  81. package/dist/application/sync/gateway/transportClassification.d.ts +12 -0
  82. package/dist/application/sync/gateway/transportClassification.d.ts.map +1 -1
  83. package/dist/application/sync/gateway/transportClassification.js +37 -0
  84. package/dist/application/sync/gateway/transportClassification.js.map +1 -1
  85. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts +16 -0
  86. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts.map +1 -1
  87. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js +26 -0
  88. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js.map +1 -1
  89. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts.map +1 -1
  90. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js +23 -3
  91. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js.map +1 -1
  92. package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts +15 -0
  93. package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts.map +1 -1
  94. package/dist/application/sync/outbound/effects/SyncEffectWorker.js +61 -8
  95. package/dist/application/sync/outbound/effects/SyncEffectWorker.js.map +1 -1
  96. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts +15 -0
  97. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts.map +1 -1
  98. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js +15 -0
  99. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js.map +1 -1
  100. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts +4 -0
  101. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts.map +1 -1
  102. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js +16 -0
  103. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js.map +1 -1
  104. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts +8 -0
  105. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts.map +1 -1
  106. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js +22 -2
  107. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js.map +1 -1
  108. package/dist/application/sync/service/SyncServiceBootstrap.d.ts +23 -1
  109. package/dist/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -1
  110. package/dist/application/sync/service/SyncServiceBootstrap.js +162 -8
  111. package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -1
  112. package/dist/infrastructure/storage/index.d.ts +1 -1
  113. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  114. package/dist/infrastructure/storage/index.js +1 -1
  115. package/dist/infrastructure/storage/index.js.map +1 -1
  116. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts +12 -0
  117. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts.map +1 -1
  118. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js +22 -1
  119. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js.map +1 -1
  120. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts +10 -0
  121. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts.map +1 -1
  122. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js +38 -0
  123. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js.map +1 -1
  124. package/docs/architecture.md +57 -13
  125. package/docs/ci.md +47 -23
  126. package/docs/development.md +35 -5
  127. package/docs/quick-start.md +43 -11
  128. package/docs/sync-bulk-write-benchmark.md +561 -0
  129. package/docs/write-and-synchronization-flow.md +70 -14
  130. package/package.json +6 -3
@@ -0,0 +1,439 @@
1
+ /**
2
+ * Observation model: row-anchor planning and full snapshot building.
3
+ *
4
+ * These helpers port the Apps Script observation operation's semantics to
5
+ * the REST wire shapes: nonblank rows are detected with the checkbox rule,
6
+ * anchors come from row-level developer metadata, and every cell is
7
+ * classified merged / error / formula / literal / blank with the same
8
+ * precedence and the same stableHash evidence as the Apps Script source, so
9
+ * snapshot hashes are byte-compatible across providers.
10
+ *
11
+ * Every untrusted SDK payload is validated by the preflight guards before it
12
+ * reaches this module; all functions here fail closed on drift (header
13
+ * mismatch, duplicate anchors, multi-anchor rows) exactly like the Apps
14
+ * Script source throws.
15
+ */
16
+ import { createHash, randomUUID } from "node:crypto";
17
+ import { presentValue, absentValue } from "../../../../../shared/state/index.js";
18
+ import { stableHash } from "../../../../../shared/encoding/index.js";
19
+ import { CELL_OBSERVATION_KINDS, } from "../../../../../shared/encoding/constants.js";
20
+ import { SYNC_GATEWAY_PROTOCOL_VERSIONS, SYNC_GATEWAY_SNAPSHOT_READ_MODES, } from "../../../../../application/sync/gateway/constants.js";
21
+ import { invalidProviderState } from "../errors.js";
22
+ import { columnLetters, quoteA1SheetName, parseRegisteredRange, } from "./valueNormalization.js";
23
+ import { apiCellNumberFormat, gridRowCells, parseSpreadsheetDocument, readAnchorIndex, readRegisteredHeaders, GOOGLE_SHEETS_API_OBSERVATION_FIELDS, } from "./preflight.js";
24
+ import { computedValueFromApiCell, isComputedBlankCell, observationLiteralFromApiValue, } from "./valueNormalization.js";
25
+ /**
26
+ * Reads the grids of several registered tabs in ONE `spreadsheets.get`
27
+ * call. Every requested tab must exist and return grid data; the result is
28
+ * keyed by tab name. The `fields` mask decides which metadata comes back
29
+ * (full observation mask or the lighter user_input mask); `timeoutMs`
30
+ * overrides the transport's per-request timeout for read calls.
31
+ */
32
+ export async function readTabGrids(transport, spreadsheetId, targets, fields = GOOGLE_SHEETS_API_OBSERVATION_FIELDS, timeoutMs) {
33
+ const tabs = new Map();
34
+ if (targets.length === 0)
35
+ return tabs;
36
+ const ranges = targets.map((target) => `${quoteA1SheetName(target.sheetName)}!A1:${rangeEndColumnLetters(target.registeredRange)}1048576`);
37
+ const request = {
38
+ spreadsheetId,
39
+ ranges,
40
+ fields,
41
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
42
+ };
43
+ const raw = await transport.getSpreadsheet(request);
44
+ const document = parseSpreadsheetDocument(raw, "observation grid");
45
+ for (const target of targets) {
46
+ const sheet = findSheetByTitle(document.sheets, target.sheetName);
47
+ if (sheet === undefined) {
48
+ invalidProviderState(`Registered sync sheet does not exist: ${target.sheetName}`);
49
+ }
50
+ const grid = document.grids.get(sheet.sheetId);
51
+ if (grid === undefined) {
52
+ invalidProviderState(`grid data is missing for sheet ${sheet.sheetId}`);
53
+ }
54
+ tabs.set(target.sheetName, {
55
+ sheetId: sheet.sheetId,
56
+ title: sheet.title,
57
+ grid,
58
+ merges: sheet.merges ?? [],
59
+ });
60
+ }
61
+ return tabs;
62
+ }
63
+ function findSheetByTitle(sheets, title) {
64
+ return sheets.find((sheet) => sheet.title === title);
65
+ }
66
+ /**
67
+ * Plans anchors for every nonblank data row of one tab grid. Rows with more
68
+ * than one anchor fail closed; missing anchors get a fresh
69
+ * `sync-anchor:<uuid>` value; duplicate anchors across rows are reported as
70
+ * evidence (never rewritten). Blank rows are skipped, matching the Apps
71
+ * Script ensureAnchorsFromValues_ behavior.
72
+ */
73
+ export function planRowAnchors(tab, target) {
74
+ const range = parseRegisteredRange(target.registeredRange);
75
+ const anchorsByRow = readAnchorIndex(tab.grid);
76
+ const checkboxIndexes = checkboxColumnIndexes(target.headers, target.checkboxHeaders);
77
+ const anchorRows = new Map();
78
+ let assigned = 0;
79
+ let existing = 0;
80
+ const planned = [];
81
+ for (let rowIndex = 0; rowIndex < tab.grid.rowData.length; rowIndex += 1) {
82
+ const rowNumber = tab.grid.startRow + 1 + rowIndex;
83
+ if (rowNumber < 2)
84
+ continue;
85
+ const values = gridRowCells(tab.grid, rowNumber, range.startColumn, range.columnCount);
86
+ if (isBlankRow(values, checkboxIndexes))
87
+ continue;
88
+ const anchors = anchorsByRow.get(rowNumber) ?? [];
89
+ if (anchors.length > 1) {
90
+ invalidProviderState(`row has multiple sync anchors: ${rowNumber}`);
91
+ }
92
+ const anchor = anchors[0];
93
+ if (anchor === undefined) {
94
+ const value = `sync-anchor:${randomUUID()}`;
95
+ planned.push({ rowIndex: rowNumber - 1, anchor: value });
96
+ assigned += 1;
97
+ anchorRows.set(value, [rowNumber]);
98
+ }
99
+ else {
100
+ existing += 1;
101
+ const rows = anchorRows.get(anchor) ?? [];
102
+ rows.push(rowNumber);
103
+ anchorRows.set(anchor, rows);
104
+ }
105
+ }
106
+ return {
107
+ assigned,
108
+ existing,
109
+ duplicateAnchors: duplicateAnchorsFrom(anchorRows),
110
+ planned,
111
+ };
112
+ }
113
+ /**
114
+ * Builds one full snapshot from a validated tab grid with EXACT parity to
115
+ * the Apps Script observation source: per-cell precedence merged -> error ->
116
+ * formula -> literal/blank, stableHash evidence (including stableHash(null)
117
+ * for blank cells), and a snapshotHash over the wire-shaped snapshot object
118
+ * with presence fields serialized as null.
119
+ */
120
+ export function buildSnapshotFromTab(tab, target) {
121
+ const range = parseRegisteredRange(target.registeredRange);
122
+ const headers = readRegisteredHeaders(tab.grid, range, target.headers);
123
+ const lightweight = target.readMode === SYNC_GATEWAY_SNAPSHOT_READ_MODES.USER_INPUT;
124
+ const anchorsByRow = readAnchorIndex(tab.grid);
125
+ const checkboxIndexes = checkboxColumnIndexes(headers, target.checkboxHeaders);
126
+ const merged = lightweight ? new Map() : mergedRangesFor(tab);
127
+ const rows = [];
128
+ const unanchoredRows = [];
129
+ const anchorRows = new Map();
130
+ for (let rowIndex = 0; rowIndex < tab.grid.rowData.length; rowIndex += 1) {
131
+ const rowNumber = tab.grid.startRow + 1 + rowIndex;
132
+ if (rowNumber < 2)
133
+ continue;
134
+ const values = gridRowCells(tab.grid, rowNumber, range.startColumn, range.columnCount);
135
+ if (isBlankRow(values, checkboxIndexes))
136
+ continue;
137
+ const anchors = anchorsByRow.get(rowNumber) ?? [];
138
+ if (anchors.length > 1) {
139
+ invalidProviderState(`row has multiple sync anchors: ${rowNumber}`);
140
+ }
141
+ const anchor = anchors[0];
142
+ if (anchor === undefined) {
143
+ unanchoredRows.push(rowNumber);
144
+ }
145
+ else {
146
+ const grouped = anchorRows.get(anchor) ?? [];
147
+ grouped.push(rowNumber);
148
+ anchorRows.set(anchor, grouped);
149
+ }
150
+ const cells = {};
151
+ headers.forEach((header, columnIndex) => {
152
+ const value = values[columnIndex];
153
+ const column = range.startColumn + columnIndex;
154
+ cells[header] = observeCell(value, lightweight, merged.get(`${rowNumber}:${column}`));
155
+ });
156
+ rows.push({
157
+ rowNumber,
158
+ physicalAnchor: anchor === undefined ? absentValue() : presentValue(anchor),
159
+ visibleRevision: absentValue(),
160
+ visibleHash: absentValue(),
161
+ cells,
162
+ });
163
+ }
164
+ const snapshotHash = stableHash(toWireSnapshot(target, headers, rows));
165
+ return {
166
+ protocolVersion: SYNC_GATEWAY_PROTOCOL_VERSIONS.V1,
167
+ sheetName: target.sheetName,
168
+ registeredRange: target.registeredRange,
169
+ projection: target.projection,
170
+ schemaVersion: target.schemaVersion,
171
+ headers,
172
+ rows,
173
+ snapshotHash,
174
+ unanchoredRows,
175
+ duplicateAnchors: duplicateAnchorsFrom(anchorRows),
176
+ };
177
+ }
178
+ /**
179
+ * Classifies one cell exactly like the Apps Script normalizeCellObservation_:
180
+ * the formula hash is computed from the raw formula first (so a merged anchor
181
+ * cell with a formula keeps its formulaHash), then merged / error / formula
182
+ * precedence, then the literal/blank branch with stableHash evidence.
183
+ */
184
+ function observeCell(value, lightweight, mergeRange) {
185
+ if (value === null || typeof value !== "object") {
186
+ return literalObservation(null, lightweight);
187
+ }
188
+ const record = value;
189
+ const entered = record.userEnteredValue;
190
+ const enteredRecord = recordLike(entered);
191
+ const formula = enteredRecord?.formulaValue;
192
+ const formulaHash = typeof formula === "string" && formula.length > 0
193
+ ? sha256Hex(formula)
194
+ : null;
195
+ const numberFormat = apiCellNumberFormat(value);
196
+ if (mergeRange !== undefined) {
197
+ return {
198
+ cellKind: CELL_OBSERVATION_KINDS.MERGED,
199
+ normalizedCell: null,
200
+ formulaHash: presenceOrAbsent(formulaHash),
201
+ mergeRange: presentValue(mergeRange),
202
+ errorCode: absentValue(),
203
+ stableHash: absentValue(),
204
+ };
205
+ }
206
+ if (lightweight) {
207
+ // The Apps Script lightweight branch reads raw values only: formulas
208
+ // resolve to their computed value, error cells to their error string,
209
+ // and the error regex runs against the stringified raw value.
210
+ const raw = computedValueFromApiCell(value, numberFormat);
211
+ const display = displayString(raw);
212
+ if (isDisplayedSheetError(display)) {
213
+ return {
214
+ cellKind: CELL_OBSERVATION_KINDS.ERROR,
215
+ normalizedCell: null,
216
+ formulaHash: absentValue(),
217
+ mergeRange: absentValue(),
218
+ errorCode: presentValue(display),
219
+ stableHash: absentValue(),
220
+ };
221
+ }
222
+ return literalObservation(raw, true);
223
+ }
224
+ const formatted = record.formattedValue;
225
+ if (typeof formatted === "string" && isDisplayedSheetError(formatted)) {
226
+ return {
227
+ cellKind: CELL_OBSERVATION_KINDS.ERROR,
228
+ normalizedCell: null,
229
+ formulaHash: presenceOrAbsent(formulaHash),
230
+ mergeRange: absentValue(),
231
+ errorCode: presentValue(formatted),
232
+ stableHash: absentValue(),
233
+ };
234
+ }
235
+ if (enteredRecord !== undefined && enteredRecord.errorValue !== undefined) {
236
+ return {
237
+ cellKind: CELL_OBSERVATION_KINDS.ERROR,
238
+ normalizedCell: null,
239
+ formulaHash: presenceOrAbsent(formulaHash),
240
+ mergeRange: absentValue(),
241
+ errorCode: presentValue(errorDisplayString(record)),
242
+ stableHash: absentValue(),
243
+ };
244
+ }
245
+ if (formula !== undefined) {
246
+ if (typeof formula !== "string") {
247
+ invalidProviderState("Sheet cell formulaValue is not a string");
248
+ }
249
+ return {
250
+ cellKind: CELL_OBSERVATION_KINDS.FORMULA,
251
+ normalizedCell: null,
252
+ formulaHash: presenceOrAbsent(formulaHash),
253
+ mergeRange: absentValue(),
254
+ errorCode: absentValue(),
255
+ stableHash: absentValue(),
256
+ };
257
+ }
258
+ const normalized = observationLiteralFromApiValue(entered, numberFormat);
259
+ if (normalized === undefined) {
260
+ // A non-empty userEnteredValue with no recognized value field maps to the
261
+ // Apps Script "unsupported_cell_value" error observation.
262
+ return {
263
+ cellKind: CELL_OBSERVATION_KINDS.ERROR,
264
+ normalizedCell: null,
265
+ formulaHash: absentValue(),
266
+ mergeRange: absentValue(),
267
+ errorCode: presentValue("unsupported_cell_value"),
268
+ stableHash: absentValue(),
269
+ };
270
+ }
271
+ return literalObservation(normalized, lightweight);
272
+ }
273
+ /** Converts a raw formula hash (null = no formula) to a Presence value. */
274
+ function presenceOrAbsent(value) {
275
+ return value === null ? absentValue() : presentValue(value);
276
+ }
277
+ /**
278
+ * Blank or literal observation with stableHash evidence (stableHash(null)
279
+ * included for blank cells, byte-compatible with the Apps Script codec).
280
+ */
281
+ function literalObservation(normalized, lightweight) {
282
+ return {
283
+ cellKind: normalized === null
284
+ ? CELL_OBSERVATION_KINDS.BLANK
285
+ : CELL_OBSERVATION_KINDS.LITERAL,
286
+ normalizedCell: normalized,
287
+ formulaHash: absentValue(),
288
+ mergeRange: absentValue(),
289
+ errorCode: absentValue(),
290
+ stableHash: lightweight ? absentValue() : presentValue(stableHash(normalized)),
291
+ };
292
+ }
293
+ /** Stringifies one normalized cell the way String(getValues) would. */
294
+ function displayString(normalized) {
295
+ if (normalized === null)
296
+ return "";
297
+ switch (normalized.kind) {
298
+ case "string":
299
+ return normalized.value;
300
+ case "number":
301
+ return String(normalized.value);
302
+ case "boolean":
303
+ return String(normalized.value);
304
+ case "date":
305
+ return normalized.value;
306
+ }
307
+ }
308
+ /** Apps Script isDisplayedSheetError_ regex over the display value. */
309
+ function isDisplayedSheetError(value) {
310
+ return /^#(REF!|DIV\/0!|N\/A|VALUE!|NAME\?|NUM!|ERROR!|NULL!)$/.test(value);
311
+ }
312
+ /** Resolves the display string of an error cell (formatted value or message). */
313
+ function errorDisplayString(record) {
314
+ const formatted = record.formattedValue;
315
+ if (typeof formatted === "string" && formatted.length > 0)
316
+ return formatted;
317
+ const entered = record.userEnteredValue;
318
+ const enteredRecord = recordLike(entered);
319
+ const error = enteredRecord?.errorValue;
320
+ const errorRecord = recordLike(error);
321
+ const message = errorRecord?.message;
322
+ if (typeof message === "string" && message.length > 0)
323
+ return message;
324
+ invalidProviderState("Sheet error cell has no display string");
325
+ }
326
+ /**
327
+ * Builds the wire-shaped snapshot object the Apps Script codec hashes:
328
+ * presence fields become null, rows carry visibleRevision/visibleHash nulls.
329
+ */
330
+ function toWireSnapshot(target, headers, rows) {
331
+ return {
332
+ protocolVersion: SYNC_GATEWAY_PROTOCOL_VERSIONS.V1,
333
+ sheetName: target.sheetName,
334
+ registeredRange: target.registeredRange,
335
+ projection: target.projection,
336
+ schemaVersion: target.schemaVersion,
337
+ headers,
338
+ rows: rows.map((row) => ({
339
+ rowNumber: row.rowNumber,
340
+ physicalAnchor: presenceToNull(row.physicalAnchor),
341
+ visibleRevision: null,
342
+ visibleHash: null,
343
+ cells: Object.fromEntries(headers.map((header) => {
344
+ const cell = row.cells[header];
345
+ if (cell === undefined) {
346
+ invalidProviderState(`snapshot cell is missing for header: ${header}`);
347
+ }
348
+ return [header, toWireCell(cell)];
349
+ })),
350
+ })),
351
+ };
352
+ }
353
+ /** Serializes one observed cell to the Apps Script wire shape. */
354
+ function toWireCell(cell) {
355
+ return {
356
+ cellKind: cell.cellKind,
357
+ normalizedCell: cell.normalizedCell,
358
+ formulaHash: presenceToNull(cell.formulaHash),
359
+ mergeRange: presenceToNull(cell.mergeRange),
360
+ errorCode: presenceToNull(cell.errorCode),
361
+ stableHash: presenceToNull(cell.stableHash),
362
+ };
363
+ }
364
+ function presenceToNull(presence) {
365
+ return presence.kind === "present" ? presence.value : null;
366
+ }
367
+ /** Builds the sorted duplicate-anchor evidence from an anchor grouping. */
368
+ function duplicateAnchorsFrom(anchorRows) {
369
+ return [...anchorRows.entries()]
370
+ .filter(([, rows]) => rows.length > 1)
371
+ .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
372
+ .map(([anchor, rows]) => ({
373
+ anchor,
374
+ rowNumbers: [...rows].sort((left, right) => left - right),
375
+ }));
376
+ }
377
+ /** Returns the checkbox column offsets (0-based inside the range) by header. */
378
+ function checkboxColumnIndexes(headers, checkboxHeaders) {
379
+ if (checkboxHeaders === undefined || checkboxHeaders.length === 0) {
380
+ return new Set();
381
+ }
382
+ const indexes = new Set();
383
+ for (const header of checkboxHeaders) {
384
+ const index = headers.indexOf(header);
385
+ if (index < 0) {
386
+ invalidProviderState(`checkbox header is not registered: ${header}`);
387
+ }
388
+ indexes.add(index);
389
+ }
390
+ return indexes;
391
+ }
392
+ /** Apps Script isBlankRow_ over computed values with the checkbox rule. */
393
+ function isBlankRow(values, checkboxIndexes) {
394
+ return values.every((value, index) => isComputedBlankCell(value, checkboxIndexes.has(index)));
395
+ }
396
+ /** Builds the A1 range end letters for one registered range. */
397
+ function rangeEndColumnLetters(registeredRange) {
398
+ const range = parseRegisteredRange(registeredRange);
399
+ return columnLetters(range.startColumn + range.columnCount - 1);
400
+ }
401
+ /**
402
+ * Returns the merged ranges of one tab as 1-based A1 strings by cell
403
+ * coordinate. Every covered cell maps to the A1 notation of the WHOLE
404
+ * merged range, matching the Apps Script mergedCellMap_. The ranges come
405
+ * from the sheet-level `merges` GridRange array, not from grid data.
406
+ */
407
+ function mergedRangesFor(tab) {
408
+ const byCell = new Map();
409
+ for (const merged of tab.merges) {
410
+ const a1 = mergedRangeA1(merged.startRowIndex, merged.endRowIndex, merged.startColumnIndex, merged.endColumnIndex);
411
+ for (let row = merged.startRowIndex + 1; row <= merged.endRowIndex; row += 1) {
412
+ for (let column = merged.startColumnIndex + 1; column <= merged.endColumnIndex; column += 1) {
413
+ byCell.set(`${row}:${column}`, a1);
414
+ }
415
+ }
416
+ }
417
+ return byCell;
418
+ }
419
+ /** Converts a 0-based exclusive GridRange to 1-based inclusive A1 notation. */
420
+ function mergedRangeA1(startRowIndex, endRowIndex, startColumnIndex, endColumnIndex) {
421
+ const startCell = `${columnLetters(startColumnIndex + 1)}${startRowIndex + 1}`;
422
+ const endRow = endRowIndex;
423
+ const endColumn = endColumnIndex;
424
+ if (endRow === startRowIndex + 1 && endColumn === startColumnIndex + 1) {
425
+ return startCell;
426
+ }
427
+ return `${startCell}:${columnLetters(endColumn)}${endRow}`;
428
+ }
429
+ /** sha256 hex of one formula literal (node:crypto, UTF-8). */
430
+ function sha256Hex(value) {
431
+ return createHash("sha256").update(value, "utf8").digest("hex");
432
+ }
433
+ function recordLike(value) {
434
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
435
+ return undefined;
436
+ }
437
+ return value;
438
+ }
439
+ //# sourceMappingURL=observation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation.js","sourceRoot":"","sources":["../../../../../../src/adapter/sheets/providers/google-sheets-api/model/observation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,WA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C,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAgC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * TypeScript planner: the Apps Script effect judgment semantics in TS.
3
+ *
4
+ * This module ports `effectOperationScript.ts`'s `requireEffect_`,
5
+ * `findRow_`, `currentHash_`, `validateDeletion_`, `result_`,
6
+ * `makeReceipt_`, and the apply-effects planning loop. Every decision that
7
+ * the Code.gs source makes before mutation (receipt replay, row lookup,
8
+ * create-if-missing, visible/candidate/repair guards, deletion shape) is
9
+ * reproduced here against the typed preflight context. Outcomes are
10
+ * discriminated unions, never nullable status markers.
11
+ */
12
+ import { type SyncGatewayEffect } from "../../../../../application/sync/gateway/syncGateway.js";
13
+ import type { ApplySyncEffectsRequest, SyncGatewayEffectResult } from "../../../../../application/sync/gateway/syncGateway.js";
14
+ import { type Presence } from "../../../../../shared/state/index.js";
15
+ import type { PreflightContext, PreflightRow } from "./preflight.js";
16
+ /** Receipt evidence produced by the planner for one effect. */
17
+ export interface PlannedReceipt {
18
+ readonly effectId: string;
19
+ readonly payloadHash: string;
20
+ readonly status: "applied";
21
+ readonly visibleHash: string;
22
+ readonly visibleRevision: number;
23
+ }
24
+ /** Terminal/non-terminal planner outcome for one effect. */
25
+ export type PlannedOutcome = {
26
+ readonly kind: "applied";
27
+ readonly effect: SyncGatewayEffect;
28
+ readonly rowNumber: Presence<number>;
29
+ readonly receipt: PlannedReceipt;
30
+ readonly created: boolean;
31
+ readonly deletion: boolean;
32
+ } | {
33
+ readonly kind: "already_applied";
34
+ readonly effect: SyncGatewayEffect;
35
+ readonly rowNumber: Presence<number>;
36
+ readonly receipt: PlannedReceipt;
37
+ } | {
38
+ readonly kind: "guard_mismatch";
39
+ readonly effect: SyncGatewayEffect;
40
+ readonly rowNumber: Presence<number>;
41
+ readonly reason: string;
42
+ } | {
43
+ readonly kind: "repair_reobserve";
44
+ readonly effect: SyncGatewayEffect;
45
+ readonly rowNumber: Presence<number>;
46
+ readonly reason: string;
47
+ } | {
48
+ readonly kind: "schema_error";
49
+ readonly effect: SyncGatewayEffect;
50
+ readonly rowNumber: Presence<number>;
51
+ readonly reason: string;
52
+ } | {
53
+ readonly kind: "retryable_error";
54
+ readonly effect: SyncGatewayEffect;
55
+ readonly rowNumber: Presence<number>;
56
+ readonly reason: string;
57
+ };
58
+ /** Target mutation planned for one effect (only successful write outcomes). */
59
+ export type PlanMutation = {
60
+ readonly kind: "append";
61
+ readonly row: WorkingRow;
62
+ } | {
63
+ readonly kind: "update";
64
+ readonly row: WorkingRow;
65
+ } | {
66
+ readonly kind: "delete";
67
+ readonly row: WorkingRow;
68
+ };
69
+ /** Mutable working copy of one preflight row during planning. */
70
+ export interface WorkingRow {
71
+ readonly rowNumber: number;
72
+ readonly anchor: Presence<string>;
73
+ readonly cells: Record<string, import("../../../../../domain/index.js").NormalizedCell>;
74
+ readonly identity: Presence<string>;
75
+ readonly appended: boolean;
76
+ deleted: boolean;
77
+ readonly writeFields: Record<string, import("../../../../../domain/index.js").NormalizedCell>;
78
+ }
79
+ /** Per-effect plan: outcome plus any mutation and receipt the batch needs. */
80
+ export interface EffectPlan {
81
+ readonly outcome: PlannedOutcome;
82
+ readonly mutation: PlanMutation | undefined;
83
+ readonly receipt: PlannedReceipt | undefined;
84
+ /** True when inline postcondition verification must re-read this write. */
85
+ readonly verify: boolean;
86
+ }
87
+ /**
88
+ * Plans one applyEffects request against a preflight context.
89
+ *
90
+ * All effects are planned (including beyond the transport byte budget); the
91
+ * batch builder decides which prefix is actually sent. Deleted working rows
92
+ * are removed from the anchor/identity indexes so later effects in the same
93
+ * batch observe the mutations of earlier ones.
94
+ */
95
+ export declare function planEffectBatch(request: ApplySyncEffectsRequest, context: PreflightContext): readonly EffectPlan[];
96
+ /** Runtime validation of one effect against its request route (fail closed). */
97
+ export declare function requireGatewayEffect(effect: SyncGatewayEffect, request: ApplySyncEffectsRequest, context: PreflightContext): void;
98
+ /** Validates the full-row deletion guard exactly like `validateDeletion_`. */
99
+ export declare function validateDeletion(context: PreflightContext, effect: SyncGatewayEffect): string | null;
100
+ /** Computes the visible hash of a row restricted to the effect's fields. */
101
+ export declare function currentHash(row: WorkingRow | PreflightRow, fields: Readonly<Record<string, import("../../../../../domain/index.js").NormalizedCell>>): string;
102
+ /** Builds a receipt record exactly like `makeReceipt_`. */
103
+ export declare function makeReceipt(effect: SyncGatewayEffect, visibleHash: string, visibleRevision: number): PlannedReceipt;
104
+ /** Finds a row by anchor first, then visible identity, then the targetId tail. */
105
+ export declare function findWorkingRow(byAnchor: ReadonlyMap<string, WorkingRow>, byIdentity: ReadonlyMap<string, WorkingRow>, anchor: string, targetId: string): WorkingRow | undefined;
106
+ /** Converts one preflight row into a working row for planning/probing. */
107
+ export declare function toWorkingRow(row: PreflightRow): WorkingRow;
108
+ export declare function isDeletionEffect(effectKind: string): boolean;
109
+ /** Encodes a planned outcome as a gateway result (Apps Script `result_`). */
110
+ export declare function encodeOutcomeResult(outcome: PlannedOutcome): SyncGatewayEffectResult;
111
+ /** Builds a schema_error result without any receipt-backed evidence. */
112
+ export declare function encodeSchemaErrorResult(effect: SyncGatewayEffect, reason: string): SyncGatewayEffectResult;
113
+ /** Applies the deferred-mode postcondition relabeling for applied results. */
114
+ export declare function withDeferredPostcondition(result: SyncGatewayEffectResult): SyncGatewayEffectResult;
115
+ //# sourceMappingURL=planner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../../../../src/adapter/sheets/providers/google-sheets-api/model/planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA0B,KAAK,iBAAiB,EAAE,MAAM,wDA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