pubky-app-specs 0.4.4 → 0.5.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 +21 -0
- package/README.md +166 -321
- package/package.json +11 -52
- package/pubky_app_specs.d.ts +448 -361
- package/{index.cjs → pubky_app_specs.js} +1840 -1902
- package/pubky_app_specs_bg.wasm +0 -0
- package/example.js +0 -295
- package/index.js +0 -3002
- package/validationLimits.cjs +0 -9
- package/validationLimits.js +0 -5
- package/validationLimits.json +0 -35
package/pubky_app_specs.d.ts
CHANGED
|
@@ -1,196 +1,71 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builds an User URI of the form "pubky://<user_pubky_id>/pub/pubky.app/profile.json"
|
|
6
|
-
*/
|
|
7
|
-
export function userUriBuilder(user_id: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Builds a Post URI of the form "pubky://<author_id>/pub/pubky.app/posts/<post_id>"
|
|
10
|
-
*/
|
|
11
|
-
export function postUriBuilder(author_id: string, post_id: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Builds a Follow URI of the form "pubky://<author_id>/pub/pubky.app/follows/<follow_id>"
|
|
14
|
-
*/
|
|
15
|
-
export function followUriBuilder(author_id: string, follow_id: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Builds a Mute URI of the form "pubky://<author_id>/pub/pubky.app/mutes/<mute_id>"
|
|
18
|
-
*/
|
|
19
|
-
export function muteUriBuilder(author_id: string, mute_id: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Builds a Bookmark URI of the form "pubky://<author_id>/pub/pubky.app/bookmarks/<bookmark_id>"
|
|
22
|
-
*/
|
|
23
|
-
export function bookmarkUriBuilder(author_id: string, bookmark_id: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Builds a Tag URI of the form "pubky://<author_id>/pub/pubky.app/tags/<tag_id>"
|
|
26
|
-
*/
|
|
27
|
-
export function tagUriBuilder(author_id: string, tag_id: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Builds a File URI of the form "pubky://<author_id>/pub/pubky.app/files/<file_id>"
|
|
30
|
-
*/
|
|
31
|
-
export function fileUriBuilder(author_id: string, file_id: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Builds a Blob URI of the form "pubky://<author_id>/pub/pubky.app/blobs/<blob_id>"
|
|
34
|
-
*/
|
|
35
|
-
export function blobUriBuilder(author_id: string, blob_id: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Builds a Feed URI of the form "pubky://<author_id>/pub/pubky.app/feeds/<feed_id>"
|
|
38
|
-
*/
|
|
39
|
-
export function feedUriBuilder(author_id: string, feed_id: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Builds a LastRead URI of the form "pubky://<author_id>/pub/pubky.app/last_read"
|
|
42
|
-
*/
|
|
43
|
-
export function lastReadUriBuilder(author_id: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Each FFI function:
|
|
46
|
-
* - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
|
|
47
|
-
* - Creates the Rust model, sanitizes, and validates it.
|
|
48
|
-
* - Generates the ID (if applicable).
|
|
49
|
-
* - Generates the path (if applicable).
|
|
50
|
-
* - Returns { json, id, path, url } or a descriptive error.
|
|
51
|
-
* Returns validation limits as a JSON value for client-side use without a builder.
|
|
52
|
-
*/
|
|
53
|
-
export function getValidationLimits(): any;
|
|
54
|
-
/**
|
|
55
|
-
* Returns the list of valid MIME types for file attachments.
|
|
56
|
-
*
|
|
57
|
-
* This allows JavaScript consumers to validate file types before submission
|
|
58
|
-
* without having to duplicate the list.
|
|
59
|
-
*
|
|
60
|
-
* # Example (TypeScript)
|
|
61
|
-
*
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { get_valid_mime_types } from "pubky-app-specs";
|
|
64
|
-
*
|
|
65
|
-
* const validTypes = get_valid_mime_types();
|
|
66
|
-
* const fileType = "image/png";
|
|
67
|
-
* if (validTypes.includes(fileType)) {
|
|
68
|
-
* console.log("Valid file type!");
|
|
69
|
-
* }
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export function getValidMimeTypes(): any[];
|
|
73
|
-
/**
|
|
74
|
-
* Parses a Pubky URI and returns a strongly typed `ParsedUriResult`.
|
|
75
|
-
*
|
|
76
|
-
* This function wraps the internal ParsedUri ust parsing logic. It converts the result into a
|
|
77
|
-
* strongly typed object that is easier to use in TypeScript.
|
|
78
|
-
*
|
|
79
|
-
* # Parameters
|
|
80
|
-
*
|
|
81
|
-
* - `uri`: A string slice representing the Pubky URI. The URI should follow the format:
|
|
82
|
-
* `pubky://<user_id>/pub/pubky.app/<resource>[/<id>]`.
|
|
83
|
-
*
|
|
84
|
-
* # Returns
|
|
85
|
-
*
|
|
86
|
-
* On success, returns a `ParsedUriResult` with:
|
|
87
|
-
* - `user_id`: the parsed user ID,
|
|
88
|
-
* - `resource`: a string (derived from the Display implementation of internal `Resource` enum),
|
|
89
|
-
* - `resource_id`: an optional resource identifier (if applicable).
|
|
90
|
-
*
|
|
91
|
-
* On failure, returns a JavaScript error (`String`) containing an error message.
|
|
92
|
-
*
|
|
93
|
-
* # Example (TypeScript)
|
|
94
|
-
*
|
|
95
|
-
* ```typescript
|
|
96
|
-
* import { parse_uri } from "pubky-app-specs";
|
|
97
|
-
*
|
|
98
|
-
* try {
|
|
99
|
-
* const result = parse_uri("pubky://user123/pub/pubky.app/posts/abc123");
|
|
100
|
-
* console.log(result.user_id); // e.g. "user123"
|
|
101
|
-
* console.log(result.resource); // e.g. "posts"
|
|
102
|
-
* console.log(result.resource_id); // e.g. "abc123" or null
|
|
103
|
-
* } catch (error) {
|
|
104
|
-
* console.error("Error parsing URI:", error);
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export function parse_uri(uri: string): ParsedUriResult;
|
|
109
|
-
/**
|
|
110
|
-
* Enum representing the layout of the feed.
|
|
111
|
-
*/
|
|
112
|
-
export enum PubkyAppFeedLayout {
|
|
113
|
-
Columns = 0,
|
|
114
|
-
Wide = 1,
|
|
115
|
-
Visual = 2,
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Enum representing the reach of the feed.
|
|
119
|
-
*/
|
|
120
|
-
export enum PubkyAppFeedReach {
|
|
121
|
-
Following = 0,
|
|
122
|
-
Followers = 1,
|
|
123
|
-
Friends = 2,
|
|
124
|
-
All = 3,
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Enum representing the sort order of the feed.
|
|
128
|
-
*/
|
|
129
|
-
export enum PubkyAppFeedSort {
|
|
130
|
-
Recent = 0,
|
|
131
|
-
Popularity = 1,
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Represents the type of pubky-app posted data
|
|
135
|
-
* Used primarily to best display the content in UI
|
|
136
|
-
*/
|
|
137
|
-
export enum PubkyAppPostKind {
|
|
138
|
-
Short = 0,
|
|
139
|
-
Long = 1,
|
|
140
|
-
Image = 2,
|
|
141
|
-
Video = 3,
|
|
142
|
-
Link = 4,
|
|
143
|
-
File = 5,
|
|
144
|
-
}
|
|
3
|
+
|
|
145
4
|
export class BlobResult {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
readonly blob: PubkyAppBlob;
|
|
9
|
+
readonly meta: Meta;
|
|
150
10
|
}
|
|
11
|
+
|
|
151
12
|
export class BookmarkResult {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
13
|
+
private constructor();
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
readonly bookmark: PubkyAppBookmark;
|
|
17
|
+
readonly meta: Meta;
|
|
156
18
|
}
|
|
19
|
+
|
|
157
20
|
export class FeedResult {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
readonly feed: PubkyAppFeed;
|
|
25
|
+
readonly meta: Meta;
|
|
162
26
|
}
|
|
27
|
+
|
|
163
28
|
export class FileResult {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
29
|
+
private constructor();
|
|
30
|
+
free(): void;
|
|
31
|
+
[Symbol.dispose](): void;
|
|
32
|
+
readonly file: PubkyAppFile;
|
|
33
|
+
readonly meta: Meta;
|
|
168
34
|
}
|
|
35
|
+
|
|
169
36
|
export class FollowResult {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
37
|
+
private constructor();
|
|
38
|
+
free(): void;
|
|
39
|
+
[Symbol.dispose](): void;
|
|
40
|
+
readonly follow: PubkyAppFollow;
|
|
41
|
+
readonly meta: Meta;
|
|
174
42
|
}
|
|
43
|
+
|
|
175
44
|
export class LastReadResult {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
45
|
+
private constructor();
|
|
46
|
+
free(): void;
|
|
47
|
+
[Symbol.dispose](): void;
|
|
48
|
+
readonly last_read: PubkyAppLastRead;
|
|
49
|
+
readonly meta: Meta;
|
|
180
50
|
}
|
|
51
|
+
|
|
181
52
|
export class Meta {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
53
|
+
private constructor();
|
|
54
|
+
free(): void;
|
|
55
|
+
[Symbol.dispose](): void;
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly path: string;
|
|
58
|
+
readonly url: string;
|
|
187
59
|
}
|
|
60
|
+
|
|
188
61
|
export class MuteResult {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
62
|
+
private constructor();
|
|
63
|
+
free(): void;
|
|
64
|
+
[Symbol.dispose](): void;
|
|
65
|
+
readonly meta: Meta;
|
|
66
|
+
readonly mute: PubkyAppMute;
|
|
193
67
|
}
|
|
68
|
+
|
|
194
69
|
/**
|
|
195
70
|
* This object represents the result of parsing a Pubky URI. It contains:
|
|
196
71
|
* - `user_id`: the parsed user ID as a string.
|
|
@@ -198,41 +73,47 @@ export class MuteResult {
|
|
|
198
73
|
* - `resource_id`: an optional resource identifier (if applicable).
|
|
199
74
|
*/
|
|
200
75
|
export class ParsedUriResult {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
76
|
+
private constructor();
|
|
77
|
+
free(): void;
|
|
78
|
+
[Symbol.dispose](): void;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the resource kind.
|
|
81
|
+
*/
|
|
82
|
+
readonly resource: string;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the resource ID if present.
|
|
85
|
+
*/
|
|
86
|
+
readonly resource_id: string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the user ID.
|
|
89
|
+
*/
|
|
90
|
+
readonly user_id: string;
|
|
215
91
|
}
|
|
92
|
+
|
|
216
93
|
export class PostResult {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
94
|
+
private constructor();
|
|
95
|
+
free(): void;
|
|
96
|
+
[Symbol.dispose](): void;
|
|
97
|
+
readonly meta: Meta;
|
|
98
|
+
readonly post: PubkyAppPost;
|
|
221
99
|
}
|
|
100
|
+
|
|
222
101
|
/**
|
|
223
102
|
* Represents a blob, which backs a file uploaded by the user.
|
|
224
103
|
* URI: /pub/pubky.app/blobs/:blob_id
|
|
225
104
|
*/
|
|
226
105
|
export class PubkyAppBlob {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
106
|
+
private constructor();
|
|
107
|
+
free(): void;
|
|
108
|
+
[Symbol.dispose](): void;
|
|
109
|
+
static fromJson(js_value: any): PubkyAppBlob;
|
|
110
|
+
toJson(): any;
|
|
111
|
+
/**
|
|
112
|
+
* Getter for the blob data as a `Uint8Array`.
|
|
113
|
+
*/
|
|
114
|
+
readonly data: Uint8Array;
|
|
235
115
|
}
|
|
116
|
+
|
|
236
117
|
/**
|
|
237
118
|
* Represents raw homeserver bookmark with id
|
|
238
119
|
* URI: /pub/pubky.app/bookmarks/:bookmark_id
|
|
@@ -244,84 +125,119 @@ export class PubkyAppBlob {
|
|
|
244
125
|
* Where bookmark_id is Crockford-base32(Blake3("{uri_bookmarked}"")[:half])
|
|
245
126
|
*/
|
|
246
127
|
export class PubkyAppBookmark {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
128
|
+
private constructor();
|
|
129
|
+
free(): void;
|
|
130
|
+
[Symbol.dispose](): void;
|
|
131
|
+
/**
|
|
132
|
+
* Serialize to JSON for WASM.
|
|
133
|
+
*/
|
|
134
|
+
static fromJson(js_value: any): PubkyAppBookmark;
|
|
135
|
+
toJson(): any;
|
|
136
|
+
created_at: bigint;
|
|
137
|
+
/**
|
|
138
|
+
* Getter for `uri`.
|
|
139
|
+
*/
|
|
140
|
+
readonly uri: string;
|
|
259
141
|
}
|
|
142
|
+
|
|
260
143
|
/**
|
|
261
144
|
* Represents a feed configuration.
|
|
262
145
|
*/
|
|
263
146
|
export class PubkyAppFeed {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
147
|
+
private constructor();
|
|
148
|
+
free(): void;
|
|
149
|
+
[Symbol.dispose](): void;
|
|
150
|
+
/**
|
|
151
|
+
* Serialize to JSON for WASM.
|
|
152
|
+
*/
|
|
153
|
+
static fromJson(js_value: any): PubkyAppFeed;
|
|
154
|
+
toJson(): any;
|
|
155
|
+
created_at: bigint;
|
|
156
|
+
/**
|
|
157
|
+
* Getter for `feed`.
|
|
158
|
+
*/
|
|
159
|
+
readonly feed: PubkyAppFeedConfig;
|
|
160
|
+
/**
|
|
161
|
+
* Getter for `name`.
|
|
162
|
+
*/
|
|
163
|
+
readonly name: string;
|
|
280
164
|
}
|
|
165
|
+
|
|
281
166
|
/**
|
|
282
167
|
* Configuration object for the feed.
|
|
283
168
|
*/
|
|
284
169
|
export class PubkyAppFeedConfig {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
170
|
+
private constructor();
|
|
171
|
+
free(): void;
|
|
172
|
+
[Symbol.dispose](): void;
|
|
173
|
+
static fromJson(js_value: any): PubkyAppFeedConfig;
|
|
174
|
+
toJson(): any;
|
|
175
|
+
/**
|
|
176
|
+
* Getter for `content`.
|
|
177
|
+
*/
|
|
178
|
+
readonly content: PubkyAppPostKind | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Getter for `layout`.
|
|
181
|
+
*/
|
|
182
|
+
readonly layout: PubkyAppFeedLayout;
|
|
183
|
+
/**
|
|
184
|
+
* Getter for `name`.
|
|
185
|
+
*/
|
|
186
|
+
readonly reach: PubkyAppFeedReach;
|
|
187
|
+
/**
|
|
188
|
+
* Getter for `sort`.
|
|
189
|
+
*/
|
|
190
|
+
readonly sort: PubkyAppFeedSort;
|
|
191
|
+
/**
|
|
192
|
+
* Getter for `tags`.
|
|
193
|
+
*/
|
|
194
|
+
readonly tags: string[] | undefined;
|
|
309
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Enum representing the layout of the feed.
|
|
199
|
+
*/
|
|
200
|
+
export enum PubkyAppFeedLayout {
|
|
201
|
+
Columns = 0,
|
|
202
|
+
Wide = 1,
|
|
203
|
+
Visual = 2,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Enum representing the reach of the feed.
|
|
208
|
+
*/
|
|
209
|
+
export enum PubkyAppFeedReach {
|
|
210
|
+
Following = 0,
|
|
211
|
+
Followers = 1,
|
|
212
|
+
Friends = 2,
|
|
213
|
+
All = 3,
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Enum representing the sort order of the feed.
|
|
218
|
+
*/
|
|
219
|
+
export enum PubkyAppFeedSort {
|
|
220
|
+
Recent = 0,
|
|
221
|
+
Popularity = 1,
|
|
222
|
+
}
|
|
223
|
+
|
|
310
224
|
/**
|
|
311
225
|
* Represents a file uploaded by the user.
|
|
312
226
|
* URI: /pub/pubky.app/files/:file_id
|
|
313
227
|
*/
|
|
314
228
|
export class PubkyAppFile {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
229
|
+
private constructor();
|
|
230
|
+
free(): void;
|
|
231
|
+
[Symbol.dispose](): void;
|
|
232
|
+
static fromJson(js_value: any): PubkyAppFile;
|
|
233
|
+
toJson(): any;
|
|
234
|
+
created_at: bigint;
|
|
235
|
+
size: number;
|
|
236
|
+
readonly content_type: string;
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly src: string;
|
|
324
239
|
}
|
|
240
|
+
|
|
325
241
|
/**
|
|
326
242
|
* Represents raw homeserver follow object with timestamp
|
|
327
243
|
*
|
|
@@ -334,23 +250,27 @@ export class PubkyAppFile {
|
|
|
334
250
|
* `/pub/pubky.app/follows/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy`
|
|
335
251
|
*/
|
|
336
252
|
export class PubkyAppFollow {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
253
|
+
private constructor();
|
|
254
|
+
free(): void;
|
|
255
|
+
[Symbol.dispose](): void;
|
|
256
|
+
static fromJson(js_value: any): PubkyAppFollow;
|
|
257
|
+
toJson(): any;
|
|
258
|
+
created_at: bigint;
|
|
342
259
|
}
|
|
260
|
+
|
|
343
261
|
/**
|
|
344
262
|
* Represents the last read timestamp for notifications.
|
|
345
263
|
* URI: /pub/pubky.app/last_read
|
|
346
264
|
*/
|
|
347
265
|
export class PubkyAppLastRead {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
266
|
+
private constructor();
|
|
267
|
+
free(): void;
|
|
268
|
+
[Symbol.dispose](): void;
|
|
269
|
+
static fromJson(js_value: any): PubkyAppLastRead;
|
|
270
|
+
toJson(): any;
|
|
271
|
+
timestamp: bigint;
|
|
353
272
|
}
|
|
273
|
+
|
|
354
274
|
/**
|
|
355
275
|
* Represents raw homeserver Mute object with timestamp
|
|
356
276
|
* URI: /pub/pubky.app/mutes/:user_id
|
|
@@ -360,12 +280,14 @@ export class PubkyAppLastRead {
|
|
|
360
280
|
* `/pub/pubky.app/mutes/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy`
|
|
361
281
|
*/
|
|
362
282
|
export class PubkyAppMute {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
283
|
+
private constructor();
|
|
284
|
+
free(): void;
|
|
285
|
+
[Symbol.dispose](): void;
|
|
286
|
+
static fromJson(js_value: any): PubkyAppMute;
|
|
287
|
+
toJson(): any;
|
|
288
|
+
created_at: bigint;
|
|
368
289
|
}
|
|
290
|
+
|
|
369
291
|
/**
|
|
370
292
|
* Represents raw post in homeserver with content and kind
|
|
371
293
|
* URI: /pub/pubky.app/posts/:post_id
|
|
@@ -376,28 +298,47 @@ export class PubkyAppMute {
|
|
|
376
298
|
* `/pub/pubky.app/posts/00321FCW75ZFY`
|
|
377
299
|
*/
|
|
378
300
|
export class PubkyAppPost {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
301
|
+
free(): void;
|
|
302
|
+
[Symbol.dispose](): void;
|
|
303
|
+
static fromJson(js_value: any): PubkyAppPost;
|
|
304
|
+
/**
|
|
305
|
+
* Creates a new `PubkyAppPost` instance and sanitizes it.
|
|
306
|
+
*/
|
|
307
|
+
constructor(content: string, kind: PubkyAppPostKind, parent?: string | null, embed?: PubkyAppPostEmbed | null, attachments?: string[] | null);
|
|
308
|
+
toJson(): any;
|
|
309
|
+
readonly attachments: string[] | undefined;
|
|
310
|
+
readonly content: string;
|
|
311
|
+
readonly embed: PubkyAppPostEmbed | undefined;
|
|
312
|
+
readonly kind: string;
|
|
313
|
+
readonly parent: string | undefined;
|
|
391
314
|
}
|
|
315
|
+
|
|
392
316
|
/**
|
|
393
317
|
* Represents embedded content within a post
|
|
394
318
|
*/
|
|
395
319
|
export class PubkyAppPostEmbed {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
320
|
+
free(): void;
|
|
321
|
+
[Symbol.dispose](): void;
|
|
322
|
+
constructor(uri: string, kind: PubkyAppPostKind);
|
|
323
|
+
readonly kind: string;
|
|
324
|
+
readonly uri: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Represents the type of pubky-app posted data
|
|
329
|
+
* Used primarily to best display the content in UI
|
|
330
|
+
*/
|
|
331
|
+
export enum PubkyAppPostKind {
|
|
332
|
+
Short = 0,
|
|
333
|
+
Long = 1,
|
|
334
|
+
Image = 2,
|
|
335
|
+
Video = 3,
|
|
336
|
+
Link = 4,
|
|
337
|
+
File = 5,
|
|
338
|
+
Collection = 6,
|
|
339
|
+
Unknown = 7,
|
|
400
340
|
}
|
|
341
|
+
|
|
401
342
|
/**
|
|
402
343
|
* Represents raw homeserver tag with id
|
|
403
344
|
* URI: /pub/pubky.app/tags/:tag_id
|
|
@@ -409,96 +350,242 @@ export class PubkyAppPostEmbed {
|
|
|
409
350
|
* Where tag_id is Crockford-base32(Blake3("{uri_tagged}:{label}")[:half])
|
|
410
351
|
*/
|
|
411
352
|
export class PubkyAppTag {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
353
|
+
private constructor();
|
|
354
|
+
free(): void;
|
|
355
|
+
[Symbol.dispose](): void;
|
|
356
|
+
static fromJson(js_value: any): PubkyAppTag;
|
|
357
|
+
/**
|
|
358
|
+
* Serialize to JSON for WASM.
|
|
359
|
+
*/
|
|
360
|
+
toJson(): any;
|
|
361
|
+
created_at: bigint;
|
|
362
|
+
/**
|
|
363
|
+
* Getter for `label`.
|
|
364
|
+
*/
|
|
365
|
+
readonly label: string;
|
|
366
|
+
/**
|
|
367
|
+
* Getter for `uri`.
|
|
368
|
+
*/
|
|
369
|
+
readonly uri: string;
|
|
428
370
|
}
|
|
371
|
+
|
|
429
372
|
/**
|
|
430
373
|
* URI: /pub/pubky.app/profile.json
|
|
431
374
|
*/
|
|
432
375
|
export class PubkyAppUser {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
376
|
+
free(): void;
|
|
377
|
+
[Symbol.dispose](): void;
|
|
378
|
+
static fromJson(js_value: any): PubkyAppUser;
|
|
379
|
+
/**
|
|
380
|
+
* Creates a new `PubkyAppUser` instance and sanitizes it.
|
|
381
|
+
*/
|
|
382
|
+
constructor(name: string, bio?: string | null, image?: string | null, links?: PubkyAppUserLink[] | null, status?: string | null);
|
|
383
|
+
toJson(): any;
|
|
384
|
+
readonly bio: string | undefined;
|
|
385
|
+
readonly image: string | undefined;
|
|
386
|
+
readonly links: PubkyAppUserLink[] | undefined;
|
|
387
|
+
readonly name: string;
|
|
388
|
+
readonly status: string | undefined;
|
|
445
389
|
}
|
|
390
|
+
|
|
446
391
|
/**
|
|
447
392
|
* Represents a user's single link with a title and URL.
|
|
448
393
|
*/
|
|
449
394
|
export class PubkyAppUserLink {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
395
|
+
free(): void;
|
|
396
|
+
[Symbol.dispose](): void;
|
|
397
|
+
/**
|
|
398
|
+
* Creates a new `PubkyAppUserLink` instance and sanitizes it.
|
|
399
|
+
*/
|
|
400
|
+
constructor(title: string, url: string);
|
|
401
|
+
readonly title: string;
|
|
402
|
+
readonly url: string;
|
|
457
403
|
}
|
|
404
|
+
|
|
458
405
|
/**
|
|
459
406
|
* Represents user data with name, bio, image, links, and status.
|
|
460
407
|
*/
|
|
461
408
|
export class PubkyId {
|
|
462
|
-
|
|
463
|
-
|
|
409
|
+
private constructor();
|
|
410
|
+
free(): void;
|
|
411
|
+
[Symbol.dispose](): void;
|
|
464
412
|
}
|
|
413
|
+
|
|
465
414
|
/**
|
|
466
415
|
* Represents a user's single link with a title and URL.
|
|
467
416
|
*/
|
|
468
417
|
export class PubkySpecsBuilder {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
418
|
+
free(): void;
|
|
419
|
+
[Symbol.dispose](): void;
|
|
420
|
+
createBlob(blob_data: any): BlobResult;
|
|
421
|
+
createBookmark(uri: string): BookmarkResult;
|
|
422
|
+
/**
|
|
423
|
+
* Creates a `kind = Collection` post — a curated list of URIs under
|
|
424
|
+
* a name and optional description.
|
|
425
|
+
*
|
|
426
|
+
* Convenience wrapper around `createPost` that builds the
|
|
427
|
+
* `PubkyAppCollectionContent` envelope (`{ name, description, items }`) and
|
|
428
|
+
* JSON-serializes it into `content` internally, so JS callers don't
|
|
429
|
+
* have to stringify the envelope themselves.
|
|
430
|
+
*
|
|
431
|
+
* `parent` and `embed` are not supported for Collection posts — the
|
|
432
|
+
* validator rejects them — so this helper omits those arguments.
|
|
433
|
+
*/
|
|
434
|
+
createCollectionPost(name: string, description?: string | null, items?: string[] | null): PostResult;
|
|
435
|
+
createFeed(tags: any, reach: string, layout: string, sort: string, content: string | null | undefined, name: string): FeedResult;
|
|
436
|
+
createFile(name: string, src: string, content_type: string, size: number): FileResult;
|
|
437
|
+
createFollow(followee_id: string): FollowResult;
|
|
438
|
+
createLastRead(): LastReadResult;
|
|
439
|
+
createMute(mutee_id: string): MuteResult;
|
|
440
|
+
createPost(content: string, kind: PubkyAppPostKind, parent?: string | null, embed?: PubkyAppPostEmbed | null, attachments?: string[] | null): PostResult;
|
|
441
|
+
createTag(uri: string, label: string): TagResult;
|
|
442
|
+
createUser(name: string, bio: string | null | undefined, image: string | null | undefined, links: any, status?: string | null): UserResult;
|
|
443
|
+
/**
|
|
444
|
+
* Edits an existing post by updating its content while preserving its original ID and timestamp.
|
|
445
|
+
*/
|
|
446
|
+
editPost(original_post: PubkyAppPost, post_id: string, new_content: string): PostResult;
|
|
447
|
+
/**
|
|
448
|
+
* Creates a new `PubkyAppBuilder` instance.
|
|
449
|
+
*/
|
|
450
|
+
constructor(pubky_id: string);
|
|
451
|
+
/**
|
|
452
|
+
* Returns validation limits as a JSON value for client-side use.
|
|
453
|
+
*/
|
|
454
|
+
readonly validationLimits: any;
|
|
492
455
|
}
|
|
456
|
+
|
|
493
457
|
export class TagResult {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
458
|
+
private constructor();
|
|
459
|
+
free(): void;
|
|
460
|
+
[Symbol.dispose](): void;
|
|
461
|
+
readonly meta: Meta;
|
|
462
|
+
readonly tag: PubkyAppTag;
|
|
498
463
|
}
|
|
464
|
+
|
|
499
465
|
export class UserResult {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
466
|
+
private constructor();
|
|
467
|
+
free(): void;
|
|
468
|
+
[Symbol.dispose](): void;
|
|
469
|
+
readonly meta: Meta;
|
|
470
|
+
readonly user: PubkyAppUser;
|
|
504
471
|
}
|
|
472
|
+
|
|
473
|
+
export function baseUriBuilder(user_id: string): string;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Builds a Blob URI of the form "pubky://<author_id>/pub/pubky.app/blobs/<blob_id>"
|
|
477
|
+
*/
|
|
478
|
+
export function blobUriBuilder(author_id: string, blob_id: string): string;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Builds a Bookmark URI of the form "pubky://<author_id>/pub/pubky.app/bookmarks/<bookmark_id>"
|
|
482
|
+
*/
|
|
483
|
+
export function bookmarkUriBuilder(author_id: string, bookmark_id: string): string;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Builds a Feed URI of the form "pubky://<author_id>/pub/pubky.app/feeds/<feed_id>"
|
|
487
|
+
*/
|
|
488
|
+
export function feedUriBuilder(author_id: string, feed_id: string): string;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Builds a File URI of the form "pubky://<author_id>/pub/pubky.app/files/<file_id>"
|
|
492
|
+
*/
|
|
493
|
+
export function fileUriBuilder(author_id: string, file_id: string): string;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Builds a Follow URI of the form "pubky://<author_id>/pub/pubky.app/follows/<follow_id>"
|
|
497
|
+
*/
|
|
498
|
+
export function followUriBuilder(author_id: string, follow_id: string): string;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Returns the list of valid MIME types for file attachments.
|
|
502
|
+
*
|
|
503
|
+
* This allows JavaScript consumers to validate file types before submission
|
|
504
|
+
* without having to duplicate the list.
|
|
505
|
+
*
|
|
506
|
+
* # Example (TypeScript)
|
|
507
|
+
*
|
|
508
|
+
* ```typescript
|
|
509
|
+
* import { get_valid_mime_types } from "pubky-app-specs";
|
|
510
|
+
*
|
|
511
|
+
* const validTypes = get_valid_mime_types();
|
|
512
|
+
* const fileType = "image/png";
|
|
513
|
+
* if (validTypes.includes(fileType)) {
|
|
514
|
+
* console.log("Valid file type!");
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
export function getValidMimeTypes(): any[];
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Each FFI function:
|
|
522
|
+
* - Accepts minimal fields in a JavaScript-friendly manner (e.g. strings, JSON).
|
|
523
|
+
* - Creates the Rust model, sanitizes, and validates it.
|
|
524
|
+
* - Generates the ID (if applicable).
|
|
525
|
+
* - Generates the path (if applicable).
|
|
526
|
+
* - Returns { json, id, path, url } or a descriptive error.
|
|
527
|
+
* Returns validation limits as a JSON value for client-side use without a builder.
|
|
528
|
+
*/
|
|
529
|
+
export function getValidationLimits(): any;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Builds a LastRead URI of the form "pubky://<author_id>/pub/pubky.app/last_read"
|
|
533
|
+
*/
|
|
534
|
+
export function lastReadUriBuilder(author_id: string): string;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Builds a Mute URI of the form "pubky://<author_id>/pub/pubky.app/mutes/<mute_id>"
|
|
538
|
+
*/
|
|
539
|
+
export function muteUriBuilder(author_id: string, mute_id: string): string;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Parses a Pubky URI and returns a strongly typed `ParsedUriResult`.
|
|
543
|
+
*
|
|
544
|
+
* This function wraps the internal ParsedUri ust parsing logic. It converts the result into a
|
|
545
|
+
* strongly typed object that is easier to use in TypeScript.
|
|
546
|
+
*
|
|
547
|
+
* # Parameters
|
|
548
|
+
*
|
|
549
|
+
* - `uri`: A string slice representing the Pubky URI. The URI should follow the format:
|
|
550
|
+
* `pubky://<user_id>/pub/pubky.app/<resource>[/<id>]`.
|
|
551
|
+
*
|
|
552
|
+
* # Returns
|
|
553
|
+
*
|
|
554
|
+
* On success, returns a `ParsedUriResult` with:
|
|
555
|
+
* - `user_id`: the parsed user ID,
|
|
556
|
+
* - `resource`: a string (derived from the Display implementation of internal `Resource` enum),
|
|
557
|
+
* - `resource_id`: an optional resource identifier (if applicable).
|
|
558
|
+
*
|
|
559
|
+
* On failure, returns a JavaScript error (`String`) containing an error message.
|
|
560
|
+
*
|
|
561
|
+
* # Example (TypeScript)
|
|
562
|
+
*
|
|
563
|
+
* ```typescript
|
|
564
|
+
* import { parse_uri } from "pubky-app-specs";
|
|
565
|
+
*
|
|
566
|
+
* try {
|
|
567
|
+
* const result = parse_uri("pubky://user123/pub/pubky.app/posts/abc123");
|
|
568
|
+
* console.log(result.user_id); // e.g. "user123"
|
|
569
|
+
* console.log(result.resource); // e.g. "posts"
|
|
570
|
+
* console.log(result.resource_id); // e.g. "abc123" or null
|
|
571
|
+
* } catch (error) {
|
|
572
|
+
* console.error("Error parsing URI:", error);
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
export function parse_uri(uri: string): ParsedUriResult;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Builds a Post URI of the form "pubky://<author_id>/pub/pubky.app/posts/<post_id>"
|
|
580
|
+
*/
|
|
581
|
+
export function postUriBuilder(author_id: string, post_id: string): string;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Builds a Tag URI of the form "pubky://<author_id>/pub/pubky.app/tags/<tag_id>"
|
|
585
|
+
*/
|
|
586
|
+
export function tagUriBuilder(author_id: string, tag_id: string): string;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Builds an User URI of the form "pubky://<user_pubky_id>/pub/pubky.app/profile.json"
|
|
590
|
+
*/
|
|
591
|
+
export function userUriBuilder(user_id: string): string;
|