@wtfalch/edge 0.7.0 → 0.9.0

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/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ClientOptions } from './transport.js';
2
- import type { AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformRecordRequest, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, FindServiceTokenResponse, ListClaimsResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, TokenResponse, UpdatePlatformRecordRequest, UploadPlatformWorkerScriptRequest } from './types.js';
2
+ import type { AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRateLimitRulesRequest, AdoptRateLimitRulesResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AdoptZonesRequest, AdoptZonesResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformRateLimitRuleRequest, CreatePlatformRecordRequest, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, CreatePlatformZoneRequest, FindServiceTokenResponse, ListClaimsResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRateLimitRulesRequest, ListPlatformRateLimitRulesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListPlatformZonesRequest, ListPlatformZonesResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformRateLimitRuleView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, TokenResponse, UpdatePlatformRecordRequest, UploadPlatformWorkerScriptRequest } from './types.js';
3
3
  export { EdgeApiError, type ClientOptions } from './transport.js';
4
4
  /** Called with an entry's key: the key carries its organisation and domain, so
5
5
  * no call names either. `setReservedLabels`, `mintKey` and `revokeKey` are
@@ -85,6 +85,41 @@ export declare function createEdgeClient(options: ClientOptions): {
85
85
  * recreated, and an app nobody names is left alone. */
86
86
  adopt: (input: AdoptAccessAppsRequest) => Promise<AdoptAccessAppsResponse>;
87
87
  };
88
+ /** Cloudflare rate limiting rules the platform owns. A zone's rules share
89
+ * one ruleset, so each rule is owned on its own; a rule's `id` is
90
+ * Cloudflare's rule id. */
91
+ ratelimits: {
92
+ /** Every live rule in the zone with its owner (`null`: no row), optionally only one description. */
93
+ list: (filter: ListPlatformRateLimitRulesRequest) => Promise<ListPlatformRateLimitRulesResponse>;
94
+ /** Creates the rule, or returns the one edge already made for that zone
95
+ * and description (201 when new, 200 after). Rejects with `conflict` when
96
+ * a live rule with that description exists that nobody adopted (adopt it
97
+ * instead, reason `exists`) or another create of it is in progress
98
+ * (reason `busy`), and with `conflict` (reason `upstream_rejected`) when Cloudflare
99
+ * refuses the rule for good. */
100
+ create: (input: CreatePlatformRateLimitRuleRequest) => Promise<PlatformRateLimitRuleView>;
101
+ /** Deletes that one rule; returns the tombstone. Repeating it rejects with `not_found`. */
102
+ remove: (zoneId: string, id: string) => Promise<PlatformRateLimitRuleView>;
103
+ /** Writes platform rows for the rules named. Nothing is changed at
104
+ * Cloudflare, and anything nobody names is left alone. */
105
+ adopt: (input: AdoptRateLimitRulesRequest) => Promise<AdoptRateLimitRulesResponse>;
106
+ };
107
+ /** Cloudflare zones the platform made or adopted. A zone is the root of a
108
+ * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
109
+ zones: {
110
+ /** The live zone with exactly this name (none: an empty list), with its owner (`null`: no row). */
111
+ list: (filter: ListPlatformZonesRequest) => Promise<ListPlatformZonesResponse>;
112
+ /** Creates the zone, or returns the one edge already made for that name
113
+ * (201 when new, 200 after); `nameServers` are what the registrar must
114
+ * delegate to. Rejects with `conflict` when a zone of that name already
115
+ * exists at Cloudflare that nobody adopted (adopt it instead, reason
116
+ * `exists`) or another create of it is in progress (reason `busy`), and
117
+ * with `conflict` (reason `upstream_rejected`) when Cloudflare refuses
118
+ * the zone for good. */
119
+ create: (input: CreatePlatformZoneRequest) => Promise<PlatformZoneView>;
120
+ /** Writes platform rows for the zones named. Nothing is changed at Cloudflare. */
121
+ adopt: (input: AdoptZonesRequest) => Promise<AdoptZonesResponse>;
122
+ };
88
123
  /** Cloudflare Workers scripts and routes the platform owns. A script's
89
124
  * `id` is its name; a route's `id` is Cloudflare's route id. */
