@supatype/cli 0.3.1 → 0.3.3

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.
Files changed (148) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +168 -158
  3. package/.turbo/turbo-typecheck.log +1 -1
  4. package/CHANGELOG.md +77 -0
  5. package/dist/api-config-cache.d.ts +20 -0
  6. package/dist/api-config-cache.d.ts.map +1 -1
  7. package/dist/api-config-cache.js +27 -0
  8. package/dist/api-config-cache.js.map +1 -1
  9. package/dist/augmentation-generator.d.ts.map +1 -1
  10. package/dist/augmentation-generator.js +126 -26
  11. package/dist/augmentation-generator.js.map +1 -1
  12. package/dist/cli-version-embedded.js +1 -1
  13. package/dist/client-generator.d.ts +3 -0
  14. package/dist/client-generator.d.ts.map +1 -0
  15. package/dist/client-generator.js +108 -0
  16. package/dist/client-generator.js.map +1 -0
  17. package/dist/commands/functions.d.ts.map +1 -1
  18. package/dist/commands/functions.js +2 -2
  19. package/dist/commands/functions.js.map +1 -1
  20. package/dist/commands/generate.d.ts.map +1 -1
  21. package/dist/commands/generate.js +3 -3
  22. package/dist/commands/generate.js.map +1 -1
  23. package/dist/commands/init.d.ts.map +1 -1
  24. package/dist/commands/init.js +36 -29
  25. package/dist/commands/init.js.map +1 -1
  26. package/dist/commands/push.d.ts.map +1 -1
  27. package/dist/commands/push.js +14 -13
  28. package/dist/commands/push.js.map +1 -1
  29. package/dist/commands/seed.d.ts +27 -1
  30. package/dist/commands/seed.d.ts.map +1 -1
  31. package/dist/commands/seed.js +206 -33
  32. package/dist/commands/seed.js.map +1 -1
  33. package/dist/commands/update.d.ts.map +1 -1
  34. package/dist/commands/update.js +19 -1
  35. package/dist/commands/update.js.map +1 -1
  36. package/dist/db-port.d.ts +36 -0
  37. package/dist/db-port.d.ts.map +1 -0
  38. package/dist/db-port.js +90 -0
  39. package/dist/db-port.js.map +1 -0
  40. package/dist/dev-compose.d.ts.map +1 -1
  41. package/dist/dev-compose.js +108 -13
  42. package/dist/dev-compose.js.map +1 -1
  43. package/dist/engine-client.d.ts +1 -0
  44. package/dist/engine-client.d.ts.map +1 -1
  45. package/dist/engine-client.js +47 -2
  46. package/dist/engine-client.js.map +1 -1
  47. package/dist/engine-floor.d.ts +27 -4
  48. package/dist/engine-floor.d.ts.map +1 -1
  49. package/dist/engine-floor.js +90 -9
  50. package/dist/engine-floor.js.map +1 -1
  51. package/dist/functions-context-refresh.d.ts +4 -0
  52. package/dist/functions-context-refresh.d.ts.map +1 -0
  53. package/dist/functions-context-refresh.js +26 -0
  54. package/dist/functions-context-refresh.js.map +1 -0
  55. package/dist/functions-deno-types.d.ts +9 -0
  56. package/dist/functions-deno-types.d.ts.map +1 -1
  57. package/dist/functions-deno-types.js +21 -1
  58. package/dist/functions-deno-types.js.map +1 -1
  59. package/dist/gitignore.d.ts +3 -1
  60. package/dist/gitignore.d.ts.map +1 -1
  61. package/dist/gitignore.js +35 -6
  62. package/dist/gitignore.js.map +1 -1
  63. package/dist/hooks-generator.d.ts.map +1 -1
  64. package/dist/hooks-generator.js +18 -3
  65. package/dist/hooks-generator.js.map +1 -1
  66. package/dist/schema-ast-v2.d.ts.map +1 -1
  67. package/dist/schema-ast-v2.js +17 -8
  68. package/dist/schema-ast-v2.js.map +1 -1
  69. package/dist/seed-connection.d.ts +60 -0
  70. package/dist/seed-connection.d.ts.map +1 -0
  71. package/dist/seed-connection.js +90 -0
  72. package/dist/seed-connection.js.map +1 -0
  73. package/dist/seed-ir.d.ts +66 -0
  74. package/dist/seed-ir.d.ts.map +1 -0
  75. package/dist/seed-ir.js +265 -0
  76. package/dist/seed-ir.js.map +1 -0
  77. package/dist/seed-runner.d.ts +44 -0
  78. package/dist/seed-runner.d.ts.map +1 -0
  79. package/dist/seed-runner.js +83 -0
  80. package/dist/seed-runner.js.map +1 -0
  81. package/dist/seed.d.ts +345 -0
  82. package/dist/seed.d.ts.map +1 -1
  83. package/dist/seed.js +138 -0
  84. package/dist/seed.js.map +1 -1
  85. package/dist/self-host-compose.d.ts +10 -2
  86. package/dist/self-host-compose.d.ts.map +1 -1
  87. package/dist/self-host-compose.js +73 -6
  88. package/dist/self-host-compose.js.map +1 -1
  89. package/dist/strict.d.ts +29 -0
  90. package/dist/strict.d.ts.map +1 -0
  91. package/dist/strict.js +37 -0
  92. package/dist/strict.js.map +1 -0
  93. package/dist/studio-dev-server.d.ts +12 -2
  94. package/dist/studio-dev-server.d.ts.map +1 -1
  95. package/dist/studio-dev-server.js +12 -2
  96. package/dist/studio-dev-server.js.map +1 -1
  97. package/dist/type-extractor.d.ts.map +1 -1
  98. package/dist/type-extractor.js +81 -2
  99. package/dist/type-extractor.js.map +1 -1
  100. package/dist/type-generation.d.ts +43 -0
  101. package/dist/type-generation.d.ts.map +1 -1
  102. package/dist/type-generation.js +93 -2
  103. package/dist/type-generation.js.map +1 -1
  104. package/package.json +2 -2
  105. package/src/api-config-cache.ts +30 -0
  106. package/src/augmentation-generator.ts +142 -26
  107. package/src/cli-version-embedded.ts +1 -1
  108. package/src/client-generator.ts +122 -0
  109. package/src/commands/functions.ts +5 -2
  110. package/src/commands/generate.ts +7 -3
  111. package/src/commands/init.ts +41 -31
  112. package/src/commands/push.ts +14 -15
  113. package/src/commands/seed.ts +294 -44
  114. package/src/commands/update.ts +20 -1
  115. package/src/db-port.ts +99 -0
  116. package/src/dev-compose.ts +116 -16
  117. package/src/engine-client.ts +52 -3
  118. package/src/engine-floor.ts +100 -9
  119. package/src/functions-context-refresh.ts +25 -0
  120. package/src/functions-deno-types.ts +24 -1
  121. package/src/gitignore.ts +38 -10
  122. package/src/hooks-generator.ts +21 -6
  123. package/src/schema-ast-v2.ts +17 -8
  124. package/src/seed-connection.ts +146 -0
  125. package/src/seed-ir.ts +311 -0
  126. package/src/seed-runner.ts +109 -0
  127. package/src/seed.ts +408 -0
  128. package/src/self-host-compose.ts +74 -6
  129. package/src/strict.ts +40 -0
  130. package/src/studio-dev-server.ts +12 -2
  131. package/src/type-extractor.ts +109 -2
  132. package/src/type-generation.ts +111 -2
  133. package/tests/access-composition.test.ts +123 -0
  134. package/tests/ast-derived-outputs.test.ts +92 -0
  135. package/tests/augmentation-generator.test.ts +273 -7
  136. package/tests/client-generator.test.ts +103 -0
  137. package/tests/db-port.test.ts +128 -0
  138. package/tests/engine-floor.test.ts +93 -0
  139. package/tests/external-database-compose.test.ts +8 -1
  140. package/tests/fixtures/seed_golden_ir.json +186 -0
  141. package/tests/functions-context-refresh.test.ts +86 -0
  142. package/tests/gitignore-secrets.test.ts +90 -0
  143. package/tests/runtime-contract.test.ts +146 -8
  144. package/tests/seed-connection.test.ts +158 -0
  145. package/tests/seed-ir.test.ts +436 -0
  146. package/tests/strict.test.ts +78 -0
  147. package/tests/type-extractor.test.ts +34 -0
  148. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/cli@0.3.1 build /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.3.3 build /home/runner/work/supatype/supatype/packages/cli
