@polymorfa/sdk 0.1.0-dev.20260922140944 → 0.1.0-dev.20260923093259

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/README.md CHANGED
@@ -2,15 +2,16 @@
2
2
 
3
3
  The handwritten Polymorfa server SDK for TypeScript and Node.js.
4
4
 
5
- This package has not been published to npm. Build it from a clone of the
6
- development branch and install the packed tarball:
5
+ Install the development prerelease from npm:
7
6
 
8
7
  ```bash
9
- npm ci
10
- npm run build:workspaces
11
- npm pack -w @polymorfa/sdk
8
+ npm install @polymorfa/sdk@dev
12
9
  ```
13
10
 
11
+ Pin an exact `0.1.0-dev.<timestamp>` version for reproducible installs. See the
12
+ [repository installation guide](../../README.md#typescript-development-install)
13
+ to build and install a packed tarball from source.
14
+
14
15
  The Calls client is part of this package as `@polymorfa/sdk/calls`.
15
16
  `@polymorfa/sdk/calls/internal` exists for the Polymorfa browser package;
16
17
  applications must not import it.
@@ -47,7 +48,7 @@ const platform = new Client({
47
48
  type: "organizationApiKey",
48
49
  value: process.env.POLYMORFA_PLATFORM_API_KEY!,
49
50
  },
50
- apiVersion: "1.0.0",
51
+ apiVersion: "2026-03-20",
51
52
  });
52
53
 
53
54
  const project = platform.project("project_123");
@@ -84,9 +85,9 @@ v1 grammar and never decodes or decrypts the credential.
84
85
  The SDK rejects `pmfa_ct_` browser tokens and CLI-only `pmfa_ls_` listener
85
86
  credentials before a management request. It also rejects retired call-agent
86
87
  `pmfa_at_` and socket `pmfa_wst_` tickets and simulated-device `pmfa_sd_`