90
125
  workers: {
package/dist/client.js CHANGED
@@ -88,6 +88,41 @@ export function createEdgeClient(options) {
88
88
  * recreated, and an app nobody names is left alone. */
89
89
  adopt: (input) => call('POST', '/v1/platform/access/apps/adopt', input),
90
90
  },
91
+ /** Cloudflare rate limiting rules the platform owns. A zone's rules share
92
+ * one ruleset, so each rule is owned on its own; a rule's `id` is
93
+ * Cloudflare's rule id. */
94
+ ratelimits: {
95
+ /** Every live rule in the zone with its owner (`null`: no row), optionally only one description. */
96
+ list: (filter) => call('GET', `/v1/platform/ratelimits/rules?${new URLSearchParams(Object.entries(filter).filter((entry) => entry[1] !== undefined))}`),
97
+ /** Creates the rule, or returns the one edge already made for that zone
98
+ * and description (201 when new, 200 after). Rejects with `conflict` when
99
+ * a live rule with that description exists that nobody adopted (adopt it
100
+ * instead, reason `exists`) or another create of it is in progress
101
+ * (reason `busy`), and with `conflict` (reason `upstream_rejected`) when Cloudflare
102
+ * refuses the rule for good. */
103
+ create: (input) => call('POST', '/v1/platform/ratelimits/rules', input),
104
+ /** Deletes that one rule; returns the tombstone. Repeating it rejects with `not_found`. */
105
+ remove: (zoneId, id) => call('DELETE', `/v1/platform/ratelimits/rules/${encodeURIComponent(id)}?${new URLSearchParams({ zoneId })}`),
106
+ /** Writes platform rows for the rules named. Nothing is changed at
107
+ * Cloudflare, and anything nobody names is left alone. */
108
+ adopt: (input) => call('POST', '/v1/platform/ratelimits/adopt', input),
109
+ },
110
+ /** Cloudflare zones the platform made or adopted. A zone is the root of a
111
+ * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
112
+ zones: {
113
+ /** The live zone with exactly this name (none: an empty list), with its owner (`null`: no row). */
114
+ list: (filter) => call('GET', `/v1/platform/zones?${new URLSearchParams({ name: filter.name })}`),
115
+ /** Creates the zone, or returns the one edge already made for that name
116
+ * (201 when new, 200 after); `nameServers` are what the registrar must
117
+ * delegate to. Rejects with `conflict` when a zone of that name already
118
+ * exists at Cloudflare that nobody adopted (adopt it instead, reason
119
+ * `exists`) or another create of it is in progress (reason `busy`), and
120
+ * with `conflict` (reason `upstream_rejected`) when Cloudflare refuses
121
+ * the zone for good. */
122
+ create: (input) => call('POST', '/v1/platform/zones', input),
123
+ /** Writes platform rows for the zones named. Nothing is changed at Cloudflare. */
124
+ adopt: (input) => call('POST', '/v1/platform/zones/adopt', input),
125
+ },
91
126
  /** Cloudflare Workers scripts and routes the platform owns. A script's
92
127
  * `id` is its name; a route's `id` is Cloudflare's route id. */
93
128
  workers: {
package/dist/types.d.ts CHANGED
@@ -501,3 +501,118 @@ export interface AdoptWorkersResponse {
501
501
  unclaimed: PlatformWorkerRouteView[];
502
502
  };
503
503
  }
