@amerged/ohmyhost-sdk 0.1.35 → 0.1.37
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/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/sdk.gen.d.ts +184 -1
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/sdk.gen.js +459 -0
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/shared-mail-response.d.ts +10 -0
- package/dist/generated/shared-mail-response.d.ts.map +1 -0
- package/dist/generated/shared-mail-response.js +220 -0
- package/dist/generated/shared-mail-response.js.map +1 -0
- package/dist/generated/types.gen.d.ts +1079 -1
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/shared-mail-response.d.ts +2 -0
- package/dist/shared-mail-response.d.ts.map +1 -0
- package/dist/shared-mail-response.js +2 -0
- package/dist/shared-mail-response.js.map +1 -0
- package/dist/shared-mail.d.ts +62 -0
- package/dist/shared-mail.d.ts.map +1 -0
- package/dist/shared-mail.js +125 -0
- package/dist/shared-mail.js.map +1 -0
- package/package.json +1 -1
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/index.ts +112 -0
- package/src/packages/sdk-ts/src/generated/sdk.gen.ts +870 -0
- package/src/packages/sdk-ts/src/generated/shared-mail-response.ts +238 -0
- package/src/packages/sdk-ts/src/generated/types.gen.ts +1208 -0
- package/src/packages/sdk-ts/src/index.ts +2 -0
- package/src/packages/sdk-ts/src/shared-mail-response.ts +1 -0
- package/src/packages/sdk-ts/src/shared-mail.ts +225 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// Generated from packages/contracts/src/shared-mail.ts by scripts/generate-sdk-ts.mjs.
|
|
2
|
+
// Canonical SHA-256: 5337c8bef2db195ba7235a963c5e2f5c72bf0724514240ddf77ec271a73f516b
|
|
3
|
+
export interface SharedMailResponseContext {
|
|
4
|
+
readonly action: string;
|
|
5
|
+
readonly organizationId?: string;
|
|
6
|
+
readonly projectId?: string;
|
|
7
|
+
readonly environmentId?: string;
|
|
8
|
+
readonly mailDomainId?: string;
|
|
9
|
+
}
|
|
10
|
+
const ULID = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/u;
|
|
11
|
+
const HOST = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/u;
|
|
12
|
+
|
|
13
|
+
/** Strict validation keeps provider data and out-of-scope resources out of client guidance. */
|
|
14
|
+
export function assertSharedMailResponse(value: unknown, input: SharedMailResponseContext): void {
|
|
15
|
+
const v = object(value);
|
|
16
|
+
if (input.action === "domains_list") {
|
|
17
|
+
exact(v, ["items"]);
|
|
18
|
+
if (!Array.isArray(v["items"]) || v["items"].length > 100) invalid();
|
|
19
|
+
for (const item of v["items"])
|
|
20
|
+
assertSharedMailResponse(item, {
|
|
21
|
+
...input,
|
|
22
|
+
action: "domain_get",
|
|
23
|
+
mailDomainId: String(object(item)["domain_id"]),
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (["domain_get", "domain_create", "domain_retire"].includes(input.action)) {
|
|
28
|
+
exact(v, [
|
|
29
|
+
"domain_id",
|
|
30
|
+
"organization_id",
|
|
31
|
+
"domain",
|
|
32
|
+
"registrable_domain",
|
|
33
|
+
"revision",
|
|
34
|
+
"status",
|
|
35
|
+
"sending",
|
|
36
|
+
"receiving",
|
|
37
|
+
"configured_at",
|
|
38
|
+
"observed_at",
|
|
39
|
+
"dns_records",
|
|
40
|
+
"bindings_count",
|
|
41
|
+
]);
|
|
42
|
+
id(v["domain_id"]);
|
|
43
|
+
id(v["organization_id"]);
|
|
44
|
+
if (
|
|
45
|
+
!("organizationId" in input) ||
|
|
46
|
+
v["organization_id"] !== input.organizationId ||
|
|
47
|
+
("mailDomainId" in input && v["domain_id"] !== input.mailDomainId)
|
|
48
|
+
)
|
|
49
|
+
invalid();
|
|
50
|
+
host(v["domain"]);
|
|
51
|
+
host(v["registrable_domain"]);
|
|
52
|
+
positive(v["revision"]);
|
|
53
|
+
member(v["status"], ["active", "retiring", "retired"]);
|
|
54
|
+
for (const k of ["sending", "receiving"])
|
|
55
|
+
member(v[k], ["disabled", "pending", "ready", "failed"]);
|
|
56
|
+
time(v["configured_at"]);
|
|
57
|
+
if (v["observed_at"] !== null) time(v["observed_at"]);
|
|
58
|
+
if (!Number.isSafeInteger(v["bindings_count"]) || Number(v["bindings_count"]) < 0) invalid();
|
|
59
|
+
if (!Array.isArray(v["dns_records"])) invalid();
|
|
60
|
+
for (const entry of v["dns_records"]) {
|
|
61
|
+
const r = object(entry);
|
|
62
|
+
exact(r, ["type", "name", "value", "purpose", "status"], ["priority"]);
|
|
63
|
+
member(r["type"], ["TXT", "MX", "CNAME"]);
|
|
64
|
+
for (const k of ["name", "value", "purpose", "status"])
|
|
65
|
+
if (typeof r[k] !== "string" || /[\r\n\0]/u.test(r[k])) invalid();
|
|
66
|
+
if (
|
|
67
|
+
r["priority"] !== undefined &&
|
|
68
|
+
(!Number.isSafeInteger(r["priority"]) ||
|
|
69
|
+
Number(r["priority"]) < 0 ||
|
|
70
|
+
Number(r["priority"]) > 65535)
|
|
71
|
+
)
|
|
72
|
+
invalid();
|
|
73
|
+
if (r["type"] === "MX" && r["priority"] === undefined) invalid();
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (["binding_get", "binding_set", "binding_detach"].includes(input.action)) {
|
|
78
|
+
exact(v, [
|
|
79
|
+
"mail_domain_id",
|
|
80
|
+
"organization_id",
|
|
81
|
+
"project_id",
|
|
82
|
+
"environment_id",
|
|
83
|
+
"revision",
|
|
84
|
+
"sending",
|
|
85
|
+
"sender_addresses",
|
|
86
|
+
"default_from",
|
|
87
|
+
"default_reply_to",
|
|
88
|
+
"legacy",
|
|
89
|
+
"status",
|
|
90
|
+
"application_domain_identity",
|
|
91
|
+
]);
|
|
92
|
+
for (const k of ["mail_domain_id", "organization_id", "project_id", "environment_id"]) id(v[k]);
|
|
93
|
+
if (
|
|
94
|
+
!("projectId" in input) ||
|
|
95
|
+
!("environmentId" in input) ||
|
|
96
|
+
v["project_id"] !== input.projectId ||
|
|
97
|
+
v["environment_id"] !== input.environmentId ||
|
|
98
|
+
("mailDomainId" in input && v["mail_domain_id"] !== input.mailDomainId)
|
|
99
|
+
)
|
|
100
|
+
invalid();
|
|
101
|
+
positive(v["revision"]);
|
|
102
|
+
for (const k of ["sending", "legacy"]) if (typeof v[k] !== "boolean") invalid();
|
|
103
|
+
member(v["status"], ["active", "detached", "suspended"]);
|
|
104
|
+
if (
|
|
105
|
+
!Array.isArray(v["sender_addresses"]) ||
|
|
106
|
+
v["sender_addresses"].length > 32 ||
|
|
107
|
+
new Set(v["sender_addresses"]).size !== v["sender_addresses"].length
|
|
108
|
+
)
|
|
109
|
+
invalid();
|
|
110
|
+
for (const a of v["sender_addresses"]) mailbox(a);
|
|
111
|
+
for (const k of ["default_from", "default_reply_to"]) if (v[k] !== null) mailbox(v[k]);
|
|
112
|
+
if (
|
|
113
|
+
!v["legacy"] &&
|
|
114
|
+
(!v["sender_addresses"].includes(v["default_from"]) || v["sender_addresses"].length === 0)
|
|
115
|
+
)
|
|
116
|
+
invalid();
|
|
117
|
+
if (v["application_domain_identity"] !== null) {
|
|
118
|
+
const identity = object(v["application_domain_identity"]);
|
|
119
|
+
exact(identity, ["hostname", "registrable_domain", "revision", "status"]);
|
|
120
|
+
host(identity["hostname"]);
|
|
121
|
+
host(identity["registrable_domain"]);
|
|
122
|
+
positive(identity["revision"]);
|
|
123
|
+
member(identity["status"], ["pending", "verified", "expired", "revoked"]);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (
|
|
128
|
+
["identity_get", "identity_declare", "identity_verify", "identity_revoke"].includes(
|
|
129
|
+
input.action,
|
|
130
|
+
)
|
|
131
|
+
) {
|
|
132
|
+
exact(v, [
|
|
133
|
+
"organization_id",
|
|
134
|
+
"project_id",
|
|
135
|
+
"hostname",
|
|
136
|
+
"registrable_domain",
|
|
137
|
+
"status",
|
|
138
|
+
"revision",
|
|
139
|
+
"challenge",
|
|
140
|
+
"verified_at",
|
|
141
|
+
"expires_at",
|
|
142
|
+
]);
|
|
143
|
+
id(v["organization_id"]);
|
|
144
|
+
id(v["project_id"]);
|
|
145
|
+
if (!("projectId" in input) || v["project_id"] !== input.projectId) invalid();
|
|
146
|
+
host(v["hostname"]);
|
|
147
|
+
host(v["registrable_domain"]);
|
|
148
|
+
positive(v["revision"]);
|
|
149
|
+
member(v["status"], ["pending", "verified", "expired", "revoked"]);
|
|
150
|
+
const challenge = object(v["challenge"]);
|
|
151
|
+
exact(challenge, ["type", "name", "value"]);
|
|
152
|
+
if (
|
|
153
|
+
challenge["type"] !== "TXT" ||
|
|
154
|
+
typeof challenge["name"] !== "string" ||
|
|
155
|
+
challenge["name"] !== `_omh-project.${v["hostname"]}` ||
|
|
156
|
+
typeof challenge["value"] !== "string" ||
|
|
157
|
+
challenge["value"].length < 16 ||
|
|
158
|
+
challenge["value"].length > 255 ||
|
|
159
|
+
/[\r\n\0]/u.test(challenge["value"])
|
|
160
|
+
)
|
|
161
|
+
invalid();
|
|
162
|
+
if (v["verified_at"] !== null) time(v["verified_at"]);
|
|
163
|
+
time(v["expires_at"]);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (input.action === "domain_dns_authorize" || input.action === "identity_authorize") {
|
|
167
|
+
exact(v, ["authorization_id", "authorization_url", "expires_at"]);
|
|
168
|
+
id(v["authorization_id"]);
|
|
169
|
+
time(v["expires_at"]);
|
|
170
|
+
if (
|
|
171
|
+
typeof v["authorization_url"] !== "string" ||
|
|
172
|
+
!/^https:\/\/dash\.cloudflare\.com\/oauth2\/auth\?/u.test(v["authorization_url"])
|
|
173
|
+
)
|
|
174
|
+
invalid();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
exact(v, ["status", "zone", "scopes", "expires_at"]);
|
|
178
|
+
member(v["status"], ["not_authorized", "pending", "authorized", "expired", "revoked"]);
|
|
179
|
+
if (
|
|
180
|
+
!Array.isArray(v["scopes"]) ||
|
|
181
|
+
v["scopes"].length > 2 ||
|
|
182
|
+
new Set(v["scopes"]).size !== v["scopes"].length ||
|
|
183
|
+
v["scopes"].some((s) => s !== "dns.write" && s !== "zone.read")
|
|
184
|
+
)
|
|
185
|
+
invalid();
|
|
186
|
+
if (v["zone"] !== null) host(v["zone"]);
|
|
187
|
+
if (v["expires_at"] !== null) time(v["expires_at"]);
|
|
188
|
+
if (
|
|
189
|
+
v["status"] === "not_authorized" &&
|
|
190
|
+
(v["zone"] !== null || v["expires_at"] !== null || v["scopes"].length)
|
|
191
|
+
)
|
|
192
|
+
invalid();
|
|
193
|
+
}
|
|
194
|
+
function object(v: unknown): Record<string, unknown> {
|
|
195
|
+
if (v === null || typeof v !== "object" || Array.isArray(v)) invalid();
|
|
196
|
+
return v as Record<string, unknown>;
|
|
197
|
+
}
|
|
198
|
+
function exact(
|
|
199
|
+
v: Record<string, unknown>,
|
|
200
|
+
required: readonly string[],
|
|
201
|
+
optional: readonly string[] = [],
|
|
202
|
+
) {
|
|
203
|
+
if (
|
|
204
|
+
required.some((k) => !(k in v)) ||
|
|
205
|
+
Object.keys(v).some((k) => !required.includes(k) && !optional.includes(k))
|
|
206
|
+
)
|
|
207
|
+
invalid();
|
|
208
|
+
}
|
|
209
|
+
function member(v: unknown, values: readonly string[]) {
|
|
210
|
+
if (typeof v !== "string" || !values.includes(v)) invalid();
|
|
211
|
+
}
|
|
212
|
+
function id(v: unknown) {
|
|
213
|
+
if (typeof v !== "string" || !ULID.test(v)) invalid();
|
|
214
|
+
}
|
|
215
|
+
function host(v: unknown) {
|
|
216
|
+
if (typeof v !== "string" || !HOST.test(v)) invalid();
|
|
217
|
+
}
|
|
218
|
+
function positive(v: unknown) {
|
|
219
|
+
if (!Number.isSafeInteger(v) || Number(v) < 1) invalid();
|
|
220
|
+
}
|
|
221
|
+
function time(v: unknown) {
|
|
222
|
+
if (typeof v !== "string" || !Number.isFinite(Date.parse(v)) || new Date(v).toISOString() !== v)
|
|
223
|
+
invalid();
|
|
224
|
+
}
|
|
225
|
+
function mailbox(v: unknown) {
|
|
226
|
+
if (
|
|
227
|
+
typeof v !== "string" ||
|
|
228
|
+
v.length > 254 ||
|
|
229
|
+
!/^[A-Za-z0-9.!#$%&'*+\-/=?^_`{|}~]+@[a-z0-9.-]+\.[a-z]{2,63}$/u.test(v) ||
|
|
230
|
+
v.startsWith(".") ||
|
|
231
|
+
v.includes("..") ||
|
|
232
|
+
v.includes(".@")
|
|
233
|
+
)
|
|
234
|
+
invalid();
|
|
235
|
+
}
|
|
236
|
+
function invalid(): never {
|
|
237
|
+
throw new TypeError("Shared mail response contract invalid");
|
|
238
|
+
}
|