3
3
  > tsc --project tsconfig.json && node --input-type=module -e "import{cpSync,mkdirSync}from'node:fs';const a='dist/assets';mkdirSync(a,{recursive:true});cpSync('assets/supatype-logo-wordmark.ascii.txt',a+'/supatype-logo-wordmark.ascii.txt')"
4
4
 
@@ -1,14 +1,13 @@
1
1
 
2
- > @supatype/cli@0.3.1 test /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.3.3 test /home/runner/work/supatype/supatype/packages/cli
3
3
  > vitest run
4
4
 
5
5
 
6
6
   RUN  v4.0.18 /home/runner/work/supatype/supatype/packages/cli
7
7
 
8
- ✓ tests/type-extractor.test.ts (48 tests) 296ms
9
- ✓ tests/access-composition.test.ts (26 tests) 223ms
10
- ✓ tests/model-hooks.test.ts (23 tests) 85ms
11
- ✓ tests/runtime-contract.test.ts (57 tests) 136ms
8
+ ✓ tests/type-extractor.test.ts (49 tests) 408ms
9
+ ✓ tests/access-composition.test.ts (32 tests) 261ms
10
+ ✓ tests/model-hooks.test.ts (23 tests) 118ms
12
11
  stdout | tests/init.test.ts > scaffold() > creates all expected files
13
12
   created package.json
14
13
  created supatype.config.ts
@@ -323,21 +322,34 @@
323
322
  created public/.gitkeep
324
323
  created .gitignore
325
324
 
326
- ✓ tests/init.test.ts (28 tests) 178ms
327
- ✓ tests/external-database-compose.test.ts (23 tests) 10ms
328
- ✓ tests/model-constraints.test.ts (18 tests) 146ms
329
- ✓ tests/model-versions.test.ts (19 tests) 68ms
330
- ✓ tests/api-config-cache-seed.test.ts (15 tests) 33ms
331
- ✓ tests/model-cache-declaration.test.ts (18 tests) 83ms
332
- ✓ tests/field-masking-tier.test.ts (16 tests) 24ms
333
-
334
- ✓ tests/dev-ui.test.ts (21 tests) 92ms
325
+ ✓ tests/init.test.ts (28 tests) 115ms
326
+ ✓ tests/augmentation-generator.test.ts (24 tests) 40ms
327
+ ✓ tests/runtime-contract.test.ts (64 tests) 177ms
328
+ ✓ tests/seed-ir.test.ts (15 tests) 34ms
329
+ ✓ tests/engine-floor.test.ts (28 tests) 36ms
330
+ ✓ tests/external-database-compose.test.ts (23 tests) 24ms
331
+ ✓ tests/model-constraints.test.ts (18 tests) 225ms
332
+ ✓ tests/model-versions.test.ts (19 tests) 78ms
333
+ ✓ tests/api-config-cache-seed.test.ts (15 tests) 34ms
334
+ ✓ tests/model-cache-declaration.test.ts (18 tests) 92ms
335
+ ✓ tests/field-masking-tier.test.ts (16 tests) 21ms
336
+ ✓ tests/hooks-generator.test.ts (7 tests) 9843ms
337
+ ✓ typechecks under strict mode, together with a handler that uses it  4001ms
338
+ ✓ rejects a handler for a table that declares no hook  3169ms
339
+ ✓ typechecks with a validator written the way the docs will show it  2605ms
340
+
341
+ ✓ tests/dev-ui.test.ts (21 tests) 125ms
335
342
 
