@pi-r/azure 0.8.1 → 0.8.3
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 +6 -6
- package/client/index.js +7 -4
- package/download/index.js +1 -1
- package/package.json +30 -30
- package/types/index.d.ts +24 -23
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
### @pi-r/azure
|
|
2
|
-
|
|
3
|
-
https://e-mc.readthedocs.io/en/latest/cloud/azure.html
|
|
4
|
-
|
|
5
|
-
### LICENSE
|
|
6
|
-
|
|
1
|
+
### @pi-r/azure
|
|
2
|
+
|
|
3
|
+
https://e-mc.readthedocs.io/en/latest/cloud/azure.html
|
|
4
|
+
|
|
5
|
+
### LICENSE
|
|
6
|
+
|
|
7
7
|
MIT
|
package/client/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const util_1 = require("@e-mc/cloud/util");
|
|
|
20
20
|
const types_1 = require("@e-mc/types");
|
|
21
21
|
function validateStorage(credential) {
|
|
22
22
|
const env = process.env;
|
|
23
|
-
if (credential.accountName && credential.accountKey || credential.connectionString || credential.sharedAccessSignature || env.AZURE_TENANT_ID && env.AZURE_CLIENT_ID && env.AZURE_CLIENT_SECRET) {
|
|
23
|
+
if (credential.accountName && (credential.accountKey || credential.accountSas) || credential.connectionString || credential.sharedAccessSignature || env.AZURE_TENANT_ID && env.AZURE_CLIENT_ID && env.AZURE_CLIENT_SECRET) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
return Cloud.enabled("process.env.apply") && !!((credential.connectionString = env.AZURE_STORAGE_CONNECTION_STRING) || (credential.sharedAccessSignature = env.AZURE_STORAGE_SAS_TOKEN) || (credential.accountName = env.AZURE_STORAGE_ACCOUNT) && (credential.accountKey = env.AZURE_STORAGE_KEY));
|
|
@@ -29,14 +29,17 @@ function validateDatabase(credential, data) {
|
|
|
29
29
|
return !!(data.name && data.table && (credential.endpoint && credential.key || credential.username && credential.password && (credential.tenantId && credential.clientId || (credential.tenantId = process.env.AZURE_TENANT_ID) && (credential.clientId = process.env.AZURE_CLIENT_ID)) || Cloud.enabled("process.env.apply") && (credential.endpoint = process.env.AZURE_COSMOS_ENDPOINT) && (credential.key = process.env.AZURE_COSMOS_KEY)));
|
|
30
30
|
}
|
|
31
31
|
function createStorageClient(credential) {
|
|
32
|
-
let { accountName, accountKey, connectionString, sharedAccessSignature } = credential;
|
|
32
|
+
let { accountName, accountKey, accountSas = '', connectionString, sharedAccessSignature } = credential;
|
|
33
33
|
if (connectionString) {
|
|
34
34
|
if (!accountName) {
|
|
35
35
|
credential.accountName = /AccountName=([^;]+);/.exec(connectionString)?.[1];
|
|
36
36
|
}
|
|
37
37
|
return storage.BlobServiceClient.fromConnectionString(connectionString);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
if (accountSas && !accountSas.startsWith('?')) {
|
|
40
|
+
accountSas = '?' + accountSas;
|
|
41
|
+
}
|
|
42
|
+
const url = `https://${accountName || process.env.AZURE_STORAGE_ACCOUNT}.blob.core.windows.net${accountSas}`;
|
|
40
43
|
if (sharedAccessSignature) {
|
|
41
44
|
if (accountName) {
|
|
42
45
|
if (!Cloud.isURL(sharedAccessSignature)) {
|
|
@@ -48,7 +51,7 @@ function createStorageClient(credential) {
|
|
|
48
51
|
}
|
|
49
52
|
return new storage.BlobServiceClient(sharedAccessSignature);
|
|
50
53
|
}
|
|
51
|
-
return new storage.BlobServiceClient(url, accountName && accountKey ? new storage.StorageSharedKeyCredential(accountName, accountKey) : new identity.DefaultAzureCredential());
|
|
54
|
+
return new storage.BlobServiceClient(url, accountName && accountSas ? new storage.AnonymousCredential() : accountName && accountKey ? new storage.StorageSharedKeyCredential(accountName, accountKey) : new identity.DefaultAzureCredential());
|
|
52
55
|
}
|
|
53
56
|
function createDatabaseClient(credential) {
|
|
54
57
|
if (credential.username && credential.password && credential.tenantId && credential.clientId) {
|
package/download/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pi-r/azure",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Azure cloud functions for E-mc.",
|
|
5
|
-
"main": "client/index.js",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
-
"directory": "src/cloud/azure"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"squared",
|
|
16
|
-
"e-mc",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.10.
|
|
24
|
-
"@e-mc/module": "^0.10.
|
|
25
|
-
"@e-mc/types": "^0.10.
|
|
26
|
-
"@azure/cosmos": "^4.
|
|
27
|
-
"@azure/identity": "^4.4.1",
|
|
28
|
-
"@azure/storage-blob": "^12.
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/azure",
|
|
3
|
+
"version": "0.8.3",
|
|
4
|
+
"description": "Azure cloud functions for E-mc.",
|
|
5
|
+
"main": "client/index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
|
+
"directory": "src/cloud/azure"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"squared",
|
|
16
|
+
"e-mc",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/cloud": "^0.10.3",
|
|
24
|
+
"@e-mc/module": "^0.10.3",
|
|
25
|
+
"@e-mc/types": "^0.10.3",
|
|
26
|
+
"@azure/cosmos": "^4.1.1",
|
|
27
|
+
"@azure/identity": "^4.4.1",
|
|
28
|
+
"@azure/storage-blob": "^12.25.0"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import type { CloudDatabase, CloudStorage } from '@e-mc/types/lib/cloud';
|
|
2
|
-
|
|
3
|
-
import type { CosmosClientOptions, FeedOptions, PartitionKey, PatchRequestBody, RequestOptions, SqlQuerySpec } from '@azure/cosmos';
|
|
4
|
-
|
|
5
|
-
export type AzureStorage = CloudStorage<AzureStorageCredential, "azure" | "az">;
|
|
6
|
-
|
|
7
|
-
export interface AzureStorageCredential {
|
|
8
|
-
accountName?: string;
|
|
9
|
-
accountKey?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import type { CloudDatabase, CloudStorage } from '@e-mc/types/lib/cloud';
|
|
2
|
+
|
|
3
|
+
import type { CosmosClientOptions, FeedOptions, PartitionKey, PatchRequestBody, RequestOptions, SqlQuerySpec } from '@azure/cosmos';
|
|
4
|
+
|
|
5
|
+
export type AzureStorage = CloudStorage<AzureStorageCredential, "azure" | "az">;
|
|
6
|
+
|
|
7
|
+
export interface AzureStorageCredential {
|
|
8
|
+
accountName?: string;
|
|
9
|
+
accountKey?: string;
|
|
10
|
+
accountSas?: string;
|
|
11
|
+
connectionString?: string;
|
|
12
|
+
sharedAccessSignature?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AzureDatabaseQuery<T = FeedOptions | RequestOptions, U = PatchRequestBody | PlainObject> extends CloudDatabase<string | SqlQuerySpec, T, U, unknown[], AzureDatabaseCredential> {
|
|
16
|
+
source: "cloud";
|
|
17
|
+
service: "azure" | "az";
|
|
18
|
+
partitionKey?: PartitionKey;
|
|
19
|
+
storedProcedureId?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AzureDatabaseCredential extends AuthValue, CosmosClientOptions {
|
|
23
|
+
tenantId?: string;
|
|
24
|
+
clientId?: string;
|
|
24
25
|
}
|