@mdbase-dev/connect 0.1.0-beta.32 → 0.1.0-beta.34

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/session.d.ts CHANGED
@@ -67,7 +67,7 @@ export declare class MdbaseSession<Frontmatter extends JsonObject = JsonObject>
67
67
  authorize(target: "choose" | "selected" | {
68
68
  collectionId: string;
69
69
  }, options?: Omit<MdbaseAuthorizeOptions, "operations" | "returnTo" | "target">): Promise<ConnectOutcome<MdbaseAuthorizationOutcome<Frontmatter>, SessionProblemCode>>;
70
- ensureOperations(requiredOperations: CollectionOperation[]): Promise<ConnectOutcome<MdbaseAuthorizationOutcome<Frontmatter> | {
70
+ ensureOperations(requiredOperations: CollectionOperation[], options?: ConnectRequestOptions): Promise<ConnectOutcome<MdbaseAuthorizationOutcome<Frontmatter> | {
71
71
  kind: "unchanged";
72
72
  connection: MdbaseConnection<Frontmatter>;
73
73
  }, SessionProblemCode>>;
package/dist/session.js CHANGED
@@ -124,7 +124,7 @@ export class MdbaseSession {
124
124
  this.refresh();
125
125
  }
126
126
  }
127
- async ensureOperations(requiredOperations) {
127
+ async ensureOperations(requiredOperations, options) {
128
128
  const current = this.snapshot;
129
129
  if (current.status !== "ready") {
130
130
  return connectFailure(connectProblem("collection_not_ready", "Choose an authorized collection first."));
@@ -137,6 +137,7 @@ export class MdbaseSession {
137
137
  this.transactionDepth += 1;
138
138
  try {
139
139
  const outcome = await this.connect.authorize({
140
+ ...options,
140
141
  operations: uniqueOperations([...capabilities.grantedOperations, ...capabilities.missingOperations]),
141
142
  target: { kind: "collection", collectionId: current.collectionId },
142
143
  returnTo: this.selection.authorizationReturnTo()
@@ -0,0 +1,8 @@
1
+ import type { WatchOptions } from "./operation-types.js";
2
+ export interface ResolvedWatchRetryOptions {
3
+ initialDelayMs: number;
4
+ maxDelayMs: number;
5
+ multiplier: number;
6
+ maxAttempts?: number;
7
+ }
8
+ export declare function watchRetryPolicy(options: WatchOptions["retry"]): ResolvedWatchRetryOptions | undefined;
@@ -0,0 +1,12 @@
1
+ export function watchRetryPolicy(options) {
2
+ if (options === false)
3
+ return undefined;
4
+ return {
5
+ initialDelayMs: Math.max(0, options?.initialDelayMs ?? 500),
6
+ maxDelayMs: Math.max(0, options?.maxDelayMs ?? 15_000),
7
+ multiplier: Math.max(1, options?.multiplier ?? 2),
8
+ ...(options?.maxAttempts === undefined
9
+ ? {}
10
+ : { maxAttempts: Math.max(0, options.maxAttempts) })
11
+ };
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdbase-dev/connect",
3
- "version": "0.1.0-beta.32",
3
+ "version": "0.1.0-beta.34",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "README.md"
34
34
  ],
35
35
  "dependencies": {
36
- "@mdbase-dev/connect-protocol": "0.1.0-beta.32"
36
+ "@mdbase-dev/connect-protocol": "0.1.0-beta.34"
37
37
  },
38
38
  "devDependencies": {
39
39
  "esbuild": "^0.28.1",
@@ -45,7 +45,7 @@
45
45
  "test": "vitest run",
46
46
  "test:browser-storage": "pnpm build && node scripts/browser-storage.test.mjs",
47
47
  "test:consumer-spikes": "tsc -p tsconfig.consumer-spikes.json",
48
- "test:public-api": "pnpm build && tsc -p tsconfig.public-api.json",
48
+ "test:public-api": "pnpm build && pnpm --filter @mdbase-dev/connect-protocol build && pnpm --filter @mdbase-dev/connect-testing build && tsc -p tsconfig.public-api.json && node scripts/check-public-api.mjs && node scripts/test-packed-api.mjs",
49
49
  "typecheck": "tsc -p tsconfig.json --noEmit"
50
50
  }
51
51
  }