@supatype/cli 0.3.4 → 0.3.6
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +168 -158
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +36 -0
- package/dist/adopt-walkthrough.d.ts +40 -0
- package/dist/adopt-walkthrough.d.ts.map +1 -0
- package/dist/adopt-walkthrough.js +113 -0
- package/dist/adopt-walkthrough.js.map +1 -0
- package/dist/cli-version-embedded.js +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +7 -16
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +5 -6
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/db.js +3 -3
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +7 -4
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +20 -5
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +5 -7
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +6 -3
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +10 -6
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.js +2 -2
- package/dist/commands/seed.js.map +1 -1
- package/dist/dev-compose.d.ts +42 -0
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +116 -71
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-reset.d.ts +19 -0
- package/dist/dev-db-reset.d.ts.map +1 -0
- package/dist/dev-db-reset.js +75 -0
- package/dist/dev-db-reset.js.map +1 -0
- package/dist/dev-initial-push.d.ts +37 -0
- package/dist/dev-initial-push.d.ts.map +1 -0
- package/dist/dev-initial-push.js +91 -0
- package/dist/dev-initial-push.js.map +1 -0
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +1 -1
- package/dist/dev-ports.js.map +1 -1
- package/dist/diff-output.d.ts +2 -2
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +1 -1
- package/dist/diff-output.js.map +1 -1
- package/dist/engine-client.d.ts +5 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +8 -6
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-push-output.d.ts +10 -0
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +12 -0
- package/dist/engine-push-output.js.map +1 -1
- package/dist/{seed-connection.d.ts → host-database.d.ts} +20 -10
- package/dist/host-database.d.ts.map +1 -0
- package/dist/{seed-connection.js → host-database.js} +40 -14
- package/dist/host-database.js.map +1 -0
- package/dist/resolve-target.d.ts +2 -2
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +15 -11
- package/dist/resolve-target.js.map +1 -1
- package/dist/retired-no-cache.d.ts +18 -0
- package/dist/retired-no-cache.d.ts.map +1 -0
- package/dist/retired-no-cache.js +21 -0
- package/dist/retired-no-cache.js.map +1 -0
- package/dist/self-host-compose.d.ts +6 -0
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +9 -3
- package/dist/self-host-compose.js.map +1 -1
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +31 -25
- package/dist/type-extractor.js.map +1 -1
- package/package.json +2 -2
- package/src/adopt-walkthrough.ts +142 -0
- package/src/cli-version-embedded.ts +1 -1
- package/src/commands/admin.ts +7 -20
- package/src/commands/adopt.ts +5 -6
- package/src/commands/db.ts +3 -3
- package/src/commands/deploy.ts +7 -4
- package/src/commands/dev.ts +22 -6
- package/src/commands/doctor.ts +5 -7
- package/src/commands/init.ts +1 -1
- package/src/commands/migrate.ts +7 -4
- package/src/commands/push.ts +28 -10
- package/src/commands/seed.ts +2 -2
- package/src/dev-compose.ts +166 -77
- package/src/dev-db-reset.ts +95 -0
- package/src/dev-initial-push.ts +134 -0
- package/src/dev-ports.ts +1 -1
- package/src/diff-output.ts +2 -2
- package/src/engine-client.ts +5 -4
- package/src/engine-push-output.ts +19 -0
- package/src/{seed-connection.ts → host-database.ts} +42 -12
- package/src/resolve-target.ts +20 -14
- package/src/retired-no-cache.ts +27 -0
- package/src/self-host-compose.ts +10 -3
- package/src/type-extractor.ts +39 -42
- package/tests/adopt-result.test.ts +27 -0
- package/tests/adopt-walkthrough.test.ts +129 -0
- package/tests/dev-db-reset.test.ts +162 -0
- package/tests/dev-initial-push.test.ts +142 -0
- package/tests/engine-push-output.test.ts +30 -1
- package/tests/host-connection-targets.test.ts +84 -0
- package/tests/{seed-connection.test.ts → host-database.test.ts} +33 -15
- package/tests/retired-no-cache.test.ts +46 -0
- package/tests/type-extractor.test.ts +80 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/seed-connection.d.ts.map +0 -1
- package/dist/seed-connection.js.map +0 -1
|
@@ -300,6 +300,50 @@ export type Post = Model<{
|
|
|
300
300
|
expect(hero).toMatchObject({ kind: "image", bucket: "covers", accessMode: "public" })
|
|
301
301
|
})
|
|
302
302
|
|
|
303
|
+
// A bucket has the same four operations a model has, each its own rule. `update` used to be
|
|
304
|
+
// skipped without a word, so an overwrite rule the author wrote was simply never enforced.
|
|
305
|
+
function bucketWithAccess(access: string): string {
|
|
306
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-bucket-rules-"))
|
|
307
|
+
dirs.push(dir)
|
|
308
|
+
const schemaPath = join(dir, "schema.ts")
|
|
309
|
+
writeFileSync(
|
|
310
|
+
schemaPath,
|
|
311
|
+
`
|
|
312
|
+
import type { Model, UUID, Bucket, BucketPublic, BucketLoggedIn, BucketOwner, FileAsset } from "@supatype/types"
|
|
313
|
+
|
|
314
|
+
export type avatars = Bucket<"avatars", { accessMode: "public"; access: ${access} }>
|
|
315
|
+
|
|
316
|
+
export type Profile = Model<{
|
|
317
|
+
id: UUID
|
|
318
|
+
avatar: FileAsset<avatars>
|
|
319
|
+
}>
|
|
320
|
+
`,
|
|
321
|
+
"utf8",
|
|
322
|
+
)
|
|
323
|
+
return schemaPath
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
it("extracts all four bucket rules, update included", () => {
|
|
327
|
+
const schemaPath = bucketWithAccess(
|
|
328
|
+
"{ read: BucketPublic; create: BucketLoggedIn; update: BucketOwner; delete: BucketOwner }",
|
|
329
|
+
)
|
|
330
|
+
const ast = extractSchemaAstFromTypes(schemaPath, join(schemaPath, ".."))
|
|
331
|
+
const b = ast?.storageBuckets?.find((x) => x.id === "avatars")
|
|
332
|
+
expect(b?.access).toEqual({
|
|
333
|
+
read: { type: "public" },
|
|
334
|
+
create: { type: "authenticated" },
|
|
335
|
+
update: { type: "owner", field: "owner_id" },
|
|
336
|
+
delete: { type: "owner", field: "owner_id" },
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
it("refuses a bucket rule key that is not an operation, rather than dropping it", () => {
|
|
341
|
+
const schemaPath = bucketWithAccess("{ read: BucketPublic; remove: BucketOwner }")
|
|
342
|
+
expect(() => extractSchemaAstFromTypes(schemaPath, join(schemaPath, ".."))).toThrow(
|
|
343
|
+
/Bucket "avatars": `remove` is not a bucket rule\. Use read, create, update or delete\./,
|
|
344
|
+
)
|
|
345
|
+
})
|
|
346
|
+
|
|
303
347
|
it("extracts accessMode custom and s3BucketPolicy string", () => {
|
|
304
348
|
const dir = mkdtempSync(join(tmpdir(), "supatype-bucket-custom-"))
|
|
305
349
|
dirs.push(dir)
|
|
@@ -556,6 +600,42 @@ export type Config = Model<{
|
|
|
556
600
|
expect(config?.options.singleton).toBe(true)
|
|
557
601
|
})
|
|
558
602
|
|
|
603
|
+
it("carries a model's label overrides to the engine as options", () => {
|
|
604
|
+
// Presentation only: the engine passes these to Studio, which otherwise inflects the type
|
|
605
|
+
// name and cannot know that "Places of Interest" has its noun first.
|
|
606
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-model-labels-"))
|
|
607
|
+
dirs.push(dir)
|
|
608
|
+
const schemaPath = join(dir, "schema.ts")
|
|
609
|
+
writeFileSync(
|
|
610
|
+
schemaPath,
|
|
611
|
+
`
|
|
612
|
+
import type { Model, UUID, Public } from "@supatype/types"
|
|
613
|
+
|
|
614
|
+
export type PlacesOfInterest = Model<{
|
|
615
|
+
id: UUID
|
|
616
|
+
}, {
|
|
617
|
+
label: "Place of Interest"
|
|
618
|
+
labelPlural: "Places of Interest"
|
|
619
|
+
access: { read: Public }
|
|
620
|
+
}>
|
|
621
|
+
|
|
622
|
+
export type Post = Model<{
|
|
623
|
+
id: UUID
|
|
624
|
+
}, {
|
|
625
|
+
access: { read: Public }
|
|
626
|
+
}>
|
|
627
|
+
`,
|
|
628
|
+
"utf8",
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
const ast = extractSchemaAstFromTypes(schemaPath, dir)
|
|
632
|
+
const places = ast?.models.find((m) => m.name === "PlacesOfInterest")
|
|
633
|
+
expect(places?.options).toMatchObject({ label: "Place of Interest", labelPlural: "Places of Interest" })
|
|
634
|
+
const post = ast?.models.find((m) => m.name === "Post")
|
|
635
|
+
expect(post?.options).not.toHaveProperty("label")
|
|
636
|
+
expect(post?.options).not.toHaveProperty("labelPlural")
|
|
637
|
+
})
|
|
638
|
+
|
|
559
639
|
it("infers timestamps from WithTimestamps wrapper", () => {
|
|
560
640
|
const dir = mkdtempSync(join(tmpdir(), "supatype-timestamps-"))
|
|
561
641
|
dirs.push(dir)
|