87
- capabilities as server API keys. It does not expose a listener,
88
- `AsyncIterable`, event emitter, or forwarding API. Live forwarding belongs to
89
- `polymorfa listen`.
88
+ capabilities as server API keys. `Client.events.stream()` exposes an
89
+ `AsyncIterable` for the separate [server event stream](#stream-events-in-real-time),
90
+ subject to scope and beta access. Live forwarding belongs to `polymorfa listen`.
90
91
 
91
92
  ## System and Bridge clients
92
93
 
@@ -1499,7 +1500,9 @@ console.log(replay.data.operationId);
1499
1500
 
1500
1501
  List methods return `CursorPage<T>`. Mutations return owner-specific typed
1501
1502
  receipts and preserve response metadata, request IDs, and idempotency receipts.
1502
- The SDK has no operation inspection or cancellation methods.
1503
+ Use `operations.get()` or `operations.wait()` to inspect asynchronous work,
1504
+ and `operations.cancel()` while `capabilities.cancellable` is true. Reads need
1505
+ `operations:read`; cancellation needs `operations:cancel`.
1503
1506
 
1504
1507
  Console and staff routes remain absent from the server client and its raw
1505
1508
  guidance. The CLI listener protocol stays private to the CLI.
@@ -1885,6 +1888,10 @@ has `delivery: "simulated"` and the event arrives as ordinary Test number
1885
1888
  activity. Both methods require an organization API key or project token with
1886
1889
  `sandbox:write` (trigger) or `sandbox:read` (list) and Test numbers access.
1887
1890
 
1891
+ Use `session.restriction_updated` with `{ restrictionActive: false }` to
1892
+ test a restriction ending, or `true` to test one starting. The `call.ended`
1893
+ fixture accepts `callEndReason: "call_restricted"` for a restricted call.
1894
+
1888
1895
  Pass `{ idempotencyKey }` as the third argument to `triggerEvent` to retry
1889
1896
  safely. Repeating the request with the same key and body reuses the same event
1890
1897
  ID, so a retry after an uncertain response never creates a second event or
@@ -4,7 +4,7 @@
4
4
  * codes are sent: no phone numbers, names, audio, video or device labels.
5
5
  */
6
6
  /** Package version sent with reports from `@polymorfa/sdk/calls`. */
7
- export declare const CALLS_SDK_VERSION = "0.1.0-dev.20260922140944";
7
+ export declare const CALLS_SDK_VERSION = "0.1.0-dev.20260923093259";
8
8
  export type CallErrorCode = "media_permission_denied" | "device_not_found" | "device_in_use" | "ice_failed" | "negotiation_failed" | "media_timeout" | "reconnect_exhausted" | "token_refresh_failed" | "unsupported_browser" | "other";
9
9
  /** Figures measured for one connection. Omit what was not measured. */
10
10
  export interface CallQualityFigures {
@@ -4,7 +4,7 @@
4
4
  * codes are sent: no phone numbers, names, audio, video or device labels.
5
5
  */
6
6
  /** Package version sent with reports from `@polymorfa/sdk/calls`. */
7
- export const CALLS_SDK_VERSION = "0.1.0-dev.20260922140944";
7
+ export const CALLS_SDK_VERSION = "0.1.0-dev.20260923093259";
8
8
  /** Platform limits per connection, applied locally to avoid refusals. */
9
9
  const QUALITY_INTERVAL_MS = 5_000;
10
10
  const ERRORS_PER_MINUTE = 20;
@@ -18,7 +18,7 @@ export interface TestingHistoryMessage {
18
18
  fromMe: boolean;
19
19
  }
20
20
  /** Fixture names accepted by `testing.triggerEvent`, in catalog order. */
21
- export declare const TEST_EVENT_FIXTURES: readonly ["message.received", "message.ack", "message.failed", "call.received", "call.missed", "call.ended", "session.status", "template.status", "bansafe.enforcement", "bansafe.risk_changed"];
21
+ export declare const TEST_EVENT_FIXTURES: readonly ["message.received", "message.ack", "message.failed", "call.received", "call.missed", "call.ended", "session.status", "session.restriction_updated", "template.status", "bansafe.enforcement", "bansafe.risk_changed"];
22
22
  /** Named test-event fixtures. Each name is the event type it produces. */
23
23
  export type TestEventFixture = (typeof TEST_EVENT_FIXTURES)[number];
24
24
  /** Optional payload overrides. Each fixture accepts only the fields it lists. */
@@ -44,7 +44,9 @@ export interface TestEventOverrides {
44
44
  /** call.ended: connected duration in seconds. */
45
45
  durationSeconds?: number;
46
46
  /** call.ended: termination reason. */
47
- callEndReason?: "user_hangup" | "timeout" | "lost_connection" | "rejected";
47
+ callEndReason?: "user_hangup" | "timeout" | "lost_connection" | "rejected" | "call_restricted";
48
+ /** session.restriction_updated: whether the restriction starts or ends. */
49
+ restrictionActive?: boolean;
48
50
  /** session.status: status. */
49
51
  status?: "CONNECTING" | "CONNECTED" | "DISCONNECTED";
50
52
  /** session.status: reason. */
@@ -1 +1 @@
1
- {"version":3,"file":"testing-configuration.d.ts","sourceRoot":"","sources":["../../src/messaging/testing-configuration.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA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IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,MAAM,kBAAkB,CAAC,CAAC;CAC5C"}
1
+ {"version":3,"file":"testing-configuration.d.ts","sourceRoot":"","sources":["../../src/messaging/testing-configuration.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACtC,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AACD,MAAM,MAAM,yBAAyB,GACjC,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,eAAe,GACf,iBAAiB,GACjB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,iOAYtB,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,GA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KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,0FAA0F;IAC1F,QAAQ,EAAE,WAAW,GAAG,WAAW,CAAC;IACpC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qGAAqG;IACrG,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,MAAM,kBAAkB,CAAC,CAAC;CAC5C"}
@@ -7,6 +7,7 @@ export const TEST_EVENT_FIXTURES = [
7
7
  "call.missed",
8
8
  "call.ended",
9
9
  "session.status",
10
+ "session.restriction_updated",
10
11
  "template.status",
11
12
  "bansafe.enforcement",
12
13
  "bansafe.risk_changed",
@@ -1 +1 @@
1
- {"version":3,"file":"testing-configuration.js","sourceRoot":"","sources":["../../src/messaging/testing-configuration.ts"],"names":[],"mappings":"AAwBA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kBAAkB;IAClB,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,qBAAqB;IACrB,sBAAsB;CACd,CAAC"}
1
+ {"version":3,"file":"testing-configuration.js","sourceRoot":"","sources":["../../src/messaging/testing-configuration.ts"],"names":[],"mappings":"AAwBA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kBAAkB;IAClB,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,6BAA6B;IAC7B,iBAAiB;IACjB,qBAAqB;IACrB,sBAAsB;CACd,CAAC"}
@@ -3,8 +3,9 @@ import type { RequestOptions } from "./types.js";
3
3
  * Give a non-idempotent messaging write a stable Idempotency-Key.
4
4
  *
5
5
  * A caller-supplied key wins. Otherwise one random key is generated per call,
6
- * so every automatic retry of that call reuses it and the API replays the
7
- * original result instead of performing the write again.
6
+ * so every automatic retry of that call reuses it. The endpoint determines the
7
+ * retry response: completed messaging writes return idempotency_completed
8
+ * without the original response body.
8
9
  */
9
10
  export declare function withIdempotencyKey(options: RequestOptions): RequestOptions;
10
11
  //# sourceMappingURL=idempotency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../src/transport/idempotency.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAG1E"}
1
+ {"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../src/transport/idempotency.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAG1E"}
@@ -2,8 +2,9 @@
2
2
  * Give a non-idempotent messaging write a stable Idempotency-Key.
3
3
  *
4
4
  * A caller-supplied key wins. Otherwise one random key is generated per call,
5
- * so every automatic retry of that call reuses it and the API replays the
6
- * original result instead of performing the write again.
5
+ * so every automatic retry of that call reuses it. The endpoint determines the
6
+ * retry response: completed messaging writes return idempotency_completed
7
+ * without the original response body.
7
8
  */
8
9
  export function withIdempotencyKey(options) {
9
10
  if (options.idempotencyKey !== undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../src/transport/idempotency.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAuB;IACxD,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACzD,OAAO,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;AACxE,CAAC"}
1
+ {"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../src/transport/idempotency.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAuB;IACxD,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACzD,OAAO,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;AACxE,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.1.0-dev.20260922140944";
1
+ export declare const SDK_VERSION = "0.1.0-dev.20260923093259";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const SDK_VERSION = "0.1.0-dev.20260922140944";
1
+ export const SDK_VERSION = "0.1.0-dev.20260923093259";
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymorfa/sdk",
3
- "version": "0.1.0-dev.20260922140944",
3
+ "version": "0.1.0-dev.20260923093259",
4
4
  "description": "Handwritten Polymorfa server SDK for TypeScript and Node.js",
5
5
  "type": "module",
6
6
  "license": "MIT",