@heynixie/contract 0.0.0-stage → 0.54.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/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <h1>@heynixie/contract</h1>
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/@heynixie/contract"><img src="https://img.shields.io/npm/v/@heynixie/contract" alt="npm version"></a>
6
+ <a href="../../LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
7
+ </p>
8
+
9
+ <p>
10
+ <a href="../../docs/architecture/channels/api.md">API</a> •
11
+ <a href="../../docs/architecture/deployment/release-pipeline.md">Release pipeline</a>
12
+ </p>
13
+ </div>
14
+
15
+ The oRPC contract of the nixie API, with the types a client needs.
16
+
17
+ Each release of nixie publishes the contract at its own version, so a client takes a change to the
18
+ API with a version bump. To start, install the package beside `@orpc/client`, build a client of the
19
+ `ContractClient` type on an oRPC link to your nixie's `/rpc` path, and send the client header on
20
+ every call.
21
+
22
+ ## Install
23
+
24
+ The package ships an ES module with its type declarations, so a client on Node, on Bun or in a
25
+ browser bundle loads it. It depends on oRPC and Zod at the versions nixie pins.
26
+
27
+ ```bash
28
+ bun add @heynixie/contract @orpc/client
29
+ ```
30
+
31
+ ## Features
32
+
33
+ - **The contract.** `contract` holds every procedure the API serves, with the Zod schema of each
34
+ input and output, and `hostContract` holds the procedures that the host commands call on the
35
+ server's local socket.
36
+ - **The client types.** `ContractClient`, `ContractInputs` and `ContractOutputs` give each
37
+ procedure's call, input and output.
38
+ - **The call headers.** `clientHeaderName` holds the name of the header the API needs on every call,
39
+ and `sessionCookieName` holds the name of the cookie that carries a device session.
40
+
41
+ ## Configuration
42
+
43
+ A client points its oRPC link at the API's `/rpc` path, and
44
+ [the API](../../docs/architecture/channels/api.md) describes how a call carries its device session.
@@ -0,0 +1,8 @@
1
+ import type { PendingInput } from './types.js';
2
+ export interface BeforeInputFields {
3
+ readonly inputType: string;
4
+ readonly data: string | null;
5
+ readonly selectionEnd: number;
6
+ readonly selectionStart: number;
7
+ }
8
+ export declare function buildPendingInput(fields: BeforeInputFields): PendingInput;