@hollware/server 0.5.0 → 0.8.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/{ceremonies-BM9G03lZ.mjs → ceremonies-D5dIEbha.mjs} +1 -1
- package/dist/index.d.mts +108 -3
- package/dist/index.mjs +715 -57
- package/dist/{store-DiS8UFI2.mjs → store-C2hiR0yd.mjs} +84 -3
- package/migrations/0010_review_comments.sql +17 -0
- package/migrations/0011_structure.sql +20 -0
- package/migrations/0012_site_secrets.sql +12 -0
- package/migrations/meta/0010_snapshot.json +2388 -0
- package/migrations/meta/0011_snapshot.json +2532 -0
- package/migrations/meta/0012_snapshot.json +2615 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as findInvitation, c as invitationById, d as redeemInvitation, f as saveChallenge, h as userHandle, i as createUser, m as touchPasskey, o as findPasskey, p as takeChallenge, r as createSession, t as addPasskey, u as passkeysOf } from "./store-
|
|
1
|
+
import { a as findInvitation, c as invitationById, d as redeemInvitation, f as saveChallenge, h as userHandle, i as createUser, m as touchPasskey, o as findPasskey, p as takeChallenge, r as createSession, t as addPasskey, u as passkeysOf } from "./store-C2hiR0yd.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
|
@@ -31,6 +31,8 @@ interface StoredEntry {
|
|
|
31
31
|
readonly publishedRevision: string | null;
|
|
32
32
|
/** When the entry was first published; republishing keeps it. */
|
|
33
33
|
readonly publishedAt: string | null;
|
|
34
|
+
/** When a scheduled entry will be published, or `null`. */
|
|
35
|
+
readonly scheduledAt: string | null;
|
|
34
36
|
readonly updatedAt: string;
|
|
35
37
|
}
|
|
36
38
|
/** A revision as the store holds it. */
|
|
@@ -161,6 +163,17 @@ interface StoredReview {
|
|
|
161
163
|
readonly decidedAt: string | null;
|
|
162
164
|
readonly note: string | null;
|
|
163
165
|
}
|
|
166
|
+
/** A comment on a review (v0.6). */
|
|
167
|
+
interface StoredReviewComment {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
readonly reviewId: string;
|
|
170
|
+
readonly authorId: string;
|
|
171
|
+
readonly authorName: string | null;
|
|
172
|
+
/** What the client that wrote it said about itself, or `null`. */
|
|
173
|
+
readonly authorMeta: Readonly<Record<string, unknown>> | null;
|
|
174
|
+
readonly body: string;
|
|
175
|
+
readonly createdAt: string;
|
|
176
|
+
}
|
|
164
177
|
/** A scheduled publication, as the cron trigger reads it. */
|
|
165
178
|
interface StoredSchedule {
|
|
166
179
|
readonly entryId: string;
|
|
@@ -295,6 +308,19 @@ interface ContentStore {
|
|
|
295
308
|
readonly status: ReviewStatus;
|
|
296
309
|
readonly limit: number;
|
|
297
310
|
}): Promise<readonly StoredReview[]>;
|
|
311
|
+
/** Adds a comment to a review, if it is still pending. */
|
|
312
|
+
commentReview(site: string, write: {
|
|
313
|
+
readonly reviewId: string;
|
|
314
|
+
readonly actor: Actor;
|
|
315
|
+
readonly body: string;
|
|
316
|
+
}): Promise<{
|
|
317
|
+
readonly outcome: 'commented';
|
|
318
|
+
readonly comment: StoredReviewComment;
|
|
319
|
+
} | {
|
|
320
|
+
readonly outcome: 'not_pending' | 'not_found';
|
|
321
|
+
}>;
|
|
322
|
+
/** The comments of these reviews, oldest first, by review. */
|
|
323
|
+
reviewComments(site: string, reviewIds: readonly string[]): Promise<ReadonlyMap<string, readonly StoredReviewComment[]>>;
|
|
298
324
|
/** Closes a pending review with a note, without publishing. */
|
|
299
325
|
requestChanges(site: string, write: {
|
|
300
326
|
readonly id: string;
|
|
@@ -397,6 +423,67 @@ interface AnalyticsReader {
|
|
|
397
423
|
readonly limit: number;
|
|
398
424
|
}): Promise<readonly PageCount[]>;
|
|
399
425
|
}
|
|
426
|
+
/** The stored structure of a site (ADR-033), or `null` for no row or a row with no definition. */
|
|
427
|
+
interface StoredStructure {
|
|
428
|
+
readonly version: number;
|
|
429
|
+
readonly definition: unknown;
|
|
430
|
+
/** When the site went to the trash, or `null`. */
|
|
431
|
+
readonly deletedAt: string | null;
|
|
432
|
+
}
|
|
433
|
+
/** Who changes a structure: the person, and what their client said about itself. */
|
|
434
|
+
interface StructureActor {
|
|
435
|
+
readonly userId: string;
|
|
436
|
+
readonly meta: Readonly<Record<string, unknown>> | null;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The structure of the sites in D1 (ADR-033): read, written with the version it was read at, and
|
|
440
|
+
* appended to `site_changes` in the same batch. A write never deletes an entry.
|
|
441
|
+
*/
|
|
442
|
+
interface StructureStore {
|
|
443
|
+
read(site: string): Promise<StoredStructure | null>;
|
|
444
|
+
/** A new definition, if the version is still `expected`: `conflict` when it moved. */
|
|
445
|
+
write(input: {
|
|
446
|
+
readonly site: string;
|
|
447
|
+
readonly expected: number;
|
|
448
|
+
readonly definition: unknown;
|
|
449
|
+
readonly actor: StructureActor;
|
|
450
|
+
}): Promise<'written' | 'conflict'>;
|
|
451
|
+
/** A new site with its definition, and its maker as owner: `taken` when the key exists, trashed or not. */
|
|
452
|
+
create(input: {
|
|
453
|
+
readonly site: string;
|
|
454
|
+
readonly definition: unknown;
|
|
455
|
+
readonly actor: StructureActor;
|
|
456
|
+
}): Promise<'created' | 'taken'>;
|
|
457
|
+
/** Puts a site in the trash, or takes it out: `false` when it was not where it had to be. */
|
|
458
|
+
trash(site: string, actor: StructureActor): Promise<boolean>;
|
|
459
|
+
restore(site: string, actor: StructureActor): Promise<boolean>;
|
|
460
|
+
/** The role of a person in a site, or `null` for none. */
|
|
461
|
+
roleOf(site: string, userId: string): Promise<'owner' | 'editor' | 'author' | null>;
|
|
462
|
+
/** How many entries a site holds, by collection and by locale. */
|
|
463
|
+
counts(site: string): Promise<{
|
|
464
|
+
readonly byCollection: ReadonlyMap<string, number>;
|
|
465
|
+
readonly byLocale: ReadonlyMap<string, number>;
|
|
466
|
+
}>;
|
|
467
|
+
/** The slug and latest frontmatter of up to `limit` entries of a collection. */
|
|
468
|
+
frontmatters(site: string, collection: string, limit: number): Promise<readonly {
|
|
469
|
+
readonly slug: string;
|
|
470
|
+
readonly frontmatter: unknown;
|
|
471
|
+
}[]>;
|
|
472
|
+
}
|
|
473
|
+
/** The structure, for the operations that change it, and what makes the Worker see a change at once. */
|
|
474
|
+
interface Structure {
|
|
475
|
+
readonly store: StructureStore;
|
|
476
|
+
/** Brings this isolate's sites in line with D1 now, after a change. */
|
|
477
|
+
readonly changed: () => Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* The secrets Hollware makes and keeps sealed (ADR-033): a new one for `name`, which replaces
|
|
480
|
+
* the one before and is answered in clear this once; `null` where the deployment has no
|
|
481
|
+
* `HOLLWARE_SECRET` to seal it with.
|
|
482
|
+
*/
|
|
483
|
+
readonly secrets?: {
|
|
484
|
+
make(site: string, name: string): Promise<string | null>;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
400
487
|
//#endregion
|
|
401
488
|
//#region src/events/run.d.ts
|
|
402
489
|
/** A message of the events Queue: the site and the id of an outbox row. */
|
|
@@ -482,6 +569,8 @@ interface OperationContext {
|
|
|
482
569
|
readonly semantic?: Semantic | null;
|
|
483
570
|
/** The counts of page views, when the deployment can read them (ADR-031); absent or `null` without. */
|
|
484
571
|
readonly analytics?: AnalyticsReader | null;
|
|
572
|
+
/** The structure of the sites (ADR-033), where an operation may change it; absent over RPC. */
|
|
573
|
+
readonly structure?: Structure;
|
|
485
574
|
}
|
|
486
575
|
/** The handler of one operation: its parsed input in, its output out. */
|
|
487
576
|
type OperationHandler<Name extends OperationName> = (input: z.output<OperationByName<Name>['input']>, context: OperationContext) => Promise<z.output<OperationByName<Name>['output']>>;
|
|
@@ -520,6 +609,11 @@ export interface HollwareEnv {
|
|
|
520
609
|
* Origin the Worker answers; without it, every request fails.
|
|
521
610
|
*/
|
|
522
611
|
readonly HOLLWARE_PUBLIC_URL: string;
|
|
612
|
+
/**
|
|
613
|
+
* The key that seals the secrets Hollware makes for the structure, such as those that sign
|
|
614
|
+
* webhooks (ADR-033): at least 32 characters, which `hollware deploy` makes when it is missing.
|
|
615
|
+
*/
|
|
616
|
+
readonly HOLLWARE_SECRET?: string;
|
|
523
617
|
/**
|
|
524
618
|
* The KV namespace of the OAuth server (ADR-026): its clients, grants and tokens, all by hash.
|
|
525
619
|
* Personal tokens work without it; OAuth does not.
|
|
@@ -547,6 +641,14 @@ export interface HollwareEnv {
|
|
|
547
641
|
readonly HOLLWARE_ANALYTICS_ACCOUNT_ID?: string;
|
|
548
642
|
readonly HOLLWARE_ANALYTICS_TOKEN?: string;
|
|
549
643
|
readonly HOLLWARE_ANALYTICS_DATASET?: string;
|
|
644
|
+
/**
|
|
645
|
+
* The agents of @hollware/agents (v0.6), over a service binding to their named entrypoint: the
|
|
646
|
+
* cron trigger of Hollware wakes them every ten minutes, so they need no cron trigger of their
|
|
647
|
+
* own (the free plan has five for the account). `wrangler types` writes it as a plain
|
|
648
|
+
* `Service`, as it cannot see the agents' entrypoint, so any binding goes in: one without `run`
|
|
649
|
+
* is not called.
|
|
650
|
+
*/
|
|
651
|
+
readonly AGENTS?: object;
|
|
550
652
|
}
|
|
551
653
|
type Output<Spec extends {
|
|
552
654
|
output: z.ZodType;
|
|
@@ -593,8 +695,11 @@ export interface HollwareWorker {
|
|
|
593
695
|
/** The RPC entrypoint, for the user's Worker to export under the name `Hollware`. */
|
|
594
696
|
readonly Hollware: new (ctx: ExecutionContext, env: HollwareEnv) => WorkerEntrypoint<HollwareEnv> & HollwareRpc;
|
|
595
697
|
}
|
|
596
|
-
/**
|
|
597
|
-
|
|
698
|
+
/**
|
|
699
|
+
* Builds the Worker. The sites live in D1 (ADR-033); a config of 0.x, when given, is moved there
|
|
700
|
+
* on the first request, for the sites that have no definition yet, and never read again.
|
|
701
|
+
*/
|
|
702
|
+
export type CreateHollware = (config?: HollwareConfig) => HollwareWorker;
|
|
598
703
|
/**
|
|
599
704
|
* Builds the Worker from the config: `const hollware = createHollware(config)`, then
|
|
600
705
|
* `export default { fetch: hollware.fetch }` and `export class Hollware extends hollware.Hollware {}`.
|
|
@@ -602,4 +707,4 @@ export type CreateHollware = (config: HollwareConfig) => HollwareWorker;
|
|
|
602
707
|
*/
|
|
603
708
|
export declare const createHollware: CreateHollware;
|
|
604
709
|
//#endregion
|
|
605
|
-
export type { Actor, AnalyticsReader, AnalyticsWriter, Clock, ContentStore, Embedder, EntrySummaryView, EntryView, EventMessage, Handlers, ListQuery, NewRevision, OperationContext, OperationHandler, OutboxEvent, PageCount, PageView, Principal, PublishWrite, RelatedEntry, ReviewStatus, RevisionSummary, SearchHit, SearchQuery, Semantic, StoredEntry, StoredPublication, StoredReview, StoredRevision, StoredSchedule, StoredVector, VectorIndex, VectorMatch, VectorMetadata, View, WriteRefusal };
|
|
710
|
+
export type { Actor, AnalyticsReader, AnalyticsWriter, Clock, ContentStore, Embedder, EntrySummaryView, EntryView, EventMessage, Handlers, 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 };
|