@hollware/server 1.0.0-rc.1 → 1.0.0-rc.2

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.
@@ -1,4 +1,4 @@
1
- import { _ as saveChallenge, b as userHandle, c as findInvitation, d as invitationById, h as redeemInvitation, i as createUser, l as findPasskey, m as passkeysOf, r as createSession, t as addPasskey, v as takeChallenge, y as touchPasskey } from "./store-DjA9s95l.mjs";
1
+ import { _ as saveChallenge, b as userHandle, c as findInvitation, d as invitationById, h as redeemInvitation, i as createUser, l as findPasskey, m as passkeysOf, r as createSession, t as addPasskey, v as takeChallenge, y as touchPasskey } from "./store-ApxKV0Sc.mjs";
2
2
  import { HollwareError, newId } from "@hollware/core";
3
3
  import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";
4
4
  import { isoBase64URL } from "@simplewebauthn/server/helpers";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AcknowledgedWarning, EntryDocument, EntryLookup, EntryRef, HollwareConfig, OperationByName, OperationName, ResolvedSite, Scope, Verdict, describeSite, getEntry, getTranslations, listEntries, search } from "@hollware/core";
1
+ import { AcknowledgedWarning, Conversion, EntryDocument, EntryLookup, EntryRef, HollwareConfig, OperationByName, OperationName, ResolvedSite, Scope, Verdict, describeSite, getEntry, getTranslations, listEntries, search } from "@hollware/core";
2
2
  import * as z from "zod";
3
3
  import { WorkerEntrypoint } from "cloudflare:workers";
4
4
  //#region src/ports.d.ts
@@ -528,6 +528,68 @@ interface Structure {
528
528
  make(site: string, name: string): Promise<string | null>;
529
529
  };
530
530
  }
531
+ /** Where the files of the assets live: R2. */
532
+ interface AssetFiles {
533
+ put(key: string, bytes: Uint8Array, contentType: string): Promise<void>;
534
+ get(key: string): Promise<{
535
+ readonly body: ReadableStream;
536
+ readonly contentType: string;
537
+ } | null>;
538
+ }
539
+ /** What an image is, as the binding reads it; an SVG has no size. */
540
+ type ImageInfo = {
541
+ readonly format: 'image/svg+xml';
542
+ } | {
543
+ readonly format: string;
544
+ readonly width: number;
545
+ readonly height: number;
546
+ };
547
+ /** The Images binding, behind what Hollware asks of it. */
548
+ interface ImageConverter {
549
+ info(bytes: Uint8Array): Promise<ImageInfo>;
550
+ convert(bytes: Uint8Array, conversion: Conversion): Promise<{
551
+ readonly bytes: Uint8Array;
552
+ readonly format: string;
553
+ }>;
554
+ }
555
+ /** A row of `assets`. */
556
+ interface AssetRow {
557
+ readonly id: string;
558
+ readonly site: string;
559
+ readonly sha256: string;
560
+ readonly format: string;
561
+ readonly width: number | null;
562
+ readonly height: number | null;
563
+ readonly bytes: number;
564
+ readonly originalFormat: string;
565
+ readonly originalBytes: number;
566
+ readonly alt: string;
567
+ readonly filename: string;
568
+ readonly createdBy: string;
569
+ readonly createdAt: string;
570
+ }
571
+ /** The rows of `assets`, of one site at a time. */
572
+ interface AssetCatalog {
573
+ byId(site: string, id: string): Promise<AssetRow | null>;
574
+ /** Writes the row, or answers the one of the same bytes that is there already. */
575
+ insert(row: AssetRow): Promise<{
576
+ readonly row: AssetRow;
577
+ readonly created: boolean;
578
+ }>;
579
+ /** Newest first; the cursor is the `createdAt` and id of the last row of the page before. */
580
+ list(site: string, limit: number, cursor: {
581
+ readonly createdAt: string;
582
+ readonly id: string;
583
+ } | null): Promise<readonly AssetRow[]>;
584
+ }
585
+ /** Media, when the Worker has an R2 bucket for it; `images` is `null` without the binding. */
586
+ interface Media {
587
+ readonly files: AssetFiles;
588
+ readonly images: ImageConverter | null;
589
+ readonly catalog: AssetCatalog;
590
+ /** Where the Worker serves the assets: `<HOLLWARE_PUBLIC_URL>/assets/`. */
591
+ readonly baseUrl: string;
592
+ }
531
593
  //#endregion
