@distilled.cloud/cloudflare 0.10.0 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/cloudflare",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -56,14 +56,14 @@
56
56
  "fmt": "oxfmt --write src",
57
57
  "lint": "oxlint --fix src",
58
58
  "check": "tsgo && oxlint src && oxfmt --check src",
59
- "test": "bunx vitest run test --exclude specs",
59
+ "test": "vitest run --exclude specs",
60
60
  "publish:npm": "bun run build && bun publish --access public",
61
61
  "generate": "bun run scripts/generate.ts && oxlint --fix src && oxfmt --write src && oxfmt --write src",
62
62
  "specs:fetch": "git submodule update --force --init --recursive --depth=1 specs/cloudflare-typescript && git -C specs/cloudflare-typescript checkout -- .",
63
63
  "specs:update": "git -C specs/cloudflare-typescript fetch && git -C specs/cloudflare-typescript checkout main && git -C specs/cloudflare-typescript pull"
64
64
  },
65
65
  "dependencies": {
66
- "@distilled.cloud/core": "0.10.0",
66
+ "@distilled.cloud/core": "0.10.2",
67
67
  "effect": "4.0.0-beta.48"
68
68
  },
69
69
  "devDependencies": {
@@ -378,7 +378,7 @@ export interface CreateConsumerRequest {
378
378
  retryDelay?: number;
379
379
  };
380
380
  /** Body param: */
381
- type?: "worker";
381
+ type: "worker" | "http_pull";
382
382
  }
383
383
 
384
384
  export const CreateConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
@@ -403,7 +403,7 @@ export const CreateConsumerRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
403
403
  }),
404
404
  ),
405
405
  ),