336
343
  [supatype] Shutting down…
337
- ✓ tests/hooks-generator.test.ts (7 tests) 6819ms
338
- ✓ typechecks under strict mode, together with a handler that uses it  2673ms
339
- ✓ rejects a handler for a table that declares no hook  2226ms
340
- ✓ typechecks with a validator written the way the docs will show it  1871ms
344
+ ✓ tests/config.test.ts (19 tests) 9687ms
345
+ ✓ loads a valid supatype.config.ts (plain export default, no package imports)  1202ms
346
+ ✓ normalizes shorthand schema string to { path, pg_schema }  1007ms
347
+ ✓ loads a supatype.config.js (plain ESM)  1367ms
348
+ ✓ loads config without a versions section (latest by default)  1236ms
349
+ ✓ prefers supatype.config.ts over supatype.config.js when both exist  1081ms
350
+ ✓ supports optional output field in config  784ms
351
+ ✓ merges supatype.local.config.ts over base  1833ms
352
+ ✓ loads defineConfig import before @supatype/cli is installed (init scaffold)  1148ms
341
353
  stdout | tests/docker-runtime.test.ts > requireDockerDaemon > exits when the daemon is unavailable
342
354
  
343
355
  Start the Docker daemon (e.g. sudo systemctl start docker), then try again.
@@ -346,53 +358,45 @@
346
358
 
347
359
  docker: daemon down
348
360
 
349
- ✓ tests/docker-runtime.test.ts (10 tests) 14ms
350
- ✓ tests/config.test.ts (19 tests) 6870ms
351
- ✓ loads a valid supatype.config.ts (plain export default, no package imports)  881ms
352
- ✓ normalizes shorthand schema string to { path, pg_schema }  904ms
353
- ✓ loads a supatype.config.js (plain ESM)  821ms
354
- ✓ loads config without a versions section (latest by default)  791ms
355
- ✓ prefers supatype.config.ts over supatype.config.js when both exist  679ms
356
- ✓ supports optional output field in config  728ms
357
- ✓ merges supatype.local.config.ts over base  1156ms
358
- ✓ loads defineConfig import before @supatype/cli is installed (init scaffold)  898ms
359
- ✓ tests/db-preflight.test.ts (14 tests) 7ms
360
- ✓ tests/keys-write.test.ts (11 tests) 13ms
361
- ✓ tests/field-bounds.test.ts (23 tests) 9ms
362
- ✓ tests/cache-clean.test.ts (8 tests) 1641ms
363
- ✓ keeps pinned versions and removes the rest  545ms
364
- ✓ --force removes pinned versions  543ms
365
- ✓ explicit version removes even when pinned (with warning)  525ms
366
- ✓ tests/functions-deno-types.test.ts (7 tests) 2130ms
367
- ✓ tsc fails with Cannot find name Deno without ambient types  1467ms
368
- ✓ tsc passes for Deno.env after ensureFunctionsDenoTypes  648ms
369
- ✓ tests/cache-provider-config.test.ts (12 tests) 10ms
370
- ✓ tests/field-bounds-matrix.test.ts (124 tests) 21ms
371
- ✓ tests/engine-floor.test.ts (17 tests) 11ms
372
- ✓ tests/external-database-config.test.ts (14 tests) 8ms
373
- ✓ tests/compose-services.test.ts (12 tests) 9ms
374
- ✓ tests/field-validators.test.ts (10 tests) 45ms
375
- ✓ tests/native-keyspace.test.ts (10 tests) 29ms
376
- ✓ tests/command-chrome-coverage.test.ts (1 test) 17ms
361
+ ✓ tests/docker-runtime.test.ts (10 tests) 17ms
362
+ ✓ tests/db-preflight.test.ts (14 tests) 11ms
363
+ ✓ tests/keys-write.test.ts (11 tests) 23ms
364
+ ✓ tests/field-bounds.test.ts (23 tests) 17ms
365
+ ✓ tests/cache-clean.test.ts (8 tests) 2011ms
366
+ ✓ keeps pinned versions and removes the rest  634ms
367
+ ✓ --force removes pinned versions  708ms
368
+ ✓ explicit version removes even when pinned (with warning)  651ms
369
+ ✓ tests/cache-provider-config.test.ts (12 tests) 14ms
370
+ ✓ tests/functions-deno-types.test.ts (7 tests) 2963ms
371
+ ✓ tsc fails with Cannot find name Deno without ambient types  2060ms
372
+ ✓ tsc passes for Deno.env after ensureFunctionsDenoTypes  883ms
373
+ ✓ tests/seed-connection.test.ts (13 tests) 15ms
374
+ ✓ tests/field-bounds-matrix.test.ts (124 tests) 24ms
375
+ ✓ tests/external-database-config.test.ts (14 tests) 10ms
376
+ ✓ tests/compose-services.test.ts (12 tests) 11ms
377
+ ✓ tests/field-validators.test.ts (10 tests) 70ms
378
+ ✓ tests/native-keyspace.test.ts (10 tests) 27ms
379
+ ✓ tests/db-port.test.ts (14 tests) 17ms
380
+ ✓ tests/command-chrome-coverage.test.ts (1 test) 19ms
377
381
  ✓ tests/hook-upload.test.ts (8 tests) 10ms
378
- ✓ tests/env-file.test.ts (9 tests) 12ms
382
+ ✓ tests/env-file.test.ts (9 tests) 21ms
379
383
  stdout | tests/link.test.ts > link model > migrates cloud.json into link.json
