@feltdb/feltkit 0.3.18 → 0.3.19
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
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer's domain model (M8): entities with typed fields, relationships, ownership, scope and
|
|
3
|
+
* constraints, as a developer states them, compiled to what the SDK really supports: `app.collection`
|
|
4
|
+
* shapes (`s.string`, `s.number`, `s.boolean`, `s.enum`, `s.optional`, `s.ref`), `{ tenant: true }`,
|
|
5
|
+
* `unique`, and one function module per entity (list, get, create, update, remove) whose permissions
|
|
6
|
+
* are named and whose ownership rule is explicit. Every line emitted here is application-owned code,
|
|
7
|
+
* written once at creation; the generated tests exercise it for real (permissions, isolation,
|
|
8
|
+
* ownership, uniqueness, references).
|
|
9
|
+
*
|
|
10
|
+
* Nothing here is a schema feature the SDK lacks: references are enforced by FeltDB when the
|
|
11
|
+
* application's schema is active (s.ref), uniqueness at commit, tenancy on every read and write.
|
|
12
|
+
*/
|
|
13
|
+
export type FieldType = "string" | "number" | "boolean" | "enum";
|
|
14
|
+
/**
|
|
15
|
+
* How the foundation groups people and data: `workspaces` (collaborative-workspace: tenants, memberships,
|
|
16
|
+
* invitations) or `individuals` (individual-accounts: each account on its own). Decides which entity scopes
|
|
17
|
+
* exist and how ownership is judged (a workspace role, or the account's own roles).
|
|
18
|
+
*/
|
|
19
|
+
export type Tenancy = "workspaces" | "individuals";
|
|
20
|
+
export interface Field {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly type: FieldType;
|
|
23
|
+
readonly required: boolean;
|
|
24
|
+
/** For enum. */
|
|
25
|
+
readonly values?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** Many-to-one: this entity's `field` holds the id of a `target` record (s.ref; FeltDB restricts deletes of referenced records). */
|
|
28
|
+
export interface Relation {
|
|
29
|
+
readonly field: string;
|
|
30
|
+
readonly target: string;
|
|
31
|
+
readonly required: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface Entity {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly description?: string;
|
|
36
|
+
/**
|
|
37
|
+
* workspace: { tenant: true }, scoped on every read and write (workspaces only). personal: each person's own
|
|
38
|
+
* records; list, get, update and remove see only the caller's (individuals only; always owned). shared:
|
|
39
|
+
* visible to every signed-in caller with the permission.
|
|
40
|
+
*/
|
|
41
|
+
readonly scope: "workspace" | "shared" | "personal";
|
|
42
|
+
/** createdBy is stamped on create; only the creator, or a manager role, may update or remove. */
|
|
43
|
+
readonly owned: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Shared entities only: list and get are `access: "public"` (anyone, signed in or not, reads); every write still
|
|
46
|
+
* needs its permission. An explicit declaration, never a default.
|
|
47
|
+
*/
|
|
48
|
+
readonly public?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Files attach to this entity's records (services.files). Seeing a record's files is reading the record; attaching and
|
|
51
|
+
* detaching is changing it (the same ownership rule as update). A file is bound to its record by metadata the functions
|
|
52
|
+
* fix at upload and check on every read: the Files service itself is application-wide (any files.read reads any file),
|
|
53
|
+
* so the binding is the generated functions', not the service's.
|
|
54
|
+
*/
|
|
55
|
+
readonly attachments?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* A membership claim gate (workspaces only, workspace-scoped entities): every function of the entity first requires
|
|
58
|
+
* the caller's membership to present `claim` (declared in workspace.tenancy.claims, set through the server, valid under
|
|
59
|
+
* the declaration now) with one of `values` (app.requireClaim). A permission without the claim is refused (FORBIDDEN).
|
|
60
|
+
*/
|
|
61
|
+
readonly requires?: {
|
|
62
|
+
readonly claim: string;
|
|
63
|
+
readonly values: readonly (string | number | boolean)[];
|
|
64
|
+
};
|
|
65
|
+
readonly fields: readonly Field[];
|
|
66
|
+
readonly relations: readonly Relation[];
|
|
67
|
+
/** Unique constraints: each a set of field names. */
|
|
68
|
+
readonly unique: ReadonlyArray<readonly string[]>;
|
|
69
|
+
}
|
|
70
|
+
import { type ClaimSpec } from "../runtime/claims.js";
|
|
71
|
+
export declare const IDENT: RegExp;
|
|
72
|
+
/** Fields the generator adds or FeltKit reserves. */
|
|
73
|
+
export declare const RESERVED_FIELDS: ReadonlySet<string>;
|
|
74
|
+
export declare class DomainError extends Error {
|
|
75
|
+
readonly hint: string;
|
|
76
|
+
constructor(message: string, hint: string);
|
|
77
|
+
}
|
|
78
|
+
/** `title:string, done:boolean, due:number?, status:enum(open|closed)` */
|
|
79
|
+
export declare function parseFields(text: string): Field[];
|
|
80
|
+
/**
|
|
81
|
+
* Membership claims as plain data: `plan:enum(free|pro), seats:integer=1, region:string` → claim specs
|
|
82
|
+
* (workspace.tenancy.claims). Types: string, number, integer, boolean, enum(a|b); `=value` is the declaration's default.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseClaims(text: string): Record<string, ClaimSpec>;
|
|
85
|
+
/** `plan=pro|enterprise` against the declared claims → a gate, its values typed by the claim's declaration. */
|
|
86
|
+
export declare function parseRequire(text: string, claims: Readonly<Record<string, ClaimSpec>>): {
|
|
87
|
+
claim: string;
|
|
88
|
+
values: Array<string | number | boolean>;
|
|
89
|
+
};
|
|
90
|
+
/** `project -> projects, assignee -> people?` */
|
|
91
|
+
export declare function parseRelations(text: string): Relation[];
|
|
92
|
+
/** `name; projectId,title` → [["name"], ["projectId","title"]] */
|
|
93
|
+
export declare function parseUnique(text: string): string[][];
|
|
94
|
+
/**
|
|
95
|
+
* Consistency across entities: every scope exists in the foundation, every relationship targets a declared
|
|
96
|
+
* entity and does not reach from wider to narrower data, every unique field exists, names are distinct.
|
|
97
|
+
*/
|
|
98
|
+
export declare function validateEntities(entities: readonly Entity[], tenancy?: Tenancy, claims?: Readonly<Record<string, ClaimSpec>>): void;
|
|
99
|
+
/** Entities ordered so that a relationship's target comes before the entity that refers to it (for tests that create records). */
|
|
100
|
+
export declare function creationOrder(entities: readonly Entity[]): Entity[];
|
|
101
|
+
/** The `app.collection(...)` declaration for an entity, for feltkit/app.ts. */
|
|
102
|
+
export declare function renderCollection(e: Entity, noun: string, tenancy?: Tenancy): string[];
|
|
103
|
+
/** The permissions an entity's functions name: <entity>.read, .create, .update, .delete. */
|
|
104
|
+
export declare const PERMISSIONS: readonly ["read", "create", "update", "delete"];
|
|
105
|
+
/**
|
|
106
|
+
* The roles that may change another member's owned record.
|
|
107
|
+
*
|
|
108
|
+
* With workspaces the top role always manages: the composition's `workspace.tenancy.managers` names the roles that
|
|
109
|
+
* manage *besides* the top one (the interview asks "which roles manage members without being the <top>"), so the
|
|
110
|
+
* effective set is the top role followed by the declared managers. With individuals there is no implicit manager and
|
|
111
|
+
* only the declared roles manage.
|
|
112
|
+
*
|
|
113
|
+
* One function, called by the entity modules and by the generated tests, because when those two derive the set
|
|
114
|
+
* separately they can disagree: they did, and the generated application's own test suite failed for a single-role
|
|
115
|
+
* workspace with no declared manager — the module let the sole role change anyone's record while the test asserted
|
|
116
|
+
* FORBIDDEN (Level B case `c_004a8472da66a7`).
|
|
117
|
+
*/
|
|
118
|
+
export declare function managingRoles(roles: readonly string[], declaredManagers: readonly string[], tenancy?: Tenancy): string[];
|
|
119
|
+
/**
|
|
120
|
+
* One function module per entity: list, get, create, update, remove, each naming its permission.
|
|
121
|
+
* `managers` are the roles that may update or remove any record of an owned entity that is not personal:
|
|
122
|
+
* workspace roles (judged on the caller's membership) with workspaces, the account's own roles otherwise. Callers
|
|
123
|
+
* derive it with `managingRoles`, never by hand, so the modules and the generated tests cannot disagree.
|
|
124
|
+
* A personal entity is the creator's alone: every function sees only the caller's own records.
|
|
125
|
+
*/
|
|
126
|
+
export declare function renderEntityModule(e: Entity, noun: string, managers: readonly string[], tenancy?: Tenancy): string;
|
|
127
|
+
/** feltkit/_generated/api.ts for the app module plus one module per entity (what `feltkit codegen` would write). */
|
|
128
|
+
export declare function renderApi(entityNames: readonly string[]): string;
|
|
129
|
+
export interface DomainTestContext {
|
|
130
|
+
/** Workspace roles, highest first (the first creates the workspace; the last is the reader). With individuals: the application's roles beyond the base one. */
|
|
131
|
+
readonly roles: readonly string[];
|
|
132
|
+
readonly managers: readonly string[];
|
|
133
|
+
readonly noun: string;
|
|
134
|
+
/** Default workspaces. */
|
|
135
|
+
readonly tenancy?: Tenancy;
|
|
136
|
+
/** With individuals: the role every account holds (identity.accounts.baseRole). */
|
|
137
|
+
readonly baseRole?: string;
|
|
138
|
+
/** The declared membership claims (workspace.tenancy.claims), for entities that require one. */
|
|
139
|
+
readonly claims?: Readonly<Record<string, ClaimSpec>>;
|
|
140
|
+
/** Who may create a workspace (workspace.tenancy.create). With "none" the tests provision one (createTestApp().provisionTenant). */
|
|
141
|
+
readonly create?: "anyone" | "none";
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* tests/domain.test.ts: for every entity, the permissions, isolation, ownership, uniqueness and
|
|
145
|
+
* references the composition claims, driven through the real runtime. Application-owned once written.
|
|
146
|
+
*/
|
|
147
|
+
export declare function renderDomainTests(entities: readonly Entity[], context: DomainTestContext): string;
|
|
148
|
+
export interface FoundationTestContext {
|
|
149
|
+
readonly noun: string;
|
|
150
|
+
/** Workspace roles as declared; with individuals, the application's roles beyond the base one. */
|
|
151
|
+
readonly roles: readonly string[];
|
|
152
|
+
readonly signUp: boolean;
|
|
153
|
+
readonly magicLink: boolean;
|
|
154
|
+
readonly create: "anyone" | "none";
|
|
155
|
+
/** Default workspaces. */
|
|
156
|
+
readonly tenancy?: Tenancy;
|
|
157
|
+
/** With individuals: the role every account holds. */
|
|
158
|
+
readonly baseRole?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* tests/foundation.test.ts, from the composition itself: what the accounts and workspace selections
|
|
162
|
+
* guarantee (open or closed sign-up, who may create a workspace, the declared roles), as executable
|
|
163
|
+
* checks against the real runtime. Application-owned once written.
|
|
164
|
+
*/
|
|
165
|
+
export declare function renderFoundationTests(c: FoundationTestContext): string;
|
|
166
|
+
/**
|
|
167
|
+
* tests/files.test.ts: for every entity with attachments, the file boundary follows the record boundary, through the
|
|
168
|
+
* real runtime and the real Files service: the creator attaches, lists and gets a download link; a caller who cannot
|
|
169
|
+
* see the record (another workspace, another person) gets NOT_FOUND from files and download; a file of another record
|
|
170
|
+
* does not exist on this one; a reader role lists and cannot attach or detach; an anonymous caller is UNAUTHORIZED
|
|
171
|
+
* (unless the entity is public, when reads are open and writes still refused); detaching removes the file; removing the
|
|
172
|
+
* record removes its files. Application-owned once written.
|
|
173
|
+
*/
|
|
174
|
+
export declare function renderFilesTests(entities: readonly Entity[], context: DomainTestContext): string;
|