@lovelaces-io/storyteller 0.3.0 → 0.3.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.
- package/AGENTS.md +1 -1
- package/dist/index.cjs +3 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -22
- package/dist/index.d.ts +26 -22
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -254,22 +254,26 @@ type NoteEmission = StoryNote & {
|
|
|
254
254
|
origin?: StoryOrigin;
|
|
255
255
|
};
|
|
256
256
|
type Emission = NoteEmission | StoryEvent;
|
|
257
|
-
type
|
|
257
|
+
/** The emission type an audience receives, given the kinds it hears */
|
|
258
|
+
type EmissionOf<Kind extends EmissionKind> = Kind extends "note" ? NoteEmission : StoryEvent;
|
|
259
|
+
/**
|
|
260
|
+
* An audience, typed by what it hears.
|
|
261
|
+
*
|
|
262
|
+
* With no `hears`, it hears stories only and `accepts`/`hear` receive a
|
|
263
|
+
* `StoryEvent` — so an audience written before live narration existed compiles
|
|
264
|
+
* unchanged, including one that hands the event to a helper typed for
|
|
265
|
+
* `StoryEvent`. `hears: ["note"]` gives `NoteEmission`; `["note", "story"]`
|
|
266
|
+
* gives the union, and the code narrows on `kind`.
|
|
267
|
+
*/
|
|
268
|
+
type AudienceMember<Kind extends EmissionKind = "story"> = {
|
|
258
269
|
name: string;
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
hears?: EmissionKind[];
|
|
264
|
-
/**
|
|
265
|
-
* Declared with method syntax deliberately. TypeScript checks method parameters
|
|
266
|
-
* bivariantly, so an audience written as `hear: (event: StoryEvent) => void`
|
|
267
|
-
* still compiles. That would be unsound if such an audience could receive a note
|
|
268
|
-
* emission — it cannot, because `hears` defaults to stories only.
|
|
269
|
-
*/
|
|
270
|
-
accepts?(emission: Emission): boolean;
|
|
271
|
-
hear(emission: Emission): void | Promise<void>;
|
|
270
|
+
/** Which emission kinds this audience wants. Defaults to `["story"]`. */
|
|
271
|
+
hears?: Kind[];
|
|
272
|
+
accepts?(emission: EmissionOf<Kind>): boolean;
|
|
273
|
+
hear(emission: EmissionOf<Kind>): void | Promise<void>;
|
|
272
274
|
};
|
|
275
|
+
/** Any audience, whatever it hears — the shape the registry stores */
|
|
276
|
+
type AnyAudienceMember = AudienceMember<EmissionKind>;
|
|
273
277
|
/**
|
|
274
278
|
* How a storyteller narrates.
|
|
275
279
|
*
|
|
@@ -314,7 +318,7 @@ type ChapterOptions = {
|
|
|
314
318
|
};
|
|
315
319
|
type StorytellerOptions = {
|
|
316
320
|
origin?: StoryOriginInput;
|
|
317
|
-
audiences?:
|
|
321
|
+
audiences?: AnyAudienceMember[];
|
|
318
322
|
/** Defaults to `STORYTELLER_NARRATION`, then `collected` */
|
|
319
323
|
narration?: NarrationInput;
|
|
320
324
|
/**
|
|
@@ -349,18 +353,18 @@ type StorytellerOptions = {
|
|
|
349
353
|
maxInFlight?: number;
|
|
350
354
|
};
|
|
351
355
|
/** Called when an audience member throws or rejects while hearing an emission */
|
|
352
|
-
type AudienceErrorHandler = (error: unknown, member:
|
|
356
|
+
type AudienceErrorHandler = (error: unknown, member: AnyAudienceMember, emission: Emission) => void;
|
|
353
357
|
/** Manages the set of audience members that receive story events */
|
|
354
358
|
declare class AudienceRegistry {
|
|
355
359
|
private members;
|
|
356
360
|
/** Register an audience member, replacing any existing member with the same name */
|
|
357
|
-
add(member: AudienceMember): this;
|
|
361
|
+
add<Kind extends EmissionKind = "story">(member: AudienceMember<Kind>): this;
|
|
358
362
|
/** Remove an audience member by name */
|
|
359
363
|
remove(name: string): this;
|
|
360
364
|
/** Return all registered audience members */
|
|
361
|
-
getAll():
|
|
365
|
+
getAll(): AnyAudienceMember[];
|
|
362
366
|
/** Return only the audience members matching the given names */
|
|
363
|
-
getOnly(names: string[]):
|
|
367
|
+
getOnly(names: string[]): AnyAudienceMember[];
|
|
364
368
|
/** Check if an audience member is registered by name */
|
|
365
369
|
has(name: string): boolean;
|
|
366
370
|
/** List the names of all registered audience members */
|
|
@@ -570,7 +574,7 @@ type ConsoleAudienceOptions = {
|
|
|
570
574
|
* story.audience.add(consoleAudience());
|
|
571
575
|
* ```
|
|
572
576
|
*/
|
|
573
|
-
declare function consoleAudience(options?: ConsoleAudienceOptions): AudienceMember
|
|
577
|
+
declare function consoleAudience(options?: ConsoleAudienceOptions): AudienceMember<EmissionKind>;
|
|
574
578
|
|
|
575
579
|
/**
|
|
576
580
|
* Create an audience that stores warn and oops stories via your insert function.
|
|
@@ -623,7 +627,7 @@ type NdjsonAudienceOptions = {
|
|
|
623
627
|
* story.audience.add(ndjsonAudience({ stream: process.stderr }));
|
|
624
628
|
* ```
|
|
625
629
|
*/
|
|
626
|
-
declare function ndjsonAudience(options?: NdjsonAudienceOptions): AudienceMember
|
|
630
|
+
declare function ndjsonAudience(options?: NdjsonAudienceOptions): AudienceMember<EmissionKind>;
|
|
627
631
|
|
|
628
632
|
type StoryReportOptions = {
|
|
629
633
|
timezone?: string;
|
|
@@ -664,4 +668,4 @@ declare function summarizeContext(note: {
|
|
|
664
668
|
error?: StoryError;
|
|
665
669
|
}): string | undefined;
|
|
666
670
|
|
|
667
|
-
export { ANSI, type AudienceErrorHandler, type AudienceMember, AudienceRegistry, type ChapterOptions, type ConsoleAudienceOptions, DEFAULT_REDACT_KEYS, type Emission, type EmissionKind, type FinishOptions, type FormattedReport, type JsonValue, type LevelInput, type LineWriter, type Narration, type NarrationInput, type NdjsonAudienceOptions, type NormalizeOptions, type NoteData, type NoteEmission, type OutputFormat, type PreviewOptions, REDACTED, type ReportNote, type ReportOptions, type StoryContextInput, type StoryContextValue, type StoryEmission, type StoryError, type StoryEvent, type StoryEventBase, type StoryLevel, type StoryNote, type StoryOrigin, type StoryOriginInput, type StoryPreviewOptions, type StoryReport, type StoryReportOptions, type StorySummary, type StorySummaryData, type StorySummaryNote, type StorySummaryOptions, Storyteller, type StorytellerOptions, consoleAudience, dbAudience, formatDuration, formatOrigin, formatStory, getLevelColor, meetsLevel, ndjsonAudience, normalizeError, normalizeValue, readEnvironmentValue, resolveColors, resolveMinimumLevel, resolveOutputFormat, summarizeContext, summarizeStory, toStoryLevel, useStoryteller, writeStoryReport };
|
|
671
|
+
export { ANSI, type AnyAudienceMember, type AudienceErrorHandler, type AudienceMember, AudienceRegistry, type ChapterOptions, type ConsoleAudienceOptions, DEFAULT_REDACT_KEYS, type Emission, type EmissionKind, type EmissionOf, type FinishOptions, type FormattedReport, type JsonValue, type LevelInput, type LineWriter, type Narration, type NarrationInput, type NdjsonAudienceOptions, type NormalizeOptions, type NoteData, type NoteEmission, type OutputFormat, type PreviewOptions, REDACTED, type ReportNote, type ReportOptions, type StoryContextInput, type StoryContextValue, type StoryEmission, type StoryError, type StoryEvent, type StoryEventBase, type StoryLevel, type StoryNote, type StoryOrigin, type StoryOriginInput, type StoryPreviewOptions, type StoryReport, type StoryReportOptions, type StorySummary, type StorySummaryData, type StorySummaryNote, type StorySummaryOptions, Storyteller, type StorytellerOptions, consoleAudience, dbAudience, formatDuration, formatOrigin, formatStory, getLevelColor, meetsLevel, ndjsonAudience, normalizeError, normalizeValue, readEnvironmentValue, resolveColors, resolveMinimumLevel, resolveOutputFormat, summarizeContext, summarizeStory, toStoryLevel, useStoryteller, writeStoryReport };
|
package/dist/index.d.ts
CHANGED
|
@@ -254,22 +254,26 @@ type NoteEmission = StoryNote & {
|
|
|
254
254
|
origin?: StoryOrigin;
|
|
255
255
|
};
|
|
256
256
|
type Emission = NoteEmission | StoryEvent;
|
|
257
|
-
type
|
|
257
|
+
/** The emission type an audience receives, given the kinds it hears */
|
|
258
|
+
type EmissionOf<Kind extends EmissionKind> = Kind extends "note" ? NoteEmission : StoryEvent;
|
|
259
|
+
/**
|
|
260
|
+
* An audience, typed by what it hears.
|
|
261
|
+
*
|
|
262
|
+
* With no `hears`, it hears stories only and `accepts`/`hear` receive a
|
|
263
|
+
* `StoryEvent` — so an audience written before live narration existed compiles
|
|
264
|
+
* unchanged, including one that hands the event to a helper typed for
|
|
265
|
+
* `StoryEvent`. `hears: ["note"]` gives `NoteEmission`; `["note", "story"]`
|
|
266
|
+
* gives the union, and the code narrows on `kind`.
|
|
267
|
+
*/
|
|
268
|
+
type AudienceMember<Kind extends EmissionKind = "story"> = {
|
|
258
269
|
name: string;
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
hears?: EmissionKind[];
|
|
264
|
-
/**
|
|
265
|
-
* Declared with method syntax deliberately. TypeScript checks method parameters
|
|
266
|
-
* bivariantly, so an audience written as `hear: (event: StoryEvent) => void`
|
|
267
|
-
* still compiles. That would be unsound if such an audience could receive a note
|
|
268
|
-
* emission — it cannot, because `hears` defaults to stories only.
|
|
269
|
-
*/
|
|
270
|
-
accepts?(emission: Emission): boolean;
|
|
271
|
-
hear(emission: Emission): void | Promise<void>;
|
|
270
|
+
/** Which emission kinds this audience wants. Defaults to `["story"]`. */
|
|
271
|
+
hears?: Kind[];
|
|
272
|
+
accepts?(emission: EmissionOf<Kind>): boolean;
|
|
273
|
+
hear(emission: EmissionOf<Kind>): void | Promise<void>;
|
|
272
274
|
};
|
|
275
|
+
/** Any audience, whatever it hears — the shape the registry stores */
|
|
276
|
+
type AnyAudienceMember = AudienceMember<EmissionKind>;
|
|
273
277
|
/**
|
|
274
278
|
* How a storyteller narrates.
|
|
275
279
|
*
|
|
@@ -314,7 +318,7 @@ type ChapterOptions = {
|
|
|
314
318
|
};
|
|
315
319
|
type StorytellerOptions = {
|
|
316
320
|
origin?: StoryOriginInput;
|
|
317
|
-
audiences?:
|
|
321
|
+
audiences?: AnyAudienceMember[];
|
|
318
322
|
/** Defaults to `STORYTELLER_NARRATION`, then `collected` */
|
|
319
323
|
narration?: NarrationInput;
|
|
320
324
|
/**
|
|
@@ -349,18 +353,18 @@ type StorytellerOptions = {
|
|
|
349
353
|
maxInFlight?: number;
|
|
350
354
|
};
|
|
351
355
|
/** Called when an audience member throws or rejects while hearing an emission */
|
|
352
|
-
type AudienceErrorHandler = (error: unknown, member:
|
|
356
|
+
type AudienceErrorHandler = (error: unknown, member: AnyAudienceMember, emission: Emission) => void;
|
|
353
357
|
/** Manages the set of audience members that receive story events */
|
|
354
358
|
declare class AudienceRegistry {
|
|
355
359
|
private members;
|
|
356
360
|
/** Register an audience member, replacing any existing member with the same name */
|
|
357
|
-
add(member: AudienceMember): this;
|
|
361
|
+
add<Kind extends EmissionKind = "story">(member: AudienceMember<Kind>): this;
|
|
358
362
|
/** Remove an audience member by name */
|
|
359
363
|
remove(name: string): this;
|
|
360
364
|
/** Return all registered audience members */
|
|
361
|
-
getAll():
|
|
365
|
+
getAll(): AnyAudienceMember[];
|
|
362
366
|
/** Return only the audience members matching the given names */
|
|
363
|
-
getOnly(names: string[]):
|
|
367
|
+
getOnly(names: string[]): AnyAudienceMember[];
|
|
364
368
|
/** Check if an audience member is registered by name */
|
|
365
369
|
has(name: string): boolean;
|
|
366
370
|
/** List the names of all registered audience members */
|
|
@@ -570,7 +574,7 @@ type ConsoleAudienceOptions = {
|
|
|
570
574
|
* story.audience.add(consoleAudience());
|
|
571
575
|
* ```
|
|
572
576
|
*/
|
|
573
|
-
declare function consoleAudience(options?: ConsoleAudienceOptions): AudienceMember
|
|
577
|
+
declare function consoleAudience(options?: ConsoleAudienceOptions): AudienceMember<EmissionKind>;
|
|
574
578
|
|
|
575
579
|
/**
|
|
576
580
|
* Create an audience that stores warn and oops stories via your insert function.
|
|
@@ -623,7 +627,7 @@ type NdjsonAudienceOptions = {
|
|
|
623
627
|
* story.audience.add(ndjsonAudience({ stream: process.stderr }));
|
|
624
628
|
* ```
|
|
625
629
|
*/
|
|
626
|
-
declare function ndjsonAudience(options?: NdjsonAudienceOptions): AudienceMember
|
|
630
|
+
declare function ndjsonAudience(options?: NdjsonAudienceOptions): AudienceMember<EmissionKind>;
|
|
627
631
|
|
|
628
632
|
type StoryReportOptions = {
|
|
629
633
|
timezone?: string;
|
|
@@ -664,4 +668,4 @@ declare function summarizeContext(note: {
|
|
|
664
668
|
error?: StoryError;
|
|
665
669
|
}): string | undefined;
|
|
666
670
|
|
|
667
|
-
export { ANSI, type AudienceErrorHandler, type AudienceMember, AudienceRegistry, type ChapterOptions, type ConsoleAudienceOptions, DEFAULT_REDACT_KEYS, type Emission, type EmissionKind, type FinishOptions, type FormattedReport, type JsonValue, type LevelInput, type LineWriter, type Narration, type NarrationInput, type NdjsonAudienceOptions, type NormalizeOptions, type NoteData, type NoteEmission, type OutputFormat, type PreviewOptions, REDACTED, type ReportNote, type ReportOptions, type StoryContextInput, type StoryContextValue, type StoryEmission, type StoryError, type StoryEvent, type StoryEventBase, type StoryLevel, type StoryNote, type StoryOrigin, type StoryOriginInput, type StoryPreviewOptions, type StoryReport, type StoryReportOptions, type StorySummary, type StorySummaryData, type StorySummaryNote, type StorySummaryOptions, Storyteller, type StorytellerOptions, consoleAudience, dbAudience, formatDuration, formatOrigin, formatStory, getLevelColor, meetsLevel, ndjsonAudience, normalizeError, normalizeValue, readEnvironmentValue, resolveColors, resolveMinimumLevel, resolveOutputFormat, summarizeContext, summarizeStory, toStoryLevel, useStoryteller, writeStoryReport };
|
|
671
|
+
export { ANSI, type AnyAudienceMember, type AudienceErrorHandler, type AudienceMember, AudienceRegistry, type ChapterOptions, type ConsoleAudienceOptions, DEFAULT_REDACT_KEYS, type Emission, type EmissionKind, type EmissionOf, type FinishOptions, type FormattedReport, type JsonValue, type LevelInput, type LineWriter, type Narration, type NarrationInput, type NdjsonAudienceOptions, type NormalizeOptions, type NoteData, type NoteEmission, type OutputFormat, type PreviewOptions, REDACTED, type ReportNote, type ReportOptions, type StoryContextInput, type StoryContextValue, type StoryEmission, type StoryError, type StoryEvent, type StoryEventBase, type StoryLevel, type StoryNote, type StoryOrigin, type StoryOriginInput, type StoryPreviewOptions, type StoryReport, type StoryReportOptions, type StorySummary, type StorySummaryData, type StorySummaryNote, type StorySummaryOptions, Storyteller, type StorytellerOptions, consoleAudience, dbAudience, formatDuration, formatOrigin, formatStory, getLevelColor, meetsLevel, ndjsonAudience, normalizeError, normalizeValue, readEnvironmentValue, resolveColors, resolveMinimumLevel, resolveOutputFormat, summarizeContext, summarizeStory, toStoryLevel, useStoryteller, writeStoryReport };
|
package/dist/index.js
CHANGED
|
@@ -1160,10 +1160,9 @@ function dbAudience(insert) {
|
|
|
1160
1160
|
return {
|
|
1161
1161
|
name: "db",
|
|
1162
1162
|
hears: ["story"],
|
|
1163
|
-
accepts: (
|
|
1164
|
-
hear: async (
|
|
1165
|
-
|
|
1166
|
-
await insert(emission);
|
|
1163
|
+
accepts: (event) => event.level === "Warning" || event.level === "Error",
|
|
1164
|
+
hear: async (event) => {
|
|
1165
|
+
await insert(event);
|
|
1167
1166
|
}
|
|
1168
1167
|
};
|
|
1169
1168
|
}
|