@kubun/plugin-p2p-api 0.16.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/LICENSE.md +57 -0
- package/lib/index.d.ts +55 -0
- package/lib/index.js +8 -0
- package/package.json +32 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# The Prosperity Public License 3.0.0
|
|
2
|
+
|
|
3
|
+
Contributor: Paul Le Cam
|
|
4
|
+
|
|
5
|
+
Source Code: https://github.com/PaulLeCam/kubun
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.
|
|
10
|
+
|
|
11
|
+
## Agreement
|
|
12
|
+
|
|
13
|
+
In order to receive this license, you have to agree to its rules. Those rules are both obligations under that agreement and conditions to your license. Don't do anything with this software that triggers a rule you can't or won't follow.
|
|
14
|
+
|
|
15
|
+
## Notices
|
|
16
|
+
|
|
17
|
+
Make sure everyone who gets a copy of any part of this software from you, with or without changes, also gets the text of this license and the contributor and source code lines above.
|
|
18
|
+
|
|
19
|
+
## Commercial Trial
|
|
20
|
+
|
|
21
|
+
Limit your use of this software for commercial purposes to a thirty-day trial period. If you use this software for work, your company gets one trial period for all personnel, not one trial per person.
|
|
22
|
+
|
|
23
|
+
## Contributions Back
|
|
24
|
+
|
|
25
|
+
Developing feedback, changes, or additions that you contribute back to the contributor on the terms of a standardized public software license such as [the Blue Oak Model License 1.0.0](https://blueoakcouncil.org/license/1.0.0), [the Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html), [the MIT license](https://spdx.org/licenses/MIT.html), or [the two-clause BSD license](https://spdx.org/licenses/BSD-2-Clause.html) doesn't count as use for a commercial purpose.
|
|
26
|
+
|
|
27
|
+
## Personal Uses
|
|
28
|
+
|
|
29
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn't count as use for a commercial purpose.
|
|
30
|
+
|
|
31
|
+
## Noncommercial Organizations
|
|
32
|
+
|
|
33
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution doesn't count as use for a commercial purpose regardless of the source of funding or obligations resulting from the funding.
|
|
34
|
+
|
|
35
|
+
## Defense
|
|
36
|
+
|
|
37
|
+
Don't make any legal claim against anyone accusing this software, with or without changes, alone or with other technology, of infringing any patent.
|
|
38
|
+
|
|
39
|
+
## Copyright
|
|
40
|
+
|
|
41
|
+
The contributor licenses you to do everything with this software that would otherwise infringe their copyright in it.
|
|
42
|
+
|
|
43
|
+
## Patent
|
|
44
|
+
|
|
45
|
+
The contributor licenses you to do everything with this software that would otherwise infringe any patents they can license or become able to license.
|
|
46
|
+
|
|
47
|
+
## Reliability
|
|
48
|
+
|
|
49
|
+
The contributor can't revoke this license.
|
|
50
|
+
|
|
51
|
+
## Excuse
|
|
52
|
+
|
|
53
|
+
You're excused for unknowingly breaking [Notices](#notices) if you take all practical steps to comply within thirty days of learning you broke the rule.
|
|
54
|
+
|
|
55
|
+
## No Liability
|
|
56
|
+
|
|
57
|
+
***As far as the law allows, this software comes as is, without any warranty or condition, and the contributor won't be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CommandRefusalReason, EnqueueOptions, InstanceStatus } from '@kubun/plugin-workflow-api';
|
|
2
|
+
export type WorkflowCommandRefusalReason = CommandRefusalReason;
|
|
3
|
+
export type WorkflowCommandResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
status: InstanceStatus;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
reason: WorkflowCommandRefusalReason;
|
|
9
|
+
};
|
|
10
|
+
export type WorkflowDiscoverReply = {
|
|
11
|
+
senderDID: string;
|
|
12
|
+
instances: Array<InstanceStatus>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The narrow typed P2P control-plane API. Each method takes `groupID` as the
|
|
16
|
+
* PEER-SELECTION argument; the transport (multi-hub fan-out for discover, a
|
|
17
|
+
* directed `.to(targetDID)` request for the rest) and reply dedup (by
|
|
18
|
+
* authenticated `senderDID`) are the implementation's concern — no
|
|
19
|
+
* group-peer-manager internal is exposed here.
|
|
20
|
+
*
|
|
21
|
+
* The three OBSERVE methods return `InstanceStatus` shapes and REJECT on refusal:
|
|
22
|
+
* a non-observable instance is refused identically to a missing one, so a
|
|
23
|
+
* rejection is indistinguishable — the caller cannot confirm a hidden instance
|
|
24
|
+
* exists. The three COMMAND methods return the discriminated
|
|
25
|
+
* {@link WorkflowCommandResult} verbatim; a caller helper reconstitutes a
|
|
26
|
+
* refusal into a local throw.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Bounds a discover fan-out, mirroring `peer/query`: `quorum` resolves a gather
|
|
30
|
+
* as soon as that many distinct responders answer (set it to the known
|
|
31
|
+
* live-member count to return promptly rather than waiting out the window),
|
|
32
|
+
* `timeoutMs` caps the wait. Both optional; absent, the gather runs its default
|
|
33
|
+
* window. `quorum` is applied per hub-peer gather, not across the deduplicated
|
|
34
|
+
* multi-hub result, so with members split across hubs a hub may wait out its
|
|
35
|
+
* window even once the combined result already holds `quorum` distinct
|
|
36
|
+
* responders; the single-hub case (the common one) resolves exactly at quorum.
|
|
37
|
+
*/
|
|
38
|
+
export type WorkflowDiscoverOptions = {
|
|
39
|
+
quorum?: number;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
};
|
|
42
|
+
export type WorkflowControlPlaneAPI = {
|
|
43
|
+
/** Fan out `workflow/discover` across the group's hubs; one entry per distinct responder. */
|
|
44
|
+
discoverWorkflows(groupID: string, options?: WorkflowDiscoverOptions): Promise<Array<WorkflowDiscoverReply>>;
|
|
45
|
+
/** Directed `workflow/list` to one peer: its remotely-observable instances. */
|
|
46
|
+
listWorkflows(groupID: string, targetDID: string): Promise<Array<InstanceStatus>>;
|
|
47
|
+
/** Directed `workflow/status` to one peer; rejects when not observable or missing. */
|
|
48
|
+
workflowStatus(groupID: string, targetDID: string, instanceID: string): Promise<InstanceStatus>;
|
|
49
|
+
/** Directed `workflow/enqueue` to one peer; refusal returned as data. */
|
|
50
|
+
enqueueWorkflow(groupID: string, targetDID: string, name: string, params?: unknown, opts?: EnqueueOptions): Promise<WorkflowCommandResult>;
|
|
51
|
+
/** Directed `workflow/cancel` to one peer; refusal returned as data. */
|
|
52
|
+
cancelWorkflow(groupID: string, targetDID: string, instanceID: string): Promise<WorkflowCommandResult>;
|
|
53
|
+
/** Directed `workflow/retry` to one peer; refusal returned as data. */
|
|
54
|
+
retryWorkflow(groupID: string, targetDID: string, instanceID: string): Promise<WorkflowCommandResult>;
|
|
55
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Caller-facing contract for the p2p group workflow control plane: the typed
|
|
2
|
+
// methods a consumer reaches through `engine.getAPI('p2p')` to drive the six
|
|
3
|
+
// remote workflow ops (discover/list/status/enqueue/cancel/retry) by `groupID`.
|
|
4
|
+
// Types only — importing this creates no runtime edge on plugin-p2p, so a
|
|
5
|
+
// consumer (e.g. plugin-workflow's caller helpers) stays independently loadable.
|
|
6
|
+
// This is the `@kubun/plugin-workflow-api` pattern in reverse: plugin-p2p
|
|
7
|
+
// implements these, plugin-workflow imports them type-only.
|
|
8
|
+
export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubun/plugin-p2p-api",
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"keywords": [],
|
|
5
|
+
"license": "see LICENSE.md",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./lib/index.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"types": "lib/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"lib/*",
|
|
15
|
+
"LICENSE.md"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@kubun/plugin-workflow-api": "^0.16.0"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
25
|
+
"build:clean": "del lib",
|
|
26
|
+
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
27
|
+
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
28
|
+
"build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
|
|
29
|
+
"test": "pnpm run test:types",
|
|
30
|
+
"test:types": "tsc --noEmit --skipLibCheck"
|
|
31
|
+
}
|
|
32
|
+
}
|