applesauce-common 6.0.0 → 6.0.1

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.
@@ -5,12 +5,12 @@ import { MetaTagOptions } from "applesauce-core/operations/event";
5
5
  import { COMMENT_KIND, CommentPointer } from "../helpers/comment.js";
6
6
  import { GroupPointer } from "../helpers/groups.js";
7
7
  export type CommentTemplate = KnownEventTemplate<typeof COMMENT_KIND>;
8
- export type CommentBlueprintOptions = TextContentOptions & MetaTagOptions;
8
+ export type CommentFactoryOptions = TextContentOptions & MetaTagOptions;
9
9
  export declare class CommentFactory extends EventFactory<typeof COMMENT_KIND, CommentTemplate> {
10
10
  /** Creates a new comment event */
11
- static create(parent: NostrEvent | CommentPointer, content: string, options?: CommentBlueprintOptions): CommentFactory;
11
+ static create(parent: NostrEvent | CommentPointer, content: string, options?: CommentFactoryOptions): CommentFactory;
12
12
  /** Creates a new comment that is replying to a parent event or pointer */
13
- static reply(parent: NostrEvent | CommentPointer, content: string, options?: CommentBlueprintOptions): CommentFactory;
13
+ static reply(parent: NostrEvent | CommentPointer, content: string, options?: CommentFactoryOptions): CommentFactory;
14
14
  /** Sets the parent event or pointer that this comment is replying to */
15
15
  parent(parent: NostrEvent | CommentPointer): this;
16
16
  /** Sets the text content of the comment */
@@ -5,22 +5,24 @@ import { MetaTagOptions } from "applesauce-core/operations/event";
5
5
  import { ProfilePointer } from "applesauce-core/helpers/pointers";
6
6
  import { ZapOptions } from "../operations/zap-split.js";
7
7
  export type NoteTemplate = KnownEventTemplate<kinds.ShortTextNote>;
8
- export type NoteBlueprintOptions = TextContentOptions & MetaTagOptions & ZapOptions;
8
+ export type NoteFactoryOptions = TextContentOptions & MetaTagOptions & ZapOptions;
9
9
  /** A factory class for building kind 1 short text note events */
10
10
  export declare class NoteFactory extends EventFactory<kinds.ShortTextNote, NoteTemplate> {
11
11
  /**
12
12
  * Creates a new note factory
13
13
  * @param content - Optional initial content
14
+ * @param opts - Optional factory options
14
15
  * @returns A new note factory
15
16
  */
16
- static create(content?: string): NoteFactory;
17
+ static create(content?: string, opts?: NoteFactoryOptions): NoteFactory;
17
18
  /**
18
19
  * Creates a note reply factory
19
20
  * @param parent - The parent note to reply to
20
21
  * @param content - Optional initial content
22
+ * @param opts - Optional factory options
21
23
  * @returns A new note factory configured as a reply
22
24
  */
23
- static reply(parent: NostrEvent, content?: string): NoteFactory;
25
+ static reply(parent: NostrEvent, content?: string, opts?: NoteFactoryOptions): NoteFactory;
24
26
  /** Sets the parent note for NIP-10 threading */
25
27
  replyTo(parent: NostrEvent): this;
26
28
  /** Sets the text content with optional formatting */
@@ -11,23 +11,31 @@ export class NoteFactory extends EventFactory {
11
11
  /**
12
12
  * Creates a new note factory
13
13
  * @param content - Optional initial content
14
+ * @param opts - Optional factory options
14
15
  * @returns A new note factory
15
16
  */
16
- static create(content) {
17
- const factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote)));
18
- return content ? factory.text(content) : factory;
17
+ static create(content, opts) {
18
+ let factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote)));
19
+ factory = content ? factory.text(content, opts) : factory;
20
+ if (opts)
21
+ factory = factory.meta(opts).zapSplit(opts);
22
+ return factory;
19
23
  }
20
24
  /**
21
25
  * Creates a note reply factory
22
26
  * @param parent - The parent note to reply to
23
27
  * @param content - Optional initial content
28
+ * @param opts - Optional factory options
24
29
  * @returns A new note factory configured as a reply
25
30
  */
26
- static reply(parent, content) {
31
+ static reply(parent, content, opts) {
27
32
  if (!isKind(parent, kinds.ShortTextNote))
28
33
  throw new Error("Kind 1 replies should only be used to reply to kind 1 notes");
29
- const factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote))).replyTo(parent);
30
- return content ? factory.text(content) : factory;
34
+ let factory = new NoteFactory((res) => res(blankEventTemplate(kinds.ShortTextNote))).replyTo(parent);
35
+ factory = content ? factory.text(content, opts) : factory;
36
+ if (opts)
37
+ factory = factory.meta(opts).zapSplit(opts);
38
+ return factory;
31
39
  }
32
40
  /** Sets the parent note for NIP-10 threading */
33
41
  replyTo(parent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-common",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Common NIP-specific helpers and models for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",