@oino-ts/types 1.0.6 → 1.0.8

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.
@@ -22,6 +22,17 @@ export declare abstract class OINOBlob extends OINODataSource {
22
22
  printCellAsValue(cellValue: OINODataCell, _sqlType: string): string;
23
23
  printStringValue(s: string): string;
24
24
  parseValueAsCell(v: OINODataCell, nativeType: string): OINODataCell;
25
+ /**
26
+ * Sanitize a blob name by replacing characters that are illegal or unsafe
27
+ * on this storage backend with `_`.
28
+ *
29
+ * The base implementation strips ASCII control characters (U+0000–U+001F
30
+ * and U+007F). Subclasses should override to apply additional
31
+ * platform-specific rules.
32
+ *
33
+ * @param name raw blob name (path within the container)
34
+ */
35
+ sanitizeName(name: string): string;
25
36
  /**
26
37
  * Test whether a blob entry matches an `OINOQueryFilter` predicate.
27
38
  * Used for in-memory (result) filtering when the storage backend cannot
@@ -1,37 +1,14 @@
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
- * AWS S3 (and S3-compatible) implementation of `OINOBlob`.
5
- *
6
- * Authenticates using static access key credentials supplied via a JSON-encoded
7
- * connection string. Connection parameters map as:
8
- * - `params.url` → optional custom endpoint, e.g. `https://s3.eu-west-1.amazonaws.com`
9
- * or a compatible service such as MinIO / Cloudflare R2
10
- * - `params.container` → S3 bucket name
11
- * - `params.connectionStr` → JSON string: `{"region":"…","accessKeyId":"…","secretAccessKey":"…"}`
12
- *
13
- * Register and use via the factory:
14
- * ```ts
15
- * import { OINOBlobFactory } from "@oino-ts/blob"
16
- * import { OINOBlobAwsS3 } from "@oino-ts/blob-aws"
17
- *
18
- * OINOBlobFactory.registerBlob("OINOBlobAwsS3", OINOBlobAwsS3)
19
- *
20
- * const blob = await OINOBlobFactory.createBlob({
21
- * type: "OINOBlobAwsS3",
22
- * url: "", // leave empty for default AWS endpoint
23
- * container: "my-bucket",
24
- * connectionStr: JSON.stringify({
25
- * region: "us-east-1",
26
- * accessKeyId: process.env.AWS_ACCESS_KEY_ID,
27
- * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
28
- * })
29
- * })
30
- * ```
31
- */
32
3
  export declare class OINOBlobAwsS3 extends OINOBlob {
33
4
  private _s3Client;
34
5
  constructor(params: OINOBlobParams);
6
+ /**
7
+ * Replace characters that are unsafe in S3 object key names
8
+ * (`\`, control characters, and shell/URL-special characters
9
+ * `{`, `}`, `[`, `]`, `^`, `` ` ``, `|`, `<`, `>`, `#`, `%`) with `_`.
10
+ */
11
+ sanitizeName(name: string): string;
35
12
  /**
36
13
  * Initialise the AWS SDK S3 client from the JSON-encoded `connectionStr`.
37
14
  * Does not perform any network call.
@@ -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
  */
@@ -4,12 +4,15 @@ import { type OINONoSqlEntry } from "@oino-ts/nosql";
4
4
  /**
5
5
  * Azure Table Storage implementation of `OINONoSql`.
6
6
  *
7
- * Authenticates using an Azure Storage connection string. Connection parameters map as:
8
- * - `params.url` → table service endpoint, e.g. `https://<account>.table.core.windows.net`
9
- * - `params.table` → table name
10
- * - `params.connectionStr` Azure Storage connection string (e.g. `DefaultEndpointsProtocol=https;AccountName=...`)
7
+ * Authenticates using either an Azure Storage connection string or a table
8
+ * service endpoint URL combined with a managed identity client id. Connection
9
+ * parameters map as:
10
+ * - `credentials.url` table service endpoint, e.g. `https://<account>.table.core.windows.net`
11
+ * - `credentials.connectionStr` → Azure Storage connection string (e.g. `DefaultEndpointsProtocol=https;AccountName=...`)
12
+ * - `credentials.clientId` → (optional) managed identity client id used with `credentials.url`
13
+ * - `params.table` → table name
11
14
  *
12
- * Register and use via the factory:
15
+ * Register and use via the factory with a connection string:
13
16
  * ```ts
14
17
  * import { OINONoSqlFactory } from "@oino-ts/nosql"
15
18
  * import { OINONoSqlAzureTable } from "@oino-ts/nosql-azure"
@@ -17,10 +20,9 @@ import { type OINONoSqlEntry } from "@oino-ts/nosql";
17
20
  * OINONoSqlFactory.registerNoSql("OINONoSqlAzureTable", OINONoSqlAzureTable)
18
21
  *
19
22
  * const nosql = await OINONoSqlFactory.createNoSql({
20
- * type: "OINONoSqlAzureTable",
21
- * url: "https://myaccount.table.core.windows.net",
22
- * table: "myTable",
23
- * connectionStr: process.env.AZURE_STORAGE_CONNECTION_STRING
23
+ * type: "OINONoSqlAzureTable",
24
+ * table: "myTable",
25
+ * credentials: { connectionStr: process.env.AZURE_STORAGE_CONNECTION_STRING }
24
26
  * })
25
27
  * const api = await OINONoSqlFactory.createApi(nosql, {
26
28
  * apiName: "entities",
@@ -28,6 +30,18 @@ import { type OINONoSqlEntry } from "@oino-ts/nosql";
28
30
  * })
29
31
  * ```
30
32
  *
33
+ * Or with a service endpoint URL and a managed identity client id:
34
+ * ```ts
35
+ * const nosql = await OINONoSqlFactory.createNoSql({
36
+ * type: "OINONoSqlAzureTable",
37
+ * table: "myTable",
38
+ * credentials: {
39
+ * url: "https://myaccount.table.core.windows.net",
40
+ * clientId: process.env.AZURE_MANAGED_IDENTITY_CLIENT_ID
41
+ * }
42
+ * })
43
+ * ```
44
+ *
31
45
  * ## Static partition key
32
46
  *
33
47
  * Set `staticPartitionKey` in the params to scope all operations to a fixed
@@ -128,4 +142,21 @@ export declare class OINONoSqlAzureTable extends OINONoSql {
128
142
  * @param entity raw entity from the Azure SDK
129
143
  */
130
144
  private static entityToEntry;
145
+ /**
146
+ * Encode an entry's `properties` into a flat map storable in Azure Table
147
+ * Storage. Nested objects/arrays are JSON-stringified with a marker
148
+ * prefix (Azure Table Storage stores only primitive property values), and
149
+ * if the serialized properties exceed the 32k per-property limit the whole
150
+ * map is JSON-serialized and split across numbered `chunkN` properties.
151
+ *
152
+ * @param properties entry properties to encode
153
+ */
154
+ private static encodeProperties;
155
+ /**
156
+ * Decode stored Azure Table Storage properties back into the original
157
+ * `properties` map, reversing `encodeProperties`.
158
+ *
159
+ * @param properties stored properties to decode
160
+ */
161
+ private static decodeProperties;
131
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/types",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "OINO TS package for types.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",