@pi-r/azure 0.5.3 → 0.5.4

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Haruhi Suzumiya
1
+ Copyright 2024 An Pham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/client/index.js CHANGED
@@ -22,14 +22,15 @@ function validateDatabase(credential, data) {
22
22
  }
23
23
  exports.validateDatabase = validateDatabase;
24
24
  function createStorageClient(credential) {
25
+ var _a, _b;
25
26
  const { BlobServiceClient, StorageSharedKeyCredential } = storage;
26
27
  const { accountName, accountKey, connectionString, sharedAccessSignature } = credential;
27
28
  if (connectionString) {
28
- credential.accountName || (credential.accountName = /AccountName=([^;]+);/.exec(connectionString)?.[1]);
29
+ credential.accountName || (credential.accountName = (_a = /AccountName=([^;]+);/.exec(connectionString)) === null || _a === void 0 ? void 0 : _a[1]);
29
30
  return BlobServiceClient.fromConnectionString(connectionString);
30
31
  }
31
32
  if (sharedAccessSignature) {
32
- credential.accountName || (credential.accountName = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)?.[1]);
33
+ credential.accountName || (credential.accountName = (_b = /^https:\/\/([a-z\d]+)\./.exec(sharedAccessSignature)) === null || _b === void 0 ? void 0 : _b[1]);
33
34
  return new BlobServiceClient(sharedAccessSignature);
34
35
  }
35
36
  let azureCredential;
@@ -160,7 +161,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
160
161
  client || (client = createDatabaseClient.call(this, length === 1 ? credential : { ...credential }));
161
162
  return client.database(name).container(table);
162
163
  };
163
- const closeClient = () => client?.dispose();
164
+ const closeClient = () => client === null || client === void 0 ? void 0 : client.dispose();
164
165
  for (let i = 0; i < length; ++i) {
165
166
  const item = batch[i];
166
167
  const { service, name, table, id, query, storedProcedureId, partitionKey = null, params, limit = 0, update, ignoreCache } = item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/azure",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Azure cloud functions for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "publishConfig": {
@@ -20,9 +20,9 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/cloud": "^0.7.3",
24
- "@e-mc/module": "^0.7.3",
25
- "@e-mc/types": "^0.7.3",
23
+ "@e-mc/cloud": "^0.7.5",
24
+ "@e-mc/module": "^0.7.5",
25
+ "@e-mc/types": "^0.7.5",
26
26
  "@azure/cosmos": "^4.0.0",
27
27
  "@azure/identity": "^4.0.1",
28
28
  "@azure/storage-blob": "^12.17.0"
package/upload/index.js CHANGED
@@ -31,14 +31,14 @@ function upload(credential, service = 'azure') {
31
31
  const configBucket = admin.configBucket;
32
32
  if (!BUCKET_SESSION.has(bucket)) {
33
33
  const bucketAcl = admin.publicRead ? 'blob' : admin.acl;
34
- const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, configBucket?.create));
34
+ const response = BUCKET_RESPONSE[_a = bucketKey = getBucketKey(credential, bucket, bucketAcl)] || (BUCKET_RESPONSE[_a] = client_1.createBucketV2.call(this, credential, bucket, bucketAcl, configBucket === null || configBucket === void 0 ? void 0 : configBucket.create));
35
35
  if (!await response) {
36
36
  errorResponse(null);
37
37
  return;
38
38
  }
39
39
  BUCKET_SESSION.add(bucket);
40
40
  }
41
- let retentionPolicy = configBucket?.retentionPolicy;
41
+ let retentionPolicy = configBucket === null || configBucket === void 0 ? void 0 : configBucket.retentionPolicy;
42
42
  if (retentionPolicy) {
43
43
  if (!Array.isArray(retentionPolicy)) {
44
44
  retentionPolicy = [retentionPolicy];
package/types/index.d.ts DELETED
@@ -1,24 +0,0 @@
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
- connectionString?: string;
11
- sharedAccessSignature?: string;
12
- }
13
-
14
- export interface AzureDatabaseQuery<T = FeedOptions | RequestOptions> extends CloudDatabase<string | SqlQuerySpec, T, PatchRequestBody, unknown[], AzureDatabaseCredential> {
15
- source: "cloud";
16
- service: "azure" | "az";
17
- partitionKey?: PartitionKey;
18
- storedProcedureId?: string;
19
- }
20
-
21
- export interface AzureDatabaseCredential extends AuthValue, CosmosClientOptions {
22
- tenantId?: string;
23
- clientId?: string;
24
- }