@amerged/ohmyhost-cli 0.1.40 → 0.1.42
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-MRBUGDRW.js → chunk-HBM2X2MV.js} +1626 -259
- package/dist/index.js +5 -3
- package/dist/licenses/pgcf-bridge-NOTICE +1 -1
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +440 -40
- package/src/apps/product-cli/src/command.ts +492 -19
- package/src/apps/product-cli/src/composition.ts +6 -3
- package/src/apps/product-cli/src/product-api.ts +366 -13
- package/src/apps/product-cli/src/runtime-contract.ts +1 -10
- package/src/packages/contracts/package.json +5 -0
- package/src/packages/contracts/src/credit-pricing.ts +78 -50
- package/src/packages/contracts/src/database-access.ts +24 -45
- package/src/packages/contracts/src/database-events.ts +697 -0
- package/src/packages/contracts/src/feedback.ts +0 -5
- package/src/packages/contracts/src/problem-policy.ts +28 -0
- package/src/packages/postgres-bridge/NOTICE +1 -1
- package/src/packages/postgres-bridge/src/bridge.ts +0 -4
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/index.ts +109 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +702 -10
- package/src/packages/sdk-ts/src/generated/types.gen.ts +1205 -49
|
@@ -112,21 +112,12 @@ export interface ProjectDatabaseAccessFields {
|
|
|
112
112
|
| "data_change"
|
|
113
113
|
| null;
|
|
114
114
|
}
|
|
115
|
-
export type ProjectDatabaseAccess = ProjectDatabaseAccessFields &
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly websocket_url?: never;
|
|
122
|
-
}
|
|
123
|
-
| {
|
|
124
|
-
readonly provider: "pgcf";
|
|
125
|
-
readonly transport: "wss";
|
|
126
|
-
readonly websocket_url: string;
|
|
127
|
-
readonly database: string;
|
|
128
|
-
}
|
|
129
|
-
);
|
|
115
|
+
export type ProjectDatabaseAccess = ProjectDatabaseAccessFields & {
|
|
116
|
+
readonly provider: "pgcf";
|
|
117
|
+
readonly transport: "wss";
|
|
118
|
+
readonly websocket_url: string;
|
|
119
|
+
readonly database: string;
|
|
120
|
+
};
|
|
130
121
|
export type ProjectDatabaseAccessCredential = ProjectDatabaseAccess & {
|
|
131
122
|
readonly connection_uri: string;
|
|
132
123
|
readonly psql_command: string;
|
|
@@ -140,6 +131,9 @@ const ACCESS_KEYS = [
|
|
|
140
131
|
"mode",
|
|
141
132
|
"role_name",
|
|
142
133
|
"host",
|
|
134
|
+
"provider",
|
|
135
|
+
"transport",
|
|
136
|
+
"websocket_url",
|
|
143
137
|
"database",
|
|
144
138
|
"label",
|
|
145
139
|
"state",
|
|
@@ -177,26 +171,23 @@ export function parseProjectDatabaseAccessRequest(value: unknown): ProjectDataba
|
|
|
177
171
|
export function assertProjectDatabaseAccess(
|
|
178
172
|
value: unknown,
|
|
179
173
|
): asserts value is ProjectDatabaseAccess {
|
|
180
|
-
if (!record(value) || !exact(value,
|
|
181
|
-
throw new TypeError("Invalid database access");
|
|
174
|
+
if (!record(value) || !exact(value, ACCESS_KEYS)) throw new TypeError("Invalid database access");
|
|
182
175
|
assertAccessFields(value);
|
|
183
176
|
}
|
|
184
177
|
export function assertProjectDatabaseAccessCredential(
|
|
185
178
|
value: unknown,
|
|
186
179
|
): asserts value is ProjectDatabaseAccessCredential {
|
|
187
|
-
if (!record(value) || !exact(value, [...
|
|
180
|
+
if (!record(value) || !exact(value, [...ACCESS_KEYS, "connection_uri", "psql_command"]))
|
|
188
181
|
throw new TypeError("Invalid database access credential");
|
|
189
182
|
assertAccessFields(value);
|
|
190
183
|
const uri = value["connection_uri"];
|
|
191
184
|
if (
|
|
192
185
|
typeof uri !== "string" ||
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
).test(value["psql_command"])
|
|
199
|
-
: value["psql_command"] !== `psql '${uri}'`)
|
|
186
|
+
typeof value["psql_command"] !== "string" ||
|
|
187
|
+
!new RegExp(
|
|
188
|
+
`^ohmyhost database psql --project [0-7][0-9A-HJKMNP-TV-Z]{25} --environment ${value["environment"]} --mode ${value["mode"]}$`,
|
|
189
|
+
"u",
|
|
190
|
+
).test(value["psql_command"])
|
|
200
191
|
)
|
|
201
192
|
throw new TypeError("Invalid database access credential");
|
|
202
193
|
let parsed: URL;
|
|
@@ -206,20 +197,14 @@ export function assertProjectDatabaseAccessCredential(
|
|
|
206
197
|
throw new TypeError("Invalid database access credential");
|
|
207
198
|
}
|
|
208
199
|
if (
|
|
209
|
-
|
|
210
|
-
? !["postgres:", "postgresql:"].includes(parsed.protocol)
|
|
211
|
-
: parsed.protocol !== "postgresql:") ||
|
|
200
|
+
!["postgres:", "postgresql:"].includes(parsed.protocol) ||
|
|
212
201
|
decodeURIComponent(parsed.username) !== value["role_name"] ||
|
|
213
202
|
parsed.password === "" ||
|
|
214
203
|
parsed.hostname !== value["host"] ||
|
|
215
|
-
(
|
|
216
|
-
? parsed.port !== "" && parsed.port !== "5432"
|
|
217
|
-
: parsed.host !== value["host"]) ||
|
|
204
|
+
(parsed.port !== "" && parsed.port !== "5432") ||
|
|
218
205
|
decodeURIComponent(parsed.pathname.slice(1)) !== value["database"] ||
|
|
219
206
|
parsed.hash !== "" ||
|
|
220
|
-
|
|
221
|
-
? !["", "?sslmode=require", "?sslmode=verify-full"].includes(parsed.search)
|
|
222
|
-
: parsed.search !== "?sslmode=require")
|
|
207
|
+
!["", "?sslmode=require", "?sslmode=verify-full"].includes(parsed.search)
|
|
223
208
|
)
|
|
224
209
|
throw new TypeError("Invalid database access credential");
|
|
225
210
|
}
|
|
@@ -235,11 +220,6 @@ export function assertProjectDatabaseAccessPage(
|
|
|
235
220
|
throw new TypeError("Invalid database access page");
|
|
236
221
|
for (const item of value["items"]) assertProjectDatabaseAccess(item);
|
|
237
222
|
}
|
|
238
|
-
function accessKeys(value: Record<string, unknown>): readonly string[] {
|
|
239
|
-
return value["provider"] === "pgcf"
|
|
240
|
-
? [...ACCESS_KEYS, "provider", "transport", "websocket_url"]
|
|
241
|
-
: ACCESS_KEYS;
|
|
242
|
-
}
|
|
243
223
|
function assertAccessFields(value: Record<string, unknown>): void {
|
|
244
224
|
const revoked = value["revoked_at"],
|
|
245
225
|
reason = value["revocation_reason"];
|
|
@@ -252,12 +232,11 @@ function assertAccessFields(value: Record<string, unknown>): void {
|
|
|
252
232
|
!ACCESS_ROLE_PATTERN.test(value["role_name"]) ||
|
|
253
233
|
typeof value["host"] !== "string" ||
|
|
254
234
|
!/^[a-z0-9]([a-z0-9.-]{0,251}[a-z0-9])?$/u.test(value["host"]) ||
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
: value["database"] !== "neondb") ||
|
|
235
|
+
value["provider"] !== "pgcf" ||
|
|
236
|
+
value["transport"] !== "wss" ||
|
|
237
|
+
value["websocket_url"] !== `wss://${value["host"]}/` ||
|
|
238
|
+
typeof value["database"] !== "string" ||
|
|
239
|
+
!/^[a-z][a-z0-9]{19}$/u.test(value["database"]) ||
|
|
261
240
|
(value["label"] !== null && accessLabel(value["label"]) !== value["label"]) ||
|
|
262
241
|
!["active", "expired", "revoked"].includes(String(value["state"])) ||
|
|
263
242
|
!timestamp(value["issued_at"]) ||
|