@attlaz/client 1.112.0 → 1.113.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.
@@ -20,6 +20,11 @@ export declare class StorageEndpoint extends Endpoint {
20
20
  * JSON envelope would either inflate it (base64) or destroy it (a UTF-8 decode replaces every
21
21
  * invalid sequence, so bytes do not survive the round trip).
22
22
  */
23
+ /**
24
+ * Whether an item exists, without transferring it. Backed by HEAD, so a content-addressed check
25
+ * ("do I already have these bytes?") costs headers rather than the whole object.
26
+ */
27
+ hasItem(projectEnvironmentId: string, storageType: StorageType, bucketKey: string, storageItemKey: string): Promise<boolean>;
23
28
  getItemBytes(projectEnvironmentId: string, storageType: StorageType, bucketKey: string, storageItemKey: string): Promise<Buffer>;
24
29
  /**
25
30
  * Store raw bytes. Metadata travels as headers, since the body is the value.
@@ -3,6 +3,8 @@ import { StorageInformation } from '../Model/Storage/StorageInformation.js';
3
3
  import { StorageItem } from '../Model/Storage/StorageItem.js';
4
4
  import { StorageItemInformation } from '../Model/Storage/StorageItemInformation.js';
5
5
  import { QueryString } from '../Http/Data/QueryString.js';
6
+ import { ClientError } from '../Http/ClientError.js';
7
+ import { HttpStatus } from '../Http/HttpStatus.js';
6
8
  import { Endpoint } from './Endpoint.js';
7
9
  export class StorageEndpoint extends Endpoint {
8
10
  async getInformation(projectEnvironmentId, storageType) {
@@ -98,6 +100,23 @@ export class StorageEndpoint extends Endpoint {
98
100
  * JSON envelope would either inflate it (base64) or destroy it (a UTF-8 decode replaces every
99
101
  * invalid sequence, so bytes do not survive the round trip).
100
102
  */
103
+ /**
104
+ * Whether an item exists, without transferring it. Backed by HEAD, so a content-addressed check
105
+ * ("do I already have these bytes?") costs headers rather than the whole object.
106
+ */
107
+ async hasItem(projectEnvironmentId, storageType, bucketKey, storageItemKey) {
108
+ const cmd = path('/projectenvironments/:projectEnvironmentId/storage/:storageType/:bucketKey/items/:key', { projectEnvironmentId, storageType, bucketKey, key: storageItemKey });
109
+ try {
110
+ await this.requestBytes(cmd, null, 'HEAD');
111
+ return true;
112
+ }
113
+ catch (error) {
114
+ if (ClientError.statusOf(error) === HttpStatus.HTTP_NOTFOUND) {
115
+ return false;
116
+ }
117
+ throw error;
118
+ }
119
+ }
101
120
  async getItemBytes(projectEnvironmentId, storageType, bucketKey, storageItemKey) {
102
121
  const cmd = path('/projectenvironments/:projectEnvironmentId/storage/:storageType/:bucketKey/items/:key', { projectEnvironmentId, storageType, bucketKey, key: storageItemKey });
103
122
  return await this.requestBytes(cmd);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.111.0";
1
+ export declare const VERSION = "1.112.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.111.0";
1
+ export const VERSION = "1.112.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.112.0",
3
+ "version": "1.113.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",