@wild-framework/storage 0.1.1 → 0.2.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @wild-framework/storage
2
2
 
3
- File storage abstraction for [Wild Framework](https://github.com/your-org/wild-framework).
3
+ File storage abstraction for [Wild Framework](https://github.com/KhandaSoftware/wild-framework).
4
4
 
5
5
  ## Install
6
6
 
@@ -13,13 +13,22 @@ pnpm add @wild-framework/storage
13
13
  ```ts
14
14
  import { Storage } from "@wild-framework/storage";
15
15
 
16
- await storage.put("avatars/photo.jpg", buffer);
16
+ await storage.put("avatars/photo.jpg", buffer, { contentType: "image/jpeg" });
17
17
  const contents = await storage.get("avatars/photo.jpg");
18
18
  await storage.exists("avatars/photo.jpg");
19
19
  await storage.delete("avatars/photo.jpg");
20
+ const url = await storage.url("avatars/photo.jpg"); // or { expiresIn: 3600 }
20
21
  ```
21
22
 
22
- Ships with a local filesystem driver. Implement `StorageDriver` for S3/GCS.
23
+ Ships with a local filesystem driver (path-traversal-safe).
24
+
25
+ Cloud backends:
26
+
27
+ - `@wild-framework/storage-s3` — AWS S3 + S3-compatible (MinIO, R2, …)
28
+ - `@wild-framework/storage-gcs` — Google Cloud Storage
29
+ - `@wild-framework/storage-auto` — env-driven (`STORAGE_DRIVER`)
30
+
31
+ Implement `StorageDriver` for any other backend.
23
32
 
24
33
  ## License
25
34
 
package/dist/driver.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Options for storing a file.
3
+ */
4
+ export interface PutOptions {
5
+ /** MIME type, e.g. `image/png`. Cloud backends store it as Content-Type. */
6
+ contentType?: string;
7
+ /** Arbitrary string metadata stored on backends that support it. */
8
+ metadata?: Record<string, string>;
9
+ }
10
+ /**
11
+ * Options for generating a URL.
12
+ */
13
+ export interface UrlOptions {
14
+ /** Return a signed URL that expires after this many seconds (private buckets). */
15
+ expiresIn?: number;
16
+ }
1
17
  /**
2
18
  * Storage driver contract.
3
19
  *
@@ -6,14 +22,14 @@
6
22
  */
7
23
  export interface StorageDriver {
8
24
  /** Store a file at the given path. Returns the stored path. */
9
- put(path: string, contents: Buffer | string): Promise<string>;
25
+ put(path: string, contents: Buffer | string, options?: PutOptions): Promise<string>;
10
26
  /** Read a file's contents. */
11
27
  get(path: string): Promise<Buffer>;
12
28
  /** Delete a file. */
13
29
  delete(path: string): Promise<void>;
14
30
  /** Check whether a file exists. */
15
31
  exists(path: string): Promise<boolean>;
16
- /** Get a public URL for a file. */
17
- url(path: string): Promise<string>;
32
+ /** Get a URL (optionally signed) for a file. */
33
+ url(path: string, options?: UrlOptions): Promise<string>;
18
34
  }
19
35
  //# sourceMappingURL=driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9D,8BAA8B;IAC9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,qBAAqB;IACrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,mCAAmC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,mCAAmC;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtC"}
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpF,8BAA8B;IAC9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,qBAAqB;IACrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,mCAAmC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,gDAAgD;IAChD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { Storage } from "./storage.js";
2
2
  export { StorageProvider } from "./provider.js";
3
3
  export { LocalStorageDriver } from "./local-driver.js";
4
- export type { StorageDriver } from "./driver.js";
4
+ export type { StorageDriver, PutOptions, UrlOptions } from "./driver.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { StorageDriver } from "./driver.js";
1
+ import type { StorageDriver, PutOptions, UrlOptions } from "./driver.js";
2
2
  /**
3
3
  * Filesystem-backed storage driver.
4
4
  *
@@ -7,11 +7,13 @@ import type { StorageDriver } from "./driver.js";
7
7
  export declare class LocalStorageDriver implements StorageDriver {
8
8
  private basePath;
9
9
  constructor(basePath: string);
10
- put(filePath: string, contents: Buffer | string): Promise<string>;
10
+ connect(): Promise<void>;
11
+ close(): Promise<void>;
12
+ put(filePath: string, contents: Buffer | string, _options?: PutOptions): Promise<string>;
11
13
  get(filePath: string): Promise<Buffer>;
12
14
  delete(filePath: string): Promise<void>;
13
15
  exists(filePath: string): Promise<boolean>;
14
- url(filePath: string): Promise<string>;
16
+ url(filePath: string, _options?: UrlOptions): Promise<string>;
15
17
  private resolve;
16
18
  }
17
19
  //# sourceMappingURL=local-driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-driver.d.ts","sourceRoot":"","sources":["../src/local-driver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACxC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAM9B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOjE,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKtC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU1C,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK5C,OAAO,CAAC,OAAO;CAWlB"}
1
+ {"version":3,"file":"local-driver.d.ts","sourceRoot":"","sources":["../src/local-driver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACxC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAM9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxF,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKtC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU1C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAKnE,OAAO,CAAC,OAAO;CAWlB"}
@@ -13,7 +13,13 @@ export class LocalStorageDriver {
13
13
  throw new Error("LocalStorageDriver requires a base path.");
14
14
  }
15
15
  }
16
- async put(filePath, contents) {
16
+ async connect() {
17
+ // No persistent connection — kept for provider symmetry.
18
+ }
19
+ async close() {
20
+ // No persistent connection — kept for provider symmetry.
21
+ }
22
+ async put(filePath, contents, _options) {
17
23
  const absolute = this.resolve(filePath);
18
24
  await fs.mkdir(path.dirname(absolute), { recursive: true });
19
25
  await fs.writeFile(absolute, contents);
@@ -37,7 +43,7 @@ export class LocalStorageDriver {
37
43
  return false;
38
44
  }
39
45
  }
40
- async url(filePath) {
46
+ async url(filePath, _options) {
41
47
  // Local files don't have a public URL — return the path.
42
48
  return filePath;
43
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"local-driver.js","sourceRoot":"","sources":["../src/local-driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACP;IAApB,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,QAAyB;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,C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KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,QAAqB;QAC7C,yDAAyD;QACzD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,OAAO,CAAC,QAAgB;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE9C,oDAAoD;QACpD,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,uCAAuC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
@@ -1,12 +1,21 @@
1
1
  import type { Provider, Application } from "@wild-framework/core";
2
2
  /**
3
- * Registers the file storage with the application.
3
+ * Registers local filesystem storage with the application.
4
+ *
5
+ * Static configuration (no-arg constructor requirement):
6
+ *
7
+ * ```ts
8
+ * StorageProvider.basePath = "./uploads"; // default "./storage"
9
+ * ```
4
10
  *
5
- * Binds a `Storage` backed by the local filesystem driver.
6
11
  * Swap drivers by implementing `StorageDriver` and binding a new
7
- * `Storage` — app code never changes.
12
+ * `Storage` — app code never changes. Cloud backends live in
13
+ * `@wild-framework/storage-s3`, `@wild-framework/storage-gcs`,
14
+ * and the env-driven `@wild-framework/storage-auto`.
8
15
  */
9
16
  export declare class StorageProvider implements Provider {
17
+ /** Local filesystem base directory. Defaults to `./storage`. */
18
+ static basePath: string;
10
19
  register(app: Application): void;
11
20
  }
12
21
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC5C,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAKnC"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC5C,gEAAgE;IAChE,MAAM,CAAC,QAAQ,SAAe;IAE9B,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAKnC"}
package/dist/provider.js CHANGED
@@ -2,16 +2,25 @@ import { Container } from "@wild-framework/container";
2
2
  import { Storage } from "./storage.js";
3
3
  import { LocalStorageDriver } from "./local-driver.js";
4
4
  /**
5
- * Registers the file storage with the application.
5
+ * Registers local filesystem storage with the application.
6
+ *
7
+ * Static configuration (no-arg constructor requirement):
8
+ *
9
+ * ```ts
10
+ * StorageProvider.basePath = "./uploads"; // default "./storage"
11
+ * ```
6
12
  *
7
- * Binds a `Storage` backed by the local filesystem driver.
8
13
  * Swap drivers by implementing `StorageDriver` and binding a new
9
- * `Storage` — app code never changes.
14
+ * `Storage` — app code never changes. Cloud backends live in
15
+ * `@wild-framework/storage-s3`, `@wild-framework/storage-gcs`,
16
+ * and the env-driven `@wild-framework/storage-auto`.
10
17
  */
11
18
  export class StorageProvider {
19
+ /** Local filesystem base directory. Defaults to `./storage`. */
20
+ static basePath = "./storage";
12
21
  register(app) {
13
22
  const container = app.resolve(Container);
14
- const storage = new Storage(new LocalStorageDriver("./storage"));
23
+ const storage = new Storage(new LocalStorageDriver(StorageProvider.basePath));
15
24
  container.singleton(Storage, () => storage);
16
25
  }
17
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACxB,QAAQ,CAAC,GAAgB;QACrB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;QACjE,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ"}
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAe;IACxB,gEAAgE;IAChE,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC;IAE9B,QAAQ,CAAC,GAAgB;QACrB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,kBAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9E,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC"}
package/dist/storage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StorageDriver } from "./driver.js";
1
+ import type { StorageDriver, PutOptions, UrlOptions } from "./driver.js";
2
2
  /**
3
3
  * File storage facade.
4
4
  *
@@ -9,14 +9,14 @@ export declare class Storage {
9
9
  private driver;
10
10
  constructor(driver: StorageDriver);
11
11
  /** Store a file at the given path. Returns the stored path. */
12
- put(path: string, contents: Buffer | string): Promise<string>;
12
+ put(path: string, contents: Buffer | string, options?: PutOptions): Promise<string>;
13
13
  /** Read a file's contents. */
14
14
  get(path: string): Promise<Buffer>;
15
15
  /** Delete a file. */
16
16
  delete(path: string): Promise<void>;
17
17
  /** Check whether a file exists. */
18
18
  exists(path: string): Promise<boolean>;
19
- /** Get a public URL for a file. */
20
- url(path: string): Promise<string>;
19
+ /** Get a URL (optionally signed) for a file. */
20
+ url(path: string, options?: UrlOptions): Promise<string>;
21
21
  }
