@cfworker/cosmos 1.13.6 → 2.1.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/dist/client.d.ts +3 -3
- package/dist/client.js +11 -2
- package/dist/response.js +3 -0
- package/dist/retry.js +3 -0
- package/dist/session.js +1 -0
- package/dist/signer.js +2 -1
- package/dist/types.d.ts +4 -4
- package/package.json +12 -12
- package/tsconfig.json +0 -16
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FeedResponse, ItemResponse } from './response.js';
|
|
|
2
2
|
import { RetryPolicy } from './retry.js';
|
|
3
3
|
import { SessionContainer } from './session.js';
|
|
4
4
|
import { Collection, ConnectionInfo, ConsistencyLevel, Database, Document, IndexingDirective, IndexingPolicy, OfferType, PartitionKeyDefinition, Resource } from './types.js';
|
|
5
|
-
export
|
|
5
|
+
export type CosmosClientConfig = (ConnectionInfo & CosmosClientConfigBase) | ({
|
|
6
6
|
connectionString: string;
|
|
7
7
|
} & CosmosClientConfigBase);
|
|
8
8
|
interface CosmosClientConfigBase {
|
|
@@ -48,7 +48,7 @@ export declare class CosmosClient {
|
|
|
48
48
|
private fetch;
|
|
49
49
|
private setHeaders;
|
|
50
50
|
}
|
|
51
|
-
export
|
|
51
|
+
export type DocumentInit = BufferSource | ReadableStream | string | Resource;
|
|
52
52
|
interface CommonArgs {
|
|
53
53
|
activityId?: string;
|
|
54
54
|
consistencyLevel?: ConsistencyLevel;
|
|
@@ -61,7 +61,7 @@ interface CommonGetListArgs extends CommonGetArgs {
|
|
|
61
61
|
maxItems?: number;
|
|
62
62
|
continuation?: string;
|
|
63
63
|
}
|
|
64
|
-
export
|
|
64
|
+
export type GetDatabasesArgs = CommonGetListArgs;
|
|
65
65
|
export interface GetDatabaseArgs extends CommonGetArgs {
|
|
66
66
|
dbId?: string;
|
|
67
67
|
}
|
package/dist/client.js
CHANGED
|
@@ -4,9 +4,18 @@ import { DefaultSessionContainer } from './session.js';
|
|
|
4
4
|
import { getSigner } from './signer.js';
|
|
5
5
|
import { assertArg, escapeNonASCII, parseConnectionString, uri } from './util.js';
|
|
6
6
|
export class CosmosClient {
|
|
7
|
+
endpoint;
|
|
8
|
+
signer;
|
|
9
|
+
retryPolicy;
|
|
10
|
+
consistencyLevel;
|
|
11
|
+
dbId;
|
|
12
|
+
collId;
|
|
13
|
+
enableCrossPartitionQueries;
|
|
14
|
+
systemFetch;
|
|
15
|
+
sessions;
|
|
16
|
+
requestCharges = 0;
|
|
17
|
+
retries = { count: 0, delayMs: 0 };
|
|
7
18
|
constructor(config) {
|
|
8
|
-
this.requestCharges = 0;
|
|
9
|
-
this.retries = { count: 0, delayMs: 0 };
|
|
10
19
|
let { endpoint, masterKey } = 'connectionString' in config
|
|
11
20
|
? parseConnectionString(config.connectionString)
|
|
12
21
|
: config;
|
package/dist/response.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export class CosmosResponse {
|
|
2
|
+
response;
|
|
2
3
|
constructor(response) {
|
|
3
4
|
this.response = response;
|
|
4
5
|
}
|
|
@@ -33,6 +34,8 @@ export class ItemResponse extends CosmosResponse {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
export class FeedResponse extends CosmosResponse {
|
|
37
|
+
next;
|
|
38
|
+
itemsProperty;
|
|
36
39
|
constructor(response, next, itemsProperty) {
|
|
37
40
|
super(response);
|
|
38
41
|
this.next = next;
|
package/dist/retry.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { readSessionNotAvailable } from './session';
|
|
2
2
|
export class DefaultRetryPolicy {
|
|
3
|
+
maxAttempts;
|
|
4
|
+
maxCumulativeWaitTimeMs;
|
|
5
|
+
defaultRetryDelayMs;
|
|
3
6
|
constructor(maxAttempts = 10, maxCumulativeWaitTimeMs = 30000, defaultRetryDelayMs = 5000) {
|
|
4
7
|
this.maxAttempts = maxAttempts;
|
|
5
8
|
this.maxCumulativeWaitTimeMs = maxCumulativeWaitTimeMs;
|
package/dist/session.js
CHANGED
package/dist/signer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { base64 } from 'rfc4648';
|
|
2
2
|
export class Signer {
|
|
3
|
+
masterkey;
|
|
4
|
+
encoder = new TextEncoder();
|
|
3
5
|
constructor(masterkey) {
|
|
4
|
-
this.encoder = new TextEncoder();
|
|
5
6
|
const promiseLike = crypto.subtle.importKey('raw', base64.parse(masterkey), { name: 'HMAC', hash: { name: 'SHA-256' } }, false, ['sign']);
|
|
6
7
|
this.masterkey = Promise.resolve(promiseLike);
|
|
7
8
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export type ConsistencyLevel = 'Strong' | 'Bounded' | 'Session' | 'Eventual';
|
|
2
|
+
export type OfferType = 'S1' | 'S2' | 'S3';
|
|
3
|
+
export type IndexingDirective = 'Include' | 'Exclude';
|
|
4
|
+
export type IndexingMode = 'none' | 'consistent' | 'lazy';
|
|
5
5
|
export interface Resource {
|
|
6
6
|
id: string;
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfworker/cosmos",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.1.0",
|
|
4
5
|
"description": "Azure Cosmos DB client for Cloudflare Workers and service workers",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"azure",
|
|
@@ -20,7 +21,6 @@
|
|
|
20
21
|
"files": [
|
|
21
22
|
"dist/**/*",
|
|
22
23
|
"src/**/*",
|
|
23
|
-
"tsconfig.json",
|
|
24
24
|
"README.md",
|
|
25
25
|
"package.json"
|
|
26
26
|
],
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc --build",
|
|
36
36
|
"clean": "tsc --build --clean",
|
|
37
|
-
"
|
|
37
|
+
"pretest": "esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
|
|
38
|
+
"test": "node ../../test.mjs"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"
|
|
41
|
-
"@cloudflare/workers-types": "^2.2.2",
|
|
42
|
-
"rfc4648": "^1.5.2"
|
|
41
|
+
"rfc4648": "^1.5.3"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@types/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"mocha": "^10.
|
|
50
|
-
"typescript": "^
|
|
44
|
+
"@types/chai": "^4.3.17",
|
|
45
|
+
"@types/mocha": "^10.0.7",
|
|
46
|
+
"chai": "^5.1.1",
|
|
47
|
+
"esbuild": "^0.23.1",
|
|
48
|
+
"mocha": "^10.7.3",
|
|
49
|
+
"typescript": "^5.5.4",
|
|
50
|
+
"wrangler": "^3.72.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig-base",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ES2021",
|
|
5
|
-
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
|
|
6
|
-
"types": [
|
|
7
|
-
"chai",
|
|
8
|
-
"mocha",
|
|
9
|
-
"@cfworker/worker-types",
|
|
10
|
-
"@cloudflare/workers-types"
|
|
11
|
-
],
|
|
12
|
-
"outDir": "dist",
|
|
13
|
-
"rootDir": "./src"
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
-
}
|