@stardeck-customer-apps/data-store-sdk 0.3.0 → 0.3.2

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/SKILL.md CHANGED
@@ -228,6 +228,36 @@ the schema snapshot is what `@stardeck-customer-apps/testing` applies to its
228
228
  in-process Postgres, so a stale snapshot means tests run against the wrong
229
229
  schema.
230
230
 
231
+ > **Never hand-edit a generated file.** `data-store-types.ts` is a write-only
232
+ > output: it's overwritten in full on every regeneration and contains only the
233
+ > raw table interfaces plus the `DB` type. Any type you append to it is silently
234
+ > wiped the next time the schema changes and you re-run `generate-types`.
235
+
236
+ App-level / derived types — serialized shapes (`Date` → `string` for API
237
+ responses), typed `jsonb` columns, computed/virtual fields, composite view
238
+ models — belong in a **separate hand-written file** that imports from the
239
+ generated one. This keeps regeneration safe and your types permanent:
240
+
241
+ ```typescript
242
+ // src/lib/order-types.ts (hand-written — survives every regeneration)
243
+ import type { Selectable } from "kysely";
244
+ import type { DB } from "@/generated/data-store-types";
245
+
246
+ type OrderRow = Selectable<DB["orders"]>;
247
+
248
+ // API-serialized shape: Dates become strings, jsonb gets a real type,
249
+ // and we add a computed field the table doesn't store.
250
+ export type Order = Omit<OrderRow, "created_at" | "metadata"> & {
251
+ created_at: string;
252
+ metadata: { source: string; tags: string[] };
253
+ is_overdue: boolean;
254
+ };
255
+ ```
256
+
257
+ If you find hand-written types already living inside a generated file, move them
258
+ into a sibling file like this and update the imports across the codebase rather
259
+ than perpetuating the append-and-restore cycle.
260
+
231
261
  ### Initialize
232
262
 
233
263
  ```typescript
@@ -324,3 +354,4 @@ try {
324
354
  - **Tables auto-generate** `id` (UUID), `created_at`, and `updated_at` columns. Don't include these in create table definitions.
325
355
  - **Column deletes are soft-deletes.** The column is renamed to `_deleted_{name}_{timestamp}` and can be restored.
326
356
  - **Type changes are restricted** to safe widening conversions (e.g., integer → bigint, boolean → text).
357
+ - **Generated column types: `bigint`/`numeric`/`decimal` map to `string`, not `number`.** `node-postgres` returns these as strings to avoid silent JS precision loss past `Number.MAX_SAFE_INTEGER`, so the generated types are `string` by design (`integer`/`smallint`/`real`/`double precision` stay `number`). `jsonb`/`json` come through as `unknown`. Cast at the boundary (`Number(row.size_bytes)`) or give the column a real type in your derived app type — don't assume `number`.
@@ -339,8 +339,12 @@ async function introspectSchema(connectionString) {
339
339
  }
340
340
  function generateTypeScript(tables) {
341
341
  const lines = [
342
- "// Auto-generated by @stardeck-customer-apps/data-store-sdk",
343
- "// Do not edit manually \u2014 regenerate with: npx stardeck-data-store generate-types",
342
+ "// AUTO-GENERATED by @stardeck-customer-apps/data-store-sdk \u2014 DO NOT EDIT.",
343
+ "// This file is overwritten in full on every run of:",
344
+ "// npx stardeck-data-store generate-types",
345
+ "// Anything you add here (hand-written or derived types) WILL BE LOST on the next",
346
+ "// regeneration. Put those in a separate file that imports from this one, e.g.",
347
+ "// src/lib/<domain>-types.ts importing the table types or DB from this file.",
344
348
  "",
345
349
  'import type { Generated } from "kysely";',
346
350
  ""
@@ -316,8 +316,12 @@ async function introspectSchema(connectionString) {
316
316
  }
317
317
  function generateTypeScript(tables) {
318
318
  const lines = [
319
- "// Auto-generated by @stardeck-customer-apps/data-store-sdk",
320
- "// Do not edit manually \u2014 regenerate with: npx stardeck-data-store generate-types",
319
+ "// AUTO-GENERATED by @stardeck-customer-apps/data-store-sdk \u2014 DO NOT EDIT.",
320
+ "// This file is overwritten in full on every run of:",
321
+ "// npx stardeck-data-store generate-types",
322
+ "// Anything you add here (hand-written or derived types) WILL BE LOST on the next",
323
+ "// regeneration. Put those in a separate file that imports from this one, e.g.",
324
+ "// src/lib/<domain>-types.ts importing the table types or DB from this file.",
321
325
  "",
322
326
  'import type { Generated } from "kysely";',
323
327
  ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stardeck-customer-apps/data-store-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "SDK for accessing Stardeck data stores from deployed projects",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",