@supacloud/cli 0.120.1 → 0.121.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/README.md +10 -9
- package/dist/index.js +639 -141
- package/dist/shared/tools/app-database-check.d.ts +2 -0
- package/dist/shared/tools/app-starter-database.d.ts +2 -1
- package/dist/shared/tools/app-starter-templates.d.ts +20 -3
- package/dist/shared/tools/app-starter.d.ts +3 -2
- package/dist/shared/tools/app-tools.d.ts +1 -1
- package/dist/shared/tools/lite-cli-tools.d.ts +5 -0
- package/package.json +10 -10
- package/skills/supacloud/references/app-workflow.md +3 -0
package/dist/index.js
CHANGED
|
@@ -10149,11 +10149,13 @@ var DeliveryOptionsSchema = _Object_({
|
|
|
10149
10149
|
}, objectOptions), { maxItems: 128 })),
|
|
10150
10150
|
httpApplications: Optional(_Array_(_Object_({
|
|
10151
10151
|
target: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
10152
|
-
source: DeliveryFilePathSchema
|
|
10152
|
+
source: DeliveryFilePathSchema,
|
|
10153
|
+
database: Optional(Boolean2())
|
|
10153
10154
|
}, objectOptions))),
|
|
10154
10155
|
workerApplications: Optional(_Array_(_Object_({
|
|
10155
10156
|
target: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
10156
|
-
source: DeliveryFilePathSchema
|
|
10157
|
+
source: DeliveryFilePathSchema,
|
|
10158
|
+
database: Optional(Boolean2())
|
|
10157
10159
|
}, objectOptions))),
|
|
10158
10160
|
assets: Optional(_Array_(_Object_({
|
|
10159
10161
|
target: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
@@ -11145,10 +11147,103 @@ function summarizeDeploymentEvidence(value) {
|
|
|
11145
11147
|
liveObservationPerformed: false
|
|
11146
11148
|
};
|
|
11147
11149
|
}
|
|
11148
|
-
// node_modules/@supacloud/delivery/src/
|
|
11150
|
+
// node_modules/@supacloud/delivery/src/platform-deployment.ts
|
|
11151
|
+
var closed6 = { additionalProperties: false };
|
|
11149
11152
|
var sha2563 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11150
|
-
var
|
|
11153
|
+
var releaseId = String2({ pattern: "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$" });
|
|
11154
|
+
var mutationId = String2({ pattern: "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$" });
|
|
11151
11155
|
var isoDate2 = String2({ minLength: 20, maxLength: 40 });
|
|
11156
|
+
var PLATFORM_DEPLOYMENT_STATE_SCHEMA = "supacloud.platform-deployment-state.v1";
|
|
11157
|
+
var componentName2 = Union([
|
|
11158
|
+
Literal("management-api"),
|
|
11159
|
+
Literal("web-console"),
|
|
11160
|
+
Literal("caddy"),
|
|
11161
|
+
Literal("postgres"),
|
|
11162
|
+
Literal("postgrest"),
|
|
11163
|
+
Literal("gotrue"),
|
|
11164
|
+
Literal("realtime"),
|
|
11165
|
+
Literal("storage"),
|
|
11166
|
+
Literal("victoria-logs"),
|
|
11167
|
+
Literal("edge-runtime")
|
|
11168
|
+
]);
|
|
11169
|
+
var componentStatus = Union([
|
|
11170
|
+
Literal("ready"),
|
|
11171
|
+
Literal("stopped"),
|
|
11172
|
+
Literal("starting"),
|
|
11173
|
+
Literal("unhealthy"),
|
|
11174
|
+
Literal("failed"),
|
|
11175
|
+
Literal("unknown")
|
|
11176
|
+
]);
|
|
11177
|
+
var desiredStatus = Union([Literal("running"), Literal("stopped")]);
|
|
11178
|
+
var actualStatus = Union([
|
|
11179
|
+
Literal("absent"),
|
|
11180
|
+
Literal("starting"),
|
|
11181
|
+
Literal("running"),
|
|
11182
|
+
Literal("stopped"),
|
|
11183
|
+
Literal("degraded"),
|
|
11184
|
+
Literal("failed"),
|
|
11185
|
+
Literal("unknown")
|
|
11186
|
+
]);
|
|
11187
|
+
var operationPhase = Union([
|
|
11188
|
+
Literal("idle"),
|
|
11189
|
+
Literal("preparing"),
|
|
11190
|
+
Literal("activating"),
|
|
11191
|
+
Literal("verifying"),
|
|
11192
|
+
Literal("confirmed"),
|
|
11193
|
+
Literal("failed"),
|
|
11194
|
+
Literal("unknown"),
|
|
11195
|
+
Literal("rolled-back")
|
|
11196
|
+
]);
|
|
11197
|
+
var retryAction = Union([
|
|
11198
|
+
Literal("none"),
|
|
11199
|
+
Literal("reconcile-same-mutation"),
|
|
11200
|
+
Literal("manual-recovery"),
|
|
11201
|
+
Literal("new-mutation")
|
|
11202
|
+
]);
|
|
11203
|
+
var PlatformDeploymentComponentSchema = _Object_({
|
|
11204
|
+
name: componentName2,
|
|
11205
|
+
version: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
11206
|
+
status: componentStatus,
|
|
11207
|
+
health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
|
|
11208
|
+
checked_at: Union([isoDate2, Null()])
|
|
11209
|
+
}, closed6);
|
|
11210
|
+
var PlatformDeploymentStateSchema = _Object_({
|
|
11211
|
+
schema: Literal(PLATFORM_DEPLOYMENT_STATE_SCHEMA),
|
|
11212
|
+
profile: Literal("single-node"),
|
|
11213
|
+
host: _Object_({
|
|
11214
|
+
os: Literal("linux"),
|
|
11215
|
+
distribution: Literal("ubuntu"),
|
|
11216
|
+
version: Literal("24.04"),
|
|
11217
|
+
architecture: Literal("amd64"),
|
|
11218
|
+
init: Literal("systemd")
|
|
11219
|
+
}, closed6),
|
|
11220
|
+
desired: _Object_({
|
|
11221
|
+
state: desiredStatus,
|
|
11222
|
+
release_id: Union([releaseId, Null()]),
|
|
11223
|
+
manifest_sha256: Union([sha2563, Null()])
|
|
11224
|
+
}, closed6),
|
|
11225
|
+
actual: _Object_({
|
|
11226
|
+
state: actualStatus,
|
|
11227
|
+
release_id: Union([releaseId, Null()]),
|
|
11228
|
+
manifest_sha256: Union([sha2563, Null()]),
|
|
11229
|
+
checked_at: Union([isoDate2, Null()]),
|
|
11230
|
+
components: _Array_(PlatformDeploymentComponentSchema, { minItems: 1, maxItems: 16 })
|
|
11231
|
+
}, closed6),
|
|
11232
|
+
operation: _Object_({
|
|
11233
|
+
mutation_id: Union([mutationId, Null()]),
|
|
11234
|
+
phase: operationPhase,
|
|
11235
|
+
retry: retryAction,
|
|
11236
|
+
error: Union([String2({ minLength: 1, maxLength: 512 }), Null()])
|
|
11237
|
+
}, closed6),
|
|
11238
|
+
rollback: _Object_({
|
|
11239
|
+
release_id: Union([releaseId, Null()]),
|
|
11240
|
+
ready: Boolean2()
|
|
11241
|
+
}, closed6)
|
|
11242
|
+
}, closed6);
|
|
11243
|
+
// node_modules/@supacloud/delivery/src/delivery-tuple.ts
|
|
11244
|
+
var sha2564 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11245
|
+
var commit = String2({ pattern: "^(?:[a-f0-9]{40}|[a-f0-9]{64})$" });
|
|
11246
|
+
var isoDate3 = String2({ minLength: 20, maxLength: 40 });
|
|
11152
11247
|
var DELIVERY_TUPLE_SCHEMA = "supacloud.fa-delivery-tuple.v1";
|
|
11153
11248
|
var FaDeliveryTupleSchema = _Object_({
|
|
11154
11249
|
schema: Literal(DELIVERY_TUPLE_SCHEMA),
|
|
@@ -11160,21 +11255,21 @@ var FaDeliveryTupleSchema = _Object_({
|
|
|
11160
11255
|
platform_commit: commit,
|
|
11161
11256
|
edge_runtime: _Object_({
|
|
11162
11257
|
version: String2({ minLength: 1, maxLength: 128 }),
|
|
11163
|
-
artifact_sha256:
|
|
11258
|
+
artifact_sha256: sha2564
|
|
11164
11259
|
}, { additionalProperties: false }),
|
|
11165
11260
|
compatibility_window: _Object_({
|
|
11166
11261
|
contract_schema: String2({ minLength: 1, maxLength: 128 }),
|
|
11167
|
-
starts_at:
|
|
11168
|
-
ends_at:
|
|
11262
|
+
starts_at: isoDate3,
|
|
11263
|
+
ends_at: isoDate3,
|
|
11169
11264
|
old_client_supported: Boolean2(),
|
|
11170
11265
|
partial_deployment_supported: Boolean2()
|
|
11171
11266
|
}, { additionalProperties: false })
|
|
11172
11267
|
}, { additionalProperties: false });
|
|
11173
11268
|
// node_modules/@supacloud/delivery/src/contract-matrix.ts
|
|
11174
|
-
var
|
|
11175
|
-
var
|
|
11269
|
+
var closed7 = { additionalProperties: false };
|
|
11270
|
+
var sha2565 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11176
11271
|
var generation = Union([Literal("old"), Literal("new")]);
|
|
11177
|
-
var versions = _Object_({ old:
|
|
11272
|
+
var versions = _Object_({ old: sha2565, new: sha2565 }, closed7);
|
|
11178
11273
|
var CONTRACT_MATRIX_SCHEMA = "supacloud.consumer-contract-matrix.v1";
|
|
11179
11274
|
var FA_CONTRACT_SCENARIOS = [
|
|
11180
11275
|
"missing-display-field",
|
|
@@ -11187,9 +11282,9 @@ var FA_CONTRACT_SCENARIOS = [
|
|
|
11187
11282
|
var ConsumerContractMatrixSchema = _Object_({
|
|
11188
11283
|
schema: Literal(CONTRACT_MATRIX_SCHEMA),
|
|
11189
11284
|
customer: Literal("xigu-fa"),
|
|
11190
|
-
baseline_tuple_sha256:
|
|
11191
|
-
candidate_tuple_sha256:
|
|
11192
|
-
artifacts: _Object_({ frontend: versions, functions: versions, database: versions },
|
|
11285
|
+
baseline_tuple_sha256: sha2565,
|
|
11286
|
+
candidate_tuple_sha256: sha2565,
|
|
11287
|
+
artifacts: _Object_({ frontend: versions, functions: versions, database: versions }, closed7),
|
|
11193
11288
|
cases: _Array_(_Object_({
|
|
11194
11289
|
frontend: generation,
|
|
11195
11290
|
functions: generation,
|
|
@@ -11197,11 +11292,11 @@ var ConsumerContractMatrixSchema = _Object_({
|
|
|
11197
11292
|
scenarios: _Array_(_Object_({
|
|
11198
11293
|
name: Enum(FA_CONTRACT_SCENARIOS),
|
|
11199
11294
|
expected: Union([Literal("compatible"), Literal("blocked-safely")])
|
|
11200
|
-
},
|
|
11201
|
-
},
|
|
11202
|
-
},
|
|
11295
|
+
}, closed7), { minItems: FA_CONTRACT_SCENARIOS.length, maxItems: FA_CONTRACT_SCENARIOS.length })
|
|
11296
|
+
}, closed7), { minItems: 8, maxItems: 8 })
|
|
11297
|
+
}, closed7);
|
|
11203
11298
|
// node_modules/@supacloud/delivery/src/fa-stability.ts
|
|
11204
|
-
var
|
|
11299
|
+
var closed8 = { additionalProperties: false };
|
|
11205
11300
|
var hash3 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11206
11301
|
var label = String2({ minLength: 1, maxLength: 256, pattern: "\\S" });
|
|
11207
11302
|
var timestamp2 = String2({ minLength: 24, maxLength: 24 });
|
|
@@ -11224,7 +11319,7 @@ var operation = Enum(FA_BUSINESS_OPERATIONS);
|
|
|
11224
11319
|
var proof = _Object_({
|
|
11225
11320
|
path: String2({ pattern: "^[A-Za-z0-9_-][A-Za-z0-9_./-]{0,255}$" }),
|
|
11226
11321
|
sha256: hash3
|
|
11227
|
-
},
|
|
11322
|
+
}, closed8);
|
|
11228
11323
|
var FaBusinessObservationSchema = _Object_({
|
|
11229
11324
|
id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
|
|
11230
11325
|
tuple_sha256: hash3,
|
|
@@ -11234,7 +11329,7 @@ var FaBusinessObservationSchema = _Object_({
|
|
|
11234
11329
|
outcome: Enum(["success", "failure", "timeout", "unknown"]),
|
|
11235
11330
|
attempts: Integer({ minimum: 1, maximum: 1000 }),
|
|
11236
11331
|
rollbacks: count
|
|
11237
|
-
},
|
|
11332
|
+
}, closed8);
|
|
11238
11333
|
var FaServiceObjectivesSchema = _Object_({
|
|
11239
11334
|
status: Literal("approved"),
|
|
11240
11335
|
owner: label,
|
|
@@ -11250,8 +11345,8 @@ var FaServiceObjectivesSchema = _Object_({
|
|
|
11250
11345
|
minimum_samples: Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
|
|
11251
11346
|
availability_percent: Number2({ exclusiveMinimum: 0, maximum: 100 }),
|
|
11252
11347
|
p95_ms: Number2({ exclusiveMinimum: 0, maximum: Number.MAX_SAFE_INTEGER })
|
|
11253
|
-
},
|
|
11254
|
-
},
|
|
11348
|
+
}, closed8), { minItems: FA_BUSINESS_OPERATIONS.length, maxItems: FA_BUSINESS_OPERATIONS.length })
|
|
11349
|
+
}, closed8);
|
|
11255
11350
|
var FaStabilityEvidenceSchema = _Object_({
|
|
11256
11351
|
schema: Literal("supacloud.fa-stability-evidence.v1"),
|
|
11257
11352
|
environment: environment2,
|
|
@@ -11277,7 +11372,7 @@ var FaStabilityEvidenceSchema = _Object_({
|
|
|
11277
11372
|
passed: Boolean2(),
|
|
11278
11373
|
measured_at: timestamp2,
|
|
11279
11374
|
proof
|
|
11280
|
-
},
|
|
11375
|
+
}, closed8), { minItems: 10, maxItems: 10 }),
|
|
11281
11376
|
matrix: _Array_(_Object_({
|
|
11282
11377
|
combination: label,
|
|
11283
11378
|
scenario: label,
|
|
@@ -11286,16 +11381,16 @@ var FaStabilityEvidenceSchema = _Object_({
|
|
|
11286
11381
|
passed: Boolean2(),
|
|
11287
11382
|
measured_at: timestamp2,
|
|
11288
11383
|
proof
|
|
11289
|
-
},
|
|
11384
|
+
}, closed8), { minItems: 48, maxItems: 48 }),
|
|
11290
11385
|
observation: proof,
|
|
11291
|
-
alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 },
|
|
11292
|
-
},
|
|
11386
|
+
alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 }, closed8)
|
|
11387
|
+
}, closed8);
|
|
11293
11388
|
// node_modules/@supacloud/delivery/src/application-promotion.ts
|
|
11294
|
-
var
|
|
11389
|
+
var closed9 = { additionalProperties: false };
|
|
11295
11390
|
var projectRef2 = String2({ pattern: "^[a-z0-9-]{1,20}$" });
|
|
11296
|
-
var
|
|
11391
|
+
var sha2566 = ApplicationReleaseIdSchema;
|
|
11297
11392
|
var nullableActivation2 = Union([ApplicationActivationIdSchema, Null()]);
|
|
11298
|
-
var nullableDigest = Union([
|
|
11393
|
+
var nullableDigest = Union([sha2566, Null()]);
|
|
11299
11394
|
var observation = {
|
|
11300
11395
|
activation_id: nullableActivation2,
|
|
11301
11396
|
receipt_confirmed: Boolean2(),
|
|
@@ -11321,33 +11416,33 @@ var ApplicationPromotionPlanSchema = _Object_({
|
|
|
11321
11416
|
project_ref: projectRef2,
|
|
11322
11417
|
application_id: ApplicationIdSchema,
|
|
11323
11418
|
environment_id: ApplicationIdSchema,
|
|
11324
|
-
manifest_sha256:
|
|
11325
|
-
plan_sha256:
|
|
11419
|
+
manifest_sha256: sha2566,
|
|
11420
|
+
plan_sha256: sha2566,
|
|
11326
11421
|
source: _Object_({
|
|
11327
11422
|
project_ref: projectRef2,
|
|
11328
11423
|
environment_id: ApplicationIdSchema,
|
|
11329
|
-
release_id:
|
|
11424
|
+
release_id: sha2566,
|
|
11330
11425
|
...observation
|
|
11331
|
-
},
|
|
11426
|
+
}, closed9),
|
|
11332
11427
|
target: _Object_({
|
|
11333
|
-
candidate_release_id:
|
|
11334
|
-
current_release_id: Union([
|
|
11428
|
+
candidate_release_id: sha2566,
|
|
11429
|
+
current_release_id: Union([sha2566, Null()]),
|
|
11335
11430
|
artifact_action: Union([Literal("materialize"), Literal("reuse")]),
|
|
11336
11431
|
configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
|
|
11337
11432
|
configuration: Union([ApplicationConfigurationViewSchema, Null()]),
|
|
11338
11433
|
...observation
|
|
11339
|
-
},
|
|
11434
|
+
}, closed9),
|
|
11340
11435
|
migrations: _Object_({
|
|
11341
|
-
ledger_digest:
|
|
11436
|
+
ledger_digest: sha2566,
|
|
11342
11437
|
ledger_compatible: Boolean2(),
|
|
11343
11438
|
project_migrations_applied: Boolean2(),
|
|
11344
11439
|
pending_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { maxItems: 4096, uniqueItems: true }),
|
|
11345
11440
|
operator_provisioning_required: Boolean2()
|
|
11346
|
-
},
|
|
11441
|
+
}, closed9),
|
|
11347
11442
|
backup: _Object_({
|
|
11348
11443
|
required: Boolean2(),
|
|
11349
11444
|
confirmed: Literal(false)
|
|
11350
|
-
},
|
|
11445
|
+
}, closed9),
|
|
11351
11446
|
action: Union([Literal("promote"), Literal("no-op"), Literal("blocked")]),
|
|
11352
11447
|
blockers: _Array_(Enum([...blocker]), {
|
|
11353
11448
|
maxItems: blocker.length,
|
|
@@ -11356,7 +11451,7 @@ var ApplicationPromotionPlanSchema = _Object_({
|
|
|
11356
11451
|
steps: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 8, uniqueItems: true }),
|
|
11357
11452
|
execution_performed: Literal(false),
|
|
11358
11453
|
data_recovery: Literal("separate-required")
|
|
11359
|
-
},
|
|
11454
|
+
}, closed9);
|
|
11360
11455
|
function applicationPromotionPlanDigest(value) {
|
|
11361
11456
|
return digest(canonical(value));
|
|
11362
11457
|
}
|
|
@@ -11932,8 +12027,7 @@ function topLevelDoBodies(sql) {
|
|
|
11932
12027
|
const masked = maskSqlPolicyNoise(sql);
|
|
11933
12028
|
const doKeywordPattern = /(?:^|;)\s*DO\b/gi;
|
|
11934
12029
|
const bodies = [];
|
|
11935
|
-
|
|
11936
|
-
while ((match = doKeywordPattern.exec(masked)) !== null) {
|
|
12030
|
+
while (doKeywordPattern.exec(masked) !== null) {
|
|
11937
12031
|
const body = doStatementBody(sql, doKeywordPattern.lastIndex);
|
|
11938
12032
|
if (body !== null)
|
|
11939
12033
|
bodies.push(body);
|
|
@@ -15763,7 +15857,7 @@ function scaffoldFiles(framework, slug) {
|
|
|
15763
15857
|
"package.json": JSON.stringify({
|
|
15764
15858
|
private: true,
|
|
15765
15859
|
type: "module",
|
|
15766
|
-
dependencies: { elysia: "2.0.0-rc.
|
|
15860
|
+
dependencies: { elysia: "2.0.0-rc.3" }
|
|
15767
15861
|
}, null, 2) + `
|
|
15768
15862
|
`,
|
|
15769
15863
|
"index.ts": `import { Elysia } from "elysia";
|
|
@@ -18118,7 +18212,7 @@ var ApplicationDeployRequestSchema2 = ApplicationDeployRequestSchema;
|
|
|
18118
18212
|
var ApplicationDeployWebReleaseSchema2 = ApplicationDeployWebReleaseSchema;
|
|
18119
18213
|
|
|
18120
18214
|
// src/shared/tools/application-workflow-schemas.ts
|
|
18121
|
-
var
|
|
18215
|
+
var closed10 = { additionalProperties: false };
|
|
18122
18216
|
var ref5 = String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" });
|
|
18123
18217
|
var uuid = ApplicationActivationIdSchema2;
|
|
18124
18218
|
var nullableUuid = Union([uuid, Null()]);
|
|
@@ -18132,7 +18226,7 @@ var ApplicationPromotionResultSchema = _Object_({
|
|
|
18132
18226
|
plan_sha256: ApplicationReleaseIdSchema2,
|
|
18133
18227
|
action: Literal("promote"),
|
|
18134
18228
|
replayed: Boolean2()
|
|
18135
|
-
},
|
|
18229
|
+
}, closed10);
|
|
18136
18230
|
var ApplicationPromotionStatusSchema = _Object_({
|
|
18137
18231
|
...scope2,
|
|
18138
18232
|
mutation: Unknown(),
|
|
@@ -18151,8 +18245,8 @@ var ApplicationPromotionStatusSchema = _Object_({
|
|
|
18151
18245
|
configuration_id: Union([ApplicationConfigurationIdSchema2, Null()]),
|
|
18152
18246
|
backup_id: Union([String2({ pattern: "^logical-full_[a-z0-9-]{1,20}_[a-f0-9]{32}$" }), Null()]),
|
|
18153
18247
|
data_recovery: Literal("separate-required")
|
|
18154
|
-
},
|
|
18155
|
-
},
|
|
18248
|
+
}, closed10)
|
|
18249
|
+
}, closed10);
|
|
18156
18250
|
var phase = Union([Literal("pending"), Literal("ready"), Literal("failed"), Literal("cleaned")]);
|
|
18157
18251
|
var previewId = String2({ pattern: "^[a-f0-9-]{8,64}$" });
|
|
18158
18252
|
var name = String2({ minLength: 1, maxLength: 256 });
|
|
@@ -18171,39 +18265,39 @@ var ApplicationPreviewReceiptSchema2 = _Object_({
|
|
|
18171
18265
|
Literal("cleaned")
|
|
18172
18266
|
]),
|
|
18173
18267
|
resources: _Object_({
|
|
18174
|
-
build_artifact: _Object_({ status: phase, release_id: ApplicationReleaseIdSchema2 },
|
|
18268
|
+
build_artifact: _Object_({ status: phase, release_id: ApplicationReleaseIdSchema2 }, closed10),
|
|
18175
18269
|
database_branch: _Object_({
|
|
18176
18270
|
status: phase,
|
|
18177
18271
|
branch_ref: ref5,
|
|
18178
18272
|
data_mode: Union([Literal("schema_only"), Literal("full_clone")])
|
|
18179
|
-
},
|
|
18180
|
-
queue_namespace: _Object_({ status: phase, namespace: name },
|
|
18181
|
-
storage_namespace: _Object_({ status: phase, namespace: name },
|
|
18182
|
-
test_secret: _Object_({ status: phase, name, value_issued: Literal(false) },
|
|
18183
|
-
configuration_revision: _Object_({ status: phase, configuration_id: Union([ApplicationConfigurationIdSchema2, Null()]) },
|
|
18184
|
-
application_activation: _Object_({ status: phase, activation_id: nullableUuid },
|
|
18273
|
+
}, closed10),
|
|
18274
|
+
queue_namespace: _Object_({ status: phase, namespace: name }, closed10),
|
|
18275
|
+
storage_namespace: _Object_({ status: phase, namespace: name }, closed10),
|
|
18276
|
+
test_secret: _Object_({ status: phase, name, value_issued: Literal(false) }, closed10),
|
|
18277
|
+
configuration_revision: _Object_({ status: phase, configuration_id: Union([ApplicationConfigurationIdSchema2, Null()]) }, closed10),
|
|
18278
|
+
application_activation: _Object_({ status: phase, activation_id: nullableUuid }, closed10),
|
|
18185
18279
|
functions: Optional(_Object_({
|
|
18186
18280
|
status: phase,
|
|
18187
18281
|
slugs: _Array_(String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }), { maxItems: 64, uniqueItems: true })
|
|
18188
|
-
},
|
|
18189
|
-
smoke_test: _Object_({ status: phase, checks, passed: checks, failed: checks },
|
|
18190
|
-
},
|
|
18282
|
+
}, closed10)),
|
|
18283
|
+
smoke_test: _Object_({ status: phase, checks, passed: checks, failed: checks }, closed10)
|
|
18284
|
+
}, closed10),
|
|
18191
18285
|
cleanup: _Object_({
|
|
18192
18286
|
required: Boolean2(),
|
|
18193
18287
|
completed: Boolean2(),
|
|
18194
18288
|
error: Union([String2({ pattern: "^[A-Z][A-Z0-9_]{0,63}$" }), Null()])
|
|
18195
|
-
},
|
|
18289
|
+
}, closed10),
|
|
18196
18290
|
branch_name: Optional(String2({ minLength: 1, maxLength: 80 })),
|
|
18197
18291
|
queue_name: Optional(name),
|
|
18198
18292
|
test_secret_name: Optional(name),
|
|
18199
18293
|
source_configuration_id: Optional(Union([ApplicationConfigurationIdSchema2, Null()])),
|
|
18200
18294
|
created_at: Optional(timestamp3),
|
|
18201
18295
|
updated_at: Optional(timestamp3)
|
|
18202
|
-
},
|
|
18296
|
+
}, closed10);
|
|
18203
18297
|
var previewListSchema = _Object_({
|
|
18204
18298
|
...scope2,
|
|
18205
18299
|
previews: _Array_(ApplicationPreviewReceiptSchema2, { maxItems: 1000 })
|
|
18206
|
-
},
|
|
18300
|
+
}, closed10);
|
|
18207
18301
|
function assertScope(value, identity) {
|
|
18208
18302
|
if (value.project_ref !== identity.project_ref || value.application_id !== identity.application_id || value.environment_id !== identity.environment_id)
|
|
18209
18303
|
throw new Error("Application workflow scope mismatch");
|
|
@@ -21691,6 +21785,10 @@ function buildLiteArgs(request) {
|
|
|
21691
21785
|
optionalFlag(args, "--storage-dir", request.storage_dir);
|
|
21692
21786
|
optionalFlag(args, "--storage-backend", request.storage_backend);
|
|
21693
21787
|
optionalFlag(args, "--s3-prefix", request.s3_prefix);
|
|
21788
|
+
booleanFlag(args, "--s3-endpoint", request.s3_endpoint);
|
|
21789
|
+
optionalFlag(args, "--s3-endpoint-access-key-id", request.s3_endpoint_access_key_id);
|
|
21790
|
+
optionalFlag(args, "--s3-endpoint-region", request.s3_endpoint_region);
|
|
21791
|
+
optionalFlag(args, "--s3-endpoint-buckets", request.s3_endpoint_buckets);
|
|
21694
21792
|
optionalFlag(args, "--engine", request.engine);
|
|
21695
21793
|
optionalFlag(args, "--host", request.host);
|
|
21696
21794
|
optionalFlag(args, "--port", request.port);
|
|
@@ -21816,6 +21914,10 @@ function registerLiteCliTools(server, options = {}) {
|
|
|
21816
21914
|
storage_dir: optional(String2(), "[*] Object storage directory"),
|
|
21817
21915
|
storage_backend: optional(stringEnum2(["fs", "memory", "s3"]), "[*] Storage backend"),
|
|
21818
21916
|
s3_prefix: optional(String2(), "[*] S3 object key prefix"),
|
|
21917
|
+
s3_endpoint: optional(Boolean2(), "[start/doctor] Expose the inbound S3-compatible endpoint at /storage/v1/s3"),
|
|
21918
|
+
s3_endpoint_access_key_id: optional(String2(), "[start] Access key id for the inbound S3 endpoint"),
|
|
21919
|
+
s3_endpoint_region: optional(String2(), "[start] SigV4 region for the inbound S3 endpoint"),
|
|
21920
|
+
s3_endpoint_buckets: optional(String2(), "[start] Comma-separated bucket allowlist for the inbound S3 endpoint"),
|
|
21819
21921
|
engine: optional(stringEnum2(["pglite", "native"]), "[*] Database engine"),
|
|
21820
21922
|
host: optional(String2(), "[start] Listen host"),
|
|
21821
21923
|
port: optional(Number2(), "[start] Listen port"),
|
|
@@ -22120,6 +22222,7 @@ import {
|
|
|
22120
22222
|
createExecutionContextPack,
|
|
22121
22223
|
createDiagnosticRepairPlan,
|
|
22122
22224
|
doctorProject,
|
|
22225
|
+
formatDoctorCheck,
|
|
22123
22226
|
loadSupacloudConfig,
|
|
22124
22227
|
formatDeliveryPlan,
|
|
22125
22228
|
planDeliveryProject,
|
|
@@ -22253,29 +22356,40 @@ var starter_metadata_default = {
|
|
|
22253
22356
|
generatedBy: "supacloud/starter-metadata-v1",
|
|
22254
22357
|
packages: {
|
|
22255
22358
|
compiler: {
|
|
22256
|
-
version: "0.62.
|
|
22359
|
+
version: "0.62.5"
|
|
22257
22360
|
},
|
|
22258
22361
|
app: {
|
|
22259
|
-
version: "0.39.
|
|
22362
|
+
version: "0.39.3",
|
|
22260
22363
|
dependencies: {
|
|
22261
22364
|
rxjs: "7.8.2"
|
|
22262
22365
|
}
|
|
22263
22366
|
},
|
|
22264
22367
|
elysia: {
|
|
22265
|
-
version: "0.42.
|
|
22368
|
+
version: "0.42.4"
|
|
22266
22369
|
},
|
|
22267
22370
|
commands: {
|
|
22268
22371
|
version: "0.12.0"
|
|
22269
22372
|
},
|
|
22270
22373
|
contracts: {
|
|
22271
|
-
version: "0.16.
|
|
22374
|
+
version: "0.16.2"
|
|
22272
22375
|
},
|
|
22273
22376
|
db: {
|
|
22274
|
-
version: "0.24.
|
|
22377
|
+
version: "0.24.2",
|
|
22378
|
+
dependencies: {},
|
|
22379
|
+
devDependencies: {},
|
|
22380
|
+
peerDependencies: {
|
|
22381
|
+
"@supacloud/db-zenstack": "^0.1.0 || ^0.2.0"
|
|
22382
|
+
}
|
|
22383
|
+
},
|
|
22384
|
+
dbZenstack: {
|
|
22385
|
+
version: "0.2.2",
|
|
22275
22386
|
dependencies: {
|
|
22276
22387
|
"@zenstackhq/orm": "3.10.0",
|
|
22277
22388
|
"@zenstackhq/schema": "3.10.0",
|
|
22278
|
-
"@zenstackhq/plugin-policy": "3.10.0"
|
|
22389
|
+
"@zenstackhq/plugin-policy": "3.10.0",
|
|
22390
|
+
"@zenstackhq/language": "3.10.0",
|
|
22391
|
+
"@zenstackhq/sdk": "3.10.0",
|
|
22392
|
+
kysely: "0.29.0"
|
|
22279
22393
|
},
|
|
22280
22394
|
devDependencies: {
|
|
22281
22395
|
"@zenstackhq/cli": "3.10.0",
|
|
@@ -22284,7 +22398,7 @@ var starter_metadata_default = {
|
|
|
22284
22398
|
}
|
|
22285
22399
|
},
|
|
22286
22400
|
sdk: {
|
|
22287
|
-
version: "0.48.
|
|
22401
|
+
version: "0.48.3",
|
|
22288
22402
|
peerDependencies: {
|
|
22289
22403
|
"@supabase/supabase-js": "^2.118.0"
|
|
22290
22404
|
}
|
|
@@ -22528,6 +22642,27 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
|
|
|
22528
22642
|
|
|
22529
22643
|
// src/shared/tools/app-starter-templates.ts
|
|
22530
22644
|
var { compiler: compilerMetadata, app: appMetadata, elysia: elysiaMetadata } = starter_metadata_default.packages;
|
|
22645
|
+
var STARTER_TEMPLATES = ["minimal", "client", "command", "model-command"];
|
|
22646
|
+
var DEFAULT_STARTER_TEMPLATE = "minimal";
|
|
22647
|
+
var STARTER_TEMPLATE_ALIASES = {
|
|
22648
|
+
app: "minimal"
|
|
22649
|
+
};
|
|
22650
|
+
function isStarterTemplate(value) {
|
|
22651
|
+
return STARTER_TEMPLATES.includes(value);
|
|
22652
|
+
}
|
|
22653
|
+
function resolveStarterTemplate(input) {
|
|
22654
|
+
if (input === undefined)
|
|
22655
|
+
return DEFAULT_STARTER_TEMPLATE;
|
|
22656
|
+
if (isStarterTemplate(input))
|
|
22657
|
+
return input;
|
|
22658
|
+
if (Object.hasOwn(STARTER_TEMPLATE_ALIASES, input)) {
|
|
22659
|
+
return STARTER_TEMPLATE_ALIASES[input];
|
|
22660
|
+
}
|
|
22661
|
+
throw new Error(`Unknown app init template: ${input}. Use ${STARTER_TEMPLATES.join(", ")}` + " (`app` is accepted as an alias of `minimal`).");
|
|
22662
|
+
}
|
|
22663
|
+
function assertNeverTemplate(value) {
|
|
22664
|
+
throw new Error(`Unhandled starter template: ${String(value)}`);
|
|
22665
|
+
}
|
|
22531
22666
|
var json = (value) => `${JSON.stringify(value, null, 2)}
|
|
22532
22667
|
`;
|
|
22533
22668
|
var DEV_SCRIPT = `import { watchProject, compileOptionsFromConfig, loadSupacloudConfig } from "@supacloud/compiler";
|
|
@@ -22575,27 +22710,88 @@ const server = Bun.serve({
|
|
|
22575
22710
|
console.log("Local demo: " + server.url);
|
|
22576
22711
|
`;
|
|
22577
22712
|
var APPLICATION_SOURCE = (name) => `import { createApplication } from "@supacloud/elysia";
|
|
22578
|
-
import {
|
|
22713
|
+
import {
|
|
22714
|
+
createSupAuthRequestContext,
|
|
22715
|
+
type SupAuthContextOptions,
|
|
22716
|
+
type CommandGovernance,
|
|
22717
|
+
type ExecutionObserver,
|
|
22718
|
+
} from "@supacloud/elysia";
|
|
22579
22719
|
import { createCompiledModules } from "../generated/application";
|
|
22580
22720
|
|
|
22721
|
+
/** Trusted-host adapters. Keep these explicit so indexed ApplicationOptions access cannot widen to any. */
|
|
22581
22722
|
export interface AppAdapters {
|
|
22582
|
-
deps:
|
|
22583
|
-
requestContext:
|
|
22723
|
+
deps: Record<string, unknown>;
|
|
22724
|
+
requestContext: (
|
|
22725
|
+
request: Request,
|
|
22726
|
+
context: unknown,
|
|
22727
|
+
signal?: AbortSignal,
|
|
22728
|
+
) => unknown | Promise<unknown>;
|
|
22584
22729
|
commandGovernance: CommandGovernance;
|
|
22585
|
-
onExecution?:
|
|
22730
|
+
onExecution?: ExecutionObserver;
|
|
22731
|
+
}
|
|
22732
|
+
|
|
22733
|
+
export interface CreatedApplication {
|
|
22734
|
+
fetch: (request: Request) => Promise<Response>;
|
|
22735
|
+
handle: (request: Request) => Promise<Response>;
|
|
22736
|
+
initialize: () => Promise<void>;
|
|
22737
|
+
destroy: () => Promise<void>;
|
|
22738
|
+
}
|
|
22739
|
+
|
|
22740
|
+
function isRecord(value: unknown): value is { readonly [key: string]: unknown } {
|
|
22741
|
+
return typeof value === "object" && value !== null;
|
|
22742
|
+
}
|
|
22743
|
+
|
|
22744
|
+
function isApplicationHost(value: unknown): value is {
|
|
22745
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
22746
|
+
handle: (request: Request) => Response | Promise<Response>;
|
|
22747
|
+
initialize: () => void | Promise<void>;
|
|
22748
|
+
destroy: () => void | Promise<void>;
|
|
22749
|
+
} {
|
|
22750
|
+
return isRecord(value)
|
|
22751
|
+
&& typeof value["fetch"] === "function"
|
|
22752
|
+
&& typeof value["handle"] === "function"
|
|
22753
|
+
&& typeof value["initialize"] === "function"
|
|
22754
|
+
&& typeof value["destroy"] === "function";
|
|
22755
|
+
}
|
|
22756
|
+
|
|
22757
|
+
function isRequestContextFactory(value: unknown): value is AppAdapters["requestContext"] {
|
|
22758
|
+
return typeof value === "function";
|
|
22759
|
+
}
|
|
22760
|
+
|
|
22761
|
+
export function readCreatedApplication(value: unknown): CreatedApplication {
|
|
22762
|
+
if (!isApplicationHost(value)) {
|
|
22763
|
+
throw new Error("createApplication returned an invalid application host");
|
|
22764
|
+
}
|
|
22765
|
+
return {
|
|
22766
|
+
fetch: async (request) => await value.fetch(request),
|
|
22767
|
+
handle: async (request) => await value.handle(request),
|
|
22768
|
+
initialize: async () => { await value.initialize(); },
|
|
22769
|
+
destroy: async () => { await value.destroy(); },
|
|
22770
|
+
};
|
|
22586
22771
|
}
|
|
22587
22772
|
|
|
22588
22773
|
// The host verifies external identity (SupAuth for unified login) before creating requestContext.
|
|
22589
|
-
export function createApp(adapters: AppAdapters) {
|
|
22590
|
-
|
|
22591
|
-
|
|
22774
|
+
export function createApp(adapters: AppAdapters): CreatedApplication {
|
|
22775
|
+
const application: unknown = createApplication({
|
|
22776
|
+
deps: adapters.deps,
|
|
22777
|
+
requestContext: adapters.requestContext,
|
|
22778
|
+
commandGovernance: adapters.commandGovernance,
|
|
22592
22779
|
name: ${JSON.stringify(name)},
|
|
22593
22780
|
modules: createCompiledModules(),
|
|
22781
|
+
...(adapters.onExecution === undefined ? {} : { onExecution: adapters.onExecution }),
|
|
22594
22782
|
});
|
|
22783
|
+
return readCreatedApplication(application);
|
|
22595
22784
|
}
|
|
22596
22785
|
|
|
22597
|
-
export function createSupAuthApp(
|
|
22598
|
-
|
|
22786
|
+
export function createSupAuthApp(
|
|
22787
|
+
identity: SupAuthContextOptions,
|
|
22788
|
+
adapters: Omit<AppAdapters, "requestContext">,
|
|
22789
|
+
): CreatedApplication {
|
|
22790
|
+
const resolved: unknown = createSupAuthRequestContext(identity);
|
|
22791
|
+
if (!isRequestContextFactory(resolved)) {
|
|
22792
|
+
throw new Error("createSupAuthRequestContext must return a requestContext function");
|
|
22793
|
+
}
|
|
22794
|
+
return createApp({ ...adapters, requestContext: resolved });
|
|
22599
22795
|
}
|
|
22600
22796
|
`;
|
|
22601
22797
|
var GENERATED_BOOTSTRAP = `// BOOTSTRAP ARTIFACT: bun run compile replaces this file.
|
|
@@ -22630,7 +22826,7 @@ function baseTemplateFiles(name, sdkDependencies) {
|
|
|
22630
22826
|
"@supacloud/app": `^${appMetadata.version}`,
|
|
22631
22827
|
"@supacloud/elysia": `^${elysiaMetadata.version}`,
|
|
22632
22828
|
effect: "4.0.5",
|
|
22633
|
-
elysia: "2.0.0-rc.
|
|
22829
|
+
elysia: "2.0.0-rc.3",
|
|
22634
22830
|
...sdkDependencies
|
|
22635
22831
|
},
|
|
22636
22832
|
devDependencies: {
|
|
@@ -22686,7 +22882,128 @@ export default defineSupacloudConfig();
|
|
|
22686
22882
|
"scripts/serve.ts": SERVE_SCRIPT
|
|
22687
22883
|
};
|
|
22688
22884
|
}
|
|
22689
|
-
|
|
22885
|
+
var DATA_CLIENT = `import { createClient, type SupabaseClient } from "@supabase/supabase-js";
|
|
22886
|
+
|
|
22887
|
+
/** Official data-plane client. Provisioned projects are reached with this client. */
|
|
22888
|
+
export function createDataClient(input: { url: string; anonKey: string }): SupabaseClient {
|
|
22889
|
+
const url = new URL(input.url);
|
|
22890
|
+
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost";
|
|
22891
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
|
|
22892
|
+
throw new Error("Use the project HTTPS API URL, or loopback HTTP for local development");
|
|
22893
|
+
}
|
|
22894
|
+
if (input.anonKey.trim().length < 8 || input.anonKey !== input.anonKey.trim()) {
|
|
22895
|
+
throw new Error("Use the anon or publishable key");
|
|
22896
|
+
}
|
|
22897
|
+
return createClient(url.toString(), input.anonKey, {
|
|
22898
|
+
auth: { persistSession: false, autoRefreshToken: false },
|
|
22899
|
+
});
|
|
22900
|
+
}
|
|
22901
|
+
`;
|
|
22902
|
+
var DATA_CLIENT_TEST = `import { expect, test } from "bun:test";
|
|
22903
|
+
import { createDataClient } from "../src/client";
|
|
22904
|
+
|
|
22905
|
+
test("the data client is the official supabase-js client", () => {
|
|
22906
|
+
const client = createDataClient({ url: "http://127.0.0.1:54321", anonKey: "public-anon-key" });
|
|
22907
|
+
expect(typeof client.from).toBe("function");
|
|
22908
|
+
expect(typeof client.channel).toBe("function");
|
|
22909
|
+
});
|
|
22910
|
+
|
|
22911
|
+
test("non-local http URLs are rejected", () => {
|
|
22912
|
+
expect(() => createDataClient({ url: "http://example.com", anonKey: "public-anon-key" })).toThrow("HTTPS");
|
|
22913
|
+
});
|
|
22914
|
+
`;
|
|
22915
|
+
function supabaseClientTemplate(name, sdkDependencies) {
|
|
22916
|
+
return {
|
|
22917
|
+
"package.json": json({
|
|
22918
|
+
name,
|
|
22919
|
+
version: "0.0.0",
|
|
22920
|
+
private: true,
|
|
22921
|
+
type: "module",
|
|
22922
|
+
engines: { bun: ">=1.4.4" },
|
|
22923
|
+
scripts: {
|
|
22924
|
+
typecheck: "tsc --noEmit",
|
|
22925
|
+
test: "bun test",
|
|
22926
|
+
check: "bun run typecheck && bun run test"
|
|
22927
|
+
},
|
|
22928
|
+
dependencies: {
|
|
22929
|
+
"@supabase/supabase-js": sdkDependencies["@supabase/supabase-js"]
|
|
22930
|
+
},
|
|
22931
|
+
devDependencies: {
|
|
22932
|
+
"@types/bun": "^1.4.4",
|
|
22933
|
+
typescript: "7.1.0-beta"
|
|
22934
|
+
}
|
|
22935
|
+
}),
|
|
22936
|
+
"tsconfig.json": json({
|
|
22937
|
+
compilerOptions: {
|
|
22938
|
+
target: "ES2022",
|
|
22939
|
+
module: "ESNext",
|
|
22940
|
+
moduleResolution: "bundler",
|
|
22941
|
+
strict: true,
|
|
22942
|
+
skipLibCheck: true,
|
|
22943
|
+
noUncheckedIndexedAccess: true,
|
|
22944
|
+
exactOptionalPropertyTypes: true,
|
|
22945
|
+
noImplicitOverride: true,
|
|
22946
|
+
noPropertyAccessFromIndexSignature: true,
|
|
22947
|
+
noFallthroughCasesInSwitch: true,
|
|
22948
|
+
forceConsistentCasingInFileNames: true,
|
|
22949
|
+
useUnknownInCatchVariables: true,
|
|
22950
|
+
noEmit: true,
|
|
22951
|
+
types: ["bun"]
|
|
22952
|
+
},
|
|
22953
|
+
include: ["src/**/*.ts", "tests/**/*.ts"]
|
|
22954
|
+
}),
|
|
22955
|
+
"bunfig.toml": `env = false
|
|
22956
|
+
`,
|
|
22957
|
+
".gitignore": ["node_modules/", ".env", ".env.*", "!.env.example", ""].join(`
|
|
22958
|
+
`),
|
|
22959
|
+
".env.example": `SUPABASE_URL=http://127.0.0.1:54321
|
|
22960
|
+
SUPABASE_ANON_KEY=replace-with-anon-or-publishable-key
|
|
22961
|
+
`,
|
|
22962
|
+
"src/client.ts": DATA_CLIENT,
|
|
22963
|
+
"tests/client.test.ts": DATA_CLIENT_TEST,
|
|
22964
|
+
"AGENTS.md": `# ${name}
|
|
22965
|
+
|
|
22966
|
+
This project talks to a provisioned Supabase-compatible API with
|
|
22967
|
+
\`@supabase/supabase-js\`. It is the explicit \`--template client\` scaffold.
|
|
22968
|
+
|
|
22969
|
+
- Do not add \`@supacloud/app\`, \`@supacloud/compiler\`, \`@supacloud/elysia\`, or \`effect\` here.
|
|
22970
|
+
- The forced default application stack is \`supacloud app init\` (\`minimal\`).
|
|
22971
|
+
- Durable SQL and model recipes are \`--template command\` and \`--template model-command\`.
|
|
22972
|
+
- Use the anon or publishable key. Never put a service-role or Management token in this client.
|
|
22973
|
+
- Management API provision does not compile this project and does not interpret Effect.
|
|
22974
|
+
`,
|
|
22975
|
+
"README.md": `# ${name}
|
|
22976
|
+
|
|
22977
|
+
Explicit data-plane client (\`supacloud app init --template client\`) for a
|
|
22978
|
+
provisioned project. This scaffold depends on \`@supabase/supabase-js\` only. It
|
|
22979
|
+
does not install \`@supacloud/app\`, the compiler, Elysia, or Effect.
|
|
22980
|
+
|
|
22981
|
+
## Local check
|
|
22982
|
+
|
|
22983
|
+
\`\`\`sh
|
|
22984
|
+
bun install
|
|
22985
|
+
bun test tests/client.test.ts
|
|
22986
|
+
bun run check
|
|
22987
|
+
\`\`\`
|
|
22988
|
+
|
|
22989
|
+
Copy \`.env.example\` and set \`SUPABASE_URL\` to the project API URL and
|
|
22990
|
+
\`SUPABASE_ANON_KEY\` to the anon or publishable key. Do not commit the filled
|
|
22991
|
+
file, and do not put the service-role key in this client.
|
|
22992
|
+
|
|
22993
|
+
\`createDataClient\` accepts HTTPS, or HTTP only for \`127.0.0.1\` and \`localhost\`.
|
|
22994
|
+
Realtime uses the same client's \`channel()\` against the project's
|
|
22995
|
+
\`/realtime/v1/websocket\` endpoint. See the platform Realtime contract for which
|
|
22996
|
+
process owns that socket.
|
|
22997
|
+
|
|
22998
|
+
## Default application stack
|
|
22999
|
+
|
|
23000
|
+
\`supacloud app init\` (template \`minimal\`) is the forced compiler + Effect
|
|
23001
|
+
project. \`--template command\` and \`--template model-command\` are the durable
|
|
23002
|
+
reference recipes. Do not add those dependencies to this client project.
|
|
23003
|
+
`
|
|
23004
|
+
};
|
|
23005
|
+
}
|
|
23006
|
+
function appFrameworkTemplate(name, sdkDependencies) {
|
|
22690
23007
|
return {
|
|
22691
23008
|
...baseTemplateFiles(name, sdkDependencies),
|
|
22692
23009
|
"src/features/health/contracts.ts": `import { t } from "elysia";
|
|
@@ -22750,6 +23067,11 @@ export function createDemo() {
|
|
|
22750
23067
|
`,
|
|
22751
23068
|
"README.md": `# ${name}
|
|
22752
23069
|
|
|
23070
|
+
Default application stack from \`supacloud app init\` (template \`minimal\`).
|
|
23071
|
+
It installs \`@supacloud/app\`, the compiler, Elysia, and Effect. The data-plane
|
|
23072
|
+
client remains \`@supabase/supabase-js\` inside this project. Use
|
|
23073
|
+
\`--template client\` only when you need a client-only directory.
|
|
23074
|
+
|
|
22753
23075
|
## Local development
|
|
22754
23076
|
|
|
22755
23077
|
\`\`\`sh
|
|
@@ -22797,9 +23119,14 @@ regeneration, then validate types, database permissions and authenticated behavi
|
|
|
22797
23119
|
};
|
|
22798
23120
|
}
|
|
22799
23121
|
function appTemplateFiles(name, template, sdkDependencies) {
|
|
22800
|
-
|
|
22801
|
-
|
|
22802
|
-
|
|
23122
|
+
switch (template) {
|
|
23123
|
+
case "client":
|
|
23124
|
+
return supabaseClientTemplate(name, sdkDependencies);
|
|
23125
|
+
case "minimal":
|
|
23126
|
+
return appFrameworkTemplate(name, sdkDependencies);
|
|
23127
|
+
default:
|
|
23128
|
+
return assertNeverTemplate(template);
|
|
23129
|
+
}
|
|
22803
23130
|
}
|
|
22804
23131
|
|
|
22805
23132
|
// src/shared/tools/command-receipts.ts
|
|
@@ -22963,13 +23290,41 @@ var COMMANDS = `import { Command, defineOperationAspect, type Aspect } from "@su
|
|
|
22963
23290
|
import { createTypeBoxTransactionalCommand } from "@supacloud/commands/typebox";
|
|
22964
23291
|
import { plaintextCommandInput } from "@supacloud/commands";
|
|
22965
23292
|
import { CommandError, type CommandIdentity, type CommandStore } from "@supacloud/contracts";
|
|
22966
|
-
import type {
|
|
22967
|
-
import type { schema } from "../../../zenstack/generated/schema";
|
|
23293
|
+
import type { CallFunctionOptions, JsonArgument, ReadFunctionArg, ReadFunctionRow } from "@supacloud/db/model-contract";
|
|
22968
23294
|
import { Type } from "typebox";
|
|
22969
23295
|
import { CreateInput, ApproveInput, Decision, decodeApprove, decodeDecision, decodeOrder, decoder, type Principal } from "./contracts";
|
|
22970
23296
|
|
|
22971
|
-
type
|
|
22972
|
-
type
|
|
23297
|
+
type OrderRow = { readonly id: string; readonly title: string; readonly state: string; readonly version: number };
|
|
23298
|
+
type OrderDb = {
|
|
23299
|
+
readonly order: {
|
|
23300
|
+
createMany(args: { readonly data: readonly Record<string, unknown>[]; readonly skipDuplicates?: boolean }): Promise<{ readonly count: number }>;
|
|
23301
|
+
findUniqueOrThrow(args: { readonly where: { readonly tenantId_id: { readonly tenantId: string; readonly id: string } }; readonly select: Record<keyof OrderRow, true> }): Promise<OrderRow>;
|
|
23302
|
+
updateMany(args: { readonly where: Record<string, unknown>; readonly data: Record<string, unknown> }): Promise<{ readonly count: number }>;
|
|
23303
|
+
};
|
|
23304
|
+
};
|
|
23305
|
+
type Tx = {
|
|
23306
|
+
readonly db: OrderDb;
|
|
23307
|
+
readonly lock: (keys: readonly string[]) => Promise<void>;
|
|
23308
|
+
readonly readFunction: (name: string, args?: readonly ReadFunctionArg[]) => Promise<unknown>;
|
|
23309
|
+
readonly readFunctionByRow: (name: string, row: ReadFunctionRow) => Promise<unknown>;
|
|
23310
|
+
readonly callFunction: (name: string, args?: readonly JsonArgument[], options?: CallFunctionOptions) => Promise<unknown>;
|
|
23311
|
+
};
|
|
23312
|
+
type Store = CommandStore<unknown>;
|
|
23313
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
23314
|
+
return value !== null && typeof value === "object";
|
|
23315
|
+
}
|
|
23316
|
+
function isTx(value: unknown): value is Tx {
|
|
23317
|
+
const root = isRecord(value) ? value : undefined;
|
|
23318
|
+
const db = root && isRecord(root["db"]) ? root["db"] : undefined;
|
|
23319
|
+
const order = db && isRecord(db["order"]) ? db["order"] : undefined;
|
|
23320
|
+
const methods = ["lock", "readFunction", "readFunctionByRow", "callFunction"];
|
|
23321
|
+
return !!root && !!db && !!order && methods.every(name => typeof root[name] === "function")
|
|
23322
|
+
&& ["createMany", "findUniqueOrThrow", "updateMany"].every(name => typeof order[name] === "function");
|
|
23323
|
+
}
|
|
23324
|
+
function decodeTx(value: unknown): Tx {
|
|
23325
|
+
if (!isTx(value)) throw new TypeError("Invalid model command transaction");
|
|
23326
|
+
return value;
|
|
23327
|
+
}
|
|
22973
23328
|
const decodeCapabilities = decoder(Type.Object({ canApprove: Type.Boolean() }, { additionalProperties: false }));
|
|
22974
23329
|
export const approvalAspect = defineOperationAspect({
|
|
22975
23330
|
kind: "command", name: "orders.approve", input: decodeApprove, result: decodeDecision,
|
|
@@ -22993,10 +23348,11 @@ export class CreateOrder {
|
|
|
22993
23348
|
inputCodec: plaintextCommandInput,
|
|
22994
23349
|
authorize: identity => sameActor(identity, principal) && principal.canCreate ? "allow" : "deny",
|
|
22995
23350
|
audit: { event: "orders.create.decided", details: (input, result) => ({ id: input.id, outcome: result.outcome }) },
|
|
22996
|
-
execute: async (
|
|
22997
|
-
const
|
|
23351
|
+
execute: async (rawTx, input): Promise<Decision> => {
|
|
23352
|
+
const tx = decodeTx(rawTx);
|
|
23353
|
+
const created: { count: number } = await tx.db.order.createMany({ data: [{ ...input, tenantId: principal.tenantId, ownerId: principal.id, state: "draft", version: 1 }], skipDuplicates: true });
|
|
22998
23354
|
if (created.count !== 1) return { outcome: "conflict", order: null };
|
|
22999
|
-
const row = await tx.db.order.findUniqueOrThrow({ where: { tenantId_id: { tenantId: principal.tenantId, id: input.id } }, select: { id: true, title: true, state: true, version: true } });
|
|
23355
|
+
const row: { id: string; title: string; state: string; version: number } = await tx.db.order.findUniqueOrThrow({ where: { tenantId_id: { tenantId: principal.tenantId, id: input.id } }, select: { id: true, title: true, state: true, version: true } });
|
|
23000
23356
|
return { outcome: "applied", order: decodeOrder(row) };
|
|
23001
23357
|
},
|
|
23002
23358
|
});
|
|
@@ -23014,18 +23370,21 @@ export class ApproveOrder {
|
|
|
23014
23370
|
name: "orders.approve", store, schemas: { input: ApproveInput, result: Decision }, inputCodec: plaintextCommandInput,
|
|
23015
23371
|
authorize: identity => sameActor(identity, principal) && principal.canApprove ? "allow" : "deny",
|
|
23016
23372
|
audit: { event: "orders.approval.decided", details: (input, result) => ({ id: input.id, outcome: result.outcome }) },
|
|
23017
|
-
execute: async (
|
|
23373
|
+
execute: async (rawTx, input) => {
|
|
23374
|
+
const tx = decodeTx(rawTx);
|
|
23375
|
+
return decodeDecision(await pipeline({
|
|
23018
23376
|
kind: "command", name: "orders.approve", input,
|
|
23019
23377
|
services: { approval: { canApprove: principal.canApprove } },
|
|
23020
23378
|
}, async (): Promise<Decision> => {
|
|
23021
|
-
const changed = await tx.db.order.updateMany({
|
|
23379
|
+
const changed: { count: number } = await tx.db.order.updateMany({
|
|
23022
23380
|
where: { tenantId: principal.tenantId, id: input.id, state: "draft", version: input.expectedVersion },
|
|
23023
23381
|
data: { state: "approved", version: { increment: 1 } },
|
|
23024
23382
|
});
|
|
23025
23383
|
if (changed.count !== 1) return { outcome: "conflict", order: null };
|
|
23026
|
-
const row = await tx.db.order.findUniqueOrThrow({ where: { tenantId_id: { tenantId: principal.tenantId, id: input.id } }, select: { id: true, title: true, state: true, version: true } });
|
|
23384
|
+
const row: { id: string; title: string; state: string; version: number } = await tx.db.order.findUniqueOrThrow({ where: { tenantId_id: { tenantId: principal.tenantId, id: input.id } }, select: { id: true, title: true, state: true, version: true } });
|
|
23027
23385
|
return { outcome: "applied", order: decodeOrder(row) };
|
|
23028
|
-
}))
|
|
23386
|
+
}));
|
|
23387
|
+
},
|
|
23029
23388
|
});
|
|
23030
23389
|
}
|
|
23031
23390
|
execute(identity: CommandIdentity, key: string, input: ApproveInput, signal?: AbortSignal) {
|
|
@@ -23070,7 +23429,7 @@ export class OrdersModule {}
|
|
|
23070
23429
|
var HOST = `import type { SQL } from "bun";
|
|
23071
23430
|
import { createApplication, ApplicationError, type CompiledModule } from "@supacloud/elysia";
|
|
23072
23431
|
import { createZenStackDatabase } from "@supacloud/db/zenstack";
|
|
23073
|
-
import { CommandError } from "@supacloud/contracts";
|
|
23432
|
+
import { CommandError, type CommandStore } from "@supacloud/contracts";
|
|
23074
23433
|
import { schema } from "../../zenstack/generated/schema";
|
|
23075
23434
|
import { createCompiledModules } from "../../generated/application";
|
|
23076
23435
|
import { CreateOrder, ApproveOrder } from "../features/orders/commands";
|
|
@@ -23086,6 +23445,34 @@ export interface IdentityAuthority {
|
|
|
23086
23445
|
resolve(actor: ActorBinding): Promise<Principal | null>;
|
|
23087
23446
|
}
|
|
23088
23447
|
|
|
23448
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
23449
|
+
return value !== null && typeof value === "object";
|
|
23450
|
+
}
|
|
23451
|
+
function isCommandStore(value: unknown): value is CommandStore<unknown> {
|
|
23452
|
+
return isRecord(value) && typeof value["transaction"] === "function";
|
|
23453
|
+
}
|
|
23454
|
+
function requireCommandStore(value: unknown): CommandStore<unknown> {
|
|
23455
|
+
if (!isCommandStore(value)) throw new CommandError("COMMAND_UNAVAILABLE");
|
|
23456
|
+
return value;
|
|
23457
|
+
}
|
|
23458
|
+
interface ScopedDatabase {
|
|
23459
|
+
readonly commandStore: unknown;
|
|
23460
|
+
readonly models: { readonly order: { findUnique(args: unknown): Promise<unknown> } };
|
|
23461
|
+
}
|
|
23462
|
+
interface DatabaseFacade {
|
|
23463
|
+
forIdentity(identity: Principal): ScopedDatabase;
|
|
23464
|
+
dispose(): Promise<void>;
|
|
23465
|
+
}
|
|
23466
|
+
function isDatabaseFacade(value: unknown): value is DatabaseFacade {
|
|
23467
|
+
if (!isRecord(value) || typeof value["forIdentity"] !== "function" || typeof value["dispose"] !== "function") return false;
|
|
23468
|
+
const scoped = value["forIdentity"];
|
|
23469
|
+
return typeof scoped === "function";
|
|
23470
|
+
}
|
|
23471
|
+
function requireDatabase(value: unknown): DatabaseFacade {
|
|
23472
|
+
if (!isDatabaseFacade(value)) throw new CommandError("COMMAND_UNAVAILABLE");
|
|
23473
|
+
return value;
|
|
23474
|
+
}
|
|
23475
|
+
|
|
23089
23476
|
export async function createModelOrderHost(pool: SQL, authority: IdentityAuthority) {
|
|
23090
23477
|
const roles = await pool<unknown[]>\`SELECT rolsuper, rolbypassrls, pg_has_role(current_user, 'model_orders_app', 'USAGE') AS allowed,
|
|
23091
23478
|
EXISTS (SELECT FROM pg_class WHERE oid IN ('public.model_orders'::regclass, 'supacloud_commands.execution_receipts'::regclass, 'supacloud_commands.execution_audit'::regclass)
|
|
@@ -23097,7 +23484,7 @@ export async function createModelOrderHost(pool: SQL, authority: IdentityAuthori
|
|
|
23097
23484
|
|| !("owns_data" in role) || role.owns_data !== false) {
|
|
23098
23485
|
throw new Error("Use a non-owner application login with model_orders_app membership");
|
|
23099
23486
|
}
|
|
23100
|
-
const database = createZenStackDatabase(schema, pool, {});
|
|
23487
|
+
const database = requireDatabase(createZenStackDatabase(schema, pool, {}));
|
|
23101
23488
|
const modules: CompiledModule[] = createCompiledModules();
|
|
23102
23489
|
const ordersModule = modules.find(module => module.name === "orders");
|
|
23103
23490
|
const approval = ordersModule?.commands?.find(command => command.name === "orders.approve")?.aspectPipeline;
|
|
@@ -23123,11 +23510,11 @@ export async function createModelOrderHost(pool: SQL, authority: IdentityAuthori
|
|
|
23123
23510
|
const port: OrderPort = {
|
|
23124
23511
|
create: async (context, key, input) => {
|
|
23125
23512
|
const bound = await bind(context);
|
|
23126
|
-
return decodeReceipt(await new CreateOrder(bound.scoped.commandStore, bound.principal).execute(bound.identity, key, decodeCreate(input), bound.signal));
|
|
23513
|
+
return decodeReceipt(await new CreateOrder(requireCommandStore(bound.scoped.commandStore), bound.principal).execute(bound.identity, key, decodeCreate(input), bound.signal));
|
|
23127
23514
|
},
|
|
23128
23515
|
approve: async (context, key, input) => {
|
|
23129
23516
|
const bound = await bind(context);
|
|
23130
|
-
return decodeReceipt(await new ApproveOrder(bound.scoped.commandStore, bound.principal, approval).execute(bound.identity, key, decodeApprove(input), bound.signal));
|
|
23517
|
+
return decodeReceipt(await new ApproveOrder(requireCommandStore(bound.scoped.commandStore), bound.principal, approval).execute(bound.identity, key, decodeApprove(input), bound.signal));
|
|
23131
23518
|
},
|
|
23132
23519
|
read: async (context, id) => {
|
|
23133
23520
|
const bound = await bind(context);
|
|
@@ -23164,16 +23551,26 @@ DO $role$ BEGIN
|
|
|
23164
23551
|
END $role$;
|
|
23165
23552
|
REVOKE ALL ON public.model_orders FROM PUBLIC;
|
|
23166
23553
|
ALTER TABLE public.model_orders ENABLE ROW LEVEL SECURITY;
|
|
23167
|
-
--
|
|
23168
|
-
--
|
|
23554
|
+
-- The host role is a trusted command connection. It does not set request.jwt.claims,
|
|
23555
|
+
-- so this bypass is not the model row projection. Do not grant it to PostgREST.
|
|
23169
23556
|
CREATE POLICY model_orders_host ON public.model_orders TO model_orders_app USING (true) WITH CHECK (true);
|
|
23557
|
+
-- Authenticated RLS is projected from zenstack/schema.zmodel @@allow rules.
|
|
23558
|
+
-- Grants stay reviewed; these policies do not by themselves grant table access.
|
|
23559
|
+
DO $supacloud_policy_rls$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'authenticated') THEN CREATE ROLE "authenticated" NOLOGIN; END IF; END $supacloud_policy_rls$;
|
|
23560
|
+
ALTER TABLE "public"."model_orders" ENABLE ROW LEVEL SECURITY;
|
|
23561
|
+
DROP POLICY IF EXISTS "model_orders_select" ON "public"."model_orders";
|
|
23562
|
+
CREATE POLICY "model_orders_select" ON "public"."model_orders" FOR SELECT TO "authenticated" USING ((((auth.jwt() IS NOT NULL) AND ("tenant_id" = (auth.jwt() ->> 'tenantId'))) AND (("owner_id" = (auth.jwt() ->> 'id')) OR ((auth.jwt() ->> 'canApprove') = 'true'))));
|
|
23563
|
+
DROP POLICY IF EXISTS "model_orders_insert" ON "public"."model_orders";
|
|
23564
|
+
CREATE POLICY "model_orders_insert" ON "public"."model_orders" FOR INSERT TO "authenticated" WITH CHECK (((((((auth.jwt() IS NOT NULL) AND ((auth.jwt() ->> 'canCreate') = 'true')) AND ("tenant_id" = (auth.jwt() ->> 'tenantId'))) AND ("owner_id" = (auth.jwt() ->> 'id'))) AND ("state" = 'draft')) AND ("version" = 1)));
|
|
23565
|
+
DROP POLICY IF EXISTS "model_orders_update" ON "public"."model_orders";
|
|
23566
|
+
CREATE POLICY "model_orders_update" ON "public"."model_orders" FOR UPDATE TO "authenticated" USING ((((auth.jwt() IS NOT NULL) AND ((auth.jwt() ->> 'canApprove') = 'true')) AND ("tenant_id" = (auth.jwt() ->> 'tenantId')))) WITH CHECK ((((auth.jwt() IS NOT NULL) AND ((auth.jwt() ->> 'canApprove') = 'true')) AND ("tenant_id" = (auth.jwt() ->> 'tenantId'))));
|
|
23170
23567
|
GRANT USAGE ON SCHEMA public, supacloud_commands TO model_orders_app;
|
|
23171
23568
|
GRANT SELECT, INSERT, UPDATE ON public.model_orders TO model_orders_app;
|
|
23172
23569
|
GRANT SELECT, INSERT, UPDATE ON supacloud_commands.execution_receipts TO model_orders_app;
|
|
23173
23570
|
GRANT SELECT, INSERT ON supacloud_commands.execution_audit TO model_orders_app;
|
|
23174
23571
|
`;
|
|
23175
23572
|
function modelCommandTemplateFiles(name, sdk) {
|
|
23176
|
-
const { app, compiler, elysia, commands, contracts, db } = starter_metadata_default.packages;
|
|
23573
|
+
const { app, compiler, elysia, commands, contracts, db, dbZenstack } = starter_metadata_default.packages;
|
|
23177
23574
|
const files = baseTemplateFiles(name, sdk);
|
|
23178
23575
|
delete files["scripts/dev.ts"];
|
|
23179
23576
|
delete files["scripts/serve.ts"];
|
|
@@ -23212,13 +23609,15 @@ function modelCommandTemplateFiles(name, sdk) {
|
|
|
23212
23609
|
"@supacloud/commands": "^" + commands.version,
|
|
23213
23610
|
"@supacloud/contracts": "^" + contracts.version,
|
|
23214
23611
|
"@supacloud/db": "^" + db.version,
|
|
23612
|
+
"@supacloud/db-zenstack": "^" + dbZenstack.version,
|
|
23215
23613
|
...db.dependencies,
|
|
23614
|
+
...dbZenstack.dependencies,
|
|
23216
23615
|
typebox: "1.4.3",
|
|
23217
23616
|
effect: "4.0.5",
|
|
23218
|
-
elysia: "2.0.0-rc.
|
|
23617
|
+
elysia: "2.0.0-rc.3",
|
|
23219
23618
|
...sdk
|
|
23220
23619
|
},
|
|
23221
|
-
devDependencies: { "@supacloud/compiler": "^" + compiler.version, ...db.devDependencies, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
|
|
23620
|
+
devDependencies: { "@supacloud/compiler": "^" + compiler.version, ...db.devDependencies, ...dbZenstack.devDependencies, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
|
|
23222
23621
|
}),
|
|
23223
23622
|
"supacloud.config.ts": `import { defineSupacloudConfig } from "@supacloud/compiler";
|
|
23224
23623
|
export default defineSupacloudConfig({
|
|
@@ -23236,6 +23635,9 @@ export default defineSupacloudConfig({
|
|
|
23236
23635
|
"db/modules.ts": `import { defineDatabaseModule } from "@supacloud/db";
|
|
23237
23636
|
export default defineDatabaseModule({ name: "orders", tables: ["public.model_orders"], policies: [
|
|
23238
23637
|
{ name: "model_orders_host", table: "public.model_orders", operation: "all", roles: ["model_orders_app"], source: "migrations/002-model-orders.sql", tests: ["tests/database-governance.sql"] },
|
|
23638
|
+
{ name: "model_orders_select", table: "public.model_orders", operation: "select", roles: ["authenticated"], source: "migrations/002-model-orders.sql", tests: ["tests/database-governance.sql"] },
|
|
23639
|
+
{ name: "model_orders_insert", table: "public.model_orders", operation: "insert", roles: ["authenticated"], source: "migrations/002-model-orders.sql", tests: ["tests/database-governance.sql"] },
|
|
23640
|
+
{ name: "model_orders_update", table: "public.model_orders", operation: "update", roles: ["authenticated"], source: "migrations/002-model-orders.sql", tests: ["tests/database-governance.sql"] },
|
|
23239
23641
|
] });
|
|
23240
23642
|
`,
|
|
23241
23643
|
"tests/database-governance.sql": `BEGIN READ ONLY;
|
|
@@ -23247,6 +23649,11 @@ DO $check$ BEGIN
|
|
|
23247
23649
|
AND policyname='model_orders_host' AND roles=ARRAY['model_orders_app']::name[] AND cmd='ALL') THEN
|
|
23248
23650
|
RAISE EXCEPTION 'model_orders trusted host policy is required';
|
|
23249
23651
|
END IF;
|
|
23652
|
+
IF (SELECT count(*) FROM pg_policies WHERE schemaname='public' AND tablename='model_orders'
|
|
23653
|
+
AND policyname IN ('model_orders_select','model_orders_insert','model_orders_update')
|
|
23654
|
+
AND 'authenticated'=ANY(roles)) <> 3 THEN
|
|
23655
|
+
RAISE EXCEPTION 'model_orders authenticated policies must match the model row projection';
|
|
23656
|
+
END IF;
|
|
23250
23657
|
END $check$;
|
|
23251
23658
|
ROLLBACK;
|
|
23252
23659
|
`,
|
|
@@ -23305,7 +23712,7 @@ Connect the existing queue consumer to host.worker(claim, signal). Acknowledge o
|
|
|
23305
23712
|
|
|
23306
23713
|
The receipt migration uses the same supacloud_commands ledger as the platform. It supports local transactional commands; external commands and durable recovery still require the existing Commands/Workflow runtime. Never apply a second migration history.
|
|
23307
23714
|
|
|
23308
|
-
The model_orders_app role is a trusted-server capability.
|
|
23715
|
+
The model_orders_app role is a trusted-server capability and does not set request.jwt.claims. Its SQL policy is a host bypass, not the model row projection; do not grant that role to PostgREST. Authenticated SELECT, INSERT and UPDATE policies are emitted from the ZModel @@allow rules and must stay in the migration. They do not grant privileges; add a reviewed GRANT before exposing the table through PostgREST.
|
|
23309
23716
|
|
|
23310
23717
|
To change the schema: bun run db:generate, bun run db:check, then bun run db:diff -- --candidate output/database-audit/change.sql against an explicit shadow database. Review forward SQL before promotion. Stop intake and drain HTTP/worker work before host.dispose(), then close the caller-owned pool.
|
|
23311
23718
|
`
|
|
@@ -24422,7 +24829,8 @@ var STARTER_DATABASE_CONFIG = {
|
|
|
24422
24829
|
consumers: ["src", "scripts", "tests"],
|
|
24423
24830
|
auditConsumers: [],
|
|
24424
24831
|
trustedHosts: ["src/host", "src/delivery-host.ts", "src/delivery-worker.ts"],
|
|
24425
|
-
role: "starter_review_http"
|
|
24832
|
+
role: "starter_review_http",
|
|
24833
|
+
policyRls: "deferred"
|
|
24426
24834
|
};
|
|
24427
24835
|
var STARTER_DATABASE_MODEL = `datasource db {
|
|
24428
24836
|
provider = "postgresql"
|
|
@@ -24580,10 +24988,11 @@ var STARTER_DATABASE_GUIDE = `
|
|
|
24580
24988
|
Maintain zenstack/schema.zmodel. Run \`bun run db:generate\` to compile model and RPC
|
|
24581
24989
|
contracts; commit generated types with their sources. Do not introduce any/@ts-ignore
|
|
24582
24990
|
to bypass model or contract diagnostics. \`bun run db:check\` compares
|
|
24583
|
-
fresh generation without writing files or opening a database.
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24991
|
+
fresh generation without writing files or opening a database. This starter sets
|
|
24992
|
+
\`policyRls\` to \`deferred\` because relation predicates and storage fences are reviewed
|
|
24993
|
+
SQL, not the authenticated row-policy projection. Command writes still use the shared
|
|
24994
|
+
transaction, receipt and audit boundary, not unrestricted CRUD. SQL constraints, RPCs
|
|
24995
|
+
and RLS remain explicit reviewed migrations when the model language cannot express them.
|
|
24587
24996
|
|
|
24588
24997
|
Use \`bun run db:diff -- --candidate output/database-audit/change.sql\` with an
|
|
24589
24998
|
explicit read-only SUPACLOUD_MODEL_DATABASE_URL. Review the SQL, then promote a new
|
|
@@ -25928,7 +26337,7 @@ export async function createReviewTaskAdapters(options: ReviewTaskOptions): Prom
|
|
|
25928
26337
|
`;
|
|
25929
26338
|
|
|
25930
26339
|
// src/shared/tools/app-starter.ts
|
|
25931
|
-
var { compiler: compilerMetadata2, app: appMetadata2, elysia: elysiaMetadata2, commands: commandsMetadata, contracts: contractsMetadata, db: dbMetadata, sdk: sdkMetadata } = starter_metadata_default.packages;
|
|
26340
|
+
var { compiler: compilerMetadata2, app: appMetadata2, elysia: elysiaMetadata2, commands: commandsMetadata, contracts: contractsMetadata, db: dbMetadata, dbZenstack: dbZenstackMetadata, sdk: sdkMetadata } = starter_metadata_default.packages;
|
|
25932
26341
|
var json3 = (value) => `${JSON.stringify(value, null, 2)}
|
|
25933
26342
|
`;
|
|
25934
26343
|
function appStarterFiles(name) {
|
|
@@ -25970,16 +26379,19 @@ function appStarterFiles(name) {
|
|
|
25970
26379
|
"@supacloud/commands": `^${commandsMetadata.version}`,
|
|
25971
26380
|
"@supacloud/contracts": `^${contractsMetadata.version}`,
|
|
25972
26381
|
"@supacloud/db": `^${dbMetadata.version}`,
|
|
26382
|
+
"@supacloud/db-zenstack": `^${dbZenstackMetadata.version}`,
|
|
25973
26383
|
...dbMetadata.dependencies,
|
|
26384
|
+
...dbZenstackMetadata.dependencies,
|
|
25974
26385
|
"@supacloud/js": `^${sdkMetadata.version}`,
|
|
25975
26386
|
"@supabase/supabase-js": sdkMetadata.peerDependencies["@supabase/supabase-js"],
|
|
25976
26387
|
effect: "4.0.5",
|
|
25977
|
-
elysia: "2.0.0-rc.
|
|
26388
|
+
elysia: "2.0.0-rc.3",
|
|
25978
26389
|
rxjs: appMetadata2.dependencies.rxjs
|
|
25979
26390
|
},
|
|
25980
26391
|
devDependencies: {
|
|
25981
26392
|
"@supacloud/compiler": `^${compilerMetadata2.version}`,
|
|
25982
26393
|
...dbMetadata.devDependencies,
|
|
26394
|
+
...dbZenstackMetadata.devDependencies,
|
|
25983
26395
|
"@types/bun": "^1.4.4",
|
|
25984
26396
|
typescript: "7.1.0-beta"
|
|
25985
26397
|
}
|
|
@@ -26177,27 +26589,88 @@ export function createDemo() {
|
|
|
26177
26589
|
}
|
|
26178
26590
|
`,
|
|
26179
26591
|
"src/application.ts": `import { createApplication } from "@supacloud/elysia";
|
|
26180
|
-
import {
|
|
26592
|
+
import {
|
|
26593
|
+
createSupAuthRequestContext,
|
|
26594
|
+
type SupAuthContextOptions,
|
|
26595
|
+
type CommandGovernance,
|
|
26596
|
+
type ExecutionObserver,
|
|
26597
|
+
} from "@supacloud/elysia";
|
|
26181
26598
|
import { createCompiledModules } from "../generated/application";
|
|
26182
26599
|
|
|
26600
|
+
/** Trusted-host adapters. Keep these explicit so indexed ApplicationOptions access cannot widen to any. */
|
|
26183
26601
|
export interface AppAdapters {
|
|
26184
|
-
deps:
|
|
26185
|
-
requestContext:
|
|
26602
|
+
deps: Record<string, unknown>;
|
|
26603
|
+
requestContext: (
|
|
26604
|
+
request: Request,
|
|
26605
|
+
context: unknown,
|
|
26606
|
+
signal?: AbortSignal,
|
|
26607
|
+
) => unknown | Promise<unknown>;
|
|
26186
26608
|
commandGovernance: CommandGovernance;
|
|
26187
|
-
onExecution?:
|
|
26609
|
+
onExecution?: ExecutionObserver;
|
|
26610
|
+
}
|
|
26611
|
+
|
|
26612
|
+
export interface CreatedApplication {
|
|
26613
|
+
fetch: (request: Request) => Promise<Response>;
|
|
26614
|
+
handle: (request: Request) => Promise<Response>;
|
|
26615
|
+
initialize: () => Promise<void>;
|
|
26616
|
+
destroy: () => Promise<void>;
|
|
26617
|
+
}
|
|
26618
|
+
|
|
26619
|
+
function isRecord(value: unknown): value is { readonly [key: string]: unknown } {
|
|
26620
|
+
return typeof value === "object" && value !== null;
|
|
26621
|
+
}
|
|
26622
|
+
|
|
26623
|
+
function isApplicationHost(value: unknown): value is {
|
|
26624
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
26625
|
+
handle: (request: Request) => Response | Promise<Response>;
|
|
26626
|
+
initialize: () => void | Promise<void>;
|
|
26627
|
+
destroy: () => void | Promise<void>;
|
|
26628
|
+
} {
|
|
26629
|
+
return isRecord(value)
|
|
26630
|
+
&& typeof value["fetch"] === "function"
|
|
26631
|
+
&& typeof value["handle"] === "function"
|
|
26632
|
+
&& typeof value["initialize"] === "function"
|
|
26633
|
+
&& typeof value["destroy"] === "function";
|
|
26634
|
+
}
|
|
26635
|
+
|
|
26636
|
+
function isRequestContextFactory(value: unknown): value is AppAdapters["requestContext"] {
|
|
26637
|
+
return typeof value === "function";
|
|
26638
|
+
}
|
|
26639
|
+
|
|
26640
|
+
export function readCreatedApplication(value: unknown): CreatedApplication {
|
|
26641
|
+
if (!isApplicationHost(value)) {
|
|
26642
|
+
throw new Error("createApplication returned an invalid application host");
|
|
26643
|
+
}
|
|
26644
|
+
return {
|
|
26645
|
+
fetch: async (request) => await value.fetch(request),
|
|
26646
|
+
handle: async (request) => await value.handle(request),
|
|
26647
|
+
initialize: async () => { await value.initialize(); },
|
|
26648
|
+
destroy: async () => { await value.destroy(); },
|
|
26649
|
+
};
|
|
26188
26650
|
}
|
|
26189
26651
|
|
|
26190
26652
|
// The host verifies external identity (SupAuth for unified login) before creating requestContext.
|
|
26191
|
-
export function createApp(adapters: AppAdapters) {
|
|
26192
|
-
|
|
26193
|
-
|
|
26653
|
+
export function createApp(adapters: AppAdapters): CreatedApplication {
|
|
26654
|
+
const application: unknown = createApplication({
|
|
26655
|
+
deps: adapters.deps,
|
|
26656
|
+
requestContext: adapters.requestContext,
|
|
26657
|
+
commandGovernance: adapters.commandGovernance,
|
|
26194
26658
|
name: ${JSON.stringify(name)},
|
|
26195
26659
|
modules: createCompiledModules(),
|
|
26660
|
+
...(adapters.onExecution === undefined ? {} : { onExecution: adapters.onExecution }),
|
|
26196
26661
|
});
|
|
26662
|
+
return readCreatedApplication(application);
|
|
26197
26663
|
}
|
|
26198
26664
|
|
|
26199
|
-
export function createSupAuthApp(
|
|
26200
|
-
|
|
26665
|
+
export function createSupAuthApp(
|
|
26666
|
+
identity: SupAuthContextOptions,
|
|
26667
|
+
adapters: Omit<AppAdapters, "requestContext">,
|
|
26668
|
+
): CreatedApplication {
|
|
26669
|
+
const resolved: unknown = createSupAuthRequestContext(identity);
|
|
26670
|
+
if (!isRequestContextFactory(resolved)) {
|
|
26671
|
+
throw new Error("createSupAuthRequestContext must return a requestContext function");
|
|
26672
|
+
}
|
|
26673
|
+
return createApp({ ...adapters, requestContext: resolved });
|
|
26201
26674
|
}
|
|
26202
26675
|
`,
|
|
26203
26676
|
"generated/application.ts": `// BOOTSTRAP ARTIFACT: bun run compile replaces this file.
|
|
@@ -26543,7 +27016,10 @@ Management API tokens and service-role keys remain on trusted servers.
|
|
|
26543
27016
|
Ordinary reads use PostgREST through the existing user-scoped
|
|
26544
27017
|
@supabase/supabase-js client: client.from("starter_reviews").select("id,state,version").
|
|
26545
27018
|
Use the caller's session, RLS and grants; never introduce a second session store.
|
|
26546
|
-
|
|
27019
|
+
Command is the write boundary of this compiler application lane only.
|
|
27020
|
+
Cross-table change, idempotency, and audit stay on the governed Command/RPC
|
|
27021
|
+
boundary. Ordinary reads and low-risk CRUD stay on PostgREST and
|
|
27022
|
+
@supabase/supabase-js.
|
|
26547
27023
|
|
|
26548
27024
|
Use listReviews from src/review/list-reviews.ts for the paginated review list.
|
|
26549
27025
|
Type the existing client with ReviewReadDatabase (a read-only projection derived
|
|
@@ -26877,18 +27353,32 @@ async function initializeAppProject(options) {
|
|
|
26877
27353
|
if ((await readdir3(root)).some((entry) => entry !== ".git")) {
|
|
26878
27354
|
throw new Error("app init requires an empty directory (an existing .git directory is allowed)");
|
|
26879
27355
|
}
|
|
26880
|
-
const template = options.template
|
|
27356
|
+
const template = resolveStarterTemplate(options.template);
|
|
26881
27357
|
const sdk = {
|
|
26882
27358
|
"@supacloud/js": `^${sdkMetadata.version}`,
|
|
26883
27359
|
"@supabase/supabase-js": sdkMetadata.peerDependencies["@supabase/supabase-js"]
|
|
26884
27360
|
};
|
|
26885
|
-
const files =
|
|
27361
|
+
const files = (() => {
|
|
27362
|
+
switch (template) {
|
|
27363
|
+
case "command":
|
|
27364
|
+
return appStarterFiles(name);
|
|
27365
|
+
case "model-command":
|
|
27366
|
+
return modelCommandTemplateFiles(name, sdk);
|
|
27367
|
+
case "minimal":
|
|
27368
|
+
case "client":
|
|
27369
|
+
return appTemplateFiles(name, template, sdk);
|
|
27370
|
+
default: {
|
|
27371
|
+
const exhausted = template;
|
|
27372
|
+
throw new Error(`Unknown app init template: ${String(exhausted)}`);
|
|
27373
|
+
}
|
|
27374
|
+
}
|
|
27375
|
+
})();
|
|
26886
27376
|
for (const [relativePath, content] of Object.entries(files)) {
|
|
26887
27377
|
const path = join9(root, relativePath);
|
|
26888
27378
|
await mkdir3(dirname6(path), { recursive: true });
|
|
26889
27379
|
await writeFile3(path, content, { encoding: "utf8", flag: "wx" });
|
|
26890
27380
|
}
|
|
26891
|
-
return { root, name, files: Object.keys(files) };
|
|
27381
|
+
return { root, name, files: Object.keys(files), template };
|
|
26892
27382
|
}
|
|
26893
27383
|
|
|
26894
27384
|
// src/shared/tools/app-database-check.ts
|
|
@@ -26930,12 +27420,18 @@ function checkAppDatabaseSources(projectRoot) {
|
|
|
26930
27420
|
}
|
|
26931
27421
|
return {
|
|
26932
27422
|
name,
|
|
27423
|
+
layer: "source",
|
|
26933
27424
|
ok: (result.exitCode === 0 || result.success) && report.ok && !messages.length,
|
|
26934
27425
|
detail: messages.join(`
|
|
26935
27426
|
`) || ((result.exitCode === 0 || result.success) && report.ok ? "Offline database contracts and boundaries are current" : "Database source check failed")
|
|
26936
27427
|
};
|
|
26937
27428
|
} catch {
|
|
26938
|
-
return {
|
|
27429
|
+
return {
|
|
27430
|
+
name,
|
|
27431
|
+
layer: "runtime",
|
|
27432
|
+
ok: false,
|
|
27433
|
+
detail: "Cannot run the project database checker. Install the project runtime and @supacloud/db with source-contracts support, then run `supacloud-db check --root .` for diagnostics."
|
|
27434
|
+
};
|
|
26939
27435
|
}
|
|
26940
27436
|
}
|
|
26941
27437
|
|
|
@@ -28590,17 +29086,20 @@ for (const [name, schema] of Object.entries(REMOTE_APP_SCHEMA)) {
|
|
|
28590
29086
|
async function initProject(args) {
|
|
28591
29087
|
if (args.force)
|
|
28592
29088
|
throw new Error("app init never overwrites files; choose an empty directory");
|
|
28593
|
-
const template =
|
|
28594
|
-
|
|
28595
|
-
|
|
29089
|
+
const { root, name, files, template } = await initializeAppProject({
|
|
29090
|
+
root: args.root,
|
|
29091
|
+
name: args.name,
|
|
29092
|
+
template: args.template
|
|
29093
|
+
});
|
|
29094
|
+
const next = template === "client" ? ["bun install", "bun run check"] : [
|
|
28596
29095
|
"bun install",
|
|
28597
|
-
...template
|
|
29096
|
+
...template === "command" || template === "model-command" ? ["bun run db:generate"] : [],
|
|
28598
29097
|
...template === "model-command" ? ["bun run compile"] : [],
|
|
28599
29098
|
"bun run check",
|
|
28600
29099
|
...template === "model-command" ? ["# Follow README.md: apply reviewed local migrations, provision the application role and configure IdentityAuthority before dev."] : [],
|
|
28601
29100
|
"bun run dev"
|
|
28602
29101
|
];
|
|
28603
|
-
const note = template === "model-command" ? "Requires an explicitly selected database, reviewed migrations and trusted HTTP/worker identity authority; see README.md." : "Local demo only. Production requires persistent governance and identity adapters; see README.md.";
|
|
29102
|
+
const note = template === "client" ? "Data-plane client only (@supabase/supabase-js). The forced default is app init (minimal compiler/Effect stack)." : template === "model-command" ? "Requires an explicitly selected database, reviewed migrations and trusted HTTP/worker identity authority; see README.md." : "Local demo only. Production requires persistent governance and identity adapters; see README.md.";
|
|
28604
29103
|
if (args.format === "json")
|
|
28605
29104
|
return textResult(JSON.stringify({
|
|
28606
29105
|
version: 1,
|
|
@@ -29134,7 +29633,7 @@ async function runDoctor(args) {
|
|
|
29134
29633
|
...doctor
|
|
29135
29634
|
}, null, 2), doctor.errors > 0);
|
|
29136
29635
|
}
|
|
29137
|
-
const lines = doctor.checks.map((check) =>
|
|
29636
|
+
const lines = doctor.checks.map((check) => formatDoctorCheck(check));
|
|
29138
29637
|
if (scope)
|
|
29139
29638
|
lines.unshift(`TARGET ${scope.target}; omitted project diagnostics=${scope.omittedProjectDiagnostics}; generated drift remains project-wide`);
|
|
29140
29639
|
for (const diagnostic of doctor.diagnostics ?? []) {
|
|
@@ -29442,7 +29941,7 @@ async function runCheck(args) {
|
|
|
29442
29941
|
return textResult([
|
|
29443
29942
|
formatDiagnostics(result.diagnostics),
|
|
29444
29943
|
...result.mismatches.map((path) => `generated artifact mismatch: ${path}`),
|
|
29445
|
-
...database ? [
|
|
29944
|
+
...database ? [formatDoctorCheck(database)] : [],
|
|
29446
29945
|
"",
|
|
29447
29946
|
summary
|
|
29448
29947
|
].join(`
|
|
@@ -30288,7 +30787,7 @@ function registerAppTools(server, options = {}) {
|
|
|
30288
30787
|
"promote-reconcile"
|
|
30289
30788
|
]), "App action; promote obtains and verifies its plan before one mutation request"),
|
|
30290
30789
|
kind: optional(stringEnum2(["module", "command", "query", "controller", "job", "contract", "resource", "feature"]), "[generate] Scaffold kind"),
|
|
30291
|
-
template: optional(stringEnum2(["minimal", "command", "model-command"]), "[init]
|
|
30790
|
+
template: optional(stringEnum2(["minimal", "client", "command", "model-command", "app"]), "[init] minimal (default) is the compiler/Effect stack; client is @supabase/supabase-js only; command is the native-SQL reference; model-command adds ZenStack HTTP/worker commands; app is an alias of minimal"),
|
|
30292
30791
|
name: optional(String2(), "[init/generate] Project or object name"),
|
|
30293
30792
|
module: optional(String2(), "[generate] Target feature module (required for command/query/controller)"),
|
|
30294
30793
|
permission: optional(String2(), "[generate feature] Explicit approval permission; not inferred from name"),
|
|
@@ -32500,7 +32999,6 @@ function handleScopeCreate(args, fallbackRef) {
|
|
|
32500
32999
|
taskId: String(args.task).trim(),
|
|
32501
33000
|
web: Boolean(args.web)
|
|
32502
33001
|
};
|
|
32503
|
-
const canonicalJson = genericScopedReleaseScopeJson(scope);
|
|
32504
33002
|
const scopeSha256 = genericScopedReleaseScopeSha256(scope);
|
|
32505
33003
|
const formatted = JSON.stringify(canonicalValue(scope), null, 2) + `
|
|
32506
33004
|
`;
|
|
@@ -34369,7 +34867,7 @@ async function runProjectDeployment(http, args) {
|
|
|
34369
34867
|
// package.json
|
|
34370
34868
|
var package_default = {
|
|
34371
34869
|
name: "@supacloud/cli",
|
|
34372
|
-
version: "0.
|
|
34870
|
+
version: "0.121.6",
|
|
34373
34871
|
description: "Project-scoped CLI for SupaCloud users",
|
|
34374
34872
|
type: "module",
|
|
34375
34873
|
main: "./dist/index.js",
|
|
@@ -34421,26 +34919,26 @@ var package_default = {
|
|
|
34421
34919
|
directory: "packages/cli"
|
|
34422
34920
|
},
|
|
34423
34921
|
dependencies: {
|
|
34424
|
-
"@supacloud/compiler": "^0.62.
|
|
34425
|
-
"@supacloud/delivery": "0.
|
|
34426
|
-
"@supacloud/db": "0.24.
|
|
34922
|
+
"@supacloud/compiler": "^0.62.5",
|
|
34923
|
+
"@supacloud/delivery": "0.28.0",
|
|
34924
|
+
"@supacloud/db": "0.24.2",
|
|
34427
34925
|
typebox: "1.4.3"
|
|
34428
34926
|
},
|
|
34429
34927
|
overrides: {
|
|
34430
|
-
"@supacloud/contracts": "0.16.
|
|
34431
|
-
"@supacloud/delivery": "0.
|
|
34928
|
+
"@supacloud/contracts": "0.16.2",
|
|
34929
|
+
"@supacloud/delivery": "0.28.0",
|
|
34432
34930
|
"@graphql-tools/utils": "^12.0.4",
|
|
34433
|
-
"@supacloud/compiler": "^0.62.
|
|
34434
|
-
"@supacloud/db": "0.24.
|
|
34931
|
+
"@supacloud/compiler": "^0.62.5",
|
|
34932
|
+
"@supacloud/db": "0.24.2",
|
|
34435
34933
|
"deepmerge-ts": "8.0.2",
|
|
34436
34934
|
prisma: "6.19.3"
|
|
34437
34935
|
},
|
|
34438
34936
|
devDependencies: {
|
|
34439
34937
|
"@supabase/supabase-js": "2.118.0",
|
|
34440
|
-
"@supacloud/elysia": "0.42.
|
|
34938
|
+
"@supacloud/elysia": "0.42.4",
|
|
34441
34939
|
"@types/bun": "^1.4.4",
|
|
34442
34940
|
effect: "4.0.5",
|
|
34443
|
-
elysia: "2.0.0-rc.
|
|
34941
|
+
elysia: "2.0.0-rc.3",
|
|
34444
34942
|
typescript: "7.1.0-beta"
|
|
34445
34943
|
}
|
|
34446
34944
|
};
|