@kehto/services 0.13.2 → 0.15.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ServiceHandler, Signer } from '@kehto/runtime';
1
+ import { ServiceHandler, Signer, RelayEventResult } from '@kehto/runtime';
2
2
  import { IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage } from '@napplet/nap/identity/types';
3
3
  import { NostrFilter, NostrEvent, EventTemplate, LinkOpenOptions, LinkOpenResult, ListSupport, ListRef, ListItem, ListOptions, ListMutationResult, SerialOpenRequest, SerialOpenResult, BleEvent, BleOpenRequest, BleOpenResult, BleService, BleAttribute, BleWriteOptions, WebrtcEvent, WebrtcOpenRequest, WebrtcOpenResult, CommonProfileTarget, CommonProfileResult, CommonFollowsResult, CommonActionResult, CommonReaction, CommonReportTarget, CommonReportReason } from '@napplet/core';
4
4
  import { MediaMetadata, MediaAction } from '@napplet/nap/media/types';
@@ -471,6 +471,46 @@ type HostCacheBridge = CacheServiceOptions;
471
471
  */
472
472
  declare function createCacheService(options: CacheServiceOptions): ServiceHandler;
473
473
 
474
+ interface CountRequest {
475
+ /** NIP-01 filters with NIP-45 COUNT OR semantics. */
476
+ readonly filters: NostrFilter[];
477
+ /** Optional runtime-owned count policy hints. */
478
+ readonly options?: Record<string, unknown>;
479
+ /** Window requesting the count. */
480
+ readonly windowId: string;
481
+ }
482
+ interface CountResult {
483
+ readonly ok: boolean;
484
+ readonly count?: number;
485
+ readonly approximate?: boolean;
486
+ readonly hll?: string;
487
+ readonly relays?: readonly string[];
488
+ readonly error?: string;
489
+ readonly reason?: string;
490
+ }
491
+ interface CountServiceOptions {
492
+ /**
493
+ * Count matching events without returning event payloads.
494
+ *
495
+ * @param request - Validated count request.
496
+ * @returns Exact/approximate count metadata, or a number for an exact count.
497
+ */
498
+ count(request: CountRequest): CountResult | number | Promise<CountResult | number>;
499
+ /**
500
+ * Optional refusal policy for unsupported or too-expensive filters.
501
+ *
502
+ * Return `true` to allow the filter, `false` for a generic refusal, or a
503
+ * string with the refusal reason.
504
+ *
505
+ * @param filter - Filter being evaluated.
506
+ * @param index - Filter index in the OR filter set.
507
+ */
508
+ isFilterSupported?(filter: NostrFilter, index: number): boolean | string;
509
+ /** Maximum number of OR filters accepted before refusing the request. */
510
+ maxFilters?: number;
511
+ }
512
+ declare function createCountService(options: CountServiceOptions): ServiceHandler;
513
+
474
514
  /**
475
515
  * Options for creating a coordinated relay service.
476
516
  *
@@ -1595,7 +1635,7 @@ declare function createResourceService(options: ResourceServiceOptions): Resourc
1595
1635
  * Inbound: outbox.getEvent, outbox.query, outbox.subscribe, outbox.close,
1596
1636
  * outbox.publish, outbox.resolveRelays
1597
1637
  * Outbound: outbox.getEvent.result, outbox.query.result, outbox.event,
1598
- * outbox.eose, outbox.closed, outbox.publish.result,
1638
+ * outbox.closed, outbox.publish.result,
1599
1639
  * outbox.resolveRelays.result
1600
1640
  *
1601
1641
  * The shell owns relay discovery, routing, fallback, deduplication, signature
@@ -1680,10 +1720,8 @@ interface OutboxRelayPlan {
1680
1720
  }
1681
1721
  /** Outcome of a single-event outbox lookup. */
