@oino-ts/blob-azure 1.0.5 → 1.0.7

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.
@@ -38,6 +38,7 @@ const blob_1 = require("@oino-ts/blob");
38
38
  * })
39
39
  * ```
40
40
  */
41
+ const BLOB_AZURE_ILLEGAL_CHARS_REGEX = /[\x00-\x1f\x7f\\]/g;
41
42
  class OINOBlobAzure extends blob_1.OINOBlob {
42
43
  _containerClient = null;
43
44
  constructor(params) {
@@ -46,6 +47,13 @@ class OINOBlobAzure extends blob_1.OINOBlob {
46
47
  throw new Error("OINOBlobAzure: missing or invalid credentials (provide either connectionStr or url and clientId)");
47
48
  }
48
49
  }
50
+ /**
51
+ * Replace characters that Azure Blob Storage does not permit in blob names
52
+ * (`\` and ASCII control characters) with `_`.
53
+ */
54
+ sanitizeName(name) {
55
+ return name.replace(BLOB_AZURE_ILLEGAL_CHARS_REGEX, "_");
56
+ }
49
57
  /**
50
58
  * Initialise the Azure SDK client. Does not perform any network call.
51
59
  */
@@ -174,8 +182,7 @@ class OINOBlobAzure extends blob_1.OINOBlob {
174
182
  throw new Error("OINOBlobAzure: not connected");
175
183
  }
176
184
  const blockBlobClient = this._containerClient.getBlockBlobClient(name);
177
- const headers = { blobDataType: contentType };
178
- await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: headers });
185
+ await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: { blobContentType: contentType } });
179
186
  }
180
187
  /**
181
188
  * Delete a named blob.
@@ -35,6 +35,7 @@ import { OINOBlob, OINOBlobDataModel } from "@oino-ts/blob";
35
35
  * })
36
36
  * ```
37
37
  */
38
+ const BLOB_AZURE_ILLEGAL_CHARS_REGEX = /[\x00-\x1f\x7f\\]/g;
38
39
  export class OINOBlobAzure extends OINOBlob {
39
40
  _containerClient = null;
40
41
  constructor(params) {
@@ -43,6 +44,13 @@ export class OINOBlobAzure extends OINOBlob {
43
44
  throw new Error("OINOBlobAzure: missing or invalid credentials (provide either connectionStr or url and clientId)");
44
45
  }
45
46
  }
47
+ /**
48
+ * Replace characters that Azure Blob Storage does not permit in blob names
49
+ * (`\` and ASCII control characters) with `_`.
50
+ */
51
+ sanitizeName(name) {
52
+ return name.replace(BLOB_AZURE_ILLEGAL_CHARS_REGEX, "_");
53
+ }
46
54
  /**
47
55
  * Initialise the Azure SDK client. Does not perform any network call.
48
56
  */
@@ -171,8 +179,7 @@ export class OINOBlobAzure extends OINOBlob {
171
179
  throw new Error("OINOBlobAzure: not connected");
172
180
  }
173
181
  const blockBlobClient = this._containerClient.getBlockBlobClient(name);
174
- const headers = { blobDataType: contentType };
175
- await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: headers });
182
+ await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: { blobContentType: contentType } });
176
183
  }
177
184
  /**
178
185
  * Delete a named blob.
@@ -1,34 +1,13 @@
1
1
  import { OINOApi, OINOResult, OINOQueryFilter } from "@oino-ts/common";
2
2
  import { OINOBlob, OINOBlobParams, type OINOBlobEntry, type OINOBlobFetchResult } from "@oino-ts/blob";
3
- /**
4
- * Azure Blob Storage implementation of `OINOBlob`.
5
- *
6
- * Authenticates using an Azure Storage connection string. Connection parameters map as:
7
- * - `params.url` → blob service endpoint, e.g. `https://<account>.blob.core.windows.net`
8
- * - `params.container` → container name
9
- * - `params.connectionStr` → Azure Storage connection string (e.g. `DefaultEndpointsProtocol=https;AccountName=...`)
10
- *
11
- * Register and use via the factory:
12
- * ```ts
13
- * import { OINOBlobFactory } from "@oino-ts/blob"
14
- * import { OINOBlobAzure } from "@oino-ts/blob-azure"
15
- *
16
- * OINOBlobFactory.registerBlob("OINOBlobAzure", OINOBlobAzure)
17
- *
18
- * const blob = await OINOBlobFactory.createBlob({
19
- * type: "OINOBlobAzure",
20
- * container: "my-container",
21
- * credentials: either connectionStr or url and clientId
22
- * })
23
- * const api = await OINOBlobFactory.createApi(blob, {
24
- * apiName: "files",
25
- * tableName: "uploads/" // blob prefix / folder
26
- * })
27
- * ```
28
- */
29
3
  export declare class OINOBlobAzure extends OINOBlob {
30
4
  private _containerClient;
31
5
  constructor(params: OINOBlobParams);
6
+ /**
7
+ * Replace characters that Azure Blob Storage does not permit in blob names
8
+ * (`\` and ASCII control characters) with `_`.
9
+ */
10
+ sanitizeName(name: string): string;
32
11
  /**
33
12
  * Initialise the Azure SDK client. Does not perform any network call.
34
13
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/blob-azure",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "OINO TS package for using Azure Blob Storage as a REST API.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -22,11 +22,11 @@
22
22
  "dependencies": {
23
23
  "@azure/storage-blob": "^12.0.0",
24
24
  "@azure/identity": "^3.0.0",
25
- "@oino-ts/blob": "1.0.5",
26
- "@oino-ts/common": "1.0.5"
25
+ "@oino-ts/blob": "1.0.7",
26
+ "@oino-ts/common": "1.0.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@oino-ts/types": "1.0.5",
29
+ "@oino-ts/types": "1.0.7",
30
30
  "@types/bun": "^1.1.14",
31
31
  "@types/node": "^22.0.00",
32
32
  "typescript": "~5.9.0"
@@ -42,6 +42,8 @@ import { OINOBlob, OINOBlobParams, OINOBlobDataModel, OINOBlobApi, type OINOBlob
42
42
  * })
43
43
  * ```
44
44
  */
45
+ const BLOB_AZURE_ILLEGAL_CHARS_REGEX = /[\x00-\x1f\x7f\\]/g
46
+
45
47
  export class OINOBlobAzure extends OINOBlob {
46
48
  private _containerClient: ContainerClient | null = null
47
49
 
@@ -52,6 +54,14 @@ export class OINOBlobAzure extends OINOBlob {
52
54
  }
53
55
  }
54
56
 
57
+ /**
58
+ * Replace characters that Azure Blob Storage does not permit in blob names
59
+ * (`\` and ASCII control characters) with `_`.
60
+ */
61
+ override sanitizeName(name: string): string {
62
+ return name.replace(BLOB_AZURE_ILLEGAL_CHARS_REGEX, "_")
63
+ }
64
+
55
65
  /**
56
66
  * Initialise the Azure SDK client. Does not perform any network call.
57
67
  */
@@ -193,8 +203,7 @@ export class OINOBlobAzure extends OINOBlob {
193
203
  throw new Error("OINOBlobAzure: not connected")
194
204
  }
195
205
  const blockBlobClient = this._containerClient.getBlockBlobClient(name)
196
- const headers:any = { blobDataType: contentType }
197
- await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: headers })
206
+ await blockBlobClient.upload(content, content.length, { blobHTTPHeaders: { blobContentType: contentType } })
198
207
  }
199
208
 
200
209
  /**