@b2bc-devkit/sheetorm 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2bc-devkit/sheetorm",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript ORM for Google Sheets (Google Apps Script runtime)",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-or-later",
package/readme.md CHANGED
@@ -28,6 +28,8 @@ extend `Record`, and everything just works.
28
28
  - **Batch operations** — `beginBatch` / `commitBatch` / `rollbackBatch` for safe bulk writes
29
29
  - **Pagination & grouping** — `select()` returns `PaginatedResult<T>`, `groupBy()` returns `GroupResult<T>`
30
30
  - **Sheet protection** — Auto-protect sheets on creation via `isProtected()` / `protectedFor()` overrides
31
+ - **Hidden sheets** — Auto-hide sheets on creation via `isHidden()` override; hidden sheets remain accessible
32
+ from the "All sheets" menu
31
33
  - **Zero runtime dependencies** — Bundles into a single `Code.js` via Vite
32
34
 
33
35
  ## Quick Start
@@ -94,7 +96,7 @@ class ArchivedCar extends Record {
94
96
  }
95
97
  ```
96
98
 
97
- ### 5. Protect a sheet
99
+ ### 4. Protect a sheet
98
100
 
99
101
  SheetORM can automatically protect auto-created sheets using the Google Sheets Protection API. Override
100
102
  `isProtected()` and `protectedFor()` on your model class:
@@ -123,6 +125,27 @@ view-only access. If `protectedFor()` returns an empty array, only the owner can
123
125
  Protection is applied **once** during sheet creation. Existing sheets are never re-protected on subsequent
124
126
  saves.
125
127
 
128
+ ### 5. Hide a sheet
129
+
130
+ SheetORM can automatically hide auto-created sheets from the bottom tab bar. Override `isHidden()` on your
131
+ model class:
132
+
133
+ ```ts
134
+ class AuditLog extends Record {
135
+ action: string;
136
+ timestamp: string;
137
+
138
+ static override isHidden(): boolean {
139
+ return true;
140
+ }
141
+ }
142
+ ```
143
+
144
+ When `isHidden()` returns `true`, the sheet is hidden the first time it is created. The sheet tab is removed
145
+ from the bottom tab bar but remains accessible via the "All sheets" menu in Google Sheets.
146
+
147
+ Hiding is applied **once** during sheet creation. Existing sheets are never re-hidden on subsequent saves.
148
+
126
149
  ### Available decorators
127
150
 
128
151
  SheetORM supports three TypeScript property decorators on `Record` models.
@@ -202,7 +225,7 @@ class Car extends Record {
202
225
 
203
226
  Use decorators only when you need schema metadata or indexing behaviour.
204
227
 
205
- ### 4. Use it
228
+ ### 6. Use it
206
229
 
207
230
  ```ts
208
231
  // Create — table auto-created on first save
@@ -296,15 +319,16 @@ examples/
296
319
  Extend `Record` to define a model. Declare fields as plain class properties — they are auto-discovered. Use
297
320
  decorators and an optional static property to customize behavior:
298
321
 
299
- | Decorator / property | Description |
300
- | ----------------------------- | ---------------------------------------------------------------------------- |
301
- | `@Required()` | Shorthand for marking a field as required |
302
- | `@Field(options?)` | Explicit field with options (required, type, defaultValue) |
303
- | `@Indexed(options?)` | Secondary index (implies `@Field`); auto-creates `idx_{ClassName}s` |
304
- | `static get tableName()` | Sheet name (defaults to `tbl_{ClassName}s` — e.g. `tbl_Cars` for `Car`) |
305
- | `static get indexTableName()` | Combined index sheet name (defaults to `idx_{ClassName}s` — e.g. `idx_Cars`) |
306
- | `static isProtected()` | Return `true` to protect the sheet on creation (default: `false`) |
307
- | `static protectedFor()` | Email addresses of allowed editors (default: `[]`) |
322
+ | Decorator / property | Description |
323
+ | ----------------------------- | ------------------------------------------------------------------------------- |
324
+ | `@Required()` | Shorthand for marking a field as required |
325
+ | `@Field(options?)` | Explicit field with options (required, type, defaultValue) |
326
+ | `@Indexed(options?)` | Secondary index (implies `@Field`); auto-creates `idx_{ClassName}s` |
327
+ | `static get tableName()` | Sheet name (defaults to `tbl_{ClassName}s` — e.g. `tbl_Cars` for `Car`) |
328
+ | `static get indexTableName()` | Combined index sheet name (defaults to `idx_{ClassName}s` — e.g. `idx_Cars`) |
329
+ | `static isProtected()` | Return `true` to protect the sheet on creation (default: `false`) |
330
+ | `static protectedFor()` | Email addresses of allowed editors (default: `[]`) |
331
+ | `static isHidden()` | Return `true` to hide the sheet from the tab bar on creation (default: `false`) |
308
332
 