406
- type: Schema.optional(Schema.Literal("worker")),
406
+ type: Schema.Literals(["worker", "http_pull"]),
407
407
  }).pipe(
408
408
  Schema.encodeKeys({
409
409
  deadLetterQueue: "dead_letter_queue",
@@ -1068,11 +1068,12 @@ export interface PushMessageRequest {
1068
1068
  export const PushMessageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
1069
1069
  queueId: Schema.String.pipe(T.HttpPath("queueId")),
1070
1070
  accountId: Schema.String.pipe(T.HttpPath("account_id")),
1071
- body: Schema.optional(Schema.String).pipe(T.HttpBody()),
1071
+ body: Schema.optional(Schema.String),
1072
1072
  contentType: Schema.optional(Schema.Literal("text")),
1073
1073
  delaySeconds: Schema.optional(Schema.Number),
1074
1074
  }).pipe(
1075
1075
  Schema.encodeKeys({
1076
+ body: "body",
1076
1077
  contentType: "content_type",
1077
1078
  delaySeconds: "delay_seconds",
1078
1079
  }),
@@ -20,7 +20,7 @@ export class InvalidCredential extends Schema.TaggedErrorClass<InvalidCredential
20
20
  "InvalidCredential",
21
21
  { code: Schema.Number, message: Schema.String },
22
22
  ) {}
23
- T.applyErrorMatchers(InvalidCredential, [{ code: 30004 }]);
23
+ T.applyErrorMatchers(InvalidCredential, [{ code: 30004 }, { code: 30005 }]);
24
24
 
25
25
  export class InvalidRoute extends Schema.TaggedErrorClass<InvalidRoute>()(
26
26
  "InvalidRoute",
@@ -11,6 +11,7 @@ import * as API from "../client/api.ts";
11
11
  import * as T from "../traits.ts";
12
12
  import type { Credentials } from "../credentials.ts";
13
13
  import { type DefaultErrors } from "../errors.ts";
14
+ import { UploadableSchema } from "../schemas.ts";
14
15
  import { SensitiveString } from "../sensitive.ts";
15
16
 
16
17
  // =============================================================================
@@ -2532,8 +2533,149 @@ export const deleteBucketSippy: API.OperationMethod<
2532
2533
  // Object
2533
2534
  // =============================================================================
2534
2535
 
2536
+ export interface GetObjectRequest {
2537
+ /** Name of the R2 bucket. */
2538
+ bucketName: string;
2539
+ /** Key (name) of the object. */
2540
+ objectName: string;
2541
+ /** Account ID. */
2542
+ accountId: string;
2543
+ /** Jurisdiction where objects in this bucket are guaranteed to be stored. */
2544
+ cfR2Jurisdiction?: "default" | "eu" | "fedramp";
2545
+ }
2546
+
2547
+ export const GetObjectRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
2548
+ bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
2549
+ objectName: Schema.String.pipe(T.HttpPath("objectName")),
2550
+ accountId: Schema.String.pipe(T.HttpPath("account_id")),
2551
+ cfR2Jurisdiction: Schema.optional(
2552
+ Schema.Literals(["default", "eu", "fedramp"]),
2553
+ ).pipe(T.HttpHeader("cf-r2-jurisdiction")),
2554
+ }).pipe(
2555
+ T.Http({
2556
+ method: "GET",
2557
+ path: "/accounts/{account_id}/r2/buckets/{bucketName}/objects/{objectName}",
2558
+ }),
2559
+ ) as unknown as Schema.Schema<GetObjectRequest>;
2560
+
2561
+ export type GetObjectResponse = File | Blob;
2562
+
2563
+ export const GetObjectResponse =
2564
+ /*@__PURE__*/ /*#__PURE__*/ UploadableSchema.pipe(T.HttpFormDataFile()).pipe(
2565
+ T.ResponsePath("result"),
2566
+ ) as unknown as Schema.Schema<GetObjectResponse>;
2567
+
2568
+ export type GetObjectError =
2569
+ | DefaultErrors
2570
+ | NoSuchBucket
2571
+ | InvalidRoute
2572
+ | NoRoute;
2573
+
2574
+ export const getObject: API.OperationMethod<
2575
+ GetObjectRequest,
2576
+ GetObjectResponse,
2577
+ GetObjectError,
2578
+ Credentials | HttpClient.HttpClient
2579
+ > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
2580
+ input: GetObjectRequest,
2581
+ output: GetObjectResponse,
2582
+ errors: [NoSuchBucket, InvalidRoute, NoRoute],
2583
+ }));
2584
+
2585
+ export interface PutObjectRequest {
2586
+ /** Name of the R2 bucket. */
2587
+ bucketName: string;
2588
+ /** Key (name) of the object. */
2589
+ objectName: string;
2590
+ /** Account ID. */
2591
+ accountId: string;
2592
+ /** Jurisdiction where objects in this bucket are guaranteed to be stored. */
2593
+ cfR2Jurisdiction?: "default" | "eu" | "fedramp";
2594
+ /** MIME type of the object. */
2595
+ contentType?: string;
2596
+ /** Content disposition of the object. */
2597
+ contentDisposition?: string;
2598
+ /** Content encoding of the object. */
2599
+ contentEncoding?: string;
2600
+ /** Content language of the object. */
2601
+ contentLanguage?: string;
2602
+ /** Content length of the object in bytes. */
2603
+ contentLength?: string;
2604
+ /** Cache control directives for the object. */
2605
+ cacheControl?: string;
2606
+ /** Expiration date of the object. */
2607
+ expires?: string;
2608
+ /** Storage class for the object. */
2609
+ cfR2StorageClass?: "Standard" | "InfrequentAccess";
2610
+ body: File | Blob;
2611
+ }
2612
+
2613
+ export const PutObjectRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
2614
+ bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
2615
+ objectName: Schema.String.pipe(T.HttpPath("objectName")),
2616
+ accountId: Schema.String.pipe(T.HttpPath("account_id")),
2617
+ cfR2Jurisdiction: Schema.optional(
2618
+ Schema.Literals(["default", "eu", "fedramp"]),
2619
+ ).pipe(T.HttpHeader("cf-r2-jurisdiction")),
2620
+ contentType: Schema.optional(Schema.String).pipe(
2621
+ T.HttpHeader("content-type"),
2622
+ ),
2623
+ contentDisposition: Schema.optional(Schema.String).pipe(
2624
+ T.HttpHeader("content-disposition"),
2625
+ ),
2626
+ contentEncoding: Schema.optional(Schema.String).pipe(
2627
+ T.HttpHeader("content-encoding"),
2628
+ ),
2629
+ contentLanguage: Schema.optional(Schema.String).pipe(
2630
+ T.HttpHeader("content-language"),
2631
+ ),
2632
+ contentLength: Schema.optional(Schema.String).pipe(
2633
+ T.HttpHeader("content-length"),
2634
+ ),
2635
+ cacheControl: Schema.optional(Schema.String).pipe(
2636
+ T.HttpHeader("cache-control"),
2637
+ ),
2638
+ expires: Schema.optional(Schema.String).pipe(T.HttpHeader("expires")),
2639
+ cfR2StorageClass: Schema.optional(
2640
+ Schema.Literals(["Standard", "InfrequentAccess"]),
2641
+ ).pipe(T.HttpHeader("cf-r2-storage-class")),
2642
+ body: UploadableSchema.pipe(T.HttpFormDataFile()).pipe(T.HttpBody()),
2643
+ }).pipe(
2644
+ T.Http({
2645
+ method: "PUT",
2646
+ path: "/accounts/{account_id}/r2/buckets/{bucketName}/objects/{objectName}",
2647
+ contentType: "multipart",
2648
+ }),
2649
+ ) as unknown as Schema.Schema<PutObjectRequest>;
2650
+
2651
+ export type PutObjectResponse = unknown;
2652
+
2653
+ export const PutObjectResponse =
2654
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Unknown.pipe(
2655
+ T.ResponsePath("result"),
2656
+ ) as unknown as Schema.Schema<PutObjectResponse>;
2657
+
2658
+ export type PutObjectError =
2659
+ | DefaultErrors
2660
+ | NoSuchBucket
2661
+ | InvalidRoute
2662
+ | NoRoute;
2663
+
2664
+ export const putObject: API.OperationMethod<
2665
+ PutObjectRequest,
2666
+ PutObjectResponse,
2667
+ PutObjectError,
2668
+ Credentials | HttpClient.HttpClient
2669
+ > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
2670
+ input: PutObjectRequest,
2671
+ output: PutObjectResponse,
2672
+ errors: [NoSuchBucket, InvalidRoute, NoRoute],
2673
+ }));
2674
+
2535
2675
  export interface DeleteObjectRequest {
2676
+ /** Name of the R2 bucket. */
2536
2677
  bucketName: string;
2678
+ /** Key (name) of the object. */
2537
2679
  objectName: string;
2538
2680
  /** Account ID. */
2539
2681
  accountId: string;
@@ -70,7 +70,7 @@ export const CreateTraceRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
70
70
  plainText: "plain_text",
71
71
  }),