504
+ /** A rate limiting rule seen with the platform credential. A zone's rules share
505
+ * one ruleset, so ownership is per rule. `id` is Cloudflare's rule id, which
506
+ * every platform rule call takes. */
507
+ export interface PlatformRateLimitRuleView {
508
+ id: string;
509
+ zoneId: string;
510
+ /** `null` for a live rule that has no description. */
511
+ description: string | null;
512
+ /** Who owns it: the platform, or `null` when no row exists (a live rule
513
+ * nobody adopted: reported, never touched). */
514
+ owner: 'platform' | null;
515
+ /** The company the rule serves; `'platform'` when none. `null` for a rule with no row. */
516
+ organisationId: string | null;
517
+ state: 'pending' | 'active' | 'removing' | 'removed';
518
+ }
519
+ export interface ListPlatformRateLimitRulesRequest {
520
+ zoneId: string;
521
+ /** Only the rule with exactly this description. */
522
+ description?: string;
523
+ }
524
+ export interface ListPlatformRateLimitRulesResponse {
525
+ rules: PlatformRateLimitRuleView[];
526
+ }
527
+ /** Creates the rule, or returns the one edge already made for that zone and
528
+ * description. The rule is added on its own: no other rule in the zone's
529
+ * ruleset is read back or rewritten. Cloudflare's plan limits (such as one rule
530
+ * on the Free plan) are Cloudflare's to refuse. */
531
+ export interface CreatePlatformRateLimitRuleRequest {
532
+ zoneId: string;
533
+ /** Names the rule in the zone: the key that makes a repeat safe. */
534
+ description: string;
535
+ expression: string;
536
+ /** Cloudflare's rule action, such as `block`. */
537
+ action: string;
538
+ ratelimit: {
539
+ characteristics: string[];
540
+ period: number;
541
+ requests_per_period: number;
542
+ mitigation_timeout?: number;
543
+ };
544
+ /** The company the rule serves. Omit for a rule that serves none. */
545
+ organisationId?: string;
546
+ }
547
+ export interface AdoptRateLimitRuleEntry {
548
+ zoneId: string;
549
+ /** Match the live rule by description, by id, or both. At least one is needed. */
550
+ description?: string;
551
+ id?: string;
552
+ }
553
+ export interface AdoptRateLimitRulesRequest {
554
+ rules: AdoptRateLimitRuleEntry[];
555
+ /** The company the adopted rules serve. Omit for none. */
556
+ organisationId?: string;
557
+ }
558
+ export interface AdoptRateLimitRulesResponse {
559
+ adopted: PlatformRateLimitRuleView[];
560
+ alreadyAdopted: PlatformRateLimitRuleView[];
561
+ /** `taken`: a row for that zone and description exists. */
562
+ skipped: Array<{
563
+ rule: PlatformRateLimitRuleView;
564
+ reason: 'taken';
565
+ }>;
566
+ notFound: AdoptRateLimitRuleEntry[];
567
+ /** Live rules in the named zones that no entry named. Reported, never touched. */
568
+ unclaimed: PlatformRateLimitRuleView[];
569
+ }
570
+ /** A Cloudflare zone seen with the platform credential. A zone is the root of a
571
+ * company's domain, so edge only looks it up, creates it and adopts it: there is no delete. */
572
+ export interface PlatformZoneView {
573
+ /** Cloudflare's zone id. */
574
+ id: string;
575
+ name: string;
576
+ /** Cloudflare's zone status, such as `pending` until the registrar delegates. */
577
+ status: string;
578
+ /** What the domain's registrar must delegate to. */
579
+ nameServers: string[];
580
+ /** Who owns it: the platform, or `null` when no row exists (a live zone
581
+ * nobody adopted: reported, never touched). */
582
+ owner: 'platform' | null;
583
+ /** The company the zone serves; `'platform'` when none. `null` for a zone with no row. */
584
+ organisationId: string | null;
585
+ state: 'pending' | 'active' | 'removed' | null;
586
+ }
587
+ export interface ListPlatformZonesRequest {
588
+ /** The zone's exact name, such as `example.com`. */
589
+ name: string;
590
+ }
591
+ /** Empty when no zone has that name. */
592
+ export interface ListPlatformZonesResponse {
593
+ zones: PlatformZoneView[];
594
+ }
595
+ export interface CreatePlatformZoneRequest {
596
+ /** The domain's apex, such as `example.com`. Lower-cased. */
597
+ name: string;
598
+ /** The company the zone serves. Omit for a zone that serves none. */
599
+ organisationId?: string;
600
+ }
601
+ export interface AdoptZoneEntry {
602
+ name: string;
603
+ }
604
+ export interface AdoptZonesRequest {
605
+ zones: AdoptZoneEntry[];
606
+ /** The company the adopted zones serve. Omit for none. */
607
+ organisationId?: string;
608
+ }
609
+ export interface AdoptZonesResponse {
610
+ adopted: PlatformZoneView[];
611
+ alreadyAdopted: PlatformZoneView[];
612
+ /** `taken`: a row for that name holds a different zone. */
613
+ skipped: Array<{
614
+ zone: PlatformZoneView;
615
+ reason: 'taken';
616
+ }>;
617
+ notFound: AdoptZoneEntry[];
618
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",