@supacloud/cli 0.120.1 → 0.121.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/index.js +597 -119
- package/dist/shared/tools/app-database-check.d.ts +2 -0
- 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 +8 -8
- package/skills/supacloud/references/app-workflow.md +3 -0
package/dist/index.js
CHANGED
|
@@ -11145,10 +11145,103 @@ function summarizeDeploymentEvidence(value) {
|
|
|
11145
11145
|
liveObservationPerformed: false
|
|
11146
11146
|
};
|
|
11147
11147
|
}
|
|
11148
|
-
// node_modules/@supacloud/delivery/src/
|
|
11148
|
+
// node_modules/@supacloud/delivery/src/platform-deployment.ts
|
|
11149
|
+
var closed6 = { additionalProperties: false };
|
|
11149
11150
|
var sha2563 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11150
|
-
var
|
|
11151
|
+
var releaseId = String2({ pattern: "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$" });
|
|
11152
|
+
var mutationId = String2({ pattern: "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$" });
|
|
11151
11153
|
var isoDate2 = String2({ minLength: 20, maxLength: 40 });
|
|
11154
|
+
var PLATFORM_DEPLOYMENT_STATE_SCHEMA = "supacloud.platform-deployment-state.v1";
|
|
11155
|
+
var componentName2 = Union([
|
|
11156
|
+
Literal("management-api"),
|
|
11157
|
+
Literal("web-console"),
|
|
11158
|
+
Literal("caddy"),
|
|
11159
|
+
Literal("postgres"),
|
|
11160
|
+
Literal("postgrest"),
|
|
11161
|
+
Literal("gotrue"),
|
|
11162
|
+
Literal("realtime"),
|
|
11163
|
+
Literal("storage"),
|
|
11164
|
+
Literal("victoria-logs"),
|
|
11165
|
+
Literal("edge-runtime")
|
|
11166
|
+
]);
|
|
11167
|
+
var componentStatus = Union([
|
|
11168
|
+
Literal("ready"),
|
|
11169
|
+
Literal("stopped"),
|
|
11170
|
+
Literal("starting"),
|
|
11171
|
+
Literal("unhealthy"),
|
|
11172
|
+
Literal("failed"),
|
|
11173
|
+
Literal("unknown")
|
|
11174
|
+
]);
|
|
11175
|
+
var desiredStatus = Union([Literal("running"), Literal("stopped")]);
|
|
11176
|
+
var actualStatus = Union([
|
|
11177
|
+
Literal("absent"),
|
|
11178
|
+
Literal("starting"),
|
|
11179
|
+
Literal("running"),
|
|
11180
|
+
Literal("stopped"),
|
|
11181
|
+
Literal("degraded"),
|
|
11182
|
+
Literal("failed"),
|
|
11183
|
+
Literal("unknown")
|
|
11184
|
+
]);
|
|
11185
|
+
var operationPhase = Union([
|
|
11186
|
+
Literal("idle"),
|
|
11187
|
+
Literal("preparing"),
|
|
11188
|
+
Literal("activating"),
|
|
11189
|
+
Literal("verifying"),
|
|
11190
|
+
Literal("confirmed"),
|
|
11191
|
+
Literal("failed"),
|
|
11192
|
+
Literal("unknown"),
|
|
11193
|
+
Literal("rolled-back")
|
|
11194
|
+
]);
|
|
11195
|
+
var retryAction = Union([
|
|
11196
|
+
Literal("none"),
|
|
11197
|
+
Literal("reconcile-same-mutation"),
|
|
11198
|
+
Literal("manual-recovery"),
|
|
11199
|
+
Literal("new-mutation")
|
|
11200
|
+
]);
|
|
11201
|
+
var PlatformDeploymentComponentSchema = _Object_({
|
|
11202
|
+
name: componentName2,
|
|
11203
|
+
version: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
11204
|
+
status: componentStatus,
|
|
11205
|
+
health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
|
|
11206
|
+
checked_at: Union([isoDate2, Null()])
|
|
11207
|
+
}, closed6);
|
|
11208
|
+
var PlatformDeploymentStateSchema = _Object_({
|
|
11209
|
+
schema: Literal(PLATFORM_DEPLOYMENT_STATE_SCHEMA),
|
|
11210
|
+
profile: Literal("single-node"),
|
|
11211
|
+
host: _Object_({
|
|
11212
|
+
os: Literal("linux"),
|
|
11213
|
+
distribution: Literal("ubuntu"),
|
|
11214
|
+
version: Literal("24.04"),
|
|
11215
|
+
architecture: Literal("amd64"),
|
|
11216
|
+
init: Literal("systemd")
|
|
11217
|
+
}, closed6),
|
|
11218
|
+
desired: _Object_({
|
|
11219
|
+
state: desiredStatus,
|
|
11220
|
+
release_id: Union([releaseId, Null()]),
|
|
11221
|
+
manifest_sha256: Union([sha2563, Null()])
|
|
11222
|
+
}, closed6),
|
|
11223
|
+
actual: _Object_({
|
|
11224
|
+
state: actualStatus,
|
|
11225
|
+
release_id: Union([releaseId, Null()]),
|
|
11226
|
+
manifest_sha256: Union([sha2563, Null()]),
|
|
11227
|
+
checked_at: Union([isoDate2, Null()]),
|
|
11228
|
+
components: _Array_(PlatformDeploymentComponentSchema, { minItems: 1, maxItems: 16 })
|
|
11229
|
+
}, closed6),
|
|
11230
|
+
operation: _Object_({
|
|
11231
|
+
mutation_id: Union([mutationId, Null()]),
|
|
11232
|
+
phase: operationPhase,
|
|
11233
|
+
retry: retryAction,
|
|
11234
|
+
error: Union([String2({ minLength: 1, maxLength: 512 }), Null()])
|
|
11235
|
+
}, closed6),
|
|
11236
|
+
rollback: _Object_({
|
|
11237
|
+
release_id: Union([releaseId, Null()]),
|
|
11238
|
+
ready: Boolean2()
|
|
11239
|
+
}, closed6)
|
|
11240
|
+
}, closed6);
|
|
11241
|
+
// node_modules/@supacloud/delivery/src/delivery-tuple.ts
|
|
11242
|
+
var sha2564 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11243
|
+
var commit = String2({ pattern: "^(?:[a-f0-9]{40}|[a-f0-9]{64})$" });
|
|
11244
|
+
var isoDate3 = String2({ minLength: 20, maxLength: 40 });
|
|
11152
11245
|
var DELIVERY_TUPLE_SCHEMA = "supacloud.fa-delivery-tuple.v1";
|
|
11153
11246
|
var FaDeliveryTupleSchema = _Object_({
|
|
11154
11247
|
schema: Literal(DELIVERY_TUPLE_SCHEMA),
|
|
@@ -11160,21 +11253,21 @@ var FaDeliveryTupleSchema = _Object_({
|
|
|
11160
11253
|
platform_commit: commit,
|
|
11161
11254
|
edge_runtime: _Object_({
|
|
11162
11255
|
version: String2({ minLength: 1, maxLength: 128 }),
|
|
11163
|
-
artifact_sha256:
|
|
11256
|
+
artifact_sha256: sha2564
|
|
11164
11257
|
}, { additionalProperties: false }),
|
|
11165
11258
|
compatibility_window: _Object_({
|
|
11166
11259
|
contract_schema: String2({ minLength: 1, maxLength: 128 }),
|
|
11167
|
-
starts_at:
|
|
11168
|
-
ends_at:
|
|
11260
|
+
starts_at: isoDate3,
|
|
11261
|
+
ends_at: isoDate3,
|
|
11169
11262
|
old_client_supported: Boolean2(),
|
|
11170
11263
|
partial_deployment_supported: Boolean2()
|
|
11171
11264
|
}, { additionalProperties: false })
|
|
11172
11265
|
}, { additionalProperties: false });
|
|
11173
11266
|
// node_modules/@supacloud/delivery/src/contract-matrix.ts
|
|
11174
|
-
var
|
|
11175
|
-
var
|
|
11267
|
+
var closed7 = { additionalProperties: false };
|
|
11268
|
+
var sha2565 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11176
11269
|
var generation = Union([Literal("old"), Literal("new")]);
|
|
11177
|
-
var versions = _Object_({ old:
|
|
11270
|
+
var versions = _Object_({ old: sha2565, new: sha2565 }, closed7);
|
|
11178
11271
|
var CONTRACT_MATRIX_SCHEMA = "supacloud.consumer-contract-matrix.v1";
|
|
11179
11272
|
var FA_CONTRACT_SCENARIOS = [
|
|
11180
11273
|
"missing-display-field",
|
|
@@ -11187,9 +11280,9 @@ var FA_CONTRACT_SCENARIOS = [
|
|
|
11187
11280
|
var ConsumerContractMatrixSchema = _Object_({
|
|
11188
11281
|
schema: Literal(CONTRACT_MATRIX_SCHEMA),
|
|
11189
11282
|
customer: Literal("xigu-fa"),
|
|
11190
|
-
baseline_tuple_sha256:
|
|
11191
|
-
candidate_tuple_sha256:
|
|
11192
|
-
artifacts: _Object_({ frontend: versions, functions: versions, database: versions },
|
|
11283
|
+
baseline_tuple_sha256: sha2565,
|
|
11284
|
+
candidate_tuple_sha256: sha2565,
|
|
11285
|
+
artifacts: _Object_({ frontend: versions, functions: versions, database: versions }, closed7),
|
|
11193
11286
|
cases: _Array_(_Object_({
|
|
11194
11287
|
frontend: generation,
|
|
11195
11288
|
functions: generation,
|
|
@@ -11197,11 +11290,11 @@ var ConsumerContractMatrixSchema = _Object_({
|
|
|
11197
11290
|
scenarios: _Array_(_Object_({
|
|
11198
11291
|
name: Enum(FA_CONTRACT_SCENARIOS),
|
|
11199
11292
|
expected: Union([Literal("compatible"), Literal("blocked-safely")])
|
|
11200
|
-
},
|
|
11201
|
-
},
|
|
11202
|
-
},
|
|
11293
|
+
}, closed7), { minItems: FA_CONTRACT_SCENARIOS.length, maxItems: FA_CONTRACT_SCENARIOS.length })
|
|
11294
|
+
}, closed7), { minItems: 8, maxItems: 8 })
|
|
11295
|
+
}, closed7);
|
|
11203
11296
|
// node_modules/@supacloud/delivery/src/fa-stability.ts
|
|
11204
|
-
var
|
|
11297
|
+
var closed8 = { additionalProperties: false };
|
|
11205
11298
|
var hash3 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
11206
11299
|
var label = String2({ minLength: 1, maxLength: 256, pattern: "\\S" });
|
|
11207
11300
|
var timestamp2 = String2({ minLength: 24, maxLength: 24 });
|
|
@@ -11224,7 +11317,7 @@ var operation = Enum(FA_BUSINESS_OPERATIONS);
|
|
|
11224
11317
|
var proof = _Object_({
|
|
11225
11318
|
path: String2({ pattern: "^[A-Za-z0-9_-][A-Za-z0-9_./-]{0,255}$" }),
|
|
11226
11319
|
sha256: hash3
|
|
11227
|
-
},
|
|
11320
|
+
}, closed8);
|
|
11228
11321
|
var FaBusinessObservationSchema = _Object_({
|
|
11229
11322
|
id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
|
|
11230
11323
|
tuple_sha256: hash3,
|
|
@@ -11234,7 +11327,7 @@ var FaBusinessObservationSchema = _Object_({
|
|
|
11234
11327
|
outcome: Enum(["success", "failure", "timeout", "unknown"]),
|
|
11235
11328
|
attempts: Integer({ minimum: 1, maximum: 1000 }),
|
|
11236
11329
|
rollbacks: count
|
|
11237
|
-
},
|
|
11330
|
+
}, closed8);
|
|
11238
11331
|
var FaServiceObjectivesSchema = _Object_({
|
|
11239
11332
|
status: Literal("approved"),
|
|
11240
11333
|
owner: label,
|
|
@@ -11250,8 +11343,8 @@ var FaServiceObjectivesSchema = _Object_({
|
|
|
11250
11343
|
minimum_samples: Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
|
|
11251
11344
|
availability_percent: Number2({ exclusiveMinimum: 0, maximum: 100 }),
|
|
11252
11345
|
p95_ms: Number2({ exclusiveMinimum: 0, maximum: Number.MAX_SAFE_INTEGER })
|
|
11253
|
-
},
|
|
11254
|
-
},
|
|
11346
|
+
}, closed8), { minItems: FA_BUSINESS_OPERATIONS.length, maxItems: FA_BUSINESS_OPERATIONS.length })
|
|
11347
|
+
}, closed8);
|
|
11255
11348
|
var FaStabilityEvidenceSchema = _Object_({
|
|
11256
11349
|
schema: Literal("supacloud.fa-stability-evidence.v1"),
|
|
11257
11350
|
environment: environment2,
|
|
@@ -11277,7 +11370,7 @@ var FaStabilityEvidenceSchema = _Object_({
|
|
|
11277
11370
|
passed: Boolean2(),
|
|
11278
11371
|
measured_at: timestamp2,
|
|
11279
11372
|
proof
|
|
11280
|
-
},
|
|
11373
|
+
}, closed8), { minItems: 10, maxItems: 10 }),
|
|
11281
11374
|
matrix: _Array_(_Object_({
|
|
11282
11375
|
combination: label,
|
|
11283
11376
|
scenario: label,
|
|
@@ -11286,16 +11379,16 @@ var FaStabilityEvidenceSchema = _Object_({
|
|
|
11286
11379
|
passed: Boolean2(),
|
|
11287
11380
|
measured_at: timestamp2,
|
|
11288
11381
|
proof
|
|
11289
|
-
},
|
|
11382
|
+
}, closed8), { minItems: 48, maxItems: 48 }),
|
|
11290
11383
|
observation: proof,
|
|
11291
|
-
alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 },
|
|
11292
|
-
},
|
|
11384
|
+
alert: _Object_({ route: label, acknowledged_by: label, delivered_at: timestamp2 }, closed8)
|
|
11385
|
+
}, closed8);
|
|
11293
11386
|
// node_modules/@supacloud/delivery/src/application-promotion.ts
|
|
11294
|
-
var
|
|
11387
|
+
var closed9 = { additionalProperties: false };
|
|
11295
11388
|
var projectRef2 = String2({ pattern: "^[a-z0-9-]{1,20}$" });
|
|
11296
|
-
var
|
|
11389
|
+
var sha2566 = ApplicationReleaseIdSchema;
|
|
11297
11390
|
var nullableActivation2 = Union([ApplicationActivationIdSchema, Null()]);
|
|
11298
|
-
var nullableDigest = Union([
|
|
11391
|
+
var nullableDigest = Union([sha2566, Null()]);
|
|
11299
11392
|
var observation = {
|
|
11300
11393
|
activation_id: nullableActivation2,
|
|
11301
11394
|
receipt_confirmed: Boolean2(),
|
|
@@ -11321,33 +11414,33 @@ var ApplicationPromotionPlanSchema = _Object_({
|
|
|
11321
11414
|
project_ref: projectRef2,
|
|
11322
11415
|
application_id: ApplicationIdSchema,
|
|
11323
11416
|
environment_id: ApplicationIdSchema,
|
|
11324
|
-
manifest_sha256:
|
|
11325
|
-
plan_sha256:
|
|
11417
|
+
manifest_sha256: sha2566,
|
|
11418
|
+
plan_sha256: sha2566,
|
|
11326
11419
|
source: _Object_({
|
|
11327
11420
|
project_ref: projectRef2,
|
|
11328
11421
|
environment_id: ApplicationIdSchema,
|
|
11329
|
-
release_id:
|
|
11422
|
+
release_id: sha2566,
|
|
11330
11423
|
...observation
|
|
11331
|
-
},
|
|
11424
|
+
}, closed9),
|
|
11332
11425
|
target: _Object_({
|
|
11333
|
-
candidate_release_id:
|
|
11334
|
-
current_release_id: Union([
|
|
11426
|
+
candidate_release_id: sha2566,
|
|
11427
|
+
current_release_id: Union([sha2566, Null()]),
|
|
11335
11428
|
artifact_action: Union([Literal("materialize"), Literal("reuse")]),
|
|
11336
11429
|
configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
|
|
11337
11430
|
configuration: Union([ApplicationConfigurationViewSchema, Null()]),
|
|
11338
11431
|
...observation
|
|
11339
|
-
},
|
|
11432
|
+
}, closed9),
|
|
11340
11433
|
migrations: _Object_({
|
|
11341
|
-
ledger_digest:
|
|
11434
|
+
ledger_digest: sha2566,
|
|
11342
11435
|
ledger_compatible: Boolean2(),
|
|
11343
11436
|
project_migrations_applied: Boolean2(),
|
|
11344
11437
|
pending_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { maxItems: 4096, uniqueItems: true }),
|
|
11345
11438
|
operator_provisioning_required: Boolean2()
|
|
11346
|
-
},
|
|
11439
|
+
}, closed9),
|
|
11347
11440
|
backup: _Object_({
|
|
11348
11441
|
required: Boolean2(),
|
|
11349
11442
|
confirmed: Literal(false)
|
|
11350
|
-
},
|
|
11443
|
+
}, closed9),
|
|
11351
11444
|
action: Union([Literal("promote"), Literal("no-op"), Literal("blocked")]),
|
|
11352
11445
|
blockers: _Array_(Enum([...blocker]), {
|
|
11353
11446
|
maxItems: blocker.length,
|
|
@@ -11356,7 +11449,7 @@ var ApplicationPromotionPlanSchema = _Object_({
|
|
|
11356
11449
|
steps: _Array_(String2({ minLength: 1, maxLength: 64 }), { maxItems: 8, uniqueItems: true }),
|
|
11357
11450
|
execution_performed: Literal(false),
|
|
11358
11451
|
data_recovery: Literal("separate-required")
|
|
11359
|
-
},
|
|
11452
|
+
}, closed9);
|
|
11360
11453
|
function applicationPromotionPlanDigest(value) {
|
|
11361
11454
|
return digest(canonical(value));
|
|
11362
11455
|
}
|
|
@@ -18118,7 +18211,7 @@ var ApplicationDeployRequestSchema2 = ApplicationDeployRequestSchema;
|
|
|
18118
18211
|
var ApplicationDeployWebReleaseSchema2 = ApplicationDeployWebReleaseSchema;
|
|
18119
18212
|
|
|
18120
18213
|
// src/shared/tools/application-workflow-schemas.ts
|
|
18121
|
-
var
|
|
18214
|
+
var closed10 = { additionalProperties: false };
|
|
18122
18215
|
var ref5 = String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" });
|
|
18123
18216
|
var uuid = ApplicationActivationIdSchema2;
|
|
18124
18217
|
var nullableUuid = Union([uuid, Null()]);
|
|
@@ -18132,7 +18225,7 @@ var ApplicationPromotionResultSchema = _Object_({
|
|
|
18132
18225
|
plan_sha256: ApplicationReleaseIdSchema2,
|
|
18133
18226
|
action: Literal("promote"),
|
|
18134
18227
|
replayed: Boolean2()
|
|
18135
|
-
},
|
|
18228
|
+
}, closed10);
|
|
18136
18229
|
var ApplicationPromotionStatusSchema = _Object_({
|
|
18137
18230
|
...scope2,
|
|
18138
18231
|
mutation: Unknown(),
|
|
@@ -18151,8 +18244,8 @@ var ApplicationPromotionStatusSchema = _Object_({
|
|
|
18151
18244
|
configuration_id: Union([ApplicationConfigurationIdSchema2, Null()]),
|
|
18152
18245
|
backup_id: Union([String2({ pattern: "^logical-full_[a-z0-9-]{1,20}_[a-f0-9]{32}$" }), Null()]),
|
|
18153
18246
|
data_recovery: Literal("separate-required")
|
|
18154
|
-
},
|
|
18155
|
-
},
|
|
18247
|
+
}, closed10)
|
|
18248
|
+
}, closed10);
|
|
18156
18249
|
var phase = Union([Literal("pending"), Literal("ready"), Literal("failed"), Literal("cleaned")]);
|
|
18157
18250
|
var previewId = String2({ pattern: "^[a-f0-9-]{8,64}$" });
|
|
18158
18251
|
var name = String2({ minLength: 1, maxLength: 256 });
|
|
@@ -18171,39 +18264,39 @@ var ApplicationPreviewReceiptSchema2 = _Object_({
|
|
|
18171
18264
|
Literal("cleaned")
|
|
18172
18265
|
]),
|
|
18173
18266
|
resources: _Object_({
|
|
18174
|
-
build_artifact: _Object_({ status: phase, release_id: ApplicationReleaseIdSchema2 },
|
|
18267
|
+
build_artifact: _Object_({ status: phase, release_id: ApplicationReleaseIdSchema2 }, closed10),
|
|
18175
18268
|
database_branch: _Object_({
|
|
18176
18269
|
status: phase,
|
|
18177
18270
|
branch_ref: ref5,
|
|
18178
18271
|
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 },
|
|
18272
|
+
}, closed10),
|
|
18273
|
+
queue_namespace: _Object_({ status: phase, namespace: name }, closed10),
|
|
18274
|
+
storage_namespace: _Object_({ status: phase, namespace: name }, closed10),
|
|
18275
|
+
test_secret: _Object_({ status: phase, name, value_issued: Literal(false) }, closed10),
|
|
18276
|
+
configuration_revision: _Object_({ status: phase, configuration_id: Union([ApplicationConfigurationIdSchema2, Null()]) }, closed10),
|
|
18277
|
+
application_activation: _Object_({ status: phase, activation_id: nullableUuid }, closed10),
|
|
18185
18278
|
functions: Optional(_Object_({
|
|
18186
18279
|
status: phase,
|
|
18187
18280
|
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
|
-
},
|
|
18281
|
+
}, closed10)),
|
|
18282
|
+
smoke_test: _Object_({ status: phase, checks, passed: checks, failed: checks }, closed10)
|
|
18283
|
+
}, closed10),
|
|
18191
18284
|
cleanup: _Object_({
|
|
18192
18285
|
required: Boolean2(),
|
|
18193
18286
|
completed: Boolean2(),
|
|
18194
18287
|
error: Union([String2({ pattern: "^[A-Z][A-Z0-9_]{0,63}$" }), Null()])
|
|
18195
|
-
},
|
|
18288
|
+
}, closed10),
|
|
18196
18289
|
branch_name: Optional(String2({ minLength: 1, maxLength: 80 })),
|
|
18197
18290
|
queue_name: Optional(name),
|
|
18198
18291
|
test_secret_name: Optional(name),
|
|
18199
18292
|
source_configuration_id: Optional(Union([ApplicationConfigurationIdSchema2, Null()])),
|
|
18200
18293
|
created_at: Optional(timestamp3),
|
|
18201
18294
|
updated_at: Optional(timestamp3)
|
|
18202
|
-
},
|
|
18295
|
+
}, closed10);
|
|
18203
18296
|
var previewListSchema = _Object_({
|
|
18204
18297
|
...scope2,
|
|
18205
18298
|
previews: _Array_(ApplicationPreviewReceiptSchema2, { maxItems: 1000 })
|
|
18206
|
-
},
|
|
18299
|
+
}, closed10);
|
|
18207
18300
|
function assertScope(value, identity) {
|
|
18208
18301
|
if (value.project_ref !== identity.project_ref || value.application_id !== identity.application_id || value.environment_id !== identity.environment_id)
|
|
18209
18302
|
throw new Error("Application workflow scope mismatch");
|
|
@@ -21691,6 +21784,10 @@ function buildLiteArgs(request) {
|
|
|
21691
21784
|
optionalFlag(args, "--storage-dir", request.storage_dir);
|
|
21692
21785
|
optionalFlag(args, "--storage-backend", request.storage_backend);
|
|
21693
21786
|
optionalFlag(args, "--s3-prefix", request.s3_prefix);
|
|
21787
|
+
booleanFlag(args, "--s3-endpoint", request.s3_endpoint);
|
|
21788
|
+
optionalFlag(args, "--s3-endpoint-access-key-id", request.s3_endpoint_access_key_id);
|
|
21789
|
+
optionalFlag(args, "--s3-endpoint-region", request.s3_endpoint_region);
|
|
21790
|
+
optionalFlag(args, "--s3-endpoint-buckets", request.s3_endpoint_buckets);
|
|
21694
21791
|
optionalFlag(args, "--engine", request.engine);
|
|
21695
21792
|
optionalFlag(args, "--host", request.host);
|
|
21696
21793
|
optionalFlag(args, "--port", request.port);
|
|
@@ -21816,6 +21913,10 @@ function registerLiteCliTools(server, options = {}) {
|
|
|
21816
21913
|
storage_dir: optional(String2(), "[*] Object storage directory"),
|
|
21817
21914
|
storage_backend: optional(stringEnum2(["fs", "memory", "s3"]), "[*] Storage backend"),
|
|
21818
21915
|
s3_prefix: optional(String2(), "[*] S3 object key prefix"),
|
|
21916
|
+
s3_endpoint: optional(Boolean2(), "[start/doctor] Expose the inbound S3-compatible endpoint at /storage/v1/s3"),
|
|
21917
|
+
s3_endpoint_access_key_id: optional(String2(), "[start] Access key id for the inbound S3 endpoint"),
|
|
21918
|
+
s3_endpoint_region: optional(String2(), "[start] SigV4 region for the inbound S3 endpoint"),
|
|
21919
|
+
s3_endpoint_buckets: optional(String2(), "[start] Comma-separated bucket allowlist for the inbound S3 endpoint"),
|
|
21819
21920
|
engine: optional(stringEnum2(["pglite", "native"]), "[*] Database engine"),
|
|
21820
21921
|
host: optional(String2(), "[start] Listen host"),
|
|
21821
21922
|
port: optional(Number2(), "[start] Listen port"),
|
|
@@ -22120,6 +22221,7 @@ import {
|
|
|
22120
22221
|
createExecutionContextPack,
|
|
22121
22222
|
createDiagnosticRepairPlan,
|
|
22122
22223
|
doctorProject,
|
|
22224
|
+
formatDoctorCheck,
|
|
22123
22225
|
loadSupacloudConfig,
|
|
22124
22226
|
formatDeliveryPlan,
|
|
22125
22227
|
planDeliveryProject,
|
|
@@ -22253,7 +22355,7 @@ var starter_metadata_default = {
|
|
|
22253
22355
|
generatedBy: "supacloud/starter-metadata-v1",
|
|
22254
22356
|
packages: {
|
|
22255
22357
|
compiler: {
|
|
22256
|
-
version: "0.62.
|
|
22358
|
+
version: "0.62.2"
|
|
22257
22359
|
},
|
|
22258
22360
|
app: {
|
|
22259
22361
|
version: "0.39.1",
|
|
@@ -22262,7 +22364,7 @@ var starter_metadata_default = {
|
|
|
22262
22364
|
}
|
|
22263
22365
|
},
|
|
22264
22366
|
elysia: {
|
|
22265
|
-
version: "0.42.
|
|
22367
|
+
version: "0.42.2"
|
|
22266
22368
|
},
|
|
22267
22369
|
commands: {
|
|
22268
22370
|
version: "0.12.0"
|
|
@@ -22271,11 +22373,22 @@ var starter_metadata_default = {
|
|
|
22271
22373
|
version: "0.16.1"
|
|
22272
22374
|
},
|
|
22273
22375
|
db: {
|
|
22274
|
-
version: "0.24.
|
|
22376
|
+
version: "0.24.2",
|
|
22377
|
+
dependencies: {},
|
|
22378
|
+
devDependencies: {},
|
|
22379
|
+
peerDependencies: {
|
|
22380
|
+
"@supacloud/db-zenstack": "^0.1.0 || ^0.2.0"
|
|
22381
|
+
}
|
|
22382
|
+
},
|
|
22383
|
+
dbZenstack: {
|
|
22384
|
+
version: "0.2.1",
|
|
22275
22385
|
dependencies: {
|
|
22276
22386
|
"@zenstackhq/orm": "3.10.0",
|
|
22277
22387
|
"@zenstackhq/schema": "3.10.0",
|
|
22278
|
-
"@zenstackhq/plugin-policy": "3.10.0"
|
|
22388
|
+
"@zenstackhq/plugin-policy": "3.10.0",
|
|
22389
|
+
"@zenstackhq/language": "3.10.0",
|
|
22390
|
+
"@zenstackhq/sdk": "3.10.0",
|
|
22391
|
+
kysely: "0.29.0"
|
|
22279
22392
|
},
|
|
22280
22393
|
devDependencies: {
|
|
22281
22394
|
"@zenstackhq/cli": "3.10.0",
|
|
@@ -22528,6 +22641,27 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
|
|
|
22528
22641
|
|
|
22529
22642
|
// src/shared/tools/app-starter-templates.ts
|
|
22530
22643
|
var { compiler: compilerMetadata, app: appMetadata, elysia: elysiaMetadata } = starter_metadata_default.packages;
|
|
22644
|
+
var STARTER_TEMPLATES = ["minimal", "client", "command", "model-command"];
|
|
22645
|
+
var DEFAULT_STARTER_TEMPLATE = "minimal";
|
|
22646
|
+
var STARTER_TEMPLATE_ALIASES = {
|
|
22647
|
+
app: "minimal"
|
|
22648
|
+
};
|
|
22649
|
+
function isStarterTemplate(value) {
|
|
22650
|
+
return STARTER_TEMPLATES.includes(value);
|
|
22651
|
+
}
|
|
22652
|
+
function resolveStarterTemplate(input) {
|
|
22653
|
+
if (input === undefined)
|
|
22654
|
+
return DEFAULT_STARTER_TEMPLATE;
|
|
22655
|
+
if (isStarterTemplate(input))
|
|
22656
|
+
return input;
|
|
22657
|
+
if (Object.hasOwn(STARTER_TEMPLATE_ALIASES, input)) {
|
|
22658
|
+
return STARTER_TEMPLATE_ALIASES[input];
|
|
22659
|
+
}
|
|
22660
|
+
throw new Error(`Unknown app init template: ${input}. Use ${STARTER_TEMPLATES.join(", ")}` + " (`app` is accepted as an alias of `minimal`).");
|
|
22661
|
+
}
|
|
22662
|
+
function assertNeverTemplate(value) {
|
|
22663
|
+
throw new Error(`Unhandled starter template: ${String(value)}`);
|
|
22664
|
+
}
|
|
22531
22665
|
var json = (value) => `${JSON.stringify(value, null, 2)}
|
|
22532
22666
|
`;
|
|
22533
22667
|
var DEV_SCRIPT = `import { watchProject, compileOptionsFromConfig, loadSupacloudConfig } from "@supacloud/compiler";
|
|
@@ -22575,27 +22709,88 @@ const server = Bun.serve({
|
|
|
22575
22709
|
console.log("Local demo: " + server.url);
|
|
22576
22710
|
`;
|
|
22577
22711
|
var APPLICATION_SOURCE = (name) => `import { createApplication } from "@supacloud/elysia";
|
|
22578
|
-
import {
|
|
22712
|
+
import {
|
|
22713
|
+
createSupAuthRequestContext,
|
|
22714
|
+
type SupAuthContextOptions,
|
|
22715
|
+
type CommandGovernance,
|
|
22716
|
+
type ExecutionObserver,
|
|
22717
|
+
} from "@supacloud/elysia";
|
|
22579
22718
|
import { createCompiledModules } from "../generated/application";
|
|
22580
22719
|
|
|
22720
|
+
/** Trusted-host adapters. Keep these explicit so indexed ApplicationOptions access cannot widen to any. */
|
|
22581
22721
|
export interface AppAdapters {
|
|
22582
|
-
deps:
|
|
22583
|
-
requestContext:
|
|
22722
|
+
deps: Record<string, unknown>;
|
|
22723
|
+
requestContext: (
|
|
22724
|
+
request: Request,
|
|
22725
|
+
context: unknown,
|
|
22726
|
+
signal?: AbortSignal,
|
|
22727
|
+
) => unknown | Promise<unknown>;
|
|
22584
22728
|
commandGovernance: CommandGovernance;
|
|
22585
|
-
onExecution?:
|
|
22729
|
+
onExecution?: ExecutionObserver;
|
|
22730
|
+
}
|
|
22731
|
+
|
|
22732
|
+
export interface CreatedApplication {
|
|
22733
|
+
fetch: (request: Request) => Promise<Response>;
|
|
22734
|
+
handle: (request: Request) => Promise<Response>;
|
|
22735
|
+
initialize: () => Promise<void>;
|
|
22736
|
+
destroy: () => Promise<void>;
|
|
22737
|
+
}
|
|
22738
|
+
|
|
22739
|
+
function isRecord(value: unknown): value is { readonly [key: string]: unknown } {
|
|
22740
|
+
return typeof value === "object" && value !== null;
|
|
22741
|
+
}
|
|
22742
|
+
|
|
22743
|
+
function isApplicationHost(value: unknown): value is {
|
|
22744
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
22745
|
+
handle: (request: Request) => Response | Promise<Response>;
|
|
22746
|
+
initialize: () => void | Promise<void>;
|
|
22747
|
+
destroy: () => void | Promise<void>;
|
|
22748
|
+
} {
|
|
22749
|
+
return isRecord(value)
|
|
22750
|
+
&& typeof value["fetch"] === "function"
|
|
22751
|
+
&& typeof value["handle"] === "function"
|
|
22752
|
+
&& typeof value["initialize"] === "function"
|
|
22753
|
+
&& typeof value["destroy"] === "function";
|
|
22754
|
+
}
|
|
22755
|
+
|
|
22756
|
+
function isRequestContextFactory(value: unknown): value is AppAdapters["requestContext"] {
|
|
22757
|
+
return typeof value === "function";
|
|
22758
|
+
}
|
|
22759
|
+
|
|
22760
|
+
export function readCreatedApplication(value: unknown): CreatedApplication {
|
|
22761
|
+
if (!isApplicationHost(value)) {
|
|
22762
|
+
throw new Error("createApplication returned an invalid application host");
|
|
22763
|
+
}
|
|
22764
|
+
return {
|
|
22765
|
+
fetch: async (request) => await value.fetch(request),
|
|
22766
|
+
handle: async (request) => await value.handle(request),
|
|
22767
|
+
initialize: async () => { await value.initialize(); },
|
|
22768
|
+
destroy: async () => { await value.destroy(); },
|
|
22769
|
+
};
|
|
22586
22770
|
}
|
|
22587
22771
|
|
|
22588
22772
|
// The host verifies external identity (SupAuth for unified login) before creating requestContext.
|
|
22589
|
-
export function createApp(adapters: AppAdapters) {
|
|
22590
|
-
|
|
22591
|
-
|
|
22773
|
+
export function createApp(adapters: AppAdapters): CreatedApplication {
|
|
22774
|
+
const application: unknown = createApplication({
|
|
22775
|
+
deps: adapters.deps,
|
|
22776
|
+
requestContext: adapters.requestContext,
|
|
22777
|
+
commandGovernance: adapters.commandGovernance,
|
|
22592
22778
|
name: ${JSON.stringify(name)},
|
|
22593
22779
|
modules: createCompiledModules(),
|
|
22780
|
+
...(adapters.onExecution === undefined ? {} : { onExecution: adapters.onExecution }),
|
|
22594
22781
|
});
|
|
22782
|
+
return readCreatedApplication(application);
|
|
22595
22783
|
}
|
|
22596
22784
|
|
|
22597
|
-
export function createSupAuthApp(
|
|
22598
|
-
|
|
22785
|
+
export function createSupAuthApp(
|
|
22786
|
+
identity: SupAuthContextOptions,
|
|
22787
|
+
adapters: Omit<AppAdapters, "requestContext">,
|
|
22788
|
+
): CreatedApplication {
|
|
22789
|
+
const resolved: unknown = createSupAuthRequestContext(identity);
|
|
22790
|
+
if (!isRequestContextFactory(resolved)) {
|
|
22791
|
+
throw new Error("createSupAuthRequestContext must return a requestContext function");
|
|
22792
|
+
}
|
|
22793
|
+
return createApp({ ...adapters, requestContext: resolved });
|
|
22599
22794
|
}
|
|
22600
22795
|
`;
|
|
22601
22796
|
var GENERATED_BOOTSTRAP = `// BOOTSTRAP ARTIFACT: bun run compile replaces this file.
|
|
@@ -22686,7 +22881,128 @@ export default defineSupacloudConfig();
|
|
|
22686
22881
|
"scripts/serve.ts": SERVE_SCRIPT
|
|
22687
22882
|
};
|
|
22688
22883
|
}
|
|
22689
|
-
|
|
22884
|
+
var DATA_CLIENT = `import { createClient, type SupabaseClient } from "@supabase/supabase-js";
|
|
22885
|
+
|
|
22886
|
+
/** Official data-plane client. Provisioned projects are reached with this client. */
|
|
22887
|
+
export function createDataClient(input: { url: string; anonKey: string }): SupabaseClient {
|
|
22888
|
+
const url = new URL(input.url);
|
|
22889
|
+
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost";
|
|
22890
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
|
|
22891
|
+
throw new Error("Use the project HTTPS API URL, or loopback HTTP for local development");
|
|
22892
|
+
}
|
|
22893
|
+
if (input.anonKey.trim().length < 8 || input.anonKey !== input.anonKey.trim()) {
|
|
22894
|
+
throw new Error("Use the anon or publishable key");
|
|
22895
|
+
}
|
|
22896
|
+
return createClient(url.toString(), input.anonKey, {
|
|
22897
|
+
auth: { persistSession: false, autoRefreshToken: false },
|
|
22898
|
+
});
|
|
22899
|
+
}
|
|
22900
|
+
`;
|
|
22901
|
+
var DATA_CLIENT_TEST = `import { expect, test } from "bun:test";
|
|
22902
|
+
import { createDataClient } from "../src/client";
|
|
22903
|
+
|
|
22904
|
+
test("the data client is the official supabase-js client", () => {
|
|
22905
|
+
const client = createDataClient({ url: "http://127.0.0.1:54321", anonKey: "public-anon-key" });
|
|
22906
|
+
expect(typeof client.from).toBe("function");
|
|
22907
|
+
expect(typeof client.channel).toBe("function");
|
|
22908
|
+
});
|
|
22909
|
+
|
|
22910
|
+
test("non-local http URLs are rejected", () => {
|
|
22911
|
+
expect(() => createDataClient({ url: "http://example.com", anonKey: "public-anon-key" })).toThrow("HTTPS");
|
|
22912
|
+
});
|
|
22913
|
+
`;
|
|
22914
|
+
function supabaseClientTemplate(name, sdkDependencies) {
|
|
22915
|
+
return {
|
|
22916
|
+
"package.json": json({
|
|
22917
|
+
name,
|
|
22918
|
+
version: "0.0.0",
|
|
22919
|
+
private: true,
|
|
22920
|
+
type: "module",
|
|
22921
|
+
engines: { bun: ">=1.4.4" },
|
|
22922
|
+
scripts: {
|
|
22923
|
+
typecheck: "tsc --noEmit",
|
|
22924
|
+
test: "bun test",
|
|
22925
|
+
check: "bun run typecheck && bun run test"
|
|
22926
|
+
},
|
|
22927
|
+
dependencies: {
|
|
22928
|
+
"@supabase/supabase-js": sdkDependencies["@supabase/supabase-js"]
|
|
22929
|
+
},
|
|
22930
|
+
devDependencies: {
|
|
22931
|
+
"@types/bun": "^1.4.4",
|
|
22932
|
+
typescript: "7.1.0-beta"
|
|
22933
|
+
}
|
|
22934
|
+
}),
|
|
22935
|
+
"tsconfig.json": json({
|
|
22936
|
+
compilerOptions: {
|
|
22937
|
+
target: "ES2022",
|
|
22938
|
+
module: "ESNext",
|
|
22939
|
+
moduleResolution: "bundler",
|
|
22940
|
+
strict: true,
|
|
22941
|
+
skipLibCheck: true,
|
|
22942
|
+
noUncheckedIndexedAccess: true,
|
|
22943
|
+
exactOptionalPropertyTypes: true,
|
|
22944
|
+
noImplicitOverride: true,
|
|
22945
|
+
noPropertyAccessFromIndexSignature: true,
|
|
22946
|
+
noFallthroughCasesInSwitch: true,
|
|
22947
|
+
forceConsistentCasingInFileNames: true,
|
|
22948
|
+
useUnknownInCatchVariables: true,
|
|
22949
|
+
noEmit: true,
|
|
22950
|
+
types: ["bun"]
|
|
22951
|
+
},
|
|
22952
|
+
include: ["src/**/*.ts", "tests/**/*.ts"]
|
|
22953
|
+
}),
|
|
22954
|
+
"bunfig.toml": `env = false
|
|
22955
|
+
`,
|
|
22956
|
+
".gitignore": ["node_modules/", ".env", ".env.*", "!.env.example", ""].join(`
|
|
22957
|
+
`),
|
|
22958
|
+
".env.example": `SUPABASE_URL=http://127.0.0.1:54321
|
|
22959
|
+
SUPABASE_ANON_KEY=replace-with-anon-or-publishable-key
|
|
22960
|
+
`,
|
|
22961
|
+
"src/client.ts": DATA_CLIENT,
|
|
22962
|
+
"tests/client.test.ts": DATA_CLIENT_TEST,
|
|
22963
|
+
"AGENTS.md": `# ${name}
|
|
22964
|
+
|
|
22965
|
+
This project talks to a provisioned Supabase-compatible API with
|
|
22966
|
+
\`@supabase/supabase-js\`. It is the explicit \`--template client\` scaffold.
|
|
22967
|
+
|
|
22968
|
+
- Do not add \`@supacloud/app\`, \`@supacloud/compiler\`, \`@supacloud/elysia\`, or \`effect\` here.
|
|
22969
|
+
- The forced default application stack is \`supacloud app init\` (\`minimal\`).
|
|
22970
|
+
- Durable SQL and model recipes are \`--template command\` and \`--template model-command\`.
|
|
22971
|
+
- Use the anon or publishable key. Never put a service-role or Management token in this client.
|
|
22972
|
+
- Management API provision does not compile this project and does not interpret Effect.
|
|
22973
|
+
`,
|
|
22974
|
+
"README.md": `# ${name}
|
|
22975
|
+
|
|
22976
|
+
Explicit data-plane client (\`supacloud app init --template client\`) for a
|
|
22977
|
+
provisioned project. This scaffold depends on \`@supabase/supabase-js\` only. It
|
|
22978
|
+
does not install \`@supacloud/app\`, the compiler, Elysia, or Effect.
|
|
22979
|
+
|
|
22980
|
+
## Local check
|
|
22981
|
+
|
|
22982
|
+
\`\`\`sh
|
|
22983
|
+
bun install
|
|
22984
|
+
bun test tests/client.test.ts
|
|
22985
|
+
bun run check
|
|
22986
|
+
\`\`\`
|
|
22987
|
+
|
|
22988
|
+
Copy \`.env.example\` and set \`SUPABASE_URL\` to the project API URL and
|
|
22989
|
+
\`SUPABASE_ANON_KEY\` to the anon or publishable key. Do not commit the filled
|
|
22990
|
+
file, and do not put the service-role key in this client.
|
|
22991
|
+
|
|
22992
|
+
\`createDataClient\` accepts HTTPS, or HTTP only for \`127.0.0.1\` and \`localhost\`.
|
|
22993
|
+
Realtime uses the same client's \`channel()\` against the project's
|
|
22994
|
+
\`/realtime/v1/websocket\` endpoint. See the platform Realtime contract for which
|
|
22995
|
+
process owns that socket.
|
|
22996
|
+
|
|
22997
|
+
## Default application stack
|
|
22998
|
+
|
|
22999
|
+
\`supacloud app init\` (template \`minimal\`) is the forced compiler + Effect
|
|
23000
|
+
project. \`--template command\` and \`--template model-command\` are the durable
|
|
23001
|
+
reference recipes. Do not add those dependencies to this client project.
|
|
23002
|
+
`
|
|
23003
|
+
};
|
|
23004
|
+
}
|
|
23005
|
+
function appFrameworkTemplate(name, sdkDependencies) {
|
|
22690
23006
|
return {
|
|
22691
23007
|
...baseTemplateFiles(name, sdkDependencies),
|
|
22692
23008
|
"src/features/health/contracts.ts": `import { t } from "elysia";
|
|
@@ -22750,6 +23066,11 @@ export function createDemo() {
|
|
|
22750
23066
|
`,
|
|
22751
23067
|
"README.md": `# ${name}
|
|
22752
23068
|
|
|
23069
|
+
Default application stack from \`supacloud app init\` (template \`minimal\`).
|
|
23070
|
+
It installs \`@supacloud/app\`, the compiler, Elysia, and Effect. The data-plane
|
|
23071
|
+
client remains \`@supabase/supabase-js\` inside this project. Use
|
|
23072
|
+
\`--template client\` only when you need a client-only directory.
|
|
23073
|
+
|
|
22753
23074
|
## Local development
|
|
22754
23075
|
|
|
22755
23076
|
\`\`\`sh
|
|
@@ -22797,9 +23118,14 @@ regeneration, then validate types, database permissions and authenticated behavi
|
|
|
22797
23118
|
};
|
|
22798
23119
|
}
|
|
22799
23120
|
function appTemplateFiles(name, template, sdkDependencies) {
|
|
22800
|
-
|
|
22801
|
-
|
|
22802
|
-
|
|
23121
|
+
switch (template) {
|
|
23122
|
+
case "client":
|
|
23123
|
+
return supabaseClientTemplate(name, sdkDependencies);
|
|
23124
|
+
case "minimal":
|
|
23125
|
+
return appFrameworkTemplate(name, sdkDependencies);
|
|
23126
|
+
default:
|
|
23127
|
+
return assertNeverTemplate(template);
|
|
23128
|
+
}
|
|
22803
23129
|
}
|
|
22804
23130
|
|
|
22805
23131
|
// src/shared/tools/command-receipts.ts
|
|
@@ -22963,13 +23289,41 @@ var COMMANDS = `import { Command, defineOperationAspect, type Aspect } from "@su
|
|
|
22963
23289
|
import { createTypeBoxTransactionalCommand } from "@supacloud/commands/typebox";
|
|
22964
23290
|
import { plaintextCommandInput } from "@supacloud/commands";
|
|
22965
23291
|
import { CommandError, type CommandIdentity, type CommandStore } from "@supacloud/contracts";
|
|
22966
|
-
import type {
|
|
22967
|
-
import type { schema } from "../../../zenstack/generated/schema";
|
|
23292
|
+
import type { CallFunctionOptions, JsonArgument, ReadFunctionArg, ReadFunctionRow } from "@supacloud/db/model-contract";
|
|
22968
23293
|
import { Type } from "typebox";
|
|
22969
23294
|
import { CreateInput, ApproveInput, Decision, decodeApprove, decodeDecision, decodeOrder, decoder, type Principal } from "./contracts";
|
|
22970
23295
|
|
|
22971
|
-
type
|
|
22972
|
-
type
|
|
23296
|
+
type OrderRow = { readonly id: string; readonly title: string; readonly state: string; readonly version: number };
|
|
23297
|
+
type OrderDb = {
|
|
23298
|
+
readonly order: {
|
|
23299
|
+
createMany(args: { readonly data: readonly Record<string, unknown>[]; readonly skipDuplicates?: boolean }): Promise<{ readonly count: number }>;
|
|
23300
|
+
findUniqueOrThrow(args: { readonly where: { readonly tenantId_id: { readonly tenantId: string; readonly id: string } }; readonly select: Record<keyof OrderRow, true> }): Promise<OrderRow>;
|
|
23301
|
+
updateMany(args: { readonly where: Record<string, unknown>; readonly data: Record<string, unknown> }): Promise<{ readonly count: number }>;
|
|
23302
|
+
};
|
|
23303
|
+
};
|
|
23304
|
+
type Tx = {
|
|
23305
|
+
readonly db: OrderDb;
|
|
23306
|
+
readonly lock: (keys: readonly string[]) => Promise<void>;
|
|
23307
|
+
readonly readFunction: (name: string, args?: readonly ReadFunctionArg[]) => Promise<unknown>;
|
|
23308
|
+
readonly readFunctionByRow: (name: string, row: ReadFunctionRow) => Promise<unknown>;
|
|
23309
|
+
readonly callFunction: (name: string, args?: readonly JsonArgument[], options?: CallFunctionOptions) => Promise<unknown>;
|
|
23310
|
+
};
|
|
23311
|
+
type Store = CommandStore<unknown>;
|
|
23312
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
23313
|
+
return value !== null && typeof value === "object";
|
|
23314
|
+
}
|
|
23315
|
+
function isTx(value: unknown): value is Tx {
|
|
23316
|
+
const root = isRecord(value) ? value : undefined;
|
|
23317
|
+
const db = root && isRecord(root["db"]) ? root["db"] : undefined;
|
|
23318
|
+
const order = db && isRecord(db["order"]) ? db["order"] : undefined;
|
|
23319
|
+
const methods = ["lock", "readFunction", "readFunctionByRow", "callFunction"];
|
|
23320
|
+
return !!root && !!db && !!order && methods.every(name => typeof root[name] === "function")
|
|
23321
|
+
&& ["createMany", "findUniqueOrThrow", "updateMany"].every(name => typeof order[name] === "function");
|
|
23322
|
+
}
|
|
23323
|
+
function decodeTx(value: unknown): Tx {
|
|
23324
|
+
if (!isTx(value)) throw new TypeError("Invalid model command transaction");
|
|
23325
|
+
return value;
|
|
23326
|
+
}
|
|
22973
23327
|
const decodeCapabilities = decoder(Type.Object({ canApprove: Type.Boolean() }, { additionalProperties: false }));
|
|
22974
23328
|
export const approvalAspect = defineOperationAspect({
|
|
22975
23329
|
kind: "command", name: "orders.approve", input: decodeApprove, result: decodeDecision,
|
|
@@ -22993,10 +23347,11 @@ export class CreateOrder {
|
|
|
22993
23347
|
inputCodec: plaintextCommandInput,
|
|
22994
23348
|
authorize: identity => sameActor(identity, principal) && principal.canCreate ? "allow" : "deny",
|
|
22995
23349
|
audit: { event: "orders.create.decided", details: (input, result) => ({ id: input.id, outcome: result.outcome }) },
|
|
22996
|
-
execute: async (
|
|
22997
|
-
const
|
|
23350
|
+
execute: async (rawTx, input): Promise<Decision> => {
|
|
23351
|
+
const tx = decodeTx(rawTx);
|
|
23352
|
+
const created: { count: number } = await tx.db.order.createMany({ data: [{ ...input, tenantId: principal.tenantId, ownerId: principal.id, state: "draft", version: 1 }], skipDuplicates: true });
|
|
22998
23353
|
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 } });
|
|
23354
|
+
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
23355
|
return { outcome: "applied", order: decodeOrder(row) };
|
|
23001
23356
|
},
|
|
23002
23357
|
});
|
|
@@ -23014,18 +23369,21 @@ export class ApproveOrder {
|
|
|
23014
23369
|
name: "orders.approve", store, schemas: { input: ApproveInput, result: Decision }, inputCodec: plaintextCommandInput,
|
|
23015
23370
|
authorize: identity => sameActor(identity, principal) && principal.canApprove ? "allow" : "deny",
|
|
23016
23371
|
audit: { event: "orders.approval.decided", details: (input, result) => ({ id: input.id, outcome: result.outcome }) },
|
|
23017
|
-
execute: async (
|
|
23372
|
+
execute: async (rawTx, input) => {
|
|
23373
|
+
const tx = decodeTx(rawTx);
|
|
23374
|
+
return decodeDecision(await pipeline({
|
|
23018
23375
|
kind: "command", name: "orders.approve", input,
|
|
23019
23376
|
services: { approval: { canApprove: principal.canApprove } },
|
|
23020
23377
|
}, async (): Promise<Decision> => {
|
|
23021
|
-
const changed = await tx.db.order.updateMany({
|
|
23378
|
+
const changed: { count: number } = await tx.db.order.updateMany({
|
|
23022
23379
|
where: { tenantId: principal.tenantId, id: input.id, state: "draft", version: input.expectedVersion },
|
|
23023
23380
|
data: { state: "approved", version: { increment: 1 } },
|
|
23024
23381
|
});
|
|
23025
23382
|
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 } });
|
|
23383
|
+
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
23384
|
return { outcome: "applied", order: decodeOrder(row) };
|
|
23028
|
-
}))
|
|
23385
|
+
}));
|
|
23386
|
+
},
|
|
23029
23387
|
});
|
|
23030
23388
|
}
|
|
23031
23389
|
execute(identity: CommandIdentity, key: string, input: ApproveInput, signal?: AbortSignal) {
|
|
@@ -23070,7 +23428,7 @@ export class OrdersModule {}
|
|
|
23070
23428
|
var HOST = `import type { SQL } from "bun";
|
|
23071
23429
|
import { createApplication, ApplicationError, type CompiledModule } from "@supacloud/elysia";
|
|
23072
23430
|
import { createZenStackDatabase } from "@supacloud/db/zenstack";
|
|
23073
|
-
import { CommandError } from "@supacloud/contracts";
|
|
23431
|
+
import { CommandError, type CommandStore } from "@supacloud/contracts";
|
|
23074
23432
|
import { schema } from "../../zenstack/generated/schema";
|
|
23075
23433
|
import { createCompiledModules } from "../../generated/application";
|
|
23076
23434
|
import { CreateOrder, ApproveOrder } from "../features/orders/commands";
|
|
@@ -23086,6 +23444,34 @@ export interface IdentityAuthority {
|
|
|
23086
23444
|
resolve(actor: ActorBinding): Promise<Principal | null>;
|
|
23087
23445
|
}
|
|
23088
23446
|
|
|
23447
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
23448
|
+
return value !== null && typeof value === "object";
|
|
23449
|
+
}
|
|
23450
|
+
function isCommandStore(value: unknown): value is CommandStore<unknown> {
|
|
23451
|
+
return isRecord(value) && typeof value["transaction"] === "function";
|
|
23452
|
+
}
|
|
23453
|
+
function requireCommandStore(value: unknown): CommandStore<unknown> {
|
|
23454
|
+
if (!isCommandStore(value)) throw new CommandError("COMMAND_UNAVAILABLE");
|
|
23455
|
+
return value;
|
|
23456
|
+
}
|
|
23457
|
+
interface ScopedDatabase {
|
|
23458
|
+
readonly commandStore: unknown;
|
|
23459
|
+
readonly models: { readonly order: { findUnique(args: unknown): Promise<unknown> } };
|
|
23460
|
+
}
|
|
23461
|
+
interface DatabaseFacade {
|
|
23462
|
+
forIdentity(identity: Principal): ScopedDatabase;
|
|
23463
|
+
dispose(): Promise<void>;
|
|
23464
|
+
}
|
|
23465
|
+
function isDatabaseFacade(value: unknown): value is DatabaseFacade {
|
|
23466
|
+
if (!isRecord(value) || typeof value["forIdentity"] !== "function" || typeof value["dispose"] !== "function") return false;
|
|
23467
|
+
const scoped = value["forIdentity"];
|
|
23468
|
+
return typeof scoped === "function";
|
|
23469
|
+
}
|
|
23470
|
+
function requireDatabase(value: unknown): DatabaseFacade {
|
|
23471
|
+
if (!isDatabaseFacade(value)) throw new CommandError("COMMAND_UNAVAILABLE");
|
|
23472
|
+
return value;
|
|
23473
|
+
}
|
|
23474
|
+
|
|
23089
23475
|
export async function createModelOrderHost(pool: SQL, authority: IdentityAuthority) {
|
|
23090
23476
|
const roles = await pool<unknown[]>\`SELECT rolsuper, rolbypassrls, pg_has_role(current_user, 'model_orders_app', 'USAGE') AS allowed,
|
|
23091
23477
|
EXISTS (SELECT FROM pg_class WHERE oid IN ('public.model_orders'::regclass, 'supacloud_commands.execution_receipts'::regclass, 'supacloud_commands.execution_audit'::regclass)
|
|
@@ -23097,7 +23483,7 @@ export async function createModelOrderHost(pool: SQL, authority: IdentityAuthori
|
|
|
23097
23483
|
|| !("owns_data" in role) || role.owns_data !== false) {
|
|
23098
23484
|
throw new Error("Use a non-owner application login with model_orders_app membership");
|
|
23099
23485
|
}
|
|
23100
|
-
const database = createZenStackDatabase(schema, pool, {});
|
|
23486
|
+
const database = requireDatabase(createZenStackDatabase(schema, pool, {}));
|
|
23101
23487
|
const modules: CompiledModule[] = createCompiledModules();
|
|
23102
23488
|
const ordersModule = modules.find(module => module.name === "orders");
|
|
23103
23489
|
const approval = ordersModule?.commands?.find(command => command.name === "orders.approve")?.aspectPipeline;
|
|
@@ -23123,11 +23509,11 @@ export async function createModelOrderHost(pool: SQL, authority: IdentityAuthori
|
|
|
23123
23509
|
const port: OrderPort = {
|
|
23124
23510
|
create: async (context, key, input) => {
|
|
23125
23511
|
const bound = await bind(context);
|
|
23126
|
-
return decodeReceipt(await new CreateOrder(bound.scoped.commandStore, bound.principal).execute(bound.identity, key, decodeCreate(input), bound.signal));
|
|
23512
|
+
return decodeReceipt(await new CreateOrder(requireCommandStore(bound.scoped.commandStore), bound.principal).execute(bound.identity, key, decodeCreate(input), bound.signal));
|
|
23127
23513
|
},
|
|
23128
23514
|
approve: async (context, key, input) => {
|
|
23129
23515
|
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));
|
|
23516
|
+
return decodeReceipt(await new ApproveOrder(requireCommandStore(bound.scoped.commandStore), bound.principal, approval).execute(bound.identity, key, decodeApprove(input), bound.signal));
|
|
23131
23517
|
},
|
|
23132
23518
|
read: async (context, id) => {
|
|
23133
23519
|
const bound = await bind(context);
|
|
@@ -23173,7 +23559,7 @@ GRANT SELECT, INSERT, UPDATE ON supacloud_commands.execution_receipts TO model_o
|
|
|
23173
23559
|
GRANT SELECT, INSERT ON supacloud_commands.execution_audit TO model_orders_app;
|
|
23174
23560
|
`;
|
|
23175
23561
|
function modelCommandTemplateFiles(name, sdk) {
|
|
23176
|
-
const { app, compiler, elysia, commands, contracts, db } = starter_metadata_default.packages;
|
|
23562
|
+
const { app, compiler, elysia, commands, contracts, db, dbZenstack } = starter_metadata_default.packages;
|
|
23177
23563
|
const files = baseTemplateFiles(name, sdk);
|
|
23178
23564
|
delete files["scripts/dev.ts"];
|
|
23179
23565
|
delete files["scripts/serve.ts"];
|
|
@@ -23212,13 +23598,15 @@ function modelCommandTemplateFiles(name, sdk) {
|
|
|
23212
23598
|
"@supacloud/commands": "^" + commands.version,
|
|
23213
23599
|
"@supacloud/contracts": "^" + contracts.version,
|
|
23214
23600
|
"@supacloud/db": "^" + db.version,
|
|
23601
|
+
"@supacloud/db-zenstack": "^" + dbZenstack.version,
|
|
23215
23602
|
...db.dependencies,
|
|
23603
|
+
...dbZenstack.dependencies,
|
|
23216
23604
|
typebox: "1.4.3",
|
|
23217
23605
|
effect: "4.0.5",
|
|
23218
23606
|
elysia: "2.0.0-rc.1",
|
|
23219
23607
|
...sdk
|
|
23220
23608
|
},
|
|
23221
|
-
devDependencies: { "@supacloud/compiler": "^" + compiler.version, ...db.devDependencies, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
|
|
23609
|
+
devDependencies: { "@supacloud/compiler": "^" + compiler.version, ...db.devDependencies, ...dbZenstack.devDependencies, "@types/bun": "^1.4.4", typescript: "7.1.0-beta" }
|
|
23222
23610
|
}),
|
|
23223
23611
|
"supacloud.config.ts": `import { defineSupacloudConfig } from "@supacloud/compiler";
|
|
23224
23612
|
export default defineSupacloudConfig({
|
|
@@ -25928,7 +26316,7 @@ export async function createReviewTaskAdapters(options: ReviewTaskOptions): Prom
|
|
|
25928
26316
|
`;
|
|
25929
26317
|
|
|
25930
26318
|
// 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;
|
|
26319
|
+
var { compiler: compilerMetadata2, app: appMetadata2, elysia: elysiaMetadata2, commands: commandsMetadata, contracts: contractsMetadata, db: dbMetadata, dbZenstack: dbZenstackMetadata, sdk: sdkMetadata } = starter_metadata_default.packages;
|
|
25932
26320
|
var json3 = (value) => `${JSON.stringify(value, null, 2)}
|
|
25933
26321
|
`;
|
|
25934
26322
|
function appStarterFiles(name) {
|
|
@@ -25970,7 +26358,9 @@ function appStarterFiles(name) {
|
|
|
25970
26358
|
"@supacloud/commands": `^${commandsMetadata.version}`,
|
|
25971
26359
|
"@supacloud/contracts": `^${contractsMetadata.version}`,
|
|
25972
26360
|
"@supacloud/db": `^${dbMetadata.version}`,
|
|
26361
|
+
"@supacloud/db-zenstack": `^${dbZenstackMetadata.version}`,
|
|
25973
26362
|
...dbMetadata.dependencies,
|
|
26363
|
+
...dbZenstackMetadata.dependencies,
|
|
25974
26364
|
"@supacloud/js": `^${sdkMetadata.version}`,
|
|
25975
26365
|
"@supabase/supabase-js": sdkMetadata.peerDependencies["@supabase/supabase-js"],
|
|
25976
26366
|
effect: "4.0.5",
|
|
@@ -25980,6 +26370,7 @@ function appStarterFiles(name) {
|
|
|
25980
26370
|
devDependencies: {
|
|
25981
26371
|
"@supacloud/compiler": `^${compilerMetadata2.version}`,
|
|
25982
26372
|
...dbMetadata.devDependencies,
|
|
26373
|
+
...dbZenstackMetadata.devDependencies,
|
|
25983
26374
|
"@types/bun": "^1.4.4",
|
|
25984
26375
|
typescript: "7.1.0-beta"
|
|
25985
26376
|
}
|
|
@@ -26177,27 +26568,88 @@ export function createDemo() {
|
|
|
26177
26568
|
}
|
|
26178
26569
|
`,
|
|
26179
26570
|
"src/application.ts": `import { createApplication } from "@supacloud/elysia";
|
|
26180
|
-
import {
|
|
26571
|
+
import {
|
|
26572
|
+
createSupAuthRequestContext,
|
|
26573
|
+
type SupAuthContextOptions,
|
|
26574
|
+
type CommandGovernance,
|
|
26575
|
+
type ExecutionObserver,
|
|
26576
|
+
} from "@supacloud/elysia";
|
|
26181
26577
|
import { createCompiledModules } from "../generated/application";
|
|
26182
26578
|
|
|
26579
|
+
/** Trusted-host adapters. Keep these explicit so indexed ApplicationOptions access cannot widen to any. */
|
|
26183
26580
|
export interface AppAdapters {
|
|
26184
|
-
deps:
|
|
26185
|
-
requestContext:
|
|
26581
|
+
deps: Record<string, unknown>;
|
|
26582
|
+
requestContext: (
|
|
26583
|
+
request: Request,
|
|
26584
|
+
context: unknown,
|
|
26585
|
+
signal?: AbortSignal,
|
|
26586
|
+
) => unknown | Promise<unknown>;
|
|
26186
26587
|
commandGovernance: CommandGovernance;
|
|
26187
|
-
onExecution?:
|
|
26588
|
+
onExecution?: ExecutionObserver;
|
|
26589
|
+
}
|
|
26590
|
+
|
|
26591
|
+
export interface CreatedApplication {
|
|
26592
|
+
fetch: (request: Request) => Promise<Response>;
|
|
26593
|
+
handle: (request: Request) => Promise<Response>;
|
|
26594
|
+
initialize: () => Promise<void>;
|
|
26595
|
+
destroy: () => Promise<void>;
|
|
26596
|
+
}
|
|
26597
|
+
|
|
26598
|
+
function isRecord(value: unknown): value is { readonly [key: string]: unknown } {
|
|
26599
|
+
return typeof value === "object" && value !== null;
|
|
26600
|
+
}
|
|
26601
|
+
|
|
26602
|
+
function isApplicationHost(value: unknown): value is {
|
|
26603
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
26604
|
+
handle: (request: Request) => Response | Promise<Response>;
|
|
26605
|
+
initialize: () => void | Promise<void>;
|
|
26606
|
+
destroy: () => void | Promise<void>;
|
|
26607
|
+
} {
|
|
26608
|
+
return isRecord(value)
|
|
26609
|
+
&& typeof value["fetch"] === "function"
|
|
26610
|
+
&& typeof value["handle"] === "function"
|
|
26611
|
+
&& typeof value["initialize"] === "function"
|
|
26612
|
+
&& typeof value["destroy"] === "function";
|
|
26613
|
+
}
|
|
26614
|
+
|
|
26615
|
+
function isRequestContextFactory(value: unknown): value is AppAdapters["requestContext"] {
|
|
26616
|
+
return typeof value === "function";
|
|
26617
|
+
}
|
|
26618
|
+
|
|
26619
|
+
export function readCreatedApplication(value: unknown): CreatedApplication {
|
|
26620
|
+
if (!isApplicationHost(value)) {
|
|
26621
|
+
throw new Error("createApplication returned an invalid application host");
|
|
26622
|
+
}
|
|
26623
|
+
return {
|
|
26624
|
+
fetch: async (request) => await value.fetch(request),
|
|
26625
|
+
handle: async (request) => await value.handle(request),
|
|
26626
|
+
initialize: async () => { await value.initialize(); },
|
|
26627
|
+
destroy: async () => { await value.destroy(); },
|
|
26628
|
+
};
|
|
26188
26629
|
}
|
|
26189
26630
|
|
|
26190
26631
|
// The host verifies external identity (SupAuth for unified login) before creating requestContext.
|
|
26191
|
-
export function createApp(adapters: AppAdapters) {
|
|
26192
|
-
|
|
26193
|
-
|
|
26632
|
+
export function createApp(adapters: AppAdapters): CreatedApplication {
|
|
26633
|
+
const application: unknown = createApplication({
|
|
26634
|
+
deps: adapters.deps,
|
|
26635
|
+
requestContext: adapters.requestContext,
|
|
26636
|
+
commandGovernance: adapters.commandGovernance,
|
|
26194
26637
|
name: ${JSON.stringify(name)},
|
|
26195
26638
|
modules: createCompiledModules(),
|
|
26639
|
+
...(adapters.onExecution === undefined ? {} : { onExecution: adapters.onExecution }),
|
|
26196
26640
|
});
|
|
26641
|
+
return readCreatedApplication(application);
|
|
26197
26642
|
}
|
|
26198
26643
|
|
|
26199
|
-
export function createSupAuthApp(
|
|
26200
|
-
|
|
26644
|
+
export function createSupAuthApp(
|
|
26645
|
+
identity: SupAuthContextOptions,
|
|
26646
|
+
adapters: Omit<AppAdapters, "requestContext">,
|
|
26647
|
+
): CreatedApplication {
|
|
26648
|
+
const resolved: unknown = createSupAuthRequestContext(identity);
|
|
26649
|
+
if (!isRequestContextFactory(resolved)) {
|
|
26650
|
+
throw new Error("createSupAuthRequestContext must return a requestContext function");
|
|
26651
|
+
}
|
|
26652
|
+
return createApp({ ...adapters, requestContext: resolved });
|
|
26201
26653
|
}
|
|
26202
26654
|
`,
|
|
26203
26655
|
"generated/application.ts": `// BOOTSTRAP ARTIFACT: bun run compile replaces this file.
|
|
@@ -26543,7 +26995,10 @@ Management API tokens and service-role keys remain on trusted servers.
|
|
|
26543
26995
|
Ordinary reads use PostgREST through the existing user-scoped
|
|
26544
26996
|
@supabase/supabase-js client: client.from("starter_reviews").select("id,state,version").
|
|
26545
26997
|
Use the caller's session, RLS and grants; never introduce a second session store.
|
|
26546
|
-
|
|
26998
|
+
Command is the write boundary of this compiler application lane only.
|
|
26999
|
+
Cross-table change, idempotency, and audit stay on the governed Command/RPC
|
|
27000
|
+
boundary. Ordinary reads and low-risk CRUD stay on PostgREST and
|
|
27001
|
+
@supabase/supabase-js.
|
|
26547
27002
|
|
|
26548
27003
|
Use listReviews from src/review/list-reviews.ts for the paginated review list.
|
|
26549
27004
|
Type the existing client with ReviewReadDatabase (a read-only projection derived
|
|
@@ -26877,18 +27332,32 @@ async function initializeAppProject(options) {
|
|
|
26877
27332
|
if ((await readdir3(root)).some((entry) => entry !== ".git")) {
|
|
26878
27333
|
throw new Error("app init requires an empty directory (an existing .git directory is allowed)");
|
|
26879
27334
|
}
|
|
26880
|
-
const template = options.template
|
|
27335
|
+
const template = resolveStarterTemplate(options.template);
|
|
26881
27336
|
const sdk = {
|
|
26882
27337
|
"@supacloud/js": `^${sdkMetadata.version}`,
|
|
26883
27338
|
"@supabase/supabase-js": sdkMetadata.peerDependencies["@supabase/supabase-js"]
|
|
26884
27339
|
};
|
|
26885
|
-
const files =
|
|
27340
|
+
const files = (() => {
|
|
27341
|
+
switch (template) {
|
|
27342
|
+
case "command":
|
|
27343
|
+
return appStarterFiles(name);
|
|
27344
|
+
case "model-command":
|
|
27345
|
+
return modelCommandTemplateFiles(name, sdk);
|
|
27346
|
+
case "minimal":
|
|
27347
|
+
case "client":
|
|
27348
|
+
return appTemplateFiles(name, template, sdk);
|
|
27349
|
+
default: {
|
|
27350
|
+
const exhausted = template;
|
|
27351
|
+
throw new Error(`Unknown app init template: ${String(exhausted)}`);
|
|
27352
|
+
}
|
|
27353
|
+
}
|
|
27354
|
+
})();
|
|
26886
27355
|
for (const [relativePath, content] of Object.entries(files)) {
|
|
26887
27356
|
const path = join9(root, relativePath);
|
|
26888
27357
|
await mkdir3(dirname6(path), { recursive: true });
|
|
26889
27358
|
await writeFile3(path, content, { encoding: "utf8", flag: "wx" });
|
|
26890
27359
|
}
|
|
26891
|
-
return { root, name, files: Object.keys(files) };
|
|
27360
|
+
return { root, name, files: Object.keys(files), template };
|
|
26892
27361
|
}
|
|
26893
27362
|
|
|
26894
27363
|
// src/shared/tools/app-database-check.ts
|
|
@@ -26930,12 +27399,18 @@ function checkAppDatabaseSources(projectRoot) {
|
|
|
26930
27399
|
}
|
|
26931
27400
|
return {
|
|
26932
27401
|
name,
|
|
27402
|
+
layer: "source",
|
|
26933
27403
|
ok: (result.exitCode === 0 || result.success) && report.ok && !messages.length,
|
|
26934
27404
|
detail: messages.join(`
|
|
26935
27405
|
`) || ((result.exitCode === 0 || result.success) && report.ok ? "Offline database contracts and boundaries are current" : "Database source check failed")
|
|
26936
27406
|
};
|
|
26937
27407
|
} catch {
|
|
26938
|
-
return {
|
|
27408
|
+
return {
|
|
27409
|
+
name,
|
|
27410
|
+
layer: "runtime",
|
|
27411
|
+
ok: false,
|
|
27412
|
+
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."
|
|
27413
|
+
};
|
|
26939
27414
|
}
|
|
26940
27415
|
}
|
|
26941
27416
|
|
|
@@ -28590,17 +29065,20 @@ for (const [name, schema] of Object.entries(REMOTE_APP_SCHEMA)) {
|
|
|
28590
29065
|
async function initProject(args) {
|
|
28591
29066
|
if (args.force)
|
|
28592
29067
|
throw new Error("app init never overwrites files; choose an empty directory");
|
|
28593
|
-
const template =
|
|
28594
|
-
|
|
28595
|
-
|
|
29068
|
+
const { root, name, files, template } = await initializeAppProject({
|
|
29069
|
+
root: args.root,
|
|
29070
|
+
name: args.name,
|
|
29071
|
+
template: args.template
|
|
29072
|
+
});
|
|
29073
|
+
const next = template === "client" ? ["bun install", "bun run check"] : [
|
|
28596
29074
|
"bun install",
|
|
28597
|
-
...template
|
|
29075
|
+
...template === "command" || template === "model-command" ? ["bun run db:generate"] : [],
|
|
28598
29076
|
...template === "model-command" ? ["bun run compile"] : [],
|
|
28599
29077
|
"bun run check",
|
|
28600
29078
|
...template === "model-command" ? ["# Follow README.md: apply reviewed local migrations, provision the application role and configure IdentityAuthority before dev."] : [],
|
|
28601
29079
|
"bun run dev"
|
|
28602
29080
|
];
|
|
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.";
|
|
29081
|
+
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
29082
|
if (args.format === "json")
|
|
28605
29083
|
return textResult(JSON.stringify({
|
|
28606
29084
|
version: 1,
|
|
@@ -29134,7 +29612,7 @@ async function runDoctor(args) {
|
|
|
29134
29612
|
...doctor
|
|
29135
29613
|
}, null, 2), doctor.errors > 0);
|
|
29136
29614
|
}
|
|
29137
|
-
const lines = doctor.checks.map((check) =>
|
|
29615
|
+
const lines = doctor.checks.map((check) => formatDoctorCheck(check));
|
|
29138
29616
|
if (scope)
|
|
29139
29617
|
lines.unshift(`TARGET ${scope.target}; omitted project diagnostics=${scope.omittedProjectDiagnostics}; generated drift remains project-wide`);
|
|
29140
29618
|
for (const diagnostic of doctor.diagnostics ?? []) {
|
|
@@ -29442,7 +29920,7 @@ async function runCheck(args) {
|
|
|
29442
29920
|
return textResult([
|
|
29443
29921
|
formatDiagnostics(result.diagnostics),
|
|
29444
29922
|
...result.mismatches.map((path) => `generated artifact mismatch: ${path}`),
|
|
29445
|
-
...database ? [
|
|
29923
|
+
...database ? [formatDoctorCheck(database)] : [],
|
|
29446
29924
|
"",
|
|
29447
29925
|
summary
|
|
29448
29926
|
].join(`
|
|
@@ -30288,7 +30766,7 @@ function registerAppTools(server, options = {}) {
|
|
|
30288
30766
|
"promote-reconcile"
|
|
30289
30767
|
]), "App action; promote obtains and verifies its plan before one mutation request"),
|
|
30290
30768
|
kind: optional(stringEnum2(["module", "command", "query", "controller", "job", "contract", "resource", "feature"]), "[generate] Scaffold kind"),
|
|
30291
|
-
template: optional(stringEnum2(["minimal", "command", "model-command"]), "[init]
|
|
30769
|
+
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
30770
|
name: optional(String2(), "[init/generate] Project or object name"),
|
|
30293
30771
|
module: optional(String2(), "[generate] Target feature module (required for command/query/controller)"),
|
|
30294
30772
|
permission: optional(String2(), "[generate feature] Explicit approval permission; not inferred from name"),
|
|
@@ -34369,7 +34847,7 @@ async function runProjectDeployment(http, args) {
|
|
|
34369
34847
|
// package.json
|
|
34370
34848
|
var package_default = {
|
|
34371
34849
|
name: "@supacloud/cli",
|
|
34372
|
-
version: "0.
|
|
34850
|
+
version: "0.121.3",
|
|
34373
34851
|
description: "Project-scoped CLI for SupaCloud users",
|
|
34374
34852
|
type: "module",
|
|
34375
34853
|
main: "./dist/index.js",
|
|
@@ -34421,23 +34899,23 @@ var package_default = {
|
|
|
34421
34899
|
directory: "packages/cli"
|
|
34422
34900
|
},
|
|
34423
34901
|
dependencies: {
|
|
34424
|
-
"@supacloud/compiler": "^0.62.
|
|
34425
|
-
"@supacloud/delivery": "0.
|
|
34426
|
-
"@supacloud/db": "0.24.
|
|
34902
|
+
"@supacloud/compiler": "^0.62.2",
|
|
34903
|
+
"@supacloud/delivery": "0.27.0",
|
|
34904
|
+
"@supacloud/db": "0.24.2",
|
|
34427
34905
|
typebox: "1.4.3"
|
|
34428
34906
|
},
|
|
34429
34907
|
overrides: {
|
|
34430
34908
|
"@supacloud/contracts": "0.16.1",
|
|
34431
|
-
"@supacloud/delivery": "0.
|
|
34909
|
+
"@supacloud/delivery": "0.27.0",
|
|
34432
34910
|
"@graphql-tools/utils": "^12.0.4",
|
|
34433
|
-
"@supacloud/compiler": "^0.62.
|
|
34434
|
-
"@supacloud/db": "0.24.
|
|
34911
|
+
"@supacloud/compiler": "^0.62.2",
|
|
34912
|
+
"@supacloud/db": "0.24.2",
|
|
34435
34913
|
"deepmerge-ts": "8.0.2",
|
|
34436
34914
|
prisma: "6.19.3"
|
|
34437
34915
|
},
|
|
34438
34916
|
devDependencies: {
|
|
34439
34917
|
"@supabase/supabase-js": "2.118.0",
|
|
34440
|
-
"@supacloud/elysia": "0.42.
|
|
34918
|
+
"@supacloud/elysia": "0.42.2",
|
|
34441
34919
|
"@types/bun": "^1.4.4",
|
|
34442
34920
|
effect: "4.0.5",
|
|
34443
34921
|
elysia: "2.0.0-rc.1",
|