1682
1722
  interface OutboxEventResult {
1683
- /** The signature-validated event matching the requested event id, when found. */
1684
- event?: NostrEvent;
1685
- /** Relay URLs where the shell observed the event. */
1686
- relays: string[];
1723
+ /** The signature-validated event result matching the requested event id, when found. */
1724
+ result?: RelayEventResult;
1687
1725
  /** True when some relay lists or connections failed and the lookup was partial. */
1688
1726
  incomplete?: boolean;
1689
1727
  /** Error reason when the lookup could not complete or did not find the event. */
@@ -1691,10 +1729,8 @@ interface OutboxEventResult {
1691
1729
  }
1692
1730
  /** Outcome of an outbox query, as returned by the {@link OutboxRouter}. */
1693
1731
  interface OutboxResult {
1694
- /** Deduplicated, signature-validated events. */
1695
- events: NostrEvent[];
1696
- /** Map of event id -> relay URLs where the shell observed the event. */
1697
- relays: Record<string, string[]>;
1732
+ /** Deduplicated, signature-validated event results. */
1733
+ events: RelayEventResult[];
1698
1734
  /** True when some relay lists or connections failed and results are partial. */
1699
1735
  incomplete?: boolean;
1700
1736
  /** Error reason when the query could not complete. */
@@ -1715,10 +1751,8 @@ interface OutboxPublishResult {
1715
1751
  }
1716
1752
  /** Sink an {@link OutboxRouter} streams subscription lifecycle through. */
1717
1753
  interface OutboxSubscriptionSink {
1718
- /** Deliver a matching event; `relay` is the relay it was observed on, when known. */
1719
- event(event: NostrEvent, relay?: string): void;
1720
- /** Signal end-of-stored-events. */
1721
- eose(): void;
1754
+ /** Deliver a matching event result. */
1755
+ event(result: RelayEventResult): void;
1722
1756
  /** Signal that the subscription was closed upstream; `reason` is optional. */
1723
1757
  closed(reason?: string): void;
1724
1758
  }
@@ -2987,4 +3021,4 @@ declare function createCordnRelayCoordinatorClient(options: CordnRelayCoordinato
2987
3021
  /** Create a Cordn/ContextVM-backed NAP-DM adapter. */
2988
3022
  declare function createCordnDmAdapter(options: CordnDmAdapterOptions): DmAdapter;
2989
3023
 
2990
- export { type AudioServiceOptions, type AudioSource, type BleServiceContext, type BleServiceOptions, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type CommonServiceContext, type CommonServiceOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, type CordnCodecResult, type CordnCoordinatorClient, type CordnCoordinatorSubscription, type CordnDmAdapterOptions, type CordnDmClient, type CordnGroupMessage, type CordnRelayCoordinatorOptions, type DmAdapter, type DmConversation, type DmConversationPage, type DmConversationQuery, type DmHexPubkey, DmMemoryStore, type DmMessage, type DmMessagePage, type DmMessageQuery, type DmMessageStatus, type DmOk, type DmPeer, type DmRelayPool, type DmSendRequest, type DmSendResult, type DmService, type DmServiceOptions, type DmStatus, type DmSubscribeRequest, type DmSubscription, type DmTimestamp, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type LinkOpenContext, type LinkServiceOptions, type ListsServiceContext, type ListsServiceOptions, type ManifestArchetypeInput, type MaybePromise, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NdrDmAdapterOptions, type NdrRelayTransport, type NdrRelayTransportOptions, type NdrRumorLike, type NdrRuntimeLike, type Nip17DmAdapterOptions, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxEventOptions, type OutboxEventResult, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceInfo, type ResourceInfoContext, type ResourceInfoProvider, type ResourceSchemeInfo, type ResourceService, type ResourceServiceOptions, type SerialServiceContext, type SerialServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadInfo, type UploadInfoContext, type UploadInfoProvider, type UploadRail, type UploadRailInfo, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, type WebrtcServiceContext, type WebrtcServiceOptions, createAudioService, createBleService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createCommonService, createConfigService, createCoordinatedRelay, createCordnDmAdapter, createCordnRelayCoordinatorClient, createDmService, createHttpUploader, createIdentityService, createIntentService, createKeysService, createLinkService, createListsService, createMediaService, createNdrDmAdapter, createNdrRelayTransport, createNip17DmAdapter, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createSerialService, createThemeService, createUploadService, createWebrtcService, manifestToIntentCatalogEntry };
3024
+ export { type AudioServiceOptions, type AudioSource, type BleServiceContext, type BleServiceOptions, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type CommonServiceContext, type CommonServiceOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, type CordnCodecResult, type CordnCoordinatorClient, type CordnCoordinatorSubscription, type CordnDmAdapterOptions, type CordnDmClient, type CordnGroupMessage, type CordnRelayCoordinatorOptions, type CountRequest, type CountResult, type CountServiceOptions, type DmAdapter, type DmConversation, type DmConversationPage, type DmConversationQuery, type DmHexPubkey, DmMemoryStore, type DmMessage, type DmMessagePage, type DmMessageQuery, type DmMessageStatus, type DmOk, type DmPeer, type DmRelayPool, type DmSendRequest, type DmSendResult, type DmService, type DmServiceOptions, type DmStatus, type DmSubscribeRequest, type DmSubscription, type DmTimestamp, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type LinkOpenContext, type LinkServiceOptions, type ListsServiceContext, type ListsServiceOptions, type ManifestArchetypeInput, type MaybePromise, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NdrDmAdapterOptions, type NdrRelayTransport, type NdrRelayTransportOptions, type NdrRumorLike, type NdrRuntimeLike, type Nip17DmAdapterOptions, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxEventOptions, type OutboxEventResult, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceInfo, type ResourceInfoContext, type ResourceInfoProvider, type ResourceSchemeInfo, type ResourceService, type ResourceServiceOptions, type SerialServiceContext, type SerialServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadInfo, type UploadInfoContext, type UploadInfoProvider, type UploadRail, type UploadRailInfo, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, type WebrtcServiceContext, type WebrtcServiceOptions, createAudioService, createBleService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createCommonService, createConfigService, createCoordinatedRelay, createCordnDmAdapter, createCordnRelayCoordinatorClient, createCountService, createDmService, createHttpUploader, createIdentityService, createIntentService, createKeysService, createLinkService, createListsService, createMediaService, createNdrDmAdapter, createNdrRelayTransport, createNip17DmAdapter, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createSerialService, createThemeService, createUploadService, createWebrtcService, manifestToIntentCatalogEntry };