@cfworker/cosmos 1.10.1 → 1.12.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.d.ts +3 -1
- package/dist/client.js +3 -1
- package/package.json +10 -11
- package/src/client.ts +10 -6
- package/tsconfig.json +7 -2
- package/LICENSE.md +0 -21
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface CosmosClientConfig {
|
|
|
10
10
|
dbId?: string;
|
|
11
11
|
collId?: string;
|
|
12
12
|
sessions?: SessionContainer;
|
|
13
|
+
enableCrossPartitionQueries?: boolean;
|
|
13
14
|
fetch?: typeof fetch;
|
|
14
15
|
}
|
|
15
16
|
export declare class CosmosClient {
|
|
@@ -19,6 +20,7 @@ export declare class CosmosClient {
|
|
|
19
20
|
private readonly consistencyLevel;
|
|
20
21
|
private readonly dbId;
|
|
21
22
|
private readonly collId;
|
|
23
|
+
private readonly enableCrossPartitionQueries;
|
|
22
24
|
private readonly systemFetch;
|
|
23
25
|
readonly sessions: SessionContainer;
|
|
24
26
|
requestCharges: number;
|
|
@@ -45,7 +47,7 @@ export declare class CosmosClient {
|
|
|
45
47
|
private fetch;
|
|
46
48
|
private setHeaders;
|
|
47
49
|
}
|
|
48
|
-
export declare type DocumentInit = BufferSource | ReadableStream
|
|
50
|
+
export declare type DocumentInit = BufferSource | ReadableStream | string | Resource;
|
|
49
51
|
interface CommonArgs {
|
|
50
52
|
activityId?: string;
|
|
51
53
|
consistencyLevel?: ConsistencyLevel;
|
package/dist/client.js
CHANGED
|
@@ -13,6 +13,8 @@ export class CosmosClient {
|
|
|
13
13
|
this.consistencyLevel = config.consistencyLevel ?? 'Session';
|
|
14
14
|
this.dbId = config.dbId;
|
|
15
15
|
this.collId = config.collId;
|
|
16
|
+
this.enableCrossPartitionQueries =
|
|
17
|
+
config.enableCrossPartitionQueries ?? true;
|
|
16
18
|
this.sessions = config.sessions ?? new DefaultSessionContainer();
|
|
17
19
|
this.systemFetch = config.fetch ?? fetch.bind(self);
|
|
18
20
|
}
|
|
@@ -147,7 +149,7 @@ export class CosmosClient {
|
|
|
147
149
|
assertArg('dbId', dbId);
|
|
148
150
|
assertArg('collId', collId);
|
|
149
151
|
const headers = Object.assign({
|
|
150
|
-
enableCrossPartition:
|
|
152
|
+
enableCrossPartition: this.enableCrossPartitionQueries,
|
|
151
153
|
enableScan: false,
|
|
152
154
|
maxItems: -1,
|
|
153
155
|
populateMetrics: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfworker/cosmos",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "Azure Cosmos DB client for Cloudflare Workers and service workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"azure",
|
|
@@ -37,17 +37,16 @@
|
|
|
37
37
|
"test": "cfworker test test/**/*.spec.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@cfworker/worker-types": "^1.
|
|
41
|
-
"@cloudflare/workers-types": "^2.
|
|
42
|
-
"base64-arraybuffer": "^0.2
|
|
40
|
+
"@cfworker/worker-types": "^1.12.1",
|
|
41
|
+
"@cloudflare/workers-types": "^2.2.2",
|
|
42
|
+
"base64-arraybuffer": "^1.0.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@cfworker/dev": "^1.
|
|
46
|
-
"@types/chai": "^4.
|
|
47
|
-
"@types/mocha": "^
|
|
45
|
+
"@cfworker/dev": "^1.13.1",
|
|
46
|
+
"@types/chai": "^4.3.0",
|
|
47
|
+
"@types/mocha": "^9.1.0",
|
|
48
48
|
"chai": "^4.3.4",
|
|
49
|
-
"mocha": "^
|
|
50
|
-
"typescript": "^4.
|
|
51
|
-
}
|
|
52
|
-
"gitHead": "ead7fc69fa2efc19191ba68fa342e9ad4befcedf"
|
|
49
|
+
"mocha": "^9.1.4",
|
|
50
|
+
"typescript": "^4.5.5"
|
|
51
|
+
}
|
|
53
52
|
}
|
package/src/client.ts
CHANGED
|
@@ -54,6 +54,11 @@ export interface CosmosClientConfig {
|
|
|
54
54
|
*/
|
|
55
55
|
sessions?: SessionContainer;
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Enables cross partition queries. This can be overriden on individual queries. Defaults to true.
|
|
59
|
+
*/
|
|
60
|
+
enableCrossPartitionQueries?: boolean;
|
|
61
|
+
|
|
57
62
|
/**
|
|
58
63
|
* System fetch function
|
|
59
64
|
*/
|
|
@@ -67,6 +72,7 @@ export class CosmosClient {
|
|
|
67
72
|
private readonly consistencyLevel: ConsistencyLevel;
|
|
68
73
|
private readonly dbId: string | undefined;
|
|
69
74
|
private readonly collId: string | undefined;
|
|
75
|
+
private readonly enableCrossPartitionQueries: boolean;
|
|
70
76
|
private readonly systemFetch: typeof fetch;
|
|
71
77
|
public readonly sessions: SessionContainer;
|
|
72
78
|
public requestCharges = 0;
|
|
@@ -79,6 +85,8 @@ export class CosmosClient {
|
|
|
79
85
|
this.consistencyLevel = config.consistencyLevel ?? 'Session';
|
|
80
86
|
this.dbId = config.dbId;
|
|
81
87
|
this.collId = config.collId;
|
|
88
|
+
this.enableCrossPartitionQueries =
|
|
89
|
+
config.enableCrossPartitionQueries ?? true;
|
|
82
90
|
this.sessions = config.sessions ?? new DefaultSessionContainer();
|
|
83
91
|
this.systemFetch = config.fetch ?? fetch.bind(self);
|
|
84
92
|
}
|
|
@@ -270,7 +278,7 @@ export class CosmosClient {
|
|
|
270
278
|
|
|
271
279
|
const headers = Object.assign(
|
|
272
280
|
{
|
|
273
|
-
enableCrossPartition:
|
|
281
|
+
enableCrossPartition: this.enableCrossPartitionQueries,
|
|
274
282
|
enableScan: false,
|
|
275
283
|
maxItems: -1,
|
|
276
284
|
populateMetrics: false,
|
|
@@ -404,11 +412,7 @@ export class CosmosClient {
|
|
|
404
412
|
}
|
|
405
413
|
}
|
|
406
414
|
|
|
407
|
-
export type DocumentInit =
|
|
408
|
-
| BufferSource
|
|
409
|
-
| ReadableStream<Uint8Array>
|
|
410
|
-
| string
|
|
411
|
-
| Resource;
|
|
415
|
+
export type DocumentInit = BufferSource | ReadableStream | string | Resource;
|
|
412
416
|
|
|
413
417
|
function toBodyInit(obj: DocumentInit): BodyInit {
|
|
414
418
|
if (
|
package/tsconfig.json
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
"extends": "../../tsconfig-base",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "ES2021",
|
|
5
|
-
"lib": ["
|
|
6
|
-
"types": [
|
|
5
|
+
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
|
|
6
|
+
"types": [
|
|
7
|
+
"chai",
|
|
8
|
+
"mocha",
|
|
9
|
+
"@cfworker/worker-types",
|
|
10
|
+
"@cloudflare/workers-types"
|
|
11
|
+
],
|
|
7
12
|
"outDir": "dist",
|
|
8
13
|
"rootDir": "./src"
|
|
9
14
|
},
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Jeremy Danyow
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|