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
package/README.md CHANGED
@@ -8,7 +8,8 @@
8
8
 
9
9
  <a href="https://www.npmjs.com/package/hikoutei">npm package</a> ·
10
10
  <a href="https://github.com/ManddarinShop/Hikoutei/issues">Issues</a> ·
11
- <a href="apps-script/gateway/Code.gs">Apps Script gateway</a>
11
+ <a href="docs/quick-start.md">Quick start</a> ·
12
+ <a href="apps-script/gateway/Code.gs">Legacy Apps Script gateway</a>
12
13
 
13
14
  [![npm version](https://img.shields.io/npm/v/hikoutei?style=flat-square)](https://www.npmjs.com/package/hikoutei)
14
15
  [![license](https://img.shields.io/npm/l/hikoutei?style=flat-square)](LICENSE)
@@ -19,7 +20,8 @@
19
20
  Hikoutei helps TypeScript and Node.js applications use Google Sheets as a
20
21
  human-friendly part of an MVP or internal workflow. Your application works
21
22
  with typed entities and local SQLite; changes can be delivered to Google
22
- Sheets asynchronously through the included Apps Script gateway.
23
+ Sheets asynchronously through a service-account Google Sheets provider (or the
24
+ legacy Apps Script gateway when no service account is available).
23
25
 
24
26
  Hikoutei is intentionally focused. It is not a general-purpose database
25
27
  replacement, a Prisma/JPA clone, or a general Google Sheets API wrapper.
@@ -114,6 +116,42 @@ Google Sheets synchronization is a service-side concern. Applications do not
114
116
  import a gateway client, pass Sheet routes to `createTypedSheets()`, call
115
117
  `setupSheets()`, or choose an operation for each write.
116
118
 
119
+ ### Service-account direct provider (recommended)
120
+
121
+ The preferred production path uses the internal `googleSheetsApi` bootstrap
122
+ option with the Google Sheets REST API directly — no Apps Script at all. The
123
+ provider provisions the registered tabs, writes outbound effects, reads table
124
+ values, assigns row anchors, and observes human edits, all with one service
125
+ account:
126
+
127
+ 1. Create a Google Cloud service account with the
128
+ `https://www.googleapis.com/auth/spreadsheets` scope and share the target
129
+ spreadsheet with its email as an Editor: the provider creates tabs, writes
130
+ effect rows and receipt records, and manages row anchors, so Viewer access
131
+ is not enough. Enable the Google Sheets API for the Cloud project.
132
+ 2. Keep the service-account key file path in
133
+ `GOOGLE_APPLICATION_CREDENTIALS` on the server, and the spreadsheet ID in
134
+ an untracked secret store. Never put the key in browser code or Git.
135
+ 3. Start the internal sync bootstrap with `googleSheetsApi` configured. It
136
+ creates and verifies headers on the registered tabs, then starts outbox
137
+ delivery and User_Input polling.
138
+
139
+ Sheet consistency does not come from cross-request Sheet transactions; it
140
+ comes from the hidden effect-receipt tab, effect-id/payload-hash dedupe, the
141
+ SQLite durable outbox, fencing, field-level compare-and-set evidence, and
142
+ postcondition recovery. The service-account path never logs credentials,
143
+ spreadsheet IDs, URLs, or payloads; it spaces request starts at 1,100 ms per
144
+ class (reads and writes separately) to stay inside Google's quota windows, and
145
+ it keeps the same SQLite-authoritative model: `flush()` commits locally,
146
+ delivery is asynchronous, and every write is receipted and recovered through
147
+ the same effect worker.
148
+
149
+ ### Apps Script gateway (legacy, no service account)
150
+
151
+ Deployments that cannot use a service account can keep the legacy Apps Script
152
+ gateway. It remains fully supported but is deprecated: new setups should
153
+ prefer the service-account direct provider.
154
+
117
155
  1. Copy [`apps-script/gateway/Code.gs`](apps-script/gateway/Code.gs) into a
118
156
  spreadsheet-bound Apps Script project and deploy it as a Web App. Paste the
119
157
  deployed `/exec` URL into the `TYPED_SHEETS_GATEWAY_URL` constant in
@@ -124,23 +162,58 @@ import a gateway client, pass Sheet routes to `createTypedSheets()`, call
124
162
  `TYPED_SHEETS_GATEWAY_SHARED_SECRET`, and
125
163
  `TYPED_SHEETS_GATEWAY_SHEET_ID` in an untracked server environment or secret
126
164
  store. Never put the shared secret in browser code or Git.
127
- 3. Start the internal sync bootstrap. It validates the private route/ownership
128
- configuration, provisions and verifies headers, then starts outbox delivery
129
- and User_Input polling.
130
-
131
- The MVP path is a single `Code.gs` file: it requires no `appsscript.json`
132
- manifest, no Apps Script Advanced Sheets Service, no Google Cloud Sheets API
133
- activation, and no service account. Sheet consistency does not come from
165
+ 3. Start the internal sync bootstrap with `appsScript` configured. It
166
+ validates the private route/ownership configuration, provisions and
167
+ verifies headers, then starts outbox delivery and User_Input polling.
168
+
169
+ **Migrating from the gateway to the service account:** share the spreadsheet
170
+ with the service account, switch the internal bootstrap option from
171
+ `appsScript` to `googleSheetsApi`, and remove the three `TYPED_SHEETS_GATEWAY_*`
172
+ environment variables. The provider reads and writes the same tabs, receipt
173
+ sheet, and anchor metadata, so existing spreadsheets keep working without
174
+ re-provisioning.
175
+
176
+ The current legacy Apps Script runtime writes append batches unconditionally
177
+ through the Apps Script Advanced Sheets Service; there is no runtime
178
+ enablement switch. The bundled [`appsscript.json`](apps-script/gateway/appsscript.json)
179
+ manifest (Sheets v4 advanced service enabled) and Google Cloud Sheets API
180
+ activation in the script's Cloud project are therefore mandatory for the
181
+ current temporary append path. A legacy `Code.gs`-only deployment that runs
182
+ only on built-in `SpreadsheetApp` services must first restore the commented
183
+ rollback block in
184
+ `src/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.ts`,
185
+ which reverts append target writes to the built-in services path. No service
186
+ account is required. Sheet consistency does not come from
134
187
  cross-request Sheet transactions; it comes from the Apps Script script lock,
135
188
  the hidden effect-receipt tab, effect-id/payload-hash dedupe, the SQLite
136
189
  durable outbox, fencing, and postcondition recovery.
137
190
 
138
- The gateway must be deployed with an access audience that can reach the
139
- service; an external server normally requires **Anyone**. Use the deployed
140
- `/exec` URL, not the editor-only `/dev` URL. When `Code.gs` changes, update the
141
- existing Web App deployment with a new version. Live Google calls are opt-in;
142
- fake gateways and SQLite fixtures are the normal verification path.
143
- The detailed setup and troubleshooting steps are in the [Quick start](docs/quick-start.md).
191
+ ### Full direct provider (service account)
192
+
193
+ The internal sync bootstrap also supports a full direct mode: one Google
194
+ Sheets API provider (the `googleSheetsApi` internal option) owns provisioning,
195
+ outbound effects (fast append, guarded update/delete, receipts, response-loss
196
+ recovery), values-only table reads, row anchors, and User_Input observation,
197
+ all with a service account through Application Default Credentials
198
+ (`GOOGLE_APPLICATION_CREDENTIALS` pointing at a service-account key shared on
199
+ the spreadsheet). No Apps Script deployment is required. The provider never
200
+ logs credentials, spreadsheet IDs, URLs, or payloads; it spaces request starts
201
+ at 1,100 ms per class (reads and writes separately) to stay inside Google's
202
+ quota windows, and it keeps the same SQLite-authoritative model: `flush()`
203
+ commits locally, delivery is asynchronous, and every write is receipted and
204
+ recovered through the same effect worker.
205
+
206
+ The direct provider is the tracked live scenario's mode. The 10,000-row
207
+ append and update/delete live evidence collected through the same REST path
208
+ is recorded in [docs/sync-bulk-write-benchmark.md](docs/sync-bulk-write-benchmark.md);
209
+ those raw-transport experiments under `scripts/bench/` are separate
210
+ measurements of the unguarded API path (no receipts, no compare-and-set), so
211
+ treat any throughput number as unverified until it is measured through the
212
+ full worker.
213
+
214
+ Live Google calls are opt-in; fake gateways and SQLite fixtures are the
215
+ normal verification path. The detailed setup and troubleshooting steps are in
216
+ the [Quick start](docs/quick-start.md).
144
217
 
145
218
  ## Documentation
146
219
 
@@ -0,0 +1,17 @@
1
+ {
2
+ "timeZone": "Etc/UTC",
3
+ "dependencies": {
4
+ "enabledAdvancedServices": [
5
+ {
6
+ "userSymbol": "Sheets",
7
+ "serviceId": "sheets",
8
+ "version": "v4"
9
+ }
10
+ ]
11
+ },
12
+ "exceptionLogging": "STACKDRIVER",
13
+ "oauthScopes": [
14
+ "https://www.googleapis.com/auth/spreadsheets"
15
+ ],
16
+ "runtimeVersion": "V8"
17
+ }
@@ -1,4 +1,12 @@
1
- /** Signed adapter tools for the registry-bound Apps Script sync gateway. */
1
+ /**
2
+ * Signed adapter tools for the registry-bound Apps Script sync gateway.
3
+ *
4
+ * @deprecated The Apps Script gateway is the legacy no-service-account
5
+ * path; the preferred `googleSheetsApi` bootstrap mode uses the full
6
+ * service-account Google Sheets provider and needs no Apps Script. The
7
+ * signed protocol and these tools remain fully supported for existing
8
+ * deployments.
9
+ */
2
10
  export { APPS_SCRIPT_OPERATION_NAMES, } from "./protocol/constants.js";
3
11
  export type { AppsScriptOperationName } from "./protocol/constants.js";
4
12
  export { canonicalSyncJson, syncSha256Hex, } from "./protocol/syncProtocol.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapter/sheets/providers/apps-script-gateway/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EACL,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,sCAAsC,EACtC,+BAA+B,EAC/B,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,2BAA2B,EAC3B,wCAAwC,GACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,uCAAuC,GACxC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,YAAY,EACV,6BAA6B,EAC7B,gCAAgC,EAChC,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,iCAAiC,EACjC,oCAAoC,EACpC,6BAA6B,GAC9B,MAAM,2CAA2C,CAAC;AACnD,YAAY,EACV,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,4CAA4C,CAAC;AACpD,YAAY,EACV,mCAAmC,EACnC,sCAAsC,EACtC,8CAA8C,EAC9C,+CAA+C,GAChD,MAAM,wCAAwC,CAAC;AAChD,YAAY,EACV,uCAAuC,EACvC,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,kDAAkD,CAAC;AAC1D,YAAY,EACV,8BAA8B,GAC/B,MAAM,yCAAyC,CAAC;AACjD,YAAY,EACV,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapter/sheets/providers/apps-script-gateway/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,aAAa,GACd,MAAM,4BAA4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CAAC;AAC1D,YAAY,EACV,8BAA8B,GAC/B,MAAM,yCAAyC,CAAC;AACjD,YAAY,EACV,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,qCAAqC,CAAC"}
@@ -1,4 +1,12 @@
1
- /** Signed adapter tools for the registry-bound Apps Script sync gateway. */
1
+ /**
2
+ * Signed adapter tools for the registry-bound Apps Script sync gateway.
3
+ *
4
+ * @deprecated The Apps Script gateway is the legacy no-service-account
5
+ * path; the preferred `googleSheetsApi` bootstrap mode uses the full
6
+ * service-account Google Sheets provider and needs no Apps Script. The
7
+ * signed protocol and these tools remain fully supported for existing
8
+ * deployments.
9
+ */
2
10
  export { APPS_SCRIPT_OPERATION_NAMES, } from "./protocol/constants.js";
3
11
  export { canonicalSyncJson, syncSha256Hex, } from "./protocol/syncProtocol.js";
4
12
  export { AppsScriptSyncGatewayError, SYNC_GATEWAY_CLIENT_ERROR_CODES, } from "./errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/adapter/sheets/providers/apps-script-gateway/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EACL,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,iBAAiB,EACjB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,sCAAsC,EACtC,+BAA+B,EAC/B,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,uCAAuC,GACxC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/adapter/sheets/providers/apps-script-gateway/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,iBAAiB,EACjB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,sCAAsC,EACtC,+BAA+B,EAC/B,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,uCAAuC,GACxC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC"}
@@ -661,7 +661,7 @@ export const EFFECT_OPERATION_SOURCE = String.raw `function (spreadsheet, args)
661
661
  return targetLayout.headers.map(function (header) { return toSheetValue_(row.cells[header]); });
662
662
  }));
663
663
  rows.forEach(function (row) {
664
- target.getRange(row.rowNumber + ":" + row.rowNumber).addDeveloperMetadata(ANCHOR_KEY, row.physicalAnchor, SpreadsheetApp.DeveloperMetadataVisibility.PROJECT);
664
+ target.getRange(row.rowNumber + ":" + row.rowNumber).addDeveloperMetadata(ANCHOR_KEY, row.physicalAnchor, SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT);
665
665
  });
666
666
  if (Array.isArray(checkboxHeaders)) checkboxHeaders.forEach(function (header) {
667
667
  var position = targetLayout.positions[header];
@@ -307,7 +307,7 @@ const OBSERVATION_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
307
307
  if (anchors.length === 0) {
308
308
  var anchor = "sync-anchor:" + Utilities.getUuid();
309
309
  targetSheet.getRange(rowNumber + ":" + rowNumber).addDeveloperMetadata(
310
- ANCHOR_KEY, anchor, SpreadsheetApp.DeveloperMetadataVisibility.PROJECT,
310
+ ANCHOR_KEY, anchor, SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT,
311
311
  );
312
312
  anchorsByRow[rowNumber] = [anchor];
313
313
  assigned += 1;
@@ -11,16 +11,24 @@ export interface AppsScriptBatchAppendOperationArgs {
11
11
  }
12
12
  export type AppsScriptBatchAppendOperation = AppsScriptOperationDefinition<AppsScriptBatchAppendOperationArgs, FastAppendRowsResult>;
13
13
  /**
14
- * Builds an idempotent append operation backed by built-in Apps Script
15
- * services only (SpreadsheetApp, LockService, PropertiesService, Utilities);
16
- * no Advanced Sheets dependency is required. The data rows and their Gateway
17
- * receipts are written under one script lock, but the target write and the
18
- * receipt write are separate flush() calls, so a crash between them can leave
19
- * a target row without a receipt; this is not a cross-request atomic batch.
20
- * A lost HTTP response is recovered by replaying the same effect ID: the
21
- * replay verifies the target row postcondition and returns applied without
22
- * adding another row, while a reused effect ID with a different payload hash
23
- * fails closed.
14
+ * Builds an idempotent append operation. The target-row write uses the
15
+ * temporary test-batch API: the reserved target range is written through the
16
+ * Apps Script Advanced Sheets service
17
+ * (Sheets.Spreadsheets.Values.batchUpdate with one RAW ValueRange) so a bulk
18
+ * pass can write up to the configured append batch in one request. Everything
19
+ * else stays on built-in Apps Script services (SpreadsheetApp, LockService,
20
+ * PropertiesService, Utilities): receipts, identity guards, visible hashing,
21
+ * date number formats, postcondition checks, authority fencing, replay, and
22
+ * recovery. The pre-test-batch built-in target write is preserved in a
23
+ * commented rollback block inside the operation source.
24
+ *
25
+ * The data rows and their Gateway receipts are written under one script lock,
26
+ * but the target write and the receipt write are separate flush() calls, so a
27
+ * crash between them can leave a target row without a receipt; this is not a
28
+ * cross-request atomic batch. A lost HTTP response is recovered by replaying
29
+ * the same effect ID: the replay verifies the target row postcondition and
30
+ * returns applied without adding another row, while a reused effect ID with a
31
+ * different payload hash fails closed.
24
32
  *
25
33
  * The registered identityField is required because this path never
26
34
  * materializes anchor metadata: replay and postcondition verification locate
@@ -1 +1 @@
1
- {"version":3,"file":"batchAppendOperation.d.ts","sourceRoot":"","sources":["../../../../../../../src/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,2DAA2D,CAAC;AAEnE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAMxF,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CACxE,kCAAkC,EAClC,oBAAoB,CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,kCAAkC,GAC1C,8BAA8B,CAOhC"}
1
+ {"version":3,"file":"batchAppendOperation.d.ts","sourceRoot":"","sources":["../../../../../../../src/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,2DAA2D,CAAC;AAEnE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAMxF,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CACxE,kCAAkC,EAClC,oBAAoB,CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,kCAAkC,GAC1C,8BAA8B,CAOhC"}
@@ -5,16 +5,24 @@ import { invalidOperationRequest, invalidOperationResponse } from "../../errors.
5
5
  import { isNormalizedCell } from "../../../../../../shared/encoding/normalizedCell.js";
6
6
  import { isRecord } from "../../../../../../shared/encoding/typeGuards.js";
7
7
  /**
8
- * Builds an idempotent append operation backed by built-in Apps Script
9
- * services only (SpreadsheetApp, LockService, PropertiesService, Utilities);
10
- * no Advanced Sheets dependency is required. The data rows and their Gateway
11
- * receipts are written under one script lock, but the target write and the
12
- * receipt write are separate flush() calls, so a crash between them can leave
13
- * a target row without a receipt; this is not a cross-request atomic batch.
14
- * A lost HTTP response is recovered by replaying the same effect ID: the
15
- * replay verifies the target row postcondition and returns applied without
16
- * adding another row, while a reused effect ID with a different payload hash
17
- * fails closed.
8
+ * Builds an idempotent append operation. The target-row write uses the
9
+ * temporary test-batch API: the reserved target range is written through the
10
+ * Apps Script Advanced Sheets service
11
+ * (Sheets.Spreadsheets.Values.batchUpdate with one RAW ValueRange) so a bulk
12
+ * pass can write up to the configured append batch in one request. Everything
13
+ * else stays on built-in Apps Script services (SpreadsheetApp, LockService,
14
+ * PropertiesService, Utilities): receipts, identity guards, visible hashing,
15
+ * date number formats, postcondition checks, authority fencing, replay, and
16
+ * recovery. The pre-test-batch built-in target write is preserved in a
17
+ * commented rollback block inside the operation source.
18
+ *
19
+ * The data rows and their Gateway receipts are written under one script lock,
20
+ * but the target write and the receipt write are separate flush() calls, so a
21
+ * crash between them can leave a target row without a receipt; this is not a
22
+ * cross-request atomic batch. A lost HTTP response is recovered by replaying
23
+ * the same effect ID: the replay verifies the target row postcondition and
24
+ * returns applied without adding another row, while a reused effect ID with a
25
+ * different payload hash fails closed.
18
26
  *
19
27
  * The registered identityField is required because this path never
20
28
  * materializes anchor metadata: replay and postcondition verification locate
@@ -24,13 +32,24 @@ import { isRecord } from "../../../../../../shared/encoding/typeGuards.js";
24
32
  export function createBatchAppendRowsOperation(request) {
25
33
  validateBatchAppendRequest(request);
26
34
  return {
27
- fn: BATCH_APPEND_OPERATION_SOURCE,
35
+ fn: APPEND_TEST_BATCH_OPERATION_SOURCE,
28
36
  args: request,
29
37
  decode: (value) => decodeBatchAppendResult(value, request.rows),
30
38
  };
31
39
  }
32
- /** Self-contained V8 source restored by Code.gs with eval. */
33
- const BATCH_APPEND_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
40
+ /**
41
+ * Self-contained V8 source restored by Code.gs with eval.
42
+ *
43
+ * TEMPORARY TEST-BATCH API: the target-row write in writeAppendRows_() uses
44
+ * the Advanced Sheets service so a bulk Apps Script pass can write a large
45
+ * append batch in one RAW ValueRange. This requires the appsscript.json
46
+ * manifest with the Sheets v4 advanced service enabled and Google Cloud
47
+ * Sheets API activation for the script's Cloud project. The commented
48
+ * rollback block at the end of this source restores the previous
49
+ * built-in-services write; no other part of the operation changes between
50
+ * the two.
51
+ */
52
+ const APPEND_TEST_BATCH_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
34
53
  var RECEIPT_SHEET_NAME = "__typed_sheets_internal_effect_receipts";
35
54
  var RECEIPT_HEADERS = ["effectId", "payloadHash", "status", "visibleHash", "visibleRevision", "updatedAt"];
36
55
  var phases = [];
@@ -396,16 +415,78 @@ const BATCH_APPEND_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
396
415
  });
397
416
  }
398
417
 
418
+ // TEMPORARY TEST-BATCH API: the append target write goes through the
419
+ // Advanced Sheets service so a bulk pass can write up to the configured
420
+ // append batch in one RAW ValueRange. The call follows the Apps Script
421
+ // Advanced Sheets signature Sheets.Spreadsheets.Values.batchUpdate(resource,
422
+ // spreadsheetId): the resource body carries the valueInputOption and the
423
+ // data array, and the spreadsheetId is the second positional path parameter.
424
+ // The rows are still reserved with the built-in insertRowsAfter first so a
425
+ // concurrent human append is shifted rather than overwritten, and the date
426
+ // columns still receive the canonical UTC number format afterwards. This
427
+ // write requires the Apps Script Advanced Sheets Service: the project needs
428
+ // the appsscript.json manifest with the Sheets v4 advanced service enabled
429
+ // and Google Cloud Sheets API activation for its Cloud project.
430
+ // Rollback: restore the commented writeAppendRows_()/toSheetValue_() block
431
+ // at the end of this source.
399
432
  function writeAppendRows_(targetSheet, range, startRow, pending) {
400
- // Reserve the rows through the spreadsheet mutation API before writing
401
- // values so a concurrent human append is shifted rather than overwritten.
402
433
  targetSheet.insertRowsAfter(startRow - 1, pending.length);
403
- targetSheet.getRange(startRow, range.startColumn, pending.length, range.columnCount).setValues(pending.map(function (entry) {
404
- return args.headers.map(function (header) { return toSheetValue_(entry.row.fields[header]); });
405
- }));
434
+ // The reserved rows are created through the built-in SpreadsheetApp
435
+ // service, but the RAW ValueRange write below goes through the Advanced
436
+ // Sheets service. Flush explicitly so the reserved target range is
437
+ // visible across that service boundary before the Values API call.
438
+ SpreadsheetApp.flush();
439
+ Sheets.Spreadsheets.Values.batchUpdate({
440
+ valueInputOption: "RAW",
441
+ data: [{
442
+ range: a1Range_(args.sheetName, range.startColumn, startRow, range.startColumn + range.columnCount - 1, startRow + pending.length - 1),
443
+ majorDimension: "ROWS",
444
+ values: pending.map(function (entry) {
445
+ return args.headers.map(function (header) { return toSheetValue_(entry.row.fields[header]); });
446
+ }),
447
+ }],
448
+ }, spreadsheet.getId());
406
449
  setDateNumberFormats_(targetSheet, range, startRow, pending);
407
450
  }
408
451
 
452
+ /** Builds a fully escaped A1 range for one sheet tab. */
453
+ function a1Range_(sheetName, startColumn, startRow, endColumn, endRow) {
454
+ return quoteA1SheetName_(sheetName) + "!" + columnLetters_(startColumn) + startRow + ":" + columnLetters_(endColumn) + endRow;
455
+ }
456
+
457
+ /** Quotes a sheet name for A1 notation, doubling any embedded single quote. */
458
+ function quoteA1SheetName_(sheetName) {
459
+ return "'" + String(sheetName).replace(/'/g, "''") + "'";
460
+ }
461
+
462
+ /** Converts a 1-based column number to A1 letters (1 -> A, 27 -> AA). */
463
+ function columnLetters_(columnNumber) {
464
+ var letters = "";
465
+ var value = columnNumber;
466
+ while (value > 0) {
467
+ var remainder = (value - 1) % 26;
468
+ letters = String.fromCharCode(65 + remainder) + letters;
469
+ value = Math.floor((value - 1) / 26);
470
+ }
471
+ return letters;
472
+ }
473
+
474
+ /**
475
+ * Excel/Sheets 1900-system serial: whole days since 1899-12-30 UTC. Canonical
476
+ * dates are always after the 1900-02-29 phantom day, so the serial is exactly
477
+ * the UTC day offset and RAW input preserves the value for the number format
478
+ * applied by setDateNumberFormats_().
479
+ */
480
+ function dateSerial_(date) {
481
+ return (date.getTime() - Date.UTC(1899, 11, 30)) / 86400000;
482
+ }
483
+
484
+ function toSheetValue_(value) {
485
+ if (value === null || value === undefined) return "";
486
+ if (value.kind === "date") return dateSerial_(new Date(value.value));
487
+ return value.value;
488
+ }
489
+
409
490
  function writeReceipts_(target, startRow, pending) {
410
491
  target.insertRowsAfter(startRow - 1, pending.length);
411
492
  var updatedAt = new Date().toISOString();
@@ -428,12 +509,42 @@ const BATCH_APPEND_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
428
509
  }
429
510
 
430
511
  function assertAppendPostcondition_(targetSheet, range, pending) {
512
+ // Batch verification: read the registered target range once and locate
513
+ // every pending row through the identity column locally, instead of
514
+ // scanning the identity column and re-reading one row per effect. A
515
+ // 1,000-row bulk append therefore costs one remote read instead of
516
+ // 2,000. The fail-closed contract is unchanged: an empty, missing, or
517
+ // duplicated identity throws, and the visible hash must still match the
518
+ // written payload exactly.
519
+ var identityColumn = args.headers.indexOf(args.identityField);
520
+ var lastRow = targetSheet.getLastRow();
521
+ var rows = lastRow >= 2
522
+ ? targetSheet.getRange(2, range.startColumn, lastRow - 1, range.columnCount).getValues()
523
+ : [];
524
+ var byIdentity = Object.create(null);
525
+ rows.forEach(function (row, index) {
526
+ var identityValue = row[identityColumn];
527
+ if (identityValue === "" || identityValue === null) return;
528
+ var identity = String(identityValue);
529
+ if (byIdentity[identity] === undefined) byIdentity[identity] = [];
530
+ byIdentity[identity].push(index + 2);
531
+ });
431
532
  pending.forEach(function (entry) {
432
- var rowNumber = findReceiptRowNumber_(targetSheet, range, entry.row);
433
- if (rowNumber === null) {
533
+ var cell = entry.row.fields[args.identityField];
534
+ var identity = cell === null || cell === undefined || cell.value === undefined
535
+ ? ""
536
+ : String(cell.value);
537
+ if (identity.length === 0) {
538
+ throw new Error("append postcondition row is unavailable for effectId: " + entry.row.effectId);
539
+ }
540
+ var matches = byIdentity[identity];
541
+ if (matches !== undefined && matches.length > 1) {
542
+ throw new Error("sync identity is duplicated: " + identity + " at rows " + matches.join(", "));
543
+ }
544
+ if (matches === undefined || matches.length === 0) {
434
545
  throw new Error("append postcondition row is unavailable for effectId: " + entry.row.effectId);
435
546
  }
436
- var values = targetSheet.getRange(rowNumber, range.startColumn, 1, range.columnCount).getValues()[0];
547
+ var values = rows[matches[0] - 2];
437
548
  var fields = Object.create(null);
438
549
  args.headers.forEach(function (header, headerIndex) {
439
550
  fields[header] = normalizedCellFromSheetValue_(values[headerIndex]);
@@ -444,12 +555,6 @@ const BATCH_APPEND_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
444
555
  });
445
556
  }
446
557
 
447
- function toSheetValue_(value) {
448
- if (value === null || value === undefined) return "";
449
- if (value.kind === "date") return new Date(value.value);
450
- return value.value;
451
- }
452
-
453
558
  function parseRange_(value) {
454
559
  var parts = value.split(":");
455
560
  var startColumn = columnNumber_(parts[0]);
@@ -471,6 +576,31 @@ const BATCH_APPEND_OPERATION_SOURCE = String.raw `function (spreadsheet, args) {
471
576
  // double-count the elapsed time.
472
577
  result.timing.phases.push({ phase: name, durationMs: durationMs });
473
578
  }
579
+
580
+ // ---------------------------------------------------------------------------
581
+ // ROLLBACK BLOCK: previous built-in-services append target write. Restore
582
+ // these two functions (and delete the Advanced Sheets writeAppendRows_() /
583
+ // date-serial toSheetValue_() above, including the explicit
584
+ // service-boundary flush inside writeAppendRows_()) to revert the temporary
585
+ // test-batch API without touching any other part of the operation.
586
+ //
587
+ // function writeAppendRows_(targetSheet, range, startRow, pending) {
588
+ // // Reserve the rows through the spreadsheet mutation API before
589
+ // // writing values so a concurrent human append is shifted rather
590
+ // // than overwritten.
591
+ // targetSheet.insertRowsAfter(startRow - 1, pending.length);
592
+ // targetSheet.getRange(startRow, range.startColumn, pending.length, range.columnCount).setValues(pending.map(function (entry) {
593
+ // return args.headers.map(function (header) { return toSheetValue_(entry.row.fields[header]); });
594
+ // }));
595
+ // setDateNumberFormats_(targetSheet, range, startRow, pending);
596
+ // }
597
+ //
598
+ // function toSheetValue_(value) {
599
+ // if (value === null || value === undefined) return "";
600
+ // if (value.kind === "date") return new Date(value.value);
601
+ // return value.value;
602
+ // }
603
+ // ---------------------------------------------------------------------------
474
604
  }`;
475
605
  function validateBatchAppendRequest(request) {
476
606
  if (request.authority !== undefined &&
@@ -1 +1 @@
1
- {"version":3,"file":"batchAppendOperation.js","sourceRoot":"","sources":["../../../../../../../src/adapter/sheets/providers/apps-script-gateway/operations/write/batchAppendOperation.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAOjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yDAAyD,CAAC;AAE5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAgB3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA2C;IAE3C,0BAA0B,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO;QACL,EAAE,EAAE,6BAA6B;QACjC,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;KAChE,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C"}
@@ -22,8 +22,10 @@ export interface AppsScriptOperationProjectionStatus {
22
22
  }
23
23
  type ProvisionedRoute = Omit<SyncGatewayProvisionRoute, "headers">;
24
24
  /**
25
- * Adapts the generic Apps Script operation transport to the sync worker's
26
- * fast and regular effect gateway boundaries.
25
+ * @deprecated Legacy Apps Script gateway adapter. The preferred
26
+ * `googleSheetsApi` bootstrap mode uses the full service-account Google
27
+ * Sheets provider and needs no Apps Script at all; this class remains for
28
+ * the deprecated `appsScript` / `googleApiWorker` modes.
27
29
  */
28
30
  export declare class AppsScriptOperationSyncGateway implements SyncSheetGateway, SyncSheetTableReaderGateway, SyncSheetObservationBatchGateway, SyncEffectWorkerFullGateway, SyncGatewayProvisioner {
29
31
  private readonly operationGateway;
@@ -1 +1 @@
1
- {"version":3,"file":"operationSyncGateway.d.ts","sourceRoot":"","sources":["../../../../../../src/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,iEAAiE,CAAC;AAYzE,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,mCAAmC,EACnC,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,oCAAoC,EACpC,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAEV,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAgB9B,iFAAiF;AACjF,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,gBAAgB,EAAE,0BAA0B,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,SAAS,kCAAkC,EAAE,CAAC;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CAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,uBAAuB,CAAC;IAkBnC,uEAAuE;IAC1D,wBAAwB,CACnC,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,SAAS,oCAAoC,EAAE,CAAC;IAU3D,qEAAqE;IACxD,gBAAgB,CAC3B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAUtC,gFAAgF;IACnE,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUzF,4EAA4E;IAC/D,eAAe,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAW7F,wEAAwE;IAC3D,gBAAgB,CAC3B,QAAQ,EAAE,SAAS,uBAAuB,EAAE,GAC3C,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;IAa3C;;;;;OAKG;IACU,cAAc,CACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,mCAAmC,CAAC;IAY/C,OAAO,CAAC,0BAA0B;CAcnC"}
1
+ {"version":3,"file":"operationSyncGateway.d.ts","sourceRoot":"","sources":["../../../../../../src/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,iEAAiE,CAAC;AAYzE,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,mCAAmC,EACnC,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,oCAAoC,EACpC,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,E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,EAAE,SAAS,wBAAwB,EAAE,GAC5C,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC;IAc1C,6EAA6E;IAChE,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAU5F,0EAA0E;IAC7D,uBAAuB,CAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,uBAAuB,CAAC;IAkBnC,uEAAuE;IAC1D,wBAAwB,CACnC,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,SAAS,oCAAoC,EAAE,CAAC;IAU3D,qEAAqE;IACxD,gBAAgB,CAC3B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAUtC,gFAAgF;IACnE,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUzF,4EAA4E;IAC/D,eAAe,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAW7F,wEAAwE;IAC3D,gBAAgB,CAC3B,QAAQ,EAAE,SAAS,uBAAuB,EAAE,GAC3C,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;IAa3C;;;;;OAKG;IACU,cAAc,CACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,mCAAmC,CAAC;IAY/C,OAAO,CAAC,0BAA0B;CAcnC"}
@@ -14,8 +14,10 @@ import { createEnsureRowAnchorsOperation, createObserveSnapshotOperation, create
14
14
  import { invalidOperationResponse } from "../errors.js";
15
15
  import { requireOperationRecord } from "../validation.js";
16
16
  /**
17
- * Adapts the generic Apps Script operation transport to the sync worker's
18
- * fast and regular effect gateway boundaries.
17
+ * @deprecated Legacy Apps Script gateway adapter. The preferred
18
+ * `googleSheetsApi` bootstrap mode uses the full service-account Google
19
+ * Sheets provider and needs no Apps Script at all; this class remains for
20
+ * the deprecated `appsScript` / `googleApiWorker` modes.
19
21
  */
20
22
  export class AppsScriptOperationSyncGateway {
21
23
  operationGateway;