@supatype/cli 0.2.1 → 0.3.1
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 +193 -157
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/api-config-cache.d.ts +34 -0
- package/dist/api-config-cache.d.ts.map +1 -0
- package/dist/api-config-cache.js +123 -0
- package/dist/api-config-cache.js.map +1 -0
- package/dist/cache-identity-scope.d.ts +38 -0
- package/dist/cache-identity-scope.d.ts.map +1 -0
- package/dist/cache-identity-scope.js +70 -0
- package/dist/cache-identity-scope.js.map +1 -0
- package/dist/cache-provider.d.ts +30 -0
- package/dist/cache-provider.d.ts.map +1 -0
- package/dist/cache-provider.js +60 -0
- package/dist/cache-provider.js.map +1 -0
- package/dist/cli-version-embedded.js +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +21 -4
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/cache.d.ts +1 -1
- package/dist/commands/cache.js +3 -3
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +2 -1
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +2 -1
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +61 -8
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +2 -1
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +6 -2
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -9
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts +35 -0
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +90 -6
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +2 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +61 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +2 -1
- package/dist/compose-services.js.map +1 -1
- package/dist/dev-compose.d.ts +13 -0
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +119 -16
- package/dist/dev-compose.js.map +1 -1
- package/dist/engine-floor.d.ts +11 -1
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +49 -16
- package/dist/engine-floor.js.map +1 -1
- package/dist/functions-deno-types.d.ts +9 -0
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +45 -1
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/functions-router-gen.d.ts.map +1 -1
- package/dist/functions-router-gen.js +113 -81
- package/dist/functions-router-gen.js.map +1 -1
- package/dist/kong-config.d.ts +1 -1
- package/dist/model-cache.d.ts +44 -0
- package/dist/model-cache.d.ts.map +1 -0
- package/dist/model-cache.js +106 -0
- package/dist/model-cache.js.map +1 -0
- package/dist/model-hooks.d.ts +5 -0
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +29 -1
- package/dist/model-hooks.js.map +1 -1
- package/dist/model-versioning.d.ts +80 -0
- package/dist/model-versioning.d.ts.map +1 -0
- package/dist/model-versioning.js +140 -0
- package/dist/model-versioning.js.map +1 -0
- package/dist/postgres-ctl.d.ts +55 -0
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +84 -8
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/preview-config-check.d.ts +21 -0
- package/dist/preview-config-check.d.ts.map +1 -0
- package/dist/preview-config-check.js +47 -0
- package/dist/preview-config-check.js.map +1 -0
- package/dist/project-config.d.ts +182 -5
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +125 -8
- package/dist/project-config.js.map +1 -1
- package/dist/resolve-target.d.ts +9 -0
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-cache-admin.d.ts.map +1 -1
- package/dist/rest-cache-admin.js +6 -2
- package/dist/rest-cache-admin.js.map +1 -1
- package/dist/schema-ast-v2.d.ts +32 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js +14 -1
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/self-host-compose.d.ts +20 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +227 -29
- package/dist/self-host-compose.js.map +1 -1
- package/dist/studio-admin-roles.d.ts +8 -1
- package/dist/studio-admin-roles.d.ts.map +1 -1
- package/dist/studio-admin-roles.js +16 -2
- package/dist/studio-admin-roles.js.map +1 -1
- package/dist/type-extractor.d.ts +7 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +234 -3
- package/dist/type-extractor.js.map +1 -1
- package/package.json +2 -2
- package/src/api-config-cache.ts +142 -0
- package/src/cache-identity-scope.ts +92 -0
- package/src/cache-provider.ts +61 -0
- package/src/cli-version-embedded.ts +1 -1
- package/src/commands/add.ts +1 -1
- package/src/commands/admin.ts +23 -6
- package/src/commands/cache.ts +3 -3
- package/src/commands/cloud.ts +2 -1
- package/src/commands/deploy.ts +2 -1
- package/src/commands/dev.ts +68 -7
- package/src/commands/diff.ts +2 -1
- package/src/commands/functions.ts +6 -2
- package/src/commands/init.ts +13 -9
- package/src/commands/keys.ts +112 -7
- package/src/commands/migrate.ts +2 -1
- package/src/commands/push.ts +68 -1
- package/src/compose-services.ts +2 -1
- package/src/dev-compose.ts +151 -15
- package/src/engine-floor.ts +73 -16
- package/src/functions-deno-types.ts +48 -1
- package/src/functions-router-gen.ts +113 -81
- package/src/kong-config.ts +1 -1
- package/src/model-cache.ts +122 -0
- package/src/model-hooks.ts +26 -2
- package/src/model-versioning.ts +167 -0
- package/src/postgres-ctl.ts +103 -9
- package/src/preview-config-check.ts +52 -0
- package/src/project-config.ts +273 -11
- package/src/resolve-target.ts +11 -1
- package/src/rest-cache-admin.ts +8 -2
- package/src/schema-ast-v2.ts +47 -0
- package/src/self-host-compose.ts +250 -29
- package/src/studio-admin-roles.ts +16 -2
- package/src/type-extractor.ts +281 -2
- package/tests/api-config-cache-seed.test.ts +180 -0
- package/tests/cache-identity-scope.test.ts +61 -0
- package/tests/cache-provider-config.test.ts +132 -0
- package/tests/engine-floor.test.ts +43 -0
- package/tests/external-database-compose.test.ts +74 -3
- package/tests/field-masking-tier.test.ts +3 -3
- package/tests/fixtures/identity-scope-corpus.json +42 -0
- package/tests/functions-concurrency.test.ts +71 -0
- package/tests/init.test.ts +36 -2
- package/tests/keys-write.test.ts +148 -0
- package/tests/model-cache-declaration.test.ts +229 -0
- package/tests/model-cache-manifest.test.ts +99 -0
- package/tests/model-hooks.test.ts +55 -0
- package/tests/model-versions.test.ts +229 -0
- package/tests/native-keyspace.test.ts +130 -0
- package/tests/preview-config-check.test.ts +104 -0
- package/tests/rest-cache-admin.test.ts +36 -0
- package/tests/runtime-contract.test.ts +176 -22
- package/tests/studio-admin-roles.test.ts +32 -0
- package/tests/type-extractor.test.ts +113 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1371,4 +1371,117 @@ export type Review = Model<{
|
|
|
1371
1371
|
// A field with no constraint modifier carries no validation key at all.
|
|
1372
1372
|
expect(review?.fields["note"]?.["validation"]).toBeUndefined()
|
|
1373
1373
|
})
|
|
1374
|
+
|
|
1375
|
+
it("carries Searchable through to the model's searchFields", () => {
|
|
1376
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-types-"))
|
|
1377
|
+
dirs.push(dir)
|
|
1378
|
+
const schemaPath = join(dir, "schema.ts")
|
|
1379
|
+
writeFileSync(
|
|
1380
|
+
schemaPath,
|
|
1381
|
+
`
|
|
1382
|
+
import type { Model, UUID, Optional, Searchable, Public } from "@supatype/types"
|
|
1383
|
+
|
|
1384
|
+
export type Article = Model<{
|
|
1385
|
+
id: UUID
|
|
1386
|
+
title: Searchable<string>
|
|
1387
|
+
subtitle: Optional<Searchable<string>>
|
|
1388
|
+
views: number
|
|
1389
|
+
}, {
|
|
1390
|
+
access: { read: Public }
|
|
1391
|
+
}>
|
|
1392
|
+
`,
|
|
1393
|
+
"utf8",
|
|
1394
|
+
)
|
|
1395
|
+
|
|
1396
|
+
const ast = extractSchemaAstFromTypes(schemaPath, dir)
|
|
1397
|
+
const article = ast?.models.find((m) => m.name === "Article")
|
|
1398
|
+
|
|
1399
|
+
// The flag reaches the field, and the model gains the list Studio reads to decide whether to
|
|
1400
|
+
// render its search box at all. This used to be dropped on the floor by the extractor.
|
|
1401
|
+
expect(article?.fields["title"]?.annotations?.platform?.searchable).toBe(true)
|
|
1402
|
+
expect(article?.annotations.platform.searchFields).toEqual(["title", "subtitle"])
|
|
1403
|
+
expect(article?.fields["views"]?.annotations?.platform?.searchable).toBeUndefined()
|
|
1404
|
+
|
|
1405
|
+
// Unwrapping still happens: Searchable<string> is a text column, not a wrapper type.
|
|
1406
|
+
expect(article?.fields["title"]).toMatchObject({ kind: "text" })
|
|
1407
|
+
expect(article?.fields["subtitle"]).toMatchObject({ kind: "text", required: false })
|
|
1408
|
+
})
|
|
1409
|
+
|
|
1410
|
+
it("lets a model order its search fields explicitly", () => {
|
|
1411
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-types-"))
|
|
1412
|
+
dirs.push(dir)
|
|
1413
|
+
const schemaPath = join(dir, "schema.ts")
|
|
1414
|
+
writeFileSync(
|
|
1415
|
+
schemaPath,
|
|
1416
|
+
`
|
|
1417
|
+
import type { Model, UUID, Searchable, Public } from "@supatype/types"
|
|
1418
|
+
|
|
1419
|
+
export type Person = Model<{
|
|
1420
|
+
id: UUID
|
|
1421
|
+
email: Searchable<string>
|
|
1422
|
+
name: string
|
|
1423
|
+
}, {
|
|
1424
|
+
searchable: ["name"]
|
|
1425
|
+
access: { read: Public }
|
|
1426
|
+
}>
|
|
1427
|
+
`,
|
|
1428
|
+
"utf8",
|
|
1429
|
+
)
|
|
1430
|
+
|
|
1431
|
+
const ast = extractSchemaAstFromTypes(schemaPath, dir)
|
|
1432
|
+
const person = ast?.models.find((m) => m.name === "Person")
|
|
1433
|
+
|
|
1434
|
+
// The declared order wins, because the list view filters on the first entry, and a field
|
|
1435
|
+
// flagged but unlisted still follows rather than being lost.
|
|
1436
|
+
expect(person?.annotations.platform.searchFields).toEqual(["name", "email"])
|
|
1437
|
+
})
|
|
1438
|
+
|
|
1439
|
+
it("refuses a searchable column that is not a field", () => {
|
|
1440
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-types-"))
|
|
1441
|
+
dirs.push(dir)
|
|
1442
|
+
const schemaPath = join(dir, "schema.ts")
|
|
1443
|
+
writeFileSync(
|
|
1444
|
+
schemaPath,
|
|
1445
|
+
`
|
|
1446
|
+
import type { Model, UUID, Public } from "@supatype/types"
|
|
1447
|
+
|
|
1448
|
+
export type Widget = Model<{
|
|
1449
|
+
id: UUID
|
|
1450
|
+
label: string
|
|
1451
|
+
}, {
|
|
1452
|
+
searchable: ["lable"]
|
|
1453
|
+
access: { read: Public }
|
|
1454
|
+
}>
|
|
1455
|
+
`,
|
|
1456
|
+
"utf8",
|
|
1457
|
+
)
|
|
1458
|
+
|
|
1459
|
+
// A typo here used to compile and produce a model with no search at all. Naming the column
|
|
1460
|
+
// and the alternatives is the whole point: the failure is otherwise invisible.
|
|
1461
|
+
expect(() => extractSchemaAstFromTypes(schemaPath, dir)).toThrow(/"lable"/)
|
|
1462
|
+
})
|
|
1463
|
+
|
|
1464
|
+
it("omits searchFields entirely when nothing is searchable", () => {
|
|
1465
|
+
const dir = mkdtempSync(join(tmpdir(), "supatype-types-"))
|
|
1466
|
+
dirs.push(dir)
|
|
1467
|
+
const schemaPath = join(dir, "schema.ts")
|
|
1468
|
+
writeFileSync(
|
|
1469
|
+
schemaPath,
|
|
1470
|
+
`
|
|
1471
|
+
import type { Model, UUID, Public } from "@supatype/types"
|
|
1472
|
+
|
|
1473
|
+
export type Event = Model<{
|
|
1474
|
+
id: UUID
|
|
1475
|
+
name: string
|
|
1476
|
+
}, {
|
|
1477
|
+
access: { read: Public }
|
|
1478
|
+
}>
|
|
1479
|
+
`,
|
|
1480
|
+
"utf8",
|
|
1481
|
+
)
|
|
1482
|
+
|
|
1483
|
+
const ast = extractSchemaAstFromTypes(schemaPath, dir)
|
|
1484
|
+
const event = ast?.models.find((m) => m.name === "Event")
|
|
1485
|
+
expect(event?.annotations.platform.searchFields).toBeUndefined()
|
|
1486
|
+
})
|
|
1374
1487
|
})
|