@package-broker/cli 0.19.8 → 2.0.0-rc.2
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/LICENSE +661 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +12 -0
- package/dist/bin.js.map +1 -0
- package/dist/build-artifacts.d.ts +27 -0
- package/dist/build-artifacts.d.ts.map +1 -0
- package/dist/build-artifacts.js +169 -0
- package/dist/build-artifacts.js.map +1 -0
- package/dist/build-assets.d.ts +36 -0
- package/dist/build-assets.d.ts.map +1 -0
- package/dist/build-assets.js +224 -0
- package/dist/build-assets.js.map +1 -0
- package/dist/build.d.ts +31 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +277 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +828 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloudflare/d1-http-executor.d.ts +30 -0
- package/dist/cloudflare/d1-http-executor.d.ts.map +1 -0
- package/dist/cloudflare/d1-http-executor.js +230 -0
- package/dist/cloudflare/d1-http-executor.js.map +1 -0
- package/dist/cloudflare/d1-http-response.d.ts +4 -0
- package/dist/cloudflare/d1-http-response.d.ts.map +1 -0
- package/dist/cloudflare/d1-http-response.js +113 -0
- package/dist/cloudflare/d1-http-response.js.map +1 -0
- package/dist/commands/admin.d.ts +47 -0
- package/dist/commands/admin.d.ts.map +1 -0
- package/dist/commands/admin.js +447 -0
- package/dist/commands/admin.js.map +1 -0
- package/dist/commands/built-manifest.d.ts +13 -0
- package/dist/commands/built-manifest.d.ts.map +1 -0
- package/dist/commands/built-manifest.js +197 -0
- package/dist/commands/built-manifest.js.map +1 -0
- package/dist/commands/cloudflare/api.d.ts +132 -0
- package/dist/commands/cloudflare/api.d.ts.map +1 -0
- package/dist/commands/cloudflare/api.js +502 -0
- package/dist/commands/cloudflare/api.js.map +1 -0
- package/dist/commands/cloudflare/deploy.d.ts +111 -0
- package/dist/commands/cloudflare/deploy.d.ts.map +1 -0
- package/dist/commands/cloudflare/deploy.js +2170 -0
- package/dist/commands/cloudflare/deploy.js.map +1 -0
- package/dist/commands/cloudflare/inventory.d.ts +257 -0
- package/dist/commands/cloudflare/inventory.d.ts.map +1 -0
- package/dist/commands/cloudflare/inventory.js +842 -0
- package/dist/commands/cloudflare/inventory.js.map +1 -0
- package/dist/commands/cloudflare/janitor.d.ts +10 -0
- package/dist/commands/cloudflare/janitor.d.ts.map +1 -0
- package/dist/commands/cloudflare/janitor.js +84 -0
- package/dist/commands/cloudflare/janitor.js.map +1 -0
- package/dist/commands/cloudflare/migrations-check.d.ts +5 -0
- package/dist/commands/cloudflare/migrations-check.d.ts.map +1 -0
- package/dist/commands/cloudflare/migrations-check.js +10 -0
- package/dist/commands/cloudflare/migrations-check.js.map +1 -0
- package/dist/commands/cloudflare/providers-file.d.ts +17 -0
- package/dist/commands/cloudflare/providers-file.d.ts.map +1 -0
- package/dist/commands/cloudflare/providers-file.js +155 -0
- package/dist/commands/cloudflare/providers-file.js.map +1 -0
- package/dist/commands/cloudflare/provision.d.ts +79 -0
- package/dist/commands/cloudflare/provision.d.ts.map +1 -0
- package/dist/commands/cloudflare/provision.js +961 -0
- package/dist/commands/cloudflare/provision.js.map +1 -0
- package/dist/commands/cloudflare/queue-consumer.d.ts +4 -0
- package/dist/commands/cloudflare/queue-consumer.d.ts.map +1 -0
- package/dist/commands/cloudflare/queue-consumer.js +57 -0
- package/dist/commands/cloudflare/queue-consumer.js.map +1 -0
- package/dist/commands/cloudflare/routes.d.ts +3 -0
- package/dist/commands/cloudflare/routes.d.ts.map +1 -0
- package/dist/commands/cloudflare/routes.js +26 -0
- package/dist/commands/cloudflare/routes.js.map +1 -0
- package/dist/commands/cloudflare/setup.d.ts +50 -0
- package/dist/commands/cloudflare/setup.d.ts.map +1 -0
- package/dist/commands/cloudflare/setup.js +836 -0
- package/dist/commands/cloudflare/setup.js.map +1 -0
- package/dist/commands/cloudflare/smoke.d.ts +29 -0
- package/dist/commands/cloudflare/smoke.d.ts.map +1 -0
- package/dist/commands/cloudflare/smoke.js +701 -0
- package/dist/commands/cloudflare/smoke.js.map +1 -0
- package/dist/commands/cloudflare/teardown.d.ts +65 -0
- package/dist/commands/cloudflare/teardown.d.ts.map +1 -0
- package/dist/commands/cloudflare/teardown.js +984 -0
- package/dist/commands/cloudflare/teardown.js.map +1 -0
- package/dist/commands/cloudflare/worker-settings.d.ts +4 -0
- package/dist/commands/cloudflare/worker-settings.d.ts.map +1 -0
- package/dist/commands/cloudflare/worker-settings.js +93 -0
- package/dist/commands/cloudflare/worker-settings.js.map +1 -0
- package/dist/commands/cloudflare/zone.d.ts +3 -0
- package/dist/commands/cloudflare/zone.d.ts.map +1 -0
- package/dist/commands/cloudflare/zone.js +73 -0
- package/dist/commands/cloudflare/zone.js.map +1 -0
- package/dist/commands/cloudflare.d.ts +55 -0
- package/dist/commands/cloudflare.d.ts.map +1 -0
- package/dist/commands/cloudflare.js +393 -0
- package/dist/commands/cloudflare.js.map +1 -0
- package/dist/commands/import-cutover.d.ts +5 -0
- package/dist/commands/import-cutover.d.ts.map +1 -0
- package/dist/commands/import-cutover.js +25 -0
- package/dist/commands/import-cutover.js.map +1 -0
- package/dist/commands/import-private-packagist.d.ts +38 -0
- package/dist/commands/import-private-packagist.d.ts.map +1 -0
- package/dist/commands/import-private-packagist.js +232 -0
- package/dist/commands/import-private-packagist.js.map +1 -0
- package/dist/commands/import-satis.d.ts +11 -0
- package/dist/commands/import-satis.d.ts.map +1 -0
- package/dist/commands/import-satis.js +112 -0
- package/dist/commands/import-satis.js.map +1 -0
- package/dist/commands/import.d.ts +22 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +343 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/openapi-specs.d.ts +4 -0
- package/dist/commands/openapi-specs.d.ts.map +1 -0
- package/dist/commands/openapi-specs.js +94 -0
- package/dist/commands/openapi-specs.js.map +1 -0
- package/dist/commands/openapi.d.ts +12 -0
- package/dist/commands/openapi.d.ts.map +1 -0
- package/dist/commands/openapi.js +44 -0
- package/dist/commands/openapi.js.map +1 -0
- package/dist/commands/source.d.ts +8 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +61 -0
- package/dist/commands/source.js.map +1 -0
- package/dist/commands/sqlite.d.ts +11 -0
- package/dist/commands/sqlite.d.ts.map +1 -0
- package/dist/commands/sqlite.js +76 -0
- package/dist/commands/sqlite.js.map +1 -0
- package/dist/import/client.d.ts +71 -0
- package/dist/import/client.d.ts.map +1 -0
- package/dist/import/client.js +348 -0
- package/dist/import/client.js.map +1 -0
- package/dist/import/credential-refs.d.ts +2 -0
- package/dist/import/credential-refs.d.ts.map +1 -0
- package/dist/import/credential-refs.js +22 -0
- package/dist/import/credential-refs.js.map +1 -0
- package/dist/import/cutover.d.ts +64 -0
- package/dist/import/cutover.d.ts.map +1 -0
- package/dist/import/cutover.js +544 -0
- package/dist/import/cutover.js.map +1 -0
- package/dist/import/private-packagist/api.d.ts +57 -0
- package/dist/import/private-packagist/api.d.ts.map +1 -0
- package/dist/import/private-packagist/api.js +246 -0
- package/dist/import/private-packagist/api.js.map +1 -0
- package/dist/import/private-packagist/dates.d.ts +30 -0
- package/dist/import/private-packagist/dates.d.ts.map +1 -0
- package/dist/import/private-packagist/dates.js +189 -0
- package/dist/import/private-packagist/dates.js.map +1 -0
- package/dist/import/private-packagist/map.d.ts +48 -0
- package/dist/import/private-packagist/map.d.ts.map +1 -0
- package/dist/import/private-packagist/map.js +162 -0
- package/dist/import/private-packagist/map.js.map +1 -0
- package/dist/import/private-packagist/plan.d.ts +61 -0
- package/dist/import/private-packagist/plan.d.ts.map +1 -0
- package/dist/import/private-packagist/plan.js +936 -0
- package/dist/import/private-packagist/plan.js.map +1 -0
- package/dist/import/private-packagist/snapshot.d.ts +31 -0
- package/dist/import/private-packagist/snapshot.d.ts.map +1 -0
- package/dist/import/private-packagist/snapshot.js +406 -0
- package/dist/import/private-packagist/snapshot.js.map +1 -0
- package/dist/import/satis.d.ts +93 -0
- package/dist/import/satis.d.ts.map +1 -0
- package/dist/import/satis.js +873 -0
- package/dist/import/satis.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -96
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +56 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +137 -0
- package/dist/manifest.js.map +1 -0
- package/dist/migrations-collect.d.ts +6 -0
- package/dist/migrations-collect.d.ts.map +1 -0
- package/dist/migrations-collect.js +39 -0
- package/dist/migrations-collect.js.map +1 -0
- package/dist/prebuilt-expected.json +7 -0
- package/dist/prebuilt.d.ts +27 -0
- package/dist/prebuilt.d.ts.map +1 -0
- package/dist/prebuilt.js +391 -0
- package/dist/prebuilt.js.map +1 -0
- package/package.json +22 -25
- package/README.md +0 -29
- package/dist/__tests__/migrate.test.d.ts +0 -2
- package/dist/__tests__/migrate.test.d.ts.map +0 -1
- package/dist/__tests__/migrate.test.js +0 -116
- package/dist/__tests__/migrate.test.js.map +0 -1
- package/dist/migrate.d.ts +0 -40
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -335
- package/dist/migrate.js.map +0 -1
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
const GUIDANCE = 'Workers Paid with Queues is the supported target. Enable the required service, verify token permissions, then rerun pb cloudflare setup. Resources were not created. For a different deployment target, use the documented single-replica Node installation.';
|
|
2
|
+
const MESSAGES = {
|
|
3
|
+
prebuilt_invalid: 'Prebuilt metadata is invalid; reinstall trusted packages.',
|
|
4
|
+
prebuilt_dirty: 'Prebuilt build provenance is dirty or unknown; reinstall trusted packages.',
|
|
5
|
+
prebuilt_git_sha_mismatch: 'Prebuilt git SHA does not match its build provenance; reinstall trusted packages.',
|
|
6
|
+
prebuilt_lockfile_mismatch: 'Prebuilt lockfile digest does not match its build provenance; reinstall trusted packages.',
|
|
7
|
+
prebuilt_dependencies_refused: 'Prebuilt packages must not declare dependencies or install hooks; reinstall trusted packages.',
|
|
8
|
+
prebuilt_io_failure: 'Local prebuilt I/O failed; check permissions and free space, then rerun.',
|
|
9
|
+
prebuilt_unavailable: 'Prebuilt package is unavailable; install @package-broker/dist-cloudflare@<cli version> or run without --prebuilt.',
|
|
10
|
+
prebuilt_version_mismatch: 'Prebuilt package version must equal the CLI version.',
|
|
11
|
+
prebuilt_unverifiable: 'The CLI has no expected prebuilt record; use a published CLI package.',
|
|
12
|
+
checksum_mismatch: 'Prebuilt checksum verification failed; reinstall trusted packages.',
|
|
13
|
+
migrations_pending: 'Prebuilt migrations are pending; run pb cloudflare migrate --prebuilt --worker-name <worker name> before deploying.',
|
|
14
|
+
invalid_input: 'Invalid input or incomplete Cloudflare build; build the selected configuration first.',
|
|
15
|
+
unsafe_path: 'State must be ignored, contained, regular and separate from build output.',
|
|
16
|
+
invalid_inventory: 'Inventory identity or journal is invalid; restore trusted private state.',
|
|
17
|
+
state_io_failure: 'Local inventory or lock I/O failed; check permissions and free space of .pb/state/cloudflare and keep the journal. Rerunning reads provider state before any further create.',
|
|
18
|
+
install_locked: 'Install lock exists. Stop all writers, read the lock file in .pb/state/cloudflare for its host, pid and started_at, and only if that process is gone remove that one file by hand, then rerun.',
|
|
19
|
+
confirmation_required: 'Review the create plan and supply --yes for noninteractive creates.',
|
|
20
|
+
confirmation_declined: 'Creation declined; literal yes is required.',
|
|
21
|
+
plan_changed: 'The acknowledged plan changed; inspect provider state and rerun.',
|
|
22
|
+
deadline_exceeded: 'The time budget for safe creates is exhausted; no further create was sent. Rerun to continue.',
|
|
23
|
+
ownership_conflict: 'Exact ownership is unresolved; inspect resources and explicitly adopt the exact ID if appropriate. Nothing is deleted.',
|
|
24
|
+
jurisdiction_conflict: 'Actual jurisdiction is unknown or differs; choose another name or plan a separate migration.',
|
|
25
|
+
configuration_conflict: 'Existing resource configuration differs; inspect and resolve it explicitly.',
|
|
26
|
+
outcome_unknown: 'The create outcome is unknown. Retain private inventory, reconcile or explicitly adopt the exact ID; for a provision create whose resource is authoritatively absent, rerun provision with --abandon-intent <operation id> from the pending_intent check. Do not blindly repeat creation.',
|
|
27
|
+
provider_failure: 'Provider request failed; no raw provider diagnostic is displayed.',
|
|
28
|
+
permission_denied: GUIDANCE,
|
|
29
|
+
capacity_exceeded: GUIDANCE,
|
|
30
|
+
capability_unknown: `Required capability is unresolved. ${GUIDANCE}`,
|
|
31
|
+
domain_zone_not_found: 'No active zone in this account serves the hostname, or the token lacks Zone Read on it. Grant Zone Read, Workers Routes Edit and DNS Edit on that zone.',
|
|
32
|
+
domain_zone_ambiguous: 'Several zones match the hostname; remove the duplicate zone before retrying.',
|
|
33
|
+
domain_zone_not_supported: 'This provider contract does not support hostname-to-zone lookup.',
|
|
34
|
+
queues_unavailable: GUIDANCE,
|
|
35
|
+
workers_paid_required: GUIDANCE,
|
|
36
|
+
workers_dev_subdomain_missing: 'Register a workers.dev subdomain manually in the Cloudflare dashboard, then rerun. No registration was attempted.',
|
|
37
|
+
r2_unavailable: `Enable R2 manually, then rerun. ${GUIDANCE}`,
|
|
38
|
+
analytics_engine_unavailable: GUIDANCE,
|
|
39
|
+
migration_failed: 'Migration failed; inspect the migration state before continuing.',
|
|
40
|
+
smoke_failed: 'Smoke assertions failed; inspect the named checks and rollback result.',
|
|
41
|
+
rollback_blocked_contract: 'A contract migration boundary blocks code rollback; restore or forward repair is required.',
|
|
42
|
+
rollback_unavailable_first_deploy: 'Smoke failed on the first deployment; retain the candidate and resources for forward repair.',
|
|
43
|
+
rollback_failed: 'Rollback activation, configuration or readiness could not be verified.',
|
|
44
|
+
organization_slug_mismatch: 'The existing organization has a different slug.',
|
|
45
|
+
organization_not_found: 'Organization not found; bootstrap the organization first.',
|
|
46
|
+
key_recovery_required: 'Key delivery or installation is uncertain. Supply the saved --key-file or --master-key-env; setup will not generate another key.',
|
|
47
|
+
token_refresh_required: 'Token issuance is uncertain. Use the saved token or explicitly request --refresh-setup-token with safe delivery.',
|
|
48
|
+
provider_anchor_changed: 'A provider definition changes a bound trust anchor; run pb admin rebind-provider first.',
|
|
49
|
+
};
|
|
50
|
+
export class CloudflareError extends Error {
|
|
51
|
+
code;
|
|
52
|
+
exitCode;
|
|
53
|
+
retryable;
|
|
54
|
+
stage;
|
|
55
|
+
status;
|
|
56
|
+
check;
|
|
57
|
+
providerCode;
|
|
58
|
+
source;
|
|
59
|
+
fields;
|
|
60
|
+
constructor(code, exitCode = 1, retryable = false, stage = 'provision', status = null, check = code ===
|
|
61
|
+
'capability_unknown'
|
|
62
|
+
? 'provider_contract'
|
|
63
|
+
: null, providerCode = null, source = null, fields = []) {
|
|
64
|
+
super(MESSAGES[code]);
|
|
65
|
+
this.code = code;
|
|
66
|
+
this.exitCode = exitCode;
|
|
67
|
+
this.retryable = retryable;
|
|
68
|
+
this.stage = stage;
|
|
69
|
+
this.status = status;
|
|
70
|
+
this.check = check;
|
|
71
|
+
this.providerCode = providerCode;
|
|
72
|
+
this.source = source;
|
|
73
|
+
this.fields = fields;
|
|
74
|
+
this.name = 'CloudflareError';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export class GitWorktreeRequiredError extends CloudflareError {
|
|
78
|
+
constructor() {
|
|
79
|
+
super('unsafe_path', 2);
|
|
80
|
+
this.message =
|
|
81
|
+
'State must live in a git work tree that ignores it; run from the project checkout or initialise one.';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function commandEnvelope(command, dryRun = false) {
|
|
85
|
+
const output = {
|
|
86
|
+
schema_version: 1,
|
|
87
|
+
command,
|
|
88
|
+
status: 'ok',
|
|
89
|
+
dry_run: dryRun,
|
|
90
|
+
worker_url: null,
|
|
91
|
+
version_id: null,
|
|
92
|
+
previous_version_id: null,
|
|
93
|
+
database_id: null,
|
|
94
|
+
kv_namespace_id: null,
|
|
95
|
+
r2_bucket: null,
|
|
96
|
+
queue_names: [],
|
|
97
|
+
migrations_applied: [],
|
|
98
|
+
build_info: null,
|
|
99
|
+
artifact_sha256: null,
|
|
100
|
+
pending_migrations: [],
|
|
101
|
+
remote_state: null,
|
|
102
|
+
plan: [],
|
|
103
|
+
checks: [],
|
|
104
|
+
rollback: { status: 'not_needed', target_version_id: null },
|
|
105
|
+
bootstrap_url: null,
|
|
106
|
+
error: null,
|
|
107
|
+
};
|
|
108
|
+
return output;
|
|
109
|
+
}
|
|
110
|
+
export function failCommand(output, error) {
|
|
111
|
+
const safe = error instanceof CloudflareError ? error : new CloudflareError('provider_failure');
|
|
112
|
+
output.status = 'error';
|
|
113
|
+
if (safe.check !== null)
|
|
114
|
+
output.checks.push({
|
|
115
|
+
name: safe.check,
|
|
116
|
+
status: safe.code,
|
|
117
|
+
...(safe.source === null ? {} : { source: safe.source }),
|
|
118
|
+
});
|
|
119
|
+
for (const name of safe.fields)
|
|
120
|
+
output.checks.push({ name, status: safe.code });
|
|
121
|
+
output.error = {
|
|
122
|
+
code: safe.code,
|
|
123
|
+
message: safe.message,
|
|
124
|
+
retryable: safe.retryable,
|
|
125
|
+
stage: safe.stage,
|
|
126
|
+
};
|
|
127
|
+
return { exitCode: safe.exitCode, output };
|
|
128
|
+
}
|
|
129
|
+
function snapshotItems(response) {
|
|
130
|
+
const { result, result_info: info } = response;
|
|
131
|
+
if (!Array.isArray(result))
|
|
132
|
+
throw new CloudflareError('provider_failure');
|
|
133
|
+
if (info &&
|
|
134
|
+
((info.total_pages !== undefined &&
|
|
135
|
+
info.total_pages !== 1 &&
|
|
136
|
+
!(info.total_pages === 0 && result.length === 0)) ||
|
|
137
|
+
(info.cursor !== undefined && info.cursor !== '') ||
|
|
138
|
+
(info.total_count !== undefined && info.total_count !== result.length) ||
|
|
139
|
+
(info.page !== undefined && info.page !== 1) ||
|
|
140
|
+
(info.count !== undefined && info.count !== result.length)))
|
|
141
|
+
throw new CloudflareError('capability_unknown');
|
|
142
|
+
return result.map(object);
|
|
143
|
+
}
|
|
144
|
+
export function object(value) {
|
|
145
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
146
|
+
throw new CloudflareError('provider_failure');
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
export function cloudflareCredentials(env) {
|
|
150
|
+
const apiToken = env.CLOUDFLARE_API_TOKEN;
|
|
151
|
+
const accountId = env.CLOUDFLARE_ACCOUNT_ID;
|
|
152
|
+
if (!apiToken ||
|
|
153
|
+
!/^[\x21-\x7e]+$/.test(apiToken) ||
|
|
154
|
+
!accountId ||
|
|
155
|
+
!/^[a-f0-9]{32}$/.test(accountId)) {
|
|
156
|
+
throw new CloudflareError('invalid_input', 2);
|
|
157
|
+
}
|
|
158
|
+
return { accountId, apiToken };
|
|
159
|
+
}
|
|
160
|
+
// Endpoint families are provisional until T830 verifies the provider wire contract.
|
|
161
|
+
// This client never infers capabilities from provider prose or retries a mutation.
|
|
162
|
+
const BUDGET_MS = 600_000;
|
|
163
|
+
const REQUEST_TIMEOUT_MS = 35_000;
|
|
164
|
+
const RECONCILIATION_MS = 15_000;
|
|
165
|
+
export const CREATE_SETTLE_MS = REQUEST_TIMEOUT_MS + RECONCILIATION_MS;
|
|
166
|
+
const RECOVERY_READS_MS = 60_000;
|
|
167
|
+
const RECOVERY_STEP_MS = CREATE_SETTLE_MS + 20_000;
|
|
168
|
+
const UNSENT = new WeakSet();
|
|
169
|
+
/** True only when the client refused a mutation locally, before any byte reached the transport. */
|
|
170
|
+
export function wasNotSent(error) {
|
|
171
|
+
return error instanceof CloudflareError && UNSENT.has(error);
|
|
172
|
+
}
|
|
173
|
+
const schedulers = new WeakMap();
|
|
174
|
+
export class CloudflareApi {
|
|
175
|
+
options;
|
|
176
|
+
now;
|
|
177
|
+
sleep;
|
|
178
|
+
budgetEnd;
|
|
179
|
+
fixedDeadline;
|
|
180
|
+
scheduler;
|
|
181
|
+
constructor(options) {
|
|
182
|
+
this.options = options;
|
|
183
|
+
cloudflareCredentials({
|
|
184
|
+
CLOUDFLARE_API_TOKEN: options.apiToken,
|
|
185
|
+
CLOUDFLARE_ACCOUNT_ID: options.accountId,
|
|
186
|
+
});
|
|
187
|
+
const transport = options.fetch ?? fetch;
|
|
188
|
+
let accounts = schedulers.get(transport);
|
|
189
|
+
if (!accounts) {
|
|
190
|
+
accounts = new Map();
|
|
191
|
+
schedulers.set(transport, accounts);
|
|
192
|
+
}
|
|
193
|
+
let scheduler = accounts.get(options.accountId);
|
|
194
|
+
if (!scheduler) {
|
|
195
|
+
scheduler = { next: 0, tail: Promise.resolve() };
|
|
196
|
+
accounts.set(options.accountId, scheduler);
|
|
197
|
+
}
|
|
198
|
+
this.scheduler = scheduler;
|
|
199
|
+
this.now = options.now ?? Date.now;
|
|
200
|
+
this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
201
|
+
this.fixedDeadline = options.deadline !== undefined;
|
|
202
|
+
this.budgetEnd = options.deadline ?? this.now() + BUDGET_MS;
|
|
203
|
+
}
|
|
204
|
+
get deadline() {
|
|
205
|
+
return this.budgetEnd;
|
|
206
|
+
}
|
|
207
|
+
get accountId() {
|
|
208
|
+
return this.options.accountId;
|
|
209
|
+
}
|
|
210
|
+
restartDeadline(budgetMs = BUDGET_MS) {
|
|
211
|
+
if (!this.fixedDeadline)
|
|
212
|
+
this.budgetEnd = this.now() + budgetMs;
|
|
213
|
+
}
|
|
214
|
+
/** Each recovery mutation keeps its full settle reserve plus its own read-back allowance. */
|
|
215
|
+
reserveRecovery(mutations) {
|
|
216
|
+
if (this.options.recoveryDeadline) {
|
|
217
|
+
this.budgetEnd = this.options.recoveryDeadline();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (!this.fixedDeadline)
|
|
221
|
+
this.budgetEnd = Math.max(this.budgetEnd, this.now() + RECOVERY_READS_MS + mutations * RECOVERY_STEP_MS);
|
|
222
|
+
}
|
|
223
|
+
assertCreateBudget() {
|
|
224
|
+
if (this.deadline - this.now() < (this.options.minimumMutationBudgetMs ?? CREATE_SETTLE_MS))
|
|
225
|
+
throw new CloudflareError('deadline_exceeded', 1, true);
|
|
226
|
+
}
|
|
227
|
+
async pause(ms) {
|
|
228
|
+
if (this.now() + ms >= this.deadline)
|
|
229
|
+
throw new CloudflareError('provider_failure', 1, true);
|
|
230
|
+
if (ms > 0)
|
|
231
|
+
await this.sleep(ms);
|
|
232
|
+
if (this.now() >= this.deadline)
|
|
233
|
+
throw new CloudflareError('provider_failure', 1, true);
|
|
234
|
+
}
|
|
235
|
+
request(path, method = 'GET', body, headers) {
|
|
236
|
+
return this.enqueue(path, method, body, undefined, undefined, headers);
|
|
237
|
+
}
|
|
238
|
+
async analyticsEngineTables() {
|
|
239
|
+
const { result } = await this.request('/analytics_engine/sql', 'POST', 'SHOW TABLES');
|
|
240
|
+
const tables = object(result);
|
|
241
|
+
if (!Array.isArray(tables.meta) ||
|
|
242
|
+
tables.meta.length !== 1 ||
|
|
243
|
+
object(tables.meta[0]).name !== 'dataset' ||
|
|
244
|
+
object(tables.meta[0]).type !== 'String' ||
|
|
245
|
+
!Array.isArray(tables.data) ||
|
|
246
|
+
!Number.isSafeInteger(tables.rows) ||
|
|
247
|
+
tables.rows !== tables.data.length ||
|
|
248
|
+
!tables.data.every((row) => typeof object(row).dataset === 'string'))
|
|
249
|
+
throw new CloudflareError('provider_failure');
|
|
250
|
+
}
|
|
251
|
+
requestZone(zone, path, method = 'GET', body) {
|
|
252
|
+
if (!/^[a-f0-9]{32}$/.test(zone))
|
|
253
|
+
throw new CloudflareError('invalid_input', 2);
|
|
254
|
+
return this.enqueue(path, method, body, `/zones/${zone}`);
|
|
255
|
+
}
|
|
256
|
+
async listZones(name) {
|
|
257
|
+
return paginatedList(`/zones?name=${encodeURIComponent(name)}`, (path) => this.enqueue(path, 'GET', undefined, ''), undefined, () => {
|
|
258
|
+
throw new CloudflareError('provider_failure', 1, false, 'deploy');
|
|
259
|
+
}, () => {
|
|
260
|
+
throw new CloudflareError('provider_failure', 1, false, 'deploy');
|
|
261
|
+
}, 50);
|
|
262
|
+
}
|
|
263
|
+
uploadAssets(body, sessionToken) {
|
|
264
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(sessionToken))
|
|
265
|
+
throw new CloudflareError('provider_failure');
|
|
266
|
+
return this.enqueue('/workers/assets/upload?base64=true', 'POST', body, undefined, sessionToken);
|
|
267
|
+
}
|
|
268
|
+
enqueue(path, method, body, prefix, token, headers) {
|
|
269
|
+
const task = this.scheduler.tail.then(() => this.send(path, method, body, prefix, token, headers));
|
|
270
|
+
this.scheduler.tail = task.catch(() => undefined);
|
|
271
|
+
return task;
|
|
272
|
+
}
|
|
273
|
+
async send(path, method, body, prefix, token, extraHeaders) {
|
|
274
|
+
if (!['GET', 'POST', 'PUT', 'PATCH'].includes(method) ||
|
|
275
|
+
!/^\/[a-zA-Z0-9_/?=&%.-]+$/.test(path) ||
|
|
276
|
+
path.includes('..') ||
|
|
277
|
+
path.startsWith('//'))
|
|
278
|
+
throw new CloudflareError('invalid_input', 2);
|
|
279
|
+
// SQL is a read-only POST with a plain-text request and a non-v4 JSON response.
|
|
280
|
+
const analyticsQuery = path === '/analytics_engine/sql' && method === 'POST' && body === 'SHOW TABLES';
|
|
281
|
+
for (let attempt = 0; attempt < (method === 'GET' ? 5 : 1); attempt++) {
|
|
282
|
+
try {
|
|
283
|
+
await this.pause(Math.max(0, this.scheduler.next - this.now()));
|
|
284
|
+
if (method !== 'GET' && !analyticsQuery)
|
|
285
|
+
this.assertCreateBudget();
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (method !== 'GET' && error instanceof CloudflareError)
|
|
289
|
+
UNSENT.add(error);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
this.scheduler.next = this.now() + 1000;
|
|
293
|
+
const controller = new AbortController();
|
|
294
|
+
const timer = setTimeout(() => controller.abort(), Math.min(REQUEST_TIMEOUT_MS, Math.max(1, this.deadline - this.now())));
|
|
295
|
+
const aborted = new Promise((_, reject) => controller.signal.addEventListener('abort', () => reject(new Error()), { once: true }));
|
|
296
|
+
let response;
|
|
297
|
+
let responseFailure;
|
|
298
|
+
let errorTimer;
|
|
299
|
+
try {
|
|
300
|
+
response = await Promise.race([
|
|
301
|
+
(this.options.fetch ?? fetch)(`https://api.cloudflare.com/client/v4${prefix ?? `/accounts/${this.options.accountId}`}${path}`, {
|
|
302
|
+
method,
|
|
303
|
+
redirect: 'manual',
|
|
304
|
+
signal: controller.signal,
|
|
305
|
+
headers: {
|
|
306
|
+
...extraHeaders,
|
|
307
|
+
authorization: `Bearer ${token ?? this.options.apiToken}`,
|
|
308
|
+
...(body instanceof FormData
|
|
309
|
+
? {}
|
|
310
|
+
: { 'content-type': analyticsQuery ? 'text/plain' : 'application/json' }),
|
|
311
|
+
},
|
|
312
|
+
...(body === undefined
|
|
313
|
+
? {}
|
|
314
|
+
: {
|
|
315
|
+
body: body instanceof FormData || analyticsQuery
|
|
316
|
+
? body
|
|
317
|
+
: JSON.stringify(body),
|
|
318
|
+
}),
|
|
319
|
+
}),
|
|
320
|
+
aborted,
|
|
321
|
+
]);
|
|
322
|
+
if (response.status === 403 || response.status === 401) {
|
|
323
|
+
controller.abort();
|
|
324
|
+
void response.body?.cancel().catch(() => undefined);
|
|
325
|
+
throw new CloudflareError('permission_denied', 1, false, 'provision', response.status);
|
|
326
|
+
}
|
|
327
|
+
const transient = [408, 429, 500, 502, 503, 504].includes(response.status);
|
|
328
|
+
if (!response.ok)
|
|
329
|
+
responseFailure = new CloudflareError('provider_failure', 1, transient, 'provision', response.status);
|
|
330
|
+
if (responseFailure) {
|
|
331
|
+
// Only Queues plan rejection needs a numeric code; other HTTP failures need no body.
|
|
332
|
+
if (method !== 'GET' ||
|
|
333
|
+
!/^\/queues(?:\?|$)/.test(path) ||
|
|
334
|
+
!response.headers.get('content-type')?.includes('application/json')) {
|
|
335
|
+
controller.abort();
|
|
336
|
+
void response.body?.cancel().catch(() => undefined);
|
|
337
|
+
throw responseFailure;
|
|
338
|
+
}
|
|
339
|
+
errorTimer = setTimeout(() => controller.abort(), 1000);
|
|
340
|
+
}
|
|
341
|
+
const reader = response.body?.getReader();
|
|
342
|
+
if (!reader)
|
|
343
|
+
throw new Error();
|
|
344
|
+
const chunks = [];
|
|
345
|
+
let size = 0;
|
|
346
|
+
try {
|
|
347
|
+
for (;;) {
|
|
348
|
+
const { done, value } = await Promise.race([reader.read(), aborted]);
|
|
349
|
+
if (done)
|
|
350
|
+
break;
|
|
351
|
+
size += value.byteLength;
|
|
352
|
+
if (size > 1_048_576) {
|
|
353
|
+
void reader.cancel().catch(() => undefined);
|
|
354
|
+
throw new Error();
|
|
355
|
+
}
|
|
356
|
+
chunks.push(value);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
void reader.cancel().catch(() => undefined);
|
|
361
|
+
reader.releaseLock();
|
|
362
|
+
}
|
|
363
|
+
const parsed = object(JSON.parse(Buffer.concat(chunks).toString('utf8')));
|
|
364
|
+
if (!response.ok || parsed.success === false) {
|
|
365
|
+
const planRejected = method === 'GET' &&
|
|
366
|
+
/^\/queues(?:\?|$)/.test(path) &&
|
|
367
|
+
Array.isArray(parsed.errors) &&
|
|
368
|
+
parsed.errors.some((entry) => entry !== null &&
|
|
369
|
+
typeof entry === 'object' &&
|
|
370
|
+
!Array.isArray(entry) &&
|
|
371
|
+
entry.code === 10253);
|
|
372
|
+
if (planRejected)
|
|
373
|
+
throw new CloudflareError('provider_failure', 1, false, 'provision', response.status, null, 10253);
|
|
374
|
+
if (responseFailure)
|
|
375
|
+
throw responseFailure;
|
|
376
|
+
throw new Error();
|
|
377
|
+
}
|
|
378
|
+
if (analyticsQuery) {
|
|
379
|
+
if (response.status !== 200)
|
|
380
|
+
throw new Error();
|
|
381
|
+
return { result: parsed };
|
|
382
|
+
}
|
|
383
|
+
if (parsed.success !== true || !Object.hasOwn(parsed, 'result'))
|
|
384
|
+
throw new Error();
|
|
385
|
+
return {
|
|
386
|
+
result: parsed.result,
|
|
387
|
+
...(parsed.result_info == null ? {} : { result_info: object(parsed.result_info) }),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
const safe = responseFailure && !(error instanceof CloudflareError && error.providerCode === 10253)
|
|
392
|
+
? responseFailure
|
|
393
|
+
: error instanceof CloudflareError
|
|
394
|
+
? error
|
|
395
|
+
: new CloudflareError('provider_failure', 1, true);
|
|
396
|
+
const header = response?.headers.get('retry-after');
|
|
397
|
+
if (safe.retryable && header) {
|
|
398
|
+
const requested = /^\d+$/.test(header)
|
|
399
|
+
? Number(header) * 1000
|
|
400
|
+
: Date.parse(header) - this.now();
|
|
401
|
+
if (Number.isFinite(requested) && requested >= 0)
|
|
402
|
+
this.scheduler.next = Math.max(this.scheduler.next, this.now() + requested);
|
|
403
|
+
}
|
|
404
|
+
if (method !== 'GET')
|
|
405
|
+
throw safe;
|
|
406
|
+
if (!safe.retryable || attempt === 4)
|
|
407
|
+
throw safe;
|
|
408
|
+
const delay = Math.max(this.scheduler.next - this.now(), 1000 * 2 ** attempt +
|
|
409
|
+
Math.min(250, Math.max(0, this.options.jitter?.() ?? Math.random() * 250)));
|
|
410
|
+
await this.pause(delay);
|
|
411
|
+
}
|
|
412
|
+
finally {
|
|
413
|
+
clearTimeout(errorTimer);
|
|
414
|
+
clearTimeout(timer);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
throw new CloudflareError('provider_failure', 1, true);
|
|
418
|
+
}
|
|
419
|
+
/** A collection whose documented response is one array without pagination metadata. */
|
|
420
|
+
async snapshot(path) {
|
|
421
|
+
return snapshotItems(await this.request(path));
|
|
422
|
+
}
|
|
423
|
+
async snapshotZone(zone, path) {
|
|
424
|
+
return snapshotItems(await this.requestZone(zone, path));
|
|
425
|
+
}
|
|
426
|
+
async list(path, field, headers) {
|
|
427
|
+
return paginatedList(path, (page) => this.request(page, 'GET', undefined, headers), field);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
export async function paginatedList(path, read, field, unknown = () => {
|
|
431
|
+
throw new CloudflareError('capability_unknown');
|
|
432
|
+
}, malformed = () => {
|
|
433
|
+
throw new CloudflareError('provider_failure');
|
|
434
|
+
}, perPage = 100) {
|
|
435
|
+
const all = [];
|
|
436
|
+
let cursor;
|
|
437
|
+
const seen = new Set();
|
|
438
|
+
let totalCount;
|
|
439
|
+
let totalPages;
|
|
440
|
+
for (let page = 1; page <= 10_000; page++) {
|
|
441
|
+
const separator = path.includes('?') ? '&' : '?';
|
|
442
|
+
const response = await read(`${path}${separator}${cursor === undefined ? `page=${page}&per_page=${perPage}` : `cursor=${encodeURIComponent(cursor)}`}`);
|
|
443
|
+
const result = field === undefined ? response.result : object(response.result)[field];
|
|
444
|
+
if (!Array.isArray(result))
|
|
445
|
+
return malformed();
|
|
446
|
+
all.push(...result.map(object));
|
|
447
|
+
const info = response.result_info;
|
|
448
|
+
const next = info?.cursor;
|
|
449
|
+
const pages = info?.total_pages;
|
|
450
|
+
const count = info?.total_count;
|
|
451
|
+
for (const value of [pages, count, info?.count, info?.page])
|
|
452
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || Number(value) < 0))
|
|
453
|
+
unknown();
|
|
454
|
+
if ((next !== undefined && typeof next !== 'string') ||
|
|
455
|
+
(info?.page !== undefined && cursor === undefined && info.page !== page) ||
|
|
456
|
+
(info?.count !== undefined && info.count !== result.length) ||
|
|
457
|
+
(totalCount !== undefined && count !== undefined && totalCount !== count) ||
|
|
458
|
+
(totalPages !== undefined && pages !== undefined && totalPages !== pages))
|
|
459
|
+
unknown();
|
|
460
|
+
if (typeof count === 'number')
|
|
461
|
+
totalCount = count;
|
|
462
|
+
if (typeof pages === 'number')
|
|
463
|
+
totalPages = pages;
|
|
464
|
+
if ((totalCount !== undefined && all.length > totalCount) ||
|
|
465
|
+
(pages === 0 && (all.length !== 0 || (next !== undefined && next !== ''))))
|
|
466
|
+
unknown();
|
|
467
|
+
const complete = () => {
|
|
468
|
+
if (totalCount !== undefined && totalCount !== all.length)
|
|
469
|
+
unknown();
|
|
470
|
+
return all;
|
|
471
|
+
};
|
|
472
|
+
if (typeof next === 'string' && next !== '') {
|
|
473
|
+
if (seen.has(next))
|
|
474
|
+
return malformed();
|
|
475
|
+
seen.add(next);
|
|
476
|
+
cursor = next;
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (typeof pages === 'number' && Number.isSafeInteger(pages) && pages >= page) {
|
|
480
|
+
if (pages === page)
|
|
481
|
+
return complete();
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if (info?.total_count === all.length || next === '' || (pages === 0 && result.length === 0))
|
|
485
|
+
return complete();
|
|
486
|
+
if (totalPages === undefined &&
|
|
487
|
+
cursor === undefined &&
|
|
488
|
+
next === undefined &&
|
|
489
|
+
typeof count === 'number' &&
|
|
490
|
+
count > all.length &&
|
|
491
|
+
info?.page === page &&
|
|
492
|
+
info.count === result.length &&
|
|
493
|
+
result.length > 0 &&
|
|
494
|
+
Number.isSafeInteger(info.per_page) &&
|
|
495
|
+
Number(info.per_page) >= result.length)
|
|
496
|
+
continue;
|
|
497
|
+
// Absence requires explicit pagination completion, never a short-page guess.
|
|
498
|
+
unknown();
|
|
499
|
+
}
|
|
500
|
+
return malformed();
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/commands/cloudflare/api.ts"],"names":[],"mappings":"AAkDA,MAAM,QAAQ,GACZ,8PAA8P,CAAC;AACjQ,MAAM,QAAQ,GAA8B;IAC1C,gBAAgB,EAAE,2DAA2D;IAC7E,cAAc,EAAE,4EAA4E;IAC5F,yBAAyB,EACvB,mFAAmF;IACrF,0BAA0B,EACxB,2FAA2F;IAC7F,6BAA6B,EAC3B,+FAA+F;IACjG,mBAAmB,EAAE,0EAA0E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AC;YACf,MAAM,GAAG,IAAI,CAAC;YACd,SAAS;QACX,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAC9E,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,QAAQ,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QACD,IAAI,IAAI,EAAE,WAAW,KAAK,GAAG,CAAC,MAAM,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;YACzF,OAAO,QAAQ,EAAE,CAAC;QACpB,IACE,UAAU,KAAK,SAAS;YACxB,MAAM,KAAK,SAAS;YACpB,IAAI,KAAK,SAAS;YAClB,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,GAAG,GAAG,CAAC,MAAM;YAClB,IAAI,EAAE,IAAI,KAAK,IAAI;YACnB,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM;YAC5B,MAAM,CAAC,MAAM,GAAG,CAAC;YACjB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM;YAEtC,SAAS;QACX,6EAA6E;QAC7E,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type PlatformPortConfig } from '@package-broker/core/platform/port-config';
|
|
2
|
+
import { type IdentityDescriptor } from '@package-broker/core/plugin';
|
|
3
|
+
import { snapshotIdentityDescriptor } from '@package-broker/core/kernel/registry';
|
|
4
|
+
import { materializePrebuilt } from '../../prebuilt.js';
|
|
5
|
+
import { type ProvidersOption } from './providers-file.js';
|
|
6
|
+
import { CloudflareApi, type CommandResult } from './api.js';
|
|
7
|
+
import { InventoryStore, InventoryTransaction, type DeploymentAttempt, type Distribution, type Inventory, type Jurisdiction, type ManagedDomain } from './inventory.js';
|
|
8
|
+
export declare function tracesMetadata(traces: PlatformPortConfig['observability']['traces']): Record<string, unknown> | undefined;
|
|
9
|
+
export declare function assertProvidersAccepted(option: ProvidersOption | undefined, identity: ReturnType<typeof snapshotIdentityDescriptor>): void;
|
|
10
|
+
export declare function dryRunIdentity(descriptor: IdentityDescriptor | null, providersText: string | null, identityHash: string | null, skippedChecks?: string[]): {
|
|
11
|
+
providers: {
|
|
12
|
+
id: string;
|
|
13
|
+
type: "oidc" | "cloudflare-access";
|
|
14
|
+
source: string;
|
|
15
|
+
}[];
|
|
16
|
+
overrides: string[];
|
|
17
|
+
displaced: ({
|
|
18
|
+
id: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
by: string;
|
|
21
|
+
} | {
|
|
22
|
+
id: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
by: null;
|
|
25
|
+
})[];
|
|
26
|
+
runtime_providers_applied: boolean;
|
|
27
|
+
runtime_document_problem: import("@package-broker/plugin-sso-oidc/definitions").DocumentProblem | null;
|
|
28
|
+
providers_sha256: string | null;
|
|
29
|
+
identity_sha256: string | null;
|
|
30
|
+
skipped_checks: string[];
|
|
31
|
+
} | null;
|
|
32
|
+
export declare function validateDeploymentArtifact(out: string): Promise<{
|
|
33
|
+
module: Buffer<ArrayBufferLike>;
|
|
34
|
+
info: import("../../build-artifacts.js").BuildInfo;
|
|
35
|
+
ports: PlatformPortConfig | null;
|
|
36
|
+
assets: {
|
|
37
|
+
name: string;
|
|
38
|
+
content: Buffer<ArrayBufferLike>;
|
|
39
|
+
contentType: string;
|
|
40
|
+
}[];
|
|
41
|
+
assetsHash: string;
|
|
42
|
+
artifactHash: string;
|
|
43
|
+
migrations: import("@package-broker/db-sqlite/migrations/source").MigrationSource[];
|
|
44
|
+
identity: IdentityDescriptor | null;
|
|
45
|
+
}>;
|
|
46
|
+
/** Provider facilities must be explicitly supported before deploy enables them. */
|
|
47
|
+
export interface DeployProviderContract {
|
|
48
|
+
versionsCreateScript: boolean;
|
|
49
|
+
createScript?: (api: CloudflareApi, script: string, form: FormData) => Promise<void>;
|
|
50
|
+
domainZone: (api: CloudflareApi, hostname: string) => Promise<string>;
|
|
51
|
+
secretInheritance: boolean;
|
|
52
|
+
assetHash?: (bytes: Buffer, name: string) => string;
|
|
53
|
+
preview: (api: CloudflareApi, script: string, version: string) => Promise<{
|
|
54
|
+
version_id: string;
|
|
55
|
+
url: string;
|
|
56
|
+
bindings_verified: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
export declare const unverifiedDeployContract: DeployProviderContract;
|
|
60
|
+
/** Cloudflare's direct-upload example hashes base64 bytes plus the extension without its dot. */
|
|
61
|
+
export declare function cloudflareAssetHash(bytes: Buffer, name: string): string;
|
|
62
|
+
export declare const cloudflareDeployContract: DeployProviderContract;
|
|
63
|
+
export interface DeployOptions {
|
|
64
|
+
providers?: ProvidersOption;
|
|
65
|
+
workerName: string;
|
|
66
|
+
prebuilt?: boolean;
|
|
67
|
+
configPath?: string;
|
|
68
|
+
project?: string;
|
|
69
|
+
outDir?: string;
|
|
70
|
+
environment?: string;
|
|
71
|
+
deploymentId?: string;
|
|
72
|
+
inventory?: string;
|
|
73
|
+
jurisdiction?: Jurisdiction;
|
|
74
|
+
runIdentity?: string;
|
|
75
|
+
rollout?: number;
|
|
76
|
+
publicUrl?: string;
|
|
77
|
+
domain?: string;
|
|
78
|
+
routes?: string;
|
|
79
|
+
secret?: readonly string[];
|
|
80
|
+
secrets?: string;
|
|
81
|
+
workersPaid?: boolean;
|
|
82
|
+
allowContract?: readonly string[];
|
|
83
|
+
dryRun?: boolean;
|
|
84
|
+
json?: boolean;
|
|
85
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
86
|
+
fetch?: typeof fetch;
|
|
87
|
+
now?: () => number;
|
|
88
|
+
sleep?: (ms: number) => Promise<void>;
|
|
89
|
+
contract?: DeployProviderContract;
|
|
90
|
+
transaction?: InventoryTransaction;
|
|
91
|
+
}
|
|
92
|
+
interface ActiveDeployment {
|
|
93
|
+
id: string | null;
|
|
94
|
+
versions: Distribution[];
|
|
95
|
+
}
|
|
96
|
+
export declare function active(api: CloudflareApi, base: string): Promise<ActiveDeployment>;
|
|
97
|
+
export declare function deploymentDomain(api: CloudflareApi, script: string, domain: string | undefined): Promise<ManagedDomain | null>;
|
|
98
|
+
export declare function workersDevOrigin(api: CloudflareApi, script: string): Promise<string>;
|
|
99
|
+
export declare function zoneRoutes(api: CloudflareApi, zone: string): Promise<Record<string, unknown>[]>;
|
|
100
|
+
export declare function versionAnnotationsMatch(annotations: Record<string, unknown>, a: DeploymentAttempt, creation?: boolean): boolean;
|
|
101
|
+
export declare function reconcileCandidatePreview(api: CloudflareApi, store: InventoryStore, j: Inventory): Promise<void>;
|
|
102
|
+
/** Smoke owns this finally block. Persisted intent also covers process interruption. */
|
|
103
|
+
export declare function withCandidatePreview<T>(api: CloudflareApi, store: InventoryStore, j: Inventory, contract: DeployProviderContract, probe: (url: string) => Promise<T>): Promise<T>;
|
|
104
|
+
export declare function deploy(o: DeployOptions, operations?: {
|
|
105
|
+
materializePrebuilt?: typeof materializePrebuilt;
|
|
106
|
+
}): Promise<CommandResult>;
|
|
107
|
+
export declare function runCloudflareDeploy(o: DeployOptions): Promise<number>;
|
|
108
|
+
/** Caller holds the install lease; smoke uses this after disabling any temporary preview. */
|
|
109
|
+
export declare function rollbackDeployment(api: CloudflareApi, store: InventoryStore, journal: Inventory): Promise<'succeeded' | 'unknown' | 'failed'>;
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=deploy.d.ts.map
|