@oino-ts/types 0.21.2 → 1.0.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.
- package/blob/src/OINOBlob.d.ts +78 -0
- package/blob/src/OINOBlobApi.d.ts +49 -0
- package/blob/src/OINOBlobConstants.d.ts +37 -0
- package/blob/src/OINOBlobDataModel.d.ts +33 -0
- package/blob/src/OINOBlobFactory.d.ts +40 -0
- package/blob/src/index.d.ts +5 -0
- package/blob-aws/src/OINOBlobAwsS3.d.ts +90 -0
- package/blob-aws/src/index.d.ts +1 -0
- package/blob-azure/src/OINOBlobAzureTable.d.ts +86 -0
- package/blob-azure/src/index.d.ts +1 -0
- package/common/src/OINOApi.d.ts +191 -0
- package/common/src/OINOConfig.d.ts +63 -0
- package/common/src/OINOConstants.d.ts +51 -0
- package/common/src/OINODataField.d.ts +209 -0
- package/common/src/OINODataModel.d.ts +78 -0
- package/common/src/OINODataSource.d.ts +184 -0
- package/common/src/OINOHtmlTemplate.d.ts +1 -1
- package/common/src/OINOModelSet.d.ts +64 -0
- package/common/src/OINOParser.d.ts +42 -0
- package/common/src/OINOQueryParams.d.ts +270 -0
- package/common/src/OINORequest.d.ts +4 -1
- package/common/src/OINOResult.d.ts +1 -1
- package/common/src/OINOStr.d.ts +1 -1
- package/common/src/OINOSwagger.d.ts +25 -0
- package/common/src/index.d.ts +14 -31
- package/db/src/OINODb.d.ts +55 -0
- package/db/src/OINODbApi.d.ts +78 -0
- package/db/src/OINODbConfig.d.ts +56 -0
- package/db/src/OINODbConstants.d.ts +23 -0
- package/db/src/OINODbDataField.d.ts +210 -0
- package/db/src/OINODbDataModel.d.ts +55 -0
- package/db/src/OINODbDataSet.d.ts +95 -0
- package/db/src/OINODbFactory.d.ts +34 -0
- package/db/src/OINODbModelSet.d.ts +62 -0
- package/db/src/OINODbParser.d.ts +42 -0
- package/db/src/OINODbQueryParams.d.ts +72 -0
- package/db/src/OINODbRequestParams.d.ts +146 -0
- package/db/src/OINODbSqlParams.d.ts +296 -0
- package/db/src/OINODbSwagger.d.ts +25 -0
- package/db/src/index.d.ts +6 -0
- package/db-bunsqlite/src/OINODbBunSqlite.d.ts +99 -0
- package/db-bunsqlite/src/index.d.ts +1 -0
- package/db-mariadb/src/OINODbMariadb.d.ts +99 -0
- package/db-mariadb/src/index.d.ts +1 -0
- package/db-mssql/src/OINODbMsSql.d.ts +116 -0
- package/db-mssql/src/index.d.ts +1 -0
- package/db-postgresql/src/OINODbPostgresql.d.ts +95 -0
- package/db-postgresql/src/index.d.ts +1 -0
- package/hashid/src/OINOHashid.d.ts +42 -0
- package/hashid/src/index.d.ts +1 -0
- package/index.d.ts +7 -7
- package/nosql/src/OINONoSql.d.ts +81 -0
- package/nosql/src/OINONoSqlApi.d.ts +67 -0
- package/nosql/src/OINONoSqlConstants.d.ts +34 -0
- package/nosql/src/OINONoSqlDataModel.d.ts +29 -0
- package/nosql/src/OINONoSqlFactory.d.ts +40 -0
- package/nosql/src/index.d.ts +5 -0
- package/nosql-aws/src/OINONoSqlAwsDynamo.d.ts +223 -0
- package/nosql-aws/src/index.d.ts +1 -0
- package/nosql-azure/src/OINONoSqlAzureTable.d.ts +130 -0
- package/nosql-azure/src/index.d.ts +1 -0
- package/package.json +28 -28
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { OINODataSource, OINODataCell, OINOQueryFilter } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlobParams, OINOBlobEntry, OINOBlobFetchResult } from "./OINOBlobConstants.js";
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for blob storage backends. Subclasses implement
|
|
5
|
+
* the two core operations (`listEntries` and `fetchEntry`) for a specific
|
|
6
|
+
* provider (e.g. Azure Blob Storage, S3, …).
|
|
7
|
+
*
|
|
8
|
+
* The SQL-formatting methods inherited from `OINODataSource` are not used
|
|
9
|
+
* by blob operations; they are implemented here as passthrough stubs so
|
|
10
|
+
* that the blob datasource can still be composed with `OINODataField`.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class OINOBlob extends OINODataSource {
|
|
13
|
+
protected readonly blobParams: OINOBlobParams;
|
|
14
|
+
/** Container / bucket name */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for `OINOBlob`.
|
|
18
|
+
* @param params blob storage connection parameters
|
|
19
|
+
*/
|
|
20
|
+
constructor(params: OINOBlobParams);
|
|
21
|
+
printTableName(name: string): string;
|
|
22
|
+
printColumnName(name: string): string;
|
|
23
|
+
printCellAsValue(cellValue: OINODataCell, _sqlType: string): string;
|
|
24
|
+
printStringValue(s: string): string;
|
|
25
|
+
parseValueAsCell(v: OINODataCell, nativeType: string): OINODataCell;
|
|
26
|
+
/**
|
|
27
|
+
* Test whether a blob entry matches an `OINOQueryFilter` predicate.
|
|
28
|
+
* Used for in-memory (result) filtering when the storage backend cannot
|
|
29
|
+
* translate the predicate to a native query.
|
|
30
|
+
*
|
|
31
|
+
* @param entry blob entry to test
|
|
32
|
+
* @param filter filter predicate to evaluate
|
|
33
|
+
*/
|
|
34
|
+
protected static matchesEntry(entry: OINOBlobEntry, filter: OINOQueryFilter): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Extract a blob/object name prefix from the filter that can be forwarded
|
|
37
|
+
* to the storage backend as a server-side query optimisation.
|
|
38
|
+
*
|
|
39
|
+
* Only two cases translate to a prefix:
|
|
40
|
+
* - `(name)-eq(value)` → exact name match (use as prefix)
|
|
41
|
+
* - `(name)-like(prefix%)` → trailing-wildcard prefix match
|
|
42
|
+
*
|
|
43
|
+
* AND-combined filters are explored recursively so that a name constraint
|
|
44
|
+
* nested inside a larger AND predicate is still extracted.
|
|
45
|
+
*
|
|
46
|
+
* @param filter filter to inspect
|
|
47
|
+
*/
|
|
48
|
+
protected static extractNamePrefix(filter: OINOQueryFilter): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* List blob entries, optionally filtered by a query filter. Implementations
|
|
51
|
+
* should apply native query filtering where possible and fall back to
|
|
52
|
+
* in-memory result filtering for predicates that cannot be expressed as a
|
|
53
|
+
* native query.
|
|
54
|
+
*
|
|
55
|
+
* @param filter optional query filter to apply to the results
|
|
56
|
+
*/
|
|
57
|
+
abstract listEntries(filter?: OINOQueryFilter): Promise<OINOBlobEntry[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Fetch the binary content and content-type of a named blob.
|
|
60
|
+
*
|
|
61
|
+
* @param name full blob name (path within the container)
|
|
62
|
+
*/
|
|
63
|
+
abstract fetchEntry(name: string): Promise<OINOBlobFetchResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Upload (create or replace) a blob with the given binary content.
|
|
66
|
+
*
|
|
67
|
+
* @param name full blob name (path within the container)
|
|
68
|
+
* @param content binary content to store
|
|
69
|
+
* @param contentType MIME type of the content (e.g. `"image/jpeg"`)
|
|
70
|
+
*/
|
|
71
|
+
abstract uploadEntry(name: string, content: Uint8Array, contentType: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a named blob.
|
|
74
|
+
*
|
|
75
|
+
* @param name full blob name (path within the container)
|
|
76
|
+
*/
|
|
77
|
+
abstract deleteEntry(name: string): Promise<void>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OINOApi, OINOApiParams, OINOApiRequest, OINOApiResult, OINOModelSet, OINOContentType, OINOQueryParams, OINOHttpRequest, type OINOApiData } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlob } from "./OINOBlob.js";
|
|
3
|
+
import { OINOBlobDataModel } from "./OINOBlobDataModel.js";
|
|
4
|
+
export declare class OINOBlobApiResult extends OINOApiResult {
|
|
5
|
+
/** Binary content of the blob (for GET with id) */
|
|
6
|
+
blobData?: Uint8Array;
|
|
7
|
+
/** Content-Type of the blob (for GET with id) */
|
|
8
|
+
blobDataType?: string;
|
|
9
|
+
constructor(request: OINOApiRequest, data?: OINOModelSet, blobData?: Uint8Array, blobDataType?: string);
|
|
10
|
+
writeApiResponse(headers?: Record<string, string>): Promise<Response>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* REST API for blob storage.
|
|
14
|
+
*
|
|
15
|
+
* Supports two GET variants:
|
|
16
|
+
* - **GET without id** – lists all blobs under the configured prefix and
|
|
17
|
+
* returns the metadata as JSON (or CSV) using `OINOModelSet`.
|
|
18
|
+
* - **GET with id** – downloads the named blob as a binary HTTP response
|
|
19
|
+
* with the blob's own `Content-Type`.
|
|
20
|
+
*
|
|
21
|
+
* All other HTTP methods return `405 Method Not Allowed`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class OINOBlobApi extends OINOApi {
|
|
24
|
+
/** Blob storage backend */
|
|
25
|
+
readonly blob: OINOBlob;
|
|
26
|
+
/** Blob-specific data model (populated by `initializeDatamodel`) */
|
|
27
|
+
blobDatamodel: OINOBlobDataModel | null;
|
|
28
|
+
/**
|
|
29
|
+
* Constructor.
|
|
30
|
+
*
|
|
31
|
+
* NOTE: `initializeDatamodel` (or `OINOBlobFactory.createApi`) must be
|
|
32
|
+
* called before the first request is dispatched.
|
|
33
|
+
*
|
|
34
|
+
* @param blob blob storage backend
|
|
35
|
+
* @param params API parameters (`tableName` is used as the blob prefix)
|
|
36
|
+
*/
|
|
37
|
+
constructor(blob: OINOBlob, params: OINOApiParams);
|
|
38
|
+
/**
|
|
39
|
+
* Attach the static blob data model and mark the API as initialised.
|
|
40
|
+
*
|
|
41
|
+
* @param datamodel `OINOBlobDataModel` instance for this API
|
|
42
|
+
*/
|
|
43
|
+
initializeDatamodel(datamodel: OINOBlobDataModel): void;
|
|
44
|
+
doApiRequest(request: OINOApiRequest): Promise<OINOBlobApiResult>;
|
|
45
|
+
doHttpRequest(request: OINOHttpRequest, rowId: string, rowData: OINOApiData, queryParams: OINOQueryParams): Promise<OINOBlobApiResult>;
|
|
46
|
+
doRequest(method: string, rowId: string, rowData: OINOApiData, queryParams: OINOQueryParams, contentType?: OINOContentType): Promise<OINOBlobApiResult>;
|
|
47
|
+
doBatchUpdate(method: string, _rowId: string, _rowData: OINOApiData, _queryParams?: OINOQueryParams): Promise<OINOBlobApiResult>;
|
|
48
|
+
doBatchApiRequest(request: OINOApiRequest): Promise<OINOBlobApiResult>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { OINOBlob } from "./OINOBlob.js";
|
|
2
|
+
/**
|
|
3
|
+
* Blob class (constructor) type
|
|
4
|
+
* @param params blob parameters
|
|
5
|
+
*/
|
|
6
|
+
export type OINOBlobConstructor = new (params: OINOBlobParams) => OINOBlob;
|
|
7
|
+
/** Blob storage connection parameters */
|
|
8
|
+
export type OINOBlobParams = {
|
|
9
|
+
/** Name of the blob class (e.g. OINOBlobAzureTable) */
|
|
10
|
+
type: string;
|
|
11
|
+
/** Blob service endpoint URL */
|
|
12
|
+
url: string;
|
|
13
|
+
/** Container / bucket name */
|
|
14
|
+
container: string;
|
|
15
|
+
/** Provider-specific connection string (e.g. Azure Storage connection string or SAS URL) */
|
|
16
|
+
connectionStr?: string;
|
|
17
|
+
};
|
|
18
|
+
/** A single blob entry returned by a listing operation */
|
|
19
|
+
export type OINOBlobEntry = {
|
|
20
|
+
/** Full blob name (path within the container) */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Entity tag */
|
|
23
|
+
etag: string;
|
|
24
|
+
/** Last modification timestamp */
|
|
25
|
+
lastModified: Date;
|
|
26
|
+
/** Size in bytes */
|
|
27
|
+
contentLength: number;
|
|
28
|
+
/** MIME content type */
|
|
29
|
+
contentType: string;
|
|
30
|
+
};
|
|
31
|
+
/** Result of a blob fetch operation */
|
|
32
|
+
export type OINOBlobFetchResult = {
|
|
33
|
+
/** Raw blob bytes */
|
|
34
|
+
content: Uint8Array;
|
|
35
|
+
/** MIME content type of the blob */
|
|
36
|
+
contentType: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OINODataModel, OINOMemoryDataset } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlobApi } from "./OINOBlobApi.js";
|
|
3
|
+
import { OINOBlobEntry } from "./OINOBlobConstants.js";
|
|
4
|
+
/**
|
|
5
|
+
* Static data model for blob listings.
|
|
6
|
+
*
|
|
7
|
+
* Fields are added by the blob implementation's `initializeApiDatamodel`
|
|
8
|
+
* method, so the exact set depends on what the storage backend supports.
|
|
9
|
+
* The canonical order is:
|
|
10
|
+
* 1. `name` – full blob name (primary key, string)
|
|
11
|
+
* 2. `etag` – entity tag (string)
|
|
12
|
+
* 3. `lastModified` – last modification timestamp (datetime)
|
|
13
|
+
* 4. `contentLength` – size in bytes (number)
|
|
14
|
+
* 5. `contentType` – MIME type (string) – omitted when not supported
|
|
15
|
+
*/
|
|
16
|
+
export declare class OINOBlobDataModel extends OINODataModel {
|
|
17
|
+
/** Reference to the owning blob API */
|
|
18
|
+
readonly blobApi: OINOBlobApi;
|
|
19
|
+
/**
|
|
20
|
+
* Constructor. Fields are added externally by the blob implementation
|
|
21
|
+
* via `initializeApiDatamodel`.
|
|
22
|
+
*
|
|
23
|
+
* @param api the `OINOBlobApi` that owns this data model
|
|
24
|
+
*/
|
|
25
|
+
constructor(api: OINOBlobApi);
|
|
26
|
+
/**
|
|
27
|
+
* Convert an array of blob entries into an in-memory dataset whose
|
|
28
|
+
* columns match the fields present in this model.
|
|
29
|
+
*
|
|
30
|
+
* @param entries blob entries from the storage backend
|
|
31
|
+
*/
|
|
32
|
+
entriesToDataset(entries: OINOBlobEntry[]): OINOMemoryDataset;
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OINOApiParams } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlobParams, OINOBlobConstructor } from "./OINOBlobConstants.js";
|
|
3
|
+
import { OINOBlob } from "./OINOBlob.js";
|
|
4
|
+
import { OINOBlobApi } from "./OINOBlobApi.js";
|
|
5
|
+
/**
|
|
6
|
+
* Static factory for creating `OINOBlob` instances and `OINOBlobApi` instances
|
|
7
|
+
* from registered provider classes.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* OINOBlobFactory.registerBlob("OINOBlobAzureTable", OINOBlobAzureTable)
|
|
12
|
+
* const blob = await OINOBlobFactory.createBlob({ type: "OINOBlobAzureTable", ... })
|
|
13
|
+
* const api = await OINOBlobFactory.createApi(blob, { apiName: "files", tableName: "uploads/" })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class OINOBlobFactory {
|
|
17
|
+
private static _registry;
|
|
18
|
+
/**
|
|
19
|
+
* Register a blob provider class under the given name.
|
|
20
|
+
*
|
|
21
|
+
* @param name name used in `OINOBlobParams.type`
|
|
22
|
+
* @param blobClass constructor of the provider
|
|
23
|
+
*/
|
|
24
|
+
static registerBlob(name: string, blobClass: OINOBlobConstructor): void;
|
|
25
|
+
/**
|
|
26
|
+
* Create and optionally connect/validate a blob backend from params.
|
|
27
|
+
*
|
|
28
|
+
* @param params connection parameters
|
|
29
|
+
* @param connect if true, calls `connect()` on the backend
|
|
30
|
+
* @param validate if true, calls `validate()` on the backend
|
|
31
|
+
*/
|
|
32
|
+
static createBlob(params: OINOBlobParams, connect?: boolean, validate?: boolean): Promise<OINOBlob>;
|
|
33
|
+
/**
|
|
34
|
+
* Create an `OINOBlobApi` and initialise its data model.
|
|
35
|
+
*
|
|
36
|
+
* @param blob blob backend to use
|
|
37
|
+
* @param params API parameters (`tableName` is used as the blob prefix)
|
|
38
|
+
*/
|
|
39
|
+
static createApi(blob: OINOBlob, params: OINOApiParams): Promise<OINOBlobApi>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { OINOBlob } from "./OINOBlob.js";
|
|
2
|
+
export { OINOBlobDataModel } from "./OINOBlobDataModel.js";
|
|
3
|
+
export { OINOBlobFactory } from "./OINOBlobFactory.js";
|
|
4
|
+
export { OINOBlobApi, OINOBlobApiResult } from "./OINOBlobApi.js";
|
|
5
|
+
export { type OINOBlobConstructor, type OINOBlobParams, type OINOBlobEntry, type OINOBlobFetchResult } from "./OINOBlobConstants.js";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { OINOApi, OINOResult, OINOQueryFilter } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlob } from "@oino-ts/blob";
|
|
3
|
+
import { type OINOBlobEntry, type OINOBlobFetchResult } from "@oino-ts/blob";
|
|
4
|
+
/**
|
|
5
|
+
* AWS S3 (and S3-compatible) implementation of `OINOBlob`.
|
|
6
|
+
*
|
|
7
|
+
* Authenticates using static access key credentials supplied via a JSON-encoded
|
|
8
|
+
* connection string. Connection parameters map as:
|
|
9
|
+
* - `params.url` → optional custom endpoint, e.g. `https://s3.eu-west-1.amazonaws.com`
|
|
10
|
+
* or a compatible service such as MinIO / Cloudflare R2
|
|
11
|
+
* - `params.container` → S3 bucket name
|
|
12
|
+
* - `params.connectionStr` → JSON string: `{"region":"…","accessKeyId":"…","secretAccessKey":"…"}`
|
|
13
|
+
*
|
|
14
|
+
* Register and use via the factory:
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { OINOBlobFactory } from "@oino-ts/blob"
|
|
17
|
+
* import { OINOBlobAwsS3 } from "@oino-ts/blob-aws"
|
|
18
|
+
*
|
|
19
|
+
* OINOBlobFactory.registerBlob("OINOBlobAwsS3", OINOBlobAwsS3)
|
|
20
|
+
*
|
|
21
|
+
* const blob = await OINOBlobFactory.createBlob({
|
|
22
|
+
* type: "OINOBlobAwsS3",
|
|
23
|
+
* url: "", // leave empty for default AWS endpoint
|
|
24
|
+
* container: "my-bucket",
|
|
25
|
+
* connectionStr: JSON.stringify({
|
|
26
|
+
* region: "us-east-1",
|
|
27
|
+
* accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
28
|
+
* secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
29
|
+
* })
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class OINOBlobAwsS3 extends OINOBlob {
|
|
34
|
+
private _s3Client;
|
|
35
|
+
/**
|
|
36
|
+
* Initialise the AWS SDK S3 client from the JSON-encoded `connectionStr`.
|
|
37
|
+
* Does not perform any network call.
|
|
38
|
+
*/
|
|
39
|
+
connect(): Promise<OINOResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Verify that the target bucket exists and is accessible using a `HeadBucket` call.
|
|
42
|
+
*/
|
|
43
|
+
validate(): Promise<OINOResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Release the S3 client (destroys the underlying HTTP connection pool).
|
|
46
|
+
*/
|
|
47
|
+
disconnect(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* List all objects in the bucket, applying a server-side S3 `Prefix` filter
|
|
50
|
+
* where possible and in-memory result filtering for all other predicates.
|
|
51
|
+
*
|
|
52
|
+
* - The `name` field supports server-side prefix filtering via `ListObjectsV2`
|
|
53
|
+
* `Prefix` option (query filtering).
|
|
54
|
+
* - All other field predicates (`etag`, `lastModified`, `contentLength`,
|
|
55
|
+
* `contentType`) are evaluated in-memory after the listing (result filtering).
|
|
56
|
+
* Note: S3 listing does not return `contentType`; it defaults to
|
|
57
|
+
* `"application/octet-stream"` unless a `contentType` filter is applied.
|
|
58
|
+
*
|
|
59
|
+
* @param filter optional query filter to apply
|
|
60
|
+
*/
|
|
61
|
+
listEntries(filter?: OINOQueryFilter): Promise<OINOBlobEntry[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Download the raw content of a named object.
|
|
64
|
+
*
|
|
65
|
+
* @param name full object key (path within the bucket)
|
|
66
|
+
*/
|
|
67
|
+
fetchEntry(name: string): Promise<OINOBlobFetchResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Upload (create or replace) an object with the given binary content.
|
|
70
|
+
*
|
|
71
|
+
* @param name full object key (path within the bucket)
|
|
72
|
+
* @param content binary content to store
|
|
73
|
+
* @param contentType MIME type of the content (e.g. `"image/jpeg"`)
|
|
74
|
+
*/
|
|
75
|
+
uploadEntry(name: string, content: Uint8Array, contentType: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Delete a named object.
|
|
78
|
+
*
|
|
79
|
+
* @param name full object key (path within the bucket)
|
|
80
|
+
*/
|
|
81
|
+
deleteEntry(name: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Attach a static `OINOBlobDataModel` to the given API, adding only the
|
|
84
|
+
* four fields that S3 object listings return (`contentType` is omitted
|
|
85
|
+
* because S3 does not include it in listing responses).
|
|
86
|
+
*
|
|
87
|
+
* @param api the `OINOBlobApi` whose data model is to be initialised
|
|
88
|
+
*/
|
|
89
|
+
initializeApiDatamodel(api: OINOApi): Promise<void>;
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OINOBlobAwsS3 } from "./OINOBlobAwsS3.js";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { OINOApi, OINOResult, OINOQueryFilter } from "@oino-ts/common";
|
|
2
|
+
import { OINOBlob } from "@oino-ts/blob";
|
|
3
|
+
import { type OINOBlobEntry, type OINOBlobFetchResult } from "@oino-ts/blob";
|
|
4
|
+
/**
|
|
5
|
+
* Azure Blob Storage implementation of `OINOBlob`.
|
|
6
|
+
*
|
|
7
|
+
* Authenticates using an Azure Storage connection string. Connection parameters map as:
|
|
8
|
+
* - `params.url` → blob service endpoint, e.g. `https://<account>.blob.core.windows.net`
|
|
9
|
+
* - `params.container` → container name
|
|
10
|
+
* - `params.connectionStr` → Azure Storage connection string (e.g. `DefaultEndpointsProtocol=https;AccountName=...`)
|
|
11
|
+
*
|
|
12
|
+
* Register and use via the factory:
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { OINOBlobFactory } from "@oino-ts/blob"
|
|
15
|
+
* import { OINOBlobAzureTable } from "@oino-ts/blob-azure"
|
|
16
|
+
*
|
|
17
|
+
* OINOBlobFactory.registerBlob("OINOBlobAzureTable", OINOBlobAzureTable)
|
|
18
|
+
*
|
|
19
|
+
* const blob = await OINOBlobFactory.createBlob({
|
|
20
|
+
* type: "OINOBlobAzureTable",
|
|
21
|
+
* url: "https://myaccount.blob.core.windows.net",
|
|
22
|
+
* container: "my-container",
|
|
23
|
+
* connectionStr: process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
24
|
+
* })
|
|
25
|
+
* const api = await OINOBlobFactory.createApi(blob, {
|
|
26
|
+
* apiName: "files",
|
|
27
|
+
* tableName: "uploads/" // blob prefix / folder
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class OINOBlobAzureTable extends OINOBlob {
|
|
32
|
+
private _containerClient;
|
|
33
|
+
/**
|
|
34
|
+
* Initialise the Azure SDK client. Does not perform any network call.
|
|
35
|
+
*/
|
|
36
|
+
connect(): Promise<OINOResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Verify that the target container exists and is accessible.
|
|
39
|
+
*/
|
|
40
|
+
validate(): Promise<OINOResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Release the client reference (Azure SDK is stateless per-request so nothing to close).
|
|
43
|
+
*/
|
|
44
|
+
disconnect(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* List all blobs, applying native Azure query filtering where possible and
|
|
47
|
+
* in-memory result filtering for predicates that cannot be expressed as a
|
|
48
|
+
* native query.
|
|
49
|
+
*
|
|
50
|
+
* - The `name` field supports server-side prefix filtering via the Azure
|
|
51
|
+
* `listBlobsFlat` `prefix` option (query filtering).
|
|
52
|
+
* - All other field predicates (`etag`, `lastModified`, `contentLength`,
|
|
53
|
+
* `contentType`) are evaluated in-memory after the listing (result
|
|
54
|
+
* filtering).
|
|
55
|
+
*
|
|
56
|
+
* @param filter optional query filter to apply
|
|
57
|
+
*/
|
|
58
|
+
listEntries(filter?: OINOQueryFilter): Promise<OINOBlobEntry[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Download the raw content of a named blob.
|
|
61
|
+
*
|
|
62
|
+
* @param name full blob name (path within the container)
|
|
63
|
+
*/
|
|
64
|
+
fetchEntry(name: string): Promise<OINOBlobFetchResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Upload (create or replace) a blob with the given binary content.
|
|
67
|
+
*
|
|
68
|
+
* @param name full blob name (path within the container)
|
|
69
|
+
* @param content binary content to store
|
|
70
|
+
* @param contentType MIME type of the content (e.g. `"image/jpeg"`)
|
|
71
|
+
*/
|
|
72
|
+
uploadEntry(name: string, content: Uint8Array, contentType: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete a named blob.
|
|
75
|
+
*
|
|
76
|
+
* @param name full blob name (path within the container)
|
|
77
|
+
*/
|
|
78
|
+
deleteEntry(name: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Attach a static `OINOBlobDataModel` to the given API, adding all five
|
|
81
|
+
* standard fields that Azure Blob Storage returns in a listing.
|
|
82
|
+
*
|
|
83
|
+
* @param api the `OINOBlobApi` whose data model is to be initialised
|
|
84
|
+
*/
|
|
85
|
+
initializeApiDatamodel(api: OINOApi): Promise<void>;
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OINOBlobAzureTable } from "./OINOBlobAzureTable.js";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
|
+
import { OINOHashid } from "@oino-ts/hashid";
|
|
5
|
+
import { OINOContentType, OINODataRow } from "./OINOConstants.js";
|
|
6
|
+
import { OINODataSource } from "./OINODataSource.js";
|
|
7
|
+
import { OINODataModel } from "./OINODataModel.js";
|
|
8
|
+
import { OINOModelSet } from "./OINOModelSet.js";
|
|
9
|
+
import { OINOQueryParams, OINOQueryFilter, OINOQueryOrder, OINOQueryAggregate, OINOQueryLimit, OINOQuerySelect } from "./OINOQueryParams.js";
|
|
10
|
+
import { OINOHttpRequest, OINOHttpRequestInit } from "./OINORequest.js";
|
|
11
|
+
import { OINOHttpResult, OINOResult } from "./OINOResult.js";
|
|
12
|
+
import { OINOHtmlTemplate } from "./OINOHtmlTemplate.js";
|
|
13
|
+
/** API parameters */
|
|
14
|
+
export type OINOApiParams = {
|
|
15
|
+
/** Name of the api */
|
|
16
|
+
apiName: string;
|
|
17
|
+
/** Name of the database table */
|
|
18
|
+
tableName: string;
|
|
19
|
+
/** Reject values that exceed field max length (behaviour on such is platform dependent) */
|
|
20
|
+
failOnOversizedValues?: boolean;
|
|
21
|
+
/** Reject PUT-requests that contain values for autoinc-type fields */
|
|
22
|
+
failOnUpdateOnAutoinc?: boolean;
|
|
23
|
+
/** Reject POST-requests without primary key value (can work if DB-side ) */
|
|
24
|
+
failOnInsertWithoutKey?: boolean;
|
|
25
|
+
/** Reject POST-requests without primary key value (can work if DB-side ) */
|
|
26
|
+
failOnAnyInvalidRows?: boolean;
|
|
27
|
+
/** Treat date type fields as just strings and use the native formatting instead of the ISO 8601 format */
|
|
28
|
+
useDatesAsString?: boolean;
|
|
29
|
+
/** Include given fields from the API and exclude rest (if defined) */
|
|
30
|
+
includeFields?: string[];
|
|
31
|
+
/** Exclude all fields with this prefix from the API */
|
|
32
|
+
excludeFieldPrefix?: string;
|
|
33
|
+
/** Exclude given fields from the API and include rest (if defined) */
|
|
34
|
+
excludeFields?: string[];
|
|
35
|
+
/** Enable hashids for numeric primarykeys by adding a 32 char key */
|
|
36
|
+
hashidKey?: string;
|
|
37
|
+
/** Set (minimum) length (12-32 chars) of the hashids */
|
|
38
|
+
hashidLength?: number;
|
|
39
|
+
/** Make hashids static per row/table */
|
|
40
|
+
hashidStaticIds?: boolean;
|
|
41
|
+
/** Name of field that has the modified field */
|
|
42
|
+
cacheModifiedField?: string;
|
|
43
|
+
/** Return inserted id values */
|
|
44
|
+
returnInsertedIds?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type OINOApiData = string | OINODataRow[] | Buffer | Uint8Array | object | null;
|
|
47
|
+
export interface OINOApiRequestInit extends OINOHttpRequestInit {
|
|
48
|
+
rowId?: string;
|
|
49
|
+
rowData?: OINOApiData;
|
|
50
|
+
queryParams?: OINOQueryParams;
|
|
51
|
+
filter?: OINOQueryFilter | string;
|
|
52
|
+
order?: OINOQueryOrder | string;
|
|
53
|
+
limit?: OINOQueryLimit | string;
|
|
54
|
+
aggregate?: OINOQueryAggregate | string;
|
|
55
|
+
select?: OINOQuerySelect | string;
|
|
56
|
+
}
|
|
57
|
+
export declare class OINOApiRequest extends OINOHttpRequest {
|
|
58
|
+
rowId: string;
|
|
59
|
+
rowData: OINOApiData;
|
|
60
|
+
queryParams: OINOQueryParams;
|
|
61
|
+
constructor(init: OINOApiRequestInit);
|
|
62
|
+
static fromFetchRequest(request: Request, rowId?: string, rowData?: OINOApiData, queryParams?: OINOQueryParams): Promise<OINOApiRequest>;
|
|
63
|
+
static fromHttpRequest(request: OINOHttpRequest, rowId?: string, rowData?: OINOApiData, queryParams?: OINOQueryParams): OINOApiRequest;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* OINO API request result object with returned data and/or http status code/message and
|
|
67
|
+
* error / warning messages.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
export declare class OINOApiResult extends OINOResult {
|
|
71
|
+
/** DbApi request params */
|
|
72
|
+
request: OINOApiRequest;
|
|
73
|
+
/** Returned data if any */
|
|
74
|
+
data?: OINOModelSet;
|
|
75
|
+
/**
|
|
76
|
+
* Constructor of OINOApiResult.
|
|
77
|
+
*
|
|
78
|
+
* @param request DbApi request parameters
|
|
79
|
+
* @param data result data
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
constructor(request: OINOApiRequest, data?: OINOModelSet);
|
|
83
|
+
/**
|
|
84
|
+
* Creates a HTTP Response from API results.
|
|
85
|
+
*
|
|
86
|
+
* @param headers Headers to include in the response
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
writeApiResponse(headers?: Record<string, string>): Promise<Response>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Specialized HTML template that can render ´OINOApiResult´.
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
export declare class OINOApiHtmlTemplate extends OINOHtmlTemplate {
|
|
96
|
+
/** Locale validation regex */
|
|
97
|
+
static LOCALE_REGEX: RegExp;
|
|
98
|
+
/** Locale formatter */
|
|
99
|
+
protected _locale: Intl.DateTimeFormat | null;
|
|
100
|
+
protected _numberDecimals: number;
|
|
101
|
+
/**
|
|
102
|
+
* Constructor of OINOApiHtmlTemplate.
|
|
103
|
+
*
|
|
104
|
+
* @param template HTML template string
|
|
105
|
+
* @param numberDecimals Number of decimals to use for numbers, -1 for no formatting
|
|
106
|
+
* @param dateLocaleStr Datetime format string, either "iso" for ISO8601 or "default" for system default or valid locale string
|
|
107
|
+
* @param dateLocaleStyle Datetime format style, either "short/medium/long/full" or Intl.DateTimeFormat options
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
constructor(template: string, numberDecimals?: number, dateLocaleStr?: string, dateLocaleStyle?: string | any);
|
|
111
|
+
/**
|
|
112
|
+
* Creates HTML Response from API modelset.
|
|
113
|
+
*
|
|
114
|
+
* @param modelset OINO API dataset
|
|
115
|
+
* @param overrideValues values to override in the data
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
renderFromDbData(modelset: OINOModelSet, overrideValues?: any): Promise<OINOHttpResult>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* API class with method to process HTTP REST requests.
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
export declare abstract class OINOApi {
|
|
125
|
+
/** Enable debug output on errors */
|
|
126
|
+
protected _debugOnError: boolean;
|
|
127
|
+
/** API database reference */
|
|
128
|
+
readonly datasource: OINODataSource;
|
|
129
|
+
/** API parameters */
|
|
130
|
+
readonly params: OINOApiParams;
|
|
131
|
+
/** API hashid */
|
|
132
|
+
readonly hashid: OINOHashid | null;
|
|
133
|
+
/** Is API initialized */
|
|
134
|
+
initialized: boolean;
|
|
135
|
+
/** API datamodel */
|
|
136
|
+
datamodel: OINODataModel | null;
|
|
137
|
+
constructor(datasource: OINODataSource, params: OINOApiParams);
|
|
138
|
+
/**
|
|
139
|
+
* Method for handling a HTTP REST request with GET, POST, PUT, DELETE corresponding to
|
|
140
|
+
* SQL select, insert, update and delete.
|
|
141
|
+
*
|
|
142
|
+
* @param request OINO HTTP request object containing all parameters of the REST request
|
|
143
|
+
* @param rowId URL id of the REST request
|
|
144
|
+
* @param rowData HTTP body data as either serialized string or unserialized JS object or OINODataRow-array or Buffer/Uint8Array binary data
|
|
145
|
+
* @param queryParams SQL parameters for the REST request
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
148
|
+
abstract doHttpRequest(request: OINOHttpRequest, rowId: string, rowData: OINOApiData, queryParams: OINOQueryParams): Promise<OINOApiResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Method for handling a HTTP REST request with GET, POST, PUT, DELETE corresponding to
|
|
151
|
+
* SQL select, insert, update and delete.
|
|
152
|
+
*
|
|
153
|
+
* @param method HTTP method of the REST request
|
|
154
|
+
* @param rowId URL id of the REST request
|
|
155
|
+
* @param rowData HTTP body data as either serialized string or unserialized JS object or OINODataRow-array or Buffer/Uint8Array binary data
|
|
156
|
+
* @param queryParams SQL parameters for the REST request
|
|
157
|
+
* @param contentType content type of the HTTP body data, default is JSON
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
abstract doRequest(method: string, rowId: string, rowData: OINOApiData, queryParams: OINOQueryParams, contentType: OINOContentType): Promise<OINOApiResult>;
|
|
161
|
+
abstract doApiRequest(request: OINOApiRequest): Promise<OINOApiResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Method for handling a HTTP REST request with batch update using PUT or DELETE methods.
|
|
164
|
+
*
|
|
165
|
+
* @param method HTTP method of the REST request
|
|
166
|
+
* @param rowId URL id of the REST request
|
|
167
|
+
* @param rowData HTTP body data as either serialized string or unserialized JS object or OINODataRow-array or Buffer/Uint8Array binary data
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
abstract doBatchUpdate(method: string, rowId: string, rowData: OINOApiData, queryParams?: OINOQueryParams): Promise<OINOApiResult>;
|
|
171
|
+
/**
|
|
172
|
+
* Method for handling a HTTP REST request with batch update using PUT or DELETE methods.
|
|
173
|
+
*
|
|
174
|
+
* @param request HTTP URL parameters as key-value-pairs
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
abstract doBatchApiRequest(request: OINOApiRequest): Promise<OINOApiResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Enable or disable debug output on errors.
|
|
180
|
+
*
|
|
181
|
+
* @param debugOnError true to enable debug output on errors, false to disable
|
|
182
|
+
*/
|
|
183
|
+
setDebugOnError(debugOnError: boolean): void;
|
|
184
|
+
/**
|
|
185
|
+
* Method to check if a field is included in the API params.
|
|
186
|
+
*
|
|
187
|
+
* @param fieldName name of the field
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
isFieldIncluded(fieldName: string): boolean;
|
|
191
|
+
}
|