@procedures/peer 0.1.0 → 0.2.1
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/CHANGELOG.md +27 -0
- package/README.md +3 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/discovery/index.d.ts +2 -1
- package/dist/discovery/index.d.ts.map +1 -1
- package/dist/discovery/index.js +2 -1
- package/dist/discovery/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +7 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +9 -1
- package/dist/module.js.map +1 -1
- package/dist/procedures/manifest.generate.d.ts +2 -1
- package/dist/procedures/manifest.generate.d.ts.map +1 -1
- package/dist/procedures/manifest.generate.js +5 -1
- package/dist/procedures/manifest.generate.js.map +1 -1
- package/dist/procedures/server.call.d.ts +2 -1
- package/dist/procedures/server.call.d.ts.map +1 -1
- package/dist/procedures/server.call.js +2 -0
- package/dist/procedures/server.call.js.map +1 -1
- package/dist/procedures/server.connect.d.ts +2 -1
- package/dist/procedures/server.connect.d.ts.map +1 -1
- package/dist/procedures/server.connect.js +6 -1
- package/dist/procedures/server.connect.js.map +1 -1
- package/dist/procedures/server.connections.d.ts +2 -1
- package/dist/procedures/server.connections.d.ts.map +1 -1
- package/dist/procedures/server.connections.js +2 -0
- package/dist/procedures/server.connections.js.map +1 -1
- package/dist/procedures/server.create.d.ts +2 -1
- package/dist/procedures/server.create.d.ts.map +1 -1
- package/dist/procedures/server.create.js +5 -1
- package/dist/procedures/server.create.js.map +1 -1
- package/dist/procedures/server.disconnect.d.ts +2 -1
- package/dist/procedures/server.disconnect.d.ts.map +1 -1
- package/dist/procedures/server.disconnect.js +5 -1
- package/dist/procedures/server.disconnect.js.map +1 -1
- package/dist/procedures/server.start.d.ts +2 -1
- package/dist/procedures/server.start.d.ts.map +1 -1
- package/dist/procedures/server.start.js +3 -0
- package/dist/procedures/server.start.js.map +1 -1
- package/dist/procedures/server.status.d.ts +2 -1
- package/dist/procedures/server.status.d.ts.map +1 -1
- package/dist/procedures/server.status.js +2 -0
- package/dist/procedures/server.status.js.map +1 -1
- package/dist/procedures/server.stop.d.ts +2 -1
- package/dist/procedures/server.stop.d.ts.map +1 -1
- package/dist/procedures/server.stop.js +2 -0
- package/dist/procedures/server.stop.js.map +1 -1
- package/dist/register.d.ts +3 -4
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +4 -9
- package/dist/register.js.map +1 -1
- package/package.json +6 -3
- package/src/discovery/index.ts +4 -1
- package/src/index.ts +1 -1
- package/src/module.ts +10 -1
- package/src/procedures/manifest.generate.ts +7 -3
- package/src/procedures/server.call.ts +4 -2
- package/src/procedures/server.connect.ts +8 -3
- package/src/procedures/server.connections.ts +4 -2
- package/src/procedures/server.create.ts +7 -3
- package/src/procedures/server.disconnect.ts +7 -3
- package/src/procedures/server.start.ts +5 -2
- package/src/procedures/server.status.ts +4 -2
- package/src/procedures/server.stop.ts +4 -2
- package/src/register.ts +4 -10
package/dist/register.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Importing this file registers the procedures of @procedures/peer
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Importing this file registers the procedures of @procedures/peer, and of the modules that it
|
|
3
|
+
* requires, in the global registry: `import "@procedures/peer/register"`. The package root and the
|
|
4
|
+
* `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
5
5
|
*/
|
|
6
6
|
export * from "./module.js";
|
|
7
|
-
export declare function registerServerProcedures(): void;
|
|
8
7
|
//# sourceMappingURL=register.d.ts.map
|
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,aAAa,CAAC"}
|
package/dist/register.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Importing this file registers the procedures of @procedures/peer
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Importing this file registers the procedures of @procedures/peer, and of the modules that it
|
|
3
|
+
* requires, in the global registry: `import "@procedures/peer/register"`. The package root and the
|
|
4
|
+
* `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { serverModule } from "./module.js";
|
|
6
|
+
import { registerServerProcedures } from "./module.js";
|
|
8
7
|
export * from "./module.js";
|
|
9
|
-
export function registerServerProcedures() {
|
|
10
|
-
registerProcedures(serverModule.procedures);
|
|
11
|
-
}
|
|
12
|
-
// Auto-register when this module is loaded
|
|
13
8
|
registerServerProcedures();
|
|
14
9
|
//# sourceMappingURL=register.js.map
|
package/dist/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,cAAc,aAAa,CAAC;AAE5B,wBAAwB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/peer",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"description": "Serve procedures: HTTP and WebSocket peers with token authentication, browser checks, an expose list, server.create, status and stop, and manifests.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"server",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"types": "./dist/module.d.ts",
|
|
36
36
|
"import": "./dist/module.js"
|
|
37
37
|
},
|
|
38
|
+
"./register": {
|
|
39
|
+
"types": "./dist/register.d.ts",
|
|
40
|
+
"import": "./dist/register.js"
|
|
41
|
+
},
|
|
38
42
|
"./procedures": {
|
|
39
43
|
"types": "./dist/procedures/index.d.ts",
|
|
40
44
|
"import": "./dist/procedures/index.js"
|
|
@@ -53,7 +57,6 @@
|
|
|
53
57
|
"CHANGELOG.md"
|
|
54
58
|
],
|
|
55
59
|
"sideEffects": [
|
|
56
|
-
"./dist/index.js",
|
|
57
60
|
"./dist/register.js"
|
|
58
61
|
],
|
|
59
62
|
"engines": {
|
|
@@ -74,7 +77,7 @@
|
|
|
74
77
|
"procedures": "./dist/register.js"
|
|
75
78
|
},
|
|
76
79
|
"dependencies": {
|
|
77
|
-
"@procedures/client": "0.1
|
|
80
|
+
"@procedures/client": "0.2.1",
|
|
78
81
|
"zod": "^4.6.5"
|
|
79
82
|
},
|
|
80
83
|
"optionalDependencies": {
|
package/src/discovery/index.ts
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
createProcedure,
|
|
10
|
+
type Effects,
|
|
10
11
|
type Procedure,
|
|
11
12
|
PROCEDURE_REGISTRY,
|
|
13
|
+
REGISTRY_READ_EFFECTS,
|
|
12
14
|
} from "@procedures/client";
|
|
13
15
|
import { schema } from "../schema.js";
|
|
14
16
|
import type {
|
|
@@ -39,7 +41,7 @@ const discoveryAnnounceOutputSchema = schema<ProcedureAnnounceMessage>();
|
|
|
39
41
|
export const discoveryAnnounceProcedure: Procedure<
|
|
40
42
|
DiscoveryAnnounceInput,
|
|
41
43
|
ProcedureAnnounceMessage,
|
|
42
|
-
{ description: string; internal: boolean }
|
|
44
|
+
{ description: string; internal: boolean; effects: Effects }
|
|
43
45
|
> = createProcedure()
|
|
44
46
|
.path(["_discovery", "announce"])
|
|
45
47
|
.input(discoveryAnnounceInputSchema)
|
|
@@ -47,6 +49,7 @@ export const discoveryAnnounceProcedure: Procedure<
|
|
|
47
49
|
.meta({
|
|
48
50
|
description: "Exchange procedure manifests for discovery",
|
|
49
51
|
internal: true,
|
|
52
|
+
effects: REGISTRY_READ_EFFECTS,
|
|
50
53
|
})
|
|
51
54
|
.handler(async (_input: DiscoveryAnnounceInput) => {
|
|
52
55
|
// Get all registered procedures
|
package/src/index.ts
CHANGED
package/src/module.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { type AnyProcedure, defineModule, type ProcedureModule } from "@procedures/client";
|
|
10
|
+
import { type AnyProcedure, defineModule, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
11
11
|
|
|
12
12
|
// Import all procedures
|
|
13
13
|
import { serverCreateProcedure } from "./procedures/server.create.js";
|
|
@@ -44,3 +44,12 @@ export const procedures: readonly AnyProcedure[] = [
|
|
|
44
44
|
export const serverModule: ProcedureModule = defineModule("@procedures/peer", [...procedures]);
|
|
45
45
|
|
|
46
46
|
export default serverModule;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This function registers the procedures of @procedures/peer, and of the modules that it requires, in
|
|
50
|
+
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
51
|
+
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
52
|
+
*/
|
|
53
|
+
export function registerServerProcedures(registry: ProcedureRegistry = PROCEDURE_REGISTRY): void {
|
|
54
|
+
registerModules(registry, [serverModule]);
|
|
55
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Generates procedure manifests in various formats
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, jsonSchemaOf, type Procedure, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
6
|
+
import { createProcedure, jsonSchemaOf, type Effects, type Procedure, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ManifestGenerateOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { manifestGenerateInputSchema } from "../input-schemas.js";
|
|
@@ -19,12 +19,16 @@ const manifestGenerateOutputSchema = wrapSchema<ManifestGenerateOutput>(Manifest
|
|
|
19
19
|
export const manifestGenerateProcedure: Procedure<
|
|
20
20
|
ManifestGenerateInput,
|
|
21
21
|
ManifestGenerateOutput,
|
|
22
|
-
{ description: string }
|
|
22
|
+
{ description: string; effects: Effects }
|
|
23
23
|
> = createProcedure()
|
|
24
24
|
.path(["manifest", "generate"])
|
|
25
25
|
.input(manifestGenerateInputSchema)
|
|
26
26
|
.output(manifestGenerateOutputSchema)
|
|
27
|
-
.meta({
|
|
27
|
+
.meta({
|
|
28
|
+
description: "Generate procedure manifests in various formats",
|
|
29
|
+
// With `outputDir`, it overwrites procedures.json and procedures.d.ts there
|
|
30
|
+
effects: { reads: ["registry"], writes: ["fs"], idempotent: true },
|
|
31
|
+
})
|
|
28
32
|
.handler(async (input: ManifestGenerateInput) => {
|
|
29
33
|
// Get all registered procedures
|
|
30
34
|
const allProcedures = PROCEDURE_REGISTRY.getAll();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Call a procedure on a remote peer through an outbound connection
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, pathToMethod, type Procedure } from "@procedures/client";
|
|
6
|
+
import { createProcedure, pathToMethod, type Effects, type Procedure } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerCallOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverCallInputSchema } from "../input-schemas.js";
|
|
@@ -42,13 +42,15 @@ const serverCallOutputSchema = wrapSchema<ServerCallOutput>(ServerCallOutputSche
|
|
|
42
42
|
export const serverCallProcedure: Procedure<
|
|
43
43
|
ServerCallInput,
|
|
44
44
|
ServerCallOutput,
|
|
45
|
-
{ description: string; args: string[]; shorts: Record<string, string>; output: string }
|
|
45
|
+
{ description: string; effects: Effects; args: string[]; shorts: Record<string, string>; output: string }
|
|
46
46
|
> = createProcedure()
|
|
47
47
|
.path(["server", "call"])
|
|
48
48
|
.input(serverCallInputSchema)
|
|
49
49
|
.output(serverCallOutputSchema)
|
|
50
50
|
.meta({
|
|
51
51
|
description: "Call a procedure on a remote peer through an outbound connection",
|
|
52
|
+
// The remote procedure can change anything on its peer
|
|
53
|
+
effects: { reads: ["network"], writes: ["network"] },
|
|
52
54
|
args: ["path"],
|
|
53
55
|
shorts: { connectionId: "c", address: "a" },
|
|
54
56
|
output: "json",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Connects to a remote peer for bidirectional RPC
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
6
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerConnectOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverConnectInputSchema } from "../input-schemas.js";
|
|
@@ -16,12 +16,17 @@ const serverConnectOutputSchema = wrapSchema<ServerConnectOutput>(ServerConnectO
|
|
|
16
16
|
export const serverConnectProcedure: Procedure<
|
|
17
17
|
ServerConnectInput,
|
|
18
18
|
ServerConnectOutput,
|
|
19
|
-
{ description: string }
|
|
19
|
+
{ description: string; effects: Effects }
|
|
20
20
|
> = createProcedure()
|
|
21
21
|
.path(["server", "connect"])
|
|
22
22
|
.input(serverConnectInputSchema)
|
|
23
23
|
.output(serverConnectOutputSchema)
|
|
24
|
-
.meta({
|
|
24
|
+
.meta({
|
|
25
|
+
description: "Connect to a remote peer for bidirectional RPC",
|
|
26
|
+
// It opens a new connection to a remote peer and reads the procedures of that peer
|
|
27
|
+
effects: { reads: ["network"], writes: ["network"], destructive: false },
|
|
28
|
+
args: ["address"],
|
|
29
|
+
})
|
|
25
30
|
.handler(async (input: ServerConnectInput) => {
|
|
26
31
|
const connectOptions: Parameters<typeof connect>[0] = {
|
|
27
32
|
address: input.address,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* List all outbound connections to remote peers
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
6
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerConnectionsOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverConnectionsInputSchema } from "../input-schemas.js";
|
|
@@ -37,13 +37,15 @@ const serverConnectionsOutputSchema = wrapSchema<ServerConnectionsOutput>(Server
|
|
|
37
37
|
export const serverConnectionsProcedure: Procedure<
|
|
38
38
|
ServerConnectionsInput,
|
|
39
39
|
ServerConnectionsOutput,
|
|
40
|
-
{ description: string; output: string }
|
|
40
|
+
{ description: string; effects: Effects; output: string }
|
|
41
41
|
> = createProcedure()
|
|
42
42
|
.path(["server", "connections"])
|
|
43
43
|
.input(serverConnectionsInputSchema)
|
|
44
44
|
.output(serverConnectionsOutputSchema)
|
|
45
45
|
.meta({
|
|
46
46
|
description: "List outbound connections to remote peers",
|
|
47
|
+
// It reads the connections that server.connect opened, and sends nothing
|
|
48
|
+
effects: { reads: ["network"], writes: [] },
|
|
47
49
|
output: "json",
|
|
48
50
|
})
|
|
49
51
|
.handler(async (): Promise<ServerConnectionsOutput> => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Creates a transport-agnostic peer that exposes procedures
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, type Procedure, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
6
|
+
import { createProcedure, type Effects, type Procedure, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerCreateOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverCreateInputSchema } from "../input-schemas.js";
|
|
@@ -20,12 +20,16 @@ const activePeers = new Map<string, Peer>();
|
|
|
20
20
|
export const serverCreateProcedure: Procedure<
|
|
21
21
|
ServerCreateInput,
|
|
22
22
|
ServerCreateOutput,
|
|
23
|
-
{ description: string }
|
|
23
|
+
{ description: string; effects: Effects }
|
|
24
24
|
> = createProcedure()
|
|
25
25
|
.path(["server", "create"])
|
|
26
26
|
.input(serverCreateInputSchema)
|
|
27
27
|
.output(serverCreateOutputSchema)
|
|
28
|
-
.meta({
|
|
28
|
+
.meta({
|
|
29
|
+
description: "Create a transport-agnostic peer that exposes procedures",
|
|
30
|
+
// Each call starts a new peer that listens on its transports. It replaces nothing.
|
|
31
|
+
effects: { reads: ["registry"], writes: ["network", "server"], destructive: false },
|
|
32
|
+
})
|
|
29
33
|
.handler(async (input: ServerCreateInput) => {
|
|
30
34
|
// Generate unique server ID
|
|
31
35
|
const serverId = `peer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Disconnects from a remote peer
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
6
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerDisconnectOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverDisconnectInputSchema } from "../input-schemas.js";
|
|
@@ -16,12 +16,16 @@ const serverDisconnectOutputSchema = wrapSchema<ServerDisconnectOutput>(ServerDi
|
|
|
16
16
|
export const serverDisconnectProcedure: Procedure<
|
|
17
17
|
ServerDisconnectInput,
|
|
18
18
|
ServerDisconnectOutput,
|
|
19
|
-
{ description: string }
|
|
19
|
+
{ description: string; effects: Effects }
|
|
20
20
|
> = createProcedure()
|
|
21
21
|
.path(["server", "disconnect"])
|
|
22
22
|
.input(serverDisconnectInputSchema)
|
|
23
23
|
.output(serverDisconnectOutputSchema)
|
|
24
|
-
.meta({
|
|
24
|
+
.meta({
|
|
25
|
+
description: "Disconnect from a remote peer",
|
|
26
|
+
effects: { reads: ["network"], writes: ["network"], idempotent: true },
|
|
27
|
+
args: ["connectionId"],
|
|
28
|
+
})
|
|
25
29
|
.handler(async (input: ServerDisconnectInput) => {
|
|
26
30
|
const success = await disconnect(input.connectionId);
|
|
27
31
|
return { success };
|
|
@@ -7,7 +7,7 @@ import { spawn } from "node:child_process";
|
|
|
7
7
|
import * as fs from "node:fs";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import * as os from "node:os";
|
|
10
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
10
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
11
11
|
import { wrapSchema } from "../schema.js";
|
|
12
12
|
import { ServerStartOutputSchema } from "../output-schemas.js";
|
|
13
13
|
import { serverStartInputSchema } from "../input-schemas.js";
|
|
@@ -88,13 +88,16 @@ function findCliPath(): string {
|
|
|
88
88
|
export const serverStartProcedure: Procedure<
|
|
89
89
|
ServerStartInput,
|
|
90
90
|
ServerStartOutput,
|
|
91
|
-
{ description: string; args: string[]; shorts: Record<string, string> }
|
|
91
|
+
{ description: string; effects: Effects; args: string[]; shorts: Record<string, string> }
|
|
92
92
|
> = createProcedure()
|
|
93
93
|
.path(["server", "start"])
|
|
94
94
|
.input(serverStartInputSchema)
|
|
95
95
|
.output(serverStartOutputSchema)
|
|
96
96
|
.meta({
|
|
97
97
|
description: "Start CLI server as background daemon",
|
|
98
|
+
// The daemon loads the procedure packages of the workspace. The procedure moves server.log
|
|
99
|
+
// over server.log.1.
|
|
100
|
+
effects: { reads: ["fs", "server"], writes: ["fs", "network", "process", "server"] },
|
|
98
101
|
args: [],
|
|
99
102
|
shorts: { port: "p", host: "h" },
|
|
100
103
|
})
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import * as os from "node:os";
|
|
8
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
8
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
9
9
|
import { wrapSchema } from "../schema.js";
|
|
10
10
|
import { ServerStatusOutputSchema } from "../output-schemas.js";
|
|
11
11
|
import { serverStatusInputSchema } from "../input-schemas.js";
|
|
@@ -50,13 +50,15 @@ function formatUptime(startedAt: string): string {
|
|
|
50
50
|
export const serverStatusProcedure: Procedure<
|
|
51
51
|
ServerStatusInput,
|
|
52
52
|
ServerStatusOutput,
|
|
53
|
-
{ description: string; output: string }
|
|
53
|
+
{ description: string; effects: Effects; output: string }
|
|
54
54
|
> = createProcedure()
|
|
55
55
|
.path(["server", "status"])
|
|
56
56
|
.input(serverStatusInputSchema)
|
|
57
57
|
.output(serverStatusOutputSchema)
|
|
58
58
|
.meta({
|
|
59
59
|
description: "Get CLI server status",
|
|
60
|
+
// It deletes the lockfile of a server that does not answer
|
|
61
|
+
effects: { reads: ["fs", "server"], writes: ["fs"], idempotent: true },
|
|
60
62
|
args: [],
|
|
61
63
|
shorts: { port: "p" },
|
|
62
64
|
output: "text",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Stops the running CLI server daemon
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createProcedure, type Procedure } from "@procedures/client";
|
|
6
|
+
import { createProcedure, type Effects, type Procedure } from "@procedures/client";
|
|
7
7
|
import { wrapSchema } from "../schema.js";
|
|
8
8
|
import { ServerStopOutputSchema } from "../output-schemas.js";
|
|
9
9
|
import { serverStopInputSchema } from "../input-schemas.js";
|
|
@@ -32,13 +32,15 @@ function killProcess(pid: number, signal: NodeJS.Signals = "SIGTERM"): boolean {
|
|
|
32
32
|
export const serverStopProcedure: Procedure<
|
|
33
33
|
ServerStopInput,
|
|
34
34
|
ServerStopOutput,
|
|
35
|
-
{ description: string }
|
|
35
|
+
{ description: string; effects: Effects }
|
|
36
36
|
> = createProcedure()
|
|
37
37
|
.path(["server", "stop"])
|
|
38
38
|
.input(serverStopInputSchema)
|
|
39
39
|
.output(serverStopOutputSchema)
|
|
40
40
|
.meta({
|
|
41
41
|
description: "Stop running CLI server",
|
|
42
|
+
// It stops the servers of the lockfiles and deletes their lockfiles
|
|
43
|
+
effects: { reads: ["fs", "server"], writes: ["fs", "server"], idempotent: true },
|
|
42
44
|
args: [],
|
|
43
45
|
shorts: { port: "p" },
|
|
44
46
|
})
|
package/src/register.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Importing this file registers the procedures of @procedures/peer
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Importing this file registers the procedures of @procedures/peer, and of the modules that it
|
|
3
|
+
* requires, in the global registry: `import "@procedures/peer/register"`. The package root and the
|
|
4
|
+
* `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { serverModule } from "./module.js";
|
|
7
|
+
import { registerServerProcedures } from "./module.js";
|
|
9
8
|
|
|
10
9
|
export * from "./module.js";
|
|
11
10
|
|
|
12
|
-
export function registerServerProcedures(): void {
|
|
13
|
-
registerProcedures(serverModule.procedures);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Auto-register when this module is loaded
|
|
17
11
|
registerServerProcedures();
|