@cfworker/cosmos 1.13.5 → 2.0.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 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 declare type CosmosClientConfig = (ConnectionInfo & CosmosClientConfigBase) | ({
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 declare type DocumentInit = BufferSource | ReadableStream | string | Resource;
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 declare type GetDatabasesArgs = CommonGetListArgs;
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
@@ -12,6 +12,7 @@ export function getCollectionId({ url, headers }) {
12
12
  return { dbId, collId };
13
13
  }
14
14
  export class DefaultSessionContainer {
15
+ tokens;
15
16
  constructor(tokens = {}) {
16
17
  this.tokens = tokens;
17
18
  }
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 declare type ConsistencyLevel = 'Strong' | 'Bounded' | 'Session' | 'Eventual';
2
- export declare type OfferType = 'S1' | 'S2' | 'S3';
3
- export declare type IndexingDirective = 'Include' | 'Exclude';
4
- export declare type IndexingMode = 'none' | 'consistent' | 'lazy';
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,6 @@
1
1
  {
2
2
  "name": "@cfworker/cosmos",
3
- "version": "1.13.5",
3
+ "version": "2.0.0",
4
4
  "description": "Azure Cosmos DB client for Cloudflare Workers and service workers",
5
5
  "keywords": [
6
6
  "azure",
@@ -34,19 +34,19 @@
34
34
  "scripts": {
35
35
  "build": "tsc --build",
36
36
  "clean": "tsc --build --clean",
37
- "test": "cfworker test test/**/*.spec.ts"
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
- "@cfworker/worker-types": "^1.12.3",
41
- "@cloudflare/workers-types": "^2.2.2",
42
- "rfc4648": "^1.5.2"
41
+ "rfc4648": "^1.5.3"
43
42
  },
44
43
  "devDependencies": {
45
- "@cfworker/dev": "^1.14.2",
46
- "@types/chai": "^4.3.3",
47
- "@types/mocha": "^10.0.0",
48
- "chai": "^4.3.6",
49
- "mocha": "^10.0.0",
50
- "typescript": "^4.8.4"
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 CHANGED
@@ -1,14 +1,8 @@
1
1
  {
2
2
  "extends": "../../tsconfig-base",
3
3
  "compilerOptions": {
4
- "target": "ES2021",
4
+ "target": "ESNext",
5
5
  "lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
6
- "types": [
7
- "chai",
8
- "mocha",
9
- "@cfworker/worker-types",
10
- "@cloudflare/workers-types"
11
- ],
12
6
  "outDir": "dist",
13
7
  "rootDir": "./src"
14
8
  },