532
594
  //#region src/events/run.d.ts
533
595
  /** A message of the events Queue: the site and the id of an outbox row. */
@@ -615,6 +677,8 @@ interface OperationContext {
615
677
  readonly analytics?: AnalyticsReader | null;
616
678
  /** The structure of the sites (ADR-033), where an operation may change it; absent over RPC. */
617
679
  readonly structure?: Structure;
680
+ /** The images of the site (ADR-038), when the Worker has their R2 bucket; absent or `null` without. */
681
+ readonly media?: Media | null;
618
682
  }
619
683
  /** The handler of one operation: its parsed input in, its output out. */
620
684
  type OperationHandler<Name extends OperationName> = (input: z.output<OperationByName<Name>['input']>, context: OperationContext) => Promise<z.output<OperationByName<Name>['output']>>;
@@ -692,6 +756,13 @@ export interface HollwareEnv {
692
756
  readonly HOLLWARE_ANALYTICS_ACCOUNT_ID?: string;
693
757
  readonly HOLLWARE_ANALYTICS_TOKEN?: string;
694
758
  readonly HOLLWARE_ANALYTICS_DATASET?: string;
759
+ /**
760
+ * The images of the sites (ADR-038): the R2 bucket that keeps them and, optionally, the Images
761
+ * binding that converts each once when it arrives. Without the bucket, upload_asset answers
762
+ * unavailable; without the binding, every file is kept as it came.
763
+ */
764
+ readonly MEDIA?: R2Bucket;
765
+ readonly IMAGES?: ImagesBinding;
695
766
  /**
696
767
  * The agents of @hollware/agents (v0.6), over a service binding to their named entrypoint: the
697
768
  * cron trigger of Hollware wakes them every ten minutes, so they need no cron trigger of their
@@ -772,4 +843,4 @@ export interface RateLimiter {
772
843
  }>;
773
844
  }
774
845
  //#endregion
775
- export type { Actor, AnalyticsReader, AnalyticsWriter, Clock, ContentStore, Embedder, EntrySummaryView, EntryView, EventMessage, Handlers, InTrash, ListQuery, NewRevision, OperationContext, OperationHandler, OutboxEvent, PageCount, PageView, Principal, PublishWrite, RelatedEntry, ReviewStatus, RevisionSummary, SearchHit, SearchQuery, Semantic, StoredEntry, StoredPublication, StoredReview, StoredReviewComment, StoredRevision, StoredSchedule, StoredStructure, StoredVector, Structure, StructureActor, StructureStore, VectorIndex, VectorMatch, VectorMetadata, View, WriteRefusal };
846
+ export type { Actor, AnalyticsReader, AnalyticsWriter, AssetCatalog, AssetFiles, AssetRow, Clock, ContentStore, Embedder, EntrySummaryView, EntryView, EventMessage, Handlers, ImageConverter, ImageInfo, InTrash, ListQuery, Media, NewRevision, OperationContext, OperationHandler, OutboxEvent, PageCount, PageView, Principal, PublishWrite, RelatedEntry, ReviewStatus, RevisionSummary, SearchHit, SearchQuery, Semantic, StoredEntry, StoredPublication, StoredReview, StoredReviewComment, StoredRevision, StoredSchedule, StoredStructure, StoredVector, Structure, StructureActor, StructureStore, VectorIndex, VectorMatch, VectorMetadata, View, WriteRefusal };