@telecrypt-io/storage 0.5.27 → 0.5.29

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.
@@ -1,3 +1,6 @@
1
+ export declare class ConditionTimeoutError extends Error {
2
+ constructor(timeoutMs: number);
3
+ }
1
4
  /**
2
5
  * A freshly-synced client doesn't always see a room/event the *instant* the
3
6
  * server has committed it — e.g. a room this same session just created can
package/dist/core/poll.js CHANGED
@@ -1,3 +1,9 @@
1
+ export class ConditionTimeoutError extends Error {
2
+ constructor(timeoutMs) {
3
+ super(`timed out after ${timeoutMs}ms waiting for condition`);
4
+ this.name = "ConditionTimeoutError";
5
+ }
6
+ }
1
7
  /**
2
8
  * A freshly-synced client doesn't always see a room/event the *instant* the
3
9
  * server has committed it — e.g. a room this same session just created can
@@ -12,7 +18,7 @@ export async function waitForCondition(check, opts) {
12
18
  const timeoutMs = opts?.timeoutMs ?? 15000;
13
19
  const intervalMs = opts?.intervalMs ?? 300;
14
20
  const deadline = Date.now() + timeoutMs;
15
- const timeoutError = () => new Error(`timed out after ${timeoutMs}ms waiting for condition`);
21
+ const timeoutError = () => new ConditionTimeoutError(timeoutMs);
16
22
  const abortError = () => {
17
23
  const reason = opts?.signal?.reason;
18
24
  return reason instanceof Error ? reason : new Error("condition wait aborted");
@@ -1,3 +1,4 @@
1
- /** Small shared input validators kept out of the public core barrel. */
1
+ /** Shared name contract used by SDK inputs and remote projections. */
2
2
  export declare const MAX_NAME_LENGTH = 512;
3
+ export declare function isValidName(value: unknown): value is string;
3
4
  export declare function validateName(value: unknown, label: string): asserts value is string;
@@ -1,10 +1,13 @@
1
- /** Small shared input validators kept out of the public core barrel. */
1
+ /** Shared name contract used by SDK inputs and remote projections. */
2
2
  export const MAX_NAME_LENGTH = 512;
3
+ export function isValidName(value) {
4
+ return (typeof value === "string" &&
5
+ value.length > 0 &&
6
+ value.length <= MAX_NAME_LENGTH &&
7
+ !/[\u0000-\u001f\u007f]/.test(value));
8
+ }
3
9
  export function validateName(value, label) {
4
- if (typeof value !== "string" ||
5
- value.length === 0 ||
6
- value.length > MAX_NAME_LENGTH ||
7
- /[\u0000-\u001f\u007f]/.test(value)) {
10
+ if (!isValidName(value)) {
8
11
  throw new Error(`invalid ${label}`);
9
12
  }
10
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.5.27",
3
+ "version": "0.5.29",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.19.0",