309
333
  #### `@Required()`
310
334
 
@@ -388,6 +412,20 @@ Query.from(Car).where("year", ">=", 2023).execute();
388
412
  Query.from("Car").where("make", "=", "Toyota").first();
389
413
  ```
390
414
 
415
+ #### Query\<T\> methods
416
+
417
+ | Method | Returns | Description |
418
+ | ----------------------- | ------------------ | ------------------------------------- |
419
+ | `and(field, op, value)` | `Query<T>` | Add AND condition |
420
+ | `or(field, op, value)` | `Query<T>` | Add OR condition |
421
+ | `orderBy(field, dir?)` | `Query<T>` | Sort results (`"asc"` \| `"desc"`) |
422
+ | `limit(n)` | `Query<T>` | Maximum number of results |
423
+ | `offset(n)` | `Query<T>` | Skip first n results |
424
+ | `execute()` | `T[]` | Run query and return matching records |
425
+ | `first()` | `T \| null` | Return first matching record |
426
+ | `count()` | `number` | Count matching records |
427
+ | `groupBy(field)` | `GroupResult<T>[]` | Group results by field |
428
+
391
429
  ### Filter operators
392
430
 
393
431
  `=`, `!=`, `<`, `>`, `<=`, `>=`, `contains`, `startsWith`, `in`, `search`
@@ -415,11 +453,11 @@ const ids = indexStore.searchCombined("idx_Cars", "model", "320i");
415
453
  npm test
416
454
  ```
417
455
 
418
- Runs **337 unit and benchmark tests** across 11 test suites using Jest + ts-jest with in-memory mock adapters:
456
+ Runs **340 unit and benchmark tests** across 11 test suites using Jest + ts-jest with in-memory mock adapters:
419
457
 
420
458
  | Suite | Tests | Description |
421
459
  | -------------------------- | ----- | -------------------------------------------- |
422
- | `record.test.ts` | 78 | ActiveRecord API (save, find, query, Query) |
460
+ | `record.test.ts` | 81 | ActiveRecord API (save, find, query, Query) |
423
461
  | `query-engine.test.ts` | 60 | Filter, sort, paginate, group |
424
462
  | `serialization.test.ts` | 47 | Row ↔ Entity conversion |
425
463
  | `index-store.test.ts` | 44 | Secondary index CRUD |
@@ -480,7 +518,8 @@ npm test
480
518
 
481
519
  Run in Google Apps Script (real Sheets API):
482
520
 
483
- - `runTestsStageOne()` / `runTestsStageTwo()` / `runTestsStageThree()` — staged runtime parity suite
521
+ - `runTestsStageOne()` / `runTestsStageTwo()` / `runTestsStageThree()` / `runTestsStageFour()` — staged
522
+ runtime parity suite
484
523
  - `validateTests()` — validates mapping only (fast drift check)
485
524
 
486
525
  ### GAS Runtime Benchmark
@@ -500,9 +539,10 @@ callable as triggers). Everything else is an internal implementation detail bund
500
539
 
501
540
  | Function | Purpose |
502
541
  | ---------------------- | ------------------------------------------------------------------------------------------------ |
503
- | `runTestsStageOne()` | Stage-one parity tests (basic CRUD + query) against the active spreadsheet. |
504
- | `runTestsStageTwo()` | Stage-two parity tests (indexes + search). |
505
- | `runTestsStageThree()` | Stage-three parity tests (advanced queries + pagination). |
542
+ | `runTestsStageOne()` | Stage-one parity tests: cache, index-store, query, query-engine (~162 tests). |
543
+ | `runTestsStageTwo()` | Stage-two parity tests: serialization, uuid (~52 tests). |
544
+ | `runTestsStageThree()` | Stage-three parity tests: record (~81 tests). |
545
+ | `runTestsStageFour()` | Stage-four parity tests: sheet-repository (~35 tests). |
506
546
  | `validateTests()` | Checks Jest ↔ GAS handler mapping parity — no Sheets API calls, fails immediately on drift. |
507
547
  | `runBenchmark()` | Write/read/query/delete cycle for Cars + Workers (100 records each); logs per-operation timings. |
508
548
  | `removeAllSheets()` | Deletes every sheet in the active spreadsheet (destructive — use with caution). |