@cloudflare/deploy-helpers 0.1.0 → 0.1.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/dist/index.d.mts CHANGED
@@ -1,7 +1,24 @@
1
1
  import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
2
- import { Config, Entry, AssetsOptions, CfPlacement, EphemeralDirectory, LegacyAssetPaths, Route } from '@cloudflare/workers-utils';
2
+ import { FetchResultFetcher, FetchListResultFetcher, Logger, Config, Entry, AssetsOptions, CfPlacement, EphemeralDirectory, LegacyAssetPaths, Route, ComplianceConfig, ZoneIdRoute, ZoneNameRoute, CustomDomainRoute } from '@cloudflare/workers-utils';
3
3
  import { NodeJSCompatMode } from 'miniflare';
4
4
 
5
+ /**
6
+ * client needs to handle logger and fetch/auth implementation
7
+ * these are passed into this package to handle any API requests/logs
8
+ */
9
+ type DeployHelpersContext = {
10
+ fetchResult: FetchResultFetcher;
11
+ fetchListResult: FetchListResultFetcher;
12
+ logger: Logger;
13
+ confirm: (text: string, options?: {
14
+ defaultValue?: boolean;
15
+ fallbackValue?: boolean;
16
+ }) => Promise<boolean>;
17
+ prompt: (text: string, options?: {
18
+ defaultValue?: string;
19
+ }) => Promise<string>;
20
+ isNonInteractiveOrCI: () => boolean;
21
+ };
5
22
  /**
6
23
  * Shared fields produced by merging CLI args with wrangler config.
7
24
  * After this point, no raw config/arg merging should happen.
@@ -101,5 +118,177 @@ type VersionsUploadProps = SharedDeployVersionsProps & {
101
118
  /** CLI-only (--preview-alias), or auto-generated from CI branch name. */
102
119
  previewAlias: string | undefined;
103
120
  };