22
22
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,qBAAa,OAAO;IACJ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEzC,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7D,8BAA8B;IAC9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlC,qBAAqB;IACrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,mCAAmC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItC,mCAAmC;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGrC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;;GAKG;AACH,qBAAa,OAAO;IACJ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEzC,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAInF,8BAA8B;IAC9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlC,qBAAqB;IACrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,mCAAmC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItC,gDAAgD;IAChD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CAG3D"}
package/dist/storage.js CHANGED
@@ -10,8 +10,8 @@ export class Storage {
10
10
  this.driver = driver;
11
11
  }
12
12
  /** Store a file at the given path. Returns the stored path. */
13
- put(path, contents) {
14
- return this.driver.put(path, contents);
13
+ put(path, contents, options) {
14
+ return this.driver.put(path, contents, options);
15
15
  }
16
16
  /** Read a file's contents. */
17
17
  get(path) {
@@ -25,9 +25,9 @@ export class Storage {
25
25
  exists(path) {
26
26
  return this.driver.exists(path);
27
27
  }
28
- /** Get a public URL for a file. */
29
- url(path) {
30
- return this.driver.url(path);
28
+ /** Get a URL (optionally signed) for a file. */
29
+ url(path, options) {
30
+ return this.driver.url(path, options);
31
31
  }
32
32
  }
33
33
  //# sourceMappingURL=storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IACI;IAApB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,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,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,gDAAgD;IAChD,GAAG,CAAC,IAAY,EAAE,OAAoB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wild-framework/storage",
3
- "version": "0.1.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "author": "Sphah",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/KhandaSoftware/wild-framework.git"
23
+ "url": "git+https://github.com/Khandasoftware/wild-framework.git"
24
24
  },
25
25
  "description": "File storage abstraction for Wild Framework.",
26
26
  "keywords": [
@@ -31,8 +31,8 @@
31
31
  "s3"
32
32
  ],
33
33
  "dependencies": {
34
- "@wild-framework/core": "0.1.1",
35
- "@wild-framework/container": "0.1.1"
34
+ "@wild-framework/core": "0.2.2",
35
+ "@wild-framework/container": "0.2.2"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsc",