@feltdb/feltkit 0.3.18 → 0.3.20
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/app.d.ts +57 -14
- package/dist/app.js +71 -9
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +25 -0
- package/dist/appboundry/build.js +10 -1
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +18 -2
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.js +3 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/cli/compose.d.ts +31 -0
- package/dist/cli/compose.js +274 -0
- package/dist/cli/compose.js.map +1 -0
- package/dist/cli/create.d.ts +201 -0
- package/dist/cli/create.js +1139 -0
- package/dist/cli/create.js.map +1 -0
- package/dist/cli/deploy.d.ts +1 -0
- package/dist/cli/deploy.js +66 -6
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/domain.d.ts +174 -0
- package/dist/cli/domain.js +1119 -0
- package/dist/cli/domain.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +135 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/shell.d.ts +7 -0
- package/dist/cli/shell.js +59 -0
- package/dist/cli/shell.js.map +1 -0
- package/dist/component.d.ts +174 -0
- package/dist/component.js +77 -0
- package/dist/component.js.map +1 -0
- package/dist/composition/catalog.d.ts +3 -0
- package/dist/composition/catalog.js +217 -0
- package/dist/composition/catalog.js.map +1 -0
- package/dist/composition/contract.d.ts +165 -0
- package/dist/composition/contract.js +12 -0
- package/dist/composition/contract.js.map +1 -0
- package/dist/composition/execute.d.ts +110 -0
- package/dist/composition/execute.js +350 -0
- package/dist/composition/execute.js.map +1 -0
- package/dist/composition/generate.d.ts +105 -0
- package/dist/composition/generate.js +274 -0
- package/dist/composition/generate.js.map +1 -0
- package/dist/composition/plan.d.ts +131 -0
- package/dist/composition/plan.js +558 -0
- package/dist/composition/plan.js.map +1 -0
- package/dist/composition/profiles.d.ts +20 -0
- package/dist/composition/profiles.js +81 -0
- package/dist/composition/profiles.js.map +1 -0
- package/dist/composition/reconcile.d.ts +153 -0
- package/dist/composition/reconcile.js +282 -0
- package/dist/composition/reconcile.js.map +1 -0
- package/dist/composition/recover.d.ts +89 -0
- package/dist/composition/recover.js +407 -0
- package/dist/composition/recover.js.map +1 -0
- package/dist/composition/resolve.d.ts +2 -0
- package/dist/composition/resolve.js +208 -0
- package/dist/composition/resolve.js.map +1 -0
- package/dist/dashboard/assets/{index-DnIOVGF-.js → index-BrC1AtZ1.js} +5 -5
- package/dist/dashboard/index.html +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/activity.d.ts +8 -1
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/audit.d.ts +43 -0
- package/dist/runtime/audit.js +52 -0
- package/dist/runtime/audit.js.map +1 -0
- package/dist/runtime/claims.d.ts +76 -0
- package/dist/runtime/claims.js +100 -0
- package/dist/runtime/claims.js.map +1 -0
- package/dist/runtime/context.d.ts +6 -5
- package/dist/runtime/contract.js +4 -1
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +14 -2
- package/dist/runtime/data.js +62 -23
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/escape-hatch.d.ts +37 -0
- package/dist/runtime/escape-hatch.js +76 -0
- package/dist/runtime/escape-hatch.js.map +1 -0
- package/dist/runtime/instance.js +2 -1
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/outbox.js +3 -0
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/runtime.d.ts +33 -0
- package/dist/runtime/runtime.js +127 -12
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services-rules.d.ts +12 -0
- package/dist/runtime/services-rules.js +8 -0
- package/dist/runtime/services-rules.js.map +1 -0
- package/dist/runtime/services.js +5 -3
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +13 -4
- package/dist/runtime/tenancy.js +30 -9
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/transactions.d.ts +38 -1
- package/dist/runtime/transactions.js +20 -5
- package/dist/runtime/transactions.js.map +1 -1
- package/dist/server/admin.js +52 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/components.d.ts +44 -0
- package/dist/server/components.js +212 -0
- package/dist/server/components.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +24 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/project.d.ts +27 -0
- package/dist/server/project.js +63 -0
- package/dist/server/project.js.map +1 -1
- package/dist/server/public.d.ts +2 -0
- package/dist/server/public.js +2 -0
- package/dist/server/public.js.map +1 -1
- package/dist/testing/index.d.ts +12 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/AUTH.md +8 -3
- package/docs/COMPONENTS.md +91 -0
- package/docs/GUARANTEES.md +24 -4
- package/docs/README.md +3 -2
- package/docs/RESOLVER.md +4 -2
- package/docs/SECURITY.md +2 -2
- package/docs/TRANSACTIONS.md +1 -1
- package/package.json +14 -12
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="apple-touch-icon" href="/_feltkit/apple-touch-icon.png" />
|
|
10
10
|
<title>FeltKit</title>
|
|
11
11
|
<script>(function(){try{var v=window.localStorage.getItem("stack-ui.theme");if(v==="light"||v==="dark")document.documentElement.setAttribute("data-stack-theme",v);}catch(e){}})();</script>
|
|
12
|
-
<script type="module" crossorigin src="/_feltkit/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/_feltkit/assets/index-BrC1AtZ1.js"></script>
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/_feltkit/assets/index-BXTNQAg1.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/dist/docs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const PACKAGE_NAME = "@feltdb/feltkit";
|
|
2
2
|
/** The documents shipped in the package, with what each one answers. Order = reading order. */
|
|
3
|
-
export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"]];
|
|
3
|
+
export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"]];
|
|
4
4
|
export type DocName = (typeof SHIPPED_DOCS)[number][0];
|
|
5
5
|
/** The shipped file on disk (inside node_modules/@feltdb/feltkit in a project). */
|
|
6
6
|
export declare function docFile(name: DocName): string;
|
package/dist/docs.js
CHANGED
|
@@ -23,6 +23,7 @@ export const SHIPPED_DOCS = [
|
|
|
23
23
|
["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"],
|
|
24
24
|
["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"],
|
|
25
25
|
["BACKUP.md", "Backing up and restoring an environment's state"],
|
|
26
|
+
["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"],
|
|
26
27
|
["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"],
|
|
27
28
|
["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"],
|
|
28
29
|
["WHY-FELTKIT.md", "Design choices, compared with Convex"],
|
package/dist/docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","sourceRoot":"","s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AE,oEAAoE,CAAC;IACvG,CAAC,gBAAgB,EAAE,sCAAsC,CAAC;IAC1D,CAAC,kBAAkB,EAAE,sEAAsE,CAAC;CACpF,CAAC;AAIX,mFAAmF;AACnF,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,MAAM,CAAC,IAAc;IACnC,OAAO,gCAAgC,YAAY,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1G,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,IAAa;IAClC,OAAO,gBAAgB,YAAY,SAAS,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,YAAY,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export { FeltKitError, fail, isFeltKitError } from "./errors.js";
|
|
|
14
14
|
export type { FeltKitErrorCode, FeltKitErrorJSON } from "./errors.js";
|
|
15
15
|
export type { QueryCtx, MutationCtx, AgentCtx, AgentTrigger, Logger, EnvironmentInfo } from "./runtime/context.js";
|
|
16
16
|
export type { CryptoContext } from "./runtime/crypto-token.js";
|
|
17
|
+
export type { ClaimDeclaration, ClaimSpec, ClaimStatus, ClaimProvenance } from "./runtime/claims.js";
|
|
18
|
+
export { CLAIM_TYPES, claimSpecProblem, claimSchema, isClaimSpec } from "./runtime/claims.js";
|
|
17
19
|
export type { DatabaseReader, DatabaseWriter, FindOptions, QueryRequest, QueryPage, WhereClause, OrderBy, SearchRequest } from "./runtime/data.js";
|
|
18
20
|
export type { AuthContext, Principal, PrincipalType } from "./runtime/authority.js";
|
|
19
21
|
export type { AuthorizeHook, AuthorizeRequest, AuthorizeResult } from "./authorize.js";
|
|
@@ -21,3 +23,5 @@ export type { EventDefinition } from "./app.js";
|
|
|
21
23
|
export type { EventsWriter } from "./runtime/context.js";
|
|
22
24
|
export type { FileInfo, FilesReader, FilesWriter, UploadInput, NotificationInfo, NotificationsReader, NotificationsWriter, SendNotificationInput, JobsWriter, WebhooksWriter, ConfigurationReader, ConfigurationWriter } from "./runtime/services.js";
|
|
23
25
|
export type { ModelReferenceOption, ModelResolution } from "./runtime/decisions.js";
|
|
26
|
+
export { defineComponent } from "./component.js";
|
|
27
|
+
export type { ComponentDeclaration, ComponentContext, ComponentInstance, ComponentHealth, ComponentState, ComponentModel, ComponentDefinition, ComponentWorkItem, ComponentWorkOutcome } from "./component.js";
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,6 @@
|
|
|
9
9
|
export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "./app.js";
|
|
10
10
|
export { s } from "./schema.js";
|
|
11
11
|
export { FeltKitError, fail, isFeltKitError } from "./errors.js";
|
|
12
|
+
export { CLAIM_TYPES, claimSpecProblem, claimSchema, isClaimSpec } from "./runtime/claims.js";
|
|
13
|
+
export { defineComponent } from "./component.js";
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA2BrE,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA2BrE,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQ9F,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The activity log:
|
|
2
|
+
* The activity log: an operational feed of what the application did (calls, refusals, reads).
|
|
3
|
+
* Best effort and trimmed to its retention; the authoritative record of committed changes is the
|
|
4
|
+
* audit trail (runtime/audit.ts), which commits in the mutation's own transaction.
|
|
3
5
|
*
|
|
4
6
|
* Entries are written to the application's FeltDB instance after an operation
|
|
5
7
|
* completes. A mutation's `writes`, `transactionId`, and `commitRevision` come from
|
|
@@ -35,6 +37,11 @@ export interface ActivityEntry {
|
|
|
35
37
|
principal: (Pick<Principal, "id" | "roles"> & {
|
|
36
38
|
type: Principal["type"] | "unknown";
|
|
37
39
|
}) | null;
|
|
40
|
+
/** The tenant the call worked in and the caller's membership role there (resolved live), if any. */
|
|
41
|
+
tenant?: {
|
|
42
|
+
id: string;
|
|
43
|
+
role: string;
|
|
44
|
+
};
|
|
38
45
|
authority?: {
|
|
39
46
|
required: string;
|
|
40
47
|
allowed: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/runtime/activity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/runtime/activity.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,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AC,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1I,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { StateFirstDB } from "@feltdb/core";
|
|
2
|
+
import type { ActivityEntry } from "./activity.js";
|
|
3
|
+
import type { Principal } from "./authority.js";
|
|
4
|
+
export declare const AUDIT_COLLECTION = "_feltkit_audit";
|
|
5
|
+
export interface AuditRecord {
|
|
6
|
+
/** `aud_<transactionId>`: one record per committed transaction. */
|
|
7
|
+
id: string;
|
|
8
|
+
at: string;
|
|
9
|
+
transactionId: string;
|
|
10
|
+
function: string;
|
|
11
|
+
via: string;
|
|
12
|
+
requestId: string;
|
|
13
|
+
principal: {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
roles: string[];
|
|
17
|
+
} | null;
|
|
18
|
+
tenantId?: string;
|
|
19
|
+
authority: NonNullable<ActivityEntry["authority"]>;
|
|
20
|
+
/** What the mutation wrote: collection, record id and operation. Values are never recorded. */
|
|
21
|
+
writes: Array<{
|
|
22
|
+
collection: string;
|
|
23
|
+
id: string;
|
|
24
|
+
op: "insert" | "update" | "delete";
|
|
25
|
+
}>;
|
|
26
|
+
/** After-commit effects recorded in the same transaction (outbox ids). */
|
|
27
|
+
effects: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function auditRecord(input: {
|
|
30
|
+
transactionId: string;
|
|
31
|
+
function: string;
|
|
32
|
+
via: string;
|
|
33
|
+
requestId: string;
|
|
34
|
+
principal: Principal | null;
|
|
35
|
+
authority: NonNullable<ActivityEntry["authority"]>;
|
|
36
|
+
writes: AuditRecord["writes"];
|
|
37
|
+
effects: string[];
|
|
38
|
+
}): AuditRecord;
|
|
39
|
+
/** Audit records, oldest first (records sort by commit time), optionally for one workspace or principal. */
|
|
40
|
+
export declare function readAudit(db: StateFirstDB, filter?: {
|
|
41
|
+
tenantId?: string;
|
|
42
|
+
principalId?: string;
|
|
43
|
+
}): Promise<AuditRecord[]>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit trail: one record per committed mutation, written in the mutation's own FeltDB
|
|
3
|
+
* transaction. It is the authoritative answer to "who changed what, under which decision".
|
|
4
|
+
*
|
|
5
|
+
* It is not the activity log (runtime/activity.ts). The activity log is an operational feed:
|
|
6
|
+
* written after the operation, best effort, trimmed to its retention, and it records refusals
|
|
7
|
+
* and reads as well. The audit trail differs in each property that makes evidence trustworthy:
|
|
8
|
+
*
|
|
9
|
+
* atomic the record commits with the writes it describes, or neither does: a crash
|
|
10
|
+
* between the commit and a later write cannot lose it
|
|
11
|
+
* append-only inserted with `requireAbsent` and never updated or deleted by FeltKit;
|
|
12
|
+
* FeltKit keeps no retention for it (it lives as long as the application's state)
|
|
13
|
+
* protected `_feltkit_audit` is not a collection the application declares, so neither
|
|
14
|
+
* `ctx.db` nor `ctx.unsafe.feltdb` reaches it (test/escape-hatch.test.ts)
|
|
15
|
+
* attributed principal, workspace, authorization decision (and the approval, for an
|
|
16
|
+
* approved agent action), function, interface, request
|
|
17
|
+
* verifiable `transactionId` is FeltDB's own transaction id for the commit, so a record can
|
|
18
|
+
* be checked against the authority's transaction history; replaying an idempotent
|
|
19
|
+
* request commits nothing new, so it adds no record
|
|
20
|
+
* recoverable part of the application's state: backups include it, restore brings it back
|
|
21
|
+
*
|
|
22
|
+
* What it is not: tamper-evident against whoever operates the FeltDB instance (a hash chain
|
|
23
|
+
* would serialize every mutation on one record). Refused and failed calls write nothing, so
|
|
24
|
+
* they appear only in the activity log.
|
|
25
|
+
*/
|
|
26
|
+
import { readAll } from "./data.js";
|
|
27
|
+
export const AUDIT_COLLECTION = "_feltkit_audit";
|
|
28
|
+
export function auditRecord(input) {
|
|
29
|
+
const p = input.principal;
|
|
30
|
+
return {
|
|
31
|
+
id: `aud_${input.transactionId}`,
|
|
32
|
+
at: new Date().toISOString(),
|
|
33
|
+
transactionId: input.transactionId,
|
|
34
|
+
function: input.function,
|
|
35
|
+
via: input.via,
|
|
36
|
+
requestId: input.requestId,
|
|
37
|
+
principal: p ? { id: p.id, type: p.type, roles: [...p.roles] } : null,
|
|
38
|
+
...(p?.tenant ? { tenantId: p.tenant.id } : {}),
|
|
39
|
+
authority: { ...input.authority },
|
|
40
|
+
writes: input.writes.map((w) => ({ ...w })),
|
|
41
|
+
effects: [...input.effects],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Audit records, oldest first (records sort by commit time), optionally for one workspace or principal. */
|
|
45
|
+
export async function readAudit(db, filter = {}) {
|
|
46
|
+
const rows = (await readAll(db, { collection: AUDIT_COLLECTION }));
|
|
47
|
+
return rows
|
|
48
|
+
.filter((r) => (filter.tenantId === undefined || r.tenantId === filter.tenantId) && (filter.principalId === undefined || r.principal?.id === filter.principalId))
|
|
49
|
+
.map(({ __version: _version, ...record }) => record)
|
|
50
|
+
.sort((a, b) => a.at.localeCompare(b.at) || a.id.localeCompare(b.id));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/runtime/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAmBjD,MAAM,UAAU,WAAW,CAAC,KAS3B;IACC,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO;QACL,EAAE,EAAE,OAAO,KAAK,CAAC,aAAa,EAAE;QAChC,EAAE,EAAE,I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C,WAAW,CAAC,CAAC;SAChK,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;SACnD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Membership claims (`auth.tenant.claims`): typed values a membership carries beside its role, set only through the
|
|
3
|
+
* server (a member manager, or an invitation) and never read from a request.
|
|
4
|
+
*
|
|
5
|
+
* A claim is declared either as a schema (`s.enum([...])`, application code) or as a **claim spec**: plain data that a
|
|
6
|
+
* composition record can hold (`{ type: "enum", values: ["free", "pro"] }`), which is what `feltkit create --claim`
|
|
7
|
+
* writes and `workspace.tenancy.claims` records. Both compile to the same schema, so validation is one rule.
|
|
8
|
+
*
|
|
9
|
+
* At the authentication boundary (`Tenancy.context`, on every call) each declared claim is classified from what the
|
|
10
|
+
* membership record holds:
|
|
11
|
+
*
|
|
12
|
+
* verified the stored value validates under the declaration now; set by `by` at `at`, through `via`
|
|
13
|
+
* default nothing is stored; the declaration gives a default, and that is the value
|
|
14
|
+
* unavailable nothing is stored and there is no default; the claim is absent
|
|
15
|
+
* invalid a stored value no longer validates (the declaration changed since it was set); it is withheld
|
|
16
|
+
*
|
|
17
|
+
* Only `verified` and `default` values appear in `claims`; `invalid` and `unavailable` ones are absent, and a rule that
|
|
18
|
+
* needs them refuses (`app.requireClaim`). A stored claim the declaration no longer names is dropped. Nothing here
|
|
19
|
+
* upgrades a status: a client cannot assert a claim, and a stale value is never served as current.
|
|
20
|
+
*/
|
|
21
|
+
import type { Schema } from "@appport/sdk";
|
|
22
|
+
export type ClaimSpec = {
|
|
23
|
+
readonly type: "enum";
|
|
24
|
+
readonly values: readonly string[];
|
|
25
|
+
readonly default?: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly default?: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "boolean";
|
|
31
|
+
readonly default?: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "number";
|
|
34
|
+
readonly default?: number;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "integer";
|
|
37
|
+
readonly default?: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const CLAIM_TYPES: readonly ["enum", "string", "boolean", "number", "integer"];
|
|
40
|
+
/** A schema (application code) or a claim spec (plain data). */
|
|
41
|
+
export type ClaimDeclaration = Schema | ClaimSpec;
|
|
42
|
+
export type ClaimStatus = "verified" | "default" | "unavailable" | "invalid";
|
|
43
|
+
/** How a claim's value came to be on the membership, as the boundary classified it for this call. */
|
|
44
|
+
export interface ClaimProvenance {
|
|
45
|
+
readonly status: ClaimStatus;
|
|
46
|
+
/** Who set the stored value (a principal id), when, and how. Only with a stored value (verified or invalid). */
|
|
47
|
+
readonly by?: string;
|
|
48
|
+
readonly at?: string;
|
|
49
|
+
readonly via?: "invitation" | "manager" | "self";
|
|
50
|
+
}
|
|
51
|
+
/** What a membership record keeps about each stored claim: who set it, when, how. */
|
|
52
|
+
export interface StoredClaimProvenance {
|
|
53
|
+
by: string;
|
|
54
|
+
at: string;
|
|
55
|
+
via: "invitation" | "manager" | "self";
|
|
56
|
+
}
|
|
57
|
+
/** Whether a value has the shape of a claim spec (a `type` among CLAIM_TYPES). Its validity is `claimSpecProblem`. */
|
|
58
|
+
export declare function isClaimSpec(v: unknown): v is ClaimSpec;
|
|
59
|
+
/** Why a declared claim is not acceptable, or null. Deterministic: the same declaration always gives the same answer. */
|
|
60
|
+
export declare function claimSpecProblem(name: string, declaration: unknown): string | null;
|
|
61
|
+
/** The schema a claim spec compiles to. */
|
|
62
|
+
export declare function claimSchema(spec: ClaimSpec): Schema;
|
|
63
|
+
export interface CompiledClaims {
|
|
64
|
+
/** One schema per declared claim, whatever form it was declared in. */
|
|
65
|
+
readonly schemas: Readonly<Record<string, Schema>>;
|
|
66
|
+
/** Declared defaults (claim specs only). */
|
|
67
|
+
readonly defaults: Readonly<Record<string, unknown>>;
|
|
68
|
+
readonly names: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
/** Compile `auth.tenant.claims` once. Throws TypeError on a declaration `claimSpecProblem` refuses. */
|
|
71
|
+
export declare function compileClaims(declared: Readonly<Record<string, ClaimDeclaration>> | undefined): CompiledClaims;
|
|
72
|
+
/** The claims a membership presents on a call, and each declared claim's provenance. Pure. */
|
|
73
|
+
export declare function classifyClaims(compiled: CompiledClaims, stored: Readonly<Record<string, unknown>>, storedProvenance?: Readonly<Record<string, StoredClaimProvenance>>): {
|
|
74
|
+
claims: Record<string, unknown>;
|
|
75
|
+
provenance: Record<string, ClaimProvenance>;
|
|
76
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { s } from "../schema.js";
|
|
2
|
+
export const CLAIM_TYPES = ["enum", "string", "boolean", "number", "integer"];
|
|
3
|
+
const isSchema = (v) => Boolean(v) && typeof v.validate === "function";
|
|
4
|
+
const plain = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !isSchema(v);
|
|
5
|
+
/** Whether a value has the shape of a claim spec (a `type` among CLAIM_TYPES). Its validity is `claimSpecProblem`. */
|
|
6
|
+
export function isClaimSpec(v) {
|
|
7
|
+
return plain(v) && typeof v.type === "string" && CLAIM_TYPES.includes(v.type);
|
|
8
|
+
}
|
|
9
|
+
const IDENT = /^[a-z][a-zA-Z0-9]{0,40}$/;
|
|
10
|
+
/** Why a declared claim is not acceptable, or null. Deterministic: the same declaration always gives the same answer. */
|
|
11
|
+
export function claimSpecProblem(name, declaration) {
|
|
12
|
+
if (name === "role")
|
|
13
|
+
return "role is the membership's role (auth.tenant.roles); do not declare it as a claim";
|
|
14
|
+
if (!IDENT.test(name))
|
|
15
|
+
return `"${name}" is not a claim name (a lower-case identifier)`;
|
|
16
|
+
if (isSchema(declaration))
|
|
17
|
+
return null;
|
|
18
|
+
if (!plain(declaration))
|
|
19
|
+
return "must be a schema (s.enum, s.string, …) or a claim spec ({ type: \"enum\", values: [...] })";
|
|
20
|
+
if (!isClaimSpec(declaration))
|
|
21
|
+
return `type must be one of ${CLAIM_TYPES.join(", ")}, got ${JSON.stringify(declaration.type)}`;
|
|
22
|
+
const known = new Set(["type", "values", "default"]);
|
|
23
|
+
const extra = Object.keys(declaration).filter((k) => !known.has(k));
|
|
24
|
+
if (extra.length)
|
|
25
|
+
return `unknown member ${extra.map((k) => JSON.stringify(k)).join(", ")} (a claim spec has type, values and default)`;
|
|
26
|
+
if (declaration.type === "enum") {
|
|
27
|
+
const values = declaration.values;
|
|
28
|
+
if (!Array.isArray(values) || !values.length || !values.every((v) => typeof v === "string" && v.length > 0))
|
|
29
|
+
return "an enum claim needs values: a non-empty list of strings";
|
|
30
|
+
if (new Set(values).size !== values.length)
|
|
31
|
+
return "an enum claim lists a value twice";
|
|
32
|
+
}
|
|
33
|
+
else if ("values" in declaration)
|
|
34
|
+
return `only an enum claim has values`;
|
|
35
|
+
if ("default" in declaration && declaration.default !== undefined) {
|
|
36
|
+
const result = claimSchema(declaration).validate(declaration.default);
|
|
37
|
+
if (!result.ok)
|
|
38
|
+
return `the default does not validate: ${result.issues?.[0]?.message ?? "invalid"}`;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/** The schema a claim spec compiles to. */
|
|
43
|
+
export function claimSchema(spec) {
|
|
44
|
+
switch (spec.type) {
|
|
45
|
+
case "enum":
|
|
46
|
+
return s.enum([...spec.values]);
|
|
47
|
+
case "string":
|
|
48
|
+
return s.string();
|
|
49
|
+
case "boolean":
|
|
50
|
+
return s.boolean();
|
|
51
|
+
case "number":
|
|
52
|
+
return s.number();
|
|
53
|
+
case "integer":
|
|
54
|
+
return s.integer();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Compile `auth.tenant.claims` once. Throws TypeError on a declaration `claimSpecProblem` refuses. */
|
|
58
|
+
export function compileClaims(declared) {
|
|
59
|
+
const schemas = {};
|
|
60
|
+
const defaults = {};
|
|
61
|
+
for (const [name, declaration] of Object.entries(declared ?? {})) {
|
|
62
|
+
const problem = claimSpecProblem(name, declaration);
|
|
63
|
+
if (problem)
|
|
64
|
+
throw new TypeError(`auth.tenant.claims.${name}: ${problem}.`);
|
|
65
|
+
if (isSchema(declaration))
|
|
66
|
+
schemas[name] = declaration;
|
|
67
|
+
else {
|
|
68
|
+
schemas[name] = claimSchema(declaration);
|
|
69
|
+
if (declaration.default !== undefined)
|
|
70
|
+
defaults[name] = declaration.default;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { schemas, defaults, names: Object.keys(schemas).sort() };
|
|
74
|
+
}
|
|
75
|
+
/** The claims a membership presents on a call, and each declared claim's provenance. Pure. */
|
|
76
|
+
export function classifyClaims(compiled, stored, storedProvenance = {}) {
|
|
77
|
+
const claims = {};
|
|
78
|
+
const provenance = {};
|
|
79
|
+
for (const name of compiled.names) {
|
|
80
|
+
const origin = storedProvenance[name];
|
|
81
|
+
const who = origin ? { by: origin.by, at: origin.at, via: origin.via } : {};
|
|
82
|
+
if (name in stored && stored[name] !== undefined) {
|
|
83
|
+
const result = compiled.schemas[name].validate(stored[name]);
|
|
84
|
+
if (result.ok) {
|
|
85
|
+
claims[name] = "value" in result ? result.value : stored[name];
|
|
86
|
+
provenance[name] = { status: "verified", ...who };
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
provenance[name] = { status: "invalid", ...who };
|
|
90
|
+
}
|
|
91
|
+
else if (name in compiled.defaults) {
|
|
92
|
+
claims[name] = compiled.defaults[name];
|
|
93
|
+
provenance[name] = { status: "default" };
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
provenance[name] = { status: "unavailable" };
|
|
97
|
+
}
|
|
98
|
+
return { claims, provenance };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.js","sourceRoot":"","sources":["../../src/runtime/claims.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AASjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAuBvF,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAQ,CAA4B,CAAC,QAAQ,KAAK,UAAU,CAAC;AACzH,MAAM,KAAK,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAErI,sHAAsH;AACtH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAK,WAAiC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACvG,CAAC;AAED,MAAM,KAAK,GAAG,0BAA0B,CAAC;AAEzC,yHAAyH;AACzH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,WAAoB;IACjE,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,iFAAiF,CAAC;IAC9G,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,IAAI,iDAAiD,CAAC;IACxF,IAAI,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,WA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/D,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,CAAC;YACpD,CAAC;;gBAAM,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,CAAC;QAC1D,CAAC;aAAM,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACvC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC3C,CAAC;;YAAM,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -9,7 +9,6 @@ export interface EventsWriter {
|
|
|
9
9
|
scope?: string;
|
|
10
10
|
}): void;
|
|
11
11
|
}
|
|
12
|
-
import type { StateFirstDB } from "@feltdb/core";
|
|
13
12
|
import type { AuthContext } from "./authority.js";
|
|
14
13
|
import type { DatabaseReader, DatabaseWriter } from "./data.js";
|
|
15
14
|
import type { ConfigurationReader, ConfigurationWriter, FilesReader, FilesWriter, NotificationsReader, NotificationsWriter, JobsWriter, WebhooksWriter } from "./services.js";
|
|
@@ -93,12 +92,14 @@ export interface MutationCtx {
|
|
|
93
92
|
/** The FeltKit agent, as the caller. */
|
|
94
93
|
readonly agent: AgentWriter;
|
|
95
94
|
/**
|
|
96
|
-
* Escape hatch: this
|
|
97
|
-
* validated, not part of the mutation's transaction, and not shown as the
|
|
98
|
-
*
|
|
95
|
+
* Escape hatch: FeltDB access to this application's own collections. Writes made here are not
|
|
96
|
+
* validated, not part of the mutation's transaction, and not shown as the mutation's writes in
|
|
97
|
+
* the activity log. It reaches only collections the application declares that do not belong to
|
|
98
|
+
* a workspace; platform collections (sessions, accounts, memberships, activity, API keys,
|
|
99
|
+
* configuration) and workspace collections are refused with FORBIDDEN. Prefer ctx.db.
|
|
99
100
|
*/
|
|
100
101
|
readonly unsafe: {
|
|
101
|
-
readonly feltdb:
|
|
102
|
+
readonly feltdb: import("./escape-hatch.js").EscapeHatch;
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
/** What an application agent's handler (`app.agent`) receives: a mutation's context, as the agent, plus its trigger. */
|
package/dist/runtime/contract.js
CHANGED
|
@@ -36,6 +36,7 @@ import { FELTDB_AGENT_STATE_CONTRACT } from "@feltdb/core";
|
|
|
36
36
|
import { SERVICE_NAMES, servicesContract } from "@appport/services";
|
|
37
37
|
import { FeltKitError } from "../errors.js";
|
|
38
38
|
import { ACTIVITY_COLLECTION } from "./activity.js";
|
|
39
|
+
import { AUDIT_COLLECTION } from "./audit.js";
|
|
39
40
|
import { ACCOUNTS_COLLECTION, ACCOUNT_EMAILS_COLLECTION } from "./accounts.js";
|
|
40
41
|
import { CHALLENGES_COLLECTION } from "./challenges.js";
|
|
41
42
|
import { INVITATIONS_COLLECTION, MEMBERSHIPS_COLLECTION, TENANTS_COLLECTION } from "./tenancy.js";
|
|
@@ -57,6 +58,8 @@ const PLATFORM_COLLECTIONS = {
|
|
|
57
58
|
[COLLECTION_MARKERS]: ["transactionId", "changedAt"],
|
|
58
59
|
[SEQUENCES_COLLECTION]: ["name", "value", "transactionId"],
|
|
59
60
|
[MIGRATIONS_COLLECTION]: ["kind", "from", "to", "changes", "migrations", "writes", "appliedAt", "by", "environment"],
|
|
61
|
+
// The audit trail (runtime/audit.ts): one record per committed mutation, in its transaction.
|
|
62
|
+
[AUDIT_COLLECTION]: ["at", "transactionId", "function", "via", "requestId", "principal", "tenantId", "authority", "writes", "effects"],
|
|
60
63
|
[OUTBOX_COLLECTION]: ["requestId", "function", "principalId", "effect", "state", "createdAt", "updatedAt", "attempts", "error", "result", "retriedBy"],
|
|
61
64
|
[ACTIVITY_COLLECTION]: [
|
|
62
65
|
"at", "kind", "name", "capability", "via", "requestId", "principal", "authority", "outcome", "error",
|
|
@@ -70,7 +73,7 @@ const PLATFORM_COLLECTIONS = {
|
|
|
70
73
|
[CHALLENGES_COLLECTION]: ["kind", "purpose", "subject", "nonce", "codeDigest", "expiresAt", "attempts", "data", "current", "issued"],
|
|
71
74
|
// Tenancy (auth.tenant). Invitations hold a nonce; the token is derived with the auth secret.
|
|
72
75
|
[TENANTS_COLLECTION]: ["name", "createdBy", "createdAt", "updatedAt"],
|
|
73
|
-
[MEMBERSHIPS_COLLECTION]: ["tenantId", "principalId", "principalType", "role", "claims", "status", "displayName", "email", "invitedBy", "createdAt", "updatedAt", "lastUsedAt"],
|
|
76
|
+
[MEMBERSHIPS_COLLECTION]: ["tenantId", "principalId", "principalType", "role", "claims", "claimsProvenance", "status", "displayName", "email", "invitedBy", "createdAt", "updatedAt", "lastUsedAt"],
|
|
74
77
|
[INVITATIONS_COLLECTION]: ["tenantId", "email", "role", "claims", "nonce", "invitedBy", "inviterName", "createdAt", "expiresAt", "status", "acceptedBy", "acceptedAt"],
|
|
75
78
|
[IDEMPOTENCY_COLLECTION]: [
|
|
76
79
|
"key", "capability", "version", "requestId", "requestDigest", "sessionId", "principalId", "response",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/runtime/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAE,2BAA2B,EAAwE,MAAM,cAAc,CAAC;AACjI,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,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CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,GAAe;IAC7C,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACzG,MAAM,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAE,aAAmC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,IAAI,OAAO,CAAC,MAAM;QAAE,MAAM,IAAI,YAAY,CAAC,eAAe,EAAE,wDAAwD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/L,OAAO,EAAmB,CAAC;AAC7B,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,cAAc,CAAC,QAAwB;IACrD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
package/dist/runtime/data.d.ts
CHANGED
|
@@ -190,8 +190,6 @@ export declare function newId(): string;
|
|
|
190
190
|
export declare function equalityWhere(filter: Record<string, unknown> | undefined): WhereClause[];
|
|
191
191
|
/** Read-only access. Every collection read is recorded so subscribers can be invalidated. */
|
|
192
192
|
export declare class Reader implements DatabaseReader {
|
|
193
|
-
protected readonly db: StateFirstDB;
|
|
194
|
-
protected readonly resolver: CollectionResolver;
|
|
195
193
|
/** Collections read (a Set of names), with the equality predicates of reads limited to them. */
|
|
196
194
|
readonly reads: ReadSet;
|
|
197
195
|
constructor(db: StateFirstDB, resolver: CollectionResolver);
|
|
@@ -221,6 +219,12 @@ export declare class Writer extends Reader implements DatabaseWriter {
|
|
|
221
219
|
/** Whether this mutation drew from a sequence. */
|
|
222
220
|
get usedSequences(): boolean;
|
|
223
221
|
get pendingCount(): number;
|
|
222
|
+
/** What this mutation will write: collection, id and operation (no values). For the audit record; not on `ctx.db`. */
|
|
223
|
+
pendingWrites(): Array<{
|
|
224
|
+
collection: string;
|
|
225
|
+
id: string;
|
|
226
|
+
op: "insert" | "update" | "delete";
|
|
227
|
+
}>;
|
|
224
228
|
get(ref: CollectionRef, id: string): Promise<any>;
|
|
225
229
|
find(ref: CollectionRef, filter?: Record<string, unknown>, options?: FindOptions): Promise<any[]>;
|
|
226
230
|
/** As `find(...).length`, with the same fence and this mutation's own writes; counted in pages when there are none. */
|
|
@@ -251,3 +255,11 @@ export declare const CONTRACT_CHANGED_HINT = "The request was built for the prev
|
|
|
251
255
|
* stays out of the answer.
|
|
252
256
|
*/
|
|
253
257
|
export declare function feltdbRefusalJSON(error: unknown): FeltKitErrorJSON | null;
|
|
258
|
+
/**
|
|
259
|
+
* What application code holds as `ctx.db`: the documented reader or writer methods, bound to
|
|
260
|
+
* FeltKit's own Reader/Writer, and nothing else. The Writer also carries the runtime's commit
|
|
261
|
+
* machinery (`stageSystem`, `staged`, `commit`): handed to application code, `stageSystem` alone
|
|
262
|
+
* would let a function have FeltKit commit any record into any collection, a session included
|
|
263
|
+
* (test/escape-hatch.test.ts).
|
|
264
|
+
*/
|
|
265
|
+
export declare function applicationView(db: Reader): DatabaseReader | DatabaseWriter;
|