applesauce-common 5.1.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 -38
- package/dist/casts/user.js +106 -153
- 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 +4 -5
- package/dist/helpers/emoji.js +3 -15
- 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/models/thread.d.ts +1 -1
- package/dist/models/thread.js +23 -7
- 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 +13 -12
- 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
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* A symbol used to mark an Observable as chainable
|
|
4
|
-
*/
|
|
5
|
-
const CHAINABLE_CACHE_SYMBOL = Symbol.for("chainable-cache");
|
|
6
|
-
/**
|
|
7
|
-
* Wraps an Observable in a Proxy that enables property chaining.
|
|
8
|
-
* When accessing a property ending with `$`, it uses switchMap to chain
|
|
9
|
-
* to that property's observable value.
|
|
10
|
-
* When accessing a non-observable property, it returns an Observable of that property's value.
|
|
11
|
-
*/
|
|
12
|
-
export function chainable(observable) {
|
|
13
|
-
// Create a Proxy that intercepts property access
|
|
14
|
-
const proxy = new Proxy(observable, {
|
|
15
|
-
get(target$, prop) {
|
|
16
|
-
const cache = observable[CHAINABLE_CACHE_SYMBOL] ||
|
|
17
|
-
(observable[CHAINABLE_CACHE_SYMBOL] = {});
|
|
18
|
-
// Forward all Observable methods and properties
|
|
19
|
-
if (prop in target$ || typeof prop === "symbol") {
|
|
20
|
-
const value = target$[prop];
|
|
21
|
-
// If it's a function, bind it to the target
|
|
22
|
-
if (typeof value === "function")
|
|
23
|
-
return value.bind(target$);
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
if (typeof prop === "string") {
|
|
27
|
-
// Return cached observable if it exists
|
|
28
|
-
const cached = cache[prop];
|
|
29
|
-
if (cached)
|
|
30
|
-
return cached;
|
|
31
|
-
// Otherwise, create a new observable
|
|
32
|
-
let prop$;
|
|
33
|
-
// Extra observalbe helpers to make it easier to work with observables
|
|
34
|
-
if (prop === "$first") {
|
|
35
|
-
return (...args) => firstValueFrom(target$.pipe(filter((v) => v !== undefined && v !== null), args.length === 2
|
|
36
|
-
? timeout({ first: args[0], with: () => of(args[1]) })
|
|
37
|
-
: timeout({ first: args[0] ?? 10_000 })));
|
|
38
|
-
}
|
|
39
|
-
else if (prop === "$last") {
|
|
40
|
-
return (...args) => lastValueFrom(target$.pipe(filter((v) => v !== undefined && v !== null), args.length === 2
|
|
41
|
-
? timeout({ first: args[0], with: () => of(args[1]) })
|
|
42
|
-
: timeout({ first: args[0] ?? 10_000 })));
|
|
43
|
-
}
|
|
44
|
-
// Handle property access for properties ending with $
|
|
45
|
-
else if (prop.endsWith("$")) {
|
|
46
|
-
// Use switchMap to chain to the nested observable
|
|
47
|
-
prop$ = target$.pipe(switchMap((target) => {
|
|
48
|
-
const value = target === undefined || target === null ? target : target[prop];
|
|
49
|
-
// If value is an observable, return it
|
|
50
|
-
if (isObservable(value))
|
|
51
|
-
return value;
|
|
52
|
-
// Otherwise wrap it in an observable
|
|
53
|
-
else
|
|
54
|
-
return of(value);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
// For non-$ properties, return an Observable of the property value
|
|
58
|
-
else {
|
|
59
|
-
prop$ = target$.pipe(
|
|
60
|
-
// Access the property on the value if target is not undefined or null
|
|
61
|
-
map((target) => (target === undefined || target === null ? target : target[prop])));
|
|
62
|
-
}
|
|
63
|
-
// Make the chained observable chainable too
|
|
64
|
-
const observable = chainable(prop$);
|
|
65
|
-
cache[prop] = observable;
|
|
66
|
-
return observable;
|
|
67
|
-
}
|
|
68
|
-
throw new Error(`Unable to access property "${prop}" on chainable observable`);
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
return proxy;
|
|
72
|
-
}
|
|
1
|
+
// Re-exported from applesauce-core — chainable now lives in the core package
|
|
2
|
+
export { chainable } from "applesauce-core/observable";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { EncryptionMethod } from "applesauce-core/helpers/encrypted-content";
|
|
3
3
|
/** Sets the app data identifier */
|
|
4
4
|
export declare function setIdentifier(identifier: string): EventOperation;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Sets the content of an application data event
|
|
7
|
+
* @param data - Data to serialize and set as content
|
|
8
|
+
* @param encryption - Boolean or EncryptionMethod for encryption
|
|
9
|
+
* @param signer - EventSigner (required if encryption is enabled)
|
|
10
|
+
*/
|
|
11
|
+
export declare function setContent<T>(data: T, encryption?: boolean | EncryptionMethod, signer?: import("applesauce-core/factories").EventSigner): EventOperation;
|
|
@@ -5,14 +5,19 @@ import { includeSingletonTag } from "applesauce-core/operations/tags";
|
|
|
5
5
|
export function setIdentifier(identifier) {
|
|
6
6
|
return includeSingletonTag(["d", identifier]);
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Sets the content of an application data event
|
|
10
|
+
* @param data - Data to serialize and set as content
|
|
11
|
+
* @param encryption - Boolean or EncryptionMethod for encryption
|
|
12
|
+
* @param signer - EventSigner (required if encryption is enabled)
|
|
13
|
+
*/
|
|
14
|
+
export function setContent(data, encryption, signer) {
|
|
10
15
|
const json = JSON.stringify(data);
|
|
11
16
|
switch (typeof encryption) {
|
|
12
17
|
case "boolean":
|
|
13
|
-
return encryption ? setHiddenContent(json) : setPlaintextContent(json);
|
|
18
|
+
return encryption ? setHiddenContent(json, signer) : setPlaintextContent(json);
|
|
14
19
|
case "string":
|
|
15
|
-
return setHiddenContent(json, encryption);
|
|
20
|
+
return setHiddenContent(json, signer, encryption);
|
|
16
21
|
case "undefined":
|
|
17
22
|
return setPlaintextContent(json);
|
|
18
23
|
default:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { AddressPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
type RelayHint = string | ((value: string) => Promise<string | undefined>);
|
|
5
|
+
/** Replaces the badge definition pointer referenced by the award */
|
|
6
|
+
export declare function setBadgePointer(address: string | AddressPointer | NostrEvent, relayHint?: RelayHint): EventOperation;
|
|
7
|
+
/** Removes the badge definition pointer */
|
|
8
|
+
export declare function clearBadgePointer(): EventOperation;
|
|
9
|
+
/** Replaces all recipients with the provided list */
|
|
10
|
+
export declare function setRecipients(recipients: Array<string | ProfilePointer>): EventOperation;
|
|
11
|
+
/** Adds or replaces a single recipient */
|
|
12
|
+
export declare function addRecipient(recipient: string | ProfilePointer, relayHint?: RelayHint): EventOperation;
|
|
13
|
+
/** Removes a specific recipient */
|
|
14
|
+
export declare function removeRecipient(recipient: string | ProfilePointer): EventOperation;
|
|
15
|
+
/** Removes every recipient */
|
|
16
|
+
export declare function clearRecipients(): EventOperation;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { addAddressPointerTag, addProfilePointerTag, removeProfilePointerTag, } from "applesauce-core/operations/tag/common";
|
|
2
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
const removeAddressTags = (tags) => tags.filter((tag) => tag[0] !== "a");
|
|
4
|
+
const removeProfileTags = (tags) => tags.filter((tag) => tag[0] !== "p");
|
|
5
|
+
/** Replaces the badge definition pointer referenced by the award */
|
|
6
|
+
export function setBadgePointer(address, relayHint) {
|
|
7
|
+
return modifyPublicTags(removeAddressTags, addAddressPointerTag(address, relayHint, true));
|
|
8
|
+
}
|
|
9
|
+
/** Removes the badge definition pointer */
|
|
10
|
+
export function clearBadgePointer() {
|
|
11
|
+
return modifyPublicTags(removeAddressTags);
|
|
12
|
+
}
|
|
13
|
+
/** Replaces all recipients with the provided list */
|
|
14
|
+
export function setRecipients(recipients) {
|
|
15
|
+
const operations = recipients.map((recipient) => addProfilePointerTag(recipient, typeof recipient === "string" ? undefined : recipient.relays?.[0], true));
|
|
16
|
+
return modifyPublicTags(removeProfileTags, ...operations);
|
|
17
|
+
}
|
|
18
|
+
/** Adds or replaces a single recipient */
|
|
19
|
+
export function addRecipient(recipient, relayHint) {
|
|
20
|
+
const hint = relayHint || typeof recipient === "string" ? undefined : recipient.relays?.[0];
|
|
21
|
+
return modifyPublicTags(addProfilePointerTag(recipient, hint, true));
|
|
22
|
+
}
|
|
23
|
+
/** Removes a specific recipient */
|
|
24
|
+
export function removeRecipient(recipient) {
|
|
25
|
+
return modifyPublicTags(removeProfilePointerTag(recipient));
|
|
26
|
+
}
|
|
27
|
+
/** Removes every recipient */
|
|
28
|
+
export function clearRecipients() {
|
|
29
|
+
return modifyPublicTags(removeProfileTags);
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
type ImageDimensions = {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
};
|
|
6
|
+
/** Sets or replaces the badge identifier "d" tag */
|
|
7
|
+
export declare function setIdentifier(identifier: string): EventOperation;
|
|
8
|
+
/** Sets or removes the badge name */
|
|
9
|
+
export declare function setName(name: string | null): EventOperation;
|
|
10
|
+
/** Sets or removes the badge description */
|
|
11
|
+
export declare function setDescription(description: string | null): EventOperation;
|
|
12
|
+
/** Sets the hero image metadata */
|
|
13
|
+
export declare function setHeroImage(url: string, dimensions?: ImageDimensions): EventOperation;
|
|
14
|
+
/** Removes the hero image tag */
|
|
15
|
+
export declare function clearHeroImage(): EventOperation;
|
|
16
|
+
/** Adds or replaces a thumbnail entry */
|
|
17
|
+
export declare function addThumbnail(url: string, dimensions?: ImageDimensions): EventOperation;
|
|
18
|
+
/** Removes a thumbnail that matches the provided URL */
|
|
19
|
+
export declare function removeThumbnail(url: string): EventOperation;
|
|
20
|
+
/** Removes every thumbnail tag */
|
|
21
|
+
export declare function clearThumbnails(): EventOperation;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { addNameValueTag, removeNameValueTag, removeSingletonTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
|
|
2
|
+
import { includeSingletonTag, modifyPublicTags } from "applesauce-core/operations/tags";
|
|
3
|
+
/** Encodes image dimensions into a string */
|
|
4
|
+
function encodeDimensions(dimensions) {
|
|
5
|
+
if (!dimensions)
|
|
6
|
+
return undefined;
|
|
7
|
+
const width = typeof dimensions.width === "number" ? dimensions.width : undefined;
|
|
8
|
+
const height = typeof dimensions.height === "number" ? dimensions.height : undefined;
|
|
9
|
+
if (width === undefined && height === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
if (width !== undefined && height !== undefined)
|
|
12
|
+
return `${width}x${height}`;
|
|
13
|
+
if (width !== undefined)
|
|
14
|
+
return `${width}`;
|
|
15
|
+
return `x${height}`;
|
|
16
|
+
}
|
|
17
|
+
/** Creates an image tag with optional dimensions */
|
|
18
|
+
function createImageTag(key, url, dimensions) {
|
|
19
|
+
const size = encodeDimensions(dimensions);
|
|
20
|
+
return size ? [key, url, size] : [key, url];
|
|
21
|
+
}
|
|
22
|
+
/** Sets or replaces the badge identifier "d" tag */
|
|
23
|
+
export function setIdentifier(identifier) {
|
|
24
|
+
return includeSingletonTag(["d", identifier], true);
|
|
25
|
+
}
|
|
26
|
+
/** Sets or removes the badge name */
|
|
27
|
+
export function setName(name) {
|
|
28
|
+
return modifyPublicTags(name === null ? removeSingletonTag("name") : setSingletonTag(["name", name], true));
|
|
29
|
+
}
|
|
30
|
+
/** Sets or removes the badge description */
|
|
31
|
+
export function setDescription(description) {
|
|
32
|
+
return modifyPublicTags(description === null ? removeSingletonTag("description") : setSingletonTag(["description", description], true));
|
|
33
|
+
}
|
|
34
|
+
/** Sets the hero image metadata */
|
|
35
|
+
export function setHeroImage(url, dimensions) {
|
|
36
|
+
return includeSingletonTag(createImageTag("image", url, dimensions), true);
|
|
37
|
+
}
|
|
38
|
+
/** Removes the hero image tag */
|
|
39
|
+
export function clearHeroImage() {
|
|
40
|
+
return modifyPublicTags(removeSingletonTag("image"));
|
|
41
|
+
}
|
|
42
|
+
const thumbnailMatcher = (existing, incoming) => existing === incoming;
|
|
43
|
+
/** Adds or replaces a thumbnail entry */
|
|
44
|
+
export function addThumbnail(url, dimensions) {
|
|
45
|
+
return modifyPublicTags(addNameValueTag(createImageTag("thumb", url, dimensions), true, thumbnailMatcher));
|
|
46
|
+
}
|
|
47
|
+
/** Removes a thumbnail that matches the provided URL */
|
|
48
|
+
export function removeThumbnail(url) {
|
|
49
|
+
return modifyPublicTags(removeNameValueTag(["thumb", url]));
|
|
50
|
+
}
|
|
51
|
+
/** Removes every thumbnail tag */
|
|
52
|
+
export function clearThumbnails() {
|
|
53
|
+
return modifyPublicTags((tags) => tags.filter((tag) => tag[0] !== "thumb"));
|
|
54
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
/** Adds a server to a 10063 event */
|
|
3
3
|
export declare function addBlossomServer(url: string | URL, replace?: boolean): EventOperation;
|
|
4
4
|
/** Removes server matching the url from a 10063 event */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { CalendarEventParticipant } from "../helpers/calendar-event.js";
|
|
3
3
|
/** Sets the title of a calendar event */
|
|
4
4
|
export declare function setTitle(title: string): EventOperation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
4
|
import { RSVPFreeBusy, RSVPStatus } from "../helpers/calendar-rsvp.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
4
|
/** Sets the title of a calendar */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
/** Includes the "e" tag referencing the channel creating event */
|
|
4
4
|
export declare function includeChannelPointerTag(channel: NostrEvent): EventOperation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
3
3
|
/** Includes a NIP-89 client tag in an event*/
|
|
4
4
|
export declare function setClient(name: string, pointer?: Omit<AddressPointer, "kind" | "relays">, replace?: boolean): EventOperation;
|
|
@@ -6,7 +6,7 @@ import { includeSingletonTag } from "applesauce-core/operations/tags";
|
|
|
6
6
|
const NEVER_ATTACH_CLIENT_TAG = [kinds.EncryptedDirectMessage, kinds.GiftWrap, kinds.Seal];
|
|
7
7
|
/** Includes a NIP-89 client tag in an event*/
|
|
8
8
|
export function setClient(name, pointer, replace = true) {
|
|
9
|
-
return (draft
|
|
9
|
+
return (draft) => {
|
|
10
10
|
if (NEVER_ATTACH_CLIENT_TAG.includes(draft.kind))
|
|
11
11
|
return draft;
|
|
12
12
|
else {
|
|
@@ -17,7 +17,7 @@ export function setClient(name, pointer, replace = true) {
|
|
|
17
17
|
kind: kinds.Handlerinformation,
|
|
18
18
|
})
|
|
19
19
|
: undefined;
|
|
20
|
-
return includeSingletonTag(fillAndTrimTag(["client", name, coordinate]), replace)(draft
|
|
20
|
+
return includeSingletonTag(fillAndTrimTag(["client", name, coordinate]), replace)(draft);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
/** Sets the code snippet content */
|
|
3
|
+
export declare function setCodeSnippetContent(code: string): EventOperation;
|
|
4
|
+
/** Sets the programming language tag (`l`) */
|
|
5
|
+
export declare function setCodeSnippetLanguage(language: string): EventOperation;
|
|
6
|
+
/** Sets the name tag (commonly a filename) */
|
|
7
|
+
export declare function setCodeSnippetName(name: string): EventOperation;
|
|
8
|
+
/** Sets the file extension tag (without the dot) */
|
|
9
|
+
export declare function setCodeSnippetExtension(extension: string): EventOperation;
|
|
10
|
+
/** Sets the description tag */
|
|
11
|
+
export declare function setCodeSnippetDescription(description: string): EventOperation;
|
|
12
|
+
/** Sets the runtime tag */
|
|
13
|
+
export declare function setCodeSnippetRuntime(runtime: string): EventOperation;
|
|
14
|
+
/** Adds a license tag (can be repeated for multi-licensing per NIP-C0) */
|
|
15
|
+
export declare function addCodeSnippetLicense(license: string): EventOperation;
|
|
16
|
+
/** Removes a specific license tag by value */
|
|
17
|
+
export declare function removeCodeSnippetLicense(license: string): EventOperation;
|
|
18
|
+
/** Sets the license tags on a code snippet event */
|
|
19
|
+
export declare function setCodeSnippetLicense(license: string | string[]): EventOperation;
|
|
20
|
+
/** Sets the repo tag (URL or NIP-34 address) */
|
|
21
|
+
export declare function setCodeSnippetRepo(repo: string, relayHint?: string): EventOperation;
|
|
22
|
+
/** Adds a dependency tag (`dep`) */
|
|
23
|
+
export declare function addCodeSnippetDependency(dep: string): EventOperation;
|
|
24
|
+
/** Removes a dependency tag */
|
|
25
|
+
export declare function removeCodeSnippetDependency(dep: string): EventOperation;
|
|
26
|
+
/** Sets all the dependency tags on a code snippet event */
|
|
27
|
+
export declare function setCodeSnippetDependencies(dependencies: string[]): EventOperation;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { setContent } from "applesauce-core/operations/content";
|
|
2
|
+
import { addNameValueTag, removeNameValueTag, setSingletonTag } from "applesauce-core/operations/tag/common";
|
|
3
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
4
|
+
/** Sets the code snippet content */
|
|
5
|
+
export function setCodeSnippetContent(code) {
|
|
6
|
+
return setContent(code);
|
|
7
|
+
}
|
|
8
|
+
/** Sets the programming language tag (`l`) */
|
|
9
|
+
export function setCodeSnippetLanguage(language) {
|
|
10
|
+
return modifyPublicTags(setSingletonTag(["l", language]));
|
|
11
|
+
}
|
|
12
|
+
/** Sets the name tag (commonly a filename) */
|
|
13
|
+
export function setCodeSnippetName(name) {
|
|
14
|
+
return modifyPublicTags(setSingletonTag(["name", name]));
|
|
15
|
+
}
|
|
16
|
+
/** Sets the file extension tag (without the dot) */
|
|
17
|
+
export function setCodeSnippetExtension(extension) {
|
|
18
|
+
return modifyPublicTags(setSingletonTag(["extension", extension]));
|
|
19
|
+
}
|
|
20
|
+
/** Sets the description tag */
|
|
21
|
+
export function setCodeSnippetDescription(description) {
|
|
22
|
+
return modifyPublicTags(setSingletonTag(["description", description]));
|
|
23
|
+
}
|
|
24
|
+
/** Sets the runtime tag */
|
|
25
|
+
export function setCodeSnippetRuntime(runtime) {
|
|
26
|
+
return modifyPublicTags(setSingletonTag(["runtime", runtime]));
|
|
27
|
+
}
|
|
28
|
+
/** Adds a license tag (can be repeated for multi-licensing per NIP-C0) */
|
|
29
|
+
export function addCodeSnippetLicense(license) {
|
|
30
|
+
return modifyPublicTags(addNameValueTag(["license", license], false));
|
|
31
|
+
}
|
|
32
|
+
/** Removes a specific license tag by value */
|
|
33
|
+
export function removeCodeSnippetLicense(license) {
|
|
34
|
+
return modifyPublicTags(removeNameValueTag(["license", license]));
|
|
35
|
+
}
|
|
36
|
+
/** Sets the license tags on a code snippet event */
|
|
37
|
+
export function setCodeSnippetLicense(license) {
|
|
38
|
+
if (Array.isArray(license)) {
|
|
39
|
+
return modifyPublicTags((tags) => [
|
|
40
|
+
...tags.filter((t) => t[0] !== "license"),
|
|
41
|
+
...license.map((l) => ["license", l]),
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return modifyPublicTags(setSingletonTag(["license", license]));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Sets the repo tag (URL or NIP-34 address) */
|
|
49
|
+
export function setCodeSnippetRepo(repo, relayHint) {
|
|
50
|
+
return modifyPublicTags(setSingletonTag(relayHint ? ["repo", repo, relayHint] : ["repo", repo]));
|
|
51
|
+
}
|
|
52
|
+
/** Adds a dependency tag (`dep`) */
|
|
53
|
+
export function addCodeSnippetDependency(dep) {
|
|
54
|
+
return modifyPublicTags(addNameValueTag(["dep", dep], false));
|
|
55
|
+
}
|
|
56
|
+
/** Removes a dependency tag */
|
|
57
|
+
export function removeCodeSnippetDependency(dep) {
|
|
58
|
+
return modifyPublicTags(removeNameValueTag(["dep", dep]));
|
|
59
|
+
}
|
|
60
|
+
/** Sets all the dependency tags on a code snippet event */
|
|
61
|
+
export function setCodeSnippetDependencies(dependencies) {
|
|
62
|
+
return modifyPublicTags((tags) => [...tags.filter((t) => t[0] !== "dep"), ...dependencies.map((d) => ["dep", d])]);
|
|
63
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { CommentPointer } from "../helpers/comment.js";
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Sets the necessary tags for a NIP-22 comment event to point to a parent event or pointer
|
|
6
|
+
* @param parent - Parent event or comment pointer
|
|
7
|
+
* @param getRelayHint - Optional function to get relay hint for event ID
|
|
8
|
+
*/
|
|
9
|
+
export declare function setParent(parent: NostrEvent | CommentPointer, getRelayHint?: (eventId: string) => Promise<string | undefined>): EventOperation;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { isEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { COMMENT_KIND, createCommentTagsForEvent, createCommentTagsFromCommentPointer, } from "../helpers/comment.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Sets the necessary tags for a NIP-22 comment event to point to a parent event or pointer
|
|
5
|
+
* @param parent - Parent event or comment pointer
|
|
6
|
+
* @param getRelayHint - Optional function to get relay hint for event ID
|
|
7
|
+
*/
|
|
8
|
+
export function setParent(parent, getRelayHint) {
|
|
9
|
+
return async (draft) => {
|
|
6
10
|
let tags = Array.from(draft.tags);
|
|
7
11
|
// If parent is a CommentPointer (not a NostrEvent), handle it directly
|
|
8
12
|
if (!isEvent(parent)) {
|
|
@@ -17,7 +21,7 @@ export function setParent(parent) {
|
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
23
|
// If parent is a NostrEvent, use existing logic
|
|
20
|
-
const relayHint = await
|
|
24
|
+
const relayHint = getRelayHint ? await getRelayHint(parent.id) : undefined;
|
|
21
25
|
tags.push(...createCommentTagsForEvent(parent, relayHint));
|
|
22
26
|
}
|
|
23
27
|
return { ...draft, tags };
|
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
2
|
-
import {
|
|
3
|
-
/** Sets
|
|
4
|
-
export declare function
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
|
+
import { FileMetadataFields } from "../helpers/file-metadata.js";
|
|
3
|
+
/** Sets or removes the file URL */
|
|
4
|
+
export declare function setFileURL(url: string | null): EventOperation;
|
|
5
|
+
/** Sets or removes the file MIME type */
|
|
6
|
+
export declare function setFileType(type: string | null): EventOperation;
|
|
7
|
+
/** Sets or removes the file SHA-256 hash */
|
|
8
|
+
export declare function setFileSHA256(hash: string | null): EventOperation;
|
|
9
|
+
/** Sets or removes the original file SHA-256 hash */
|
|
10
|
+
export declare function setOriginalFileSHA256(hash: string | null): EventOperation;
|
|
11
|
+
/** Sets or removes the file size */
|
|
12
|
+
export declare function setFileSize(size: number | null): EventOperation;
|
|
13
|
+
/** Sets or removes the file dimensions */
|
|
14
|
+
export declare function setFileDimensions(dimensions: string | null): EventOperation;
|
|
15
|
+
/** Sets or removes the magnet URI */
|
|
16
|
+
export declare function setFileMagnet(magnet: string | null): EventOperation;
|
|
17
|
+
/** Sets or removes the torrent infohash */
|
|
18
|
+
export declare function setFileInfohash(infohash: string | null): EventOperation;
|
|
19
|
+
/** Sets or removes the thumbnail URL */
|
|
20
|
+
export declare function setFileThumbnail(url: string | null): EventOperation;
|
|
21
|
+
/** Sets or removes the preview image URL */
|
|
22
|
+
export declare function setFileImage(url: string | null): EventOperation;
|
|
23
|
+
/** Sets or removes the summary */
|
|
24
|
+
export declare function setFileSummary(summary: string | null): EventOperation;
|
|
25
|
+
/** Sets or removes the alt text */
|
|
26
|
+
export declare function setFileAlt(alt: string | null): EventOperation;
|
|
27
|
+
/** Sets or removes the blurhash */
|
|
28
|
+
export declare function setFileBlurhash(blurhash: string | null): EventOperation;
|
|
29
|
+
/** Adds a fallback URL */
|
|
30
|
+
export declare function addFallbackURL(url: string, replace?: boolean): EventOperation;
|
|
31
|
+
/** Removes a matching fallback URL */
|
|
32
|
+
export declare function removeFallbackURL(url: string): EventOperation;
|
|
33
|
+
/** Removes all fallback URLs */
|
|
34
|
+
export declare function clearFallbackURLs(): EventOperation;
|
|
35
|
+
/** Replaces all fallback URLs with the provided list */
|
|
36
|
+
export declare function setFallbackURLs(urls: string[]): EventOperation;
|
|
37
|
+
/** Sets all NIP-94 tags for {@link FileMetadataFields} */
|
|
38
|
+
export declare function setFileMetadata(metadata: FileMetadataFields): EventOperation;
|
|
@@ -1,21 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { eventPipe } from "applesauce-core/helpers";
|
|
2
|
+
import { addNameValueTag, removeNameValueTag, removeSingletonTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
|
|
3
|
+
import { modifyPublicTags } from "applesauce-core/operations/tags";
|
|
4
|
+
function setNullableSingletonTag(name, value) {
|
|
5
|
+
return modifyPublicTags(value === null ? removeSingletonTag(name) : setSingletonTag([name, String(value)], true));
|
|
6
|
+
}
|
|
7
|
+
/** Sets or removes the file URL */
|
|
8
|
+
export function setFileURL(url) {
|
|
9
|
+
return setNullableSingletonTag("url", url);
|
|
10
|
+
}
|
|
11
|
+
/** Sets or removes the file MIME type */
|
|
12
|
+
export function setFileType(type) {
|
|
13
|
+
return setNullableSingletonTag("m", type);
|
|
14
|
+
}
|
|
15
|
+
/** Sets or removes the file SHA-256 hash */
|
|
16
|
+
export function setFileSHA256(hash) {
|
|
17
|
+
return setNullableSingletonTag("x", hash);
|
|
18
|
+
}
|
|
19
|
+
/** Sets or removes the original file SHA-256 hash */
|
|
20
|
+
export function setOriginalFileSHA256(hash) {
|
|
21
|
+
return setNullableSingletonTag("ox", hash);
|
|
22
|
+
}
|
|
23
|
+
/** Sets or removes the file size */
|
|
24
|
+
export function setFileSize(size) {
|
|
25
|
+
return setNullableSingletonTag("size", size);
|
|
26
|
+
}
|
|
27
|
+
/** Sets or removes the file dimensions */
|
|
28
|
+
export function setFileDimensions(dimensions) {
|
|
29
|
+
return setNullableSingletonTag("dim", dimensions);
|
|
30
|
+
}
|
|
31
|
+
/** Sets or removes the magnet URI */
|
|
32
|
+
export function setFileMagnet(magnet) {
|
|
33
|
+
return setNullableSingletonTag("magnet", magnet);
|
|
34
|
+
}
|
|
35
|
+
/** Sets or removes the torrent infohash */
|
|
36
|
+
export function setFileInfohash(infohash) {
|
|
37
|
+
return setNullableSingletonTag("i", infohash);
|
|
38
|
+
}
|
|
39
|
+
/** Sets or removes the thumbnail URL */
|
|
40
|
+
export function setFileThumbnail(url) {
|
|
41
|
+
return setNullableSingletonTag("thumb", url);
|
|
42
|
+
}
|
|
43
|
+
/** Sets or removes the preview image URL */
|
|
44
|
+
export function setFileImage(url) {
|
|
45
|
+
return setNullableSingletonTag("image", url);
|
|
46
|
+
}
|
|
47
|
+
/** Sets or removes the summary */
|
|
48
|
+
export function setFileSummary(summary) {
|
|
49
|
+
return setNullableSingletonTag("summary", summary);
|
|
50
|
+
}
|
|
51
|
+
/** Sets or removes the alt text */
|
|
52
|
+
export function setFileAlt(alt) {
|
|
53
|
+
return setNullableSingletonTag("alt", alt);
|
|
54
|
+
}
|
|
55
|
+
/** Sets or removes the blurhash */
|
|
56
|
+
export function setFileBlurhash(blurhash) {
|
|
57
|
+
return setNullableSingletonTag("blurhash", blurhash);
|
|
58
|
+
}
|
|
59
|
+
/** Adds a fallback URL */
|
|
60
|
+
export function addFallbackURL(url, replace = true) {
|
|
61
|
+
return modifyPublicTags(addNameValueTag(["fallback", url], replace));
|
|
62
|
+
}
|
|
63
|
+
/** Removes a matching fallback URL */
|
|
64
|
+
export function removeFallbackURL(url) {
|
|
65
|
+
return modifyPublicTags(removeNameValueTag(["fallback", url]));
|
|
66
|
+
}
|
|
67
|
+
/** Removes all fallback URLs */
|
|
68
|
+
export function clearFallbackURLs() {
|
|
69
|
+
return modifyPublicTags((tags) => tags.filter((tag) => tag[0] !== "fallback"));
|
|
70
|
+
}
|
|
71
|
+
/** Replaces all fallback URLs with the provided list */
|
|
72
|
+
export function setFallbackURLs(urls) {
|
|
73
|
+
return eventPipe(clearFallbackURLs(), ...urls.map((url) => addFallbackURL(url, false)));
|
|
74
|
+
}
|
|
75
|
+
/** Sets all NIP-94 tags for {@link FileMetadataFields} */
|
|
4
76
|
export function setFileMetadata(metadata) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
77
|
+
const operations = [];
|
|
78
|
+
if ("url" in metadata)
|
|
79
|
+
operations.push(setFileURL(metadata.url ?? null));
|
|
80
|
+
if ("type" in metadata)
|
|
81
|
+
operations.push(setFileType(metadata.type ?? null));
|
|
82
|
+
if ("sha256" in metadata)
|
|
83
|
+
operations.push(setFileSHA256(metadata.sha256 ?? null));
|
|
84
|
+
if ("originalSha256" in metadata)
|
|
85
|
+
operations.push(setOriginalFileSHA256(metadata.originalSha256 ?? null));
|
|
86
|
+
if ("size" in metadata)
|
|
87
|
+
operations.push(setFileSize(metadata.size ?? null));
|
|
88
|
+
if ("dimensions" in metadata)
|
|
89
|
+
operations.push(setFileDimensions(metadata.dimensions ?? null));
|
|
90
|
+
if ("magnet" in metadata)
|
|
91
|
+
operations.push(setFileMagnet(metadata.magnet ?? null));
|
|
92
|
+
if ("infohash" in metadata)
|
|
93
|
+
operations.push(setFileInfohash(metadata.infohash ?? null));
|
|
94
|
+
if ("thumbnail" in metadata)
|
|
95
|
+
operations.push(setFileThumbnail(metadata.thumbnail ?? null));
|
|
96
|
+
if ("image" in metadata)
|
|
97
|
+
operations.push(setFileImage(metadata.image ?? null));
|
|
98
|
+
if ("summary" in metadata)
|
|
99
|
+
operations.push(setFileSummary(metadata.summary ?? null));
|
|
100
|
+
if ("alt" in metadata)
|
|
101
|
+
operations.push(setFileAlt(metadata.alt ?? null));
|
|
102
|
+
if ("blurhash" in metadata)
|
|
103
|
+
operations.push(setFileBlurhash(metadata.blurhash ?? null));
|
|
104
|
+
if ("fallback" in metadata)
|
|
105
|
+
operations.push(setFallbackURLs(metadata.fallback ?? []));
|
|
106
|
+
return eventPipe(...operations);
|
|
21
107
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventOperation } from "applesauce-core/
|
|
1
|
+
import { EventOperation } from "applesauce-core/factories";
|
|
2
2
|
/** Adds all "g" geohash tags for a given geohash or removes them if null */
|
|
3
3
|
export declare function setGeohash(geohash: string | null): EventOperation;
|
|
4
4
|
/** Removes all "g" geohash tags from an event */
|