applesauce-common 5.2.0 → 6.0.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/dist/casts/_circular-import.d.ts +7 -0
- package/dist/casts/_circular-import.js +9 -0
- package/dist/casts/article.d.ts +1 -1
- package/dist/casts/badge-award.d.ts +24 -0
- package/dist/casts/badge-award.js +39 -0
- package/dist/casts/badge.d.ts +19 -0
- package/dist/casts/badge.js +48 -0
- package/dist/casts/bookmarks.d.ts +5 -5
- package/dist/casts/cast.d.ts +1 -30
- package/dist/casts/cast.js +2 -67
- package/dist/casts/comment.d.ts +5 -5
- package/dist/casts/emoji-pack.d.ts +11 -0
- package/dist/casts/emoji-pack.js +25 -0
- package/dist/casts/favorite-emojis.d.ts +25 -0
- package/dist/casts/favorite-emojis.js +62 -0
- package/dist/casts/file-metadata.d.ts +22 -0
- package/dist/casts/file-metadata.js +55 -0
- package/dist/casts/groups.d.ts +1 -1
- package/dist/casts/index.d.ts +7 -0
- package/dist/casts/index.js +7 -0
- package/dist/casts/mutes.d.ts +1 -1
- package/dist/casts/note.d.ts +7 -7
- package/dist/casts/profile-badges.d.ts +28 -0
- package/dist/casts/profile-badges.js +59 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-lists.d.ts +1 -1
- package/dist/casts/relay-monitor.d.ts +1 -1
- package/dist/casts/report.d.ts +2 -2
- package/dist/casts/share.d.ts +2 -2
- package/dist/casts/stream.d.ts +9 -9
- package/dist/casts/torrent.d.ts +3 -3
- package/dist/casts/trusted-assertions.d.ts +144 -0
- package/dist/casts/trusted-assertions.js +281 -0
- package/dist/casts/user.d.ts +22 -40
- package/dist/casts/user.js +105 -161
- package/dist/casts/zap-goal.d.ts +2 -2
- package/dist/casts/zap.d.ts +4 -4
- package/dist/factories/app-data.d.ts +13 -0
- package/dist/factories/app-data.js +20 -0
- package/dist/factories/badge-award.d.ts +25 -0
- package/dist/factories/badge-award.js +41 -0
- package/dist/factories/badge.d.ts +32 -0
- package/dist/factories/badge.js +50 -0
- package/dist/factories/blocked-relays.d.ts +10 -0
- package/dist/factories/blocked-relays.js +16 -0
- package/dist/factories/blossom-server-list.d.ts +19 -0
- package/dist/factories/blossom-server-list.js +36 -0
- package/dist/factories/bookmark-list.d.ts +23 -0
- package/dist/factories/bookmark-list.js +45 -0
- package/dist/factories/bookmark-set.d.ts +25 -0
- package/dist/factories/bookmark-set.js +51 -0
- package/dist/factories/calendar-event.d.ts +88 -0
- package/dist/factories/calendar-event.js +175 -0
- package/dist/factories/calendar-rsvp.d.ts +22 -0
- package/dist/factories/calendar-rsvp.js +35 -0
- package/dist/factories/calendar.d.ts +20 -0
- package/dist/factories/calendar.js +36 -0
- package/dist/factories/code-snippet.d.ts +65 -0
- package/dist/factories/code-snippet.js +100 -0
- package/dist/factories/comment.d.ts +26 -0
- package/dist/factories/comment.js +49 -0
- package/dist/factories/contacts.d.ts +19 -0
- package/dist/factories/contacts.js +36 -0
- package/dist/factories/dm-relays.d.ts +10 -0
- package/dist/factories/dm-relays.js +16 -0
- package/dist/factories/favorite-relays.d.ts +16 -0
- package/dist/factories/favorite-relays.js +31 -0
- package/dist/factories/file-metadata.d.ts +54 -0
- package/dist/factories/file-metadata.js +92 -0
- package/dist/factories/follow-set.d.ts +12 -0
- package/dist/factories/follow-set.js +22 -0
- package/dist/factories/gift-wrap.d.ts +17 -0
- package/dist/factories/gift-wrap.js +21 -0
- package/dist/factories/group-management.d.ts +63 -0
- package/dist/factories/group-management.js +147 -0
- package/dist/factories/group.d.ts +35 -0
- package/dist/factories/group.js +69 -0
- package/dist/factories/highlight.d.ts +33 -0
- package/dist/factories/highlight.js +49 -0
- package/dist/factories/index.d.ts +41 -0
- package/dist/factories/index.js +41 -0
- package/dist/factories/legacy-message.d.ts +10 -0
- package/dist/factories/legacy-message.js +19 -0
- package/dist/factories/list.d.ts +56 -0
- package/dist/factories/list.js +120 -0
- package/dist/factories/live-stream.d.ts +48 -0
- package/dist/factories/live-stream.js +90 -0
- package/dist/factories/mute-list.d.ts +27 -0
- package/dist/factories/mute-list.js +57 -0
- package/dist/factories/note.d.ts +38 -0
- package/dist/factories/note.js +66 -0
- package/dist/factories/picture-post.d.ts +28 -0
- package/dist/factories/picture-post.js +46 -0
- package/dist/factories/pin-list.d.ts +14 -0
- package/dist/factories/pin-list.js +24 -0
- package/dist/factories/poll-response.d.ts +36 -0
- package/dist/factories/poll-response.js +46 -0
- package/dist/factories/poll.d.ts +35 -0
- package/dist/factories/poll.js +48 -0
- package/dist/factories/profile-badges.d.ts +31 -0
- package/dist/factories/profile-badges.js +52 -0
- package/dist/factories/reaction.d.ts +22 -0
- package/dist/factories/reaction.js +37 -0
- package/dist/factories/relay-set.d.ts +12 -0
- package/dist/factories/relay-set.js +22 -0
- package/dist/factories/search-relays.d.ts +10 -0
- package/dist/factories/search-relays.js +16 -0
- package/dist/factories/share.d.ts +26 -0
- package/dist/factories/share.js +44 -0
- package/dist/factories/stream-chat-message.d.ts +22 -0
- package/dist/factories/stream-chat-message.js +31 -0
- package/dist/factories/torrent.d.ts +57 -0
- package/dist/factories/torrent.js +93 -0
- package/dist/factories/wrapped-message.d.ts +22 -0
- package/dist/factories/wrapped-message.js +39 -0
- package/dist/factories/zap-goal.d.ts +35 -0
- package/dist/factories/zap-goal.js +49 -0
- package/dist/factories/zap-request.d.ts +28 -0
- package/dist/factories/zap-request.js +55 -0
- package/dist/factories/zap.d.ts +13 -0
- package/dist/factories/zap.js +21 -0
- package/dist/helpers/badge-award.d.ts +15 -0
- package/dist/helpers/badge-award.js +32 -0
- package/dist/helpers/badge.d.ts +27 -0
- package/dist/helpers/badge.js +59 -0
- package/dist/helpers/blossom.d.ts +29 -1
- package/dist/helpers/blossom.js +64 -7
- package/dist/helpers/emoji-pack.d.ts +43 -0
- package/dist/helpers/emoji-pack.js +108 -0
- package/dist/helpers/emoji.d.ts +0 -4
- package/dist/helpers/emoji.js +0 -16
- package/dist/helpers/file-metadata.d.ts +18 -13
- package/dist/helpers/file-metadata.js +10 -4
- package/dist/helpers/groups.d.ts +1 -0
- package/dist/helpers/groups.js +3 -2
- package/dist/helpers/hashtag.d.ts +1 -0
- package/dist/helpers/hashtag.js +3 -3
- package/dist/helpers/index.d.ts +7 -2
- package/dist/helpers/index.js +7 -2
- package/dist/helpers/lists.d.ts +8 -0
- package/dist/helpers/lists.js +27 -5
- package/dist/helpers/picture-post.d.ts +2 -2
- package/dist/helpers/profile-badges.d.ts +23 -0
- package/dist/helpers/profile-badges.js +51 -0
- package/dist/helpers/trusted-assertions.d.ts +81 -0
- package/dist/helpers/trusted-assertions.js +161 -0
- package/dist/helpers/zap.d.ts +8 -2
- package/dist/helpers/zap.js +31 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +1 -1
- package/dist/observable/chainable.d.ts +1 -36
- package/dist/observable/chainable.js +2 -72
- package/dist/operations/app-data.d.ts +8 -3
- package/dist/operations/app-data.js +9 -4
- package/dist/operations/badge-award.d.ts +17 -0
- package/dist/operations/badge-award.js +30 -0
- package/dist/operations/badge.d.ts +22 -0
- package/dist/operations/badge.js +54 -0
- package/dist/operations/blossom.d.ts +1 -1
- package/dist/operations/calendar-event.d.ts +1 -1
- package/dist/operations/calendar-rsvp.d.ts +1 -1
- package/dist/operations/calendar.d.ts +1 -1
- package/dist/operations/channel.d.ts +1 -1
- package/dist/operations/client.d.ts +1 -1
- package/dist/operations/client.js +2 -2
- package/dist/operations/code-snippet.d.ts +27 -0
- package/dist/operations/code-snippet.js +63 -0
- package/dist/operations/comment.d.ts +7 -3
- package/dist/operations/comment.js +8 -4
- package/dist/operations/file-metadata.d.ts +38 -4
- package/dist/operations/file-metadata.js +105 -19
- package/dist/operations/geohash.d.ts +1 -1
- package/dist/operations/gift-wrap.d.ts +19 -7
- package/dist/operations/gift-wrap.js +36 -26
- package/dist/operations/group.d.ts +1 -1
- package/dist/operations/hashtags.d.ts +1 -1
- package/dist/operations/highlight.d.ts +1 -1
- package/dist/operations/highlight.js +5 -5
- package/dist/operations/index.d.ts +7 -1
- package/dist/operations/index.js +7 -1
- package/dist/operations/legacy-message.d.ts +1 -1
- package/dist/operations/list.d.ts +1 -1
- package/dist/operations/live-stream.d.ts +7 -3
- package/dist/operations/live-stream.js +9 -5
- package/dist/operations/media-attachment.d.ts +3 -3
- package/dist/operations/note.d.ts +10 -4
- package/dist/operations/note.js +14 -8
- package/dist/operations/picture-post.d.ts +1 -1
- package/dist/operations/poll-response.d.ts +1 -1
- package/dist/operations/poll-response.js +1 -1
- package/dist/operations/poll.d.ts +1 -1
- package/dist/operations/profile-badges.d.ts +26 -0
- package/dist/operations/profile-badges.js +150 -0
- package/dist/operations/reaction.d.ts +8 -3
- package/dist/operations/reaction.js +10 -5
- package/dist/operations/share.d.ts +8 -3
- package/dist/operations/share.js +10 -5
- package/dist/operations/stream.d.ts +1 -1
- package/dist/operations/tag/bookmarks.d.ts +1 -1
- package/dist/operations/torrent.d.ts +1 -1
- package/dist/operations/wrapped-message.d.ts +1 -1
- package/dist/operations/zap-goal.d.ts +1 -1
- package/dist/operations/zap-request.d.ts +22 -0
- package/dist/operations/zap-request.js +40 -0
- package/dist/operations/zap-split.d.ts +8 -4
- package/dist/operations/zap-split.js +10 -6
- package/dist/operations/zap.d.ts +12 -0
- package/dist/operations/zap.js +34 -0
- package/package.json +12 -11
- package/dist/blueprints/__register__.d.ts +0 -7
- package/dist/blueprints/__register__.js +0 -8
- package/dist/blueprints/app-data.d.ts +0 -5
- package/dist/blueprints/app-data.js +0 -10
- package/dist/blueprints/calendar.d.ts +0 -5
- package/dist/blueprints/calendar.js +0 -7
- package/dist/blueprints/channels.d.ts +0 -6
- package/dist/blueprints/channels.js +0 -13
- package/dist/blueprints/comment.d.ts +0 -13
- package/dist/blueprints/comment.js +0 -15
- package/dist/blueprints/delete.d.ts +0 -9
- package/dist/blueprints/delete.js +0 -14
- package/dist/blueprints/file-metadata.d.ts +0 -8
- package/dist/blueprints/file-metadata.js +0 -11
- package/dist/blueprints/follow-set.d.ts +0 -11
- package/dist/blueprints/follow-set.js +0 -21
- package/dist/blueprints/gift-wrap.d.ts +0 -5
- package/dist/blueprints/gift-wrap.js +0 -6
- package/dist/blueprints/group-mangement.d.ts +0 -25
- package/dist/blueprints/group-mangement.js +0 -40
- package/dist/blueprints/group.d.ts +0 -9
- package/dist/blueprints/group.js +0 -17
- package/dist/blueprints/highlight.d.ts +0 -20
- package/dist/blueprints/highlight.js +0 -12
- package/dist/blueprints/index.d.ts +0 -25
- package/dist/blueprints/index.js +0 -26
- package/dist/blueprints/legacy-message.d.ts +0 -7
- package/dist/blueprints/legacy-message.js +0 -29
- package/dist/blueprints/live-stream.d.ts +0 -6
- package/dist/blueprints/live-stream.js +0 -9
- package/dist/blueprints/note.d.ts +0 -16
- package/dist/blueprints/note.js +0 -30
- package/dist/blueprints/picture-post.d.ts +0 -12
- package/dist/blueprints/picture-post.js +0 -17
- package/dist/blueprints/poll.d.ts +0 -41
- package/dist/blueprints/poll.js +0 -33
- package/dist/blueprints/profile.d.ts +0 -3
- package/dist/blueprints/profile.js +0 -7
- package/dist/blueprints/reaction.d.ts +0 -10
- package/dist/blueprints/reaction.js +0 -14
- package/dist/blueprints/share.d.ts +0 -12
- package/dist/blueprints/share.js +0 -25
- package/dist/blueprints/stream.d.ts +0 -6
- package/dist/blueprints/stream.js +0 -7
- package/dist/blueprints/torrent.d.ts +0 -30
- package/dist/blueprints/torrent.js +0 -29
- package/dist/blueprints/wrapped-message.d.ts +0 -20
- package/dist/blueprints/wrapped-message.js +0 -64
- package/dist/blueprints/zap-goal.d.ts +0 -16
- package/dist/blueprints/zap-goal.js +0 -12
- package/dist/register.d.ts +0 -2
- package/dist/register.js +0 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { addBlossomServer, removeBlossomServer } from "../operations/blossom.js";
|
|
3
|
+
import { BLOSSOM_SERVER_LIST_KIND } from "../helpers/blossom.js";
|
|
4
|
+
/** A factory class for building kind 10063 Blossom server list events */
|
|
5
|
+
export class BlossomServerListFactory extends EventFactory {
|
|
6
|
+
/** Creates a new Blossom server list factory */
|
|
7
|
+
static create() {
|
|
8
|
+
return new BlossomServerListFactory((res) => res(blankEventTemplate(BLOSSOM_SERVER_LIST_KIND)));
|
|
9
|
+
}
|
|
10
|
+
/** Creates a new Blossom server list factory from an existing Blossom server list event */
|
|
11
|
+
static modify(event) {
|
|
12
|
+
if (event.kind !== BLOSSOM_SERVER_LIST_KIND)
|
|
13
|
+
throw new Error("Event is not a Blossom server list event");
|
|
14
|
+
return new BlossomServerListFactory((res) => res(toEventTemplate(event)));
|
|
15
|
+
}
|
|
16
|
+
/** Adds a Blossom server to the list */
|
|
17
|
+
addServer(url) {
|
|
18
|
+
return this.chain(addBlossomServer(url));
|
|
19
|
+
}
|
|
20
|
+
/** Removes a Blossom server from the list */
|
|
21
|
+
removeServer(url) {
|
|
22
|
+
return this.chain(removeBlossomServer(url));
|
|
23
|
+
}
|
|
24
|
+
/** Moves a server to the top of the list, making it the default */
|
|
25
|
+
setDefaultServer(url) {
|
|
26
|
+
return this.removeServer(url).modifyPublicTags((tags) => [["server", String(url)], ...tags]);
|
|
27
|
+
}
|
|
28
|
+
/** Replaces all servers with the given list */
|
|
29
|
+
servers(urls) {
|
|
30
|
+
return this.modifyPublicTags((tags) => {
|
|
31
|
+
const filtered = tags.filter((t) => t[0] !== "server");
|
|
32
|
+
const serverTags = urls.map((url) => ["server", String(url)]);
|
|
33
|
+
return [...filtered, ...serverTags];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
2
|
+
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
3
|
+
import { NIP51ItemListFactory } from "./list.js";
|
|
4
|
+
export type BookmarkListTemplate = KnownEventTemplate<kinds.BookmarkList>;
|
|
5
|
+
/** A factory class for building kind 10003 bookmark list events */
|
|
6
|
+
export declare class BookmarkListFactory extends NIP51ItemListFactory<kinds.BookmarkList, BookmarkListTemplate> {
|
|
7
|
+
/** Creates a new bookmark list factory */
|
|
8
|
+
static create(): BookmarkListFactory;
|
|
9
|
+
/** Creates a new bookmark list factory from an existing bookmark list event */
|
|
10
|
+
static modify(event: NostrEvent | KnownEvent<kinds.BookmarkList>): BookmarkListFactory;
|
|
11
|
+
/** Bookmarks an event — uses "a" tag for articles, "e" tag for notes */
|
|
12
|
+
bookmarkEvent(event: NostrEvent | EventPointer | AddressPointer, hidden?: boolean): this;
|
|
13
|
+
/** Removes a bookmark — uses "a" tag for articles, "e" tag for notes */
|
|
14
|
+
unbookmarkEvent(event: NostrEvent | EventPointer | AddressPointer, hidden?: boolean): this;
|
|
15
|
+
/** Bookmarks a URL by adding an "r" tag */
|
|
16
|
+
bookmarkUrl(url: string, hidden?: boolean): this;
|
|
17
|
+
/** Removes a bookmarked URL */
|
|
18
|
+
unbookmarkUrl(url: string, hidden?: boolean): this;
|
|
19
|
+
/** Bookmarks a hashtag by adding a "t" tag */
|
|
20
|
+
bookmarkHashtag(hashtag: string, hidden?: boolean): this;
|
|
21
|
+
/** Removes a bookmarked hashtag */
|
|
22
|
+
unbookmarkHashtag(hashtag: string, hidden?: boolean): this;
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind, kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { addEventBookmarkTag, removeEventBookmarkTag } from "../operations/tag/bookmarks.js";
|
|
4
|
+
import { NIP51ItemListFactory } from "./list.js";
|
|
5
|
+
/** A factory class for building kind 10003 bookmark list events */
|
|
6
|
+
export class BookmarkListFactory extends NIP51ItemListFactory {
|
|
7
|
+
/** Creates a new bookmark list factory */
|
|
8
|
+
static create() {
|
|
9
|
+
return new BookmarkListFactory((res) => res(blankEventTemplate(kinds.BookmarkList)));
|
|
10
|
+
}
|
|
11
|
+
/** Creates a new bookmark list factory from an existing bookmark list event */
|
|
12
|
+
static modify(event) {
|
|
13
|
+
if (!isKind(event, kinds.BookmarkList))
|
|
14
|
+
throw new Error("Event is not a bookmark list event");
|
|
15
|
+
return new BookmarkListFactory((res) => res(toEventTemplate(event)));
|
|
16
|
+
}
|
|
17
|
+
/** Bookmarks an event — uses "a" tag for articles, "e" tag for notes */
|
|
18
|
+
bookmarkEvent(event, hidden = false) {
|
|
19
|
+
return hidden
|
|
20
|
+
? this.modifyHiddenTags(addEventBookmarkTag(event))
|
|
21
|
+
: this.modifyPublicTags(addEventBookmarkTag(event));
|
|
22
|
+
}
|
|
23
|
+
/** Removes a bookmark — uses "a" tag for articles, "e" tag for notes */
|
|
24
|
+
unbookmarkEvent(event, hidden = false) {
|
|
25
|
+
return hidden
|
|
26
|
+
? this.modifyHiddenTags(removeEventBookmarkTag(event))
|
|
27
|
+
: this.modifyPublicTags(removeEventBookmarkTag(event));
|
|
28
|
+
}
|
|
29
|
+
/** Bookmarks a URL by adding an "r" tag */
|
|
30
|
+
bookmarkUrl(url, hidden = false) {
|
|
31
|
+
return this.addUrlItem(url, hidden);
|
|
32
|
+
}
|
|
33
|
+
/** Removes a bookmarked URL */
|
|
34
|
+
unbookmarkUrl(url, hidden = false) {
|
|
35
|
+
return this.removeUrlItem(url, hidden);
|
|
36
|
+
}
|
|
37
|
+
/** Bookmarks a hashtag by adding a "t" tag */
|
|
38
|
+
bookmarkHashtag(hashtag, hidden = false) {
|
|
39
|
+
return this.addHashtagItem(hashtag, hidden);
|
|
40
|
+
}
|
|
41
|
+
/** Removes a bookmarked hashtag */
|
|
42
|
+
unbookmarkHashtag(hashtag, hidden = false) {
|
|
43
|
+
return this.removeHashtagItem(hashtag, hidden);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
2
|
+
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
3
|
+
import { NIP51ItemListFactory } from "./list.js";
|
|
4
|
+
export type BookmarkSetTemplate = KnownEventTemplate<kinds.Bookmarksets>;
|
|
5
|
+
/** A factory class for building kind 30003 bookmark set events */
|
|
6
|
+
export declare class BookmarkSetFactory extends NIP51ItemListFactory<kinds.Bookmarksets, BookmarkSetTemplate> {
|
|
7
|
+
/** Creates a new bookmark set factory with an auto-generated identifier */
|
|
8
|
+
static create(): BookmarkSetFactory;
|
|
9
|
+
/** Sets the "d" identifier tag */
|
|
10
|
+
identifier(id: string): this;
|
|
11
|
+
/** Creates a new bookmark set factory from an existing bookmark set event */
|
|
12
|
+
static modify(event: NostrEvent | KnownEvent<kinds.Bookmarksets>): BookmarkSetFactory;
|
|
13
|
+
/** Bookmarks an event — uses "a" tag for articles, "e" tag for notes */
|
|
14
|
+
bookmarkEvent(event: NostrEvent | EventPointer | AddressPointer, hidden?: boolean): this;
|
|
15
|
+
/** Removes a bookmark — uses "a" tag for articles, "e" tag for notes */
|
|
16
|
+
unbookmarkEvent(event: NostrEvent | EventPointer | AddressPointer, hidden?: boolean): this;
|
|
17
|
+
/** Bookmarks a URL by adding an "r" tag */
|
|
18
|
+
bookmarkUrl(url: string, hidden?: boolean): this;
|
|
19
|
+
/** Removes a bookmarked URL */
|
|
20
|
+
unbookmarkUrl(url: string, hidden?: boolean): this;
|
|
21
|
+
/** Bookmarks a hashtag by adding a "t" tag */
|
|
22
|
+
bookmarkHashtag(hashtag: string, hidden?: boolean): this;
|
|
23
|
+
/** Removes a bookmarked hashtag */
|
|
24
|
+
unbookmarkHashtag(hashtag: string, hidden?: boolean): this;
|
|
25
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind, kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { includeReplaceableIdentifier } from "applesauce-core/operations/index";
|
|
4
|
+
import { nanoid } from "nanoid";
|
|
5
|
+
import { addEventBookmarkTag, removeEventBookmarkTag } from "../operations/tag/bookmarks.js";
|
|
6
|
+
import { NIP51ItemListFactory } from "./list.js";
|
|
7
|
+
/** A factory class for building kind 30003 bookmark set events */
|
|
8
|
+
export class BookmarkSetFactory extends NIP51ItemListFactory {
|
|
9
|
+
/** Creates a new bookmark set factory with an auto-generated identifier */
|
|
10
|
+
static create() {
|
|
11
|
+
return new BookmarkSetFactory((res) => res(blankEventTemplate(kinds.Bookmarksets))).identifier(nanoid());
|
|
12
|
+
}
|
|
13
|
+
/** Sets the "d" identifier tag */
|
|
14
|
+
identifier(id) {
|
|
15
|
+
return this.chain(includeReplaceableIdentifier(id));
|
|
16
|
+
}
|
|
17
|
+
/** Creates a new bookmark set factory from an existing bookmark set event */
|
|
18
|
+
static modify(event) {
|
|
19
|
+
if (!isKind(event, kinds.Bookmarksets))
|
|
20
|
+
throw new Error("Event is not a bookmark set event");
|
|
21
|
+
return new BookmarkSetFactory((res) => res(toEventTemplate(event)));
|
|
22
|
+
}
|
|
23
|
+
/** Bookmarks an event — uses "a" tag for articles, "e" tag for notes */
|
|
24
|
+
bookmarkEvent(event, hidden = false) {
|
|
25
|
+
return hidden
|
|
26
|
+
? this.modifyHiddenTags(addEventBookmarkTag(event))
|
|
27
|
+
: this.modifyPublicTags(addEventBookmarkTag(event));
|
|
28
|
+
}
|
|
29
|
+
/** Removes a bookmark — uses "a" tag for articles, "e" tag for notes */
|
|
30
|
+
unbookmarkEvent(event, hidden = false) {
|
|
31
|
+
return hidden
|
|
32
|
+
? this.modifyHiddenTags(removeEventBookmarkTag(event))
|
|
33
|
+
: this.modifyPublicTags(removeEventBookmarkTag(event));
|
|
34
|
+
}
|
|
35
|
+
/** Bookmarks a URL by adding an "r" tag */
|
|
36
|
+
bookmarkUrl(url, hidden = false) {
|
|
37
|
+
return this.addUrlItem(url, hidden);
|
|
38
|
+
}
|
|
39
|
+
/** Removes a bookmarked URL */
|
|
40
|
+
unbookmarkUrl(url, hidden = false) {
|
|
41
|
+
return this.removeUrlItem(url, hidden);
|
|
42
|
+
}
|
|
43
|
+
/** Bookmarks a hashtag by adding a "t" tag */
|
|
44
|
+
bookmarkHashtag(hashtag, hidden = false) {
|
|
45
|
+
return this.addHashtagItem(hashtag, hidden);
|
|
46
|
+
}
|
|
47
|
+
/** Removes a bookmarked hashtag */
|
|
48
|
+
unbookmarkHashtag(hashtag, hidden = false) {
|
|
49
|
+
return this.removeHashtagItem(hashtag, hidden);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
+
import { DATE_BASED_CALENDAR_EVENT_KIND, TIME_BASED_CALENDAR_EVENT_KIND, CalendarEventParticipant } from "../helpers/calendar-event.js";
|
|
5
|
+
export type DateBasedCalendarEventTemplate = KnownEventTemplate<typeof DATE_BASED_CALENDAR_EVENT_KIND>;
|
|
6
|
+
export type TimeBasedCalendarEventTemplate = KnownEventTemplate<typeof TIME_BASED_CALENDAR_EVENT_KIND>;
|
|
7
|
+
/** A factory class for building NIP-52 date-based calendar events (kind 31922) */
|
|
8
|
+
export declare class DateBasedCalendarEventFactory extends EventFactory<typeof DATE_BASED_CALENDAR_EVENT_KIND, DateBasedCalendarEventTemplate> {
|
|
9
|
+
/** Creates a new date-based calendar event factory */
|
|
10
|
+
static create(title: string): DateBasedCalendarEventFactory;
|
|
11
|
+
/** Creates a factory from an existing date-based calendar event for editing */
|
|
12
|
+
static modify(event: NostrEvent | KnownEvent<typeof DATE_BASED_CALENDAR_EVENT_KIND>): DateBasedCalendarEventFactory;
|
|
13
|
+
/** Sets the "d" identifier tag */
|
|
14
|
+
identifier(id: string): this;
|
|
15
|
+
/** Sets the title of the calendar event */
|
|
16
|
+
title(title: string): this;
|
|
17
|
+
/** Sets the description/content of the calendar event */
|
|
18
|
+
description(content: string): this;
|
|
19
|
+
/** Sets the summary of the calendar event */
|
|
20
|
+
summary(summary: string): this;
|
|
21
|
+
/** Sets the image for the calendar event */
|
|
22
|
+
image(url: string): this;
|
|
23
|
+
/** Sets the start date (YYYY-MM-DD) */
|
|
24
|
+
startDate(date: string | Date): this;
|
|
25
|
+
/** Sets the end date (YYYY-MM-DD) */
|
|
26
|
+
endDate(date: string | Date): this;
|
|
27
|
+
/** Sets the geohash for the calendar event */
|
|
28
|
+
geohash(geohash: string): this;
|
|
29
|
+
/** Adds a location to the calendar event */
|
|
30
|
+
location(location: string): this;
|
|
31
|
+
/** Removes a location from the calendar event */
|
|
32
|
+
removeLocation(location: string): this;
|
|
33
|
+
/** Adds a reference link to the calendar event */
|
|
34
|
+
referenceLink(link: string | URL): this;
|
|
35
|
+
/** Removes a reference link from the calendar event */
|
|
36
|
+
removeReferenceLink(link: string | URL): this;
|
|
37
|
+
/** Adds a participant to the calendar event */
|
|
38
|
+
participant(participant: CalendarEventParticipant): this;
|
|
39
|
+
/** Removes a participant from the calendar event */
|
|
40
|
+
removeParticipant(pubkey: string | CalendarEventParticipant): this;
|
|
41
|
+
/** Adds a hashtag to the calendar event */
|
|
42
|
+
addHashtag(hashtag: string): this;
|
|
43
|
+
/** Adds multiple hashtags to the calendar event */
|
|
44
|
+
hashtags(hashtags: string[]): this;
|
|
45
|
+
/** Sets meta tags */
|
|
46
|
+
meta(options: MetaTagOptions): this;
|
|
47
|
+
}
|
|
48
|
+
/** A factory class for building NIP-52 time-based calendar events (kind 31923) */
|
|
49
|
+
export declare class TimeBasedCalendarEventFactory extends EventFactory<typeof TIME_BASED_CALENDAR_EVENT_KIND, TimeBasedCalendarEventTemplate> {
|
|
50
|
+
/** Creates a new time-based calendar event factory */
|
|
51
|
+
static create(title: string): TimeBasedCalendarEventFactory;
|
|
52
|
+
/** Creates a factory from an existing time-based calendar event for editing */
|
|
53
|
+
static modify(event: NostrEvent | KnownEvent<typeof TIME_BASED_CALENDAR_EVENT_KIND>): TimeBasedCalendarEventFactory;
|
|
54
|
+
/** Sets the "d" identifier tag */
|
|
55
|
+
identifier(id: string): this;
|
|
56
|
+
/** Sets the title of the calendar event */
|
|
57
|
+
title(title: string): this;
|
|
58
|
+
/** Sets the description/content of the calendar event */
|
|
59
|
+
description(content: string): this;
|
|
60
|
+
/** Sets the summary of the calendar event */
|
|
61
|
+
summary(summary: string): this;
|
|
62
|
+
/** Sets the image for the calendar event */
|
|
63
|
+
image(url: string): this;
|
|
64
|
+
/** Sets the start time */
|
|
65
|
+
startTime(time: number | Date, timezone?: string): this;
|
|
66
|
+
/** Sets the end time */
|
|
67
|
+
endTime(time: number | Date, timezone?: string): this;
|
|
68
|
+
/** Sets the geohash for the calendar event */
|
|
69
|
+
geohash(geohash: string): this;
|
|
70
|
+
/** Adds a location to the calendar event */
|
|
71
|
+
location(location: string): this;
|
|
72
|
+
/** Removes a location from the calendar event */
|
|
73
|
+
removeLocation(location: string): this;
|
|
74
|
+
/** Adds a reference link to the calendar event */
|
|
75
|
+
referenceLink(link: string | URL): this;
|
|
76
|
+
/** Removes a reference link from the calendar event */
|
|
77
|
+
removeReferenceLink(link: string | URL): this;
|
|
78
|
+
/** Adds a participant to the calendar event */
|
|
79
|
+
participant(participant: CalendarEventParticipant): this;
|
|
80
|
+
/** Removes a participant from the calendar event */
|
|
81
|
+
removeParticipant(pubkey: string | CalendarEventParticipant): this;
|
|
82
|
+
/** Adds a hashtag to the calendar event */
|
|
83
|
+
addHashtag(hashtag: string): this;
|
|
84
|
+
/** Adds multiple hashtags to the calendar event */
|
|
85
|
+
hashtags(hashtags: string[]): this;
|
|
86
|
+
/** Sets meta tags */
|
|
87
|
+
meta(options: MetaTagOptions): this;
|
|
88
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { EventFactory, blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind } from "applesauce-core/helpers";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
import { setContent } from "applesauce-core/operations/content";
|
|
5
|
+
import { setMetaTags } from "applesauce-core/operations/event";
|
|
6
|
+
import { includeReplaceableIdentifier } from "applesauce-core/operations/index";
|
|
7
|
+
import { DATE_BASED_CALENDAR_EVENT_KIND, TIME_BASED_CALENDAR_EVENT_KIND, } from "../helpers/calendar-event.js";
|
|
8
|
+
import * as CalendarEventOps from "../operations/calendar-event.js";
|
|
9
|
+
import { addHashtag, includeHashtags } from "../operations/hashtags.js";
|
|
10
|
+
/** A factory class for building NIP-52 date-based calendar events (kind 31922) */
|
|
11
|
+
export class DateBasedCalendarEventFactory extends EventFactory {
|
|
12
|
+
/** Creates a new date-based calendar event factory */
|
|
13
|
+
static create(title) {
|
|
14
|
+
return new DateBasedCalendarEventFactory((res) => res(blankEventTemplate(DATE_BASED_CALENDAR_EVENT_KIND)))
|
|
15
|
+
.identifier(nanoid())
|
|
16
|
+
.title(title);
|
|
17
|
+
}
|
|
18
|
+
/** Creates a factory from an existing date-based calendar event for editing */
|
|
19
|
+
static modify(event) {
|
|
20
|
+
if (!isKind(event, DATE_BASED_CALENDAR_EVENT_KIND))
|
|
21
|
+
throw new Error("Event is not a date-based calendar event");
|
|
22
|
+
return new DateBasedCalendarEventFactory((res) => res(toEventTemplate(event)));
|
|
23
|
+
}
|
|
24
|
+
/** Sets the "d" identifier tag */
|
|
25
|
+
identifier(id) {
|
|
26
|
+
return this.chain(includeReplaceableIdentifier(id));
|
|
27
|
+
}
|
|
28
|
+
/** Sets the title of the calendar event */
|
|
29
|
+
title(title) {
|
|
30
|
+
return this.chain(CalendarEventOps.setTitle(title));
|
|
31
|
+
}
|
|
32
|
+
/** Sets the description/content of the calendar event */
|
|
33
|
+
description(content) {
|
|
34
|
+
return this.chain(setContent(content));
|
|
35
|
+
}
|
|
36
|
+
/** Sets the summary of the calendar event */
|
|
37
|
+
summary(summary) {
|
|
38
|
+
return this.chain(CalendarEventOps.setSummary(summary));
|
|
39
|
+
}
|
|
40
|
+
/** Sets the image for the calendar event */
|
|
41
|
+
image(url) {
|
|
42
|
+
return this.chain(CalendarEventOps.setImage(url));
|
|
43
|
+
}
|
|
44
|
+
/** Sets the start date (YYYY-MM-DD) */
|
|
45
|
+
startDate(date) {
|
|
46
|
+
return this.chain(CalendarEventOps.setStartDate(date));
|
|
47
|
+
}
|
|
48
|
+
/** Sets the end date (YYYY-MM-DD) */
|
|
49
|
+
endDate(date) {
|
|
50
|
+
return this.chain(CalendarEventOps.setEndDate(date));
|
|
51
|
+
}
|
|
52
|
+
/** Sets the geohash for the calendar event */
|
|
53
|
+
geohash(geohash) {
|
|
54
|
+
return this.chain(CalendarEventOps.setGeohash(geohash));
|
|
55
|
+
}
|
|
56
|
+
/** Adds a location to the calendar event */
|
|
57
|
+
location(location) {
|
|
58
|
+
return this.chain(CalendarEventOps.addLocation(location));
|
|
59
|
+
}
|
|
60
|
+
/** Removes a location from the calendar event */
|
|
61
|
+
removeLocation(location) {
|
|
62
|
+
return this.chain(CalendarEventOps.removeLocation(location));
|
|
63
|
+
}
|
|
64
|
+
/** Adds a reference link to the calendar event */
|
|
65
|
+
referenceLink(link) {
|
|
66
|
+
return this.chain(CalendarEventOps.addReferenceLink(link));
|
|
67
|
+
}
|
|
68
|
+
/** Removes a reference link from the calendar event */
|
|
69
|
+
removeReferenceLink(link) {
|
|
70
|
+
return this.chain(CalendarEventOps.removeReferenceLink(link));
|
|
71
|
+
}
|
|
72
|
+
/** Adds a participant to the calendar event */
|
|
73
|
+
participant(participant) {
|
|
74
|
+
return this.chain(CalendarEventOps.addParticipant(participant));
|
|
75
|
+
}
|
|
76
|
+
/** Removes a participant from the calendar event */
|
|
77
|
+
removeParticipant(pubkey) {
|
|
78
|
+
return this.chain(CalendarEventOps.removeParticipant(pubkey));
|
|
79
|
+
}
|
|
80
|
+
/** Adds a hashtag to the calendar event */
|
|
81
|
+
addHashtag(hashtag) {
|
|
82
|
+
return this.chain(addHashtag(hashtag));
|
|
83
|
+
}
|
|
84
|
+
/** Adds multiple hashtags to the calendar event */
|
|
85
|
+
hashtags(hashtags) {
|
|
86
|
+
return this.chain(includeHashtags(hashtags));
|
|
87
|
+
}
|
|
88
|
+
/** Sets meta tags */
|
|
89
|
+
meta(options) {
|
|
90
|
+
return this.chain(setMetaTags(options));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** A factory class for building NIP-52 time-based calendar events (kind 31923) */
|
|
94
|
+
export class TimeBasedCalendarEventFactory extends EventFactory {
|
|
95
|
+
/** Creates a new time-based calendar event factory */
|
|
96
|
+
static create(title) {
|
|
97
|
+
return new TimeBasedCalendarEventFactory((res) => res(blankEventTemplate(TIME_BASED_CALENDAR_EVENT_KIND)))
|
|
98
|
+
.identifier(nanoid())
|
|
99
|
+
.title(title);
|
|
100
|
+
}
|
|
101
|
+
/** Creates a factory from an existing time-based calendar event for editing */
|
|
102
|
+
static modify(event) {
|
|
103
|
+
if (!isKind(event, TIME_BASED_CALENDAR_EVENT_KIND))
|
|
104
|
+
throw new Error("Event is not a time-based calendar event");
|
|
105
|
+
return new TimeBasedCalendarEventFactory((res) => res(toEventTemplate(event)));
|
|
106
|
+
}
|
|
107
|
+
/** Sets the "d" identifier tag */
|
|
108
|
+
identifier(id) {
|
|
109
|
+
return this.chain(includeReplaceableIdentifier(id));
|
|
110
|
+
}
|
|
111
|
+
/** Sets the title of the calendar event */
|
|
112
|
+
title(title) {
|
|
113
|
+
return this.chain(CalendarEventOps.setTitle(title));
|
|
114
|
+
}
|
|
115
|
+
/** Sets the description/content of the calendar event */
|
|
116
|
+
description(content) {
|
|
117
|
+
return this.chain(setContent(content));
|
|
118
|
+
}
|
|
119
|
+
/** Sets the summary of the calendar event */
|
|
120
|
+
summary(summary) {
|
|
121
|
+
return this.chain(CalendarEventOps.setSummary(summary));
|
|
122
|
+
}
|
|
123
|
+
/** Sets the image for the calendar event */
|
|
124
|
+
image(url) {
|
|
125
|
+
return this.chain(CalendarEventOps.setImage(url));
|
|
126
|
+
}
|
|
127
|
+
/** Sets the start time */
|
|
128
|
+
startTime(time, timezone) {
|
|
129
|
+
return this.chain(CalendarEventOps.setStartTime(time, timezone));
|
|
130
|
+
}
|
|
131
|
+
/** Sets the end time */
|
|
132
|
+
endTime(time, timezone) {
|
|
133
|
+
return this.chain(CalendarEventOps.setEndTime(time, timezone));
|
|
134
|
+
}
|
|
135
|
+
/** Sets the geohash for the calendar event */
|
|
136
|
+
geohash(geohash) {
|
|
137
|
+
return this.chain(CalendarEventOps.setGeohash(geohash));
|
|
138
|
+
}
|
|
139
|
+
/** Adds a location to the calendar event */
|
|
140
|
+
location(location) {
|
|
141
|
+
return this.chain(CalendarEventOps.addLocation(location));
|
|
142
|
+
}
|
|
143
|
+
/** Removes a location from the calendar event */
|
|
144
|
+
removeLocation(location) {
|
|
145
|
+
return this.chain(CalendarEventOps.removeLocation(location));
|
|
146
|
+
}
|
|
147
|
+
/** Adds a reference link to the calendar event */
|
|
148
|
+
referenceLink(link) {
|
|
149
|
+
return this.chain(CalendarEventOps.addReferenceLink(link));
|
|
150
|
+
}
|
|
151
|
+
/** Removes a reference link from the calendar event */
|
|
152
|
+
removeReferenceLink(link) {
|
|
153
|
+
return this.chain(CalendarEventOps.removeReferenceLink(link));
|
|
154
|
+
}
|
|
155
|
+
/** Adds a participant to the calendar event */
|
|
156
|
+
participant(participant) {
|
|
157
|
+
return this.chain(CalendarEventOps.addParticipant(participant));
|
|
158
|
+
}
|
|
159
|
+
/** Removes a participant from the calendar event */
|
|
160
|
+
removeParticipant(pubkey) {
|
|
161
|
+
return this.chain(CalendarEventOps.removeParticipant(pubkey));
|
|
162
|
+
}
|
|
163
|
+
/** Adds a hashtag to the calendar event */
|
|
164
|
+
addHashtag(hashtag) {
|
|
165
|
+
return this.chain(addHashtag(hashtag));
|
|
166
|
+
}
|
|
167
|
+
/** Adds multiple hashtags to the calendar event */
|
|
168
|
+
hashtags(hashtags) {
|
|
169
|
+
return this.chain(includeHashtags(hashtags));
|
|
170
|
+
}
|
|
171
|
+
/** Sets meta tags */
|
|
172
|
+
meta(options) {
|
|
173
|
+
return this.chain(setMetaTags(options));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { CALENDAR_EVENT_RSVP_KIND, RSVPFreeBusy, RSVPStatus } from "../helpers/calendar-rsvp.js";
|
|
5
|
+
export type CalendarEventRSVPTemplate = KnownEventTemplate<typeof CALENDAR_EVENT_RSVP_KIND>;
|
|
6
|
+
/** A factory class for building NIP-52 calendar event RSVP events (kind 31925) */
|
|
7
|
+
export declare class CalendarEventRSVPFactory extends EventFactory<typeof CALENDAR_EVENT_RSVP_KIND, CalendarEventRSVPTemplate> {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new RSVP factory for a calendar event
|
|
10
|
+
* @param calendarEvent - The calendar event being RSVPed to
|
|
11
|
+
* @param status - The RSVP status (accepted, declined, tentative)
|
|
12
|
+
*/
|
|
13
|
+
static create(calendarEvent: NostrEvent | AddressPointer, status: RSVPStatus, relay?: string): CalendarEventRSVPFactory;
|
|
14
|
+
/** Creates a factory from an existing RSVP event for editing */
|
|
15
|
+
static modify(event: NostrEvent | KnownEvent<typeof CALENDAR_EVENT_RSVP_KIND>): CalendarEventRSVPFactory;
|
|
16
|
+
/** Sets the pointer to the calendar event being RSVPed to */
|
|
17
|
+
calendarEvent(pointer: NostrEvent | AddressPointer, relay?: string): this;
|
|
18
|
+
/** Sets the RSVP status */
|
|
19
|
+
status(status: RSVPStatus): this;
|
|
20
|
+
/** Sets the free/busy status for the time slot */
|
|
21
|
+
freeBusy(freeBusy: RSVPFreeBusy): this;
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventFactory, blankEventTemplate, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind } from "applesauce-core/helpers";
|
|
3
|
+
import { CALENDAR_EVENT_RSVP_KIND } from "../helpers/calendar-rsvp.js";
|
|
4
|
+
import * as CalendarRsvpOps from "../operations/calendar-rsvp.js";
|
|
5
|
+
/** A factory class for building NIP-52 calendar event RSVP events (kind 31925) */
|
|
6
|
+
export class CalendarEventRSVPFactory extends EventFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new RSVP factory for a calendar event
|
|
9
|
+
* @param calendarEvent - The calendar event being RSVPed to
|
|
10
|
+
* @param status - The RSVP status (accepted, declined, tentative)
|
|
11
|
+
*/
|
|
12
|
+
static create(calendarEvent, status, relay) {
|
|
13
|
+
return new CalendarEventRSVPFactory((res) => res(blankEventTemplate(CALENDAR_EVENT_RSVP_KIND)))
|
|
14
|
+
.calendarEvent(calendarEvent, relay)
|
|
15
|
+
.status(status);
|
|
16
|
+
}
|
|
17
|
+
/** Creates a factory from an existing RSVP event for editing */
|
|
18
|
+
static modify(event) {
|
|
19
|
+
if (!isKind(event, CALENDAR_EVENT_RSVP_KIND))
|
|
20
|
+
throw new Error("Event is not a calendar event RSVP");
|
|
21
|
+
return new CalendarEventRSVPFactory((res) => res(toEventTemplate(event)));
|
|
22
|
+
}
|
|
23
|
+
/** Sets the pointer to the calendar event being RSVPed to */
|
|
24
|
+
calendarEvent(pointer, relay) {
|
|
25
|
+
return this.chain(CalendarRsvpOps.setCalendarEvent(pointer, relay));
|
|
26
|
+
}
|
|
27
|
+
/** Sets the RSVP status */
|
|
28
|
+
status(status) {
|
|
29
|
+
return this.chain(CalendarRsvpOps.setStatus(status));
|
|
30
|
+
}
|
|
31
|
+
/** Sets the free/busy status for the time slot */
|
|
32
|
+
freeBusy(freeBusy) {
|
|
33
|
+
return this.chain(CalendarRsvpOps.setFreeBusy(freeBusy));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { kinds, KnownEvent, KnownEventTemplate, NostrEvent } from "applesauce-core/helpers";
|
|
3
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
export type CalendarTemplate = KnownEventTemplate<kinds.Calendar>;
|
|
5
|
+
export declare class CalendarFactory extends EventFactory<kinds.Calendar, CalendarTemplate> {
|
|
6
|
+
/** Creates a new calendar event */
|
|
7
|
+
static create(title: string): CalendarFactory;
|
|
8
|
+
/** Modify a calendar event */
|
|
9
|
+
static modify(event: NostrEvent | KnownEvent<kinds.Calendar>): CalendarFactory;
|
|
10
|
+
/** Sets the title of the calendar */
|
|
11
|
+
title(title: string): this;
|
|
12
|
+
/** Adds a calendar event to the calendar */
|
|
13
|
+
addEvent(event: NostrEvent | AddressPointer): this;
|
|
14
|
+
/** Removes a calendar event from the calendar */
|
|
15
|
+
removeEvent(event: NostrEvent | AddressPointer): this;
|
|
16
|
+
/** Adds a hashtag "t" tag to the calendar */
|
|
17
|
+
addHashtag(hashtag: string): this;
|
|
18
|
+
/** Adds multiple hashtags as "t" tags */
|
|
19
|
+
hashtags(hashtags: string[]): this;
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { blankEventTemplate, EventFactory, toEventTemplate } from "applesauce-core/factories";
|
|
2
|
+
import { isKind, kinds } from "applesauce-core/helpers";
|
|
3
|
+
import { addEvent, removeEvent, setTitle } from "../operations/calendar.js";
|
|
4
|
+
import { addHashtag, includeHashtags } from "../operations/hashtags.js";
|
|
5
|
+
export class CalendarFactory extends EventFactory {
|
|
6
|
+
/** Creates a new calendar event */
|
|
7
|
+
static create(title) {
|
|
8
|
+
return new CalendarFactory((res) => res(blankEventTemplate(kinds.Calendar))).title(title);
|
|
9
|
+
}
|
|
10
|
+
/** Modify a calendar event */
|
|
11
|
+
static modify(event) {
|
|
12
|
+
if (!isKind(event, kinds.Calendar))
|
|
13
|
+
throw new Error("Event is not a calendar event");
|
|
14
|
+
return new CalendarFactory((res) => res(toEventTemplate(event)));
|
|
15
|
+
}
|
|
16
|
+
/** Sets the title of the calendar */
|
|
17
|
+
title(title) {
|
|
18
|
+
return this.chain(setTitle(title));
|
|
19
|
+
}
|
|
20
|
+
/** Adds a calendar event to the calendar */
|
|
21
|
+
addEvent(event) {
|
|
22
|
+
return this.chain(addEvent(event));
|
|
23
|
+
}
|
|
24
|
+
/** Removes a calendar event from the calendar */
|
|
25
|
+
removeEvent(event) {
|
|
26
|
+
return this.chain(removeEvent(event));
|
|
27
|
+
}
|
|
28
|
+
/** Adds a hashtag "t" tag to the calendar */
|
|
29
|
+
addHashtag(hashtag) {
|
|
30
|
+
return this.chain(addHashtag(hashtag));
|
|
31
|
+
}
|
|
32
|
+
/** Adds multiple hashtags as "t" tags */
|
|
33
|
+
hashtags(hashtags) {
|
|
34
|
+
return this.chain(includeHashtags(hashtags));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EventFactory } from "applesauce-core/factories";
|
|
2
|
+
import { KnownEventTemplate } from "applesauce-core/helpers";
|
|
3
|
+
import { MetaTagOptions } from "applesauce-core/operations/event";
|
|
4
|
+
import { CODE_SNIPPET_KIND } from "../helpers/code-snippet.js";
|
|
5
|
+
export type CodeSnippetTemplate = KnownEventTemplate<typeof CODE_SNIPPET_KIND>;
|
|
6
|
+
export type CodeSnippetOptions = MetaTagOptions & {
|
|
7
|
+
/** Programming language (lowercase) */
|
|
8
|
+
language?: string;
|
|
9
|
+
/** Filename or snippet name */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** File extension without the dot */
|
|
12
|
+
extension?: string;
|
|
13
|
+
/** Brief description of what the code does */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Runtime or environment specification */
|
|
16
|
+
runtime?: string;
|
|
17
|
+
/** SPDX license identifier(s) — repeatable for multi-licensing */
|
|
18
|
+
license?: string | string[];
|
|
19
|
+
/** Repository URL or NIP-34 address */
|
|
20
|
+
repo?: string;
|
|
21
|
+
/** Dependencies required to run the code */
|
|
22
|
+
dependencies?: string[];
|
|
23
|
+
};
|
|
24
|
+
/** A factory class for building NIP-C0 code snippet events (kind 1337) */
|
|
25
|
+
export declare class CodeSnippetFactory extends EventFactory<typeof CODE_SNIPPET_KIND, CodeSnippetTemplate> {
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new code snippet factory
|
|
28
|
+
* @param code - The code content
|
|
29
|
+
* @param options - Optional metadata (language, name, extension, description, runtime, licenses, repo, deps)
|
|
30
|
+
* @returns A new code snippet factory
|
|
31
|
+
*/
|
|
32
|
+
static create(code: string, options?: CodeSnippetOptions): CodeSnippetFactory;
|
|
33
|
+
/** Sets the code content */
|
|
34
|
+
code(code: string): this;
|
|
35
|
+
/** Sets the programming language (`l` tag) */
|
|
36
|
+
language(language: string): this;
|
|
37
|
+
/** Sets the snippet name, commonly a filename (`name` tag) */
|
|
38
|
+
name(name: string): this;
|
|
39
|
+
/** Sets the file extension without the dot (`extension` tag) */
|
|
40
|
+
extension(ext: string): this;
|
|
41
|
+
/** Sets the description (`description` tag) */
|
|
42
|
+
description(description: string): this;
|
|
43
|
+
/** Sets the runtime or environment specification (`runtime` tag) */
|
|
44
|
+
runtime(runtime: string): this;
|
|
45
|
+
/** Adds a license tag (repeatable for multi-licensing per NIP-C0) */
|
|
46
|
+
license(license: string | string[]): this;
|
|
47
|
+
/** Adds a license tag (repeatable for multi-licensing per NIP-C0) */
|
|
48
|
+
addLicense(license: string): this;
|
|
49
|
+
/** Removes a license tag */
|
|
50
|
+
removeLicense(license: string): this;
|
|
51
|
+
/** Sets the repository reference (`repo` tag); optionally a relay hint for NIP-34 addresses */
|
|
52
|
+
repo(repo: string, relayHint?: string): this;
|
|
53
|
+
/** Adds a dependency (`dep` tag) */
|
|
54
|
+
addDependency(dep: string): this;
|
|
55
|
+
/** Removes a dependency */
|
|
56
|
+
removeDependency(dep: string): this;
|
|
57
|
+
/** Sets all the dependency tags on a code snippet event */
|
|
58
|
+
dependencies(dependencies: string[]): this;
|
|
59
|
+
/** Adds a hashtag "t" tag to the code snippet */
|
|
60
|
+
addHashtag(hashtag: string): this;
|
|
61
|
+
/** Adds multiple hashtags as "t" tags */
|
|
62
|
+
hashtags(tags: string[]): this;
|
|
63
|
+
/** Sets meta tags */
|
|
64
|
+
meta(options: MetaTagOptions): this;
|
|
65
|
+
}
|