@b2bc-devkit/sheetorm 1.0.3 → 1.1.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.0.3",
3
+ "version": "1.1.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",
@@ -68,7 +68,7 @@
68
68
  "@babel/plugin-transform-numeric-separator": "^7.28.6",
69
69
  "@babel/plugin-transform-optional-chaining": "^7.28.6",
70
70
  "@google/clasp": "^3.3.0",
71
- "@rollup/plugin-babel": "^6.1.0",
71
+ "@rollup/plugin-babel": "^7.0.0",
72
72
  "@types/google-apps-script": "^2.0.8",
73
73
  "@types/jest": "^30.0.0",
74
74
  "@typescript-eslint/eslint-plugin": "^8.57.1",
@@ -80,7 +80,7 @@
80
80
  "prettier": "^3.8.1",
81
81
  "terser": "^5.44.1",
82
82
  "ts-jest": "^29.4.6",
83
- "typescript": "^5.9.3",
84
- "vite": "^7.3.1"
83
+ "typescript": "^6.0.2",
84
+ "vite": "^8.0.8"
85
85
  }
86
86
  }
@@ -27,6 +27,7 @@ extend `Record`, and everything just works.
27
27
  - **Lifecycle hooks** — `beforeSave`, `afterSave`, `beforeDelete`, `afterDelete`
28
28
  - **Batch operations** — `beginBatch` / `commitBatch` / `rollbackBatch` for safe bulk writes
29
29
  - **Pagination & grouping** — `select()` returns `PaginatedResult<T>`, `groupBy()` returns `GroupResult<T>`
30
+ - **Sheet protection** — Auto-protect sheets on creation via `isProtected()` / `protectedFor()` overrides
30
31
  - **Zero runtime dependencies** — Bundles into a single `Code.js` via Vite
31
32
 
32
33
  ## Quick Start
@@ -93,6 +94,35 @@ class ArchivedCar extends Record {
93
94
  }
94
95
  ```
95
96
 
97
+ ### 5. Protect a sheet
98
+
99
+ SheetORM can automatically protect auto-created sheets using the Google Sheets Protection API. Override
100
+ `isProtected()` and `protectedFor()` on your model class:
101
+
102
+ ```ts
103
+ class SecretReport extends Record {
104
+ @Required()
105
+ title: string;
106
+
107
+ body: string;
108
+
109
+ static override isProtected(): boolean {
110
+ return true;
111
+ }
112
+
113
+ static override protectedFor(): string[] {
114
+ return ["alice@example.com", "bob@example.com"];
115
+ }
116
+ }
117
+ ```
118
+
119
+ When `isProtected()` returns `true`, the sheet is protected the first time it is created. The emails returned
120
+ by `protectedFor()` are added as editors — all other users (except the spreadsheet owner) are restricted to
121
+ view-only access. If `protectedFor()` returns an empty array, only the owner can edit.
122
+
123
+ Protection is applied **once** during sheet creation. Existing sheets are never re-protected on subsequent
124
+ saves.
125
+
96
126
  ### Available decorators
97
127
 
98
128
  SheetORM supports three TypeScript property decorators on `Record` models.
@@ -273,6 +303,8 @@ decorators and an optional static property to customize behavior:
273
303
  | `@Indexed(options?)` | Secondary index (implies `@Field`); auto-creates `idx_{ClassName}s` |
274
304
  | `static get tableName()` | Sheet name (defaults to `tbl_{ClassName}s` — e.g. `tbl_Cars` for `Car`) |
275
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: `[]`) |
276
308
 
277
309
  #### `@Required()`
278
310
 
@@ -383,11 +415,11 @@ const ids = indexStore.searchCombined("idx_Cars", "model", "320i");
383
415
  npm test
384
416
  ```
385
417
 
386
- Runs **333 unit and benchmark tests** across 11 test suites using Jest + ts-jest with in-memory mock adapters:
418
+ Runs **337 unit and benchmark tests** across 11 test suites using Jest + ts-jest with in-memory mock adapters:
387
419
 
388
420
  | Suite | Tests | Description |
389
421
  | -------------------------- | ----- | -------------------------------------------- |
390
- | `record.test.ts` | 74 | ActiveRecord API (save, find, query, Query) |
422
+ | `record.test.ts` | 78 | ActiveRecord API (save, find, query, Query) |
391
423
  | `query-engine.test.ts` | 60 | Filter, sort, paginate, group |
392
424
  | `serialization.test.ts` | 47 | Row ↔ Entity conversion |
393
425
  | `index-store.test.ts` | 44 | Secondary index CRUD |
@@ -567,6 +599,11 @@ included in this template):
567
599
  1. Install `madge` globally with `npm i --global madge`.
568
600
  2. Check for circular dependencies with `madge src/index.ts --circular`.
569
601
 
602
+ ## Security
603
+
604
+ To report a vulnerability, see [SECURITY.md](SECURITY.md). Do not open a public GitHub issue for security
605
+ issues — use GitHub's private Security Advisories instead.
606
+
570
607
  ## License
571
608
 
572
609
  GPL-3.0-or-later — see [license.md](license.md).