@hollware/server 0.6.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-6mZ3u32c.mjs → ceremonies-D5dIEbha.mjs} +1 -1
- package/dist/index.d.mts +76 -3
- package/dist/index.mjs +564 -39
- package/dist/{store-CYMjP0iN.mjs → store-C2hiR0yd.mjs} +54 -6
- package/migrations/0011_structure.sql +20 -0
- package/migrations/0012_site_secrets.sql +12 -0
- package/migrations/meta/0011_snapshot.json +2532 -0
- package/migrations/meta/0012_snapshot.json +2615 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +3 -3
|
@@ -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. */
|
|
@@ -421,6 +423,67 @@ interface AnalyticsReader {
|
|
|
421
423
|
readonly limit: number;
|
|
422
424
|
}): Promise<readonly PageCount[]>;
|
|
423
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
|
+
}
|
|
424
487
|
//#endregion
|
|
425
488
|
//#region src/events/run.d.ts
|
|
426
489
|
/** A message of the events Queue: the site and the id of an outbox row. */
|
|
@@ -506,6 +569,8 @@ interface OperationContext {
|
|
|
506
569
|
readonly semantic?: Semantic | null;
|
|
507
570
|
/** The counts of page views, when the deployment can read them (ADR-031); absent or `null` without. */
|
|
508
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;
|
|
509
574
|
}
|
|
510
575
|
/** The handler of one operation: its parsed input in, its output out. */
|
|
511
576
|
type OperationHandler<Name extends OperationName> = (input: z.output<OperationByName<Name>['input']>, context: OperationContext) => Promise<z.output<OperationByName<Name>['output']>>;
|
|
@@ -544,6 +609,11 @@ export interface HollwareEnv {
|
|
|
544
609
|
* Origin the Worker answers; without it, every request fails.
|
|
545
610
|
*/
|
|
546
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;
|
|
547
617
|
/**
|
|
548
618
|
* The KV namespace of the OAuth server (ADR-026): its clients, grants and tokens, all by hash.
|
|
549
619
|
* Personal tokens work without it; OAuth does not.
|
|
@@ -625,8 +695,11 @@ export interface HollwareWorker {
|
|
|
625
695
|
/** The RPC entrypoint, for the user's Worker to export under the name `Hollware`. */
|
|
626
696
|
readonly Hollware: new (ctx: ExecutionContext, env: HollwareEnv) => WorkerEntrypoint<HollwareEnv> & HollwareRpc;
|
|
627
697
|
}
|
|
628
|
-
/**
|
|
629
|
-
|
|
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;
|
|
630
703
|
/**
|
|
631
704
|
* Builds the Worker from the config: `const hollware = createHollware(config)`, then
|
|
632
705
|
* `export default { fetch: hollware.fetch }` and `export class Hollware extends hollware.Hollware {}`.
|
|
@@ -634,4 +707,4 @@ export type CreateHollware = (config: HollwareConfig) => HollwareWorker;
|
|
|
634
707
|
*/
|
|
635
708
|
export declare const createHollware: CreateHollware;
|
|
636
709
|
//#endregion
|
|
637
|
-
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, 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 };
|