@welshman/app 0.0.20 → 0.0.22
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/build/src/commands.cjs +4 -4
- package/build/src/commands.cjs.map +1 -1
- package/build/src/commands.mjs +4 -4
- package/build/src/commands.mjs.map +1 -1
- package/build/src/context.cjs +2 -0
- package/build/src/context.cjs.map +1 -1
- package/build/src/context.mjs +3 -1
- package/build/src/context.mjs.map +1 -1
- package/build/src/feeds.cjs +51 -49
- package/build/src/feeds.cjs.map +1 -1
- package/build/src/feeds.d.ts +5 -2
- package/build/src/feeds.mjs +47 -49
- package/build/src/feeds.mjs.map +1 -1
- package/build/src/relays.cjs +94 -22
- package/build/src/relays.cjs.map +1 -1
- package/build/src/relays.d.ts +19 -5
- package/build/src/relays.mjs +96 -24
- package/build/src/relays.mjs.map +1 -1
- package/build/src/router.cjs +136 -270
- package/build/src/router.cjs.map +1 -1
- package/build/src/router.d.ts +99 -111
- package/build/src/router.mjs +138 -269
- package/build/src/router.mjs.map +1 -1
- package/build/src/storage.cjs +1 -1
- package/build/src/storage.cjs.map +1 -1
- package/build/src/storage.mjs +2 -2
- package/build/src/storage.mjs.map +1 -1
- package/build/src/tags.cjs +2 -2
- package/build/src/tags.cjs.map +1 -1
- package/build/src/tags.mjs +2 -2
- package/build/src/tags.mjs.map +1 -1
- package/package.json +7 -7
package/build/src/router.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type { RelaysAndFilters } from '@welshman/net';
|
|
1
|
+
import type { TrustedEvent, Filter } from "@welshman/util";
|
|
2
|
+
import type { RelaysAndFilters } from "@welshman/net";
|
|
4
3
|
export declare const INDEXED_KINDS: number[];
|
|
5
4
|
export declare enum RelayMode {
|
|
6
5
|
Read = "read",
|
|
@@ -13,18 +12,6 @@ export type RouterOptions = {
|
|
|
13
12
|
* @returns The user's public key as a string, or null if not available.
|
|
14
13
|
*/
|
|
15
14
|
getUserPubkey?: () => string | null;
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves group relays for the specified community.
|
|
18
|
-
* @param address - The address to retrieve group relays for.
|
|
19
|
-
* @returns An array of group relay URLs as strings.
|
|
20
|
-
*/
|
|
21
|
-
getGroupRelays?: (address: string) => string[];
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves relays for the specified community.
|
|
24
|
-
* @param address - The address to retrieve community relays for.
|
|
25
|
-
* @returns An array of community relay URLs as strings.
|
|
26
|
-
*/
|
|
27
|
-
getCommunityRelays?: (address: string) => string[];
|
|
28
15
|
/**
|
|
29
16
|
* Retrieves relays for the specified public key and mode.
|
|
30
17
|
* @param pubkey - The public key to retrieve relays for.
|
|
@@ -53,11 +40,6 @@ export type RouterOptions = {
|
|
|
53
40
|
* @returns The quality of the relay as a number between 0 and 1 inclusive.
|
|
54
41
|
*/
|
|
55
42
|
getRelayQuality?: (url: string) => number;
|
|
56
|
-
/**
|
|
57
|
-
* Retrieves the redundancy setting, which is how many relays to use per selection value.
|
|
58
|
-
* @returns The redundancy setting as a number.
|
|
59
|
-
*/
|
|
60
|
-
getRedundancy?: () => number;
|
|
61
43
|
/**
|
|
62
44
|
* Retrieves the limit setting, which is the maximum number of relays that should be
|
|
63
45
|
* returned from getUrls and getSelections.
|
|
@@ -65,135 +47,141 @@ export type RouterOptions = {
|
|
|
65
47
|
*/
|
|
66
48
|
getLimit?: () => number;
|
|
67
49
|
};
|
|
68
|
-
export type
|
|
69
|
-
|
|
70
|
-
relay: string;
|
|
71
|
-
values: string[];
|
|
72
|
-
};
|
|
73
|
-
export type ValueRelays = {
|
|
74
|
-
value: string;
|
|
50
|
+
export type Selection = {
|
|
51
|
+
weight: number;
|
|
75
52
|
relays: string[];
|
|
76
53
|
};
|
|
77
54
|
export type FallbackPolicy = (count: number, limit: number) => number;
|
|
78
|
-
export declare const addNoFallbacks: (count: number,
|
|
79
|
-
export declare const addMinimalFallbacks: (count: number,
|
|
80
|
-
export declare const addMaximalFallbacks: (count: number,
|
|
55
|
+
export declare const addNoFallbacks: (count: number, limit: number) => number;
|
|
56
|
+
export declare const addMinimalFallbacks: (count: number, limit: number) => 0 | 1;
|
|
57
|
+
export declare const addMaximalFallbacks: (count: number, limit: number) => number;
|
|
81
58
|
export declare class Router {
|
|
82
59
|
readonly options: RouterOptions;
|
|
83
60
|
constructor(options: RouterOptions);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
getPubkeySelections: (pubkeys: string[], mode?: RelayMode) => {
|
|
89
|
-
value: string;
|
|
90
|
-
relays: string[];
|
|
91
|
-
}[];
|
|
92
|
-
getUserSelections: (mode?: RelayMode) => {
|
|
93
|
-
value: string;
|
|
94
|
-
relays: string[];
|
|
95
|
-
}[];
|
|
96
|
-
getContextSelections: (tags: Tags) => {
|
|
97
|
-
value: string;
|
|
98
|
-
relays: string[];
|
|
99
|
-
}[];
|
|
100
|
-
selection: (value: string, relays: Iterable<string>) => {
|
|
101
|
-
value: string;
|
|
102
|
-
relays: string[];
|
|
103
|
-
};
|
|
104
|
-
selections: (values: string[], relays: string[]) => {
|
|
105
|
-
value: string;
|
|
106
|
-
relays: string[];
|
|
107
|
-
}[];
|
|
108
|
-
forceValue: (value: string, selections: ValueRelays[]) => {
|
|
109
|
-
value: string;
|
|
110
|
-
relays: string[];
|
|
111
|
-
}[];
|
|
112
|
-
relaySelectionsFromMap: (valuesByRelay: ValuesByRelay) => {
|
|
113
|
-
relay: string;
|
|
114
|
-
values: string[];
|
|
115
|
-
}[];
|
|
116
|
-
scoreRelaySelection: ({ values, relay }: RelayValues) => number;
|
|
117
|
-
sortRelaySelections: (relaySelections: RelayValues[]) => RelayValues[];
|
|
118
|
-
scenario: (selections: ValueRelays[]) => RouterScenario;
|
|
61
|
+
getRelaysForPubkey: (pubkey: string, mode?: RelayMode) => string[];
|
|
62
|
+
getRelaysForPubkeys: (pubkeys: string[], mode?: RelayMode) => string[][];
|
|
63
|
+
getRelaysForUser: (mode?: RelayMode) => string[];
|
|
64
|
+
scenario: (selections: Selection[]) => RouterScenario;
|
|
119
65
|
merge: (scenarios: RouterScenario[]) => RouterScenario;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
66
|
+
FromRelays: (relays: string[]) => RouterScenario;
|
|
67
|
+
ForUser: () => RouterScenario;
|
|
68
|
+
FromUser: () => RouterScenario;
|
|
69
|
+
UserInbox: () => RouterScenario;
|
|
70
|
+
ForPubkey: (pubkey: string) => RouterScenario;
|
|
71
|
+
FromPubkey: (pubkey: string) => RouterScenario;
|
|
72
|
+
PubkeyInbox: (pubkey: string) => RouterScenario;
|
|
73
|
+
ForPubkeys: (pubkeys: string[]) => RouterScenario;
|
|
74
|
+
FromPubkeys: (pubkeys: string[]) => RouterScenario;
|
|
75
|
+
PubkeyInboxes: (pubkeys: string[]) => RouterScenario;
|
|
128
76
|
Event: (event: TrustedEvent) => RouterScenario;
|
|
129
|
-
|
|
77
|
+
Replies: (event: TrustedEvent) => RouterScenario;
|
|
78
|
+
Quote: (event: TrustedEvent, value: string, relays?: never[]) => RouterScenario;
|
|
130
79
|
EventAncestors: (event: TrustedEvent, type: "mentions" | "replies" | "roots") => RouterScenario;
|
|
131
80
|
EventMentions: (event: TrustedEvent) => RouterScenario;
|
|
132
81
|
EventParents: (event: TrustedEvent) => RouterScenario;
|
|
133
82
|
EventRoots: (event: TrustedEvent) => RouterScenario;
|
|
134
83
|
PublishEvent: (event: TrustedEvent) => RouterScenario;
|
|
135
|
-
FromPubkeys: (pubkeys: string[]) => RouterScenario;
|
|
136
|
-
ForPubkeys: (pubkeys: string[]) => RouterScenario;
|
|
137
|
-
WithinGroup: (address: string, relays?: string) => RouterScenario;
|
|
138
|
-
WithinCommunity: (address: string) => RouterScenario;
|
|
139
|
-
WithinContext: (address: string) => RouterScenario;
|
|
140
|
-
WithinMultipleContexts: (addresses: string[]) => RouterScenario;
|
|
141
|
-
Search: (term: string, relays?: string[]) => RouterScenario;
|
|
142
84
|
}
|
|
143
85
|
export type RouterScenarioOptions = {
|
|
144
|
-
redundancy?: number;
|
|
145
86
|
policy?: FallbackPolicy;
|
|
146
87
|
limit?: number;
|
|
147
88
|
};
|
|
148
89
|
export declare class RouterScenario {
|
|
149
90
|
readonly router: Router;
|
|
150
|
-
readonly selections:
|
|
91
|
+
readonly selections: Selection[];
|
|
151
92
|
readonly options: RouterScenarioOptions;
|
|
152
|
-
constructor(router: Router, selections:
|
|
93
|
+
constructor(router: Router, selections: Selection[], options?: RouterScenarioOptions);
|
|
153
94
|
clone: (options: RouterScenarioOptions) => RouterScenario;
|
|
154
|
-
filter: (f: (selection:
|
|
155
|
-
update: (f: (selection:
|
|
156
|
-
redundancy: (redundancy: number) => RouterScenario;
|
|
95
|
+
filter: (f: (selection: Selection) => boolean) => RouterScenario;
|
|
96
|
+
update: (f: (selection: Selection) => Selection) => RouterScenario;
|
|
157
97
|
policy: (policy: FallbackPolicy) => RouterScenario;
|
|
158
98
|
limit: (limit: number) => RouterScenario;
|
|
159
|
-
|
|
160
|
-
getPolicy: () => (count: number,
|
|
99
|
+
weight: (scale: number) => RouterScenario;
|
|
100
|
+
getPolicy: () => (count: number, limit: number) => number;
|
|
161
101
|
getLimit: () => number;
|
|
162
|
-
getSelections: () => {
|
|
163
|
-
relay: string;
|
|
164
|
-
values: string[];
|
|
165
|
-
}[];
|
|
166
102
|
getUrls: () => string[];
|
|
167
103
|
getUrl: () => string;
|
|
168
104
|
}
|
|
169
|
-
export declare const getRelayQuality: (url: string) =>
|
|
105
|
+
export declare const getRelayQuality: (url: string) => 0 | 1;
|
|
170
106
|
export declare const getPubkeyRelays: (pubkey: string, mode?: string) => string[];
|
|
171
107
|
export declare const getIndexerRelays: () => string[];
|
|
172
108
|
export declare const getFallbackRelays: () => string[];
|
|
173
109
|
export declare const getSearchRelays: () => string[];
|
|
174
110
|
export declare const makeRouter: (options?: Partial<RouterOptions>) => Router;
|
|
175
|
-
|
|
176
|
-
id: string;
|
|
111
|
+
type FilterScenario = {
|
|
177
112
|
filter: Filter;
|
|
178
113
|
scenario: RouterScenario;
|
|
179
114
|
};
|
|
180
|
-
type
|
|
115
|
+
type FilterSelectionRule = (filter: Filter) => FilterScenario[];
|
|
116
|
+
export declare const getFilterSelectionsForSearch: (filter: Filter) => {
|
|
181
117
|
filter: Filter;
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
118
|
+
scenario: RouterScenario;
|
|
119
|
+
}[];
|
|
120
|
+
export declare const getFilterSelectionsForWraps: (filter: Filter) => {
|
|
121
|
+
filter: {
|
|
122
|
+
kinds: number[];
|
|
123
|
+
ids?: string[] | undefined;
|
|
124
|
+
authors?: string[] | undefined;
|
|
125
|
+
since?: number | undefined;
|
|
126
|
+
until?: number | undefined;
|
|
127
|
+
limit?: number | undefined;
|
|
128
|
+
search?: string | undefined;
|
|
129
|
+
};
|
|
130
|
+
scenario: RouterScenario;
|
|
131
|
+
}[];
|
|
132
|
+
export declare const getFilterSelectionsForIndexedKinds: (filter: Filter) => {
|
|
133
|
+
filter: {
|
|
134
|
+
kinds: number[];
|
|
135
|
+
ids?: string[] | undefined;
|
|
136
|
+
authors?: string[] | undefined;
|
|
137
|
+
since?: number | undefined;
|
|
138
|
+
until?: number | undefined;
|
|
139
|
+
limit?: number | undefined;
|
|
140
|
+
search?: string | undefined;
|
|
141
|
+
};
|
|
142
|
+
scenario: RouterScenario;
|
|
143
|
+
}[];
|
|
144
|
+
export declare const getFilterSelectionsForAuthors: (filter: Filter) => {
|
|
145
|
+
filter: {
|
|
146
|
+
authors: string[];
|
|
147
|
+
ids?: string[] | undefined;
|
|
148
|
+
kinds?: number[] | undefined;
|
|
149
|
+
since?: number | undefined;
|
|
150
|
+
until?: number | undefined;
|
|
151
|
+
limit?: number | undefined;
|
|
152
|
+
search?: string | undefined;
|
|
153
|
+
};
|
|
154
|
+
scenario: RouterScenario;
|
|
155
|
+
}[];
|
|
156
|
+
export declare const getFilterSelectionsForUser: (filter: Filter) => {
|
|
187
157
|
filter: Filter;
|
|
188
158
|
scenario: RouterScenario;
|
|
189
|
-
};
|
|
190
|
-
export declare const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
159
|
+
}[];
|
|
160
|
+
export declare const defaultFilterSelectionRules: (((filter: Filter) => {
|
|
161
|
+
filter: Filter;
|
|
162
|
+
scenario: RouterScenario;
|
|
163
|
+
}[]) | ((filter: Filter) => {
|
|
164
|
+
filter: {
|
|
165
|
+
kinds: number[];
|
|
166
|
+
ids?: string[] | undefined;
|
|
167
|
+
authors?: string[] | undefined;
|
|
168
|
+
since?: number | undefined;
|
|
169
|
+
until?: number | undefined;
|
|
170
|
+
limit?: number | undefined;
|
|
171
|
+
search?: string | undefined;
|
|
172
|
+
};
|
|
173
|
+
scenario: RouterScenario;
|
|
174
|
+
}[]) | ((filter: Filter) => {
|
|
175
|
+
filter: {
|
|
176
|
+
authors: string[];
|
|
177
|
+
ids?: string[] | undefined;
|
|
178
|
+
kinds?: number[] | undefined;
|
|
179
|
+
since?: number | undefined;
|
|
180
|
+
until?: number | undefined;
|
|
181
|
+
limit?: number | undefined;
|
|
182
|
+
search?: string | undefined;
|
|
183
|
+
};
|
|
184
|
+
scenario: RouterScenario;
|
|
185
|
+
}[]))[];
|
|
198
186
|
export declare const getFilterSelections: (filters: Filter[], rules?: FilterSelectionRule[]) => RelaysAndFilters[];
|
|
199
187
|
export {};
|