fn(worker_name$0, database_name$1, database_id$17, cron$2, api_token$3, script_url$11, wasm$40) =>
#handle<@wasi.io>({
request: @http.request-of-url(
method: "PUT",
url: $11,
headers: [{name: "Content-Type", value: "multipart/form-data; boundary=definy-deploy-boundary-5f0c3a"}],
body: @definy.cloudflare-service-upload-body(database_id: $17, wasm: $40)
),
secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $3}],
then: fn(result$18) =>
match $18 {
#error(error$19) =>
#done<@wasi.io>(@core.string-concat(left: "アップロードできませんでした: ", right: @http.error-text(error: $19))),
#ok(response$20) =>
match @core.less-than(left: $20.status, right: 300) {
false =>
#done<@wasi.io>(@core.string-concat(left: "アップロードできませんでした: ", right: @http.body-text(response: $20))),
true =>
#handle<@wasi.io>({
request: @http.request-of-url(
method: "POST",
url: @std.string-join(
items: [
@core.string-slice(
value: $11,
start: 0,
end: @core.string-index-of(text: $11, target: "/workers/scripts/", start: 0)
),
"/d1/database/",
$17,
"/query"
],
separator: ""
),
headers: [{name: "Content-Type", value: "application/json"}],
body: @core.string-to-bytes(value: "{\"sql\":\"DROP TABLE IF EXISTS host_cache\"}")
),
secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $3}],
then: fn(result$25) =>
#handle<@wasi.io>({
request: @http.request-of-url(
method: "PUT",
url: @core.string-concat(left: $11, right: "/schedules"),
headers: [{name: "Content-Type", value: "application/json"}],
body: @core.string-to-bytes(
value: @std.string-join(items: ["[{\"cron\":", @definy.json-string-literal(value: $2), "}]"], separator: "")
)
),
secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $3}],
then: fn(result$21) =>
#handle<@wasi.io>({
request: @http.request-of-url(
method: "POST",
url: @core.string-concat(left: $11, right: "/subdomain"),
headers: [{name: "Content-Type", value: "application/json"}],
body: @core.string-to-bytes(value: "{\"enabled\":true}")
),
secret_headers: [{name: "Authorization", prefix: "Bearer ", secret: $3}],
then: fn(result$22) =>
#done<@wasi.io>(@std.string-join(
items: [
"デプロイしました: ",
$0,
" (D1: ",
$1,
", Cron: ",
$2,
match $21 {
#ok(schedules$23) =>
match @core.less-than(left: $23.status, right: 300) {
true =>
"",
false =>
@core.string-concat(left: ". Cron を設定できませんでした: ", right: @http.body-text(response: $23))
},
#error(error$24) =>
@core.string-concat(left: ". Cron を設定できませんでした: ", right: @http.error-text(error: $24))
},
match $25 {
#ok(cleared$26) =>
match @core.less-than(left: $26.status, right: 300) {
true =>
"",
false =>
@core.string-concat(
left: ". 読み取りのキャッシュ (D1 の host_cache) を消せませんでした: ",
right: @http.body-text(response: $26)
)
},
#error(error$27) =>
@core.string-concat(
left: ". 読み取りのキャッシュ (D1 の host_cache) を消せませんでした: ",
right: @http.error-text(error: $27)
)
},
")"
],
separator: ""
))
})
})
})
}
}
})