72
72
  ),
73
- ).pipe(T.HttpBody()),
73
+ ),
74
74
  context: Schema.optional(
75
75
  Schema.Struct({
76
76
  botScore: Schema.optional(Schema.Number),
@@ -120,6 +120,7 @@ export const CreateTraceRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
120
120
  Schema.encodeKeys({
121
121
  method: "method",
122
122
  url: "url",
123
+ body: "body",
123
124
  context: "context",
124
125
  cookies: "cookies",
125
126
  headers: "headers",
@@ -35,6 +35,17 @@ export class DomainNotFound extends Schema.TaggedErrorClass<DomainNotFound>()(
35
35
  ) {}
36
36
  T.applyErrorMatchers(DomainNotFound, [{ code: 100114 }]);
37
37
 
38
+ export class DuplicateMigrationTarget extends Schema.TaggedErrorClass<DuplicateMigrationTarget>()(
39
+ "DuplicateMigrationTarget",
40
+ { code: Schema.Number, message: Schema.String },
41
+ ) {}
42
+ T.applyErrorMatchers(DuplicateMigrationTarget, [
43
+ {
44
+ code: 10074,
45
+ message: { includes: "cannot be the target of more than one migration" },
46
+ },
47
+ ]);
48
+
38
49
  export class DurableObjectMustBeSqlite extends Schema.TaggedErrorClass<DurableObjectMustBeSqlite>()(
39
50
  "DurableObjectMustBeSqlite",
40
51
  { code: Schema.Number, message: Schema.String },
@@ -7472,7 +7483,8 @@ export type PutScriptError =
7472
7483
  | DefaultErrors
7473
7484
  | InvalidRoute
7474
7485
  | InvalidWorkerScript
7475
- | DurableObjectMustBeSqlite;
7486
+ | DurableObjectMustBeSqlite
7487
+ | DuplicateMigrationTarget;
7476
7488
 
7477
7489
  export const putScript: API.OperationMethod<
7478
7490
  PutScriptRequest,
@@ -7482,7 +7494,12 @@ export const putScript: API.OperationMethod<
7482
7494
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
7483
7495
  input: PutScriptRequest,
7484
7496
  output: PutScriptResponse,
7485
- errors: [InvalidRoute, InvalidWorkerScript, DurableObjectMustBeSqlite],
7497
+ errors: [
7498
+ InvalidRoute,
7499
+ InvalidWorkerScript,
7500
+ DurableObjectMustBeSqlite,
7501
+ DuplicateMigrationTarget,
7502
+ ],
7486
7503
  }));
7487
7504
 
7488
7505
  export interface DeleteScriptRequest {