How akahoshi1421/gassma works
Project type and purpose
• GASsma is an open-source TypeScript library that provides a Prisma-like ORM API for Google Sheets via Google Apps Script (GAS).
• Its primary goal is to let developers perform CRUD, filtering, aggregation, grouping, and other operations on spreadsheet data using a fluent, type-safe client.
File structure
• Top-level build and config:
• webpack.config.js, tsconfig.json, .clasp.json (GAS deployment), package.json, jest.config.ts
• Source code under src/:
• src/gassma.ts: entry-point exposing GassmaClient
• src/gassmaController.ts: orchestrates method calls and error handling
• src/util: modules for each operation (find, create, update, delete, count, aggregate, groupBy, changeSettings, filterConditions, andOrNot, etc.)
• src/errors: custom error classes per operation
• src/types: TypeScript type definitions for all public APIs
• Tests under src/__test__: validate each utility’s logic
• Build output in dist/: compiled JS and GAS manifest (appsscript.json)
Key points from README
• Shows how a user instantiates new GassmaClient and calls methods in either Clasp-driven TS code or directly in GAS script editor.
• Mentions the library is distributed via npm and linked into GAS via its Script ID.
1. Build & Distribution Layer
• TypeScript source
• Webpack/tsc compiler
• npm package registry
2. Client Application / GAS Runtime
• User’s Clasp project or GAS script editor
3. GassmaClient (public API)
4. GassmaController (core orchestrator)
5. Utility Modules (business logic)
• find, create, update, delete, count, aggregate, groupBy, changeSettings, filterConditions, andOrNot, etc.
6. Error Modules (operation-specific errors)
7. Type Definitions (compile-time contracts)
8. Google Apps Script Services
• SpreadsheetApp (GAS API)
1. Build & Distribution → npm registry → User’s project
2. User calls → GassmaClient methods
3. GassmaClient forwards → GassmaController
4. GassmaController invokes → appropriate util module (e.g., findMany → util/find/findMany.ts)
5. Util module uses → GAS SpreadsheetApp API to fetch/update raw sheet data
6. Raw data flows back → util module transforms → GassmaController
7. GassmaController applies → error handling (errors/*)
8. Final data returned → GassmaClient → User’s code
c. Architectural patterns & principles
• Layered architecture: public client → controller → utilities → external service
• Separation of concerns: each util module handles one CRUD or aggregation concern
• Error-first design: custom error classes per feature
• Type safety: TypeScript types in types/ enforce schema at compile time
• Modular design: small, testable units, validated by jest tests
d. Key technologies & frameworks
• TypeScript (tsc, type definitions)
• Webpack (bundling for GAS deployment)
• Google Apps Script (SpreadsheetApp service)
• Jest (unit tests)
• npm (package management)
• Clasp (GAS deployment)
Final recommendations
• TypeScript → JavaScript compile step feeding into dist/.