380
384
   created package.json
381
- stderr | tests/link.test.ts > link model > migrates cloud.json into link.json
382
- [supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
383
385
  created supatype.config.ts
384
-
385
386
  created schema/index.ts
386
387
  created .env
387
388
  created seed.ts
389
+ stderr | tests/link.test.ts > link model > migrates cloud.json into link.json
388
390
  created seeds/.gitkeep
389
391
  created public/.gitkeep
390
392
  created .gitignore
391
393
 
392
- ✓ tests/link.test.ts (4 tests) 2351ms
393
- ✓ resolveTarget returns cloud mode with /api/v1 prefix  769ms
394
- ✓ resolveTarget returns self-host mode with /platform/v1 prefix  770ms
395
- ✓ targetSchemaRollback posts to /platform/v1 when linked  802ms
394
+ [supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
395
+
396
+ ✓ tests/link.test.ts (4 tests) 3123ms
397
+ ✓ resolveTarget returns cloud mode with /api/v1 prefix  1060ms
398
+ ✓ resolveTarget returns self-host mode with /platform/v1 prefix  1041ms
399
+ ✓ targetSchemaRollback posts to /platform/v1 when linked  1011ms
396
400
  stdout | tests/admin-ensure.test.ts > init admin seed in .env > writes SUPATYPE_ADMIN_* when scaffold options include credentials
397
401
   created package.json
398
402
  created supatype.config.ts
@@ -403,8 +407,8 @@
403
407
  created public/.gitkeep
404
408
  created .gitignore
405
409
 
406
- ✓ tests/admin-ensure.test.ts (10 tests) 143ms
407
- ✓ tests/service-role-check.test.ts (10 tests) 9ms
410
+ ✓ tests/admin-ensure.test.ts (10 tests) 182ms
411
+ ✓ tests/service-role-check.test.ts (10 tests) 15ms
408
412
  stdout | tests/admin-studio-membership.test.ts > first admin user creation > does not write a role into app_metadata
409
413
  [supatype] Admin user "admin@example.com" created (role: admin).
410
414
  [supatype] Log in at /admin after starting the dev server.
@@ -421,51 +425,55 @@
421
425
  [supatype] Admin user "admin@example.com" created (role: admin).
422
426
  [supatype] Log in at /admin after starting the dev server.
423
427
 
424
- ✓ tests/admin-studio-membership.test.ts (5 tests) 397ms
425
- ✓ tests/augmentation-generator.test.ts (6 tests) 12ms
426
- ✓ tests/pull-utils.test.ts (49 tests) 10ms
427
- ✓ tests/keys.test.ts (11 tests) 12833ms
428
- ✓ exits 0 with --secret  1269ms
429
- ✓ outputs ANON_KEY= line  1068ms
430
- ✓ outputs SERVICE_ROLE_KEY= line  1008ms
431
- ✓ ANON_KEY is a valid three-part JWT  1079ms
432
- ✓ SERVICE_ROLE_KEY payload has role: service_role  1036ms
433
- ✓ JWT has exp in the future  1028ms
434
- ✓ --exp-years changes the expiry window  2179ms
435
- ✓ reads JWT_SECRET from environment variable  1092ms
436
- ✓ reads JWT_SECRET from .env file  1039ms
437
- ✓ exits non-zero when no secret is available  1019ms
438
- ✓ keys --help shows --secret and --exp-years options  1010ms
439
- ✓ tests/preview-config-check.test.ts (9 tests) 5ms
440
- ✓ tests/schema-sources.test.ts (5 tests) 993ms
441
- ✓ buildSchemaSourcesPayload includes manifest metadata  485ms
442
- ✓ restore overwrites modified local files  476ms
428
+ ✓ tests/admin-studio-membership.test.ts (5 tests) 440ms
429
+ ✓ tests/pull-utils.test.ts (49 tests) 14ms
430
+ ✓ tests/schema-sources.test.ts (5 tests) 1223ms
431
+ ✓ buildSchemaSourcesPayload includes manifest metadata  594ms
432
+ ✓ restore overwrites modified local files  586ms
433
+ ✓ tests/preview-config-check.test.ts (9 tests) 6ms
434
+ ✓ tests/keys.test.ts (11 tests) 17760ms
435
+ ✓ exits 0 with --secret  1627ms
436
+ ✓ outputs ANON_KEY= line  1464ms
437
+ ✓ outputs SERVICE_ROLE_KEY= line  1362ms
438
+ ✓ ANON_KEY is a valid three-part JWT  1546ms
439
+ ✓ SERVICE_ROLE_KEY payload has role: service_role  1374ms
440
+ ✓ JWT has exp in the future  1603ms
441
+ ✓ --exp-years changes the expiry window  2946ms
442
+ ✓ reads JWT_SECRET from environment variable  1496ms
443
+ ✓ reads JWT_SECRET from .env file  1518ms
444
+ ✓ exits non-zero when no secret is available  1378ms
445
+ ✓ keys --help shows --secret and --exp-years options  1438ms
443
446
  stderr | tests/binary-cache-cloud-overrides.test.ts > isLinkedToCloudProject > is true when .supatype/cloud.json has projectSlug
444
447
  [supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
445
448
 
446
- ✓ tests/binary-cache-cloud-overrides.test.ts (11 tests) 15ms
447
- ✓ tests/homebrew-formula.test.ts (4 tests) 180ms
448
- ✓ tests/model-cache-manifest.test.ts (12 tests) 7ms
449
- ✓ tests/minisign.test.ts (5 tests) 11ms
450
- ✓ tests/local-server-image-env.test.ts (5 tests) 10ms
451
- ✓ tests/local-secrets.test.ts (5 tests) 7ms
452
- ✓ tests/functions-concurrency.test.ts (6 tests) 4ms
453
- ✓ tests/self-host-keys.test.ts (7 tests) 8ms
454
- ✓ tests/readiness-poll.test.ts (3 tests) 316ms
455
- ✓ ends promptly when it carries a deadline  313ms
456
- ✓ tests/api-schemas.test.ts (10 tests) 5ms
449
+ ✓ tests/binary-cache-cloud-overrides.test.ts (11 tests) 22ms
450
+ ✓ tests/local-server-image-env.test.ts (5 tests) 19ms
451
+ ✓ tests/homebrew-formula.test.ts (4 tests) 214ms
452
+ ✓ tests/model-cache-manifest.test.ts (12 tests) 9ms
453
+ ✓ tests/minisign.test.ts (5 tests) 17ms
454
+ ✓ tests/client-generator.test.ts (9 tests) 11ms
455
+ ✓ tests/local-secrets.test.ts (5 tests) 11ms
456
+ ✓ tests/functions-concurrency.test.ts (6 tests) 5ms
457
+ ✓ tests/readiness-poll.test.ts (3 tests) 331ms
458
+ ✓ ends promptly when it carries a deadline  327ms
459
+ ✓ tests/ast-derived-outputs.test.ts (5 tests) 15ms
460
+ ✓ tests/self-host-keys.test.ts (7 tests) 15ms
461
+ ✓ tests/functions-context-refresh.test.ts (4 tests) 10ms
462
+ ✓ tests/api-schemas.test.ts (10 tests) 13ms
463
+ ✓ tests/gitignore-secrets.test.ts (5 tests) 93ms
457
464
  stdout | tests/storage-provision.test.ts > provisionBuckets > POSTs each bucket to the storage API
458
465
  [supatype] Storage bucket "photos" ready.
459
466
 
460
467
  stdout | tests/storage-provision.test.ts > provisionBuckets > POSTs each bucket to the storage API
461
468
  [supatype] Storage bucket "avatars" ready.
462
469
 
463
- ✓ tests/storage-provision.test.ts (6 tests) 10ms
470
+ ✓ tests/storage-provision.test.ts (6 tests) 12ms
471
+ ✓ tests/strict.test.ts (7 tests) 7ms
464
472
  ✓ tests/cached-artifact-format.test.ts (7 tests) 10ms
465
- ✓ tests/cache-identity-scope.test.ts (33 tests) 7ms
466
- ✓ tests/target-client-refresh.test.ts (3 tests) 8ms
467
- ✓ tests/studio-admin-roles.test.ts (6 tests) 5ms
468
- ✓ tests/proxy-dev-app.test.ts (7 tests) 5ms
473
+ ✓ tests/cache-identity-scope.test.ts (33 tests) 12ms
474
+ ✓ tests/target-client-refresh.test.ts (3 tests) 15ms
475
+ ✓ tests/studio-admin-roles.test.ts (6 tests) 6ms
476
+ ✓ tests/proxy-dev-app.test.ts (7 tests) 7ms
469
477
  stdout | tests/app-command.test.ts > supatype app add --static > sets app.mode=static and static_dir in supatype.config.ts
470
478
   created package.json
471
479
  created supatype.config.ts
@@ -486,77 +494,79 @@
486
494
  created public/.gitkeep
487
495
  created .gitignore
488
496
 
489
- ✓ tests/service-role-routes.test.ts (4 tests) 1314ms
490
- ✓ reads the declared list  475ms
491
- ✓ is an empty list when a project declares none  437ms
492
- ✓ sends what the project declared, hook entries included  400ms
493
- ✓ tests/compose-parsable-defaults.test.ts (2 tests) 6ms
494
- ✓ tests/app-command.test.ts (2 tests) 2406ms
495
- ✓ sets app.mode=static and static_dir in supatype.config.ts  1266ms
496
- ✓ creates the static directory when missing  1139ms
497
- ✓ tests/rest-cache-admin.test.ts (3 tests) 34ms
498
- ✓ tests/init-dependency-versions.test.ts (4 tests) 23ms
499
- ✓ tests/type-resolver.test.ts (2 tests) 14ms
500
- ✓ tests/cli-help.test.ts (16 tests) 17210ms
501
- ✓ --help lists all top-level commands  1097ms
502
- ✓ --version prints package.json version  1092ms
503
- ✓ self-update --help describes the command  1017ms
504
- ✓ init --help describes the init command  1138ms
505
- ✓ push --help describes the push command and --yes flag  1144ms
506
- ✓ diff --help describes the diff command  1098ms
507
- ✓ pull --help describes scaffold pull command  1074ms
508
- ✓ doctor --help describes drift report command  1072ms
509
- ✓ introspect --help describes database introspection command  1044ms
510
- ✓ adopt --help describes adoption ceremony command  1086ms
511
- ✓ reset --help shows --yes flag  983ms
512
- ✓ app --help describes the app command with add/remove subcommands  918ms
513
- ✓ app add --help shows --static and --port options  1057ms
514
- ✓ self-host --help shows compose only (legacy commands hidden)  1115ms
515
- ✓ self-host compose --help shows compose subcommands  1131ms
516
- ✓ unknown command exits non-zero  1135ms
517
- ✓ tests/engine-push-output.test.ts (7 tests) 5ms
518
- ✓ tests/command-chrome-wrap.test.ts (3 tests) 5ms
519
- ✓ tests/doctor-render.test.ts (3 tests) 5ms
520
- ✓ tests/cli-install-method.test.ts (8 tests) 11ms
521
- ✓ tests/port-in-use.test.ts (4 tests) 17ms
497
+ ✓ tests/service-role-routes.test.ts (4 tests) 1771ms
498
+ ✓ reads the declared list  592ms
499
+ ✓ is an empty list when a project declares none  610ms
500
+ ✓ sends what the project declared, hook entries included  565ms
501
+ ✓ tests/cli-help.test.ts (16 tests) 23059ms
502
+ ✓ --help lists all top-level commands  1506ms
503
+ ✓ --version prints package.json version  1416ms
504
+ ✓ self-update --help describes the command  1380ms
505
+ ✓ init --help describes the init command  1381ms
506
+ ✓ push --help describes the push command and --yes flag  1515ms
507
+ ✓ diff --help describes the diff command  1450ms
508
+ ✓ pull --help describes scaffold pull command  1361ms
509
+ ✓ doctor --help describes drift report command  1414ms
510
+ ✓ introspect --help describes database introspection command  1491ms
511
+ ✓ adopt --help describes adoption ceremony command  1400ms
512
+ ✓ reset --help shows --yes flag  1420ms
513
+ ✓ app --help describes the app command with add/remove subcommands  1412ms
514
+ ✓ app add --help shows --static and --port options  1438ms
515
+ ✓ self-host --help shows compose only (legacy commands hidden)  1571ms
516
+ ✓ self-host compose --help shows compose subcommands  1453ms
517
+ ✓ unknown command exits non-zero  1444ms
518
+ ✓ tests/compose-parsable-defaults.test.ts (2 tests) 7ms
519
+ ✓ tests/app-command.test.ts (2 tests) 3088ms
520
+ ✓ sets app.mode=static and static_dir in supatype.config.ts  1595ms
521
+ ✓ creates the static directory when missing  1491ms
522
+ ✓ tests/rest-cache-admin.test.ts (3 tests) 52ms
523
+ ✓ tests/init-dependency-versions.test.ts (4 tests) 41ms
524
+ ✓ tests/engine-push-output.test.ts (7 tests) 7ms
525
+ ✓ tests/type-resolver.test.ts (2 tests) 17ms
526
+ ✓ tests/command-chrome-wrap.test.ts (3 tests) 8ms
527
+ ✓ tests/cli-install-method.test.ts (8 tests) 8ms
528
+ ✓ tests/port-in-use.test.ts (4 tests) 26ms
529
+ ✓ tests/doctor-render.test.ts (3 tests) 8ms
522
530
  ✓ tests/archive-name-alias.test.ts (4 tests) 5ms
523
- ✓ tests/ensure-binary.test.ts (2 tests) 7ms
524
- ✓ tests/init-project-detect.test.ts (4 tests) 6ms
525
- ✓ tests/tsx-runner.test.ts (7 tests) 2317ms
526
- ✓ evaluates a simple expression and returns stdout  300ms
527
- ✓ can serialize a JSON object to stdout  336ms
528
- ✓ returns non-zero exit code on runtime error  349ms
529
- ✓ captures stderr separately from stdout  354ms
530
- ✓ runs a .ts file and returns its stdout  405ms
531
- ✓ tests/doctor-service-role.test.ts (4 tests) 4ms
532
- ✓ tests/required-host-components.test.ts (4 tests) 5ms
533
- ✓ tests/dev-ports-owner.test.ts (6 tests) 3ms
531
+ ✓ tests/ensure-binary.test.ts (2 tests) 11ms
532
+ ✓ tests/init-project-detect.test.ts (4 tests) 8ms
533
+ ✓ tests/tsx-runner.test.ts (7 tests) 3066ms
534
+ ✓ evaluates a simple expression and returns stdout  381ms
535
+ ✓ evaluates TypeScript syntax (type annotations)  436ms
536
+ ✓ can serialize a JSON object to stdout  429ms
537
+ ✓ returns non-zero exit code on syntax error  407ms
538
+ ✓ returns non-zero exit code on runtime error  427ms
539
+ ✓ captures stderr separately from stdout  388ms
540
+ ✓ runs a .ts file and returns its stdout  591ms
541
+ ✓ tests/doctor-service-role.test.ts (4 tests) 8ms
542
+ ✓ tests/required-host-components.test.ts (4 tests) 6ms
534
543
  ✓ tests/ui-messages.test.ts (5 tests) 7ms
535
- ✓ tests/normalize-admin-config.test.ts (1 test) 5ms
536
- ✓ tests/ui-confirm.test.ts (3 tests) 6ms
537
- ✓ tests/docker-postgres.test.ts (5 tests) 3ms
538
- ✓ tests/binary-download-lock.test.ts (2 tests) 5ms
539
- ✓ tests/dev-session-lock.test.ts (2 tests) 4ms
540
- ✓ tests/config-load-failure.test.ts (2 tests) 2749ms
541
- ✓ is reported, rather than treated as absent  1585ms
542
- ✓ does not stop the CLI working with no config at all  1162ms
543
- ✓ tests/dev-ports.test.ts (3 tests) 4ms
544
- ✓ tests/route-manifest.test.ts (1 test) 4ms
545
- ✓ tests/dev-ready-panel.test.ts (2 tests) 3ms
544
+ ✓ tests/normalize-admin-config.test.ts (1 test) 6ms
545
+ ✓ tests/dev-ports-owner.test.ts (6 tests) 5ms
546
+ ✓ tests/ui-confirm.test.ts (3 tests) 9ms
547
+ ✓ tests/docker-postgres.test.ts (5 tests) 5ms
548
+ ✓ tests/binary-download-lock.test.ts (2 tests) 13ms
549
+ ✓ tests/dev-session-lock.test.ts (2 tests) 5ms
550
+ ✓ tests/config-load-failure.test.ts (2 tests) 3614ms
551
+ ✓ is reported, rather than treated as absent  2066ms
552
+ ✓ does not stop the CLI working with no config at all  1545ms
553
+ ✓ tests/route-manifest.test.ts (1 test) 6ms
554
+ ✓ tests/dev-ports.test.ts (3 tests) 6ms
546
555
  ✓ tests/realtime-launch.test.ts (1 test) 4ms
547
- ✓ tests/release-pins.test.ts (2 tests) 3ms
556
+ ✓ tests/release-pins.test.ts (2 tests) 6ms
557
+ ✓ tests/dev-ready-panel.test.ts (2 tests) 4ms
548
558
  ✓ tests/ensure-dev-api-config.test.ts (1 test) 4ms
549
- ✓ tests/seed-discover.test.ts (2 tests) 10ms
550
- ✓ tests/init-package-json.test.ts (1 test) 3ms
551
- ✓ tests/pg-spawn-env.test.ts (2 tests) 3ms
552
- ✓ tests/resolve-api-url.test.ts (2 tests) 3ms
553
- ✓ tests/cli-package-version.test.ts (1 test) 2ms
554
- ✓ tests/migrate-from-v1.test.ts (1 test) 9ms
559
+ ✓ tests/seed-discover.test.ts (2 tests) 19ms
560
+ ✓ tests/init-package-json.test.ts (1 test) 4ms
561
+ ✓ tests/pg-spawn-env.test.ts (2 tests) 7ms
562
+ ✓ tests/resolve-api-url.test.ts (2 tests) 4ms
563
+ ✓ tests/migrate-from-v1.test.ts (1 test) 11ms
564
+ ✓ tests/cli-package-version.test.ts (1 test) 4ms
555
565
  ✓ tests/postgres-archive-tag.test.ts (1 test) 2ms
556
- ✓ tests/stdin-after-ink.test.ts (1 test) 2ms
566
+ ✓ tests/stdin-after-ink.test.ts (1 test) 3ms
557
567
 
558
-  Test Files  95 passed (95)
559
-  Tests  997 passed (997)
560
-  Start at  09:25:57
561
-  Duration  39.48s (transform 6.25s, setup 0ms, import 40.35s, tests 62.64s, environment 15ms)
568
+  Test Files  103 passed (103)
569
+  Tests  1112 passed (1112)
570
+  Start at  16:22:17
571
+  Duration  55.20s (transform 7.96s, setup 0ms, import 58.00s, tests 85.16s, environment 24ms)
562
572
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/cli@0.3.1 typecheck /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.3.3 typecheck /home/runner/work/supatype/supatype/packages/cli
3
3
  > tsc --project tsconfig.json --noEmit && tsc --project tests/tsconfig.json --noEmit
4
4
 
package/CHANGELOG.md ADDED
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ### Features
6
+
7
+ * **seed:** a seed file now exports a default function and describes writes rather than
8
+ performing them. The calls are collected into a document that the engine validates against
9
+ the schema, orders by foreign key, batches, and applies in one transaction. There is no
10
+ connection to open, no SQL, no ordering to work out by hand, and a failure part way through
11
+ leaves nothing behind. See `references/seeding.md`.
12
+ * **seed:** `db` is typed from the project's schema by a generated builder. A reference to the
13
+ wrong model, a `where` on a column that does not identify a row, a time expression on a text
14
+ column, or a currency amount as a float are all compile errors.
15
+ * **seed:** `upsert`, `createMany`, nested `create` on the inverse side of a relation, and
16
+ `connect` by any unique key.
17
+ * **seed:** `$if` runs a block only when the database says so, evaluated by the engine at that
18
+ position inside the transaction. `$sql` puts a raw statement in the same transaction and the
19
+ same order as everything else.
20
+ * **seed:** `expr.now`, `expr.startOf`, `expr.ago` and `expr.default` are evaluated by Postgres
21
+ at seed time, so a fixture calendar stays ahead of whenever it is run.
22
+ * **seed:** `--status` reports what has been applied to an environment, including whether a file
23
+ has changed since it ran. `--atomic` runs every file in one transaction. `--connection` and
24
+ `--environment` were added alongside.
25
+ * **seed:** every run is recorded in `_supatype.seeds`, inside the same transaction as the writes
26
+ it describes, so the record can never claim a seed applied when it rolled back. A file may opt
27
+ into `runOnce` for a genuine one-time backfill.
28
+ * **seed:** failures arrive in the schema's terms. `Organiser.slug is already taken`, with the
29
+ file and the position in the document, rather than a Postgres constraint name.
30
+ * **seed:** exit codes distinguish a seed that failed (1) from an environment that is not set up
31
+ (2), so CI can tell which one to retry.
32
+ * **seed:** the connection string is resolved from the flag, the config, the environment and the
33
+ project's `.env` in that order, and when none of them has one the error names every source it
34
+ tried. Connection strings are redacted wherever they are printed.
35
+ * **generate:** writes the seed builder beside the generated client. It needs no database and no
36
+ running stack, which is what makes it safe to gitignore.
37
+ * **init:** the scaffolded seed uses the new contract and carries no connection string. The
38
+ scaffolded `package.json` runs `supatype seed` and gains a `prepare` script so a fresh clone
39
+ has a builder before anything imports it.
40
+ * **dev:** the database is always published to the host on `127.0.0.1`. Seeding is a host
41
+ process, so the previous rule left a fresh project with a database nothing on the host could
42
+ reach and a remedy nobody had reason to know about.
43
+ * **schema:** `After<>` and `Before<>` are parsed from the schema into the AST.
44
+
45
+ * **generate:** a rich text column is typed as the document it holds on the way out and as
46
+ `RichText | string` on the way in. The engine emits a trigger that normalises a plain string
47
+ into a Lexical document on insert and update, so prose can be written as prose while a read
48
+ always returns the document. The seed builder gets the same split, and a tightening with it:
49
+ the column was typed as any JSON at all, so a seed could write a bare number into one.
50
+
51
+ ### Bug Fixes
52
+
53
+ * **generate:** the client augmentation follows the order the schema declares its models and
54
+ columns in. It sorted alphabetically, which threw away an order the author chose and the AST
55
+ preserved, and made it disagree with `types/database.ts` about the same table.
56
+ * **generate:** a `Slug` column is no longer demanded on insert. A trigger fills it, so the
57
+ generated type was asking for a value the database was about to overwrite.
58
+ * **generate:** a rich text column is typed as the Lexical document it holds. It was
59
+ `SerializedEditorState | string`, which made the augmentation disagree with
60
+ `types/database.ts` about the same column in the same project.
61
+ * **generate:** the augmentation's columns are indented into the block that holds them.
62
+ * **generate:** the augmentation and the database types use the same named types for storage
63
+ references and rich text, rather than one naming them and the other writing them out.
64
+ * **hooks:** the generated Deno stand-in for rich text loses its `| string` for the same reason,
65
+ and a storage reference is declared beside it.
66
+ * **generate:** the generated output paths are resolved in one place. `generate` applied defaults
67
+ and the seed runner did not, so a project that had configured no output got a builder written
68
+ and then a run that reported it missing.
69
+ * **engine:** a failed seed is reported with its result document. The engine exits non-zero and
70
+ prints what happened, and that was being discarded as a crash with no output.
71
+ * **seed:** a project pinned to an engine with no `seed` subcommand is told so, by name, before
72
+ anything is resolved or downloaded. It got a usage error about an unrecognised argument, which
73
+ names nothing about the project and reads like a broken install.
74
+ * **push:** a schema with a rich text column is refused on an engine that cannot normalise one.
75
+ The generated types accept a string on the way in and promise a document on the way out, and
76
+ the trigger is what makes the second half true; an older engine emits no trigger and rejects
77
+ nothing, so the push succeeded and a later read returned what the types call impossible.
@@ -14,6 +14,26 @@ export interface CacheSeedResult {
14
14
  * creates it.
15
15
  */
16
16
  export declare function seedApiConfigCache(cwd: string, ast: unknown): CacheSeedResult | null;
17
+ /**
18
+ * What a newly declared table is switched on as.
19
+ *
20
+ * `allow_public` follows the declaration rather than defaulting off: the schema saying `public` is
21
+ * a considered statement that this table's reads are the same for everyone, and `push` has already
22
+ * refused it where the read rule varies by caller. Defaulting it off would make the declaration
23
+ * mean nothing until someone ticked a box that the schema had already justified.
24
+ */
25
+ /**
26
+ * What a push or a dev boot should say about cache seeding, as lines to print.
27
+ *
28
+ * Returns the text rather than printing it, because the two callers write to the console
29
+ * differently and the thing worth sharing is the decision about what to say, not the formatting.
30
+ * Extracted from `push` when `dev` grew the same need: `seedApiConfigCache` had exactly one caller
31
+ * for a long time, which is why a stack brought up with `supatype dev` alone had no cache
32
+ * allowlist at all and nothing anywhere said so.
33
+ *
34
+ * Never an error, and never a rewrite of an entry that already exists. See `seedApiConfigCache`.
35
+ */
36
+ export declare function cacheSeedingNotes(cwd: string, ast: unknown): string[];
17
37
  /**
18
38
  * §13.4's note, in the words of the project that will read it — or null when there is nothing to
19
39
  * say.
@@ -1 +1 @@
1
- {"version":3,"file":"api-config-cache.d.ts","sourceRoot":"","sources":["../src/api-config-cache.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,eAAe;IAC9B,0FAA0F;IAC1F,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,yFAAyF;IACzF,QAAQ,EAAE,OAAO,CAAA;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CA4CpF;AAmBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAW9G"}
1
+ {"version":3,"file":"api-config-cache.d.ts","sourceRoot":"","sources":["../src/api-config-cache.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,eAAe;IAC9B,0FAA0F;IAC1F,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,yFAAyF;IACzF,QAAQ,EAAE,OAAO,CAAA;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CA4CpF;AAED;;;;;;;GAOG;AACH;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAiBrE;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAW9G"}
@@ -82,6 +82,33 @@ export function seedApiConfigCache(cwd, ast) {
82
82
  * refused it where the read rule varies by caller. Defaulting it off would make the declaration
83
83
  * mean nothing until someone ticked a box that the schema had already justified.
84
84
  */
85
+ /**
86
+ * What a push or a dev boot should say about cache seeding, as lines to print.
87
+ *
88
+ * Returns the text rather than printing it, because the two callers write to the console
89
+ * differently and the thing worth sharing is the decision about what to say, not the formatting.
90
+ * Extracted from `push` when `dev` grew the same need: `seedApiConfigCache` had exactly one caller
91
+ * for a long time, which is why a stack brought up with `supatype dev` alone had no cache
92
+ * allowlist at all and nothing anywhere said so.
93
+ *
94
+ * Never an error, and never a rewrite of an entry that already exists. See `seedApiConfigCache`.
95
+ */
96
+ export function cacheSeedingNotes(cwd, ast) {
97
+ const result = seedApiConfigCache(cwd, ast);
98
+ if (result === null)
99
+ return [];
100
+ const notes = [];
101
+ if (result.seeded.length > 0) {
102
+ notes.push(`Server cache enabled for ${result.seeded.join(", ")} in .supatype/api-config.json`);
103
+ }
104
+ if (result.ttlIsOff) {
105
+ // A note rather than a fix. Zero is an off switch someone may have chosen, and a push that
106
+ // turned caching on project-wide would be overriding a decision rather than filling in a blank.
107
+ notes.push(`${result.declared.length} table(s) declare a cache, but cache_max_ttl is 0, so nothing ` +
108
+ `is cached until it is set, under API > REST > Settings or in .supatype/api-config.json.`);
109
+ }
110
+ return notes;
111
+ }
85
112
  function seedEntry(entry) {
86
113
  return { enabled: true, allow_public: entry.public === true };
87
114
  }