@amerged/ohmyhost-cli 0.1.37 → 0.1.39

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +27 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/{chunk-IHXNADOQ.js → chunk-R2BC42EW.js} +4501 -134
  5. package/dist/index.js +1 -1
  6. package/dist/licenses/pgcf-bridge-LICENSE +201 -0
  7. package/dist/licenses/pgcf-bridge-NOTICE +1 -0
  8. package/package.json +1 -1
  9. package/src/apps/product-cli/package.json +4 -3
  10. package/src/apps/product-cli/src/cli.ts +7 -5
  11. package/src/apps/product-cli/src/command.ts +18 -5
  12. package/src/apps/product-cli/src/product-api.ts +22 -15
  13. package/src/apps/product-cli/src/psql-session.ts +54 -19
  14. package/src/apps/product-cli/src/repository-init.ts +181 -9
  15. package/src/packages/contracts/package.json +6 -1
  16. package/src/packages/contracts/src/credit-pricing.ts +7 -1
  17. package/src/packages/contracts/src/database-access.ts +53 -12
  18. package/src/packages/contracts/src/database-compute.ts +66 -11
  19. package/src/packages/contracts/src/database-sizes.ts +114 -0
  20. package/src/packages/contracts/src/framework-admission-corpus.ts +15 -18
  21. package/src/packages/contracts/src/framework-build-script.mjs +10 -3
  22. package/src/packages/contracts/src/index.ts +3 -0
  23. package/src/packages/contracts/src/operation-failure.ts +2 -2
  24. package/src/packages/contracts/src/platform-origins.ts +8 -0
  25. package/src/packages/contracts/src/problem-policy.ts +16 -2
  26. package/src/packages/contracts/src/storage-gateway-origin.ts +93 -0
  27. package/src/packages/postgres-bridge/LICENSE +201 -0
  28. package/src/packages/postgres-bridge/NOTICE +1 -0
  29. package/src/packages/postgres-bridge/package.json +26 -0
  30. package/src/packages/postgres-bridge/src/auth.ts +159 -0
  31. package/src/packages/postgres-bridge/src/bridge.ts +168 -0
  32. package/src/packages/postgres-bridge/src/index.ts +2 -0
  33. package/src/packages/postgres-bridge/src/options.ts +49 -0
  34. package/src/packages/sdk-ts/package.json +2 -2
  35. package/src/packages/sdk-ts/src/generated/index.ts +1 -0
  36. package/src/packages/sdk-ts/src/generated/sdk.gen.ts +9 -8
  37. package/src/packages/sdk-ts/src/generated/types.gen.ts +91 -24
  38. package/src/packages/sdk-ts/src/index.ts +1 -0
  39. package/src/packages/sdk-ts/src/managed-mail-attachment.ts +107 -0
  40. package/src/packages/workos-auth-contracts/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ import type { Client } from "./generated/client/index.js";
2
+ import { getManagedMailAttachment } from "./generated/sdk.gen.js";
3
+
4
+ export interface ManagedMailAttachmentDownload {
5
+ readonly projectId: string;
6
+ readonly environmentId: string;
7
+ readonly messageId: string;
8
+ readonly attachmentId: string;
9
+ readonly signal?: AbortSignal;
10
+ }
11
+
12
+ export type ManagedMailAttachmentResult =
13
+ | Readonly<{ status: "expired" }>
14
+ | Readonly<{ status: "download"; response: Response; body: ReadableStream<Uint8Array> }>;
15
+
16
+ /** Uses the generated authenticated GET without its automatic binary-to-Blob parser. */
17
+ export async function downloadManagedMailAttachment(
18
+ client: Client,
19
+ input: ManagedMailAttachmentDownload,
20
+ ): Promise<ManagedMailAttachmentResult> {
21
+ if (
22
+ ![input.projectId, input.environmentId, input.messageId].every((id) =>
23
+ /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/u.test(id),
24
+ ) ||
25
+ !/^[A-Za-z0-9_-]{1,128}$/u.test(input.attachmentId)
26
+ )
27
+ invalid();
28
+ // The generator's return type is fixed to data-only, despite supporting this explicit fields option.
29
+ const result = (await getManagedMailAttachment(
30
+ {
31
+ project_id: input.projectId,
32
+ environment_id: input.environmentId,
33
+ message_id: input.messageId,
34
+ attachment_id: input.attachmentId,
35
+ },
36
+ {
37
+ client,
38
+ parseAs: "stream",
39
+ responseStyle: "fields",
40
+ throwOnError: true,
41
+ signal: input.signal,
42
+ },
43
+ )) as unknown as { response: Response; data: unknown };
44
+ const response = result.response;
45
+ if (
46
+ !(response instanceof Response) ||
47
+ response.status !== 200 ||
48
+ response.body === null ||
49
+ result.data !== response.body
50
+ )
51
+ invalid();
52
+ const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
53
+ if (contentType === "application/octet-stream") {
54
+ return Object.freeze({ status: "download", response, body: response.body });
55
+ }
56
+ if (contentType !== "application/json") {
57
+ void response.body.cancel().catch(ignoreCancellationError);
58
+ invalid();
59
+ }
60
+ const declared = response.headers.get("content-length");
61
+ if (declared !== null && (!/^[0-9]+$/u.test(declared) || Number(declared) > 1024)) {
62
+ void response.body.cancel().catch(ignoreCancellationError);
63
+ invalid();
64
+ }
65
+ const reader = response.body.getReader();
66
+ const bytes = new Uint8Array(1024);
67
+ let length = 0;
68
+ let finished = false;
69
+ try {
70
+ for (;;) {
71
+ const next = await reader.read();
72
+ if (next.done) {
73
+ finished = true;
74
+ break;
75
+ }
76
+ if (!(next.value instanceof Uint8Array) || length + next.value.byteLength > bytes.byteLength)
77
+ invalid();
78
+ bytes.set(next.value, length);
79
+ length += next.value.byteLength;
80
+ }
81
+ const value: unknown = JSON.parse(
82
+ new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, length)),
83
+ );
84
+ if (
85
+ typeof value !== "object" ||
86
+ value === null ||
87
+ Array.isArray(value) ||
88
+ Object.keys(value).length !== 1 ||
89
+ (value as Record<string, unknown>)["status"] !== "expired"
90
+ )
91
+ invalid();
92
+ return Object.freeze({ status: "expired" });
93
+ } catch {
94
+ return invalid();
95
+ } finally {
96
+ if (!finished) void reader.cancel().catch(ignoreCancellationError);
97
+ reader.releaseLock();
98
+ }
99
+ }
100
+
101
+ function invalid(): never {
102
+ throw new Error("Mail attachment response contract invalid");
103
+ }
104
+
105
+ function ignoreCancellationError(): void {
106
+ // Cleanup cannot replace the response contract failure.
107
+ }
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsc --project tsconfig.build.json",
35
- "typecheck": "tsc --project tsconfig.json --noEmit",
35
+ "typecheck": "tsc --project tsconfig.json --noEmit --incremental --tsBuildInfoFile typecheck.tsbuildinfo",
36
36
  "test": "vitest run --root ../.. packages/workos-auth-contracts/src"
37
37
  },
38
38
  "license": "Apache-2.0"