@uploadista/data-store-r2 0.0.9 → 0.0.11

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.cts CHANGED
@@ -1,8 +1,17 @@
1
- import { Effect } from "effect";
2
- import { R2Bucket } from "@cloudflare/workers-types";
1
+ import { DataStore, UploadFile, UploadFileKVStore } from "@uploadista/core/types";
2
+ import { Context, Effect } from "effect";
3
+ import { R2Bucket, R2UploadedPart, ReadableStream } from "@cloudflare/workers-types";
4
+ import { UploadistaError } from "@uploadista/core/errors";
3
5
 
4
6
  //#region src/types.d.ts
5
7
 
8
+ /**
9
+ * Extended R2UploadedPart type that includes size property
10
+ * Cloudflare's R2UploadedPart doesn't include size, but we need it for tracking
11
+ */
12
+ type R2UploadedPart$1 = R2UploadedPart & {
13
+ size: number;
14
+ };
6
15
  type R2StoreOptions = {
7
16
  deliveryUrl: string;
8
17
  /**
@@ -27,11 +36,47 @@ type R2StoreOptions = {
27
36
  bucket: string;
28
37
  r2Bucket: R2Bucket;
29
38
  };
39
+ type R2OperationContext = {
40
+ uploadId: string;
41
+ bucket: string;
42
+ key: string;
43
+ partNumber?: number;
44
+ partSize?: number;
45
+ contentType?: string;
46
+ cacheControl?: string;
47
+ };
48
+ type MultipartUploadInfo = {
49
+ uploadId: string;
50
+ bucket: string;
51
+ key: string;
52
+ };
30
53
  type R2StoreConfig = R2StoreOptions;
31
54
  //#endregion
55
+ //#region src/services/r2-client.service.d.ts
56
+ declare const R2ClientService_base: Context.TagClass<R2ClientService, "R2ClientService", {
57
+ readonly bucket: string;
58
+ readonly getObject: (key: string) => Effect.Effect<ReadableStream, UploadistaError>;
59
+ readonly headObject: (key: string) => Effect.Effect<number | undefined, UploadistaError>;
60
+ readonly putObject: (key: string, body: Uint8Array) => Effect.Effect<string, UploadistaError>;
61
+ readonly deleteObject: (key: string) => Effect.Effect<void, UploadistaError>;
62
+ readonly deleteObjects: (keys: string[]) => Effect.Effect<void, UploadistaError>;
63
+ readonly createMultipartUpload: (context: R2OperationContext) => Effect.Effect<MultipartUploadInfo, UploadistaError>;
64
+ readonly uploadPart: (context: R2OperationContext & {
65
+ partNumber: number;
66
+ data: Uint8Array;
67
+ }) => Effect.Effect<string, UploadistaError>;
68
+ readonly completeMultipartUpload: (context: R2OperationContext, parts: Array<R2UploadedPart$1>) => Effect.Effect<string | undefined, UploadistaError>;
69
+ readonly abortMultipartUpload: (context: R2OperationContext) => Effect.Effect<void, UploadistaError>;
70
+ readonly getIncompletePart: (id: string) => Effect.Effect<ReadableStream | undefined, UploadistaError>;
71
+ readonly getIncompletePartSize: (id: string) => Effect.Effect<number | undefined, UploadistaError>;
72
+ readonly putIncompletePart: (id: string, data: Uint8Array) => Effect.Effect<string, UploadistaError>;
73
+ readonly deleteIncompletePart: (id: string) => Effect.Effect<void, UploadistaError>;
74
+ }>;
75
+ declare class R2ClientService extends R2ClientService_base {}
76
+ //#endregion
32
77
  //#region src/r2-store.d.ts
33
- declare function createR2Store(config: R2StoreConfig): Effect.Effect<DataStore<UploadFile>, unknown, unknown>;
34
- declare const r2Store: (options: R2StoreConfig) => Effect.Effect<DataStore<UploadFile>, unknown, unknown>;
78
+ declare function createR2Store(config: R2StoreConfig): Effect.Effect<DataStore<UploadFile>, never, R2ClientService | UploadFileKVStore>;
79
+ declare const r2Store: (options: R2StoreConfig) => Effect.Effect<DataStore<UploadFile>, never, UploadFileKVStore>;
35
80
  //#endregion
36
81
  export { createR2Store, r2Store };
37
82
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/r2-store.ts"],"sourcesContent":[],"mappings":";;;;;ACqDmD,KD/BvC,cAAA,GC+BuC;EAAA,WAAA,EAAA,MAAA;EAAA;;AAg4BnD;;;EAA8C,QAAA,CAAA,EAAA,MAAA;EAAA;;;;;;;;;;;;;;YDx4BlC;;KA4DA,aAAA,GAAgB;;;iBCpDZ,aAAA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AAtB,cAfI,eAAA,SAAwB,oBAAA,CAerB;;;iBC4BA,aAAA,SAAsB,gBAAa,MAAA,CAAA,OAAA,UAAA,oBAAA,kBAAA;AFnCvC,cEm6BC,OFn6Ba,EAAA,CAAA,OAAG,EEm6BI,aFn6BoB,EAAA,GEm6BP,MAAA,CAAA,MFn6BO,CEm6BP,SFn6BO,CEm6BP,UFn6BO,CAAA,EAAA,KAAA,EEm6BP,iBFn6BO,CAAA"}
package/dist/index.d.mts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { UploadistaError } from "@uploadista/core/errors";
2
- import "@uploadista/core/types";
3
- import { Effect } from "effect";
4
- import { R2Bucket } from "@cloudflare/workers-types";
2
+ import { DataStore, UploadFile, UploadFileKVStore } from "@uploadista/core/types";
3
+ import { Context, Effect, Layer } from "effect";
4
+ import { R2Bucket, R2UploadedPart, ReadableStream } from "@cloudflare/workers-types";
5
5
 
6
6
  //#region src/types.d.ts
7
7
 
8
+ /**
9
+ * Extended R2UploadedPart type that includes size property
10
+ * Cloudflare's R2UploadedPart doesn't include size, but we need it for tracking
11
+ */
12
+ type R2UploadedPart$1 = R2UploadedPart & {
13
+ size: number;
14
+ };
8
15
  type R2StoreOptions = {
9
16
  deliveryUrl: string;
10
17
  /**
@@ -29,11 +36,47 @@ type R2StoreOptions = {
29
36
  bucket: string;
30
37
  r2Bucket: R2Bucket;
31
38
  };
39
+ type R2OperationContext = {
40
+ uploadId: string;
41
+ bucket: string;
42
+ key: string;
43
+ partNumber?: number;
44
+ partSize?: number;
45
+ contentType?: string;
46
+ cacheControl?: string;
47
+ };
48
+ type MultipartUploadInfo = {
49
+ uploadId: string;
50
+ bucket: string;
51
+ key: string;
52
+ };
32
53
  type R2StoreConfig = R2StoreOptions;
33
54
  //#endregion
55
+ //#region src/services/r2-client.service.d.ts
56
+ declare const R2ClientService_base: Context.TagClass<R2ClientService, "R2ClientService", {
57
+ readonly bucket: string;
58
+ readonly getObject: (key: string) => Effect.Effect<ReadableStream, UploadistaError>;
59
+ readonly headObject: (key: string) => Effect.Effect<number | undefined, UploadistaError>;
60
+ readonly putObject: (key: string, body: Uint8Array) => Effect.Effect<string, UploadistaError>;
61
+ readonly deleteObject: (key: string) => Effect.Effect<void, UploadistaError>;
62
+ readonly deleteObjects: (keys: string[]) => Effect.Effect<void, UploadistaError>;
63
+ readonly createMultipartUpload: (context: R2OperationContext) => Effect.Effect<MultipartUploadInfo, UploadistaError>;
64
+ readonly uploadPart: (context: R2OperationContext & {
65
+ partNumber: number;
66
+ data: Uint8Array;
67
+ }) => Effect.Effect<string, UploadistaError>;
68
+ readonly completeMultipartUpload: (context: R2OperationContext, parts: Array<R2UploadedPart$1>) => Effect.Effect<string | undefined, UploadistaError>;
69
+ readonly abortMultipartUpload: (context: R2OperationContext) => Effect.Effect<void, UploadistaError>;
70
+ readonly getIncompletePart: (id: string) => Effect.Effect<ReadableStream | undefined, UploadistaError>;
71
+ readonly getIncompletePartSize: (id: string) => Effect.Effect<number | undefined, UploadistaError>;
72
+ readonly putIncompletePart: (id: string, data: Uint8Array) => Effect.Effect<string, UploadistaError>;
73
+ readonly deleteIncompletePart: (id: string) => Effect.Effect<void, UploadistaError>;
74
+ }>;
75
+ declare class R2ClientService extends R2ClientService_base {}
76
+ //#endregion
34
77
  //#region src/r2-store.d.ts
35
- declare function createR2Store(config: R2StoreConfig): Effect.Effect<DataStore<UploadFile>, unknown, unknown>;
36
- declare const r2Store: (options: R2StoreConfig) => Effect.Effect<DataStore<UploadFile>, unknown, unknown>;
78
+ declare function createR2Store(config: R2StoreConfig): Effect.Effect<DataStore<UploadFile>, never, R2ClientService | UploadFileKVStore>;
79
+ declare const r2Store: (options: R2StoreConfig) => Effect.Effect<DataStore<UploadFile>, never, UploadFileKVStore>;
37
80
  //#endregion
38
81
  export { createR2Store, r2Store };
39
82
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/r2-store.ts"],"sourcesContent":[],"mappings":";;;;;;;ACqDgB,KD/BJ,cAAA,GC+BiB;EAAS,WAAA,EAAA,MAAA;EAAa;;;;AAg4BnD;EAAiC,QAAA,CAAA,EAAA,MAAA;EAAa;;;;;;;;;;;;;;YDx4BlC;;KA4DA,aAAA,GAAgB;;;iBCpDZ,aAAA,SAAsB,gBAAa,MAAA,CAAA,OAAA,UAAA;cAg4BtC,mBAAoB,kBAAa,MAAA,CAAA,OAAA,UAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/services/r2-client.service.ts","../src/r2-store.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkBA;AAIA;AAiCY,KArCA,gBAAA,GAAiB,cAqCC,GAAA;EAelB,IAAA,EAAA,MAAA;AAmCZ,CAAA;KAnFY,cAAA;;;ACf4E;;;;EAW/E,QAAO,CAAA,EAAA,MAAA;EAG2B;;;;;EAOd,WAAA,CAAA,EAAA,MAAA;EAApB;;;EAOM,iBAAA,CAAA,EAAA,MAAA;EACQ,OAAA,CAAA,EAAA,OAAA;EAAqB,wBAAA,CAAA,EAAA,MAAA;EAAnC,8BAAO,CAAA,EAAA,MAAA;EAED,MAAA,EAAA,MAAA;EAAiD,QAAA,EDOpD,QCPoD;CACjC;AAMhB,KDUH,kBAAA,GCVG;EACc,QAAA,EAAA,MAAA;EAApB,MAAO,EAAA,MAAA;EAKO,GAAA,EAAA,MAAA;EAA4B,UAAA,CAAA,EAAA,MAAA;EAA1C,QAAO,CAAA,EAAA,MAAA;EAG2B,WAAA,CAAA,EAAA,MAAA;EAAlC,YAAO,CAAA,EAAA,MAAA;CAGJ;KDaA,mBAAA;;EC5DC,MAAA,EAAA,MAAA;;;KD+FD,aAAA,GAAgB;;;cClG4D;;EDW5E,SAAA,SAAA,EAAc,CAAA,GAAA,EAAA,MAAG,EAAA,GCApB,MAAA,CAAO,MDAqC,CCA9B,cDA8B,ECAd,eDAc,CAAA;EAIzC,SAAA,UAAc,EAAA,CAAA,GAAA,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CI,EAAA,GAqCP,MAAA,CAAO,MArCA,CAAA,MAAA,EAqCe,eArCf,CAAA;EAGJ,SAAA,oBAAA,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GAqCH,MAAA,CAAO,MArCJ,CAAA,IAAA,EAqCiB,eArCjB,CAAA;CACmB,CAAA;AAAtB,cAfI,eAAA,SAAwB,oBAAA,CAerB;;;iBC4BA,aAAA,SAAsB,gBAAa,MAAA,CAAA,OAAA,UAAA,oBAAA,kBAAA;AFnCvC,cEm6BC,OFn6Ba,EAAA,CAAA,OAAG,EEm6BI,aFn6BoB,EAAA,GEm6BP,MAAA,CAAA,MFn6BO,CEm6BP,SFn6BO,CEm6BP,UFn6BO,CAAA,EAAA,KAAA,EEm6BP,iBFn6BO,CAAA"}
package/package.json CHANGED
@@ -1,27 +1,28 @@
1
1
  {
2
2
  "name": "@uploadista/data-store-r2",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "description": "Cloudflare R2 data store for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
10
+ "types": "./dist/index.d.mts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs",
13
+ "default": "./dist/index.mjs"
13
14
  }
14
15
  },
15
16
  "dependencies": {
16
17
  "@cloudflare/workers-types": "4.20251014.0",
17
18
  "effect": "3.19.0",
18
- "@uploadista/core": "0.0.9",
19
- "@uploadista/observability": "0.0.9"
19
+ "@uploadista/core": "0.0.11",
20
+ "@uploadista/observability": "0.0.11"
20
21
  },
21
22
  "devDependencies": {
22
23
  "tsdown": "0.16.0",
23
24
  "vitest": "4.0.7",
24
- "@uploadista/typescript-config": "0.0.9"
25
+ "@uploadista/typescript-config": "0.0.11"
25
26
  },
26
27
  "scripts": {
27
28
  "build": "tsdown",