@cfworker/cosmos 1.13.0 → 1.13.1
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/dist/client.js +2 -2
- package/dist/signer.d.ts +1 -1
- package/dist/signer.js +4 -4
- package/dist/types.d.ts +1 -1
- package/dist/util.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +3 -3
- package/src/signer.ts +4 -4
- package/src/types.ts +1 -1
- package/src/util.ts +1 -1
package/dist/client.js
CHANGED
|
@@ -7,14 +7,14 @@ export class CosmosClient {
|
|
|
7
7
|
constructor(config) {
|
|
8
8
|
this.requestCharges = 0;
|
|
9
9
|
this.retries = { count: 0, delayMs: 0 };
|
|
10
|
-
let { endpoint,
|
|
10
|
+
let { endpoint, masterKey } = 'connectionString' in config
|
|
11
11
|
? parseConnectionString(config.connectionString)
|
|
12
12
|
: config;
|
|
13
13
|
if (endpoint.endsWith('/')) {
|
|
14
14
|
endpoint = endpoint.slice(0, -1);
|
|
15
15
|
}
|
|
16
16
|
this.endpoint = endpoint;
|
|
17
|
-
this.signer = getSigner(
|
|
17
|
+
this.signer = getSigner(masterKey);
|
|
18
18
|
this.retryPolicy = config.retryPolicy ?? defaultRetryPolicy;
|
|
19
19
|
this.consistencyLevel = config.consistencyLevel ?? 'Session';
|
|
20
20
|
this.dbId = config.dbId;
|
package/dist/signer.d.ts
CHANGED
package/dist/signer.js
CHANGED
|
@@ -35,9 +35,9 @@ export class Signer {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
const signers = {};
|
|
38
|
-
export function getSigner(
|
|
39
|
-
if (!signers[
|
|
40
|
-
signers[
|
|
38
|
+
export function getSigner(masterKey) {
|
|
39
|
+
if (!signers[masterKey]) {
|
|
40
|
+
signers[masterKey] = new Signer(masterKey);
|
|
41
41
|
}
|
|
42
|
-
return signers[
|
|
42
|
+
return signers[masterKey];
|
|
43
43
|
}
|
package/dist/types.d.ts
CHANGED
package/dist/util.js
CHANGED
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type CosmosClientConfig =
|
|
|
27
27
|
/**
|
|
28
28
|
* Cosmos DB connection string.
|
|
29
29
|
* @example
|
|
30
|
-
* "AccountEndpoint=https://xxxxxxxxxx.documents.azure.com:443/;
|
|
30
|
+
* "AccountEndpoint=https://xxxxxxxxxx.documents.azure.com:443/;AccountKey=xxxxxxxxxx;"
|
|
31
31
|
*/
|
|
32
32
|
connectionString: string;
|
|
33
33
|
} & CosmosClientConfigBase);
|
|
@@ -84,7 +84,7 @@ export class CosmosClient {
|
|
|
84
84
|
public retries = { count: 0, delayMs: 0 };
|
|
85
85
|
|
|
86
86
|
constructor(config: CosmosClientConfig) {
|
|
87
|
-
let { endpoint,
|
|
87
|
+
let { endpoint, masterKey } =
|
|
88
88
|
'connectionString' in config
|
|
89
89
|
? parseConnectionString(config.connectionString)
|
|
90
90
|
: config;
|
|
@@ -92,7 +92,7 @@ export class CosmosClient {
|
|
|
92
92
|
endpoint = endpoint.slice(0, -1);
|
|
93
93
|
}
|
|
94
94
|
this.endpoint = endpoint;
|
|
95
|
-
this.signer = getSigner(
|
|
95
|
+
this.signer = getSigner(masterKey);
|
|
96
96
|
this.retryPolicy = config.retryPolicy ?? defaultRetryPolicy;
|
|
97
97
|
this.consistencyLevel = config.consistencyLevel ?? 'Session';
|
|
98
98
|
this.dbId = config.dbId;
|
package/src/signer.ts
CHANGED
|
@@ -55,9 +55,9 @@ export class Signer {
|
|
|
55
55
|
|
|
56
56
|
const signers: Record<string, Signer> = {};
|
|
57
57
|
|
|
58
|
-
export function getSigner(
|
|
59
|
-
if (!signers[
|
|
60
|
-
signers[
|
|
58
|
+
export function getSigner(masterKey: string) {
|
|
59
|
+
if (!signers[masterKey]) {
|
|
60
|
+
signers[masterKey] = new Signer(masterKey);
|
|
61
61
|
}
|
|
62
|
-
return signers[
|
|
62
|
+
return signers[masterKey];
|
|
63
63
|
}
|
package/src/types.ts
CHANGED