hikoutei 0.10.17-dev → 0.10.19-dev
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/README.ja.md +73 -215
- package/README.ko.md +56 -195
- package/README.md +64 -331
- package/dist/contracts/api/entity.d.ts +10 -5
- package/dist/contracts/api/entity.d.ts.map +1 -1
- package/dist/contracts/api/entity.js +18 -10
- package/dist/contracts/api/entity.js.map +1 -1
- package/dist/contracts/sync-orm/mapping/identity.d.ts +10 -5
- package/dist/contracts/sync-orm/mapping/identity.d.ts.map +1 -1
- package/dist/contracts/sync-orm/mapping/identity.js +25 -11
- package/dist/contracts/sync-orm/mapping/identity.js.map +1 -1
- package/dist/orm/mapping/observationMapping.d.ts +4 -4
- package/dist/orm/mapping/observationMapping.d.ts.map +1 -1
- package/dist/orm/mapping/observationMapping.js +2 -1
- package/dist/orm/mapping/observationMapping.js.map +1 -1
- package/dist/orm/persistence/support/helpers.d.ts +5 -1
- package/dist/orm/persistence/support/helpers.d.ts.map +1 -1
- package/dist/orm/persistence/support/helpers.js +16 -6
- package/dist/orm/persistence/support/helpers.js.map +1 -1
- package/dist/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.js +36 -4
- package/dist/persistence/providers/mikro-orm/api/MikroOrmScalarPersistenceProvider.js.map +1 -1
- package/dist/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.js +5 -0
- package/dist/persistence/providers/mikro-orm/engine/MikroOrmScalarEntityRuntime.js.map +1 -1
- package/dist/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js +18 -4
- package/dist/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js.map +1 -1
- package/dist/sync-engine/api/internalEntityManager.d.ts.map +1 -1
- package/dist/sync-engine/api/internalEntityManager.js +3 -1
- package/dist/sync-engine/api/internalEntityManager.js.map +1 -1
- package/dist/sync-engine/orm/persistence/scalar/unitOfWork.d.ts.map +1 -1
- package/dist/sync-engine/orm/persistence/scalar/unitOfWork.js +102 -9
- package/dist/sync-engine/orm/persistence/scalar/unitOfWork.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
+
<img src="assets/hikoutei-icon.png" alt="Hikoutei" width="220" />
|
|
6
|
+
|
|
5
7
|
# Hikoutei
|
|
6
8
|
|
|
7
9
|
**Keep your app fast with SQLite. Keep your workflow visible in Google Sheets.**
|
|
@@ -34,46 +36,6 @@ collaboration.
|
|
|
34
36
|
> and it does not treat Google Sheets as the authoritative application
|
|
35
37
|
> database. SQLite is the source of truth; Sheets is the human-facing view.
|
|
36
38
|
|
|
37
|
-
## Quick start
|
|
38
|
-
|
|
39
|
-
Define a scalar entity and use the local SQLite authority through a
|
|
40
|
-
request-local manager.
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { createTypedSheets, defineTypedSheetsEntity } from "hikoutei";
|
|
44
|
-
|
|
45
|
-
const User = defineTypedSheetsEntity({
|
|
46
|
-
name: "User",
|
|
47
|
-
tableName: "users",
|
|
48
|
-
properties: {
|
|
49
|
-
id: { type: "string", primary: true },
|
|
50
|
-
name: { type: "string" },
|
|
51
|
-
age: { type: "number" },
|
|
52
|
-
active: { type: "boolean" },
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const hikoutei = await createTypedSheets({
|
|
57
|
-
dbName: "./hikoutei.sqlite",
|
|
58
|
-
entities: [User],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const em = hikoutei.em.fork();
|
|
62
|
-
const user = em.create(User, { id: "u1", name: "Ada", age: 36, active: true });
|
|
63
|
-
em.persist(user);
|
|
64
|
-
await em.flush();
|
|
65
|
-
|
|
66
|
-
user.name = "Ada Lovelace";
|
|
67
|
-
await em.flush();
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**What happens to the Sheet?** The write commits to local SQLite immediately —
|
|
71
|
-
the application request never waits on Google. When the sync service is
|
|
72
|
-
enabled, Hikoutei later projects the entity to the registered Google Sheet in
|
|
73
|
-
the background. Human edits made in the sheet are observed, validated, and
|
|
74
|
-
either accepted back into SQLite or recorded as conflicts, never silently
|
|
75
|
-
overwritten.
|
|
76
|
-
|
|
77
39
|
## Why Hikoutei?
|
|
78
40
|
|
|
79
41
|
- Define typed entities instead of manually converting Sheet rows.
|
|
@@ -82,29 +44,6 @@ overwritten.
|
|
|
82
44
|
- Detect unexpected column changes and duplicate headers.
|
|
83
45
|
- Avoid overwriting newer Sheet edits during conflicting updates.
|
|
84
46
|
|
|
85
|
-
## When to use Hikoutei
|
|
86
|
-
|
|
87
|
-
Hikoutei is a good fit for:
|
|
88
|
-
|
|
89
|
-
- MVPs and prototypes where a spreadsheet is part of the product workflow.
|
|
90
|
-
- Internal tools and low-traffic administrative applications.
|
|
91
|
-
- Teams that want typed application data while keeping Sheets easy for people
|
|
92
|
-
to inspect.
|
|
93
|
-
- Services that can use SQLite locally and accept asynchronous Sheet updates.
|
|
94
|
-
|
|
95
|
-
## When to choose something else
|
|
96
|
-
|
|
97
|
-
Use a conventional database and direct Google APIs when you need:
|
|
98
|
-
|
|
99
|
-
- Strong transactions across many rows or services.
|
|
100
|
-
- High write throughput or many concurrent writers.
|
|
101
|
-
- Complex queries, joins, or reporting workloads.
|
|
102
|
-
- Multi-server or multi-region coordination.
|
|
103
|
-
- Immediate read-after-write consistency in Google Sheets.
|
|
104
|
-
- Google Sheets to be the primary database for the application.
|
|
105
|
-
|
|
106
|
-
## Is Hikoutei the right abstraction for you?
|
|
107
|
-
|
|
108
47
|
Hikoutei does not replace `google-spreadsheet` or `@googleapis/sheets` — it
|
|
109
48
|
sits one level above them. If you only need raw spreadsheet access, use the API
|
|
110
49
|
client directly.
|
|
@@ -119,289 +58,83 @@ client directly.
|
|
|
119
58
|
| Direct row and cell manipulation | Limited | ✅ | ✅ |
|
|
120
59
|
| Full Google Sheets API access | Provider only | Partial | ✅ |
|
|
121
60
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
Google Sheets synchronization is a service-side concern. Applications do not
|
|
125
|
-
import a provider client, pass Sheet routes to `createTypedSheets()`, or choose
|
|
126
|
-
an operation for each write — `CreateTypedSheetsOptions` fields (`dbName`,
|
|
127
|
-
`entities`, `providerOptions`) are all optional. The sync runtime uses one
|
|
128
|
-
internal Google Sheets API provider with a service account — no Apps Script
|
|
129
|
-
deployment. Sync auto-start is selected by `HIKOUTEI_SYNC_SPREADSHEET_URL`
|
|
130
|
-
plus `GOOGLE_APPLICATION_CREDENTIALS`. Optional `providerOptions` tunes the
|
|
131
|
-
sync-path provider (telemetry/timeouts; inert when local-only), and
|
|
132
|
-
`createTypedSheetsWithSync()` exposes the same options with a richer result
|
|
133
|
-
for existing-sheet adoption.
|
|
134
|
-
|
|
135
|
-
**Fastest path:** install the gcloud CLI, then run `npx hikoutei setup` from your
|
|
136
|
-
project directory. On an interactive terminal it offers (press Enter) to
|
|
137
|
-
start `gcloud auth login --enable-gdrive-access --force` for you when the
|
|
138
|
-
active account is missing or lacks Drive access — you only complete the
|
|
139
|
-
browser approval yourself. (In `--yes`, CI, or non-TTY sessions, run that
|
|
140
|
-
login command yourself first.) Setup then creates the project, service
|
|
141
|
-
account, and key, creates a spreadsheet owned by your account, shares it
|
|
142
|
-
with the service account as an Editor, verifies service-account access, and
|
|
143
|
-
writes `GOOGLE_APPLICATION_CREDENTIALS` plus `HIKOUTEI_SYNC_SPREADSHEET_URL`
|
|
144
|
-
into your `.env`. The human access token is used in memory only and never
|
|
145
|
-
stored. Automatic setup runs on macOS and Linux; on Windows a non-dry-run
|
|
146
|
-
is refused before any mutation and manual setup is available. Interrupted runs resume from a local checkpoint
|
|
147
|
-
(`.hikoutei-setup-state.json`); a spreadsheet create whose outcome is
|
|
148
|
-
unknown is reconciled by its creation marker on the next run and setup
|
|
149
|
-
never creates a second spreadsheet (inspect Drive and rerun if setup
|
|
150
|
-
reports `sheet_create_uncertain`, and a create rejected up front with
|
|
151
|
-
HTTP 400/403 plus a confirmed-zero marker lookup rolls back to `key_ready`
|
|
152
|
-
so a corrected rerun starts a fresh marker). Sharing is write-ahead too:
|
|
153
|
-
`spreadsheet_share_started` is persisted before the idempotent SA writer
|
|
154
|
-
permission ensure and `spreadsheet_shared` after it, so a crash between
|
|
155
|
-
the remote permission mutation and the checkpoint write resumes the
|
|
156
|
-
ensure on the next run and never creates a second spreadsheet. The
|
|
157
|
-
service-account key is
|
|
158
|
-
created under a write-ahead contract too: the user-managed key list is
|
|
159
|
-
recorded as a baseline before the single gcloud key create, and
|
|
160
|
-
`key_create_started`/`key_ready` checkpoints let a crashed run recover a
|
|
161
|
-
staged or installed key instead of creating a second one. Only the
|
|
162
|
-
invocation that just persisted `key_create_started` may issue the one key
|
|
163
|
-
create; resumed runs are reconcile-only and, when no credential and no
|
|
164
|
-
post-baseline key are visible, poll the key list plus staged/final
|
|
165
|
-
evidence for up to two minutes (2, 4, 8, 16, 30, 30, 30 s) before failing
|
|
166
|
-
with `key_create_uncertain` — the create is never retried automatically.
|
|
167
|
-
An unmatched user-managed key with no local credential is never deleted
|
|
168
|
-
automatically — setup fails with `key_create_uncertain` and you inspect
|
|
169
|
-
the key list in the Google Cloud console before rerunning (a
|
|
170
|
-
verified-absent state requires removing the setup state file to reset the
|
|
171
|
-
key checkpoint); reused keys are enforced to owner-only mode 600. An exclusive lock directory
|
|
172
|
-
(`.hikoutei-setup-state.json.lock`) prevents concurrent runs and is never
|
|
173
|
-
removed automatically: a crash leaves an empty lock directory behind, and
|
|
174
|
-
removing it manually is required only when you are certain no setup is
|
|
175
|
-
running. Starting fresh requires removing or moving both the checkpoint and
|
|
176
|
-
the key file, or passing `--project` to recover an existing key —
|
|
177
|
-
checkpointed or identity-matched cloud resources are reused, and setup
|
|
178
|
-
never deletes cloud resources. The manual steps below remain available for
|
|
179
|
-
advanced setups.
|
|
180
|
-
|
|
181
|
-
**Setup progress.** `hikoutei setup` reports step-by-step progress to
|
|
182
|
-
**stderr** across the ten setup phases (cloud auth, Drive access, project,
|
|
183
|
-
APIs, service account, service-account key, spreadsheet, share,
|
|
184
|
-
service-account access, output): an **overall bar** advances only when a
|
|
185
|
-
phase actually completes — it is never an ETA and never guesses a
|
|
186
|
-
percentage — and a **detail line** shows the bounded propagation checks
|
|
187
|
-
(how many of the eight key/access checks have run) and the known 2, 4, 8,
|
|
188
|
-
16, 30, 30, 30 s waits, with a fixed `working…` label for unknown-duration
|
|
189
|
-
steps. On an interactive terminal the four-line block redraws in place;
|
|
190
|
-
in CI, non-TTY, or `NO_COLOR` sessions one static line is printed per
|
|
191
|
-
phase/retry event with no control sequences. Progress pauses and the
|
|
192
|
-
block is cleared during the interactive `gcloud auth login` handoff and
|
|
193
|
-
resumes with the retry. Progress never prints credentials, tokens, keys,
|
|
194
|
-
project ids, emails, paths, or raw command output, and it can never
|
|
195
|
-
change the setup result or exit code; `--dry-run` prints the command
|
|
196
|
-
plan only.
|
|
197
|
-
|
|
198
|
-
**Keep setup artifacts out of Git.** `hikoutei setup` writes its defaults
|
|
199
|
-
into the current directory: the service-account key
|
|
200
|
-
(`hikoutei-service-account.json`, owner-only mode 600 — a secret), the
|
|
201
|
-
resume checkpoint (`.hikoutei-setup-state.json` and its `.tmp`/unique-temp
|
|
202
|
-
and `.lock` siblings), private key staging/cleanup directories
|
|
203
|
-
(`.hikoutei-key-stage-*`, `.hikoutei-key-cleanup-*`), and
|
|
204
|
-
`.hikoutei-env-*` temporary env writes. The repository's `.gitignore`
|
|
205
|
-
already ignores these defaults, so a plain `git add .` does not pick them
|
|
206
|
-
up. A `.gitignore` is **not a security boundary**, though: it only keeps
|
|
207
|
-
untracked files out of `git add`, and it does not protect files that are
|
|
208
|
-
already tracked (remove a mistakenly tracked key from history and rotate
|
|
209
|
-
it — delete the user-managed key in the Cloud console and rerun setup).
|
|
210
|
-
When you use a custom `--output` or keep the key or checkpoint at custom
|
|
211
|
-
paths, add those exact paths to your application's ignore rules and never
|
|
212
|
-
commit them.
|
|
213
|
-
|
|
214
|
-
### Env-driven sync auto-start
|
|
215
|
-
|
|
216
|
-
Set the spreadsheet URL in the environment and `createTypedSheets()` starts
|
|
217
|
-
the Sheets sync internally — `flush()` then flows to Google Sheets through
|
|
218
|
-
the outbox worker with no per-call setup:
|
|
61
|
+
## Installation
|
|
219
62
|
|
|
220
63
|
```sh
|
|
221
|
-
|
|
222
|
-
GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```ts
|
|
226
|
-
const hikoutei = await createTypedSheets({ dbName: "./hikoutei.sqlite", entities: [User] });
|
|
64
|
+
npm install hikoutei @mikro-orm/core @mikro-orm/sql
|
|
227
65
|
```
|
|
228
66
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
shared on the spreadsheet (the error tells you which email to share).
|
|
233
|
-
|
|
234
|
-
### Manual service-account setup
|
|
235
|
-
|
|
236
|
-
1. **Create a service account.** Enable the Google Sheets API in a Cloud
|
|
237
|
-
project, create a service account with the
|
|
238
|
-
`https://www.googleapis.com/auth/spreadsheets` scope, and share the target
|
|
239
|
-
spreadsheet with its email as an **Editor**. The provider creates tabs,
|
|
240
|
-
writes effect rows and receipt records, and manages row anchors, so Viewer
|
|
241
|
-
access is not enough.
|
|
242
|
-
2. **Keep the key server-side.** Put the service-account key path in
|
|
243
|
-
`GOOGLE_APPLICATION_CREDENTIALS` on the server and the spreadsheet ID in an
|
|
244
|
-
untracked secret store. Never put the key in browser code or Git: add the
|
|
245
|
-
key path (and any custom `.env`/checkpoint paths) to the application's
|
|
246
|
-
`.gitignore` — the defaults created by `hikoutei setup` are already
|
|
247
|
-
ignored, but a `.gitignore` is not a security boundary and does not
|
|
248
|
-
protect already-tracked files.
|
|
249
|
-
3. **Run the application normally.** Start the app with
|
|
250
|
-
`GOOGLE_APPLICATION_CREDENTIALS` and `HIKOUTEI_SYNC_SPREADSHEET_URL` set;
|
|
251
|
-
`createTypedSheets()` detects them and starts the internal sync bootstrap —
|
|
252
|
-
it creates and verifies headers on the registered tabs, then starts outbox
|
|
253
|
-
delivery and User_Input polling. Pass `providerOptions` only when sync-path
|
|
254
|
-
tuning is needed; there is no internal bootstrap to start by hand.
|
|
255
|
-
|
|
256
|
-
> **Legacy spreadsheet note.** Spreadsheets provisioned by the old Apps Script
|
|
257
|
-
> provider with developer-metadata row anchors are not migrated: `User_Input`
|
|
258
|
-
> tabs now require the `__hikoutei_row_id` system column, so legacy tabs must
|
|
259
|
-
> be re-provisioned. Current provisioning also adds one internal formula
|
|
260
|
-
> column, `__hikoutei_row_check`, directly after each `User_Input` tab's
|
|
261
|
-
> registered range: Hikoutei writes a change-detection formula per row, and
|
|
262
|
-
> polling reads only that column to spot human edits (rows without it fall
|
|
263
|
-
> back to full reads). Do not edit, sort, or delete the column or its
|
|
264
|
-
> formulas.
|
|
265
|
-
|
|
266
|
-
Hikoutei uses a durable local outbox, idempotent delivery, and conflict-aware
|
|
267
|
-
updates so temporary API failures do not lose committed application writes. The
|
|
268
|
-
provider never logs credentials, spreadsheet IDs, URLs, or payloads, and it
|
|
269
|
-
spaces request starts to stay inside Google's quota windows. See the
|
|
270
|
-
[internal consistency model](website/guide/internal-consistency.md) for the
|
|
271
|
-
detailed state machine and recovery rules.
|
|
272
|
-
|
|
273
|
-
Live Google calls are opt-in; fake providers and SQLite fixtures are the normal
|
|
274
|
-
verification path. The detailed setup and troubleshooting steps are in the
|
|
275
|
-
[Quick start](website/guide/quick-start.md) and [Google Sheets setup](website/guide/setup.md) —
|
|
276
|
-
including the credential pool (`--sa-count`) and API quota guidance when
|
|
277
|
-
polling-heavy workloads hit HTTP 429.
|
|
67
|
+
Installing the library does not touch Google Cloud — it runs local-only
|
|
68
|
+
(SQLite) by default. Run the setup command below only when you want Sheet
|
|
69
|
+
sync.
|
|
278
70
|
|
|
279
|
-
##
|
|
71
|
+
## Setup (Google Sheets sync)
|
|
280
72
|
|
|
281
|
-
|
|
282
|
-
(packageManager `pnpm@11.1.2`):
|
|
73
|
+
One-time, interactive. Install the gcloud CLI, then:
|
|
283
74
|
|
|
284
75
|
```sh
|
|
285
|
-
|
|
76
|
+
npx hikoutei setup
|
|
286
77
|
```
|
|
287
78
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
- [Write and synchronization flow](website/guide/sync-flow.md) —
|
|
298
|
-
asynchronous delivery and recovery behavior.
|
|
299
|
-
- [Internal consistency model](website/guide/internal-consistency.md) —
|
|
300
|
-
durable outbox, idempotent delivery, and conflict-aware updates.
|
|
301
|
-
- [Contributing](website/guide/contributing.md) — local development and test
|
|
302
|
-
commands.
|
|
303
|
-
- [Soak testing](website/guide/soak-testing.md) — the long-duration soak
|
|
304
|
-
runner: source build, six scalar tables, 6h preflight and 24h direct-live
|
|
305
|
-
runs, log envs, redaction contract, resume/cleanup, and acceptance
|
|
306
|
-
criteria.
|
|
307
|
-
- [Benchmark notes](website/guide/benchmarks.md) — dated measurements and
|
|
308
|
-
their limitations.
|
|
309
|
-
|
|
310
|
-
## Limitations
|
|
311
|
-
|
|
312
|
-
- Google Sheets has quota, latency, and API rate limits. The outbound sync
|
|
313
|
-
worker batches effects to the spreadsheet scope, so remote request volume
|
|
314
|
-
does not grow with the number of tabs a dispatch touches.
|
|
315
|
-
- Sheet updates are asynchronous; the application should read its local state.
|
|
316
|
-
- SQLite is local to the service and is not a distributed coordination layer.
|
|
317
|
-
- Schema changes, manual edits, and conflicting updates still need an
|
|
318
|
-
operational policy from the application.
|
|
319
|
-
- The EntityManager is an ORM-style facade over scalar entities, not a full
|
|
320
|
-
ORM: entity definitions are scalar-only (`string`, `number`, `boolean`,
|
|
321
|
-
`date`), and v1 permits uniqueness only on the primary/business key.
|
|
322
|
-
- Relations, joins, `populate()`, migrations, cascades, bulk/ORM query
|
|
323
|
-
builders, and raw SQL are unsupported in this milestone. Sheets is an async
|
|
324
|
-
projection and human input surface, never a live query database.
|
|
325
|
-
|
|
326
|
-
## Local queries
|
|
327
|
-
|
|
328
|
-
Reads use Hikoutei-owned typed operators and always execute against SQLite:
|
|
79
|
+
This creates the Cloud project, service account, key, and spreadsheet, and
|
|
80
|
+
writes `.env` for you. Without `HIKOUTEI_SYNC_SPREADSHEET_URL`,
|
|
81
|
+
`createTypedSheets()` stays local-only (SQLite). Details, credential pools,
|
|
82
|
+
quota guidance, and manual setup: [Google Sheets setup](website/guide/setup.md).
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
Define a scalar entity and use the local SQLite authority through a
|
|
87
|
+
request-local manager.
|
|
329
88
|
|
|
330
89
|
```ts
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
offset: 0,
|
|
90
|
+
import { createTypedSheets, defineTypedSheetsEntity } from "hikoutei";
|
|
91
|
+
|
|
92
|
+
const User = defineTypedSheetsEntity({
|
|
93
|
+
name: "User",
|
|
94
|
+
tableName: "users",
|
|
95
|
+
properties: {
|
|
96
|
+
id: { type: "string", primary: true },
|
|
97
|
+
name: { type: "string" },
|
|
98
|
+
age: { type: "number" },
|
|
99
|
+
active: { type: "boolean" },
|
|
342
100
|
},
|
|
343
|
-
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const hikoutei = await createTypedSheets({
|
|
104
|
+
dbName: "./hikoutei.sqlite",
|
|
105
|
+
entities: [User],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const em = hikoutei.em.fork();
|
|
109
|
+
const user = em.create(User, { id: "u1", name: "Ada", age: 36, active: true });
|
|
110
|
+
em.persist(user);
|
|
111
|
+
await em.flush();
|
|
112
|
+
|
|
113
|
+
user.name = "Ada Lovelace";
|
|
114
|
+
await em.flush();
|
|
115
|
+
|
|
116
|
+
const loaded = await em.findOne(User, { id: "u1" });
|
|
117
|
+
if (loaded !== null) {
|
|
118
|
+
em.remove(loaded);
|
|
119
|
+
await em.flush();
|
|
120
|
+
}
|
|
344
121
|
```
|
|
345
122
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
`HIKOUTEI_ERROR_CODES` constants (`HIKOUTEI_ERROR_CODES.INVALID_QUERY` and
|
|
362
|
-
`HIKOUTEI_ERROR_CODES.INVALID_SCALAR_VALUE`, which resolve to the lowercase
|
|
363
|
-
runtime codes `invalid_query` and `invalid_scalar_value`) instead of guessing
|
|
364
|
-
strings or parsing messages.
|
|
365
|
-
|
|
366
|
-
## Project status
|
|
367
|
-
|
|
368
|
-
Hikoutei is in active development. The current EntityManager supports scalar
|
|
369
|
-
entity lifecycle operations, typed local filters and ordering, `limit` /
|
|
370
|
-
`offset` pagination, `count()`, snapshot-consistent `findAndCount()`, and
|
|
371
|
-
callback-style `transactional()` work. Normal reads always come from SQLite,
|
|
372
|
-
never Google Sheets. Sheet edit ingestion and conflict presentation are still
|
|
373
|
-
evolving. Review release notes before upgrading minor versions.
|
|
374
|
-
|
|
375
|
-
## Roadmap
|
|
376
|
-
|
|
377
|
-
The first EntityManager milestone, rich local reads, is complete. Remaining
|
|
378
|
-
milestones follow the implementation order below; no milestone is tied to a
|
|
379
|
-
date or release number.
|
|
380
|
-
|
|
381
|
-
1. **Lifecycle-safe writes**
|
|
382
|
-
- Add `upsert` and direct/bulk mutation capabilities only through a
|
|
383
|
-
Hikoutei-owned contract that preserves one SQLite transaction across the
|
|
384
|
-
entity table, canonical state, and durable Sheet effect outbox.
|
|
385
|
-
- Do not promise raw `nativeInsert`, `nativeUpdate`, `nativeDelete`, or SQL
|
|
386
|
-
pass-through APIs that could bypass that atomic lifecycle.
|
|
387
|
-
2. **Relationships and loading**
|
|
388
|
-
- Add many-to-one, one-to-many, and `populate()` capabilities.
|
|
389
|
-
- Design SQLite relationship mapping, Sheets projection representation,
|
|
390
|
-
schema behavior, and conflict semantics together before public release.
|
|
391
|
-
3. **Schema operations**
|
|
392
|
-
- Add migration and schema drift management.
|
|
393
|
-
- Integrate validation and operational workflows with the existing setup
|
|
394
|
-
tooling.
|
|
395
|
-
|
|
396
|
-
### Synchronization and operations
|
|
397
|
-
|
|
398
|
-
The following work continues in parallel with the EntityManager milestones:
|
|
399
|
-
|
|
400
|
-
- Complete ingestion of intentional user edits from Google Sheets.
|
|
401
|
-
- Improve update/delete conflict handling and presentation.
|
|
402
|
-
|
|
403
|
-
See the [open issues](https://github.com/ManddarinShop/Hikoutei/issues)
|
|
404
|
-
for current work.
|
|
123
|
+
More reads, transactions, and operators: [Quick start](website/guide/quick-start.md).
|
|
124
|
+
|
|
125
|
+
Writes commit to local SQLite immediately — the request never waits on Google.
|
|
126
|
+
Human edits in the Sheet flow back through polling — accepted into SQLite or
|
|
127
|
+
recorded as conflicts, never silently overwritten. The full pipeline (outbox,
|
|
128
|
+
delivery, conflict handling) is covered in
|
|
129
|
+
[Write and synchronization flow](website/guide/sync-flow.md).
|
|
130
|
+
|
|
131
|
+
## Learn more
|
|
132
|
+
|
|
133
|
+
- [Quick start](website/guide/quick-start.md) — installation, ORM lifecycle, sync setup.
|
|
134
|
+
- [Architecture](website/guide/architecture.md) — local store and Sheet views.
|
|
135
|
+
- [Write and synchronization flow](website/guide/sync-flow.md) — delivery and recovery.
|
|
136
|
+
- [Limitations](website/guide/limitations.md) — when to choose something else.
|
|
137
|
+
- [Project status and roadmap](website/guide/status.md) — what is done and next.
|
|
405
138
|
|
|
406
139
|
## License
|
|
407
140
|
|
|
@@ -100,11 +100,16 @@ export declare function clearRegisteredEntityTokens(): void;
|
|
|
100
100
|
* Validates a scalar entity descriptor and returns a stable entity token.
|
|
101
101
|
*
|
|
102
102
|
* Throws a typed `HikouteiError` for an empty name or table name, an invalid
|
|
103
|
-
* table identifier, a missing or duplicate primary key, a non-string
|
|
104
|
-
* key, a non-scalar property type, or any unsupported
|
|
105
|
-
* The returned token is safe to pass to
|
|
106
|
-
* is also registered so a later
|
|
107
|
-
* `entities` can use it as the default
|
|
103
|
+
* table identifier, a missing or duplicate primary key, a non-string/number
|
|
104
|
+
* primary key, a non-scalar property type, or any unsupported
|
|
105
|
+
* relation/provider option. The returned token is safe to pass to
|
|
106
|
+
* `createTypedSheets({ entities })`, and is also registered so a later
|
|
107
|
+
* `createTypedSheets()` call that omits `entities` can use it as the default
|
|
108
|
+
* entity set.
|
|
109
|
+
*
|
|
110
|
+
* A `string` primary key stays a TEXT column with application-assigned IDs.
|
|
111
|
+
* A `number` primary key becomes an INTEGER AUTOINCREMENT column so SQLite
|
|
112
|
+
* assigns the numeric ID when the app omits it at insert.
|
|
108
113
|
*/
|
|
109
114
|
export declare function defineTypedSheetsEntity<Name extends string, Properties extends HikouteiPropertyDescriptorMap>(input: HikouteiEntityDescriptorInput<Name, Properties>): HikouteiEntity<HikouteiEntityInstance<Properties>, Name>;
|
|
110
115
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/api/entity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,kEAAkE;AAClE,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AAEX,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE,qEAAqE;AACrE,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpE,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,QAAQ,CA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,CAAC,CAAC;AAE/C,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,CAChC,UAAU,SAAS,6BAA6B,IAC9C;IACF,CAAC,UAAU,QAAQ,IAAI,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;CAC1F,CAAC;AAYF,qBAAa,cAAc,CACzB,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,IAAI,SAAS,MAAM,GAAG,MAAM;IAE5B,sEAAsE;IACtE,iBAAyB,YAAY,CAAS;IAC9C,mEAAmE;IACnE,iBAAyB,YAAY,CAAO;gBAEhC,UAAU,EAAE,gCAAgC;CAGzD;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,MAAM,SAAS,MAAM,EACrB,IAAI,SAAS,MAAM,EAEnB,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,GACnC,gCAAgC,CAMlC;AAaD;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,SAAS,cAAc,EAAE,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,SAAS,MAAM,EACnB,UAAU,SAAS,6BAA6B,EAEhD,KAAK,EAAE,6BAA6B,CAAC,IAAI,EAAE,UAAU,CAAC,GACrD,cAAc,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAM1D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,6BAA6B,GACnC,gCAAgC,CAkDlC;AA+FD,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,aA6B/B,CAAC"}
|
|
@@ -81,11 +81,16 @@ const ALLOWED_PROPERTY_OPTION_KEYS = new Set([
|
|
|
81
81
|
* Validates a scalar entity descriptor and returns a stable entity token.
|
|
82
82
|
*
|
|
83
83
|
* Throws a typed `HikouteiError` for an empty name or table name, an invalid
|
|
84
|
-
* table identifier, a missing or duplicate primary key, a non-string
|
|
85
|
-
* key, a non-scalar property type, or any unsupported
|
|
86
|
-
* The returned token is safe to pass to
|
|
87
|
-
* is also registered so a later
|
|
88
|
-
* `entities` can use it as the default
|
|
84
|
+
* table identifier, a missing or duplicate primary key, a non-string/number
|
|
85
|
+
* primary key, a non-scalar property type, or any unsupported
|
|
86
|
+
* relation/provider option. The returned token is safe to pass to
|
|
87
|
+
* `createTypedSheets({ entities })`, and is also registered so a later
|
|
88
|
+
* `createTypedSheets()` call that omits `entities` can use it as the default
|
|
89
|
+
* entity set.
|
|
90
|
+
*
|
|
91
|
+
* A `string` primary key stays a TEXT column with application-assigned IDs.
|
|
92
|
+
* A `number` primary key becomes an INTEGER AUTOINCREMENT column so SQLite
|
|
93
|
+
* assigns the numeric ID when the app omits it at insert.
|
|
89
94
|
*/
|
|
90
95
|
export function defineTypedSheetsEntity(input) {
|
|
91
96
|
const entity = new HikouteiEntity(resolveEntityDescriptor(input));
|
|
@@ -131,8 +136,9 @@ export function resolveEntityDescriptor(input) {
|
|
|
131
136
|
throwInvalid(`entity "${name}" must declare exactly one primary key.`);
|
|
132
137
|
}
|
|
133
138
|
const primaryProperty = findProperty(properties, primaryKey);
|
|
134
|
-
if (primaryProperty.type !== HIKOUTEI_SCALAR_TYPES.STRING
|
|
135
|
-
|
|
139
|
+
if (primaryProperty.type !== HIKOUTEI_SCALAR_TYPES.STRING &&
|
|
140
|
+
primaryProperty.type !== HIKOUTEI_SCALAR_TYPES.NUMBER) {
|
|
141
|
+
throwInvalid(`entity "${name}" primary key "${primaryKey}" must be a string or number scalar in v1.`);
|
|
136
142
|
}
|
|
137
143
|
return { name, tableName, primaryKey, properties };
|
|
138
144
|
}
|
|
@@ -176,18 +182,20 @@ function resolveProperty(propertyName, options) {
|
|
|
176
182
|
return {
|
|
177
183
|
name: propertyName,
|
|
178
184
|
type,
|
|
179
|
-
storageType: toStorageType(type),
|
|
185
|
+
storageType: toStorageType(type, primary),
|
|
180
186
|
primary,
|
|
181
187
|
nullable,
|
|
182
188
|
unique,
|
|
183
189
|
};
|
|
184
190
|
}
|
|
185
|
-
function toStorageType(type) {
|
|
191
|
+
function toStorageType(type, primary) {
|
|
186
192
|
switch (type) {
|
|
187
193
|
case HIKOUTEI_SCALAR_TYPES.STRING:
|
|
188
194
|
return "TEXT";
|
|
189
195
|
case HIKOUTEI_SCALAR_TYPES.NUMBER:
|
|
190
|
-
|
|
196
|
+
// A numeric primary key is the SQLite-generated identity (INTEGER
|
|
197
|
+
// PRIMARY KEY AUTOINCREMENT); non-primary numbers stay REAL floats.
|
|
198
|
+
return primary ? "INTEGER" : "REAL";
|
|
191
199
|
case HIKOUTEI_SCALAR_TYPES.BOOLEAN:
|
|
192
200
|
return "INTEGER";
|
|
193
201
|
case HIKOUTEI_SCALAR_TYPES.DATE:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/api/entity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACJ,CAAC;AA+EX;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAA4C,CAAC;AAEnF,MAAM,OAAO,cAAc;IASzB,YAAY,UAA4C;QACtD,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,UAAU,mBAAmB,CAIjC,MA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;IACxF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACzD,IACE,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QACjD,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAC7C,CAAC;QACD,YAAY,CAAC,eAAe,SAAS,sCAAsC,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc,EAAE,KAAa;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,wBAAwB,EAAE,CAAC;QAClF,YAAY,CAAC,GAAG,KAAK,8BAA8B,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,IAAI,aAAa,CAAC,oBAAoB,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -6,13 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { TypedSheetsEntityMapping } from "./contracts.js";
|
|
8
8
|
/** Derives the stable row-binding ID shared by an entity's physical projections. */
|
|
9
|
-
export declare function typedSheetsEntityRowBindingId(mapping: TypedSheetsEntityMapping, entityId: string): string;
|
|
9
|
+
export declare function typedSheetsEntityRowBindingId(mapping: TypedSheetsEntityMapping, entityId: string | number): string;
|
|
10
10
|
/** Derives and validates the projection anchor for one canonical entity. */
|
|
11
|
-
export declare function typedSheetsEntityAnchor(mapping: TypedSheetsEntityMapping, entityId: string): string;
|
|
12
|
-
/** Reads the mapping's
|
|
11
|
+
export declare function typedSheetsEntityAnchor(mapping: TypedSheetsEntityMapping, entityId: string | number): string;
|
|
12
|
+
/** Reads the mapping's primary key from a pending entity change.
|
|
13
|
+
*
|
|
14
|
+
* Accepts a non-empty string or a safe-integer number and normalizes both to
|
|
15
|
+
* the single canonical string form (`String(id)`) so Sheets, canonical
|
|
16
|
+
* state, and observation agree on `42` vs `"42"`.
|
|
17
|
+
*/
|
|
13
18
|
export declare function typedSheetsEntityId(mapping: TypedSheetsEntityMapping, entity: object): string;
|
|
14
19
|
/** Converts a visible entity ID into the canonical ID used by sync state. */
|
|
15
|
-
export declare function typedSheetsCanonicalEntityId(mapping: TypedSheetsEntityMapping, entityId: string): string;
|
|
20
|
+
export declare function typedSheetsCanonicalEntityId(mapping: TypedSheetsEntityMapping, entityId: string | number): string;
|
|
16
21
|
/** Converts a canonical sync identity back to the entity-table primary key. */
|
|
17
|
-
export declare function typedSheetsEntityIdFromCanonical(mapping: TypedSheetsEntityMapping, entityId: string): string;
|
|
22
|
+
export declare function typedSheetsEntityIdFromCanonical(mapping: TypedSheetsEntityMapping, entityId: string | number): string;
|
|
18
23
|
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/sync-orm/mapping/identity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,oFAAoF;AACpF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/sync-orm/mapping/identity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,oFAAoF;AACpF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,CAMR;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,MAAM,GACb,MAAM,CAGR;AAED,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,CAKR;AAED,+EAA+E;AAC/E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,CAKR"}
|