121
+ interface TriggerDeployment {
122
+ targets: string[];
123
+ error?: Error;
124
+ }
125
+ type TriggerProps = {
126
+ config: Config;
127
+ accountId: string;
128
+ scriptName: string;
129
+ env: string | undefined;
130
+ crons: string[] | undefined;
131
+ routes: Route[];
132
+ useServiceEnvironments: boolean;
133
+ firstDeploy: boolean;
134
+ };
135
+
136
+ declare function triggersDeploy(props: TriggerProps, ctx: DeployHelpersContext): Promise<string[] | void>;
137
+ declare function getSubdomainValues(config_workers_dev: boolean | undefined, config_preview_urls: boolean | undefined, routes: Route[]): {
138
+ workers_dev: boolean;
139
+ preview_urls?: boolean;
140
+ };
141
+ declare function getSubdomainValuesAPIMock(config_workers_dev: boolean | undefined, config_preview_urls: boolean | undefined, routes: Route[]): {
142
+ workers_dev: boolean;
143
+ preview_urls: boolean;
144
+ };
145
+
146
+ type WorkersDevSubdomainRegistrationContext = "workers_dev" | "workflows";
147
+ type GetWorkersDevSubdomainOptions = {
148
+ configPath?: string | undefined;
149
+ abortSignal?: AbortSignal | undefined;
150
+ registrationContext?: WorkersDevSubdomainRegistrationContext | undefined;
151
+ };
152
+ /**
153
+ * Gets the <user-subdomain>.(fed.)workers.dev URL for the given account.
154
+ */
155
+ declare function getWorkersDevSubdomain(complianceConfig: ComplianceConfig, accountId: string, ctx: DeployHelpersContext, options?: GetWorkersDevSubdomainOptions): Promise<string>;
156
+
157
+ interface Zone {
158
+ id: string;
159
+ host: string;
160
+ }
161
+ type ZoneIdCache = Map<string, Promise<string | null>>;
162
+ declare function getZoneForRoute(complianceConfig: ComplianceConfig, from: {
163
+ route: Route;
164
+ accountId: string;
165
+ }, ctx: DeployHelpersContext, zoneIdCache?: ZoneIdCache): Promise<Zone | undefined>;
166
+ /**
167
+ * Given something that resembles a host, try to infer a zone id from it.
168
+ *
169
+ * It's hard to get a 'valid' domain from a string, so we don't even try to validate TLDs, etc.
170
+ * For each domain-like part of the host (e.g. w.x.y.z) try to get a zone id for it by
171
+ * lopping off subdomains until we get a hit from the API.
172
+ */
173
+ declare function getZoneIdFromHost(complianceConfig: ComplianceConfig, from: {
174
+ host: string;
175
+ accountId: string;
176
+ }, ctx: DeployHelpersContext, zoneIdCache?: ZoneIdCache): Promise<string>;
177
+
178
+ type RouteObject = ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
179
+ type CustomDomain = {
180
+ id: string;
181
+ zone_id: string;
182
+ zone_name: string;
183
+ hostname: string;
184
+ service: string;
185
+ environment: string;
186
+ enabled: boolean;
187
+ previews_enabled: boolean;
188
+ };
189
+ type UpdatedCustomDomain = CustomDomain & {
190
+ modified: boolean;
191
+ };
192
+ type ConflictingCustomDomain = CustomDomain & {
193
+ external_dns_record_id?: string | null;
194
+ external_cert_id?: string;
195
+ };
196
+ type CustomDomainChangeset = {
197
+ added: CustomDomain[];
198
+ removed: CustomDomain[];
199
+ updated: UpdatedCustomDomain[];
200
+ conflicting: ConflictingCustomDomain[];
201
+ };
202
+ declare function renderRoute(route: Route): string;
203
+ /**
204
+ * Associate the newly deployed Worker with the given routes.
205
+ */
206
+ declare function publishRoutes(complianceConfig: ComplianceConfig, routes: Route[], { workerUrl, scriptName, useServiceEnvironments, accountId, }: {
207
+ workerUrl: string;
208
+ scriptName: string;
209
+ useServiceEnvironments: boolean;
210
+ accountId: string;
211
+ }, ctx: DeployHelpersContext): Promise<string[]>;
212
+ declare function publishCustomDomains(complianceConfig: ComplianceConfig, workerUrl: string, accountId: string, domains: Array<RouteObject>, ctx: DeployHelpersContext): Promise<TriggerDeployment>;
213
+
214
+ interface PostQueueBody {
215
+ queue_name: string;
216
+ settings?: QueueSettings;
217
+ }
218
+ interface QueueSettings {
219
+ delivery_delay?: number;
220
+ delivery_paused?: boolean;
221
+ message_retention_period?: number;
222
+ }
223
+ interface PostQueueResponse {
224
+ queue_id: string;
225
+ queue_name: string;
226
+ settings?: QueueSettings;
227
+ created_on: string;
228
+ modified_on: string;
229
+ }
230
+ interface QueueResponse {
231
+ queue_id: string;
232
+ queue_name: string;
233
+ created_on: string;
234
+ modified_on: string;
235
+ producers: Producer[];
236
+ producers_total_count: number;
237
+ consumers: Consumer[];
238
+ consumers_total_count: number;
239
+ settings?: QueueSettings;
240
+ }
241
+ interface ScriptReference {
242
+ namespace?: string;
243
+ script?: string;
244
+ service?: string;
245
+ environment?: string;
246
+ }
247
+ type Producer = ScriptReference & {
248
+ type: string;
249
+ bucket_name?: string;
250
+ };
251
+ type Consumer = ScriptReference & {
252
+ dead_letter_queue?: string;
253
+ settings: ConsumerSettings;
254
+ consumer_id: string;
255
+ bucket_name?: string;
256
+ type: string;
257
+ };
258
+ interface TypedConsumerResponse extends Consumer {
259
+ queue_name: string;
260
+ created_on: string;
261
+ }
262
+ interface PostTypedConsumerBody {
263
+ type: string;
264
+ script_name?: string;
265
+ environment_name?: string;
266
+ settings: ConsumerSettings;
267
+ dead_letter_queue?: string;
268
+ }
269
+ interface ConsumerSettings {
270
+ batch_size?: number;
271
+ max_retries?: number;
272
+ max_wait_time_ms?: number;
273
+ max_concurrency?: number | null;
274
+ visibility_timeout_ms?: number;
275
+ retry_delay?: number;
276
+ }
277
+ interface PurgeQueueBody {
278
+ delete_messages_permanently: boolean;
279
+ }
280
+ interface PurgeQueueResponse {
281
+ started_at: string;
282
+ complete: boolean;
283
+ }
284
+ declare function listQueues(complianceConfig: ComplianceConfig, accountId: string, ctx: DeployHelpersContext, page?: number, name?: string): Promise<QueueResponse[]>;
285
+ declare function getQueue(complianceConfig: ComplianceConfig, accountId: string, queueName: string, ctx: DeployHelpersContext): Promise<QueueResponse>;
286
+ declare function postConsumer(complianceConfig: ComplianceConfig, accountId: string, queueName: string, body: PostTypedConsumerBody, ctx: DeployHelpersContext): Promise<TypedConsumerResponse>;
287
+ declare function putConsumerById(complianceConfig: ComplianceConfig, accountId: string, queueId: string, consumerId: string, body: PostTypedConsumerBody, ctx: DeployHelpersContext): Promise<TypedConsumerResponse>;
288
+ declare function putConsumer(complianceConfig: ComplianceConfig, accountId: string, queueName: string, scriptName: string, envName: string | undefined, body: PostTypedConsumerBody, ctx: DeployHelpersContext): Promise<TypedConsumerResponse>;
289
+ declare function deletePullConsumer(complianceConfig: ComplianceConfig, accountId: string, queueName: string, ctx: DeployHelpersContext): Promise<void>;
290
+ declare function listConsumers(complianceConfig: ComplianceConfig, accountId: string, queueName: string, ctx: DeployHelpersContext): Promise<Consumer[]>;
291
+ declare function deleteWorkerConsumer(complianceConfig: ComplianceConfig, accountId: string, queueName: string, scriptName: string, envName: string | undefined, ctx: DeployHelpersContext): Promise<void>;
292
+ declare function updateQueueConsumers(complianceConfig: ComplianceConfig, accountId: string, scriptName: string, config: Config, ctx: DeployHelpersContext): Promise<Promise<TriggerDeployment>[]>;
104
293
 
105
- export type { DeployProps, SharedDeployVersionsProps, VersionsUploadProps };
294
+ export { type Consumer, type ConsumerSettings, type CustomDomain, type CustomDomainChangeset, type DeployHelpersContext, type DeployProps, type PostQueueBody, type PostQueueResponse, type PostTypedConsumerBody, type Producer, type PurgeQueueBody, type PurgeQueueResponse, type QueueResponse, type QueueSettings, type RouteObject, type ScriptReference, type SharedDeployVersionsProps, type TriggerDeployment, type TriggerProps, type TypedConsumerResponse, type VersionsUploadProps, type Zone, type ZoneIdCache, deletePullConsumer, deleteWorkerConsumer, getQueue, getSubdomainValues, getSubdomainValuesAPIMock, getWorkersDevSubdomain, getZoneForRoute, getZoneIdFromHost, listConsumers, listQueues, postConsumer, publishCustomDomains, publishRoutes, putConsumer, putConsumerById, renderRoute, triggersDeploy, updateQueueConsumers };