@amerged/ohmyhost-cli 0.1.56 → 0.1.57
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 +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-HNFWXGDN.js → chunk-GODV5QDC.js} +579 -76
- package/dist/index.js +7 -1
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +150 -11
- package/src/apps/product-cli/src/command.ts +185 -4
- package/src/apps/product-cli/src/product-api.ts +126 -3
- package/src/apps/product-cli/src/repository-init.ts +8 -0
- package/src/apps/product-cli/src/runtime-contract.ts +43 -5
- package/src/apps/product-cli/src/user-token-file.ts +73 -0
- package/src/packages/contracts/src/credit-pricing.ts +1 -1
- package/src/packages/contracts/src/database-events.ts +67 -0
- package/src/packages/contracts/src/framework-admission.ts +5 -4
- package/src/packages/contracts/src/framework-source-rules.ts +9 -2
- package/src/packages/contracts/src/index.ts +9 -0
- package/src/packages/contracts/src/operation-deployment-result.ts +121 -1
- package/src/packages/contracts/src/operation-failure.ts +72 -1
- package/src/packages/contracts/src/problem-policy.ts +13 -1
- package/src/packages/contracts/src/secret-names.ts +3 -2
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/index.ts +30 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +216 -2
- package/src/packages/sdk-ts/src/generated/types.gen.ts +370 -1
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
NativeKeyringProfileRegistry,
|
|
15
15
|
NetworkTransportError,
|
|
16
16
|
OwnerOnlyProjectLinkStore,
|
|
17
|
+
PrivateSecretFileError,
|
|
17
18
|
ProductApiAuthenticationError,
|
|
18
19
|
ProductCli,
|
|
19
20
|
ProfileIndexFiles,
|
|
@@ -82,6 +83,7 @@ import {
|
|
|
82
83
|
parseSafeProblem,
|
|
83
84
|
parseWithLinkedProject,
|
|
84
85
|
prepareLocalSourcePublication,
|
|
86
|
+
preparePrivateSecretFile,
|
|
85
87
|
prepareUserTokenFile,
|
|
86
88
|
profileIndexDirectory,
|
|
87
89
|
profileLimitAction,
|
|
@@ -90,6 +92,7 @@ import {
|
|
|
90
92
|
publicWorkspace,
|
|
91
93
|
publishSourceSnapshot,
|
|
92
94
|
readBoundedResponseBody,
|
|
95
|
+
readPrivateWebhookCreateRequest,
|
|
93
96
|
readProjectLinks,
|
|
94
97
|
readSecretValueFromStandardInput,
|
|
95
98
|
recognizedCommandLabel,
|
|
@@ -103,7 +106,7 @@ import {
|
|
|
103
106
|
selectWorkspace,
|
|
104
107
|
verifiedUserId,
|
|
105
108
|
workspaceOf
|
|
106
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-GODV5QDC.js";
|
|
107
110
|
import {
|
|
108
111
|
CredentialStoreIntegrityError,
|
|
109
112
|
CredentialStoreUnavailableError,
|
|
@@ -270,6 +273,7 @@ export {
|
|
|
270
273
|
NetworkTransportError,
|
|
271
274
|
OwnerOnlyFileCredentialStore,
|
|
272
275
|
OwnerOnlyProjectLinkStore,
|
|
276
|
+
PrivateSecretFileError,
|
|
273
277
|
ProductApiAuthenticationError,
|
|
274
278
|
ProductCli,
|
|
275
279
|
ProfileIndexFiles,
|
|
@@ -340,6 +344,7 @@ export {
|
|
|
340
344
|
parseSafeProblem,
|
|
341
345
|
parseWithLinkedProject,
|
|
342
346
|
prepareLocalSourcePublication,
|
|
347
|
+
preparePrivateSecretFile,
|
|
343
348
|
prepareUserTokenFile,
|
|
344
349
|
profileIndexDirectory,
|
|
345
350
|
profileLimitAction,
|
|
@@ -348,6 +353,7 @@ export {
|
|
|
348
353
|
publicWorkspace,
|
|
349
354
|
publishSourceSnapshot,
|
|
350
355
|
readBoundedResponseBody,
|
|
356
|
+
readPrivateWebhookCreateRequest,
|
|
351
357
|
readProjectLinks,
|
|
352
358
|
readSecretValueFromStandardInput,
|
|
353
359
|
recognizedCommandLabel,
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { lstat, open } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
4
|
import {
|
|
4
5
|
assertManagedSourceResponse,
|
|
5
6
|
type ManagedProjectSource,
|
|
@@ -45,7 +46,12 @@ import {
|
|
|
45
46
|
EXPORT_PASSWORD_MIN_CHARACTERS,
|
|
46
47
|
exportPasswordMeetsMinimum,
|
|
47
48
|
} from "@ohmyhost/contracts/project-exports";
|
|
48
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
prepareUserTokenFile,
|
|
51
|
+
UserTokenFileError,
|
|
52
|
+
preparePrivateSecretFile,
|
|
53
|
+
PrivateSecretFileError,
|
|
54
|
+
} from "./user-token-file.js";
|
|
49
55
|
import { parseUserApiKeyPage } from "@ohmyhost/contracts/user-api-keys";
|
|
50
56
|
import { assertOrganizationCreditUsage } from "@ohmyhost/contracts/credit-pricing";
|
|
51
57
|
import {
|
|
@@ -402,7 +408,7 @@ const HELP_USAGE = Object.freeze({
|
|
|
402
408
|
"feedback submit":
|
|
403
409
|
"ohmyhost feedback submit --organization ULID --kind bug|issue|feature_request --title TITLE --description REDACTED_REPORT [--project ULID] [--environment ULID] [--operation ULID] [--error-code CODE] [--client-version VERSION] --idempotency-key KEY --json",
|
|
404
410
|
"project create":
|
|
405
|
-
"ohmyhost project create --organization ULID --name NAME [--data-mode shared|isolated] [--dev-access-mode protected|public] [--region us|eu] --idempotency-key KEY --json (
|
|
411
|
+
"ohmyhost project create --organization ULID --name NAME [--include-development-environment true|false] [--data-mode shared|isolated] [--dev-access-mode protected|public] [--region us|eu] --idempotency-key KEY --json (Dev defaults to included; add it later with project dev add. Data mode defaults to shared; later changes do not copy data. The region is chosen once: us defaults to US; eu selects EU database, new files and builds; the customer API cannot change region later)",
|
|
406
412
|
"project data plan":
|
|
407
413
|
"ohmyhost project data plan --project ULID --change isolate_prod_keeps_data|isolate_dev_keeps_data|share_prod_keeps_data|reset_dev --json (shared is the optional creation default; review which data is kept or deleted; no data is copied)",
|
|
408
414
|
"project data change":
|
|
@@ -412,6 +418,7 @@ const HELP_USAGE = Object.freeze({
|
|
|
412
418
|
"project notes set":
|
|
413
419
|
"ohmyhost project notes set --project ULID --version NUMBER --markdown TEXT --idempotency-key KEY --json (no credentials or signed URLs)",
|
|
414
420
|
"project status": "ohmyhost project status --project ULID --json",
|
|
421
|
+
"project dev add": "ohmyhost project dev add --project ULID --idempotency-key KEY --json",
|
|
415
422
|
"project dev-access create": "ohmyhost project dev-access create --project ULID --json",
|
|
416
423
|
"project dev-share link": "ohmyhost project dev-share link --project ULID --json",
|
|
417
424
|
"project dev-share rotate":
|
|
@@ -453,6 +460,12 @@ const HELP_USAGE = Object.freeze({
|
|
|
453
460
|
"ohmyhost database table create --project ULID --environment dev|prod --table NAME --columns-file PATH [--primary-key COL[,COL]] --idempotency-key KEY --yes --json (the table is created in the public schema as the migration role, with the same access as migration tables, so a database watch can attach later; the columns file is a UTF-8 JSON array of 1 to 64 column objects, at most 64 KiB, each with name, type and optional nullable, identity and default; types: text, integer, bigint, boolean, numeric, double precision, timestamptz, date, uuid, jsonb; identity needs integer or bigint; default now needs timestamptz and default uuid needs uuid; identical repeats answer created false; at most 100 tables, 64 columns per table)",
|
|
454
461
|
"database webhook create":
|
|
455
462
|
"ohmyhost database webhook create --project ULID --environment dev|prod --url HTTPS_URL --event-types TYPE[,TYPE] [--headers-file PATH] --idempotency-key KEY --yes --json (the signing secret is shown once in this answer; types: database.created, database.ready, database.woke, database.slept, database.suspended, database.resized, database.deleted, data.<topic> for the rows of one watched table printed by database watch create, or data.* for every watched table; a bare * is not accepted and does not include data events; the headers file is a UTF-8 JSON object of at most 8 KiB)",
|
|
463
|
+
"database webhook subscription activate":
|
|
464
|
+
"ohmyhost database webhook subscription activate --project ULID --environment dev|prod --subscription ULID --generation N --url HTTPS_URL --event-types TYPE[,TYPE] [--headers-file PATH] --out NEW_PRIVATE_FILE --idempotency-key KEY --yes --json (the secret is written privately; repeat the same key and body after uncertainty using a new output file)",
|
|
465
|
+
"database webhook subscription deactivate":
|
|
466
|
+
"ohmyhost database webhook subscription deactivate --project ULID --environment dev|prod --subscription ULID --generation N --idempotency-key KEY --yes --json",
|
|
467
|
+
"database webhook subscription status":
|
|
468
|
+
"ohmyhost database webhook subscription status --project ULID [--environment dev|prod] --subscription ULID --json",
|
|
456
469
|
"database webhook list":
|
|
457
470
|
"ohmyhost database webhook list --project ULID [--environment dev|prod] --json (dev when omitted; the secret is never listed)",
|
|
458
471
|
"database webhook get":
|
|
@@ -1186,6 +1199,8 @@ export class ProductCli {
|
|
|
1186
1199
|
return success("project notes set", { status: "succeeded", notes });
|
|
1187
1200
|
}
|
|
1188
1201
|
if (command.kind === "project-status") return await this.getProjectStatus(command, signal);
|
|
1202
|
+
if (command.kind === "project-development-add")
|
|
1203
|
+
return await this.addProjectDevelopment(command, signal);
|
|
1189
1204
|
if (command.kind === "project-dev-access-create")
|
|
1190
1205
|
return await this.createDevAccessTicket(command, signal);
|
|
1191
1206
|
if (command.kind === "project-flag-status" || command.kind === "project-flag-set") {
|
|
@@ -1294,6 +1309,12 @@ export class ProductCli {
|
|
|
1294
1309
|
return await this.createDatabaseTable(command, signal);
|
|
1295
1310
|
if (command.kind === "database-webhook-create")
|
|
1296
1311
|
return await this.createDatabaseWebhook(command, signal);
|
|
1312
|
+
if (
|
|
1313
|
+
command.kind === "database-webhook-subscription-activate" ||
|
|
1314
|
+
command.kind === "database-webhook-subscription-deactivate" ||
|
|
1315
|
+
command.kind === "database-webhook-subscription-status"
|
|
1316
|
+
)
|
|
1317
|
+
return await this.databaseWebhookSubscription(command, signal);
|
|
1297
1318
|
if (command.kind === "database-webhook-list")
|
|
1298
1319
|
return await this.listDatabaseWebhooks(command, signal);
|
|
1299
1320
|
if (command.kind === "database-webhook-get")
|
|
@@ -1382,7 +1403,7 @@ export class ProductCli {
|
|
|
1382
1403
|
}
|
|
1383
1404
|
return await this.deleteEnvironmentSecret(command, signal);
|
|
1384
1405
|
} catch (error) {
|
|
1385
|
-
if (error instanceof UserTokenFileError)
|
|
1406
|
+
if (error instanceof UserTokenFileError || error instanceof PrivateSecretFileError)
|
|
1386
1407
|
return failure(name, 3, error.code, false, error.message);
|
|
1387
1408
|
if (error instanceof InteractiveSessionRequiredError)
|
|
1388
1409
|
return failure(
|
|
@@ -1957,6 +1978,9 @@ export class ProductCli {
|
|
|
1957
1978
|
name: command.name,
|
|
1958
1979
|
...(command.dataMode === undefined ? {} : { dataMode: command.dataMode }),
|
|
1959
1980
|
...(command.devAccessMode === undefined ? {} : { devAccessMode: command.devAccessMode }),
|
|
1981
|
+
...(command.includeDevelopmentEnvironment === undefined
|
|
1982
|
+
? {}
|
|
1983
|
+
: { includeDevelopmentEnvironment: command.includeDevelopmentEnvironment }),
|
|
1960
1984
|
...(command.region === undefined ? {} : { region: command.region }),
|
|
1961
1985
|
idempotencyKey: command.idempotencyKey,
|
|
1962
1986
|
}),
|
|
@@ -2012,6 +2036,20 @@ export class ProductCli {
|
|
|
2012
2036
|
return success("project status", { status: "succeeded", project, context: this.context() });
|
|
2013
2037
|
}
|
|
2014
2038
|
|
|
2039
|
+
private async addProjectDevelopment(
|
|
2040
|
+
command: Extract<ProductCliCommand, { kind: "project-development-add" }>,
|
|
2041
|
+
signal: AbortSignal,
|
|
2042
|
+
): Promise<CliResult> {
|
|
2043
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2044
|
+
const operation = parseOperation(
|
|
2045
|
+
await api.addProjectDevelopmentEnvironment({
|
|
2046
|
+
projectId: command.projectId,
|
|
2047
|
+
idempotencyKey: command.idempotencyKey,
|
|
2048
|
+
}),
|
|
2049
|
+
);
|
|
2050
|
+
return success("project dev add", { status: "accepted", operation });
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2015
2053
|
private async createDevAccessTicket(
|
|
2016
2054
|
command: Extract<ProductCliCommand, { kind: "project-dev-access-create" }>,
|
|
2017
2055
|
signal: AbortSignal,
|
|
@@ -2159,6 +2197,63 @@ export class ProductCli {
|
|
|
2159
2197
|
return success("database webhook create", { status: "succeeded", webhook });
|
|
2160
2198
|
}
|
|
2161
2199
|
|
|
2200
|
+
private async databaseWebhookSubscription(
|
|
2201
|
+
command: Extract<
|
|
2202
|
+
ProductCliCommand,
|
|
2203
|
+
{
|
|
2204
|
+
kind:
|
|
2205
|
+
| "database-webhook-subscription-activate"
|
|
2206
|
+
| "database-webhook-subscription-deactivate"
|
|
2207
|
+
| "database-webhook-subscription-status";
|
|
2208
|
+
}
|
|
2209
|
+
>,
|
|
2210
|
+
signal: AbortSignal,
|
|
2211
|
+
): Promise<CliResult> {
|
|
2212
|
+
const common = {
|
|
2213
|
+
projectId: command.projectId,
|
|
2214
|
+
environment: command.environment,
|
|
2215
|
+
subscriptionId: command.subscriptionId,
|
|
2216
|
+
};
|
|
2217
|
+
if (command.kind === "database-webhook-subscription-activate") {
|
|
2218
|
+
const request = await webhookCreateRequest(command);
|
|
2219
|
+
const file = await preparePrivateSecretFile(command.outputPath);
|
|
2220
|
+
try {
|
|
2221
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2222
|
+
const value = await api.activateDatabaseWebhookSubscription({
|
|
2223
|
+
...common,
|
|
2224
|
+
generation: command.generation,
|
|
2225
|
+
idempotencyKey: command.idempotencyKey,
|
|
2226
|
+
request,
|
|
2227
|
+
});
|
|
2228
|
+
await file.save(value.secret);
|
|
2229
|
+
const subscription = {
|
|
2230
|
+
id: value.id,
|
|
2231
|
+
environment: value.environment,
|
|
2232
|
+
state: value.state,
|
|
2233
|
+
generation: value.generation,
|
|
2234
|
+
provider_id: value.provider_id,
|
|
2235
|
+
};
|
|
2236
|
+
return success(parsedCommandName(command), {
|
|
2237
|
+
status: "succeeded",
|
|
2238
|
+
subscription,
|
|
2239
|
+
secret_file: file.path,
|
|
2240
|
+
});
|
|
2241
|
+
} finally {
|
|
2242
|
+
await file.close();
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
const api = await this.authenticatedApi(command.credentialStore, signal);
|
|
2246
|
+
const subscription =
|
|
2247
|
+
command.kind === "database-webhook-subscription-status"
|
|
2248
|
+
? await api.getDatabaseWebhookSubscription(common)
|
|
2249
|
+
: await api.deactivateDatabaseWebhookSubscription({
|
|
2250
|
+
...common,
|
|
2251
|
+
generation: command.generation,
|
|
2252
|
+
idempotencyKey: command.idempotencyKey,
|
|
2253
|
+
});
|
|
2254
|
+
return success(parsedCommandName(command), { status: "succeeded", subscription });
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2162
2257
|
private async listDatabaseWebhooks(
|
|
2163
2258
|
command: Extract<ProductCliCommand, { kind: "database-webhook-list" }>,
|
|
2164
2259
|
signal: AbortSignal,
|
|
@@ -2795,7 +2890,7 @@ export class ProductCli {
|
|
|
2795
2890
|
await api.planDeployment({
|
|
2796
2891
|
projectId: command.projectId,
|
|
2797
2892
|
commitSha: command.commitSha,
|
|
2798
|
-
environment: command.environment,
|
|
2893
|
+
...(command.environment === undefined ? {} : { environment: command.environment }),
|
|
2799
2894
|
}),
|
|
2800
2895
|
);
|
|
2801
2896
|
let accepted: unknown;
|
|
@@ -2830,7 +2925,7 @@ export class ProductCli {
|
|
|
2830
2925
|
const notes =
|
|
2831
2926
|
operation.state === "succeeded"
|
|
2832
2927
|
? [
|
|
2833
|
-
`
|
|
2928
|
+
`If this is a Dev deployment, check project status for dev_access_mode. For protected Dev, run '${this.dependencies.commandPrefix} project dev-share link --project ULID --json' and open or share its persistent share_url; public Dev opens directly.`,
|
|
2834
2929
|
]
|
|
2835
2930
|
: [];
|
|
2836
2931
|
return success("deploy", {
|
|
@@ -3524,17 +3619,42 @@ const readBoundedUtf8File = async (
|
|
|
3524
3619
|
path: string,
|
|
3525
3620
|
maxBytes: number,
|
|
3526
3621
|
refusal: () => ProductCliFailure,
|
|
3622
|
+
privateFile = false,
|
|
3527
3623
|
): Promise<string> => {
|
|
3528
3624
|
let file: Awaited<ReturnType<typeof open>>;
|
|
3625
|
+
let before: Awaited<ReturnType<typeof lstat>> | undefined;
|
|
3529
3626
|
try {
|
|
3530
|
-
|
|
3627
|
+
if (privateFile) {
|
|
3628
|
+
if (!isAbsolute(path)) throw refusal();
|
|
3629
|
+
before = await lstat(path);
|
|
3630
|
+
if (
|
|
3631
|
+
!before.isFile() ||
|
|
3632
|
+
before.isSymbolicLink() ||
|
|
3633
|
+
before.nlink !== 1 ||
|
|
3634
|
+
(process.platform !== "win32" &&
|
|
3635
|
+
(before.uid !== process.getuid?.() || (before.mode & 0o077) !== 0))
|
|
3636
|
+
)
|
|
3637
|
+
throw refusal();
|
|
3638
|
+
}
|
|
3639
|
+
file = await open(path, privateFile ? constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) : "r");
|
|
3531
3640
|
} catch {
|
|
3532
3641
|
throw refusal();
|
|
3533
3642
|
}
|
|
3534
3643
|
const buffer = Buffer.alloc(maxBytes + 1);
|
|
3535
3644
|
try {
|
|
3536
3645
|
const stat = await file.stat();
|
|
3537
|
-
if (
|
|
3646
|
+
if (
|
|
3647
|
+
!stat.isFile() ||
|
|
3648
|
+
stat.size > maxBytes ||
|
|
3649
|
+
(before !== undefined &&
|
|
3650
|
+
(stat.ino !== before.ino ||
|
|
3651
|
+
stat.dev !== before.dev ||
|
|
3652
|
+
stat.nlink !== 1 ||
|
|
3653
|
+
stat.size !== before.size ||
|
|
3654
|
+
(process.platform !== "win32" &&
|
|
3655
|
+
(stat.uid !== process.getuid?.() || (stat.mode & 0o077) !== 0))))
|
|
3656
|
+
)
|
|
3657
|
+
throw refusal();
|
|
3538
3658
|
let length = 0;
|
|
3539
3659
|
while (length < buffer.length) {
|
|
3540
3660
|
const read = await file.read(buffer, length, buffer.length - length, null);
|
|
@@ -3554,14 +3674,19 @@ const readBoundedUtf8File = async (
|
|
|
3554
3674
|
|
|
3555
3675
|
/** The create request with the headers of `--headers-file`; a refused file sends nothing. */
|
|
3556
3676
|
const webhookCreateRequest = async (
|
|
3557
|
-
command:
|
|
3677
|
+
command: {
|
|
3678
|
+
readonly url: string;
|
|
3679
|
+
readonly eventTypes: readonly import("@ohmyhost/contracts/database-events").DatabaseWebhookEventPattern[];
|
|
3680
|
+
readonly headersFile: string | null;
|
|
3681
|
+
},
|
|
3682
|
+
privateHeaders = false,
|
|
3558
3683
|
) => {
|
|
3559
3684
|
const headersFailure = () =>
|
|
3560
3685
|
new ProductCliFailure(2, "headers_file_invalid", false, HEADERS_FILE_INVALID_ACTION);
|
|
3561
3686
|
const headers =
|
|
3562
3687
|
command.headersFile === null
|
|
3563
3688
|
? undefined
|
|
3564
|
-
: await readBoundedUtf8File(command.headersFile, 8_192, headersFailure).then(
|
|
3689
|
+
: await readBoundedUtf8File(command.headersFile, 8_192, headersFailure, privateHeaders).then(
|
|
3565
3690
|
(text: string): unknown => {
|
|
3566
3691
|
try {
|
|
3567
3692
|
return JSON.parse(text) as unknown;
|
|
@@ -3581,6 +3706,13 @@ const webhookCreateRequest = async (
|
|
|
3581
3706
|
}
|
|
3582
3707
|
};
|
|
3583
3708
|
|
|
3709
|
+
/** The local MCP webhook action reads only an absolute, owner-private header file, never a raw argument. */
|
|
3710
|
+
export const readPrivateWebhookCreateRequest = (input: {
|
|
3711
|
+
readonly url: string;
|
|
3712
|
+
readonly eventTypes: readonly import("@ohmyhost/contracts/database-events").DatabaseWebhookEventPattern[];
|
|
3713
|
+
readonly headersFile: string | null;
|
|
3714
|
+
}) => webhookCreateRequest(input, true);
|
|
3715
|
+
|
|
3584
3716
|
/**
|
|
3585
3717
|
* The schedule request of `database schedule set`: the statements file is a UTF-8 JSON array, and
|
|
3586
3718
|
* the schedule fields are checked by the same contract the service uses. A refused file or field
|
|
@@ -3766,6 +3898,7 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
|
|
|
3766
3898
|
if (command.kind === "project-context") return "project context";
|
|
3767
3899
|
if (command.kind === "project-notes-set") return "project notes set";
|
|
3768
3900
|
if (command.kind === "project-status") return "project status";
|
|
3901
|
+
if (command.kind === "project-development-add") return "project dev add";
|
|
3769
3902
|
if (command.kind === "project-dev-access-create") return "project dev-access create";
|
|
3770
3903
|
if (command.kind === "project-dev-share-link") return "project dev-share link";
|
|
3771
3904
|
if (command.kind === "project-dev-share-rotate") return "project dev-share rotate";
|
|
@@ -3786,6 +3919,12 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
|
|
|
3786
3919
|
if (command.kind === "database-watch-delete") return "database watch delete";
|
|
3787
3920
|
if (command.kind === "database-table-create") return "database table create";
|
|
3788
3921
|
if (command.kind === "database-webhook-create") return "database webhook create";
|
|
3922
|
+
if (command.kind === "database-webhook-subscription-activate")
|
|
3923
|
+
return "database webhook subscription activate";
|
|
3924
|
+
if (command.kind === "database-webhook-subscription-deactivate")
|
|
3925
|
+
return "database webhook subscription deactivate";
|
|
3926
|
+
if (command.kind === "database-webhook-subscription-status")
|
|
3927
|
+
return "database webhook subscription status";
|
|
3789
3928
|
if (command.kind === "database-webhook-list") return "database webhook list";
|
|
3790
3929
|
if (command.kind === "database-webhook-get") return "database webhook get";
|
|
3791
3930
|
if (command.kind === "database-webhook-delete") return "database webhook delete";
|
|
@@ -349,6 +349,7 @@ export type ProductCliCommand =
|
|
|
349
349
|
readonly name: string;
|
|
350
350
|
readonly dataMode?: "shared" | "isolated";
|
|
351
351
|
readonly devAccessMode?: "protected" | "public";
|
|
352
|
+
readonly includeDevelopmentEnvironment?: boolean;
|
|
352
353
|
readonly region?: "us" | "eu";
|
|
353
354
|
readonly idempotencyKey: string;
|
|
354
355
|
readonly credentialStore: "native";
|
|
@@ -364,6 +365,12 @@ export type ProductCliCommand =
|
|
|
364
365
|
readonly projectId: string;
|
|
365
366
|
readonly credentialStore: "native";
|
|
366
367
|
}
|
|
368
|
+
| {
|
|
369
|
+
readonly kind: "project-development-add";
|
|
370
|
+
readonly projectId: string;
|
|
371
|
+
readonly idempotencyKey: string;
|
|
372
|
+
readonly credentialStore: "native";
|
|
373
|
+
}
|
|
367
374
|
| {
|
|
368
375
|
readonly kind: "project-dev-share-link";
|
|
369
376
|
readonly projectId: string;
|
|
@@ -492,6 +499,37 @@ export type ProductCliCommand =
|
|
|
492
499
|
readonly yes: true;
|
|
493
500
|
readonly credentialStore: "native";
|
|
494
501
|
}
|
|
502
|
+
| {
|
|
503
|
+
readonly kind: "database-webhook-subscription-status";
|
|
504
|
+
readonly projectId: string;
|
|
505
|
+
readonly environment: "dev" | "prod";
|
|
506
|
+
readonly subscriptionId: string;
|
|
507
|
+
readonly credentialStore: "native";
|
|
508
|
+
}
|
|
509
|
+
| {
|
|
510
|
+
readonly kind: "database-webhook-subscription-activate";
|
|
511
|
+
readonly projectId: string;
|
|
512
|
+
readonly environment: "dev" | "prod";
|
|
513
|
+
readonly subscriptionId: string;
|
|
514
|
+
readonly generation: number;
|
|
515
|
+
readonly url: string;
|
|
516
|
+
readonly eventTypes: readonly DatabaseWebhookEventPattern[];
|
|
517
|
+
readonly headersFile: string | null;
|
|
518
|
+
readonly outputPath: string;
|
|
519
|
+
readonly idempotencyKey: string;
|
|
520
|
+
readonly yes: true;
|
|
521
|
+
readonly credentialStore: "native";
|
|
522
|
+
}
|
|
523
|
+
| {
|
|
524
|
+
readonly kind: "database-webhook-subscription-deactivate";
|
|
525
|
+
readonly projectId: string;
|
|
526
|
+
readonly environment: "dev" | "prod";
|
|
527
|
+
readonly subscriptionId: string;
|
|
528
|
+
readonly generation: number;
|
|
529
|
+
readonly idempotencyKey: string;
|
|
530
|
+
readonly yes: true;
|
|
531
|
+
readonly credentialStore: "native";
|
|
532
|
+
}
|
|
495
533
|
| {
|
|
496
534
|
readonly kind: "database-webhook-list";
|
|
497
535
|
readonly projectId: string;
|
|
@@ -636,7 +674,7 @@ export type ProductCliCommand =
|
|
|
636
674
|
readonly kind: "plan";
|
|
637
675
|
readonly projectId: string;
|
|
638
676
|
readonly commitSha: string;
|
|
639
|
-
readonly environment
|
|
677
|
+
readonly environment?: "dev" | "prod";
|
|
640
678
|
readonly credentialStore: "native";
|
|
641
679
|
}
|
|
642
680
|
| {
|
|
@@ -645,7 +683,7 @@ export type ProductCliCommand =
|
|
|
645
683
|
/** Exactly one of an existing plan or a commit that is planned first. */
|
|
646
684
|
readonly planId: string | null;
|
|
647
685
|
readonly commitSha: string | null;
|
|
648
|
-
readonly environment
|
|
686
|
+
readonly environment?: "dev" | "prod";
|
|
649
687
|
readonly idempotencyKey: string;
|
|
650
688
|
readonly yes: true;
|
|
651
689
|
readonly wait: boolean;
|
|
@@ -1076,6 +1114,7 @@ export type RecognizedCommandLabel =
|
|
|
1076
1114
|
| "github disconnect"
|
|
1077
1115
|
| "project list"
|
|
1078
1116
|
| "project status"
|
|
1117
|
+
| "project dev add"
|
|
1079
1118
|
| "project dev-access create"
|
|
1080
1119
|
| "project dev-share link"
|
|
1081
1120
|
| "project dev-share rotate"
|
|
@@ -1095,6 +1134,9 @@ export type RecognizedCommandLabel =
|
|
|
1095
1134
|
| "database watch delete"
|
|
1096
1135
|
| "database table create"
|
|
1097
1136
|
| "database webhook create"
|
|
1137
|
+
| "database webhook subscription activate"
|
|
1138
|
+
| "database webhook subscription deactivate"
|
|
1139
|
+
| "database webhook subscription status"
|
|
1098
1140
|
| "database webhook list"
|
|
1099
1141
|
| "database webhook get"
|
|
1100
1142
|
| "database webhook delete"
|
|
@@ -1241,6 +1283,7 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1241
1283
|
if (value === "project" && values[0] === "notes" && values[1] === "set")
|
|
1242
1284
|
return "project notes set";
|
|
1243
1285
|
if (value === "project" && values[0] === "status") return "project status";
|
|
1286
|
+
if (value === "project" && values[0] === "dev" && values[1] === "add") return "project dev add";
|
|
1244
1287
|
if (value === "project" && values[0] === "handle" && values[1] === "check")
|
|
1245
1288
|
return "project handle check";
|
|
1246
1289
|
if (value === "project" && values[0] === "handle" && values[1] === "set")
|
|
@@ -1282,6 +1325,11 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
|
|
|
1282
1325
|
if (value === "database" && values[0] === "table" && values[1] === "create")
|
|
1283
1326
|
return "database table create";
|
|
1284
1327
|
if (value === "database" && values[0] === "webhook") {
|
|
1328
|
+
if (
|
|
1329
|
+
values[1] === "subscription" &&
|
|
1330
|
+
["activate", "deactivate", "status"].includes(values[2] ?? "")
|
|
1331
|
+
)
|
|
1332
|
+
return `database webhook subscription ${values[2]}` as RecognizedCommandLabel;
|
|
1285
1333
|
if (values[1] === "create") return "database webhook create";
|
|
1286
1334
|
if (values[1] === "list") return "database webhook list";
|
|
1287
1335
|
if (values[1] === "get") return "database webhook get";
|
|
@@ -2081,6 +2129,16 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2081
2129
|
}
|
|
2082
2130
|
if (first === "project") {
|
|
2083
2131
|
const subcommand = values.shift();
|
|
2132
|
+
if (subcommand === "dev" && values.shift() === "add") {
|
|
2133
|
+
if (yes || wait || follow || stdin) throw new InvalidCommandError();
|
|
2134
|
+
const options = parseOptions(values, ["--project", "--idempotency-key"]);
|
|
2135
|
+
return {
|
|
2136
|
+
kind: "project-development-add",
|
|
2137
|
+
projectId: options["--project"],
|
|
2138
|
+
idempotencyKey: options["--idempotency-key"],
|
|
2139
|
+
credentialStore,
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2084
2142
|
if (subcommand === "data") {
|
|
2085
2143
|
const action = values.shift();
|
|
2086
2144
|
if (follow || stdin || (action !== "plan" && action !== "change"))
|
|
@@ -2246,10 +2304,12 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2246
2304
|
"--idempotency-key",
|
|
2247
2305
|
"--data-mode",
|
|
2248
2306
|
"--dev-access-mode",
|
|
2307
|
+
"--include-development-environment",
|
|
2249
2308
|
"--region",
|
|
2250
2309
|
]);
|
|
2251
2310
|
const dataMode = options["--data-mode"];
|
|
2252
2311
|
const devAccessMode = options["--dev-access-mode"];
|
|
2312
|
+
const includeDevelopmentEnvironment = options["--include-development-environment"];
|
|
2253
2313
|
const region = options["--region"];
|
|
2254
2314
|
if (
|
|
2255
2315
|
!options["--organization"] ||
|
|
@@ -2259,6 +2319,9 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2259
2319
|
(devAccessMode !== undefined &&
|
|
2260
2320
|
devAccessMode !== "protected" &&
|
|
2261
2321
|
devAccessMode !== "public") ||
|
|
2322
|
+
(includeDevelopmentEnvironment !== undefined &&
|
|
2323
|
+
includeDevelopmentEnvironment !== "true" &&
|
|
2324
|
+
includeDevelopmentEnvironment !== "false") ||
|
|
2262
2325
|
(region !== undefined && region !== "us" && region !== "eu")
|
|
2263
2326
|
)
|
|
2264
2327
|
throw new InvalidCommandError();
|
|
@@ -2268,6 +2331,9 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2268
2331
|
name: options["--name"],
|
|
2269
2332
|
...(dataMode === undefined ? {} : { dataMode }),
|
|
2270
2333
|
...(devAccessMode === undefined ? {} : { devAccessMode }),
|
|
2334
|
+
...(includeDevelopmentEnvironment === undefined
|
|
2335
|
+
? {}
|
|
2336
|
+
: { includeDevelopmentEnvironment: includeDevelopmentEnvironment === "true" }),
|
|
2271
2337
|
...(region === undefined ? {} : { region }),
|
|
2272
2338
|
idempotencyKey: options["--idempotency-key"],
|
|
2273
2339
|
credentialStore,
|
|
@@ -2561,6 +2627,117 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
2561
2627
|
if (first === "database" && values[0] === "webhook") {
|
|
2562
2628
|
values.shift();
|
|
2563
2629
|
const subcommand = values.shift();
|
|
2630
|
+
if (subcommand === "subscription") {
|
|
2631
|
+
const action = values.shift();
|
|
2632
|
+
if (
|
|
2633
|
+
!["activate", "deactivate", "status"].includes(action ?? "") ||
|
|
2634
|
+
wait ||
|
|
2635
|
+
follow ||
|
|
2636
|
+
revoke ||
|
|
2637
|
+
stdin ||
|
|
2638
|
+
yes !== (action !== "status")
|
|
2639
|
+
)
|
|
2640
|
+
throw new InvalidCommandError();
|
|
2641
|
+
const options = parseOptionalOptions(values, [
|
|
2642
|
+
"--project",
|
|
2643
|
+
"--environment",
|
|
2644
|
+
"--subscription",
|
|
2645
|
+
"--generation",
|
|
2646
|
+
"--url",
|
|
2647
|
+
"--event-types",
|
|
2648
|
+
"--headers-file",
|
|
2649
|
+
"--out",
|
|
2650
|
+
"--idempotency-key",
|
|
2651
|
+
]);
|
|
2652
|
+
const projectId = options["--project"],
|
|
2653
|
+
environment = options["--environment"] ?? (action === "status" ? "dev" : undefined),
|
|
2654
|
+
subscriptionId = options["--subscription"];
|
|
2655
|
+
if (
|
|
2656
|
+
!isValue(projectId) ||
|
|
2657
|
+
!subscriptionId ||
|
|
2658
|
+
!ORGANIZATION_ULID.test(subscriptionId) ||
|
|
2659
|
+
(environment !== "dev" && environment !== "prod")
|
|
2660
|
+
)
|
|
2661
|
+
throw new InvalidCommandError();
|
|
2662
|
+
if (action === "status") {
|
|
2663
|
+
if (
|
|
2664
|
+
(
|
|
2665
|
+
[
|
|
2666
|
+
"--generation",
|
|
2667
|
+
"--url",
|
|
2668
|
+
"--event-types",
|
|
2669
|
+
"--headers-file",
|
|
2670
|
+
"--out",
|
|
2671
|
+
"--idempotency-key",
|
|
2672
|
+
] as const
|
|
2673
|
+
).some((key) => options[key] !== undefined)
|
|
2674
|
+
)
|
|
2675
|
+
throw new InvalidCommandError();
|
|
2676
|
+
return {
|
|
2677
|
+
kind: "database-webhook-subscription-status",
|
|
2678
|
+
projectId,
|
|
2679
|
+
environment,
|
|
2680
|
+
subscriptionId,
|
|
2681
|
+
credentialStore,
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
const generationText = options["--generation"],
|
|
2685
|
+
idempotencyKey = options["--idempotency-key"];
|
|
2686
|
+
if (
|
|
2687
|
+
!generationText ||
|
|
2688
|
+
!/^[1-9][0-9]*$/u.test(generationText) ||
|
|
2689
|
+
Number(generationText) > 2147483647 ||
|
|
2690
|
+
!isValue(idempotencyKey)
|
|
2691
|
+
)
|
|
2692
|
+
throw new InvalidCommandError();
|
|
2693
|
+
const generation = Number(generationText);
|
|
2694
|
+
if (action === "deactivate") {
|
|
2695
|
+
if (
|
|
2696
|
+
(["--url", "--event-types", "--headers-file", "--out"] as const).some(
|
|
2697
|
+
(key) => options[key] !== undefined,
|
|
2698
|
+
)
|
|
2699
|
+
)
|
|
2700
|
+
throw new InvalidCommandError();
|
|
2701
|
+
return {
|
|
2702
|
+
kind: "database-webhook-subscription-deactivate",
|
|
2703
|
+
projectId,
|
|
2704
|
+
environment,
|
|
2705
|
+
subscriptionId,
|
|
2706
|
+
generation,
|
|
2707
|
+
idempotencyKey,
|
|
2708
|
+
yes: true,
|
|
2709
|
+
credentialStore,
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
const url = options["--url"],
|
|
2713
|
+
eventTypes = options["--event-types"],
|
|
2714
|
+
headersFile = options["--headers-file"],
|
|
2715
|
+
outputPath = options["--out"];
|
|
2716
|
+
if (
|
|
2717
|
+
!isValue(url) ||
|
|
2718
|
+
!isValue(eventTypes) ||
|
|
2719
|
+
!isValue(outputPath) ||
|
|
2720
|
+
(headersFile !== undefined && !isValue(headersFile))
|
|
2721
|
+
)
|
|
2722
|
+
throw new InvalidCommandError();
|
|
2723
|
+
const request = contractValue(() =>
|
|
2724
|
+
parseDatabaseWebhookCreateRequest({ url, event_types: eventTypes.split(",") }),
|
|
2725
|
+
);
|
|
2726
|
+
return {
|
|
2727
|
+
kind: "database-webhook-subscription-activate",
|
|
2728
|
+
projectId,
|
|
2729
|
+
environment,
|
|
2730
|
+
subscriptionId,
|
|
2731
|
+
generation,
|
|
2732
|
+
url: request.url,
|
|
2733
|
+
eventTypes: request.event_types,
|
|
2734
|
+
headersFile: headersFile ?? null,
|
|
2735
|
+
outputPath,
|
|
2736
|
+
idempotencyKey,
|
|
2737
|
+
yes: true,
|
|
2738
|
+
credentialStore,
|
|
2739
|
+
};
|
|
2740
|
+
}
|
|
2564
2741
|
if (subcommand === "create") {
|
|
2565
2742
|
if (!yes || wait || follow || revoke || stdin) throw new InvalidCommandError();
|
|
2566
2743
|
const options = parseOptionalOptions(values, [
|
|
@@ -3020,7 +3197,9 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
3020
3197
|
kind: "plan",
|
|
3021
3198
|
projectId,
|
|
3022
3199
|
commitSha,
|
|
3023
|
-
|
|
3200
|
+
...(options["--environment"] === undefined
|
|
3201
|
+
? {}
|
|
3202
|
+
: { environment: deploymentEnvironment(options["--environment"]) }),
|
|
3024
3203
|
credentialStore,
|
|
3025
3204
|
};
|
|
3026
3205
|
}
|
|
@@ -3050,7 +3229,9 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
|
|
|
3050
3229
|
projectId,
|
|
3051
3230
|
planId,
|
|
3052
3231
|
commitSha,
|
|
3053
|
-
|
|
3232
|
+
...(options["--environment"] === undefined
|
|
3233
|
+
? {}
|
|
3234
|
+
: { environment: deploymentEnvironment(options["--environment"]) }),
|
|
3054
3235
|
idempotencyKey,
|
|
3055
3236
|
yes,
|
|
3056
3237
|
wait,
|